@open-mercato/cezar 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/automations/github-poller.d.ts +8 -1
- package/dist/automations/github-poller.js +78 -13
- package/dist/automations/github-poller.js.map +1 -1
- package/dist/automations/pr-head.js +15 -1
- package/dist/automations/pr-head.js.map +1 -1
- package/dist/automations/prompts.js +2 -2
- package/dist/automations/types.d.ts +10 -0
- package/dist/automations/types.js +12 -1
- package/dist/automations/types.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.js +6 -0
- package/dist/config.js.map +1 -1
- package/dist/contract/automations.d.ts +31 -1
- package/dist/contract/index.d.ts +1 -0
- package/dist/contract/index.js +161 -17
- package/dist/contract/projects.d.ts +46 -0
- package/dist/contract/runs.d.ts +15 -0
- package/dist/contract/skills.d.ts +1 -0
- package/dist/contract/telemetry.d.ts +124 -0
- package/dist/contract/workspace.d.ts +3 -0
- package/dist/core/cursor-agent-runner.d.ts +11 -0
- package/dist/core/cursor-agent-runner.js +48 -4
- package/dist/core/cursor-agent-runner.js.map +1 -1
- package/dist/core/disclaim-spawn.d.ts +10 -0
- package/dist/core/disclaim-spawn.js +105 -8
- package/dist/core/disclaim-spawn.js.map +1 -1
- package/dist/git-diff-base.js +26 -19
- package/dist/git-diff-base.js.map +1 -1
- package/dist/git-remotes.d.ts +43 -0
- package/dist/git-remotes.js +127 -0
- package/dist/git-remotes.js.map +1 -0
- package/dist/git-worktree.d.ts +43 -19
- package/dist/git-worktree.js +138 -54
- package/dist/git-worktree.js.map +1 -1
- package/dist/index.js +46 -6
- package/dist/index.js.map +1 -1
- package/dist/runs/auto-name.d.ts +17 -0
- package/dist/runs/auto-name.js +47 -2
- package/dist/runs/auto-name.js.map +1 -1
- package/dist/runs/event-history.d.ts +10 -2
- package/dist/runs/event-history.js +290 -120
- package/dist/runs/event-history.js.map +1 -1
- package/dist/runs/retention.js +1 -1
- package/dist/runs/retention.js.map +1 -1
- package/dist/runs/store.d.ts +16 -3
- package/dist/runs/store.js +89 -10
- package/dist/runs/store.js.map +1 -1
- package/dist/server/checkout.d.ts +4 -0
- package/dist/server/checkout.js +9 -5
- package/dist/server/checkout.js.map +1 -1
- package/dist/server/create-project.d.ts +77 -0
- package/dist/server/create-project.js +342 -0
- package/dist/server/create-project.js.map +1 -0
- package/dist/server/forge/github.d.ts +2 -0
- package/dist/server/forge/github.js +32 -10
- package/dist/server/forge/github.js.map +1 -1
- package/dist/server/forge/index.d.ts +1 -12
- package/dist/server/forge/index.js +7 -29
- package/dist/server/forge/index.js.map +1 -1
- package/dist/server/forge/types.d.ts +2 -0
- package/dist/server/git-changes.d.ts +15 -0
- package/dist/server/git-changes.js +51 -1
- package/dist/server/git-changes.js.map +1 -1
- package/dist/server/git.d.ts +3 -2
- package/dist/server/git.js +4 -3
- package/dist/server/git.js.map +1 -1
- package/dist/server/project-context.js +1 -1
- package/dist/server/project-context.js.map +1 -1
- package/dist/server/server.d.ts +609 -302
- package/dist/server/server.js +191 -12
- package/dist/server/server.js.map +1 -1
- package/dist/server/star-count.d.ts +27 -11
- package/dist/server/star-count.js +57 -28
- package/dist/server/star-count.js.map +1 -1
- package/dist/telemetry-cli.d.ts +10 -0
- package/dist/telemetry-cli.js +54 -0
- package/dist/telemetry-cli.js.map +1 -0
- package/dist/telemetry-service.json +1 -0
- package/dist/telemetry.d.ts +79 -0
- package/dist/telemetry.js +453 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/workflows/run.d.ts +28 -0
- package/dist/workflows/run.js +111 -16
- package/dist/workflows/run.js.map +1 -1
- package/dist/workspace/config.d.ts +10 -0
- package/dist/workspace/config.js +16 -0
- package/dist/workspace/config.js.map +1 -1
- package/dist/workspace/projects-cli.js +3 -0
- package/dist/workspace/projects-cli.js.map +1 -1
- package/package.json +3 -3
- package/scripts/mock-claude.mjs +32 -17
- package/scripts/stamp-telemetry-service.mjs +20 -0
- package/web/dist/assets/agent-task-pickers-mJzYn0UB.js +1 -0
- package/web/dist/assets/{alert-dialog-CF_-dmQ1.js → alert-dialog-Dd1WPOaz.js} +1 -1
- package/web/dist/assets/arrow-left-fsST4JqT.js +1 -0
- package/web/dist/assets/{automation-format-D1nqk0ID.js → automation-format-BTIFWfjt.js} +1 -1
- package/web/dist/assets/automations-route-DJjhwqug.js +1 -0
- package/web/dist/assets/button-BNnH7COh.js +100 -0
- package/web/dist/assets/{centered-state-T0J7VmBb.js → centered-state-sEYB3bgq.js} +1 -1
- package/web/dist/assets/check-DA37PQLT.js +1 -0
- package/web/dist/assets/chevron-left-zbXV2Qbu.js +1 -0
- package/web/dist/assets/chevron-right-Beu1pd6H.js +1 -0
- package/web/dist/assets/{collapsible-RD4hkew7.js → collapsible-MuXfYnM8.js} +1 -1
- package/web/dist/assets/commit-list-Bps23fvP.js +1 -0
- package/web/dist/assets/compare-variants-CQskdfDW.js +1 -0
- package/web/dist/assets/composer-DKWLJeo9.js +18 -0
- package/web/dist/assets/dashboard-BCNe_6p7.js +44 -0
- package/web/dist/assets/diff-CrLUECGW.js +3 -0
- package/web/dist/assets/{diff-stat-CFoeFye2.js → diff-stat-SpfygteL.js} +1 -1
- package/web/dist/assets/diff-view-DP4Gw3QJ.js +13 -0
- package/web/dist/assets/{download-BFQEsJRY.js → download-CBwSbmy_.js} +1 -1
- package/web/dist/assets/dropdown-menu-CxPGHgWX.js +1 -0
- package/web/dist/assets/ellipsis-BmusVE8U.js +1 -0
- package/web/dist/assets/{file-Df5WtpM_.js → file-DkvcUwxT.js} +1 -1
- package/web/dist/assets/file-preview-DxFusXAO.js +2 -0
- package/web/dist/assets/file-text-DBeC0yKb.js +1 -0
- package/web/dist/assets/file-tree-BTJZXRkM.js +1 -0
- package/web/dist/assets/{git-commit-horizontal-DawNm4qg.js → git-commit-horizontal-BM9_nEW7.js} +1 -1
- package/web/dist/assets/git-toolbar-DXyPCDkQ.js +1 -0
- package/web/dist/assets/github-G5fU4gJd.js +1 -0
- package/web/dist/assets/index-BN3w52uE.js +21 -0
- package/web/dist/assets/index-CAvSSpvF.css +2 -0
- package/web/dist/assets/{markdown-Bmfy_1Ll.js → markdown-BpZ4p95p.js} +1 -1
- package/web/dist/assets/{markdown-B_O1ys3h.js → markdown-C5F95Rt-.js} +1 -1
- package/web/dist/assets/{message-square-BOO9s3qX.js → message-square-BFQln9c4.js} +1 -1
- package/web/dist/assets/{pill-bO5OcHuK.js → pill-BcIQGDbn.js} +1 -1
- package/web/dist/assets/project-router-CWMOKp_H.js +3 -0
- package/web/dist/assets/reference-chip-B7lU_Pyh.js +1 -0
- package/web/dist/assets/reference-overflow-ClRRXWez.js +1 -0
- package/web/dist/assets/{refresh-cw-BaFyjVUz.js → refresh-cw-BBEYC6z2.js} +1 -1
- package/web/dist/assets/repo-git-CgxxZ7cO.js +1 -0
- package/web/dist/assets/{run-diff-GZbNs8fA.js → run-diff-BTB7nBeD.js} +1 -1
- package/web/dist/assets/run-header-BPNBEaOy.js +1 -0
- package/web/dist/assets/{image-preview-4SVDrBvn.js → scroll-within-DRt7mAnQ.js} +1 -1
- package/web/dist/assets/{search-x-bpAfQtVY.js → search-x-6BavY3mg.js} +1 -1
- package/web/dist/assets/sheet-D9PeyyRZ.js +1 -0
- package/web/dist/assets/skills-SIMzpL0l.js +1 -0
- package/web/dist/assets/square-DsFAQaY9.js +1 -0
- package/web/dist/assets/tab-link-DEUSZU49.js +1 -0
- package/web/dist/assets/{tag-DLwUkUsN.js → tag-DvCVnA6I.js} +1 -1
- package/web/dist/assets/task-changes-D-aajoMU.js +1 -0
- package/web/dist/assets/task-commits-BYD1GVkS.js +1 -0
- package/web/dist/assets/task-composer-7bdNNMP_.js +12 -0
- package/web/dist/assets/task-files-BfIOz-eN.js +1 -0
- package/web/dist/assets/task-graph-B5-5_IPh.js +1 -0
- package/web/dist/assets/task-notes-CfkTBgo8.js +1 -0
- package/web/dist/assets/task-thread-eEkjTDxr.js +10 -0
- package/web/dist/assets/{terminal-CwrL1hAi.js → terminal-xRHwWarr.js} +1 -1
- package/web/dist/assets/textarea-rKUFh5lI.js +1 -0
- package/web/dist/assets/thread-loading-DLlbK51g.js +1 -0
- package/web/dist/assets/{token-metrics-C149OWmd.js → token-metrics-BcPjL36-.js} +1 -1
- package/web/dist/assets/tooltip-BVqBAGNb.js +1 -0
- package/web/dist/assets/tracker-2DfMzsIE.js +4 -0
- package/web/dist/assets/triangle-alert-CP3Xp0FU.js +1 -0
- package/web/dist/assets/upload-bwO_2kok.js +1 -0
- package/web/dist/assets/use-automations-PceYR6ss.js +5 -0
- package/web/dist/assets/use-now-BAKdIYLG.js +1 -0
- package/web/dist/assets/use-submit-shortcut-BA4NVpJl.js +1 -0
- package/web/dist/assets/workflow-graph-HopaWPea.js +13 -0
- package/web/dist/assets/x-HaVPcg_B.js +1 -0
- package/web/dist/index.html +28 -31
- package/web/dist/assets/agent-task-pickers-C3ydGatB.js +0 -1
- package/web/dist/assets/arrow-left-BxBdc5DC.js +0 -1
- package/web/dist/assets/automations-route-BsflncpV.js +0 -1
- package/web/dist/assets/button-CjSjKnkd.js +0 -100
- package/web/dist/assets/check-DAAMuI4o.js +0 -1
- package/web/dist/assets/chevron-left-CvcqxpQZ.js +0 -1
- package/web/dist/assets/chevron-right-DKiL3NWw.js +0 -1
- package/web/dist/assets/commit-list-BJac2uO6.js +0 -1
- package/web/dist/assets/compare-variants-CfqICvRy.js +0 -1
- package/web/dist/assets/composer-DZx3cwQW.js +0 -18
- package/web/dist/assets/dashboard-CpCDiZdE.js +0 -44
- package/web/dist/assets/diff-LG2cl0PE.js +0 -3
- package/web/dist/assets/diff-controls-QgdH-r3F.js +0 -1
- package/web/dist/assets/diff-view-BVwSaBb2.js +0 -13
- package/web/dist/assets/dropdown-menu-DkEK7m00.js +0 -1
- package/web/dist/assets/editable-title-CJSWyCcL.js +0 -1
- package/web/dist/assets/ellipsis-vertical-CB0adfr7.js +0 -1
- package/web/dist/assets/external-link-DPKRidDg.js +0 -1
- package/web/dist/assets/eye-CEHQ0c-s.js +0 -1
- package/web/dist/assets/file-preview-kYsqZiLU.js +0 -2
- package/web/dist/assets/file-text-m0tZu8sU.js +0 -1
- package/web/dist/assets/git-merge-B7oVXcKc.js +0 -1
- package/web/dist/assets/git-toolbar-B0K4Q5Zv.js +0 -1
- package/web/dist/assets/github-C4WaHPni.js +0 -1
- package/web/dist/assets/index-CiQrbvAq.js +0 -21
- package/web/dist/assets/index-WWaEax-B.css +0 -2
- package/web/dist/assets/pencil-CCR9uUZ1.js +0 -1
- package/web/dist/assets/reference-chip-Bx_mG9QG.js +0 -1
- package/web/dist/assets/repo-git-Mn3_jrGP.js +0 -1
- package/web/dist/assets/run-header-i1D5Lvfs.js +0 -1
- package/web/dist/assets/sheet-DCdZVHFk.js +0 -1
- package/web/dist/assets/skills-Dea5ynJK.js +0 -1
- package/web/dist/assets/tab-link-BVItTl_Y.js +0 -1
- package/web/dist/assets/task-changes-xNbBM7FO.js +0 -1
- package/web/dist/assets/task-commits-BYozE_X3.js +0 -1
- package/web/dist/assets/task-composer-Brx0sa7_.js +0 -12
- package/web/dist/assets/task-files-MAPO-efK.js +0 -1
- package/web/dist/assets/task-graph-BSLCUr1E.js +0 -1
- package/web/dist/assets/task-thread-CRVmwchQ.js +0 -9
- package/web/dist/assets/textarea-Bb0_Hz53.js +0 -1
- package/web/dist/assets/thread-loading-Bo6IOu3Y.js +0 -1
- package/web/dist/assets/toaster-Hj_czp_o.js +0 -3
- package/web/dist/assets/tooltip--PYfu68E.js +0 -1
- package/web/dist/assets/tracker-DM5WtYD0.js +0 -4
- package/web/dist/assets/trash-2-EdjdGvEo.js +0 -1
- package/web/dist/assets/triangle-alert-DpH3QFz6.js +0 -1
- package/web/dist/assets/use-automations-XKvBTPM-.js +0 -5
- package/web/dist/assets/use-now-CrM50BFB.js +0 -1
- package/web/dist/assets/use-submit-shortcut-BJ10ZshV.js +0 -1
- package/web/dist/assets/workflow-graph-Y2Pr7ubb.js +0 -13
- package/web/dist/assets/x-BkwTUDpG.js +0 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{S as r,Yt as i,Zr as a,aa as o,f as s,h as c,mt as l,zt as ee}from"./project-router-CWMOKp_H.js";import{F as u,ht as d,r as f,t as p}from"./button-BNnH7COh.js";import{K as te,a as ne,o as re,s as ie}from"./reference-overflow-ClRRXWez.js";import{a as ae,i as oe,r as se}from"./reference-chip-B7lU_Pyh.js";import{t as ce}from"./check-DA37PQLT.js";import{t as le}from"./x-HaVPcg_B.js";import{t as ue}from"./use-submit-shortcut-BA4NVpJl.js";import{t as de}from"./square-DsFAQaY9.js";import{c as fe,n as pe,s as me,t as m}from"./use-now-BAKdIYLG.js";var he=u(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),ge=u(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),_e=u(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),h=e(t(),1),ve=new Set([`ai`,`cezar`,`agents`,`team`]);function g(e){return ve.has(e.source)}function _(e){return[...e].sort((e,t)=>Number(!g(e))-Number(!g(t)))}var v=5;function y(e,t,{mostUsedLimit:n=v}={}){let r=e.map((e,n)=>({skill:e,index:n,count:x(t,e.name)})).filter(e=>e.count>0).sort((e,t)=>t.count-e.count||Number(!g(e.skill))-Number(!g(t.skill))||e.index-t.index).slice(0,n).map(e=>e.skill),i=new Set(r),a=e.filter(e=>!i.has(e));return{mostUsed:r,project:a.filter(g),global:a.filter(e=>!g(e))}}function b(e,t){let n=y(e,t);return[...n.mostUsed,...n.project,...n.global]}function x(e,t){if(!e||!Object.hasOwn(e,t))return 0;let n=e[t];return typeof n==`number`?n:0}function ye(e,t){return{...e,[t]:x(e,t)+1}}function be(e,t){if(t===``)return!0;let n=e.toLowerCase(),r=t.toLowerCase(),i=0;for(let e of r){if(i=n.indexOf(e,i),i===-1)return!1;i+=1}return!0}function xe(e,t){let n=[];for(let r of e)for(let e of r.steps??[])e.skill===t&&n.push(`${r.name} › ${e.name??e.id}`);return n}var S=/[\s\-/_.]/;function Se(e,t){let n=0;for(let r=e.indexOf(t);r!==-1;r=e.indexOf(t,r+1)){let i=1,a=e[r-1];if(r===0||a!==void 0&&S.test(a)){let n=e[r+t.length];i=n===void 0||S.test(n)?3:2}if(i>n&&(n=i),n===3)break}return n}function C(e,t,n){let r=t.toLowerCase().split(/\s+/).filter(Boolean);if(r.length===0)return 1;let i=[e,...n??[]].join(` `).toLowerCase(),a=0;for(let e of r){let t=Se(i,e);if(t===0)return 0;a+=t}return a/(r.length*3)}function Ce(e,t){if(t===``)return 1;let n=e.toLowerCase(),r=t.toLowerCase();if(n===r)return 6;if(n.startsWith(r))return 5;let i=n.indexOf(r);if(i>0){let e=n[i-1];return e!==void 0&&S.test(e)?4:3}return+!!be(n,r)}function we(e,t){let n=e.split(`-`).filter(Boolean);return t?[...n,t]:n}var Te=10;function w(e,t,n){let r=n.toLowerCase().split(/\s+/).filter(Boolean);if(r.length===0)return 1;let i=0;for(let n of r){let r=Ce(e,n),a=t?Ce(t,n):0;if(r===0&&a===0)return 0;i+=r>0?r+Te:a}return i}var T=.5;function E(e,t,n){return t.trim()===``?[...e]:e.map((e,r)=>{let i=w(e.name,e.description,t),a=x(n,e.name),o=Math.min(a,v)*T;return{item:e,index:r,count:a,score:i>0?i+o:0}}).filter(e=>e.score>0).sort((e,t)=>t.score-e.score||t.count-e.count||e.index-t.index).map(e=>e.item)}function D(e,t,n){return E(e,t,n)}function Ee(e,t){return E(e,t)}function De(e,t,n){return E(b(e,n),t,n)}function O(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable?!0:e.closest(`[contenteditable=""], [contenteditable="true"]`)!==null}function Oe(e){return e instanceof HTMLElement&&e.closest(`[cmdk-input]`)!==null}function k(e,t){return!(typeof e.key!=`string`||e.key.toLowerCase()!==t.toLowerCase()||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey||e.repeat||O(e.target)&&!Oe(e.target))}function A(e,t){let n=h.useRef(t);h.useLayoutEffect(()=>{n.current=t}),h.useEffect(()=>{let t=t=>{k(t,e)&&(t.preventDefault(),n.current(t))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function j(e,t){return!(typeof e.key!=`string`||e.key.toLowerCase()!==t.toLowerCase()||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.repeat||O(e.target))}function M(e,t=typeof navigator>`u`?``:navigator.platform){let n=e.toUpperCase();return/mac|iphone|ipad|ipod/i.test(t)?`⌘${n}`:`Ctrl+${n}`}function N(e,t){let n=h.useRef(t);h.useLayoutEffect(()=>{n.current=t}),h.useEffect(()=>{let t=t=>{j(t,e)&&n.current(t)};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function P(){let e=r(),t=l(),n=(e.data?.profiles??[]).map(e=>({provider:e.provider,id:e.id,label:e.label,configDir:e.configDir})),i=t.data?.info?.root;return{accounts:n,repoAccount:F(i?e.data?.selections?.[i]:void 0,e.data?.defaults)}}function F(e,t){let n={};for(let r of[t,e])for(let[e,t]of Object.entries(r??{}))t&&(n[e]=t);return Object.keys(n).length>0?n:void 0}function I(e,t){return e.filter(e=>e.provider===t).length>1}var L=80,R=d,ke=50,Ae=200,z=50,B=[{id:`add-tests`,label:`Add tests`,text:`Also add or update tests covering this change.`},{id:`explain-change`,label:`Explain the change`,text:`Explain what changed and why before finishing.`},{id:`keep-minimal`,label:`Keep it minimal`,text:`Keep the change as small and targeted as possible — no unrelated refactors.`},{id:`update-docs`,label:`Update docs`,text:`Also update any relevant documentation or comments.`},{id:`check-edge-cases`,label:`Double-check edge cases`,text:`Double-check edge cases and error handling before finishing.`},{id:`review-open-prs`,label:`Review open PRs`,text:'Check this repository\'s open pull requests that still need a review (use `gh pr list --state open --json number,title,headRefName,isDraft,reviewDecision` and skip drafts and PRs already approved). For each one, dispatch a separate review task with `cez task create --kind review --review-of <headRefName> --title "Review PR #<number>" "Review pull request #<number> (<title>) on branch <headRefName>: read the diff, run the tests, and report a verdict with findings."`, at most 4 at a time. Then end your turn with CEZ:MONITORING and, when their reports arrive, summarise every verdict in one message. If `cez task create` is refused or unavailable, stop and report that dispatch is disabled on this cockpit — do not review the PRs yourself and do not use sub-agents instead.'},{id:`create-automation`,label:`Create an automation`,skills:[`create-cezar-automation`],text:`Create an automation for this repository.
|
|
2
|
+
Trigger: <when — e.g. every new pull request; every issue labelled \`needs-agent\`; every day at 04:00; weekdays at 07:30; every 6 hours>.
|
|
3
|
+
Task for each run: <what the launched task must do — e.g. review the diff, run the tests and post findings as a review comment>.
|
|
4
|
+
Leave it paused and, for a GitHub trigger, preview its matches so I can check the filter before enabling it.`}],V=new Set([`review-open-prs`]),H=new Set([`create-automation`]);function U(e,t){return e.filter(e=>(t?.dispatch===!0||!V.has(e.id))&&(t?.automations===!0||!H.has(e.id)))}function W(e){return!!e&&typeof e==`object`}function je(e){if(e===void 0||!Array.isArray(e))return B.map(e=>({...e}));let t=new Set,n=[];for(let r of e){if(!W(r))continue;let e=typeof r.id==`string`?r.id.trim():``,i=typeof r.label==`string`?r.label.trim():``,a=typeof r.text==`string`?r.text.trim():``;if(!e||!i||!a||t.has(e))continue;t.add(e);let o=G(r.skills);if(n.push({id:e,label:i.slice(0,L),text:a.slice(0,R),...o.length>0?{skills:o}:{}}),n.length>=ke)break}return n}function G(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();if(!(!e||t.has(e))&&(t.add(e.slice(0,Ae)),t.size>=z))break}return[...t]}function Me(e,t){if(t.length===0)return[];let n=new Set(t);return e.filter(e=>e.skills?.some(e=>n.has(e)))}function K(e,t){return Me(e,t).map(e=>e.text).join(`
|
|
5
|
+
|
|
6
|
+
`)}function q(e,t,n,r=``){if(e===``||e===r||e===t){let e=r&&n?`${r}\n\n${n}`:r||n;return{text:e,applied:n?e:``}}return{text:e,applied:t}}function J(){return`tpl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Ne(e,t,n){let r=Math.max(0,Math.min(t,e.length)),i=e.slice(0,r),a=e.slice(r),o=``;i.length>0&&(o=i.endsWith(`
|
|
7
|
+
|
|
8
|
+
`)?``:i.endsWith(`
|
|
9
|
+
`)?`
|
|
10
|
+
`:`
|
|
11
|
+
|
|
12
|
+
`);let s=a.replace(/^[ \t]+/,``),c=``;return s.length>0&&(c=s.startsWith(`
|
|
13
|
+
|
|
14
|
+
`)?``:s.startsWith(`
|
|
15
|
+
`)?`
|
|
16
|
+
`:`
|
|
17
|
+
|
|
18
|
+
`),{text:i+o+n+c+s,caret:i.length+o.length+n.length}}var Y=new Set([`/`,`@`]);function Pe(e,t){for(let n=t-1;n>=0;--n){let r=e[n];if(/\s/.test(r))return null;if(Y.has(r))return n>0&&!/\s/.test(e[n-1])?null:{trigger:r,start:n,query:e.slice(n+1,t)}}return null}function Fe(e,t,n,r){let i=`${t.trigger}${r} `;return{text:e.slice(0,t.start)+i+e.slice(n),caret:t.start+i.length}}function X(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition}function Z(e,t){let n=e,r=``;for(let e=t.resultIndex;e<t.results.length;e+=1){let i=t.results[e],a=i[0]?.transcript??``;i.isFinal?n+=a:r+=a}return{finalText:n,interim:r}}function Ie(e){let[t,n]=h.useState(null),r=h.useRef(null),i=h.useRef(``),[a]=h.useState(()=>X()!==void 0),o=h.useCallback(()=>{let e=r.current;r.current=null,i.current=``,n(null),e&&(e.onresult=null,e.onerror=null,e.onend=null,e.abort())},[]);return h.useEffect(()=>o,[o]),{supported:a,recording:t,start:h.useCallback(()=>{if(r.current)return;let t=X();if(!t)return;let a;try{a=new t,a.lang=navigator.language||`en-US`,a.continuous=!0,a.interimResults=!0;let s=Date.now();a.onresult=e=>{let t=Z(i.current,e);i.current=t.finalText,n({transcript:t.finalText+t.interim,startedAt:s})},a.onerror=t=>{e(`Dictation failed${t.error?` — ${t.error}`:``}`),o()},a.start(),r.current=a,n({transcript:``,startedAt:s})}catch{e(`Dictation failed — the microphone could not be started`),o()}},[e,o]),cancel:h.useCallback(()=>o(),[o]),finish:h.useCallback(()=>{let e=r.current,a=(i.current+``).trim()===``?``:i.current,o=t?.transcript??a;return e&&(e.onresult=null,e.onerror=null,e.onend=null,e.stop()),r.current=null,i.current=``,n(null),o.trim()},[t])}}function Le(e,t){let n=Math.max(0,Math.floor((t-e)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}`}var Q=n(),Re={KeyA:`Yes, approved.`,KeyC:`Continue.`};function ze({onSubmit:e,value:t,onValueChange:n,images:r,onImagesChange:l,autoFocus:u=!1,draftItems:d,footerStart:ce,footerEnd:m,sendAriaLabel:ve=`Send`,stop:_,disabled:v=!1,disabledReason:y=`Session closed — Continue to reopen.`,allowEmptySubmit:b=!1,placeholder:x=`Reply — / for skills, @ for files…`,ariaLabel:xe=`Reply to the agent`,autocompleteSkills:S=!0,quickReplies:Se=!1,getMentionCandidates:C,ref:Ce}){let[we,Te]=(0,h.useState)(``),w=t??we,T=(0,h.useRef)(w);T.current=w;let E=(0,h.useRef)(n);E.current=n;let D=(0,h.useCallback)(e=>{let t=typeof e==`function`?e(T.current):e;Te(t),E.current?.(t)},[]),[Ee,Oe]=(0,h.useState)([]),k=r??Ee,A=(0,h.useRef)(k);A.current=k;let j=(0,h.useRef)(l);j.current=l;let M=(0,h.useCallback)((e,t=`edit`)=>{let n=typeof e==`function`?e(A.current):e;A.current=n,Oe(n),j.current?.(n,t)},[]),[N,P]=(0,h.useState)(!1),[F,I]=(0,h.useState)(null),[L,R]=(0,h.useState)(``),[ke,Ae]=(0,h.useState)(!1),z=(0,h.useRef)(null),B=(0,h.useRef)(null),V=(0,h.useRef)(null),H=(0,h.useRef)(new Map),U=ee(S&&ke),W=i(),je=o(),G=Ie(e=>s(e,{tone:`danger`}));(0,h.useEffect)(()=>{u&&z.current?.focus()},[]),(0,h.useImperativeHandle)(Ce,()=>({insertAtCaret:e=>{let t=z.current,n=Ne(T.current,t?.selectionStart??T.current.length,e);D(n.text),V.current=n.caret,t?.focus()}}),[D]);let Me=(0,h.useCallback)(()=>{let e=z.current;if(!e||v){I(null);return}let t=Pe(e.value,e.selectionStart??e.value.length);if(t?.trigger===`/`&&!S||t?.trigger===`@`&&C===void 0)return I(null);t?.trigger===`/`&&Ae(!0),I(t)},[S,v,C]),K=(0,h.useMemo)(()=>F===null?[]:F.trigger===`/`?De(U.data??[],F.query,W.data?.skillUsage).map(e=>({value:`${e.name} ${e.path}`,insert:e.name,label:e.name,description:e.description,emphasized:g(e)})):(C?.()??[]).filter(e=>be(e,F.query)).map(e=>({value:e,insert:e,label:e,emphasized:!1})),[C,U.data,F,W.data?.skillUsage]),q=K.some(e=>e.value===L)?L:K[0]?.value,J=F!==null,Y=(0,h.useCallback)(()=>I(null),[]),X=e=>{let t=z.current;if(!t||F===null)return;let n=t.selectionStart??t.value.length,r=Fe(t.value,F,n,e.insert);F.trigger===`/`&&W.data!==void 0&&a({skillUsage:ye(W.data.skillUsage,e.insert)}).then(()=>je.invalidateQueries({queryKey:c.uiState})).catch(()=>{}),D(r.text),V.current=r.caret,I(null),t.focus()};(0,h.useEffect)(()=>{!J||q==null||H.current.get(q)?.scrollIntoView({block:`nearest`})},[q,J]),(0,h.useLayoutEffect)(()=>{let e=V.current,t=z.current;e!==null&&t&&(t.setSelectionRange(e,e),V.current=null)},[w]),(0,h.useLayoutEffect)(()=>{let e=z.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`)},[w]);let Z=(0,h.useCallback)((e,t=`file`)=>{if(v)return;let n=re(e,A.current.length);for(let e of n.rejected)s(e,{tone:`danger`});for(let e of n.accepted)ne(e,t).then(e=>M(t=>t.length>=4?t:[...t,e]))},[v]),Le=e=>{let t=[...e.clipboardData?.items??[]].filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null);t.length!==0&&(e.preventDefault(),Z(t,`clipboard`))},ze=e=>{let t=[...e.dataTransfer?.files??[]];t.length!==0&&(e.preventDefault(),Z(t))},$=(0,h.useCallback)(async(t,n,r,i)=>{let a=t.trim();if(!(v||N)&&!(a===``&&n.length===0&&!b)){P(!0);try{let t=n.map(ie);await(i?e(a,t,i):e(a,t))}catch(e){s(e instanceof Error?e.message:String(e),{tone:`danger`}),r&&(D(e=>e===``?t:`${t}\n${e}`),M(e=>[...n,...e].slice(0,4)))}finally{P(!1)}}},[b,N,v,e]),He=(0,h.useCallback)(()=>{if(w.trim()===``&&k.length===0&&!b)return;let e=w,t=k;D(``),M([],`submit`),I(null),$(e,t,!0)},[b,k,$,w]),Ue=e=>{if(J){if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),K.length===0)return;let t=K.findIndex(e=>e.value===q),n=e.key===`ArrowDown`?1:-1,r=K[(t+n+K.length)%K.length];R(r.value);return}if(e.key===`Escape`){e.preventDefault(),Y();return}if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey){let t=K.find(e=>e.value===q);if(t){e.preventDefault(),X(t);return}Y()}}ue({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.preventDefault(),He())};(0,h.useEffect)(()=>{if(!Se||v)return;let e=e=>{if(!e.altKey||e.metaKey||e.ctrlKey||e.repeat||O(e.target))return;let t=Re[e.code];t!==void 0&&(e.preventDefault(),$(t,[],!1,{quickReply:!0}))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[v,Se,$]);let We=e=>{let t=G.finish();if(t===``)return;let n=w.trim()===``?t:`${w.replace(/\s*$/,``)} ${t}`;if(e){D(``),M([],`submit`),$(n,k,!0);return}D(n),V.current=n.length,z.current?.focus()},Ge=G.recording;return(0,Q.jsxs)(se,{open:J,onOpenChange:e=>e?void 0:Y(),children:[(0,Q.jsx)(oe,{asChild:!0,children:(0,Q.jsxs)(`div`,{ref:B,"data-slot":`composer`,"data-disabled":v||void 0,onDrop:ze,onDragOver:e=>e.preventDefault(),className:f(`rounded-xl border border-border bg-card shadow-xs transition-[border-color,box-shadow]`,`focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/15`,v&&`opacity-80`),children:[k.length>0||d?(0,Q.jsxs)(`div`,{"data-slot":`composer-thumbs`,className:`flex flex-wrap items-center gap-2 px-4 pt-3`,children:[d,k.map((e,t)=>(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,title:`Click to remove`,className:f(`group relative overflow-hidden rounded-md border border-border`,e.isImage?`size-12`:`flex h-12 max-w-[200px] items-center gap-1.5 bg-muted/40 px-2.5 text-xs text-muted-foreground`),onClick:()=>M(e=>e.filter((e,n)=>n!==t)),children:[e.isImage?(0,Q.jsx)(`img`,{src:e.preview,alt:``,className:`size-full object-cover`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(_e,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,Q.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center bg-background/70 group-hover:flex group-focus-visible:flex`,children:(0,Q.jsx)(le,{"aria-hidden":`true`,className:`size-4`})})]},`${e.name}-${t}`))]}):null,(0,Q.jsx)(`textarea`,{ref:z,rows:1,value:w,disabled:v,"aria-label":xe,placeholder:v?y:x,className:`block max-h-[220px] min-h-11 w-full resize-none bg-transparent px-3 pt-2.5 pb-1 text-base leading-normal outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed md:min-h-[54px] md:px-4 md:pt-3 md:text-sm`,onChange:e=>{D(e.target.value),Me()},onKeyDown:Ue,onSelect:Me,onPaste:Le}),Ge?(0,Q.jsx)(Ve,{transcript:Ge.transcript,startedAt:Ge.startedAt,onCancel:G.cancel,onInsert:()=>We(!1),onInsertAndSend:()=>We(!0)}):(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 gap-y-1 px-1.5 pt-1 pb-1.5 md:gap-y-1.5 md:px-2 md:pt-1.5 md:pb-2`,children:[(0,Q.jsxs)(`div`,{"data-slot":`composer-footer-start`,className:`flex min-w-0 flex-wrap items-center gap-1`,children:[(0,Q.jsx)(Be,{disabled:v,onFiles:Z}),ce]}),(0,Q.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[G.supported?(0,Q.jsxs)(p,{type:`button`,variant:`ghost`,size:`sm`,disabled:v,"aria-label":`Start dictation`,title:`Dictation`,className:`h-8 gap-1.5 px-2.5 text-xs font-medium text-muted-foreground`,onClick:G.start,children:[(0,Q.jsx)(ge,{"aria-hidden":`true`,className:`size-3.5`}),`Dictation`]}):null,m?(0,Q.jsx)(`div`,{"data-slot":`composer-footer-end`,className:`flex items-center gap-1.5`,children:m}):null,_?(0,Q.jsx)(te,{label:_.label,side:`top`,children:(0,Q.jsx)(p,{type:`button`,size:`icon-sm`,variant:`contrast`,"data-slot":`composer-stop`,"aria-label":_.label,disabled:_.pending,className:`size-8`,onClick:_.onStop,children:(0,Q.jsx)(de,{"aria-hidden":`true`,className:`size-3 fill-current`})})}):null,!_||w.trim()!==``||k.length>0||b?(0,Q.jsx)(p,{type:`button`,size:`icon-sm`,"aria-label":ve,disabled:v||N||w.trim()===``&&k.length===0&&!b,className:`size-8`,onClick:He,children:(0,Q.jsx)(he,{"aria-hidden":`true`})}):null]})]})]})}),(0,Q.jsx)(ae,{side:`top`,align:`start`,sideOffset:8,className:`w-80 max-w-[calc(100vw-2rem)] p-0`,onOpenAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{B.current?.contains(e.target)&&e.preventDefault()},children:(0,Q.jsx)(pe,{shouldFilter:!1,value:q??``,onValueChange:R,children:(0,Q.jsx)(fe,{"data-slot":`composer-menu`,"data-trigger":F?.trigger,className:`max-h-[min(16rem,var(--radix-popover-content-available-height))] p-1`,children:K.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:F?.trigger===`@`?`No files seen in this session yet — full file search arrives with the Files tab.`:U.isPending?`Loading skills…`:`No matching skills.`}):K.map(e=>(0,Q.jsxs)(me,{ref:t=>{t?H.current.set(e.value,t):H.current.delete(e.value)},value:e.value,"data-slot":`composer-menu-item`,"data-emphasized":e.emphasized||void 0,onSelect:()=>X(e),children:[(0,Q.jsx)(`span`,{className:f(`shrink-0 truncate`,e.emphasized&&`font-semibold`,F?.trigger===`@`&&`font-mono text-xs`),children:e.label}),e.description?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null]},e.value))})})})]})}function Be({disabled:e,onFiles:t}){let n=(0,h.useRef)(null);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(p,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Attach files`,title:`Attach an image, PDF, TXT or MD file (or paste a screenshot)`,disabled:e,className:`size-8 text-muted-foreground`,onClick:()=>n.current?.click(),children:(0,Q.jsx)(_e,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,Q.jsx)(`input`,{ref:n,type:`file`,accept:`image/*,application/pdf,text/plain,text/markdown,.pdf,.txt,.md,.markdown,.log`,multiple:!0,className:`hidden`,"aria-hidden":`true`,tabIndex:-1,onChange:e=>{t([...e.target.files??[]]),e.target.value=``}})]})}function Ve({transcript:e,startedAt:t,onCancel:n,onInsert:r,onInsertAndSend:i}){let a=m(1e3);return(0,Q.jsxs)(`div`,{"data-slot":`dictation-overlay`,role:`status`,"aria-label":`Dictation in progress`,className:`flex items-center gap-2.5 rounded-b-xl border-t border-border bg-muted/60 px-3 py-2`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none animate-pulse rounded-full bg-danger motion-reduce:animate-none`}),(0,Q.jsx)(`span`,{"data-slot":`dictation-timer`,className:`text-xs font-medium text-muted-foreground tabular-nums`,children:Le(t,a)}),(0,Q.jsx)(`span`,{"data-slot":`dictation-transcript`,"aria-live":`polite`,className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:e===``?(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Listening…`}):e}),(0,Q.jsx)(p,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Cancel dictation`,className:`size-8 text-muted-foreground`,onClick:n,children:(0,Q.jsx)(le,{"aria-hidden":`true`})}),(0,Q.jsx)(p,{type:`button`,variant:`outline`,size:`icon-sm`,"aria-label":`Insert transcription`,className:`size-8`,onClick:r,children:(0,Q.jsx)(ce,{"aria-hidden":`true`})}),(0,Q.jsx)(p,{type:`button`,size:`icon-sm`,"aria-label":`Insert transcription and send`,className:`size-8`,onClick:i,children:(0,Q.jsx)(he,{"aria-hidden":`true`})})]})}export{D as C,_e as D,xe as E,w as S,we as T,g as _,U as a,b,je as c,P as d,M as f,De as g,ye as h,K as i,q as l,N as m,B as n,Ne as o,A as p,R as r,J as s,ze as t,I as u,C as v,Ee as w,y as x,_ as y};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$r as r,Ci as i,In as a,Pr as o,Rn as s,Sn as c,V as l,Wi as u,Wn as d,Zi as f,Zn as p,aa as m,ea as h,in as g,nn as _,ra as v,tt as y}from"./project-router-CWMOKp_H.js";import{$ as b,F as x,Q as S,X as C,Y as w,Z as T,et as ee,gt as E,nt as D,t as O}from"./button-BNnH7COh.js";import{A as te,C as ne,E as re,M as k,N as A,O as j,P as M,T as ie,_ as ae,b as oe,c as se,d as ce,f as le,g as ue,h as de,i as fe,j as pe,m as me,p as he,v as ge,w as _e,x as ve,y as ye}from"./use-automations-PceYR6ss.js";import{a as be,i as xe,o as Se,r as Ce,t as we}from"./sheet-D9PeyyRZ.js";import{S as Te,a as Ee,o as De,r as Oe,t as ke}from"./reference-chip-B7lU_Pyh.js";import{a as Ae,f as N,p as je,r as Me}from"./automation-format-BTIFWfjt.js";import{i as Ne,n as Pe,p as Fe,r as Ie,t as Le}from"./tooltip-BVqBAGNb.js";import{t as Re}from"./chevron-right-Beu1pd6H.js";import{t as ze}from"./download-CBwSbmy_.js";import{i as P,r as F,t as Be}from"./token-metrics-BcPjL36-.js";import{t as Ve}from"./use-now-BAKdIYLG.js";import{t as He}from"./index-BN3w52uE.js";var Ue=x(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),We=x(`arrow-down-left`,[[`path`,{d:`M17 7 7 17`,key:`15tmo1`}],[`path`,{d:`M17 17H7V7`,key:`1org7z`}]]),Ge=x(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),Ke=x(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),qe=x(`grip-horizontal`,[[`circle`,{cx:`12`,cy:`9`,r:`1`,key:`124mty`}],[`circle`,{cx:`19`,cy:`9`,r:`1`,key:`1ruzo2`}],[`circle`,{cx:`5`,cy:`9`,r:`1`,key:`1a8b28`}],[`circle`,{cx:`12`,cy:`15`,r:`1`,key:`1e56xg`}],[`circle`,{cx:`19`,cy:`15`,r:`1`,key:`1a92ep`}],[`circle`,{cx:`5`,cy:`15`,r:`1`,key:`5r1jwy`}]]),Je=x(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),I=e(t(),1);function Ye(e){let t=Date.parse(e.nextRunAt??``),n=Date.parse(e.state?.backoffUntil??``);return Number.isFinite(t)?Math.max(t,Number.isFinite(n)?n:t):null}function Xe(e){return e.flatMap(e=>(e.data?.automations??[]).filter(e=>e.enabled).map(t=>({project:e,automation:t,at:Ye(t)}))).sort((e,t)=>(e.at??1/0)-(t.at??1/0)||e.project.id.localeCompare(t.project.id)||e.automation.id.localeCompare(t.automation.id))}function Ze(e){let t=y(),n=m(),r=t.data?.projects??[],a=t.data?.bootProject,o=a&&!r.some(e=>e.id===a)?[...r,{id:a,name:a,status:`ok`}]:r,s=v({queryKey:[...g.dashboard,`automations`,o.map(e=>[e.id,e.name,e.status])],enabled:e&&!!t.data,queryFn:async({signal:e})=>{let t=0,n=[];return await Promise.all([0,1].map(async()=>{for(;t<o.length&&!e.aborted;){let r=o[t++];if(r.status===`missing`){n.push({...r,error:`Project folder unavailable`});continue}try{let t=D.parse(await i(await p.api.v1.workspace.dashboard.automations.$get({query:{projectId:r.id}},{init:{signal:e}}),`/workspace/dashboard/automations`));n.push({id:r.id,name:r.name,data:t})}catch{n.push({id:r.id,name:r.name,error:`Could not load automations`})}}})),n}});return(0,I.useEffect)(()=>{if(e)return j(e=>{e===`automation-change`&&n.invalidateQueries({queryKey:[...g.dashboard,`automations`]})})},[n,e]),{...s,registry:t,retry:()=>{t.refetch(),s.refetch()}}}var L=n();function R({rows:e}){return(0,L.jsx)(`span`,{hidden:!0,"data-dashboard-export":JSON.stringify(e)})}var z=`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,B=`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,Qe=`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden`;function V(){return(0,L.jsx)(Re,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-soft-foreground transition-transform duration-150 motion-reduce:transition-none [details[open]>summary>&]:rotate-90`})}var $e=`flex items-center gap-2 text-xs text-muted-foreground`;function et({className:e=``,...t}){return(0,L.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,L.jsx)(`select`,{...t,className:`h-9 cursor-pointer appearance-none rounded-md border bg-card-2 pr-8 pl-3 font-mono text-xs text-foreground outline-none transition-colors hover:border-foreground/20 hover:bg-muted focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 no-hover:min-h-11 ${e}`}),(0,L.jsx)(Fe,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 right-2.5 size-3.5 -translate-y-1/2 text-soft-foreground`})]})}var tt=`relative min-w-0 overflow-hidden rounded-lg border bg-card-2 p-4 transition-colors before:absolute before:inset-x-0 before:top-0 before:h-px before:opacity-80 hover:border-foreground/20 hover:bg-muted/40 sm:p-5`,H={violet:`before:bg-violet`,info:`before:bg-info`,success:`before:bg-success`,danger:`before:bg-danger`,primary:`before:bg-primary`,neutral:`before:bg-border`};function nt({label:e,value:t,icon:n,children:r}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-[11px] font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,L.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:n})]}),(0,L.jsx)(`span`,{className:`mt-4 block text-4xl font-semibold leading-none tracking-tight tabular-nums`,children:t}),(0,L.jsx)(`span`,{className:`mt-3 block text-xs text-soft-foreground`,children:r})]})}function rt({at:e}){return(0,L.jsxs)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:[`Updated `,F(e),` ago`]})}function it(){let e=fe(),t=Ze(e.known&&!e.off),n=Ve(3e4),[r,i]=(0,I.useState)(!1),a=Xe(t.data??[]),o=r?a:a.slice(0,3),s=t.data?.filter(e=>e.error)??[],c=!e.known||!t.registry.isError&&(t.registry.isPending||t.isPending),l=t.isError||t.registry.isError||s.length>0;return(0,L.jsxs)(N,{"data-export-context":`Enabled automations · showing ${o.length} of ${a.length} loaded · ${l?`partial coverage`:`available projects`}`,className:`min-w-0 gap-0 py-0`,children:[(0,L.jsxs)(`div`,{className:B,children:[(0,L.jsxs)(`h2`,{className:`flex items-center ${z}`,children:[`Automations`,(0,L.jsx)(je,{className:`ml-2 size-3.5 text-soft-foreground`,"aria-hidden":`true`})]}),!e.off&&t.data&&(0,L.jsxs)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:[a.length,` enabled`,l?` · partial`:``]})]}),!e.off&&t.data&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(R,{rows:[{section:`automations`,metric:`enabled`,value:a.length,unit:`automations`,note:l?`Partial project coverage`:`Loaded projects`}]}),t.dataUpdatedAt>0&&(0,L.jsx)(`p`,{className:`px-4 pt-3 text-xs text-muted-foreground`,children:(0,L.jsx)(rt,{at:new Date(t.dataUpdatedAt).toISOString()})})]}),e.off?(0,L.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,L.jsxs)(L.Fragment,{children:[c&&(0,L.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading automations…`}),l&&(0,L.jsxs)(`div`,{role:`alert`,className:`p-4 text-sm`,children:[(0,L.jsx)(`p`,{children:`Some automation data could not be refreshed. Available results are shown.`}),s.map(e=>(0,L.jsxs)(`p`,{children:[e.name,`: `,e.error]},e.id)),(0,L.jsx)(O,{variant:`ghost`,onClick:t.retry,children:`Retry automations`})]}),!c&&!l&&a.length===0&&(0,L.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`No enabled automations. Enable one in a project's Automations page.`}),o.map(({project:e,automation:t,at:r})=>{let i=(t.state?.consecutiveFailures??0)>0?`Recent checks failed`:void 0,a=r===null?`Next time not available`:r<=n?`Due — awaiting scheduler`:Ae(r,n),o=t.kind===`schedule`?`Next run`:`Next check`;return(0,L.jsxs)(`div`,{"data-export-row":!0,className:`border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,L.jsx)(u,{className:`block min-h-11 text-sm font-medium hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations/${encodeURIComponent(t.id)}`,children:t.name}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.name,` · `,o,`: `,a]}),r!==null&&(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:(0,L.jsxs)(`time`,{dateTime:new Date(r).toISOString(),children:[Me(r,e.data.timeZone),` · `,e.data.timeZone]})}),t.kind!==`schedule`&&(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Checks for matching events; a task may not be started.`}),i&&(0,L.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:i}),(0,L.jsx)(R,{rows:[{section:`automation`,entity:`${e.id}:${t.id}`,metric:`name`,value:t.name},{section:`automation`,entity:`${e.id}:${t.id}`,metric:t.kind===`schedule`?`nextRunAt`:`nextCheckAt`,value:r===null?null:new Date(r).toISOString(),note:[a,i].filter(Boolean).join(` · `)}]})]},`${e.id}:${t.id}`)}),a.length>3&&(0,L.jsx)(O,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>i(!r),children:r?`Show fewer`:`Show all ${a.length} enabled`}),!c&&(0,L.jsxs)(`details`,{className:`border-t px-4 py-2 text-xs text-muted-foreground`,children:[(0,L.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden min-h-11`,"data-export-heading":`Project automations`,children:[(0,L.jsx)(V,{}),`Manage automations by project`]}),t.data?.map(e=>(0,L.jsx)(u,{className:`block min-h-11 py-3 hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations`,children:e.name},e.id))]})]})]})}function at(e,t,n){let r=new Set,i=new Map(e.map((e,t)=>[n(e),{r:e,i:t}]));return t.forEach((e,t)=>{let a=i.get(n(e));(!a||a.i!==t||JSON.stringify(a.r)!==JSON.stringify(e))&&r.add(n(e)),i.delete(n(e))}),i.forEach((e,t)=>r.add(t)),r}function ot(e,t,n){let r=new Map(t.map(e=>[n(e),e]));return e.map(e=>({row:r.get(n(e))??e,removed:!r.has(n(e))}))}var st=(0,I.createContext)(``),ct=(0,I.createContext)(!0),U=new Map;function lt(e,t,n=``,r=0,i){let a=(0,I.useContext)(st),o=`${a}:${n}`,[s,c]=(0,I.useState)(()=>U.get(o)),[l,u]=(0,I.useState)(o),d=(0,I.useRef)(r),f=(0,I.useRef)(!1);l!==o&&(u(o),c(U.get(o)),d.current=r,f.current=!1),d.current!==r&&(d.current=r,f.current=!0),(0,I.useEffect)(()=>{e&&(!s||f.current)&&(c(e),f.current=!1)},[s,e]);let p=(0,I.useMemo)(()=>({current:s}),[o]);p.current=s,(0,I.useEffect)(()=>()=>{!a||!p.current||(U.delete(o),U.set(o,p.current),U.size>60&&U.delete(U.keys().next().value))},[a,o,p]);let m=s??e??[],h=new Set((e??m).map(t)),g=i?m.filter(e=>h.has(t(e))||i(e)):m;return{rows:ot(g,e??m,t),updates:e?at(g,e,t).size:0,show:()=>c(e)}}var ut=new Map;function dt(e){return ut.get(e)}function ft(e,t){ut.delete(e),ut.set(e,t),ut.size>20&&ut.delete(ut.keys().next().value)}var W=new Map;function pt(e,t){return W.get(e)?.[t]}function mt(e,t,n){let r=W.get(e)??{};r[t]=n,W.delete(e),W.set(e,r),W.size>20&&W.delete(W.keys().next().value)}var G=e=>`${e.projectId}:${e.id}`;function ht({row:e,removed:t=!1,queue:n=!1,checking:r=!1,checkFailed:i=!1,kicker:o}){let l=(0,I.useContext)(ct)&&!r&&!i,d=M(e);t=t||d===null||n&&d?.archived===!0,d&&(e={...e,status:d.status,awaitingAnswerSince:d.awaitingAnswerSince});let f=a(e),p=n&&!s(e),m=t||p||!l;return(0,L.jsxs)(`div`,{"data-dashboard-row":G(e),className:`min-w-0 border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,L.jsx)(R,{rows:[{section:`task`,entity:G(e),metric:`title`,value:e.titleSummary||e.title},{section:`task`,entity:G(e),metric:`status`,value:m?`Not currently actionable`:e.status},{section:`task`,entity:G(e),metric:`createdAt`,value:e.createdAt}]}),o&&(0,L.jsx)(`p`,{className:`mb-1 pl-[15px] font-mono text-[10.5px] uppercase tracking-[0.1em] text-soft-foreground`,children:o}),(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(P,{tone:f.tone,className:`mt-[7px]`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(u,{tabIndex:m?-1:void 0,"aria-disabled":m||void 0,onClick:e=>{m&&e.preventDefault()},to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,className:`block break-words text-sm font-medium leading-relaxed hover:underline no-hover:min-h-11`,children:e.titleSummary||e.title}),(0,L.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:e.projectId}),(0,L.jsx)(`span`,{children:i?`Could not check current state`:l?t?n&&d!==null?`No longer needs you`:`Task removed`:p?`No longer needs you`:f.label:`Checking current state…`}),(0,L.jsx)(`span`,{children:F(e.createdAt)}),e.dispatch&&(0,L.jsx)(`span`,{children:`Subtask`}),!m&&c(e).map(t=>(0,L.jsx)(ke,{reference:t,taskTitle:e.title,projectId:e.projectId,className:`no-hover:min-h-11`},`${t.kind}:${t.number}`))]})]})]})]})}function K({coverage:e,count:t,retry:n}){let r=e.projects.filter(e=>e.state!==`complete`);return r.length?(0,L.jsxs)(`div`,{className:`rounded-lg border border-pending/40 bg-card-2 p-3 text-sm`,role:`status`,children:[(0,L.jsxs)(`p`,{children:[t===void 0?``:`${t} tasks need you in the available data. Complete coverage: ${e.projects.length-r.length} of ${e.projects.length} projects. `,r.length===1?r[0].state===`unavailable`?`One project is unavailable.`:`One project has incomplete coverage.`:`${r.length} projects have incomplete coverage.`]}),(0,L.jsxs)(`details`,{className:`mt-2`,children:[(0,L.jsxs)(`summary`,{className:`${Qe} min-h-11`,children:[(0,L.jsx)(V,{}),`View unavailable `,r.length===1?`project`:`projects`]}),r.map(e=>(0,L.jsxs)(`p`,{children:[e.projectId,`: `,e.reason??e.state,e.omittedRuns>0?` · ${e.omittedRuns} omitted tasks`:``]},e.projectId))]}),(0,L.jsx)(O,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Retry`})]}):null}function gt(e,t=!1){return e==null?`Unavailable`:t?`$${e.toFixed(e===0||e>=1?2:Math.min(20,Math.max(4,Math.ceil(-Math.log10(e))+1)))}`:e.toLocaleString(`en-US`)}function q(e){return e===null?`Unavailable`:e<1?`${Math.round(e*60)}m`:e<48?`${e.toFixed(1)}h`:`${(e/24).toFixed(1)}d`}function _t(e,t,n){let r=f(),i=r.state?.dashboardEntry??r.key,[a,o]=h(),s=a.get(e);return[s!==null&&t.includes(s)?s:n,t=>o(n=>{let r=new URLSearchParams(n);return r.set(e,t),r},{replace:!0,state:{...r.state,dashboardEntry:i}})]}var vt=e=>`Last ${e===`7d`?7:30} calendar days`,yt=`font-mono text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,bt=`min-w-0 rounded-lg border bg-card-2 p-4`,J=`whitespace-nowrap px-3 py-2 font-mono text-[11px] font-medium uppercase tracking-[0.1em] text-soft-foreground`;function xt(){let e=y().data?.projects;return t=>e?.find(e=>e.id===t)?.name??t}var St=(e,t)=>`/p/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}`;function Ct({label:e,value:t,onChange:n}){return(0,L.jsxs)(`label`,{className:$e,children:[e,(0,L.jsxs)(et,{value:t,onChange:e=>n(e.target.value===`30d`?`30d`:`7d`),children:[(0,L.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,L.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})}function wt({query:e}){return e.isPending?(0,L.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading insights…`}):e.isError?(0,L.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[e.data?`Showing previous results. `:``,`Could not refresh insights.`,` `,(0,L.jsx)(O,{variant:`outline`,onClick:()=>void e.refetch(),children:`Retry insights`})]}):null}function Tt({period:e,active:t}){let n=He(e,t),r=n.data;return(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsx)(wt,{query:n}),r&&(0,L.jsx)(K,{coverage:r.coverage,retry:()=>void n.refetch()}),r&&(0,L.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,L.jsx)(Et,{data:r}),(0,L.jsx)(Dt,{data:r})]})]})}function Et({data:e}){let t=e.delivered,n=[{label:`PRs opened`,value:t.prsOpened,note:`${t.prsTouched} touched`},{label:`Lines`,value:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`text-success`,children:[`+`,t.additions.toLocaleString(`en-US`)]}),` `,(0,L.jsxs)(`span`,{className:`text-danger`,children:[`−`,t.deletions.toLocaleString(`en-US`)]})]})},{label:`Files`,value:t.files.toLocaleString(`en-US`)},{label:`Issues`,value:t.issues}];return(0,L.jsxs)(`section`,{className:bt,"aria-label":`Delivered`,children:[(0,L.jsx)(R,{rows:Object.entries(t).map(([t,n])=>({section:`delivered`,metric:t,value:n,unit:[`additions`,`deletions`].includes(t)?`lines`:t===`files`?`files`:`count`,asOf:e.asOf,note:`Completed since ${e.windowStart}`}))}),(0,L.jsx)(`h3`,{className:yt,children:`Delivered`}),(0,L.jsx)(`dl`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-4`,children:n.map(e=>(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`dt`,{className:`text-xs text-soft-foreground`,children:e.label}),(0,L.jsx)(`dd`,{className:`mt-1 truncate text-xl font-semibold tracking-tight tabular-nums`,children:e.value}),e.note&&(0,L.jsx)(`dd`,{className:`text-xs text-soft-foreground`,children:e.note})]},e.label))}),(0,L.jsxs)(`span`,{className:`mt-3 block text-xs text-soft-foreground`,children:[`From `,t.completedTasks,` completed `,t.completedTasks===1?`task`:`tasks`,` ·`,` `,t.measuredTasks,` with a stored diff`]})]})}function Dt({data:e}){let t=xt(),{total:n,reasons:r}=e.failures;return(0,L.jsxs)(`section`,{className:bt,"aria-label":`Why tasks failed`,children:[(0,L.jsx)(R,{rows:r.map(t=>({section:`failures`,entity:t.label,metric:t.category,value:t.count,unit:`tasks`,asOf:e.asOf,note:t.latest.message}))}),(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,L.jsx)(`h3`,{className:yt,children:`Why tasks failed`}),n>0&&(0,L.jsxs)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:[n,` failed`]})]}),n===0?(0,L.jsxs)(`span`,{className:`mt-4 flex items-center gap-2.5 text-sm text-muted-foreground`,children:[(0,L.jsx)(P,{tone:`success`}),`No failed outcomes in this period`]}):(0,L.jsx)(`ul`,{className:`mt-3 space-y-3`,children:r.map(e=>(0,L.jsx)(Ot,{reason:e,total:n,projectName:t},`${e.category}:${e.label}`))})]})}function Ot({reason:e,total:t,projectName:n}){let{latest:r}=e;return(0,L.jsxs)(`li`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate font-medium`,title:e.label,children:e.label}),(0,L.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:e.count})]}),(0,L.jsx)(`div`,{className:`mt-1.5 h-1 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full bg-danger/70`,style:{width:`${e.count/t*100}%`}})}),(0,L.jsxs)(`span`,{className:`mt-1.5 block truncate text-xs text-soft-foreground`,title:r.message,children:[`Latest:`,` `,(0,L.jsx)(u,{className:`text-muted-foreground hover:text-foreground hover:underline`,to:St(r.projectId,r.id),children:r.title}),` `,`· `,n(r.projectId),r.step?` · ${r.step}`:``,` · `,F(r.at),` ago`]})]})}var kt={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,cursor:`Cursor`,pi:`Pi`,unknown:`Unknown backend`,mixed:`Mixed backends`},At=e=>kt[e]??e,jt=(e,t)=>t?Math.round(e/t*100):0;function Mt(){let[e,t]=_t(`backends`,[`7d`,`30d`],`7d`),n=He(e),r=n.data,i=r?.visibility.cost;return(0,L.jsx)(`section`,{"data-dashboard-module":`backends`,className:`min-w-0`,children:(0,L.jsxs)(N,{className:`gap-0 py-0`,"data-export-context":`Backends: ${vt(e)}; finished tasks`,children:[(0,L.jsxs)(`div`,{className:B,children:[(0,L.jsx)(`h2`,{className:z,children:`Backends & models`}),(0,L.jsx)(Ct,{label:`Finished`,value:e,onChange:t})]}),(0,L.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,L.jsx)(wt,{query:n}),r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Tasks that finished done or failed in the period, by the backend and model their steps ran on. Includes subtasks. Cost is reported USD only.`}),(0,L.jsx)(K,{coverage:r.coverage,retry:()=>void n.refetch()}),r.backends.length?(0,L.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Backend comparison`,tabIndex:0,children:(0,L.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{className:J,children:`Backend`}),(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Finished`}),(0,L.jsx)(`th`,{className:J,children:`Success`}),(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Median cycle`}),i&&(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Reported USD`}),i&&(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Per completed`})]})}),(0,L.jsx)(`tbody`,{children:r.backends.map(e=>(0,L.jsx)(Nt,{stat:e,cost:!!i},`${e.backend}:${e.model??``}`))})]})}):(0,L.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No finished tasks in this period.`}),(0,L.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:(0,L.jsx)(rt,{at:r.asOf})}),(0,L.jsx)(R,{rows:r.backends.flatMap(e=>[`finished`,`done`,`failed`,`medianCycleHours`].map(t=>({section:`backends`,entity:`${e.backend}${e.model?`:${e.model}`:``}`,metric:t,value:e[t],unit:t===`medianCycleHours`?`hours`:`tasks`,asOf:r.asOf})))})]})]})]})})}function Nt({stat:e,cost:t}){let n=jt(e.done,e.finished),r=e.costUsd?.value;return(0,L.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,L.jsxs)(`td`,{className:`px-3 py-2.5`,children:[(0,L.jsx)(`span`,{className:`block font-medium`,children:At(e.backend)}),(0,L.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:e.backend===`mixed`?`steps ran on different backends`:e.model??`default model`})]}),(0,L.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.finished}),(0,L.jsxs)(`td`,{className:`min-w-40 px-3 py-2.5`,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-danger/40`,"aria-hidden":`true`,children:(0,L.jsx)(`span`,{className:`block h-full rounded-full bg-success`,style:{width:`${n}%`}})}),(0,L.jsxs)(`span`,{className:`w-10 text-right font-mono text-xs tabular-nums`,children:[n,`%`]})]}),(0,L.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.done,` done · `,e.failed,` failed`]})]}),(0,L.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.timedTasks?q(e.medianCycleHours):`—`}),t&&(0,L.jsxs)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:[r==null?`—`:gt(r,!0),(0,L.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.costUsd?.reportedTasks??0,`/`,e.finished,` reported`]})]}),t&&(0,L.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:r==null||!e.done?`—`:gt(r/e.done,!0)})]})}function Pt(){let[e,t]=_t(`automations`,[`7d`,`30d`],`7d`),n=fe(),r=He(e),i=Ze(n.known&&!n.off),a=xt(),o=r.data,s=o?.visibility.cost,c=new Map;for(let e of i.data??[])for(let t of e.data?.automations??[])c.set(`${e.id}\u0000${t.id}`,{projectId:e.id,automationId:t.id,name:t.name,enabled:t.enabled,definition:`known`});let l=new Set((i.data??[]).flatMap(e=>e.data&&!e.error?[e.id]:[])),u=i.isError||i.registry.isError||(i.data??[]).some(e=>e.error);for(let e of o?.automations??[]){let t=`${e.projectId}\u0000${e.automationId}`,n=c.get(t);c.set(t,n?{...n,stat:e}:{...e,name:e.automationId,definition:l.has(e.projectId)?`removed`:`unknown`,stat:e})}let d=[...c.values()].sort((e,t)=>(t.stat?.tasks??0)-(e.stat?.tasks??0)||Number(t.enabled??!1)-Number(e.enabled??!1)||e.name.localeCompare(t.name));return(0,L.jsx)(`section`,{"data-dashboard-module":`automation-outcomes`,className:`min-w-0`,children:(0,L.jsxs)(N,{className:`gap-0 py-0`,"data-export-context":`Automation outcomes: tasks created in ${vt(e)}`,children:[(0,L.jsxs)(`div`,{className:B,children:[(0,L.jsx)(`h2`,{className:z,children:`Automation outcomes`}),(0,L.jsx)(Ct,{label:`Launched`,value:e,onChange:t})]}),(0,L.jsx)(`div`,{className:`space-y-3 p-4`,children:n.off?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(wt,{query:r}),o&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Tasks each automation created in the period and how they ended. Active means still running, queued, waiting on you, or waiting to resume after a usage limit.`}),(0,L.jsx)(K,{coverage:o.coverage,retry:()=>void r.refetch()}),u&&(0,L.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Some automation details could not be loaded. Their outcomes are shown by id.`,` `,(0,L.jsx)(O,{variant:`ghost`,onClick:i.retry,children:`Retry automations`})]}),d.length?(0,L.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Automation outcomes`,tabIndex:0,children:(0,L.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{className:J,children:`Automation`}),(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Tasks`}),(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Done`}),(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Failed`}),(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Active`}),(0,L.jsx)(`th`,{className:J,children:`Last run`}),s&&(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Reported USD`})]})}),(0,L.jsx)(`tbody`,{children:d.map(e=>(0,L.jsx)(Ft,{row:e,cost:!!s,projectName:a},`${e.projectId}:${e.automationId}`))})]})}):(0,L.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No automations yet. Create one in a project's Automations page.`}),(0,L.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:(0,L.jsx)(rt,{at:o.asOf})}),(0,L.jsx)(R,{rows:d.flatMap(e=>[`tasks`,`done`,`failed`,`active`].map(t=>({section:`automation-outcomes`,entity:`${e.projectId}:${e.automationId}`,metric:t,value:e.stat?.[t]??0,unit:`tasks`,asOf:o.asOf,note:e.name})))})]})]})})]})})}function Ft({row:e,cost:t,projectName:n}){let r=e.stat,i=`px-3 py-2.5 text-right tabular-nums`,a=e=>e||(0,L.jsx)(`span`,{className:`text-soft-foreground`,children:`0`});return(0,L.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,L.jsxs)(`td`,{className:`px-3 py-2.5`,children:[e.definition===`removed`?(0,L.jsx)(`span`,{className:`block font-medium`,children:e.name}):(0,L.jsx)(u,{className:`block font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/automations/${encodeURIComponent(e.automationId)}`,children:e.name}),(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-soft-foreground`,children:[(0,L.jsx)(P,{tone:e.enabled?`success`:`neutral`}),n(e.projectId),` ·`,` `,e.definition===`removed`?`Removed`:e.definition===`unknown`?`Details unavailable`:e.enabled?`Enabled`:`Disabled`]})]}),(0,L.jsx)(`td`,{className:i,children:a(r?.tasks)}),(0,L.jsx)(`td`,{className:i,children:a(r?.done)}),(0,L.jsx)(`td`,{className:`${i} ${r?.failed?`text-danger`:``}`,children:a(r?.failed)}),(0,L.jsx)(`td`,{className:i,children:a(r?.active)}),(0,L.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-xs text-muted-foreground`,children:r?.lastRunAt?(0,L.jsxs)(`time`,{dateTime:r.lastRunAt,title:new Date(r.lastRunAt).toLocaleString(),children:[F(r.lastRunAt),` ago · `,r.lastStatus]}):`—`}),t&&(0,L.jsx)(`td`,{className:i,children:r?.costUsd?.value==null?`—`:gt(r.costUsd.value,!0)})]})}var It=0,Lt=()=>++It,Y=new Map;function X(e,t){let n=(0,I.useContext)(st),r=()=>{let r=n?Y.get(n):void 0;return r?.has(e)?r.get(e):typeof t==`function`?t():t},[i,a]=(0,I.useState)(r),o=`${n}:${e}`,[s,c]=(0,I.useState)(o);o!==s&&(c(o),a(()=>r()));let l=(0,I.useMemo)(()=>({value:i}),[n,e]);return l.value=i,(0,I.useEffect)(()=>()=>{if(!n)return;let t=Y.get(n)??new Map;t.set(e,l.value),t.size>80&&t.delete(t.keys().next().value),Y.delete(n),Y.set(n,t),Y.size>20&&Y.delete(Y.keys().next().value)},[n,e,l]),[i,a]}var Rt=`a[href], button, select, input, [tabindex]`;function zt(e){let[t]=X(`${e}:position`,()=>({scroll:0})),n=(0,I.useCallback)(e=>{let n=[...e.querySelectorAll(Rt)],r=t.href?n.find(e=>e.getAttribute(`href`)===t.href):t.index===void 0?void 0:n[t.index];return r&&r.getAttribute(`aria-disabled`)!==`true`&&r.focus({preventScroll:!0}),e.scrollTop=t.scroll,!!r&&r.getAttribute(`aria-disabled`)!==`true`},[t]),r=(0,I.useMemo)(()=>({restore:()=>!1}),[t]);return{ref:(0,I.useCallback)(e=>{if(!e)return;let i=t.href!==void 0||t.index!==void 0,a=()=>{if(!i)return!1;let r=n(e);return r?(i=!1,o.disconnect()):e.querySelector(`[data-sheet-loading="false"]`)&&(i=!1,o.disconnect(),e.querySelector(`button:not([disabled]), select, [tabindex="0"]`)?.focus({preventScroll:!0}),e.scrollTop=t.scroll),r};r.restore=a;let o=new MutationObserver(a);i&&o.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-sheet-loading`]});let s=()=>{i=!1,o.disconnect()},c=()=>{i||(t.scroll=e.scrollTop)},l=n=>{i||!(n.target instanceof HTMLElement)||(t.href=n.target.getAttribute(`href`)??void 0,t.index=[...e.querySelectorAll(Rt)].indexOf(n.target))};return e.addEventListener(`pointerdown`,s),e.addEventListener(`keydown`,s),e.addEventListener(`wheel`,s,{passive:!0}),e.addEventListener(`scroll`,c),e.addEventListener(`focusin`,l),()=>{o.disconnect(),e.removeEventListener(`pointerdown`,s),e.removeEventListener(`keydown`,s),e.removeEventListener(`wheel`,s),e.removeEventListener(`scroll`,c),e.removeEventListener(`focusin`,l)}},[t,n,r]),onOpenAutoFocus:e=>{(t.href!==void 0||t.index!==void 0)&&(e.preventDefault(),r.restore())}}}function Bt(e,t){let n=(0,I.useRef)(null),[r,i]=X(`${e}:trigger`,null);return{capture:()=>{let e=document.activeElement;n.current=e instanceof HTMLElement&&e!==document.body?e:null,i(n.current?{label:n.current.getAttribute(`aria-label`),text:n.current.textContent}:null)},restore:()=>{((n.current?.isConnected?n.current:r?[...document.querySelectorAll(`button`)].find(e=>!e.closest(`[role="dialog"]`)&&!e.hasAttribute(`disabled`)&&(r.label?e.getAttribute(`aria-label`)===r.label:e.textContent===r.text)):void 0)??document.querySelector(t))?.focus({preventScroll:!0})}}}function Vt(e,t=!0){return v({queryKey:[...g.dashboard,`overview`,e],enabled:t,staleTime:5e3,refetchInterval:t&&!e.snapshotId?15e3:!1,refetchIntervalInBackground:!1,retry:!1,queryFn:async({signal:t})=>w.parse(await i(await p.api.v1.workspace.dashboard.overview.$get({query:{period:e.period??`7d`,group:e.group??`completed`,tzOffsetMinutes:String(e.tzOffsetMinutes??new Date().getTimezoneOffset()),...e.snapshotId?{snapshotId:e.snapshotId}:{},...e.projectId?{projectId:e.projectId}:{},offset:String(e.offset??0),limit:`20`}},{init:{signal:t}}),`/workspace/dashboard/overview`))})}var Ht={running:`Running now`,"needs-you":`Needs you`,completed:`Completed`,failed:`Failed outcomes`},Ut={"needs-you":H.violet,running:H.info,completed:H.success,failed:H.danger},Wt={"needs-you":Ke,running:Ue,completed:re,failed:Ge};function Gt({active:e,children:t,onCurrent:n}){let[r,i]=_t(`period`,[`7d`,`30d`],`7d`),a=Bt(`outcome`,`[data-outcome-trigger]`),o=y().data?.projects,s=e=>o?.find(t=>t.id===e)?.name??e,c=Vt({period:r},e),[l,d]=X(`outcome:selection`,null),f=zt(`outcome:${l?.identity??`closed`}`),p=pe();if((0,I.useEffect)(()=>{e||d(null)},[e]),!e)return t({});let m=c.data,h=(e,t)=>{a.capture(),m&&d({identity:Lt(),snapshot:m,group:e,projectId:t})},g=m?.coverage.projects.every(e=>e.state===`complete`);return(0,L.jsxs)(L.Fragment,{children:[t({overview:(0,L.jsxs)(N,{className:`gap-0 py-0`,children:[(0,L.jsxs)(`div`,{className:B,children:[(0,L.jsx)(`h2`,{className:z,children:`Workspace overview`}),(0,L.jsxs)(`label`,{className:$e,children:[`Outcomes period`,(0,L.jsxs)(et,{value:r,onChange:e=>{i(e.target.value===`30d`?`30d`:`7d`),d(null)},children:[(0,L.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,L.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,L.jsxs)(`div`,{className:`space-y-4 p-4`,children:[c.isPending&&(0,L.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading overview…`}),c.isError&&(0,L.jsxs)(`p`,{role:`alert`,children:[m?`Showing previous results. `:``,`Could not refresh overview.`,` `,(0,L.jsx)(O,{variant:`outline`,onClick:()=>void c.refetch(),children:`Retry overview`})]}),m&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[m.metrics.needsYou?`${m.metrics.needsYou} tasks require your input or review.`:g&&p.connected&&!c.isError?`No tasks currently require your input or review.`:`No waiting tasks found in the available data.`,` `,m.metrics.failed,` failed `,m.metrics.failed===1?`outcome`:`outcomes`,` `,`in this period. Includes subtasks; completed does not mean accepted or deployed.`]}),(0,L.jsx)(K,{coverage:m.coverage,retry:()=>void c.refetch()}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[`needs-you`,`running`,`completed`,`failed`].map(e=>{let t=m.metrics[e===`needs-you`?`needsYou`:e],i=Wt[e];return(0,L.jsxs)(O,{"data-outcome-trigger":!0,"data-export-keep":!0,variant:`outline`,className:`relative min-w-0 overflow-hidden rounded-lg border bg-card-2 p-4 transition-colors before:absolute before:inset-x-0 before:top-0 before:h-px before:opacity-80 hover:border-foreground/20 hover:bg-muted/40 sm:p-5 group/metric h-auto min-h-24 flex-col items-start gap-0 whitespace-normal text-left font-normal ${t===0?H.neutral:Ut[e]}`,onClick:t=>{n&&(e===`running`||e===`needs-you`)?n(e,t.currentTarget):h(e)},"aria-label":`${Ht[e]}: ${t}`,children:[(0,L.jsx)(nt,{label:Ht[e],value:t,icon:(0,L.jsx)(i,{className:`size-4`}),children:e===`running`||e===`needs-you`?`Current state`:`Last ${r===`7d`?7:30} calendar days`}),(0,L.jsxs)(`span`,{"data-export-exclude":!0,className:`mt-4 flex items-center gap-1 text-xs font-medium text-muted-foreground transition-colors group-hover/metric:text-foreground`,children:[`View tasks`,` `,(0,L.jsx)(Re,{className:`size-3 transition-transform group-hover/metric:translate-x-0.5 motion-reduce:transition-none`,"aria-hidden":`true`})]})]},e)})}),(0,L.jsx)(Tt,{period:r,active:e}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 border-t pt-3`,children:[(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Median cycle time`,` `,(0,L.jsx)(`strong`,{className:`font-mono font-semibold text-foreground`,children:q(m.metrics.medianCycleHours)}),` `,`· `,m.metrics.timedTasks,`/`,m.metrics.completed,` completed tasks have valid timings.`,` `,(0,L.jsx)(O,{variant:`ghost`,className:`h-auto px-1.5 py-1 text-sm text-foreground underline-offset-4 hover:underline`,onClick:()=>h(`completed`),children:`Inspect completed tasks`})]}),(0,L.jsx)(`p`,{className:`font-mono text-[11px] text-soft-foreground`,children:(0,L.jsxs)(`time`,{dateTime:m.asOf,title:new Date(m.asOf).toLocaleString(),children:[`Updated `,F(m.asOf),` ago`]})})]}),(0,L.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,L.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden py-1`,children:[(0,L.jsx)(V,{}),`How these metrics work`]}),(0,L.jsx)(`p`,{className:`mt-1 max-w-prose pl-5 leading-relaxed`,children:`Outcomes use finish dates, including archived tasks. Scheduled retries are excluded from failed outcomes. Period includes today at your current fixed UTC offset.`})]}),(0,L.jsx)(R,{rows:Object.entries(m.metrics).map(([e,t])=>({section:`overview`,metric:e,value:t,unit:e===`medianCycleHours`?`hours`:`tasks`,asOf:m.asOf,note:e===`running`||e===`needsYou`?`Current non-archived state`:`Finished since ${m.windowStart}`}))})]})]})]}),portfolio:m&&(0,L.jsx)(`div`,{children:(0,L.jsxs)(N,{className:`gap-0 py-0`,"data-export-context":`Outcomes: Last ${r===`7d`?7:30} calendar days; workload: current state`,children:[(0,L.jsx)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,children:(0,L.jsx)(`h2`,{className:`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Projects`})}),(0,L.jsx)(`p`,{className:`px-4 pt-3 text-xs text-muted-foreground`,children:`Current workload and outcomes for the selected period. Sorted by tasks needing you, then running tasks. Counts include subtasks.`}),(0,L.jsxs)(`div`,{className:`overflow-x-auto px-1 pb-2`,role:`region`,"aria-label":`Project outcomes`,tabIndex:0,children:[(0,L.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsx)(`tr`,{children:[`Project`,`Needs you`,`Running`,`Completed`,`Failed`,`Median cycle`].map(e=>(0,L.jsx)(`th`,{className:`whitespace-nowrap px-3 py-2 font-mono text-[11px] font-medium uppercase tracking-[0.1em] text-soft-foreground ${e===`Project`?``:`text-right`}`,children:e},e))})}),(0,L.jsx)(`tbody`,{children:m.projects.map(e=>{let t=m.coverage.projects.find(t=>t.projectId===e.projectId);return(0,L.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,L.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,L.jsx)(u,{className:`font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/tasks`,children:s(e.projectId)}),t?.state!==`complete`&&(0,L.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Incomplete data`})]}),[`needs-you`,`running`,`completed`,`failed`].map(n=>(0,L.jsx)(`td`,{className:`px-3 py-1 text-right`,children:(0,L.jsx)(O,{"data-export-keep":!0,variant:`ghost`,className:`min-h-11 tabular-nums`,"aria-label":`${s(e.projectId)}: ${Ht[n]}: ${t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]}`,disabled:t?.state===`unavailable`,onClick:()=>h(n,e.projectId),children:t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]})},n)),(0,L.jsxs)(`td`,{className:`px-3 py-2 text-right tabular-nums`,children:[q(e.medianCycleHours),(0,L.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.timedTasks,`/`,e.completed,` timed`]})]})]},e.projectId)})})]}),!m.projects.length&&(0,L.jsx)(`p`,{className:`py-4`,children:`No projects to compare yet.`})]}),(0,L.jsx)(R,{rows:m.projects.flatMap(({projectId:e,...t})=>Object.entries(t).map(([t,n])=>({section:`portfolio`,entity:e,metric:t,value:m.coverage.projects.find(t=>t.projectId===e)?.state===`unavailable`?null:n,unit:t===`medianCycleHours`?`hours`:`tasks`,asOf:m.asOf,note:`Outcomes since ${m.windowStart}; running and needsYou are current state`})))})]})})}),(0,L.jsx)(we,{open:!!l,onOpenChange:e=>{e||d(null)},children:(0,L.jsxs)(Ce,{...f,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),a.restore()},children:[(0,L.jsxs)(be,{children:[(0,L.jsxs)(Se,{children:[l?Ht[l.group]:`Tasks`,l?.projectId?` · ${l.projectId}`:``]}),(0,L.jsx)(xe,{children:`Tasks behind the selected metric. Includes subtasks. Snapshot keeps counts and rows consistent.`})]}),l&&(0,L.jsx)(Kt,{selection:l,projectName:s,refresh:()=>{d(null),c.refetch()}},l.identity)]})})]})}function Kt({selection:e,refresh:t,projectName:n}){let[r,i]=X(`outcome:${e.identity}:offset`,0),a=Vt({period:e.snapshot.period,snapshotId:e.snapshot.snapshotId,group:e.group,projectId:e.projectId,offset:r}),o=(0,I.useRef)(null),s=(0,I.useRef)(null);(0,I.useEffect)(()=>{a.data&&s.current===r&&(o.current?.focus(),s.current=null)},[a.data,r]);let c=e=>{s.current=e,i(e)};return(0,L.jsxs)(`div`,{className:`space-y-3 p-4`,"data-sheet-loading":a.isFetching,children:[a.isPending&&(0,L.jsx)(`p`,{children:`Loading tasks…`}),a.isError&&(0,L.jsxs)(`p`,{role:`alert`,children:[`This snapshot may have expired or become unavailable.`,` `,(0,L.jsx)(O,{onClick:t,children:`Refresh overview`})]}),a.data&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{ref:o,tabIndex:-1,className:`text-xs text-muted-foreground`,children:[a.data.page.total,` tasks · Snapshot from`,` `,(0,L.jsxs)(`time`,{dateTime:a.data.asOf,title:new Date(a.data.asOf).toLocaleString(),children:[F(a.data.asOf),` ago`]})]}),a.data.page.rows.map(t=>(0,L.jsx)(qt,{row:t,group:e.group,projectName:n},`${t.projectId}:${t.id}`)),!a.data.page.rows.length&&(0,L.jsx)(`p`,{children:`No tasks in this group.`})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(O,{variant:`outline`,disabled:!r||a.isFetching,onClick:()=>c(Math.max(0,r-20)),children:`Previous`}),(0,L.jsx)(O,{variant:`outline`,disabled:!a.data||a.data.page.nextOffset===null||a.isFetching,onClick:()=>c(a.data.page.nextOffset),children:`Next`})]})]})}function qt({row:e,group:t,projectName:n}){let r=M(e),i=t===`running`||t===`needs-you`;i&&r&&(e={...e,...r});let o=r===null,c=i&&(e.archived||(t===`running`?e.status!==`running`:!s(e))),l=o||c,d=a(e),f=i&&o?`Task removed`:c?t===`running`?`No longer running`:`No longer needs you`:d.label;return(0,L.jsxs)(`div`,{className:`border-b py-3`,children:[(0,L.jsx)(u,{"aria-disabled":l||void 0,tabIndex:l?-1:void 0,onClick:e=>{l&&e.preventDefault()},className:`block min-h-11 font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,children:e.titleSummary||e.title}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,L.jsx)(P,{tone:d.tone}),` `,n(e.projectId),` ·`,` `,f,` · `,e.archived?`Archived · `:``,(0,L.jsxs)(`time`,{dateTime:e.finishedAt??e.createdAt,title:new Date(e.finishedAt??e.createdAt).toLocaleString(),children:[e.finishedAt?`Finished`:`Created`,` `,F(e.finishedAt??e.createdAt),` ago`]})]})]})}var Jt={snapshot:[...g.dashboard,`snapshot`],feed:e=>[...g.dashboard,`feed`,e],telemetry:[...g.dashboard,`telemetry`]},Yt=new Map;async function Xt(e){let t=k(),n=S.parse(await i(await p.api.v1.workspace.dashboard.$get({},{init:{signal:e}}),`/workspace/dashboard`));return Yt.has(n.snapshotId)||Yt.set(n.snapshotId,t),Yt.size>60&&Yt.delete(Yt.keys().next().value),A(t,[...n.questions.rows,...n.reviews.rows]),n}async function Zt(e,t,n=0,r=20,a){let o=b.parse(await i(await p.api.v1.workspace.dashboard.tasks.$get({query:{snapshotId:e,group:t,offset:String(n),limit:String(r)}},{init:{signal:a}}),`/workspace/dashboard/tasks`)),s=Yt.get(e);return s!==void 0&&A(s,o.page.rows),o}function Qt(e){return v({queryKey:Jt.snapshot,queryFn:({signal:e})=>Xt(e),enabled:e,staleTime:5e3,refetchOnMount:`always`,refetchInterval:e?15e3:!1,refetchIntervalInBackground:!1,retry:!1})}function $t(e){return v({queryKey:Jt.telemetry,enabled:e,staleTime:0,queryFn:async({signal:e})=>{let t=ee.parse(await i(await p.api.v1.workspace.dashboard.telemetry.$get({},{init:{signal:e}}),`/workspace/dashboard/telemetry`));return te.seed(t.samples,t.asOf),t}})}function en(e,t){let n=v({queryKey:Jt.feed(e),queryFn:async({signal:t})=>{let n=k(),r=T.parse(await i(await p.api.v1.workspace.dashboard.feed.$get({query:{filter:e}},{init:{signal:t}}),`/workspace/dashboard/feed`));return A(n,r.rows.flatMap(e=>e.kind===`task-result`?[e.run]:[])),r},enabled:t,staleTime:15e3,refetchInterval:t&&e!==`github`?15e3:!1,retry:!1}),r=(0,I.useRef)(!1);return(0,I.useEffect)(()=>{r.current=!1},[e,t]),(0,I.useEffect)(()=>{if(!t||r.current||!n.data?.sources.some(e=>e.reason===`Still loading GitHub`))return;let e=setTimeout(()=>{document.visibilityState!==`hidden`&&(r.current=!0,n.refetch())},5e3);return()=>clearTimeout(e)},[t,n.data,n.refetch]),n}function tn(e,t){let n=en(`tasks`,t&&e!==`github`),r=en(`github`,t&&e!==`tasks`),i=(0,I.useMemo)(()=>{if(e===`tasks`)return n.data;if(e===`github`)return r.data;let t=n.data,i=r.data;if(!t&&!i)return;let a=t??i,o=new Date(Math.max(Date.parse(t?.asOf??a.asOf),Date.parse(i?.asOf??a.asOf))).toISOString(),s=new Date(Date.parse(o)-10080*60*1e3).toISOString(),c=[...t?.rows??[],...i?.rows??[]].filter(e=>Date.parse(e.at)>=Date.parse(s)&&Date.parse(e.at)<=Date.parse(o)).sort((e,t)=>nn(e,t)),l=new Set(c.slice(60).map(e=>e.kind===`task-result`?`tasks:${e.run.projectId}`:e.key.slice(0,e.key.lastIndexOf(`:`)))),u=[...t?.sources??[],...i?.sources??[]].map(e=>l.has(e.key)?{...e,truncated:!0}:e);return{...a,asOf:o,windowStart:s,filter:`all`,rows:c.slice(0,60),sources:u,coverage:t?.coverage??a.coverage,truncated:c.length>60||!!t?.truncated||!!i?.truncated}},[e,n.data,r.data]),a=e===`github`?r:n;return{...a,data:i,githubError:r.isError,githubFetching:r.isFetching,retryTasks:()=>n.refetch(),retryFailed:()=>e===`github`?r.refetch():e===`tasks`?n.refetch():Promise.all([...n.isError?[n.refetch()]:[],...r.isError?[r.refetch()]:[]]),isPending:!i&&a.isPending,isError:a.isError||e===`all`&&r.isError,isFetching:a.isFetching||e===`all`&&r.isFetching,refetch:()=>e===`tasks`?n.refetch():r.refetch()}}function nn(e,t){return Date.parse(t.at)-Date.parse(e.at)||e.key.localeCompare(t.key)}var rn=[...g.dashboard,`costs`];function an(){let e=0,t=0,n,r=new Set;return{subscribe:e=>(r.add(e),()=>{r.delete(e)}),getSnapshot:()=>n,async read(i,a){let o=++e,s=await un(i,a);return!a?.aborted&&o>t&&(t=o,(n?.cost!==s.visibility.cost||n?.tokens!==s.visibility.tokens)&&(n=s.visibility,r.forEach(e=>e()))),s}}}var on=new WeakMap;function sn(e){let t=on.get(e);return t||(t=an(),on.set(e,t)),t}function cn(){let e=sn(m());return(0,I.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot)}var ln=new Map;async function un(e,t){let n=k(),r=C.parse(await i(await p.api.v1.workspace.dashboard.costs.$get({query:{...e,offset:String(e.offset??0),limit:`20`}},{init:{signal:t}}),`/workspace/dashboard/costs`));!e.snapshotId&&!ln.has(r.snapshotId)&&ln.set(r.snapshotId,n),ln.size>60&&ln.delete(ln.keys().next().value);let a=ln.get(r.snapshotId);return a!==void 0&&A(a,r.tasks.rows),r}function dn(e,t,n){let r=sn(m());return v({queryKey:[...rn,e,t,n],queryFn:({signal:n})=>r.read({period:e,sort:t,tzOffsetMinutes:new Date().getTimezoneOffset()},n),staleTime:5e3,refetchOnMount:`always`,refetchInterval:15e3,refetchIntervalInBackground:!1,retry:!1})}function fn(e,t,n,r){let i=sn(m());return v({queryKey:[...rn,`tasks`,e.snapshotId,t,n,r,e.visibility],retry:!1,queryFn:async({signal:a})=>{let o=e.tzOffsetMinutes??new Date().getTimezoneOffset(),s=async s=>{let c=await i.read({period:e.period,sort:n,snapshotId:s,projectId:t,tzOffsetMinutes:o},a),l=[...c.tasks.rows];for(;c.tasks.nextOffset!==null&&l.length<r;)c=await i.read({period:e.period,sort:n,snapshotId:c.snapshotId,projectId:t,offset:c.tasks.nextOffset},a),l.push(...c.tasks.rows);return{...c,tasks:{...c.tasks,rows:l}}};try{return await s(e.snapshotId)}catch(e){if(e instanceof d&&e.status===409)return s();throw e}}})}var pn={cost:{text:`text-primary`,fill:`bg-primary`,tint:H.primary,icon:ie},input:{text:`text-violet`,fill:`bg-violet`,tint:H.violet,icon:We},output:{text:`text-info`,fill:`bg-info`,tint:H.info,icon:Te}};function mn({metric:e,label:t,value:n,reported:r,total:i}){let a=pn[e],o=a.icon,s=i?Math.min(100,r/i*100):0;return(0,L.jsxs)(`div`,{className:`${tt} ${a.tint}`,children:[(0,L.jsxs)(nt,{label:t,value:n,icon:(0,L.jsx)(o,{className:`size-4 ${a.text}`}),children:[r,` of `,i,` tasks report this metric`]}),(0,L.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full ${a.fill} transition-[width] duration-300 motion-reduce:transition-none`,style:{width:`${s}%`}})})]})}function hn({projects:e,currentProjects:t,metric:n,field:r,label:i,format:a,onSelect:o}){let s=e.reduce((e,t)=>Math.max(e,t[r]?.value??0),0),c=pn[n];return(0,L.jsxs)(Ie,{delayDuration:150,children:[(0,L.jsxs)(`div`,{className:`space-y-1 rounded-xl border p-2`,"aria-label":`Projects ranked by ${i}`,children:[e.length===0&&(0,L.jsx)(`p`,{className:`px-3 py-4 text-muted-foreground`,children:`No projects to compare in this cohort.`}),e.slice(0,5).map((e,n)=>{let l=e[r],u=l?.value,d=u==null||s===0?0:u/s*100,f=u!=null;return(0,L.jsxs)(Le,{children:[(0,L.jsx)(Ne,{asChild:!0,children:(0,L.jsxs)(`button`,{"data-export-row":!0,"data-export-keep":!0,className:`group w-full rounded-lg px-3 py-3 text-left transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 motion-reduce:transition-none`,disabled:!t.some(t=>t.projectId===e.projectId),onClick:()=>o(e.projectId),children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`w-4 shrink-0 text-xs tabular-nums text-muted-foreground`,"aria-hidden":`true`,children:n+1}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-medium`,children:e.projectId}),(0,L.jsx)(`span`,{className:`shrink-0 font-semibold tabular-nums`,children:a(u)}),(0,L.jsx)(Re,{"data-export-exclude":!0,className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]}),(0,L.jsx)(`div`,{className:`mt-2 ml-7 h-2 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,L.jsx)(`div`,{"data-project-bar":e.projectId,className:`h-full rounded-full ${c.fill} transition-[width] duration-300 motion-reduce:transition-none`,style:{width:`${d}%`}})}),(0,L.jsxs)(`p`,{className:`mt-1.5 ml-7 text-xs text-muted-foreground`,children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric`,f?``:` · No measured value`]})]})}),(0,L.jsxs)(Pe,{className:`max-w-64`,children:[(0,L.jsxs)(`p`,{className:`font-medium`,children:[e.projectId,` · `,i,`: `,a(u)]}),(0,L.jsxs)(`p`,{children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric.`]}),(0,L.jsx)(`p`,{children:`Open project tasks`})]})]},e.projectId)})]}),e.length>0&&(0,L.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[e.length>5?`Top 5 of ${e.length} projects. `:``,`Bar lengths compare reported values; the largest is the reference.`]})]})}var Z={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},gn={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function _n(e,t){return JSON.stringify([e.totals,e.projects,e.tasks,e.visibility,e.coverage,e.invalidDateTasks])!==JSON.stringify([t.totals,t.projects,t.tasks,t.visibility,t.coverage,t.invalidDateTasks])}var vn=(e,t)=>gt(e,t===`cost`);function Q(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}function yn({value:e,onChange:t,visibility:n}){return(0,L.jsxs)(`label`,{className:$e,children:[`Sort by`,(0,L.jsx)(et,{value:e,onChange:e=>t(e.target.value),children:Q(n).map(e=>(0,L.jsx)(`option`,{value:e,children:gn[e]},e))})]})}function bn(){return(0,L.jsx)(xn,{visibility:Be(l().data)})}function xn({visibility:e}){return(0,L.jsxs)(N,{className:`gap-0 py-0`,children:[(0,L.jsx)(`div`,{className:B,children:(0,L.jsx)(`h2`,{className:z,children:`Usage & cost`})}),!e.cost&&!e.tokens?(0,L.jsx)(`p`,{className:`p-4 text-sm`,children:`Usage metrics are hidden by workspace settings`}):(0,L.jsx)(Sn,{visibility:e},`${e.cost}:${e.tokens}`)]})}function Sn({visibility:e}){let[t,n]=_t(`usagePeriod`,[`all`,`7d`,`30d`],`all`),[r,i]=_t(`usageSort`,Q(e),e.cost?`cost`:`input`);return(0,L.jsx)(Cn,{period:t,setPeriod:n,sort:r,setSort:i,visibility:e})}function Cn({period:e,setPeriod:t,sort:n,setSort:r,visibility:i}){let a=dn(e,n,`${i.cost}:${i.tokens}`),[o,s]=X(`usage:accepted`,void 0),c=o??a.data,l=a.data??c,[u,d]=X(`usage:panel`,null),[f,p]=(0,I.useState)(e);f!==e&&(p(e),s(void 0),d(null));let m=zt(`usage:${u?.identity??`closed`}`),h=Bt(`usage`,`[data-usage-trigger]`),g=e=>{h.capture(),c&&d({identity:Lt(),projectId:e,snapshot:c,latestId:l?.snapshotId??c.snapshotId})},_=cn()??i,v={cost:i.cost&&_.cost,tokens:i.tokens&&_.tokens},y=Q(v).includes(n)?n:Q(v)[0]??`cost`,b=[...c?.projects??[]].sort((e,t)=>{let n=e[Z[y]]?.value,r=t[Z[y]]?.value;return(n==null?r==null?0:1:r==null?-1:r-n)||e.projectId.localeCompare(t.projectId)});!o&&a.data&&s(a.data);let x=c&&l&&_n(c,l),S=c?.coverage.projects.some(e=>e.state!==`complete`),C=l?.coverage.projects.some(e=>e.state!==`complete`),w=JSON.stringify(c?.coverage)!==JSON.stringify(l?.coverage),T=c?.totals.tasks===0&&!S&&!C;return(0,L.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[c&&(0,L.jsx)(R,{rows:T?[]:[...Q(v).map(e=>({section:`totals`,metric:Z[e],value:c.totals[Z[e]]?.value??null,unit:e===`cost`?`USD`:`tokens`,reportedTasks:c.totals[Z[e]]?.reportedTasks??0,totalTasks:c.totals.tasks,asOf:c.asOf})),...(v.cost||v.tokens?b.slice(0,5):[]).map(e=>({section:`project`,entity:e.projectId,metric:Z[y],value:e[Z[y]]?.value??null,unit:y===`cost`?`USD`:`tokens`,reportedTasks:e[Z[y]]?.reportedTasks??0,totalTasks:e.tasks,asOf:c.asOf}))]}),c&&(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,L.jsx)(rt,{at:c.asOf})}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`font-medium`,children:`Lifetime totals of retained tasks`}),(0,L.jsxs)(`details`,{className:`mt-1 text-xs text-muted-foreground`,children:[(0,L.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${Qe} min-h-11`,children:[(0,L.jsx)(V,{}),`How these metrics work`]}),(0,L.jsxs)(`p`,{children:[`Includes archived tasks and subtasks.`,` `,v.cost&&`Reported USD is not an invoice. `,`Missing reports are excluded, not treated as zero. Calendar days use your current UTC offset, including today.`]})]})]}),(0,L.jsxs)(`label`,{className:$e,children:[`Tasks created`,(0,L.jsxs)(et,{value:e,onChange:e=>t(e.target.value),children:[(0,L.jsx)(`option`,{value:`all`,children:`All time`}),(0,L.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,L.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),e!==`all`&&(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Lifetime usage of tasks created in this period — not spending during the period.`}),a.isPending&&(0,L.jsx)(`p`,{children:`Loading usage…`}),a.isError&&(0,L.jsxs)(`p`,{role:`alert`,children:[c?`Showing stale usage. Could not refresh.`:`Could not load usage.`,` `,(0,L.jsx)(O,{className:`min-h-11`,onClick:()=>void a.refetch(),children:`Retry`})]}),x&&(0,L.jsx)(`p`,{role:`status`,children:`Newer usage data is available; displayed values use the previous snapshot.`}),x&&(0,L.jsx)(O,{className:`min-h-11`,variant:`outline`,onClick:()=>s(l),children:`Updates available — Show`}),c&&S&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed usage:`}),(0,L.jsx)(K,{coverage:c.coverage,retry:()=>void a.refetch()})]}),l&&C&&w&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,L.jsx)(K,{coverage:l.coverage,retry:()=>void a.refetch()})]}),c&&(0,L.jsxs)(L.Fragment,{children:[!T&&(0,L.jsx)(`div`,{className:`report-cost-metrics grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(220px,1fr))]`,children:Q(v).map(e=>(0,L.jsx)(mn,{metric:e,label:gn[e],value:vn(c.totals[Z[e]]?.value,e),reported:c.totals[Z[e]]?.reportedTasks??0,total:c.totals.tasks},e))}),!v.cost&&!v.tokens&&(0,L.jsx)(`p`,{children:`Usage metrics are hidden by workspace settings`}),c.totals.tasks===0?(0,L.jsx)(`p`,{children:S||C?`No retained tasks could be read from available sources.`:`No retained tasks in this cohort.`}):Q(v).every(e=>!c.totals[Z[e]]?.reportedTasks)&&(0,L.jsx)(`p`,{children:`No reports for the visible metrics in this cohort.`}),T&&(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Usage appears when tasks report cost or tokens.`}),(0,L.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Deleted tasks are excluded from retained history.`,c.invalidDateTasks?` ${c.invalidDateTasks} tasks have missing or invalid creation dates${e===`all`?`; included in All time`:`; excluded from this period`}.`:``]}),!T&&(v.cost||v.tokens)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`font-medium`,children:`Top projects`}),(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Ranking uses reported metrics only.`})]}),(0,L.jsx)(yn,{value:y,onChange:r,visibility:v})]}),(0,L.jsx)(hn,{projects:b,metric:y,label:gn[y],field:Z[y],format:e=>vn(e,y),currentProjects:l?.projects??[],onSelect:g}),(0,L.jsx)(O,{"data-usage-trigger":!0,className:`min-h-11`,variant:`outline`,onClick:()=>g(``),children:`View tasks`})]})]}),(0,L.jsx)(we,{open:u!==null&&(v.cost||v.tokens),onOpenChange:e=>{e||d(null)},children:(0,L.jsxs)(Ce,{...m,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),h.restore()},children:[(0,L.jsxs)(be,{children:[(0,L.jsx)(Se,{children:u?.projectId?`${u.projectId} tasks`:`All tasks`}),(0,L.jsx)(xe,{children:`Lifetime usage of retained tasks. Missing reports are unavailable.`})]}),u!==null&&(0,L.jsx)(wn,{identity:`usage:${u.identity}`,snapshot:l&&l.snapshotId!==u.latestId?l:u.snapshot,projectId:u.projectId||void 0,visibility:v},u.identity)]})})]})}function wn({identity:e,snapshot:t,projectId:n,visibility:r}){let[i,a]=X(`${e}:sort`,t.sort);return(0,L.jsx)(Tn,{identity:e,snapshot:t,projectId:n,visibility:r,sort:Q(r).includes(i)?i:Q(r)[0]??`cost`,setSort:a})}function Tn({identity:e,snapshot:t,projectId:n,visibility:r,sort:i,setSort:a}){let[o,s]=X(`${e}:count`,20),[c,l]=X(`${e}:paging`,void 0),[u,d]=(0,I.useState)(t.snapshotId);u!==t.snapshotId&&(d(t.snapshotId),l(void 0));let f=fn(c??t,n,i,o),p=cn()??r,m={cost:r.cost&&p.cost,tokens:r.tokens&&p.tokens},h=Q(m).includes(i)?i:Q(m)[0]??`cost`,[g,_]=X(`${e}:accepted`,void 0),[v,y]=X(`${e}:acceptedCount`,o),[b,x]=X(`${e}:acceptedSort`,i),[S,C]=(0,I.useState)(i);S!==i&&(C(i),s(20),l(g??c??t)),f.data&&(!g||(v!==o||b!==i)&&g.snapshotId===f.data.snapshotId)&&(_(f.data),y(o),x(i));let w=g??f.data,T=f.data&&w&&_n(f.data,w),ee=w?.coverage.projects.some(e=>e.state!==`complete`),E=f.data?.coverage.projects.some(e=>e.state!==`complete`),D=JSON.stringify(w?.coverage)!==JSON.stringify(f.data?.coverage),te=!n||t.projects.some(e=>e.projectId===n);return(0,L.jsxs)(`div`,{className:`space-y-3 p-4 text-sm`,"data-sheet-loading":f.isFetching,children:[(0,L.jsx)(yn,{value:h,onChange:a,visibility:m}),f.isPending&&(0,L.jsx)(`p`,{children:`Loading tasks…`}),f.isError&&(0,L.jsxs)(`p`,{role:`alert`,children:[`Could not refresh tasks. `,w?`Showing stale usage.`:``,` `,(0,L.jsx)(O,{className:`min-h-11`,onClick:()=>void f.refetch(),children:`Retry`})]}),T&&(0,L.jsx)(O,{className:`min-h-11`,onClick:()=>{_(f.data),y(o),x(i)},children:`Updates available — Show`}),w&&ee&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed tasks:`}),(0,L.jsx)(K,{coverage:w.coverage,retry:()=>void f.refetch()})]}),f.data&&E&&D&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,L.jsx)(K,{coverage:f.data.coverage,retry:()=>void f.refetch()})]}),w&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`border-b pb-2 font-mono text-[11px] text-soft-foreground`,children:[w.tasks.rows.length,` of `,w.tasks.total,` retained tasks`]}),w.tasks.total===0&&(0,L.jsx)(`p`,{children:w.coverage.projects.some(e=>e.state!==`complete`)?`No tasks could be read from available sources.`:`No retained tasks in this cohort.`}),w.tasks.rows.map(e=>(0,L.jsx)(En,{row:e,sort:h,visibility:m,disabled:!te||!f.data||!!(T&&!f.data?.tasks.rows.some(t=>t.id===e.id&&t.projectId===e.projectId))},`${e.projectId}:${e.id}`)),w.tasks.nextOffset!==null&&(0,L.jsx)(O,{className:`min-h-11`,disabled:f.isFetching,onClick:()=>{l(w),s(e=>e+20)},children:`Show 20 more tasks`})]})]})}function En({row:e,sort:t,visibility:n,disabled:r}){let i=M(e);r||=i===null;let o=a(i?{status:i.status,awaitingAnswerSince:i.awaitingAnswerSince}:e),s=Q(n).filter(e=>e!==t),c=t=>{let n=e[Z[t]];return n==null?`—`:vn(n,t)},l=t=>`${gn[t]}: ${vn(e[Z[t]],t)}`;return(0,L.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-4 border-b py-3 last:border-0`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(P,{tone:o.tone,pulse:o.pulse,className:`mt-[7px]`}),(0,L.jsx)(u,{className:`line-clamp-2 break-words font-medium leading-snug hover:underline no-hover:min-h-11`,title:e.title,to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,"aria-disabled":r||void 0,tabIndex:r?-1:void 0,onClick:e=>{r&&e.preventDefault()},children:e.title})]}),(0,L.jsxs)(`p`,{className:`mt-1 pl-[15px] font-mono text-[11px] text-soft-foreground`,children:[e.projectId,` · `,r?`Checking current state…`:i?.status??e.status,e.archived?` · Archived`:``,e.subtask?` · Subtask`:``]})]}),(0,L.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,L.jsx)(`span`,{"aria-label":l(t),className:`block font-semibold ${e[Z[t]]==null?`text-soft-foreground`:``}`,children:c(t)}),s.length>0&&(0,L.jsx)(`span`,{className:`mt-1 flex justify-end gap-3 font-mono text-[11px] text-soft-foreground`,children:s.map(e=>(0,L.jsxs)(`span`,{"aria-label":l(e),children:[c(e),` `,e===`cost`?``:e===`input`?`in`:`out`]},e))})]})]})}var Dn={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},On={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function kn(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}var An=(e,t)=>gt(e,t===`cost`);function jn(e){return new Date(`${e}T00:00:00`).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Mn({series:e,height:t,accent:n,renderTooltip:r,describe:i}){let a=Math.max(1,...e.map(t));return(0,L.jsxs)(Ie,{delayDuration:150,children:[(0,L.jsx)(`div`,{className:`flex h-20 items-end gap-0.5`,role:`group`,"aria-label":`Daily trend`,children:e.map(e=>{let o=t(e),s=Math.max(o>0?4:0,o/a*100);return(0,L.jsxs)(Le,{children:[(0,L.jsx)(Ne,{asChild:!0,children:(0,L.jsx)(`button`,{"data-export-keep":!0,"aria-label":i(e),type:`button`,className:`min-w-0 flex-1 rounded-t-sm transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,style:{height:`100%`,display:`flex`,alignItems:`end`},children:(0,L.jsx)(`span`,{style:{height:`${s}%`},className:`block w-full rounded-t-sm ${n}`})})}),(0,L.jsx)(Pe,{children:r(e)})]},e.date)})}),(0,L.jsxs)(`div`,{className:`mt-1 flex justify-between text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{children:jn(e[0].date)}),(0,L.jsx)(`span`,{children:jn(e.at(-1).date)})]})]})}function Nn({metrics:e,series:t}){return(0,L.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b`,children:[(0,L.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`Date`}),e.map(e=>(0,L.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:On[e]},e)),(0,L.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:`Completed`}),(0,L.jsx)(`th`,{className:`py-1 text-right font-medium`,children:`Avg cycle`})]})}),(0,L.jsx)(`tbody`,{children:t.map(t=>(0,L.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,L.jsx)(`td`,{className:`py-1 pr-2`,children:jn(t.date)}),e.map(e=>(0,L.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:An(t[Dn[e]]?.value,e)},e)),(0,L.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:t.completed}),(0,L.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.avgCycleHours===null?`—`:q(t.avgCycleHours)})]},t.date))})]})}function Pn({metric:e,series:t}){let n=pn[e],r=Dn[e],i=t.reduce((e,t)=>e+(t[r]?.reportedTasks??0),0);return(0,L.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium ${n.text}`,children:On[e]}),(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(Mn,{series:t,describe:t=>`${t.date}, ${On[e]}: ${An(t[r]?.value,e)}, ${t[r]?.reportedTasks??0} of ${t.tasks} tasks reported`,height:e=>e[r]?.value??0,accent:n.fill,renderTooltip:t=>(0,L.jsxs)(`p`,{children:[jn(t.date),` · `,An(t[r]?.value,e),` ·`,` `,t[r]?.reportedTasks??0,`/`,t.tasks,` tasks reported`]})})}),i===0&&(0,L.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No reports in this period.`})]})}function Fn({series:e}){let t=e.reduce((e,t)=>e+t.completed,0),n=e.reduce((e,t)=>e+(t.avgCycleHours??0)*(t.cycleReportedTasks??t.completed),0),r=e.reduce((e,t)=>e+(t.cycleReportedTasks??t.completed),0),i=r?n/r:null;return(0,L.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-success`,children:`Completed tasks`}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` done · avg cycle`,` `,i===null?`unavailable`:q(i)]})]}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r,`/`,t,` completed tasks have valid cycle times.`]}),(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(Mn,{series:e,describe:e=>`${e.date}: ${e.completed} completed tasks, average cycle ${e.avgCycleHours==null?`Unavailable`:q(e.avgCycleHours)}`,height:e=>e.completed,accent:`bg-success`,renderTooltip:e=>(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`p`,{children:[jn(e.date),` · `,e.completed,` completed`]}),(0,L.jsxs)(`p`,{children:[`Avg cycle`,` `,e.avgCycleHours===null?`unavailable`:q(e.avgCycleHours),` · Median`,` `,e.medianCycleHours===null?`unavailable`:q(e.medianCycleHours)]})]})})}),t===0&&(0,L.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No tasks finished in this period.`})]})}function In(){return(0,L.jsx)(Ln,{visibility:Be(l().data)})}function Ln({visibility:e}){let[t,n]=_t(`trendPeriod`,[`7d`,`30d`],`7d`),r=dn(t,e.cost?`cost`:`input`,`${e.cost}:${e.tokens}`),i=r.data,a=i&&i.totals.tasks===0&&i.coverage.projects.every(e=>e.state===`complete`)&&i.series.every(e=>e.tasks===0&&e.completed===0),o=kn({cost:e.cost&&i?.visibility.cost!==!1,tokens:e.tokens&&i?.visibility.tokens!==!1});return(0,L.jsxs)(N,{className:`gap-0 py-0`,children:[(0,L.jsxs)(`div`,{className:B,children:[(0,L.jsx)(`h2`,{className:z,children:`Trends`}),(0,L.jsxs)(`label`,{className:$e,children:[`Period`,(0,L.jsxs)(et,{value:t,onChange:e=>n(e.target.value),children:[(0,L.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,L.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,L.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[i&&(0,L.jsx)(R,{rows:a?[]:i.series.flatMap(e=>[...o.map(t=>({section:`daily-creation-cohort`,entity:e.date,metric:Dn[t],value:e[Dn[t]]?.value??null,unit:t===`cost`?`USD`:`tokens`,reportedTasks:e[Dn[t]]?.reportedTasks??0,totalTasks:e.tasks,asOf:i.asOf,note:`Lifetime usage grouped by task creation date; not daily spend`})),{section:`daily-completions`,entity:e.date,metric:`completed`,value:e.completed,unit:`tasks`,asOf:i.asOf},{section:`daily-completions`,entity:e.date,metric:`avgCycleHours`,value:e.avgCycleHours,reportedTasks:e.cycleReportedTasks??e.completed,totalTasks:e.completed,unit:`hours`,asOf:i.asOf},{section:`daily-completions`,entity:e.date,metric:`medianCycleHours`,value:e.medianCycleHours,unit:`hours`,asOf:i.asOf}])}),(0,L.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,L.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${Qe} py-2`,children:[(0,L.jsx)(V,{}),`How these metrics work`]}),(0,L.jsx)(`p`,{children:`Usage is grouped by creation date, not spending date. Completed tasks are grouped by finish date. Calendar days use your current UTC offset (fixed across the period), including today.`})]}),r.isPending&&(0,L.jsx)(`p`,{children:`Loading trends…`}),r.isError&&(0,L.jsxs)(`p`,{role:`alert`,children:[i?`Showing stale trends. Could not refresh.`:`Could not load trends.`,` `,(0,L.jsx)(O,{className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry`})]}),i&&(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,L.jsx)(rt,{at:i.asOf})}),i&&(0,L.jsx)(K,{coverage:i.coverage,retry:()=>void r.refetch()}),i&&a&&(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`No retained tasks in this period yet.`}),i&&!a&&i.series.length>0&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`space-y-4`,children:[o.length>0&&(0,L.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(200px,1fr))]`,children:o.map(e=>(0,L.jsx)(Pn,{metric:e,series:i.series},e))}),(0,L.jsx)(Fn,{series:i.series})]}),(0,L.jsxs)(`details`,{className:`group rounded-lg border bg-muted/20 print:block`,children:[(0,L.jsxs)(`summary`,{"data-export-heading":`Daily data`,className:`flex min-h-11 cursor-pointer list-none items-center gap-2 px-3 text-xs font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden`,children:[(0,L.jsx)(Je,{className:`size-4`,"aria-hidden":`true`}),` View data table`,(0,L.jsx)(Fe,{className:`ml-auto size-4 transition-transform group-open:rotate-180`,"aria-hidden":`true`})]}),(0,L.jsx)(`div`,{className:`max-h-80 overflow-auto border-t p-3 print:max-h-none print:overflow-visible`,role:`region`,"aria-label":`Daily trend values`,tabIndex:0,children:(0,L.jsx)(Nn,{metrics:o,series:i.series})})]})]})]})]})}function Rn(e,t,n,r=!0){let i=m();return v({queryKey:[...Jt.snapshot,e?.snapshotId,t,n],enabled:r&&!!e,retry:!1,queryFn:async({signal:r})=>{if(!e)throw Error(`Dashboard not loaded`);let a=[];try{for(let i=0;i<n;){let o=await Zt(e.snapshotId,t,i,Math.min(20,n-i),r);if(a.push(...o.page.rows),o.page.nextOffset===null)break;i=o.page.nextOffset}return a}catch(e){if(e instanceof d&&e.status===409){let e=await Xt(r);i.setQueryData(Jt.snapshot,e)}throw e}}})}function zn(e,t,n,r){let i=m(),a=t===`questions`||t===`reviews`?`needs-you`:t,o=a===`needs-you`?0:n,s=r.map(e=>`${e.projectId}:${e.id}`).sort();return v({queryKey:[...Jt.snapshot,e.snapshotId,t,`displaced`,...s],enabled:s.length>0,retry:!1,queryFn:async({signal:t})=>{let n=new Set(s),r=new Map;try{for(let i=o;i!==null&&n.size;){let o=await Zt(e.snapshotId,a,i,20,t);for(let e of o.page.rows){let t=`${e.projectId}:${e.id}`;n.delete(t)&&r.set(t,e)}i=o.page.nextOffset}return r}catch(e){throw e instanceof d&&e.status===409&&i.setQueryData(Jt.snapshot,await Xt(t)),e}}})}function Bn({snapshot:e,questions:t,reviews:n,more:r,healthy:i=!0}){let a=pe();return(0,L.jsxs)(N,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,L.jsxs)(`div`,{className:B,children:[(0,L.jsxs)(`h2`,{id:`dashboard-needs-you`,tabIndex:-1,className:z,children:[`Needs you · `,e.counts.questions+e.counts.reviews]}),(0,L.jsxs)(`p`,{className:`font-mono text-[11px] text-soft-foreground`,children:[e.counts.questions,` questions · `,e.counts.reviews,` reviews`]})]}),i&&a.connected&&e.counts.questions+e.counts.reviews===0&&e.coverage.projects.every(e=>e.state===`complete`)?(0,L.jsxs)(`p`,{className:`flex items-center gap-2.5 px-4 py-8 text-sm text-muted-foreground`,children:[(0,L.jsx)(P,{tone:`success`}),`All caught up — no tasks need your input`]}):null,(0,L.jsx)(Vn,{snapshot:e,group:`questions`,count:t,more:r}),(0,L.jsx)(Vn,{snapshot:e,group:`reviews`,count:n,more:r})]})}function Vn({snapshot:e,group:t,count:n,more:r}){let i=e[t],a=Math.max(n,i.rows.length),o=Rn(e,t,a,a>i.rows.length),s=a>i.rows.length?o.data:i.rows,c=lt(s,G,t,n),l=zn(e,t,a,c.rows.filter(e=>e.removed).map(e=>e.row)),u=(0,I.useRef)(null);return!i.total&&!c.rows.length?null:(0,L.jsxs)(`section`,{children:[(0,L.jsxs)(`h3`,{ref:u,tabIndex:-1,className:`border-b bg-card-2 px-4 py-2 font-mono text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:[t===`questions`?`Questions`:`Reviews`,` · `,i.total]}),c.updates>0&&(0,L.jsxs)(O,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>{c.show(),u.current?.focus()},children:[c.updates,` updates — Show`]}),c.rows.map(({row:e,removed:t})=>(0,L.jsx)(ht,{row:l.data?.get(G(e))??e,removed:t&&!!l.data&&!l.data.has(G(e)),checking:s===void 0||t&&!l.data,checkFailed:s===void 0&&o.isError||t&&!l.data&&l.isError,queue:!0},G(e))),(o.isError||l.isError)&&(0,L.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not check current task state.`,` `,(0,L.jsx)(O,{variant:`ghost`,className:`min-h-11`,onClick:()=>{o.refetch(),l.refetch()},children:`Retry`})]}),a<i.total&&(0,L.jsxs)(O,{variant:`ghost`,className:`m-2 min-h-11`,disabled:o.isFetching,onClick:()=>r(t,a+Math.min(20,i.total-a)),children:[`Show `,Math.min(20,i.total-a),` more `,t]})]})}function Hn(e){if(!e.startsWith(`github:`))return e===`tasks`?`Task results`:e;let t=e.slice(7).split(`:`),n=t.pop()===`pr`?`Pull requests`:`Issues`;return`${t.join(`:`).replace(/^project:/,`Project `).replace(/^github.com\//,``)} · ${n}`}var Un=e=>e.key;function Wn({filter:e,setFilter:t,count:n,more:r}){let i=tn(e,!0),a=lt(i.data?.rows,Un,`feed:${e}`,0,e=>e.kind===`task-result`),o=a.rows,s=a.updates,c=(0,I.useContext)(st),l=(0,I.useRef)(null),u=`feed:${e}`,d=(0,I.useMemo)(()=>({scroll:pt(c,u)?.scroll??0,done:!1}),[c,u]);(0,I.useLayoutEffect)(()=>{!l.current||d.done||(l.current.scrollTop=d.scroll,d.done=Math.abs(l.current.scrollTop-d.scroll)<1||!!i.data&&!i.isPending&&!i.isFetching)},[d,o.length,n,i.data,i.isPending,i.isFetching]);let f=(0,I.useRef)(null),p=i.data?.sources.filter(e=>e.key.startsWith(`github:`))??[],m=p.flatMap(e=>e.fetchedAt?[e.fetchedAt]:[]).sort()[0],h=i.githubError,g=p.filter(e=>e.reason===`No GitHub remote`),_=p.some(e=>e.reason===`Still loading GitHub`),v=p.length>0&&g.length===p.length&&!h,y=p.filter(e=>e.state!==`ready`&&e.reason!==`No GitHub remote`&&e.reason!==`Still loading GitHub`),b=v&&e===`all`;return(0,L.jsxs)(N,{"data-export-context":`Results source: ${e}; Last 7 days; loaded ${Math.min(n,o.length)} rows`,className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,L.jsxs)(`div`,{className:`space-y-2 border-b px-4 pt-2.5 pb-2`,children:[(0,L.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center justify-between gap-2`,children:[(0,L.jsx)(`h2`,{ref:f,tabIndex:-1,className:z,children:b?`Recent results`:`Recent results & GitHub`}),(0,L.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:`Last 7 days`})]}),!b&&(0,L.jsx)(se,{slot:`dashboard-feed`,label:`Results source`,value:e,options:[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`github`,label:`GitHub`}],onChange:t}),b&&(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Task results · No GitHub repositories configured`}),e!==`tasks`&&!b&&(0,L.jsxs)(`details`,{className:`text-xs text-muted-foreground`,open:y.length||h?!0:void 0,children:[(0,L.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden py-1.5`,children:[(0,L.jsx)(V,{}),y.length||h?`GitHub needs attention`:_?`Checking GitHub…`:v?`GitHub not configured`:m?`GitHub checked ${F(m)} ago`:`GitHub source`]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3`,children:[(0,L.jsx)(`p`,{children:y.length||h?m?`Could not refresh GitHub. Showing results from ${new Date(m).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}.`:`Could not load one or more GitHub sources.`:_?`Checking repository sources. Available results remain visible.`:v?`No GitHub repositories configured. Select Tasks to see task results.`:m?`GitHub checked ${F(m)} ago`:`GitHub snapshot`}),!v&&(0,L.jsx)(O,{variant:`ghost`,className:`min-h-11 px-0`,disabled:i.githubFetching,onClick:()=>{i.refetch()},children:i.githubFetching?`Refreshing…`:y.length||h?`Retry GitHub`:`Refresh GitHub`})]})]})]}),(0,L.jsxs)(`div`,{role:`region`,"aria-label":`Recent results list`,ref:l,onWheel:()=>{d.done=!0},onTouchStart:()=>{d.done=!0},onKeyDown:()=>{d.done=!0},onScroll:e=>{c&&d.done&&mt(c,u,{count:n,scroll:e.currentTarget.scrollTop})},tabIndex:0,className:`max-h-80 overflow-y-auto overscroll-contain focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[i.isError&&(0,L.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not load results.`,` `,(0,L.jsx)(O,{className:`min-h-11`,onClick:()=>{i.retryFailed()},children:`Retry`})]}),i.isPending&&(0,L.jsx)(`p`,{className:`p-4 text-sm`,children:`Loading results…`}),s>0&&(0,L.jsxs)(O,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>{a.show(),f.current?.focus()},children:[s,` updates — Show`]}),o.slice(0,n).map(({row:e,removed:t})=>e.kind===`task-result`?(0,L.jsx)(ht,{row:e.run,kicker:t?`Outside current results`:`Latest result: ${e.run.status===`failed`?`Failed`:`Completed`}`},e.key):(0,L.jsxs)(`div`,{className:`border-b px-4 py-3 transition-colors hover:bg-muted/30`,children:[(0,L.jsx)(R,{rows:[{section:`github`,entity:`${e.repo}#${e.number}`,metric:e.itemKind,value:e.title,asOf:e.at,note:e.url}]}),(0,L.jsx)(`a`,{className:`block break-words text-sm font-medium hover:underline no-hover:min-h-11`,href:e.url,target:`_blank`,rel:`noreferrer`,children:e.title}),(0,L.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.repo,` · `,e.itemKind===`pr`?`PR`:`Issue`,` #`,e.number,` created ·`,` `,F(e.at)]})]},e.key)),i.data&&!i.data.rows.length&&!o.length&&!i.isFetching&&!i.isError&&!y.length&&!_&&i.data.coverage.projects.every(e=>e.state===`complete`)&&(0,L.jsx)(`p`,{className:`px-4 py-8 text-sm text-muted-foreground`,children:`No results in the last 7 days`}),n<o.length&&(0,L.jsxs)(O,{variant:`ghost`,className:`m-2 min-h-11`,onClick:r,children:[`Show `,Math.min(20,o.length-n),` more results`]}),i.data?.truncated&&(0,L.jsx)(`p`,{className:`p-4 text-xs`,children:`Showing the latest 60 results`}),i.data&&(0,L.jsx)(K,{coverage:i.data.coverage,retry:()=>{i.retryTasks()}}),!b&&i.data?.sources.some(e=>e.state!==`ready`||e.truncated)&&(0,L.jsxs)(`details`,{className:`p-4 text-xs`,children:[(0,L.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden min-h-11`,children:[(0,L.jsx)(V,{}),`Source details`]}),i.data.sources.map(e=>(0,L.jsxs)(`p`,{className:`break-words py-1`,children:[Hn(e.key),`:`,` `,e.reason===`No GitHub remote`?`Not configured`:e.reason===`Still loading GitHub`?`Checking…`:e.reason??(e.state===`ready`?`Up to date`:e.state),e.truncated?` · capped`:``,e.fetchedAt?` · checked ${F(e.fetchedAt)}`:``]},e.key))]})]})]})}var $=e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]),Gn=`Visible modules and loaded rows only. Filters and report availability apply. Retained task usage is not an invoice or a complete history.`,Kn=`Confidential — internal distribution only`,qn={costUsd:{label:`Reported cost`,usd:!0},inputTokens:{label:`Input tokens`},outputTokens:{label:`Output tokens`},needsYou:{label:`Needs you`},running:{label:`Running now`},completed:{label:`Completed in period`},failed:{label:`Failed outcomes in period`},medianCycleHours:{label:`Median cycle (hours)`}};function Jn(e,t){return e==null?`Unavailable`:typeof e==`string`?e:gt(e,t)}function Yn(e){let t=new Set,n=[];for(let r of e.modules)for(let e of r.rows){if(e.section!==`totals`&&e.section!==`fleet`&&e.section!==`overview`)continue;let i=qn[e.metric];!i||t.has(e.metric)||(t.add(e.metric),n.push({label:i.label,value:Jn(e.value,i.usd),note:[e.metric===`needsYou`||e.metric===`running`?e.note||`Current non-archived state`:r.filters,e.asOf?`Data as of ${e.asOf}`:``,e.reportedTasks==null?``:`${e.reportedTasks} of ${e.totalTasks} tasks reported`].filter(Boolean).join(` · `)}))}return n}function Xn(e){let t=e.cloneNode(!0);t.querySelectorAll(`script,style,link,img,iframe,object,embed,input,[hidden],[data-dashboard-export],[data-export-exclude]`).forEach(e=>e.remove()),t.querySelectorAll(`select`).forEach((t,n)=>{let r=e.querySelectorAll(`select`)[n];t.replaceWith(document.createTextNode(`: `+(r?.selectedOptions[0]?.textContent??``)))}),t.querySelectorAll(`[data-export-row],[data-dashboard-row]`).forEach(e=>e.classList.add(`report-row`)),t.querySelectorAll(`summary`).forEach(e=>{let t=document.createElement(`h3`);t.textContent=e.getAttribute(`data-export-heading`)||e.textContent,e.replaceWith(t)}),t.querySelectorAll(`button`).forEach(e=>{if(e.hasAttribute(`data-export-keep`)){let t=document.createElement(`div`);for(let n of[...e.attributes])[`class`,`style`,`title`].includes(n.name)&&t.setAttribute(n.name,n.value);t.append(...e.childNodes),e.replaceWith(t)}else e.remove()}),t.querySelectorAll(`details`).forEach(e=>{let t=document.createElement(`div`);t.className=e.className,t.append(...e.childNodes),e.replaceWith(t)});for(let e of[t,...t.querySelectorAll(`*`)])for(let t of[...e.attributes])(t.name.startsWith(`on`)||[`href`,`src`,`srcset`,`action`,`formaction`,`tabindex`].includes(t.name)||t.name.startsWith(`data-`))&&e.removeAttribute(t.name);return t.removeAttribute(`style`),t.innerHTML}function Zn(e,t,n,r){return{generatedAt:t,source:n,title:r||void 0,notices:[...e.querySelectorAll(`[role=alert],[role=status]`)].filter(e=>!e.closest(`[data-dashboard-module]`)).map(e=>e.textContent?.trim()??``).filter(Boolean),modules:[...e.querySelectorAll(`[data-dashboard-module]`)].map(e=>{let t=[...e.querySelectorAll(`select`)].map(e=>`${e.closest(`label`)?.childNodes[0]?.textContent?.trim()??`Filter`}: ${e.selectedOptions[0]?.textContent}`).concat([...e.querySelectorAll(`[data-export-context]`)].map(e=>e.dataset.exportContext)).join(`; `),n=[...new Set([...e.querySelectorAll(`p,[role="alert"],[role="status"]`)].filter(e=>!e.closest(`table,[data-export-exclude]`)&&!e.querySelector(`p,[role="alert"],[role="status"]`)).map(e=>{let t=e.cloneNode(!0);return t.querySelectorAll(`table,button,select,summary,[data-export-exclude]`).forEach(e=>e.remove()),t.textContent?.trim()}).filter(Boolean))].join(` | `);return{id:e.dataset.dashboardModule,title:e.querySelector(`h2`)?.textContent??e.dataset.dashboardModule,filters:t,notes:n,html:Xn(e),rows:[...e.querySelectorAll(`[data-dashboard-export]`)].flatMap(e=>JSON.parse(e.dataset.dashboardExport))}})}}function Qn(e){let t=e==null?``:String(e);return typeof e==`string`&&/^[\s\uFEFF]*[=+@\-]/.test(t)&&(t=`'${t}`),`"${t.replaceAll(`"`,`""`)}"`}function $n(e){let t=[[`generated_at`,`source`,`module`,`filters`,`section`,`entity`,`metric`,`value`,`unit`,`availability`,`reported_tasks`,`total_tasks`,`as_of`,`notes`]];for(let n of e.modules){t.push([e.generatedAt,e.source,n.title,n.filters,`context`,``,`scope`,Gn,``,``,``,``,``,[...e.title?[`Report title: ${e.title}`]:[],...e.notices,n.notes].join(` | `)]);for(let r of n.rows)t.push([e.generatedAt,e.source,n.title,n.filters,r.section,r.entity,r.metric,r.value,r.unit,r.value===null?`unavailable`:typeof r.value==`number`?`measured`:`reported`,r.reportedTasks,r.totalTasks,r.asOf,r.note])}return``+t.map(e=>e.map(Qn).join(`,`)).join(`\r
|
|
2
|
+
`)+`\r
|
|
3
|
+
`}function er(e,t){let n=Yn(e);return`<!doctype html><html class="light"><head><meta charset="utf-8"><title>${$(e.title||`Dashboard`)} ${$(e.generatedAt.slice(0,10))}</title>${t.join(``)}<style>
|
|
4
|
+
@page {
|
|
5
|
+
size:A4; margin:14mm 14mm 18mm;
|
|
6
|
+
@bottom-left { content:"${Kn}"; font-family:system-ui,sans-serif; font-size:9px; color:var(--muted-foreground); }
|
|
7
|
+
@bottom-right { content:"Page " counter(page) " of " counter(pages); font-family:system-ui,sans-serif; font-size:9px; color:var(--muted-foreground); }
|
|
8
|
+
}
|
|
9
|
+
html,body { height:auto!important; overflow:visible!important; background:var(--background)!important; color:var(--foreground)!important; }
|
|
10
|
+
* { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
|
|
11
|
+
body { margin:0; font:12px/1.5 system-ui,sans-serif; }
|
|
12
|
+
.report-heading { border-bottom:2px solid var(--violet); padding-bottom:16px; margin-bottom:20px; }
|
|
13
|
+
.report-heading h1 { font-size:26px; margin:0 0 8px; }
|
|
14
|
+
.report-heading p { margin:4px 0; color:var(--muted-foreground); }
|
|
15
|
+
.report-confidential { display:inline-block; margin:6px 0; padding:2px 8px; border:1px solid var(--destructive); border-radius:4px; color:var(--destructive); font-size:11px; font-weight:600; letter-spacing:.03em; text-transform:uppercase; }
|
|
16
|
+
.report-summary { margin:0 0 24px; }
|
|
17
|
+
.report-summary h2 { font-size:12px; margin:0 0 10px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted-foreground); }
|
|
18
|
+
.summary-grid { display:flex; flex-wrap:wrap; gap:12px; }
|
|
19
|
+
.summary-tile { flex:1 1 140px; border:1px solid var(--border); border-radius:8px; padding:12px 14px; break-inside:avoid; }
|
|
20
|
+
.summary-value { display:block; font-size:22px; font-weight:600; }
|
|
21
|
+
.summary-label { display:block; font-size:11px; color:var(--muted-foreground); margin-top:2px; }
|
|
22
|
+
.summary-note { display:block; font-size:10px; color:var(--soft-foreground); margin-top:4px; }
|
|
23
|
+
.report-module { margin:0 0 20px; break-before:auto; }
|
|
24
|
+
.report-module h2,.report-module h3 { break-after:avoid; }
|
|
25
|
+
.report-module-usage, .report-module-fleet { break-inside:avoid; }
|
|
26
|
+
.report-module-usage label { min-height:0!important; }
|
|
27
|
+
.report-module-usage .space-y-4 > :not(:last-child) { margin-block-end:8px!important; }
|
|
28
|
+
.report-module-usage .report-row { padding-top:5px!important; padding-bottom:5px!important; }
|
|
29
|
+
.report-cost-metrics { grid-template-columns:repeat(3,minmax(0,1fr))!important; }
|
|
30
|
+
.report-cost-metrics > div { padding:12px!important; break-inside:avoid; }
|
|
31
|
+
.report-cost-metrics .text-3xl { font-size:22px!important; }
|
|
32
|
+
.report-module > :first-child, .report-module header, .report-context { break-after:avoid; }
|
|
33
|
+
.report-module .report-row, .report-module tr { break-inside:avoid; }
|
|
34
|
+
.report-module thead { display:table-header-group; }
|
|
35
|
+
.report-module .report-row { padding-top:8px!important; padding-bottom:8px!important; }
|
|
36
|
+
.report-module a { min-height:0!important; }
|
|
37
|
+
.report-module > div { padding-top:12px!important; padding-bottom:12px!important; }
|
|
38
|
+
.report-module * { overflow:visible !important; max-height: none !important; animation:none!important; transition:none!important; box-shadow:none!important; }
|
|
39
|
+
.report-module a { color:inherit; text-decoration:none; }
|
|
40
|
+
.report-module svg { max-width:24px; }
|
|
41
|
+
.report-module [role=region] > div, .report-module [role=region] > p { break-inside:avoid; }
|
|
42
|
+
.report-module .sr-only { display:none!important; }
|
|
43
|
+
.report-context { font-size:11px; color:var(--muted-foreground); margin:0 0 8px; }
|
|
44
|
+
</style></head><body><header class="report-heading"><h1>${$(e.title||`Dashboard report`)}</h1><p>${$(e.generatedAt)} · ${$(e.source)}</p><span class="report-confidential">${Kn}</span><p>${$(Gn)}</p>${e.notices.map(e=>`<p>${$(e)}</p>`).join(``)}</header>${n.length?`<section class="report-summary"><h2>Executive summary</h2><div class="summary-grid">${n.map(e=>`<div class="summary-tile"><span class="summary-value">${$(e.value)}</span><span class="summary-label">${$(e.label)}</span>${e.note?`<span class="summary-note">${$(e.note)}</span>`:``}</div>`).join(``)}</div></section>`:``}${e.modules.map(e=>`<section class="report-module${e.id===`usage`?` report-module-usage`:e.id===`fleet`?` report-module-fleet`:``}"><p class="report-context">${$(e.filters)}</p>${e.html}</section>`).join(``)}</body></html>`}function tr({dashboard:e}){let[t,n]=(0,I.useState)(!1),[r,i]=(0,I.useState)(``),[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(``),l=t=>{i(``);try{if(!e.current)return;let r=Zn(e.current,new Date().toISOString(),location.origin,s.trim());if(!r.modules.length){i(`Show at least one dashboard module before exporting.`);return}if(t===`csv`){let e=URL.createObjectURL(new Blob([$n(r)],{type:`text/csv;charset=utf-8`})),t=document.createElement(`a`);t.href=e,t.download=`dashboard-${r.generatedAt.replaceAll(`:`,`-`)}.csv`,document.body.append(t),t.click(),t.remove(),setTimeout(()=>URL.revokeObjectURL(e),1e3),n(!1)}else{o(!0);let e=[...document.querySelectorAll(`link[rel="stylesheet"],style`)].flatMap(e=>{if(e.tagName===`STYLE`)return[e.outerHTML];let t=e.href;if(new URL(t).origin!==location.origin)return[];let n=document.createElement(`link`);return n.rel=`stylesheet`,n.href=t,[n.outerHTML]}),t=document.createElement(`iframe`);t.title=`Dashboard PDF report`,t.style.cssText=`position:fixed;width:1000px;height:1px;bottom:0;left:0;border:0;opacity:0;pointer-events:none`;let a,s=()=>{clearTimeout(a),t.remove(),o(!1)};t.onload=async()=>{try{let e=t.contentWindow;await e.document.fonts.ready,e.addEventListener(`afterprint`,s,{once:!0}),e.focus(),e.print(),n(!1),o(!1)}catch{s(),i(`Could not open the print dialog. Please try again.`)}},a=setTimeout(s,12e4),t.srcdoc=er(r,e),document.body.append(t)}}catch{o(!1),i(`Could not prepare the export. Please try again.`)}};return(0,L.jsxs)(Oe,{open:t,onOpenChange:n,children:[(0,L.jsx)(De,{asChild:!0,children:(0,L.jsxs)(O,{variant:`outline`,className:`min-h-11`,disabled:a,children:[(0,L.jsx)(ze,{className:`size-4`}),a?`Preparing report…`:`Export`]})}),(0,L.jsxs)(Ee,{align:`end`,className:`max-w-[calc(100vw-2rem)] space-y-3`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:`Export current dashboard`}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Visible modules, current filters and loaded rows. Hidden metrics are excluded.`}),(0,L.jsxs)(`label`,{className:`block space-y-1 text-xs text-muted-foreground`,children:[`Report title (optional)`,(0,L.jsx)(`input`,{className:`min-h-11 w-full rounded-md border bg-background px-3 text-sm text-foreground`,placeholder:`e.g. Fleet review for leadership`,value:s,onChange:e=>c(e.target.value)})]}),(0,L.jsx)(O,{className:`min-h-11 w-full`,onClick:()=>l(`pdf`),children:`PDF report…`}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Choose Save as PDF in the print dialog.`}),(0,L.jsx)(O,{variant:`outline`,className:`min-h-11 w-full`,onClick:()=>l(`csv`),children:`Download CSV`}),r&&(0,L.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r})]})]})}var nr={overview:`Workspace overview`,portfolio:`Projects`,automations:`Automations`,fleet:`Queue & scheduling`,needsYou:`Needs you`,recent:`Recent results & GitHub`,usage:`Usage & cost`,trends:`Trends`};function rr({id:e,children:t,wide:n}){let{attributes:r,listeners:i,setNodeRef:a,setActivatorNodeRef:o,transform:s,isDragging:c}=de({id:e});return(0,L.jsxs)(`section`,{ref:a,"data-dashboard-module":e,className:`group/module relative min-w-0 ${n?`lg:col-span-2`:``} ${c?`z-20 opacity-80`:``}`,style:{transform:s?`translate3d(${s.x}px, ${s.y}px, 0)`:void 0},children:[(0,L.jsx)(O,{ref:o,variant:`ghost`,className:`absolute -top-[22px] left-1/2 z-10 min-h-11 min-w-11 -translate-x-1/2 cursor-grab touch-none p-0 opacity-0 transition-opacity hover:bg-transparent focus-visible:opacity-100 active:cursor-grabbing group-hover/module:opacity-100 no-hover:opacity-100`,...r,...i,"aria-label":`Move ${nr[e]}`,children:(0,L.jsx)(`span`,{className:`flex h-4 w-8 items-center justify-center rounded-full border bg-card text-muted-foreground shadow-xs`,children:(0,L.jsx)(qe,{className:`size-3.5`,"aria-hidden":`true`})})}),t]})}function ir({order:e,modules:t,onOrder:n}){let r=ve(oe(ge,{activationConstraint:{distance:8}}),oe(ae,{coordinateGetter:me})),i=e.filter(e=>t[e]),a=new Set([`overview`,`portfolio`,`usage`,`trends`]),o;for(let e of i)a.has(e)?(o&&a.add(o),o=void 0):o=o?void 0:e;o&&a.add(o);let s=e=>`${nr[e]}, position ${i.indexOf(e)+1} of ${i.length}`;return(0,L.jsx)(ue,{sensors:r,collisionDetection:ye,accessibility:{announcements:{onDragStart:({active:e})=>`Picked up ${s(e.id)}.`,onDragOver:({active:e,over:t})=>t?`${nr[e.id]} moved to position ${i.indexOf(t.id)+1} of ${i.length}.`:void 0,onDragEnd:({active:e,over:t})=>t?`${nr[e.id]} dropped at position ${i.indexOf(t.id)+1} of ${i.length}.`:`Order unchanged. ${s(e.id)}.`,onDragCancel:({active:e})=>`Reordering cancelled. ${s(e.id)}.`},screenReaderInstructions:{draggable:`Press Space to pick up a module, use arrow keys to move, Space to drop, or Escape to cancel.`}},onDragEnd:({active:t,over:r})=>{!r||t.id===r.id||n(le(e,e.indexOf(t.id),e.indexOf(r.id)))},children:(0,L.jsx)(ce,{items:i,strategy:he,children:(0,L.jsx)(`div`,{className:`grid items-start gap-5 lg:grid-cols-2`,children:i.map(e=>(0,L.jsx)(rr,{id:e,wide:a.has(e),children:t[e]},e))})})})}var ar=[`overview`,`needsYou`,`recent`,`fleet`,`automations`,`portfolio`,`usage`,`trends`],or=e=>ar.includes(e);function sr(e=[]){let t=e.filter(or);return(e=>t.length===e.length&&t.every((t,n)=>t===e[n]))(ar.filter(e=>e!==`automations`))?[...ar]:[...new Set([...t.includes(`overview`)?[]:[`overview`],...t,...ar])]}function cr(e=[],t){let n=0;return[...e.map(e=>or(e)?t[n++]:e),...t.slice(n)]}function lr(){let e=_(),t=m(),[n,i]=(0,I.useState)(),[a,s]=(0,I.useState)(!1),c=(0,I.useRef)(void 0),l=(0,I.useRef)(!1),u=E.parse(e.data?.dashboard??{}),d=(0,I.useRef)(u);d.current=u;let f=n?.tiles??{automations:u.tiles?.automations??!0,fleet:u.tiles?.fleet??!0,needsYou:u.tiles?.needsYou??!0,recent:u.tiles?.recent??!0,usage:u.tiles?.usage??!0,trends:u.tiles?.trends??!0},p=sr(n?.order??u.order),h=(0,I.useRef)({tiles:f,order:p});h.current=n??{tiles:f,order:p};let v=e=>{let t={...h.current,...e};h.current=t,i(t),c.current=t},y=async()=>{if(!(l.current||!c.current)){for(l.current=!0;c.current;){let n=c.current;c.current=void 0;try{e.data||(d.current=E.parse((await o()).dashboard??{}));let a=await r({dashboard:{...d.current,order:cr(d.current.order,n.order),tiles:{...d.current?.tiles,...n.tiles}}});t.setQueryData(g.uiState,a),d.current=E.parse(a.dashboard??{}),s(!1),i(e=>e===n?void 0:e)}catch{s(!0),c.current||=n;break}}l.current=!1}},b=(0,I.useRef)(y);return b.current=y,(0,I.useEffect)(()=>()=>{b.current()},[]),(0,I.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{y()},250);return()=>clearTimeout(e)},[n]),{tiles:f,order:p,setOrder:e=>v({order:sr(e)}),failed:a,ready:e.data!==void 0||e.isError,setTiles(e){v({tiles:e})},retry:()=>{y()}}}function ur(e,t){let n=ar.filter(e=>t.includes(e)),r=0;return e.map(e=>t.includes(e)?n[r++]:e)}var dr=[[`overview`,`Overview`],[`costs`,`Usage & cost`],[`automations`,`Automations`]];function fr(){let e=f(),t=e.state?.dashboardEntry??e.key;return(0,L.jsx)(pr,{entryKey:t},t)}function pr({entryKey:e}){let t=f(),[n,r]=h(),i=(0,I.useRef)(dt(e)).current,[a,o]=(0,I.useState)(i?.questions??0),[s,c]=(0,I.useState)(i?.reviews??0),[l,d]=(0,I.useState)(i?.feed??6),p=(0,I.useRef)(null),m=(0,I.useRef)(null),[g,_]=(0,I.useState)(!1),v=lr(),[y,b]=(0,I.useState)(!1),x=n.get(`view`)===`costs`?`costs`:n.get(`view`)===`automations`?`automations`:`overview`,S=dr.find(([e])=>e===x)[1],C=x===`costs`?[`usage`,`trends`]:x===`automations`?[`automations`]:[`fleet`,`needsYou`,`recent`],w=x===`overview`?[`overview`,`portfolio`,...C]:[...C],T=ur(v.order,w),ee=()=>v.setTiles({...v.tiles,...Object.fromEntries(C.map(e=>[e,!0]))}),E=v.tiles,D={...E,automations:x===`automations`&&E.automations,fleet:x===`overview`&&E.fleet,needsYou:x===`overview`&&E.needsYou,recent:x===`overview`&&E.recent,usage:x===`costs`&&E.usage,trends:x===`costs`&&E.trends},te=n.get(`feed`)===`tasks`?`tasks`:n.get(`feed`)===`github`?`github`:`all`,re=n.get(`panel`),k=re&&[`running`,`queued`,`scheduled`,`needs-you`].includes(re)?re:null,A=D.fleet||D.needsYou||D.recent&&te!==`github`||!!k,j=Qt(v.ready&&A),M=pe();$t(v.ready&&D.fleet&&y);let ie=(0,I.useRef)({questions:a,reviews:s,feed:l,scroll:i?.scroll??0,focus:i?.focus});ie.current={...ie.current,questions:a,reviews:s,feed:l},(0,I.useEffect)(()=>{let t=p.current?.closest(`main`)??p.current,n=()=>{ie.current.scroll=t?.scrollTop??0},r=()=>{ie.current.focus=document.activeElement?.closest(`[data-dashboard-row]`)?.getAttribute(`data-dashboard-row`)??void 0};return t?.addEventListener(`scroll`,n),document.addEventListener(`focusin`,r),()=>{ft(e,ie.current),t?.removeEventListener(`scroll`,n),document.removeEventListener(`focusin`,r)}},[e]);let ae=(0,I.useRef)(!1),oe=v.ready&&(!A||!!j.data&&!j.isFetching);(0,I.useEffect)(()=>{if(!i||ae.current||!oe)return;let e=!1,t=()=>{if(e)return!0;let t=p.current?.closest(`main`)??p.current;t&&(t.scrollTop=i.scroll);let n=!!t&&Math.abs(t.scrollTop-i.scroll)<1;if(!i.focus)return n;let r=document.querySelector(`[data-dashboard-row="${CSS.escape(i.focus)}"] a`);return r?(r.focus({preventScroll:!0}),n):(document.getElementById(`dashboard-needs-you`)?.focus({preventScroll:!0}),!1)},n=()=>{t()&&o()},r=new MutationObserver(n),a=typeof ResizeObserver>`u`?null:new ResizeObserver(n),o=()=>{e=!0,ae.current=!0,r.disconnect(),a?.disconnect()},s=requestAnimationFrame(()=>{n(),e||(r.observe(document.body,{childList:!0,subtree:!0}),p.current&&a?.observe(p.current))}),c=setTimeout(o,5e3),l=[`pointerdown`,`keydown`,`wheel`,`touchstart`];for(let e of l)document.addEventListener(e,o,{once:!0});return()=>{cancelAnimationFrame(s),clearTimeout(c),e=!0,r.disconnect(),a?.disconnect();for(let e of l)document.removeEventListener(e,o)}},[i,oe]);let se=i=>{let a=new URLSearchParams(n);i?a.set(`panel`,i):a.delete(`panel`),r(a,{replace:!0,state:{...t.state,dashboardEntry:e}})},ce=(e,t)=>{m.current=t,se(e)},le=j.data?j.data.counts.questions+j.data.counts.reviews:0;return(0,L.jsx)(st.Provider,{value:e,children:(0,L.jsx)(ct.Provider,{value:!i||!j.isFetching&&!j.isError,children:(0,L.jsxs)(`div`,{ref:p,"data-route":`dashboard`,className:`mx-auto w-full max-w-[1440px] space-y-6 p-4 md:px-8 md:py-7`,children:[(0,L.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Dashboard`}),(0,L.jsxs)(`p`,{className:`mt-1 flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground`,children:[`Across your workspace · Includes subtasks`,(0,L.jsxs)(`span`,{"data-export-exclude":!0,className:`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 font-mono text-[10.5px] uppercase tracking-[0.1em]`,children:[(0,L.jsx)(P,{tone:M.connected?`success`:`neutral`,pulse:M.connected}),M.connected?`Live`:`Offline`]})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsx)(tr,{dashboard:p}),(0,L.jsxs)(Oe,{open:g,onOpenChange:_,children:[(0,L.jsx)(De,{asChild:!0,children:(0,L.jsxs)(O,{variant:`outline`,className:`min-h-11`,children:[(0,L.jsx)(ne,{className:`size-4`}),`Customize`]})}),(0,L.jsxs)(Ee,{align:`end`,className:`max-h-[min(32rem,80dvh)] max-w-[calc(100vw-2rem)] overflow-y-auto`,children:[(0,L.jsx)(`p`,{className:`mb-3 text-sm font-medium`,children:`Optional modules in this view`}),C.map(e=>(0,L.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:E[e],disabled:!v.ready,onChange:t=>v.setTiles({...E,[e]:t.target.checked})}),{automations:`Automations`,fleet:`Queue & scheduling`,needsYou:`Needs you`,recent:`Recent results & GitHub`,usage:`Usage & cost`,trends:`Trends`}[e]]},e)),(0,L.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Drag a module by its handle. With keyboard: Space, arrow keys, Space. Escape cancels.`}),v.order.some((e,t)=>e!==T[t])&&(0,L.jsxs)(O,{variant:`ghost`,className:`min-h-11`,onClick:()=>v.setOrder(T),children:[`Reset `,S,` order`]}),(0,L.jsx)(`p`,{className:`my-3 text-xs text-muted-foreground`,children:`Shared across browsers using this workspace`}),C.some(e=>!E[e])&&(0,L.jsxs)(O,{variant:`outline`,className:`min-h-11`,disabled:!v.ready,onClick:()=>{ee(),_(!1)},children:[`Show all in `,S]})]})]})]})]}),(0,L.jsx)(`nav`,{"aria-label":`Dashboard views`,className:`-mt-2 flex flex-wrap gap-5 border-b`,children:dr.map(([r,i])=>{let a=new URLSearchParams(n);return a.set(`view`,r),a.delete(`panel`),(0,L.jsx)(O,{asChild:!0,variant:`ghost`,className:`-mb-px min-h-11 rounded-none border-b-2 px-0.5 hover:bg-transparent ${x===r?`border-primary text-foreground`:`border-transparent`}`,children:(0,L.jsx)(u,{"aria-current":x===r?`page`:void 0,to:`?${a}`,replace:x===r,state:{...t.state,dashboardEntry:x===r?e:void 0},children:i})},r)})}),v.failed&&(0,L.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Layout changed for this session, but could not be saved.`,` `,(0,L.jsx)(O,{variant:`ghost`,className:`min-h-11`,onClick:v.retry,children:`Retry saving`})]}),A&&!M.connected&&j.data&&(0,L.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[`Tasks disconnected · Last updated `,F(j.data.asOf),` ago`]}),A&&j.isError&&(0,L.jsxs)(`p`,{role:`alert`,className:`rounded-md border p-4 text-sm`,children:[`Could not refresh dashboard.`,` `,j.data?`Showing the last available task state.`:``,` `,(0,L.jsx)(O,{className:`min-h-11`,onClick:()=>{j.refetch()},children:`Retry`})]}),x===`costs`&&!Object.values(D).some(Boolean)?(0,L.jsxs)(`p`,{role:`status`,className:`flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(_e,{className:`size-4`,"aria-hidden":`true`}),`Optional modules in this view are hidden.`,(0,L.jsxs)(O,{variant:`outline`,className:`min-h-11`,onClick:()=>ee(),children:[`Show all in `,S]})]}):null,j.isPending&&(D.fleet||D.needsYou)&&(0,L.jsx)(`p`,{className:`text-sm`,children:`Loading dashboard…`}),A&&j.data&&(0,L.jsx)(K,{coverage:j.data.coverage,count:le,retry:()=>void j.refetch()}),x===`automations`&&(0,L.jsx)(Pt,{}),(0,L.jsx)(Gt,{active:x===`overview`,onCurrent:ce,children:i=>v.ready&&(0,L.jsx)(ir,{order:v.order,onOrder:v.setOrder,modules:{...i,automations:D.automations?(0,L.jsx)(it,{}):null,fleet:D.fleet&&j.data?(0,L.jsxs)(N,{className:`gap-0 py-0`,children:[(0,L.jsx)(R,{rows:Object.entries({queued:j.data.counts.queued,scheduled:j.data.counts.scheduled,monitoring:j.data.counts.monitoring}).map(([e,t])=>({section:`fleet`,metric:e,value:t,unit:`tasks`,asOf:j.data.asOf}))}),(0,L.jsxs)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,children:[(0,L.jsx)(`h2`,{className:`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Queue & scheduling`}),(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(P,{tone:M.connected?`success`:`neutral`}),M.connected?`Tasks connected`:`Tasks disconnected`]})]}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 divide-x`,children:[[`queued`,`Queued`,j.data.counts.queued],[`scheduled`,`Scheduled`,j.data.counts.scheduled]].map(([e,t,n])=>(0,L.jsxs)(`button`,{"data-export-keep":!0,"aria-label":`${t}: ${n}`,className:`min-h-24 p-4 text-left transition-colors hover:bg-muted/40 focus-visible:outline-ring`,onClick:t=>ce(e,t.currentTarget),children:[(0,L.jsx)(`span`,{className:`block font-mono text-[11px] uppercase tracking-[0.12em] text-muted-foreground`,children:t}),(0,L.jsx)(`span`,{className:`mt-3 block text-3xl font-semibold leading-none tracking-tight tabular-nums`,children:n})]},e))}),(0,L.jsxs)(`details`,{open:y,onToggle:e=>b(e.currentTarget.open),className:`border-t px-4 py-3 text-xs text-muted-foreground`,children:[(0,L.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden py-2`,children:[(0,L.jsx)(V,{}),`Technical details`]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-2`,children:[(0,L.jsxs)(`span`,{children:[j.data.counts.monitoring,` monitoring (included in Running)`]}),(0,L.jsx)(`span`,{children:`Agent processes`}),y&&(0,L.jsx)(mr,{running:j.data.counts.running})]})]})]}):null,needsYou:D.needsYou&&j.data?(0,L.jsx)(Bn,{healthy:!j.isError,snapshot:j.data,questions:a,reviews:s,more:(e,t)=>e===`questions`?o(t):c(t)}):null,recent:D.recent?(0,L.jsx)(Wn,{filter:te,setFilter:i=>{let a=new URLSearchParams(n);a.set(`feed`,i||`all`),r(a,{replace:!0,state:{...t.state,dashboardEntry:e}}),d(6)},count:l,more:()=>d(e=>Math.min(60,e+20))}):null,usage:D.usage?(0,L.jsx)(bn,{}):null,trends:D.trends?(0,L.jsx)(In,{}):null}})}),x===`costs`&&(0,L.jsx)(Mt,{}),(0,L.jsx)(we,{open:!!k,onOpenChange:e=>{e||se(null)},children:(0,L.jsxs)(Ce,{className:`w-full overflow-y-auto sm:max-w-lg`,onCloseAutoFocus:e=>{e.preventDefault(),m.current?.focus()},children:[(0,L.jsxs)(be,{children:[(0,L.jsxs)(Se,{children:[k===`needs-you`?`Needs you`:k?k[0].toUpperCase()+k.slice(1):`Tasks`,j.data&&k?` · ${k===`needs-you`?le:j.data.counts[k]}`:``]}),(0,L.jsx)(xe,{children:`Includes subtasks. Open a task to continue in its project.`})]}),!j.data&&j.isPending&&(0,L.jsx)(`p`,{className:`p-4`,role:`status`,children:`Loading tasks…`}),!j.data&&j.isError&&(0,L.jsxs)(`p`,{className:`p-4`,role:`alert`,children:[`Could not load tasks.`,` `,(0,L.jsx)(O,{className:`min-h-11`,onClick:()=>{j.refetch()},children:`Retry`})]}),k&&j.data&&(0,L.jsx)(hr,{snapshot:j.data,group:k},k)]})})]})})})}function mr({running:e}){let{connected:t,samples:n}=pe(),r=t?n:[],i=r.filter(e=>e.cpuPct!==null);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(R,{rows:[{section:`telemetry`,metric:`cpuPct`,value:i.length?i.reduce((e,t)=>e+(t.cpuPct??0),0):null,unit:`%`,reportedTasks:i.length,totalTasks:e,note:`Sum of sampled processes; may exceed 100%`},{section:`telemetry`,metric:`rssBytes`,value:r.length?r.reduce((e,t)=>e+t.rssBytes,0):null,unit:`bytes`,reportedTasks:r.length,totalTasks:e}]}),(0,L.jsxs)(`span`,{children:[`CPU`,` `,i.length?`${Math.round(i.reduce((e,t)=>e+(t.cpuPct??0),0))}%`:`unavailable`,` `,`· `,i.length,`/`,e,` measured`]}),(0,L.jsxs)(`span`,{children:[`RSS`,` `,r.length?`${(r.reduce((e,t)=>e+t.rssBytes,0)/1024**3).toFixed(1)} GiB`:`unavailable`,` `,`· `,r.length,`/`,e,` measured`]}),(0,L.jsx)(`span`,{children:`RSS sums process resident memory; CPU may exceed 100%.`})]})}function hr({snapshot:e,group:t}){let n=(0,I.useContext)(st),r=(0,I.useRef)(pt(n,t)).current,[i,a]=(0,I.useState)(r?.count??20),o=(0,I.useRef)(null),s=(0,I.useRef)({count:i,scroll:r?.scroll??0});s.current.count=i,(0,I.useEffect)(()=>{let e=o.current?.closest(`[data-slot="sheet-content"]`),r=()=>{s.current.scroll=e?.scrollTop??0};return e?.addEventListener(`scroll`,r),()=>{mt(n,t,s.current),e?.removeEventListener(`scroll`,r)}},[n,t]);let c=Rn(e,t,i),l=lt(c.data,G,`panel:${t}`,i),u=zn(e,t,i,l.rows.filter(e=>e.removed).map(e=>e.row)),d=(0,I.useRef)(null),f=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!c.data||!r||f.current)return;f.current=!0;let e=o.current?.closest(`[data-slot="sheet-content"]`);e&&(e.scrollTop=r.scroll)},[c.data,r]);let p=t===`needs-you`?e.counts.questions+e.counts.reviews:e.counts[t];return(0,L.jsxs)(`div`,{ref:o,children:[(0,L.jsx)(`h3`,{ref:d,tabIndex:-1,className:`sr-only`,children:`Tasks`}),c.isPending&&(0,L.jsx)(`p`,{className:`p-4`,children:`Loading tasks…`}),(c.isError||u.isError)&&(0,L.jsxs)(`p`,{className:`p-4`,role:`alert`,children:[`Could not check current task state.`,` `,(0,L.jsx)(O,{className:`min-h-11`,onClick:()=>{c.refetch(),u.refetch()},children:`Retry`})]}),l.updates>0&&(0,L.jsxs)(O,{className:`m-4 min-h-11`,onClick:()=>{l.show(),d.current?.focus()},children:[l.updates,` updates — Show`]}),l.rows.map(({row:e,removed:n})=>(0,L.jsx)(ht,{row:u.data?.get(G(e))??e,removed:n&&!!u.data&&!u.data.has(G(e)),checking:!c.data||n&&!u.data,checkFailed:!c.data&&c.isError||n&&!u.data&&u.isError,queue:t===`needs-you`},G(e))),i<p&&(0,L.jsxs)(O,{className:`m-4 min-h-11`,disabled:c.isFetching,onClick:()=>a(e=>e+20),children:[`Show `,Math.min(20,p-i),` more tasks`]})]})}export{fr as DashboardRoute};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-view-DP4Gw3QJ.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/button-BNnH7COh.js","assets/bundle-mjs-BT31bpU6.js","assets/chevron-right-Beu1pd6H.js","assets/use-submit-shortcut-BA4NVpJl.js","assets/diff-stat-SpfygteL.js","assets/chunk-BO2N2NFS-MDrqQfMl.js","assets/lib-BxQXEXDF.js","assets/markdown-BpZ4p95p.js","assets/alert-dialog-Dd1WPOaz.js","assets/index-BN3w52uE.js","assets/project-router-CWMOKp_H.js","assets/use-automations-PceYR6ss.js","assets/sheet-D9PeyyRZ.js","assets/x-HaVPcg_B.js","assets/reference-chip-B7lU_Pyh.js","assets/tooltip-BVqBAGNb.js","assets/triangle-alert-CP3Xp0FU.js","assets/token-metrics-BcPjL36-.js","assets/check-DA37PQLT.js","assets/use-now-BAKdIYLG.js","assets/reference-overflow-ClRRXWez.js","assets/textarea-rKUFh5lI.js","assets/dropdown-menu-CxPGHgWX.js","assets/composer-DKWLJeo9.js","assets/square-DsFAQaY9.js","assets/centered-state-sEYB3bgq.js","assets/thread-loading-DLlbK51g.js","assets/search-x-6BavY3mg.js","assets/upload-bwO_2kok.js","assets/pill-BcIQGDbn.js","assets/index-CAvSSpvF.css","assets/lib-BQXq3kEf.js","assets/markdown-C5F95Rt-.js","assets/message-square-BFQln9c4.js","assets/scroll-within-DRt7mAnQ.js","assets/types-BTlmexWF.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{r}from"./button-BNnH7COh.js";import{i}from"./bundle-mjs-BT31bpU6.js";import{t as a}from"./diff-stat-SpfygteL.js";import{i as o,n as s,r as c,t as l}from"./scroll-within-DRt7mAnQ.js";var u=e(t(),1),d=n();function f(e){let[t,n]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let e=!1;return i(()=>import(`./diff-view-DP4Gw3QJ.js`).then(t=>{e||n({View:t.DiffView})},()=>{e||n(`failed`)}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38])),()=>{e=!0}},[]),e.files.length===0?(0,d.jsx)(`p`,{"data-slot":`diff-empty`,className:r(`px-1 text-xs text-soft-foreground`,e.className),children:`No changes.`}):t===`failed`?(0,d.jsx)(p,{...e}):t===null?(0,d.jsx)(`p`,{"data-slot":`diff-loading`,className:r(`px-1 text-xs text-soft-foreground`,e.className),children:`Loading diff…`}):(0,d.jsx)(t.View,{...e})}function p({files:e,wrap:t=!1,imageSrc:n,onOpenInApp:i,viewRef:o,className:c}){let f={adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length},p=(0,u.useRef)(null);return(0,u.useImperativeHandle)(o,()=>({scrollToPath:e=>{for(let t of p.current?.querySelectorAll(`[data-slot="diff-file"]`)??[])if(t.dataset.path===e){let e=l(t);e&&s(e,t,Number.parseFloat(getComputedStyle(t).scrollMarginTop)||0);return}}})),(0,d.jsxs)(`div`,{ref:p,"data-slot":`diff`,"data-fallback":`true`,className:r(`flex min-w-0 flex-col gap-3`,c),children:[(0,d.jsxs)(`p`,{"data-slot":`diff-totals`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,d.jsxs)(`span`,{children:[f.files,` `,f.files===1?`file`:`files`,` changed`]}),(0,d.jsx)(a,{stat:f})]}),e.map(e=>(0,d.jsx)(m,{file:e,wrap:t,imageSrc:n,onOpenInApp:i},`${e.oldPath??``}→${e.path}`))]})}function m({file:e,wrap:t,imageSrc:n,onOpenInApp:i}){return(0,d.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 scroll-mt-[var(--diff-sticky-top,0px)] overflow-clip rounded-md border border-border bg-card`,children:[(0,d.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,d.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?`${e.oldPath} → ${e.path}`:e.path}),(0,d.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,d.jsx)(a,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-[11px]`})})]}),o(e)?(0,d.jsx)(c,{file:e,imageSrc:n,onOpenInApp:i}):e.binary?(0,d.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.patch===``?(0,d.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,d.jsx)(`pre`,{className:r(`py-2 font-mono text-xs leading-[1.7]`,t?`break-words whitespace-pre-wrap`:`overflow-x-auto whitespace-pre`),children:e.patch.split(`
|
|
3
|
+
`).map((e,t)=>(0,d.jsxs)(`span`,{className:r(`block px-4`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-diff-add`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-soft-foreground`),children:[e,e===``?` `:``]},t))})]})}export{f as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-runtime-CCIEwYL0.js";import{r as t}from"./button-
|
|
1
|
+
import{t as e}from"./react-runtime-CCIEwYL0.js";import{r as t}from"./button-BNnH7COh.js";var n=e();function r({stat:e,className:r}){let i=`+${e.adds} −${e.dels} across ${e.files} ${e.files===1?`file`:`files`}`,a=e.repointed?`${i} — measured against another branch checked out in this task's worktree, as this task found it`:void 0;return(0,n.jsxs)(`span`,{"data-slot":`diff-stat`,...a?{"data-repointed":`true`,"aria-label":a}:{},title:a??i,className:t(`font-mono text-xs font-semibold tabular-nums`,e.repointed&&`cursor-help underline decoration-dotted underline-offset-2`,r),children:[(0,n.jsxs)(`span`,{className:`text-success`,children:[`+`,e.adds]}),` `,(0,n.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.dels]})]})}export{r as t};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{F as r,r as i,t as a}from"./button-BNnH7COh.js";import{t as o}from"./chevron-right-Beu1pd6H.js";import{r as s,t as c}from"./use-submit-shortcut-BA4NVpJl.js";import{t as l}from"./diff-stat-SpfygteL.js";import{o as u}from"./chunk-BO2N2NFS-MDrqQfMl.js";import{a as d,i as f,r as p,t as m}from"./markdown-BpZ4p95p.js";import{R as h}from"./index-BN3w52uE.js";import{t as g}from"./lib-BQXq3kEf.js";import{n as _,t as v}from"./markdown-C5F95Rt-.js";import{i as ee,n as y,r as te,t as b}from"./scroll-within-DRt7mAnQ.js";import{n as x,t as ne}from"./types-BTlmexWF.js";var S=r(`message-square-off`,[[`path`,{d:`M19 19H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.7.7 0 0 1 2 21.286V5a2 2 0 0 1 1.184-1.826`,key:`1wyg69`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.656 3H20a2 2 0 0 1 2 2v11.344`,key:`mhl4k6`}]]),C=e(t(),1),w=44;function T(e){if(e.binary===!0||e.patch===``)return 1;let t=e.patch.split(`
|
|
2
|
+
`),n=t.findIndex(e=>e.startsWith(`@@`));return n===-1?t.length:t.length-n}function re(e){return T(e)*20+w}function ie(e){return e.reduce((e,t)=>e+T(t),0)}function ae(e,t){let n=new URLSearchParams(e).get(`diff`);return n===`flat`||n===`virtual`?n:t>1500?`virtual`:`flat`}function E(e){return`${e.oldPath??``}→${e.path}`}function D(e){let t=0;for(let n of e.split(`
|
|
3
|
+
`))n.length>t&&(t=n.length);return t}var O=/[A-Za-z0-9_]+|\s+|[^\sA-Za-z0-9_]+/g,k=300,A=.3;function j(e,t){if(e===t)return null;let n=e.match(O)??[],r=t.match(O)??[];if(n.length===0||r.length===0||n.length>k||r.length>k)return null;let i=r.length+1,a=new Uint16Array((n.length+1)*i);for(let e=1;e<=n.length;e++)for(let t=1;t<=r.length;t++)a[e*i+t]=n[e-1]===r[t-1]?(a[(e-1)*i+(t-1)]??0)+1:Math.max(a[(e-1)*i+t]??0,a[e*i+(t-1)]??0);if((a[n.length*i+r.length]??0)/Math.max(n.length,r.length)<A)return null;let o=Array(n.length).fill(!1),s=Array(r.length).fill(!1),c=n.length,l=r.length;for(;c>0&&l>0;)n[c-1]===r[l-1]?(o[c-1]=!0,s[l-1]=!0,c--,l--):(a[(c-1)*i+l]??0)>=(a[c*i+(l-1)]??0)?c--:l--;return{del:M(n,o),add:M(r,s)}}function M(e,t){let n=[];return e.forEach((e,r)=>{let i=!(t[r]??!1),a=n[n.length-1];a&&a.changed===i?a.text+=e:n.push({text:e,changed:i})}),n}function N(e,t,n){if(!t||t.length===0)return e?e.map(e=>({text:e.content,color:e.color,changed:!1})):n===``?[]:[{text:n,changed:!1}];if(!e||e.length===0)return t.map(e=>({text:e.text,changed:e.changed}));let r=[],i=0,a=0,o=0,s=0;for(;i<e.length&&o<t.length;){let n=e[i],c=t[o],l=n.content.length-a,u=c.text.length-s,d=Math.min(l,u);d>0&&(r.push({text:n.content.slice(a,a+d),color:n.color,changed:c.changed}),a+=d,s+=d),n.content.length-a<=0&&(i++,a=0),c.text.length-s<=0&&(o++,s=0)}for(;i<e.length;){let t=e[i],n=t.content.slice(a);n!==``&&r.push({text:n,color:t.color,changed:!1}),i++,a=0}return r}var P=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,F=`… (patch truncated)`;function I(e){let t=[],n=!1,r=null,i=0,a=0,o=e.split(`
|
|
4
|
+
`);o.at(-1)===``&&o.pop();for(let e of o){let o=P.exec(e);if(o){r={header:e,oldStart:Number(o[1]),oldCount:o[2]===void 0?1:Number(o[2]),newStart:Number(o[3]),newCount:o[4]===void 0?1:Number(o[4]),lines:[]},i=r.oldStart,a=r.newStart,t.push(r);continue}if(e.includes(F)){n=!0,r=null;continue}r&&(e.startsWith(`+`)?r.lines.push({kind:`add`,text:e.slice(1),newLine:a++}):e.startsWith(`-`)?r.lines.push({kind:`del`,text:e.slice(1),oldLine:i++}):e.startsWith(`\\`)||r.lines.push({kind:`context`,text:e.slice(1),oldLine:i++,newLine:a++}))}return{hunks:t,truncated:n}}function L(e,t=!1){let n=[],r=e[0];if(!r)return n;r.newStart>1&&n.push({beforeHunk:0,count:r.newStart-1,oldStart:1,newStart:1});for(let t=1;t<e.length;t++){let r=e[t-1],i=e[t],a=r.oldStart+r.oldCount,o=r.newStart+r.newCount,s=i.newStart-o;s>0&&n.push({beforeHunk:t,count:s,oldStart:a,newStart:o})}if(t){let t=e[e.length-1];n.push({beforeHunk:e.length,oldStart:t.oldStart+t.oldCount,newStart:t.newStart+t.newCount})}return n}function oe(e,t){let n=e.count===void 0?t.length:e.newStart+e.count-1,r=e.oldStart-e.newStart,i=[];for(let a=e.newStart;a<=Math.min(n,t.length);a++)i.push({kind:`context`,text:t[a-1]??``,oldLine:a+r,newLine:a});return i}function se(e,t){let n=Array(e.length),r=Array(t.length),i=Math.min(e.length,t.length);for(let a=0;a<i;a++){let i=j(e[a].text,t[a].text);i&&(n[a]=i.del,r[a]=i.add)}return{dels:e,adds:t,delSpans:n,addSpans:r}}function R(e,t,n){let r=0;for(;r<e.lines.length;){let i=e.lines[r];if(i.kind===`del`||i.kind===`add`){let t=[],i=[];for(;r<e.lines.length&&e.lines[r].kind===`del`;)t.push(e.lines[r++]);for(;r<e.lines.length&&e.lines[r].kind===`add`;)i.push(e.lines[r++]);n(se(t,i))}else t(i),r++}}function z(e,t=[],n){let r=new Map(t.map(e=>[e.beforeHunk,e])),i=[],a=e=>{let t=r.get(e);if(!t)return;let a=n?.get(e);if(a)for(let e of a)i.push({type:`line`,cell:{line:e}});else i.push({type:`gap`,gap:t})};return e.forEach((e,t)=>{a(t),i.push({type:`hunk`,hunk:e}),R(e,e=>i.push({type:`line`,cell:{line:e}}),e=>{e.dels.forEach((t,n)=>i.push({type:`line`,cell:{line:t,spans:e.delSpans[n]}})),e.adds.forEach((t,n)=>i.push({type:`line`,cell:{line:t,spans:e.addSpans[n]}}))})}),a(e.length),i}function B(e,t=[],n){let r=new Map(t.map(e=>[e.beforeHunk,e])),i=[],a=e=>{let t=r.get(e);if(!t)return;let a=n?.get(e);if(a)for(let e of a)i.push({type:`pair`,left:{line:e},right:{line:e}});else i.push({type:`gap`,gap:t})};return e.forEach((e,t)=>{a(t),i.push({type:`hunk`,hunk:e}),R(e,e=>i.push({type:`pair`,left:{line:e},right:{line:e}}),e=>{let t=Math.max(e.dels.length,e.adds.length);for(let n=0;n<t;n++){let t=e.dels[n],r=e.adds[n];i.push({type:`pair`,...t?{left:{line:t,spans:e.delSpans[n]}}:{},...r?{right:{line:r,spans:e.addSpans[n]}}:{}})}})}),a(e.length),i}var V=n();function H({file:e,loadFileText:t,imageSrc:n}){let r=(0,C.useMemo)(()=>U(e),[e]),i=(0,C.useRef)(t);i.current=t;let a=t!==void 0,[o,s]=(0,C.useState)(null);(0,C.useEffect)(()=>{let t=i.current;if(!t)return;let n=!1;return t(e.path).then(t=>!n&&s({path:e.path,text:t}),()=>!n&&s({path:e.path,text:null})),()=>{n=!0}},[e.path,e.patch,a]);let c=(0,C.useRef)(n);c.current=n;let l=(0,C.useMemo)(()=>le(e.path,e=>c.current?.(e)),[e.path]),u=o?.path===e.path?o:null;if(a&&u===null)return(0,V.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Loading preview…`});let d=u?.text??null;return(0,V.jsxs)(`div`,{"data-slot":`diff-markdown-preview`,className:`px-6 py-6`,children:[d===null&&!r.complete?(0,V.jsx)(`p`,{className:`mx-auto mb-4 max-w-[72ch] text-xs text-soft-foreground`,children:`Showing the changed sections only.`}):null,(0,V.jsx)(m,{variant:`document`,urlTransform:l,children:d??r.text})]})}function U(e){let t=I(e.patch);return{text:t.hunks.map(e=>e.lines.filter(e=>e.kind!==`del`).map(e=>e.text).join(`
|
|
5
|
+
`)).join(`
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
`),complete:e.status===`added`&&!t.truncated}}var ce=/^(?:[a-z][a-z\d+.-]*:|\/\/)/i;function le(e,t){return(n,r,i)=>{if(n.startsWith(`#`)||ce.test(n))return u(n,r,i);let a=W(e,n);return a===null||r!==`src`?null:t(a)??null}}function W(e,t){let n=t.split(/[?#]/,1)[0]??``;if(n===``)return null;let r=n.startsWith(`/`)?[]:e.split(`/`).slice(0,-1);for(let e of n.split(`/`))if(!(e===``||e===`.`))if(e===`..`){if(r.pop()===void 0)return null}else r.push(G(e));return r.length>0?r.join(`/`):null}function G(e){try{return decodeURIComponent(e)}catch{return e}}function K(e,t){return t.kind===`del`?t.oldLine===void 0?void 0:{path:e,side:`old`,line:t.oldLine}:t.newLine===void 0?void 0:{path:e,side:`new`,line:t.newLine}}function q(e){return`${e.side}:${e.line}\u0000${e.path}`}function ue(e,t,n,r){let i=Math.max(0,Math.min(n,r)),a=Math.min(t.length-1,Math.max(n,r)),o=t[a],s=o?K(e,o):void 0;if(!s)return;let c=t.slice(i,a+1);if(i===a)return{anchor:s,excerpt:o.text};let l=K(e,t[i]);return{anchor:s,...l?{start:{side:l.side,line:l.line}}:{},excerpt:J(c)}}function J(e){let t=[],n,r;for(let i of e){if(i.newLine!==void 0&&r!==void 0&&i.newLine>r+1||i.oldLine!==void 0&&n!==void 0&&i.oldLine>n+1){let e=i.newLine!==void 0&&r!==void 0?i.newLine-r-1:i.oldLine-n-1;t.push(`⋯ ${e} unchanged ${e===1?`line`:`lines`} not shown`)}t.push(i.text),i.oldLine!==void 0&&(n=i.oldLine),i.newLine!==void 0&&(r=i.newLine)}return t.join(`
|
|
10
|
+
`)}var Y=(0,C.createContext)(null);function X(e){if(e===`selected`)return`relative before:pointer-events-none before:absolute before:inset-0 before:bg-primary/15`;if(e===`commented`)return`shadow-[inset_3px_0_0_0_var(--color-primary)]`}var de=(0,C.createContext)(null);function Z(){return(0,C.useContext)(de)}function fe(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(hover: none)`).matches}function pe(e,t,n){if(!(!e?.canAdd||t===void 0))return{onClick:r=>{fe()&&(r.target.closest(`button, a, textarea, input`)||(window.getSelection?.()?.toString()??``)===``&&e.open(t,n))}}}function me({anchor:e,excerpt:t,line:n}){let r=Z(),a=(0,C.useContext)(Y);if(!r?.canAdd||e===void 0)return null;let o=a?.orderOf.get(n),s=r.editing,c=s!==null&&s.commentId===void 0&&s.anchor.path===e.path&&a!==null;return(0,V.jsx)(`button`,{type:`button`,"data-slot":`diff-add-comment`,"aria-label":`Comment on ${e.path.split(`/`).at(-1)} ${e.side===`old`?`removed `:``}line ${e.line}`,title:`Add a comment for the agent — drag to cover several lines, or shift-click to extend`,onMouseDown:t=>{t.button===0&&(t.preventDefault(),!(t.shiftKey&&c)&&a&&o!==void 0&&r.beginSelect(e.path,o,a.lines))},onClick:n=>{if(n.shiftKey&&c&&o!==void 0&&s){let t=s.start??s.anchor,n=he(a,e.path,t)??o,i=ue(e.path,a.lines,n,o);i&&r.open(i.anchor,i.excerpt,i.start,!0);return}n.detail===0&&r.open(e,t)},className:i(`absolute top-1/2 left-0 z-[1] flex size-4 -translate-y-1/2 items-center justify-center rounded-sm`,`bg-primary text-primary-foreground opacity-0 shadow-xs transition-opacity`,`group-hover/line:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),children:(0,V.jsx)(h,{"aria-hidden":`true`,className:`size-2.5`,strokeWidth:3})})}function he(e,t,n){let r=q({path:t,side:n.side,line:n.line});for(let[n,i]of e.orderOf){let e=K(t,n);if(e&&q(e)===r)return i}}function ge({anchors:e}){let t=Z(),n=(0,C.useContext)(Y);if(!t)return null;let r=[...new Set(e.filter(e=>e!==void 0).map(q))],i=r.flatMap(e=>t.byKey.get(e)??[]),a=t.editing!==null&&r.includes(t.editing.threadKey)?t.editing:null;if(i.length===0&&a===null)return null;let o=a?.commentId;return(0,V.jsx)(`div`,{"data-slot":`diff-line-comments`,className:`border-y border-primary/25 bg-primary/5 py-2.5 font-sans`,children:(0,V.jsxs)(`div`,{className:`sticky left-0 flex w-full max-w-2xl flex-col gap-2 px-3 md:pl-24`,children:[i.map(e=>e.id===o&&a?(0,V.jsx)(ye,{editing:a,api:t},a.key):(0,V.jsx)(ve,{comment:e,outdated:_e(e,n),onEdit:t.edit,onRemove:t.remove},e.id)),a&&o===void 0?(0,V.jsx)(ye,{editing:a,api:t},a.key):null]})})}function _e(e,t){if(!t||!e.excerpt||e.excerpt.endsWith(`…`))return!1;let n=q(e),r=t.lines.find(t=>{let r=K(e.path,t);return r!==void 0&&q(r)===n});return r?(e.excerpt.split(`
|
|
11
|
+
`).at(-1)??``).trimEnd()!==r.text.trimEnd():!1}function ve({comment:e,outdated:t=!1,onEdit:n,onRemove:r}){return(0,V.jsxs)(`div`,{"data-slot":`diff-line-comment`,"data-comment-id":e.id,role:`group`,"aria-label":`Comment on ${x(e,e.start)}`,className:`flex flex-col gap-1.5 rounded-md border border-primary/40 bg-card px-3 py-2.5 text-[13px] leading-normal shadow-sm transition-shadow duration-500 data-[flash=true]:ring-2 data-[flash=true]:ring-primary`,children:[t?(0,V.jsxs)(`div`,{"data-slot":`diff-line-comment-outdated`,className:`flex flex-col gap-1`,children:[(0,V.jsx)(`p`,{className:`text-[11px] font-medium text-pending-strong`,children:`Outdated — the code here changed since this comment`}),(0,V.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded-sm border border-border/60 bg-muted/40 px-2 py-1 font-mono text-[12px] whitespace-pre text-muted-foreground`,children:e.excerpt})]}):null,(0,V.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.body}),n||r?(0,V.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[n?(0,V.jsxs)(a,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>n(e),children:[(0,V.jsx)(s,{"aria-hidden":`true`,className:`size-3.5`}),`Edit`]}):null,r?(0,V.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(e.id),children:[(0,V.jsx)(S,{"aria-hidden":`true`,className:`size-3.5`}),`Remove from chat`]}):null]}):null]})}function ye({editing:e,api:t}){let[n,r]=(0,C.useState)(()=>t.pendingText.get(e.key)??e.initial??``),i=(0,C.useRef)(null);(0,C.useEffect)(()=>{let n=i.current;!n||t.focusRequest.current!==e.key||(t.focusRequest.current=null,n.focus({preventScroll:!0}),n.setSelectionRange(n.value.length,n.value.length),n.closest(`[data-slot="diff-comment-editor"]`)?.scrollIntoView?.({block:`nearest`}))},[]);let o=n.trim(),s=()=>{o!==``&&(e.commentId===void 0?t.submit({...e.anchor,...e.start?{start:e.start}:{},...e.oldPath?{oldPath:e.oldPath}:{},excerpt:e.excerpt,body:o}):t.update(e.commentId,o))&&t.pendingText.delete(e.key)},l=()=>{t.pendingText.delete(e.key),t.cancel()};return(0,V.jsxs)(`div`,{"data-slot":`diff-comment-editor`,className:`flex flex-col gap-2`,children:[(0,V.jsx)(`textarea`,{ref:i,rows:3,maxLength:ne,value:n,"aria-label":`Comment on ${x(e.anchor,e.start)}`,placeholder:`Add a comment for the AI`,onChange:n=>{r(n.target.value),t.pendingText.set(e.key,n.target.value)},onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),l();return}c({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.preventDefault(),s())},className:`block w-full resize-y rounded-md border border-ring/60 bg-background px-3 py-2 text-base leading-normal outline-none placeholder:text-muted-foreground focus:border-ring focus:ring-[3px] focus:ring-ring/15 md:text-sm`}),(0,V.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,V.jsx)(a,{type:`button`,variant:`ghost`,size:`sm`,onClick:l,children:`Cancel`}),(0,V.jsxs)(a,{type:`button`,size:`sm`,disabled:o===``,onClick:s,children:[e.commentId===void 0?`Comment`:`Save`,` `,(0,V.jsx)(`span`,{"aria-hidden":`true`,children:`↵`})]})]})]})}var be=1500,xe=new Map;function Se(e,t){if(e){for(let n of e.querySelectorAll(`[data-slot="diff-file"]`))if(n.dataset.path===t)return n}}function Ce(e,t){let n=Se(e,t.path);if(!n)return;if(t.commentId!==void 0){for(let e of n.querySelectorAll(`[data-slot="diff-line-comment"]`))if(e.dataset.commentId===t.commentId)return e}if(t.line===void 0)return;let r=String(t.line);for(let e of n.querySelectorAll(`[data-slot="diff-line"], [data-slot="diff-cell"]`))if((t.side===`old`?e.dataset.oldLine:e.dataset.newLine)===r)return e}function we(e){e.dataset.flash=`true`,setTimeout(()=>{delete e.dataset.flash},1600)}function Te({files:e,mode:t=`unified`,wrap:n=!1,preview:r=!1,loadFileText:a,imageSrc:o,onOpenInApp:s,viewRef:c,comments:u,onAddComment:d,onEditComment:f,onRemoveComment:p,className:m}){let h=(0,C.useMemo)(()=>({adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length}),[e]),[g,_]=(0,C.useState)(()=>new Set),[ee,te]=(0,C.useState)(()=>new Map),x=(0,C.useCallback)(e=>{_(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]),ne=(0,C.useCallback)(async(e,t)=>{if(!a)return;let n=await a(e.path);if(n===null)return;let r=oe(t,n.split(`
|
|
12
|
+
`));te(n=>{let i=E(e);return new Map(n).set(i,new Map(n.get(i)??xe).set(t.beforeHunk,r))})},[a]),[S,w]=(0,C.useState)(null),T=(0,C.useRef)(new Map).current,D=(0,C.useRef)(null),[O,k]=(0,C.useState)(null),A=(0,C.useRef)(null),j=(0,C.useRef)([]),M=O!==null,N=(0,C.useRef)(S);N.current=S;let P=(0,C.useRef)({element:null}),F=(0,C.useRef)(null),I=(0,C.useRef)(null),[L,se]=(0,C.useState)(0),R=e=>{let t=document.activeElement;P.current={element:t instanceof HTMLElement&&F.current?.contains(t)?t:null,...e?{commentId:e}:{}}},z=()=>{let{element:e,commentId:t}=P.current;P.current={element:null},setTimeout(()=>{if(e?.isConnected){e.focus({preventScroll:!0});return}if(t!==void 0){for(let e of F.current?.querySelectorAll(`[data-slot="diff-line-comment"]`)??[])if(e.dataset.commentId===t){e.querySelector(`button`)?.focus({preventScroll:!0});return}}},0)},B=(0,C.useRef)({captureOpener:R,restoreFocus:z});B.current={captureOpener:R,restoreFocus:z};let H=(0,C.useCallback)((t,n,r,i=!1)=>{let a=q(t),o=r?`${a}\u0000${r.side}:${r.line}`:a,s=N.current;if(i&&s&&s.commentId===void 0&&s.key!==o){let e=T.get(s.key);e!==void 0&&(T.set(o,e),T.delete(s.key))}let c=t.side===`old`||r?.side===`old`?e.find(e=>e.path===t.path)?.oldPath:void 0;D.current=o,i||B.current.captureOpener(),w({key:o,threadKey:a,anchor:t,excerpt:n,...r?{start:r}:{},...c?{oldPath:c}:{}})},[e,T]);(0,C.useEffect)(()=>{if(!M)return;let e=()=>{let e=A.current;if(A.current=null,k(null),!e)return;let t=ue(e.path,j.current,e.from,e.to);t&&H(t.anchor,t.excerpt,t.start)};return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)},[H,M]);let U=(0,C.useMemo)(()=>{if(!d&&(u?.length??0)===0)return null;let e=new Map;for(let t of u??[]){let n=q(t);e.set(n,[...e.get(n)??[],t])}return{comments:u??[],byKey:e,editing:S,selection:O,canAdd:d!==void 0,open:H,beginSelect:(e,t,n)=>{j.current=n,A.current={path:e,from:t,to:t},k(A.current)},extendSelect:(e,t)=>{let n=A.current;n===null||n.path!==e||n.to===t||(A.current={...n,to:t},k(A.current))},edit:f?e=>{D.current=`edit:${e.id}`,B.current.captureOpener(e.id),w({key:`edit:${e.id}`,threadKey:q(e),anchor:e,...e.start?{start:e.start}:{},excerpt:``,commentId:e.id,initial:e.body})}:void 0,cancel:()=>{w(null),B.current.restoreFocus()},submit:e=>d?.(e)===!1?!1:(w(null),B.current.restoreFocus(),!0),update:(e,t)=>f?.(e,t)===!1?!1:(w(null),B.current.restoreFocus(),!0),remove:p,pendingText:T,focusRequest:D}},[u,S,d,f,p,H,T,O]),ce=(0,C.useMemo)(()=>ie(e),[e]),[le]=(0,C.useState)(()=>typeof window>`u`?``:window.location.search),W=ae(le,ce),G=(0,C.useRef)(null),K=(0,C.useRef)(null),J=(0,C.useRef)(null),Y=Ee(c!==void 0,J,G,L);(0,C.useImperativeHandle)(c,()=>{let t=t=>{let n=e.findIndex(e=>e.path===t);if(n===-1)return;let r=K.current,i=J.current,a=i&&Number.parseFloat(getComputedStyle(i).scrollMarginTop)||0;if(r)r.scrollToIndex(n,{align:`start`,offset:-a});else{let e=Se(i,t),n=G.current;e&&n&&y(n,e,a)}};return{scrollToPath:e=>t(e),reveal:n=>{let r=e.find(e=>e.path===n.path);if(!r)return;_(e=>{if(!e.has(E(r)))return e;let t=new Set(e);return t.delete(E(r)),t}),t(n.path);let i=0,a=()=>{let e=Ce(J.current,n);if(e){let t=G.current,n=K.current;if(t&&n){let r=e.getBoundingClientRect(),i=Number.parseFloat(getComputedStyle(e).scrollMarginBottom)||0;n.scrollTo(t.scrollTop+r.top-t.getBoundingClientRect().top-(t.clientHeight-i-r.height)/2)}else t&&y(t,e,(t.clientHeight-e.getBoundingClientRect().height)/2);we(e);return}++i<30&&requestAnimationFrame(a)};requestAnimationFrame(a)}}},[e]);let X=e=>{let i=E(e);return(0,V.jsx)(ke,{file:e,open:!g.has(i),onToggle:()=>x(i),expanded:ee.get(i)??xe,onExpand:t=>void ne(e,t),mode:t,wrap:n,preview:r&&v(e),loadFileText:a,canExpand:a!==void 0,imageSrc:o,onOpenInApp:s})};return(0,V.jsx)(de.Provider,{value:U,children:(0,V.jsxs)(`div`,{ref:e=>{if(J.current=e,F.current=e,!e)return;let t=b(e);G.current=t,I.current&&I.current!==t&&se(e=>e+1),I.current=t},"data-slot":`diff`,"data-mode":t,className:i(`flex min-w-0 flex-col scroll-mt-[var(--diff-sticky-top,0px)]`,m),children:[(0,V.jsxs)(`p`,{"data-slot":`diff-totals`,className:`flex items-center gap-2 px-1 pb-3 text-xs text-muted-foreground`,children:[(0,V.jsxs)(`span`,{children:[h.files,` `,h.files===1?`file`:`files`,` changed`]}),(0,V.jsx)(l,{stat:h})]}),W===`virtual`?(0,V.jsx)(De,{files:e,handleRef:K,scrollElRef:G,card:X,endRoom:Y},L):(0,V.jsx)(`div`,{"data-slot":`diff-files`,"data-virtualized":`false`,children:e.map((t,n)=>(0,V.jsx)(`div`,{"data-slot":`diff-file-slot`,style:{containIntrinsicBlockSize:`auto ${re(t)}px`,...n===e.length-1&&Y?{minHeight:Y}:{}},className:`pb-3 [content-visibility:auto]`,children:X(t)},E(t)))})]})})}function Ee(e,t,n,r){let[i,a]=(0,C.useState)(0);return(0,C.useLayoutEffect)(()=>{let r=t.current,i=n.current;if(!e||!r||!i){a(0);return}let o=()=>{let e=Number.parseFloat(getComputedStyle(r).scrollMarginTop)||0;a(Math.max(0,Math.round(i.clientHeight-e)))};if(o(),typeof ResizeObserver>`u`)return;let s=new ResizeObserver(o);return s.observe(i),()=>s.disconnect()},[e,t,n,r]),i}function De({files:e,handleRef:t,scrollElRef:n,card:r,endRoom:i}){let a=(0,C.useRef)(null),[o,s]=(0,C.useState)(0);return(0,C.useLayoutEffect)(()=>{let e=()=>{let e=a.current,t=n.current;!e||!t||s(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[n]),(0,V.jsx)(`div`,{ref:e=>{a.current=e,e&&(n.current=b(e))},"data-slot":`diff-files`,"data-virtualized":`true`,children:(0,V.jsx)(g,{ref:t,scrollRef:n,startMargin:o,children:e.map((t,n)=>(0,V.jsx)(`div`,{"data-slot":`diff-file-slot`,style:n===e.length-1&&i?{minHeight:i}:void 0,className:`pb-3`,children:r(t)},E(t)))})})}var Oe={added:`added`,deleted:`deleted`,renamed:`renamed`,copied:`copied`};function ke({file:e,open:t,onToggle:n,expanded:r,onExpand:a,mode:s,wrap:c,preview:u,loadFileText:d,canExpand:f,imageSrc:p,onOpenInApp:m}){let h=Oe[e.status],g=Z()?.comments.filter(t=>t.path===e.path).length??0;return(0,V.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 scroll-mt-[var(--diff-sticky-top,0px)] overflow-clip rounded-md border border-border bg-card`,children:[(0,V.jsx)(`header`,{className:`sticky top-[var(--diff-sticky-top,0px)] z-10 border-b border-[color-mix(in_oklab,var(--border)_50%,var(--card))] bg-card shadow-[0_-1px_0_var(--card)]`,children:(0,V.jsxs)(`button`,{type:`button`,"data-slot":`diff-file-header`,"aria-expanded":t,onClick:n,className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted/50`,children:[(0,V.jsx)(o,{className:i(`size-3.5 shrink-0 text-soft-foreground transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),(0,V.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`span`,{className:`text-soft-foreground`,children:[e.oldPath,` → `]}),e.path]}):e.path}),h?(0,V.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:h}):null,e.image?(0,V.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:`image`}):e.binary?(0,V.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:`binary`}):null,u?(0,V.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:`preview`}):null,(0,V.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,V.jsx)(_,{count:g}),(0,V.jsx)(l,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-[11px]`})]})]})}),t&&u?(0,V.jsx)(H,{file:e,loadFileText:d,imageSrc:p}):t?(0,V.jsx)(Ae,{file:e,expanded:r,onExpand:a,mode:s,wrap:c,canExpand:f,imageSrc:p,onOpenInApp:m}):null]})}function Ae({file:e,expanded:t,onExpand:n,mode:r,wrap:a,canExpand:o,imageSrc:s,onOpenInApp:c}){let l=(0,C.useMemo)(()=>I(e.patch),[e.patch]),u=o&&e.status!==`added`&&e.status!==`deleted`,d=(0,C.useMemo)(()=>L(l.hunks,u),[l.hunks,u]),f=(0,C.useMemo)(()=>{let e=[];l.hunks.forEach((n,r)=>{let i=t.get(r);i&&e.push(...i),e.push(...n.lines)});let n=t.get(l.hunks.length);return n&&e.push(...n),e},[l.hunks,t]),p=(0,C.useMemo)(()=>new Map(f.map((e,t)=>[e,t])),[f]),m=je(e.path,f),h=Z(),g=(0,C.useMemo)(()=>{if(!h)return null;let t=new Map;f.forEach((n,r)=>{let i=K(e.path,n);i&&t.set(q(i),r)});let n=n=>t.get(q({path:e.path,side:n.side,line:n.line})),r=new Map,i=(e,t,n)=>{for(let i=Math.min(e,t);i<=Math.max(e,t);i++)(n===`selected`||!r.has(i))&&r.set(i,n)},a=(e,t,r)=>{let a=n(e);a!==void 0&&i(t?n(t)??a:a,a,r)};for(let t of h.comments)t.path===e.path&&a(t,t.start,`commented`);let{editing:o,selection:s}=h;return o&&o.anchor.path===e.path&&a(o.anchor,o.start,`selected`),s&&s.path===e.path&&i(s.from,s.to,`selected`),{path:e.path,lines:f,orderOf:p,markAt:e=>r.get(e)}},[h,e.path,f,p]),_=(0,C.useMemo)(()=>r===`unified`?z(l.hunks,d,t):null,[r,l.hunks,d,t]),v=(0,C.useMemo)(()=>r===`split`?B(l.hunks,d,t):null,[r,l.hunks,d,t]),y=(0,C.useMemo)(()=>r===`unified`&&!a?{minInlineSize:`calc(${D(e.patch)}ch + 7rem)`}:void 0,[r,a,e.patch]);if(ee(e))return(0,V.jsx)(te,{file:e,imageSrc:s,onOpenInApp:c});if(e.binary)return(0,V.jsx)(Q,{children:`Binary file — no text diff.`});if(l.hunks.length===0)return(0,V.jsx)(Q,{children:l.truncated?`Patch truncated by the server.`:`No content changes (metadata only).`});let b=e=>{if(!m)return null;let t=p.get(e);return t===void 0?null:m[t]??null};return(0,V.jsxs)(`div`,{"data-slot":`diff-file-body`,"data-wrap":a||void 0,className:i(`py-1 font-mono text-xs leading-[1.7]`,!a&&`overflow-x-auto`),children:[(0,V.jsx)(Y.Provider,{value:g,children:(0,V.jsxs)(`div`,{"data-slot":`diff-rows`,style:y,className:`[&>*]:[contain-intrinsic-block-size:auto_20px] [&>*]:[content-visibility:auto]`,children:[_?_.map((t,r)=>(0,V.jsx)(Re,{path:e.path,row:t,wrap:a,tokensFor:b,onExpand:u?n:void 0},r)):null,v?v.map((t,r)=>(0,V.jsx)(ze,{path:e.path,row:t,wrap:a,tokensFor:b,onExpand:u?n:void 0},r)):null]})}),l.truncated?(0,V.jsx)(Q,{children:`Patch truncated by the server — counts above remain exact.`}):null]})}function je(e,t){let n=(0,C.useMemo)(()=>t.length>be?null:t.map(e=>e.text).join(`
|
|
13
|
+
`),[t]),r=(0,C.useMemo)(()=>d(e),[e]),[i,a]=(0,C.useState)(null);return(0,C.useEffect)(()=>{if(n===null||r===null)return;let e=!1;return p(n,r).then(t=>{e||a({text:n,tokens:t.tokens})}),()=>{e=!0}},[n,r]),n===null||r===null?null:i?.text===n?i.tokens:f(n,r)?.tokens??null}function Q({children:e}){return(0,V.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:e})}var Me={add:`bg-diff-add`,del:`bg-diff-del`,context:void 0},Ne={add:`+`,del:`−`,context:` `},Pe=`transition-shadow duration-500 data-[flash=true]:ring-2 data-[flash=true]:ring-inset data-[flash=true]:ring-primary`;function Fe({hunk:e}){return(0,V.jsx)(`div`,{"data-slot":`diff-hunk`,className:`bg-muted/40 px-4 py-0.5 whitespace-pre text-soft-foreground`,children:e.header})}function Ie({gap:e,onExpand:t}){let n=e.count===void 0?`⋯ unchanged lines to end of file`:`⋯ ${e.count} unchanged ${e.count===1?`line`:`lines`}`;return t?(0,V.jsxs)(`button`,{type:`button`,"data-slot":`diff-gap`,onClick:()=>t(e),className:`block w-full border-y border-border/40 bg-muted/20 px-4 py-0.5 text-left text-[11px] text-soft-foreground hover:bg-muted/50 hover:text-foreground`,children:[n,` — expand`]}):(0,V.jsx)(`div`,{"data-slot":`diff-gap`,className:`border-y border-border/40 bg-muted/20 px-4 py-0.5 text-[11px] text-soft-foreground`,children:n})}function Le({cell:e,tokens:t,wrap:n}){let r=N(t,e.spans,e.line.text),a=e.line.kind===`add`?`bg-diff-add-strong`:`bg-diff-del-strong`;return(0,V.jsxs)(`span`,{className:i(`min-w-0 flex-1 pr-4`,n?`break-words whitespace-pre-wrap`:`whitespace-pre`),children:[r.map((t,n)=>(0,V.jsx)(`span`,{"data-word":t.changed?e.line.kind:void 0,style:t.color===void 0?void 0:{color:t.color},className:t.changed?i(`rounded-[2px]`,a):void 0,children:t.text},n)),e.line.text===``?` `:``]})}function $({value:e}){return(0,V.jsx)(`span`,{className:`w-10 shrink-0 pr-2 text-right text-soft-foreground/70 tabular-nums select-none`,children:e??``})}function Re({path:e,row:t,wrap:n,tokensFor:r,onExpand:a}){let o=Z(),s=(0,C.useContext)(Y);if(t.type===`hunk`)return(0,V.jsx)(Fe,{hunk:t.hunk});if(t.type===`gap`)return(0,V.jsx)(Ie,{gap:t.gap,onExpand:a});let{line:c}=t.cell,l=K(e,c),u=pe(o,l,c.text),d=s?.orderOf.get(c),f=d===void 0?void 0:s?.markAt(d);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{"data-slot":`diff-line`,"data-line":c.kind,"data-old-line":c.oldLine,"data-new-line":c.newLine,"data-mark":f,...u,onMouseEnter:o?.selection&&d!==void 0?()=>o.extendSelect(e,d):void 0,className:i(`group/line flex`,Me[c.kind],X(f),Pe),children:[(0,V.jsx)($,{value:c.oldLine}),(0,V.jsx)($,{value:c.newLine}),(0,V.jsxs)(`span`,{className:`relative w-4 shrink-0 text-soft-foreground select-none`,children:[Ne[c.kind],(0,V.jsx)(me,{anchor:l,excerpt:c.text,line:c})]}),(0,V.jsx)(Le,{cell:t.cell,tokens:r(c),wrap:n})]}),(0,V.jsx)(ge,{anchors:[l]})]})}function ze({path:e,row:t,wrap:n,tokensFor:r,onExpand:i}){if(t.type===`hunk`)return(0,V.jsx)(Fe,{hunk:t.hunk});if(t.type===`gap`)return(0,V.jsx)(Ie,{gap:t.gap,onExpand:i});let a=t.left?K(e,t.left.line):void 0,o=t.right?K(e,t.right.line):void 0;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{"data-slot":`diff-pair`,className:`grid grid-cols-2`,children:[(0,V.jsx)(Be,{cell:t.left,anchor:a,side:`old`,tokensFor:r,wrap:n}),(0,V.jsx)(Be,{cell:t.right,anchor:o,side:`new`,tokensFor:r,wrap:n})]}),(0,V.jsx)(ge,{anchors:[a,o]})]})}function Be({cell:e,anchor:t,side:n,tokensFor:r,wrap:a}){let o=Z(),s=(0,C.useContext)(Y);if(!e)return(0,V.jsx)(`div`,{"data-slot":`diff-cell-empty`,className:i(`bg-muted/20`,n===`new`&&`border-l border-border/40`)});let{line:c}=e,l=s?.orderOf.get(c),u=l===void 0?void 0:s?.markAt(l);return(0,V.jsxs)(`div`,{"data-slot":`diff-cell`,"data-line":c.kind,"data-old-line":c.oldLine,"data-new-line":c.newLine,"data-mark":u,...pe(o,t,c.text),onMouseEnter:o?.selection&&l!==void 0&&t?()=>o.extendSelect(t.path,l):void 0,className:i(`group/line flex min-w-0 overflow-x-auto`,Me[c.kind],n===`new`&&`border-l border-border/40`,X(u),Pe),children:[(0,V.jsx)($,{value:n===`old`?c.oldLine:c.newLine}),(0,V.jsxs)(`span`,{className:`relative w-4 shrink-0 text-soft-foreground select-none`,children:[Ne[c.kind],(0,V.jsx)(me,{anchor:t,excerpt:c.text,line:c})]}),(0,V.jsx)(Le,{cell:e,tokens:r(c),wrap:a})]})}export{Te as DiffView};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as e}from"./button-
|
|
1
|
+
import{F as e}from"./button-BNnH7COh.js";var t=e(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{A as r,C as i,D as a,E as o,F as s,N as c,O as l,S as u,T as d,_ as f,b as p,g as m,h,m as g,r as _,v,w as y,x as b,y as ee}from"./button-BNnH7COh.js";import{a as x,c as S,l as C,o as te,s as w}from"./tooltip-BVqBAGNb.js";var T=s(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),E=s(`eye`,[[`path`,{d:`M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0`,key:`1nclc0`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),ne=s(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),D=s(`git-branch`,[[`path`,{d:`M15 6a9 9 0 0 0-9 9V3`,key:`1cii5b`}],[`circle`,{cx:`18`,cy:`6`,r:`3`,key:`1h7g24`}],[`circle`,{cx:`6`,cy:`18`,r:`3`,key:`fqmcym`}]]),O=e(t(),1),k=n();function A(e){let t=e+`CollectionProvider`,[n,i]=o(t),[a,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=e=>{let{scope:t,children:n}=e,r=O.useRef(null),i=O.useRef(new Map).current;return(0,k.jsx)(a,{scope:t,itemMap:i,collectionRef:r,children:n})};l.displayName=t;let u=e+`CollectionSlot`,d=r(u),f=O.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=c(t,s(u,n).collectionRef);return(0,k.jsx)(d,{ref:i,children:r})});f.displayName=u;let p=e+`CollectionItemSlot`,m=`data-radix-collection-item`,h=r(p),g=O.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,a=O.useRef(null),o=c(t,a),l=s(p,n);return O.useEffect(()=>(l.itemMap.set(a,{ref:a,...i}),()=>void l.itemMap.delete(a))),(0,k.jsx)(h,{[m]:``,ref:o,children:r})});g.displayName=p;function _(t){let n=s(e+`CollectionConsumer`,t);return O.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${m}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:l,Slot:f,ItemSlot:g},_,i]}var j=O.createContext(void 0);function M(e){let t=O.useContext(j);return e||t||`ltr`}var N=!1;function P(){let[e,t]=O.useState(N);return O.useEffect(()=>{N||(N=!0,t(!0))},[]),e}var F=O.useSyncExternalStore;function I(){return()=>{}}function re(){return F(I,()=>!0,()=>!1)}var ie=typeof F==`function`?re:P,L=`rovingFocusGroup.onEntryFocus`,R={bubbles:!1,cancelable:!0},z=`RovingFocusGroup`,[ae,oe,se]=A(z),[ce,le]=o(z,[se]),[ue,de]=ce(z),fe=O.forwardRef((e,t)=>(0,k.jsx)(ae.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,k.jsx)(ae.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,k.jsx)(pe,{...e,ref:t})})}));fe.displayName=z;var pe=O.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:l,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:f,onEntryFocus:m,preventScrollOnEntryFocus:h=!1,...g}=e,_=O.useRef(null),v=c(t,_),y=M(s),[b,ee]=i({prop:l,defaultProp:u??null,onChange:f,caller:z}),[x,S]=O.useState(!1),C=p(m),te=oe(n),w=O.useRef(!1),[T,E]=O.useState(0);return O.useEffect(()=>{let e=_.current;if(e)return e.addEventListener(L,C),()=>e.removeEventListener(L,C)},[C]),(0,k.jsx)(ue,{scope:n,orientation:r,dir:y,loop:o,currentTabStopId:b,onItemFocus:O.useCallback(e=>ee(e),[ee]),onItemShiftTab:O.useCallback(()=>S(!0),[]),onFocusableItemAdd:O.useCallback(()=>E(e=>e+1),[]),onFocusableItemRemove:O.useCallback(()=>E(e=>e-1),[]),children:(0,k.jsx)(a.div,{tabIndex:x||T===0?-1:0,"data-orientation":r,...g,ref:v,style:{outline:`none`,...e.style},onMouseDown:d(e.onMouseDown,()=>{w.current=!0}),onFocus:d(e.onFocus,e=>{let t=!w.current;if(e.target===e.currentTarget&&t&&!x){let t=new CustomEvent(L,R);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=te().filter(e=>e.focusable);ye([e.find(e=>e.active),e.find(e=>e.id===b),...e].filter(Boolean).map(e=>e.ref.current),h)}}w.current=!1}),onBlur:d(e.onBlur,()=>S(!1))})})}),me=`RovingFocusGroupItem`,he=O.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:o,children:s,...c}=e,l=b(),u=o||l,f=de(me,n),p=f.currentTabStopId===u,m=oe(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:_}=f,v=ie();return y(()=>{if(!(!v||!r))return h(),()=>g()},[v,r,h,g]),O.useEffect(()=>{if(!(v||!r))return h(),()=>g()},[v,r,h,g]),(0,k.jsx)(ae.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:(0,k.jsx)(a.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...c,ref:t,onMouseDown:d(e.onMouseDown,e=>{r?f.onItemFocus(u):e.preventDefault()}),onFocus:d(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:d(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){f.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=ve(e,f.orientation,f.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=m().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=f.loop?be(n,r+1):n.slice(r+1)}setTimeout(()=>ye(n))}}),children:typeof s==`function`?s({isCurrentTabStop:p,hasTabStop:_!=null}):s})})});he.displayName=me;var ge={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function _e(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function ve(e,t,n){let r=_e(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return ge[r]}function ye(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function be(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var xe=fe,Se=he,Ce=[`Enter`,` `],we=[`ArrowDown`,`PageUp`,`Home`],Te=[`ArrowUp`,`PageDown`,`End`],Ee=[...we,...Te],De={ltr:[...Ce,`ArrowRight`],rtl:[...Ce,`ArrowLeft`]},Oe={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},B=`Menu`,[V,ke,Ae]=A(B),[H,je]=o(B,[Ae,C,le]),U=C(),Me=le(),[Ne,W]=H(B),[Pe,G]=H(B),Fe=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=U(t),[c,l]=O.useState(null),u=O.useRef(!1),d=p(a),f=M(i);return O.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),O.useEffect(()=>{if(!n)return;let e=()=>d(!1);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,k.jsx)(S,{...s,children:(0,k.jsx)(Ne,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,k.jsx)(Pe,{scope:t,onClose:O.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};Fe.displayName=B;var Ie=`MenuAnchor`,Le=O.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=U(n);return(0,k.jsx)(x,{...i,...r,ref:t})});Le.displayName=Ie;var Re=`MenuPortal`,[ze,Be]=H(Re,{forceMount:void 0}),Ve=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=W(Re,t);return(0,k.jsx)(ze,{scope:t,forceMount:n,children:(0,k.jsx)(u,{present:n||a.open,children:(0,k.jsx)(f,{asChild:!0,container:i,children:r})})})};Ve.displayName=Re;var K=`MenuContent`,[He,Ue]=H(K),We=O.forwardRef((e,t)=>{let n=Be(K,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=W(K,e.__scopeMenu),o=G(K,e.__scopeMenu);return(0,k.jsx)(V.Provider,{scope:e.__scopeMenu,children:(0,k.jsx)(u,{present:r||a.open,children:(0,k.jsx)(V.Slot,{scope:e.__scopeMenu,children:o.modal?(0,k.jsx)(Ge,{...i,ref:t}):(0,k.jsx)(Ke,{...i,ref:t})})})})}),Ge=O.forwardRef((e,t)=>{let n=W(K,e.__scopeMenu),r=O.useRef(null),i=c(t,r);return O.useEffect(()=>{let e=r.current;if(e)return g(e)},[]),(0,k.jsx)(Je,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:d(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Ke=O.forwardRef((e,t)=>{let n=W(K,e.__scopeMenu);return(0,k.jsx)(Je,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),qe=r(`MenuContent.ScrollLock`),Je=O.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:g,onDismiss:_,disableOutsideScroll:y,...b}=e,x=W(K,n),S=G(K,n),C=U(n),te=Me(n),T=ke(n),[E,ne]=O.useState(null),D=O.useRef(null),A=c(t,D,x.onContentChange),j=O.useRef(0),M=O.useRef(``),N=O.useRef(0),P=O.useRef(null),F=O.useRef(`right`),I=O.useRef(0),re=y?h:O.Fragment,ie=y?{as:qe,allowPinchZoom:!0}:void 0,L=e=>{let t=M.current+e,n=T().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Ot(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){M.current=t,window.clearTimeout(j.current),t!==``&&(j.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};O.useEffect(()=>()=>window.clearTimeout(j.current),[]),m();let R=O.useCallback(e=>F.current===P.current?.side&&At(e,P.current?.area),[]);return(0,k.jsx)(He,{scope:n,searchRef:M,onItemEnter:O.useCallback(e=>{R(e)&&e.preventDefault()},[R]),onItemLeave:O.useCallback(e=>{R(e)||(D.current?.focus(),ne(null))},[R]),onTriggerLeave:O.useCallback(e=>{R(e)&&e.preventDefault()},[R]),pointerGraceTimerRef:N,onPointerGraceIntentChange:O.useCallback(e=>{P.current=e},[]),children:(0,k.jsx)(re,{...ie,children:(0,k.jsx)(v,{asChild:!0,trapped:i,onMountAutoFocus:d(a,e=>{e.preventDefault(),D.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,k.jsx)(ee,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:g,onDismiss:_,children:(0,k.jsx)(xe,{asChild:!0,...te,dir:S.dir,orientation:`vertical`,loop:r,currentTabStopId:E,onCurrentTabStopIdChange:ne,onEntryFocus:d(l,e=>{S.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,k.jsx)(w,{role:`menu`,"aria-orientation":`vertical`,"data-state":wt(x.open),"data-radix-menu-content":``,dir:S.dir,...C,...b,ref:A,style:{outline:`none`,...b.style},onKeyDown:d(b.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&L(e.key));let i=D.current;if(e.target!==i||!Ee.includes(e.key))return;e.preventDefault();let a=T().filter(e=>!e.disabled).map(e=>e.ref.current);Te.includes(e.key)&&a.reverse(),Et(a)}),onBlur:d(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(j.current),M.current=``)}),onPointerMove:d(e.onPointerMove,Z(e=>{let t=e.target,n=I.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>I.current?`right`:`left`;F.current=t,I.current=e.clientX}}))})})})})})})});We.displayName=K;var Ye=`MenuGroup`,Xe=O.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,k.jsx)(a.div,{role:`group`,...r,ref:t})});Xe.displayName=Ye;var Ze=`MenuLabel`,Qe=O.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,k.jsx)(a.div,{...r,ref:t})});Qe.displayName=Ze;var q=`MenuItem`,$e=`menu.itemSelect`,J=O.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=O.useRef(null),o=G(q,e.__scopeMenu),s=Ue(q,e.__scopeMenu),u=c(t,a),f=O.useRef(!1),p=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent($e,{bubbles:!0,cancelable:!0});e.addEventListener($e,e=>r?.(e),{once:!0}),l(e,t),t.defaultPrevented?f.current=!1:o.onClose()}};return(0,k.jsx)(et,{...i,ref:u,disabled:n,onClick:d(e.onClick,p),onPointerDown:t=>{e.onPointerDown?.(t),f.current=!0},onPointerUp:d(e.onPointerUp,e=>{f.current||e.currentTarget?.click()}),onKeyDown:d(e.onKeyDown,e=>{n||e.target!==e.currentTarget||s.searchRef.current!==``&&e.key===` `||Ce.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});J.displayName=q;var et=O.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...o}=e,s=Ue(q,n),l=Me(n),u=O.useRef(null),f=c(t,u),[p,m]=O.useState(!1),[h,g]=O.useState(``);return O.useEffect(()=>{let e=u.current;e&&g((e.textContent??``).trim())},[o.children]),(0,k.jsx)(V.ItemSlot,{scope:n,disabled:r,textValue:i??h,children:(0,k.jsx)(Se,{asChild:!0,...l,focusable:!r,children:(0,k.jsx)(a.div,{role:`menuitem`,"data-highlighted":p?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...o,ref:f,onPointerMove:d(e.onPointerMove,Z(e=>{r?s.onItemLeave(e):(s.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:d(e.onPointerLeave,Z(e=>s.onItemLeave(e))),onFocus:d(e.onFocus,()=>m(!0)),onBlur:d(e.onBlur,()=>m(!1))})})})}),tt=`MenuCheckboxItem`,nt=O.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,k.jsx)(ut,{scope:e.__scopeMenu,checked:n,children:(0,k.jsx)(J,{role:`menuitemcheckbox`,"aria-checked":X(n)?`mixed`:n,...i,ref:t,"data-state":Tt(n),onSelect:d(i.onSelect,()=>r?.(X(n)?!0:!n),{checkForDefaultPrevented:!1})})})});nt.displayName=tt;var rt=`MenuRadioGroup`,[it,at]=H(rt,{value:void 0,onValueChange:()=>{}}),ot=O.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=p(r);return(0,k.jsx)(it,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,k.jsx)(Xe,{...i,ref:t})})});ot.displayName=rt;var st=`MenuRadioItem`,ct=O.forwardRef((e,t)=>{let{value:n,...r}=e,i=at(st,e.__scopeMenu),a=n===i.value;return(0,k.jsx)(ut,{scope:e.__scopeMenu,checked:a,children:(0,k.jsx)(J,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":Tt(a),onSelect:d(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});ct.displayName=st;var lt=`MenuItemIndicator`,[ut,dt]=H(lt,{checked:!1}),ft=O.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,o=dt(lt,n);return(0,k.jsx)(u,{present:r||X(o.checked)||o.checked===!0,children:(0,k.jsx)(a.span,{...i,ref:t,"data-state":Tt(o.checked)})})});ft.displayName=lt;var pt=`MenuSeparator`,mt=O.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,k.jsx)(a.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});mt.displayName=pt;var ht=`MenuArrow`,gt=O.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=U(n);return(0,k.jsx)(te,{...i,...r,ref:t})});gt.displayName=ht;var _t=`MenuSub`,[vt,yt]=H(_t),bt=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=W(_t,t),o=U(t),[s,c]=O.useState(null),[l,u]=O.useState(null),d=p(i);return O.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,k.jsx)(S,{...o,children:(0,k.jsx)(Ne,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,k.jsx)(vt,{scope:t,contentId:b(),triggerId:b(),trigger:s,onTriggerChange:c,children:n})})})};bt.displayName=_t;var Y=`MenuSubTrigger`,xt=O.forwardRef((e,t)=>{let n=W(Y,e.__scopeMenu),r=G(Y,e.__scopeMenu),i=yt(Y,e.__scopeMenu),a=Ue(Y,e.__scopeMenu),o=O.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=a,u={__scopeMenu:e.__scopeMenu},f=O.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);O.useEffect(()=>f,[f]),O.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),l(null)}},[s,l]);let p=c(t,i.onTriggerChange);return(0,k.jsx)(Le,{asChild:!0,...u,children:(0,k.jsx)(et,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":wt(n.open),...e,ref:p,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:d(e.onPointerMove,Z(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:d(e.onPointerLeave,Z(e=>{f();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:d(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||a.searchRef.current!==``&&t.key===` `||De[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});xt.displayName=Y;var St=`MenuSubContent`,Ct=O.forwardRef((e,t)=>{let n=Be(K,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=W(K,e.__scopeMenu),s=G(K,e.__scopeMenu),l=yt(St,e.__scopeMenu),f=O.useRef(null),p=c(t,f);return(0,k.jsx)(V.Provider,{scope:e.__scopeMenu,children:(0,k.jsx)(u,{present:r||o.open,children:(0,k.jsx)(V.Slot,{scope:e.__scopeMenu,children:(0,k.jsx)(Je,{id:l.contentId,"aria-labelledby":l.triggerId,...a,ref:p,align:i,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&f.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:d(e.onFocusOutside,e=>{e.target!==l.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:d(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:d(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=Oe[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),l.trigger?.focus(),e.preventDefault())})})})})})});Ct.displayName=St;function wt(e){return e?`open`:`closed`}function X(e){return e===`indeterminate`}function Tt(e){return X(e)?`indeterminate`:e?`checked`:`unchecked`}function Et(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Dt(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Ot(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Dt(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function kt(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function At(e,t){return t?kt({x:e.clientX,y:e.clientY},t):!1}function Z(e){return t=>t.pointerType===`mouse`?e(t):void 0}var jt=Fe,Mt=Le,Nt=Ve,Pt=We,Ft=Xe,It=Qe,Lt=J,Rt=nt,zt=ot,Bt=ct,Vt=ft,Ht=mt,Ut=gt,Wt=xt,Gt=Ct,Q=`DropdownMenu`,[Kt,qt]=o(Q,[je]),$=je(),[Jt,Yt]=Kt(Q),Xt=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:a,defaultOpen:o,onOpenChange:s,modal:c=!0}=e,l=$(t),u=O.useRef(null),[d,f]=i({prop:a,defaultProp:o??!1,onChange:s,caller:Q});return(0,k.jsx)(Jt,{scope:t,triggerId:b(),triggerRef:u,contentId:b(),open:d,onOpenChange:f,onOpenToggle:O.useCallback(()=>f(e=>!e),[f]),modal:c,children:(0,k.jsx)(jt,{...l,open:d,onOpenChange:f,dir:r,modal:c,children:n})})};Xt.displayName=Q;var Zt=`DropdownMenuTrigger`,Qt=O.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,o=Yt(Zt,n),s=$(n),l=c(t,o.triggerRef);return(0,k.jsx)(Mt,{asChild:!0,...s,children:(0,k.jsx)(a.button,{type:`button`,id:o.triggerId,"aria-haspopup":`menu`,"aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:l,onPointerDown:d(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(o.onOpenToggle(),o.open||e.preventDefault())}),onKeyDown:d(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&o.onOpenToggle(),e.key===`ArrowDown`&&o.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});Qt.displayName=Zt;var $t=`DropdownMenuPortal`,en=e=>{let{__scopeDropdownMenu:t,...n}=e,r=$(t);return(0,k.jsx)(Nt,{...r,...n})};en.displayName=$t;var tn=`DropdownMenuContent`,nn=O.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Yt(tn,n),a=$(n),o=O.useRef(!1);return(0,k.jsx)(Pt,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:d(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:d(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});nn.displayName=tn;var rn=`DropdownMenuGroup`,an=O.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,k.jsx)(Ft,{...i,...r,ref:t})});an.displayName=rn;var on=`DropdownMenuLabel`,sn=O.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,k.jsx)(It,{...i,...r,ref:t})});sn.displayName=on;var cn=`DropdownMenuItem`,ln=O.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,k.jsx)(Lt,{...i,...r,ref:t})});ln.displayName=cn;var un=`DropdownMenuCheckboxItem`,dn=O.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,k.jsx)(Rt,{...i,...r,ref:t})});dn.displayName=un;var fn=`DropdownMenuRadioGroup`,pn=O.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,k.jsx)(zt,{...i,...r,ref:t})});pn.displayName=fn;var mn=`DropdownMenuRadioItem`,hn=O.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,k.jsx)(Bt,{...i,...r,ref:t})});hn.displayName=mn;var gn=`DropdownMenuItemIndicator`,_n=O.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,k.jsx)(Vt,{...i,...r,ref:t})});_n.displayName=gn;var vn=`DropdownMenuSeparator`,yn=O.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,k.jsx)(Ht,{...i,...r,ref:t})});yn.displayName=vn;var bn=`DropdownMenuArrow`,xn=O.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,k.jsx)(Ut,{...i,...r,ref:t})});xn.displayName=bn;var Sn=`DropdownMenuSubTrigger`,Cn=O.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,k.jsx)(Wt,{...i,...r,ref:t})});Cn.displayName=Sn;var wn=`DropdownMenuSubContent`,Tn=O.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,k.jsx)(Gt,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});Tn.displayName=wn;var En=Xt,Dn=Qt,On=en,kn=nn,An=sn,jn=ln,Mn=pn,Nn=hn,Pn=_n,Fn=yn;function In({...e}){return(0,k.jsx)(En,{"data-slot":`dropdown-menu`,...e})}function Ln({...e}){return(0,k.jsx)(Dn,{"data-slot":`dropdown-menu-trigger`,...e})}function Rn({className:e,sideOffset:t=4,...n}){return(0,k.jsx)(On,{children:(0,k.jsx)(kn,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:_(`z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...n})})}function zn({className:e,inset:t,variant:n=`default`,...r}){return(0,k.jsx)(jn,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:_(`relative flex cursor-pointer items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!`,e),...r})}function Bn({...e}){return(0,k.jsx)(Mn,{"data-slot":`dropdown-menu-radio-group`,...e})}function Vn({className:e,children:t,...n}){return(0,k.jsxs)(Nn,{"data-slot":`dropdown-menu-radio-item`,className:_(`relative flex cursor-pointer items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[(0,k.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,k.jsx)(Pn,{children:(0,k.jsx)(T,{className:`size-2 fill-current`})})}),t]})}function Hn({className:e,inset:t,...n}){return(0,k.jsx)(An,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:_(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function Un({className:e,...t}){return(0,k.jsx)(Fn,{"data-slot":`dropdown-menu-separator`,className:_(`-mx-1 my-1 h-px bg-border`,e),...t})}export{T as _,Bn as a,Ln as c,le as d,M as f,E as g,ne as h,Hn as i,Se as l,D as m,Rn as n,Vn as o,A as p,zn as r,Un as s,In as t,xe as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{F as e}from"./button-BNnH7COh.js";var t=e(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),n=e(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]);export{t as n,n as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as e}from"./button-
|
|
1
|
+
import{F as e}from"./button-BNnH7COh.js";var t=e(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]);export{t};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Et as r,Wn as i,_t as a,fi as o,li as s}from"./project-router-CWMOKp_H.js";import{F as c,r as l}from"./button-BNnH7COh.js";import{t as u}from"./triangle-alert-CP3Xp0FU.js";import{t as d}from"./centered-state-sEYB3bgq.js";import{a as f,i as p,r as m,t as h}from"./markdown-BpZ4p95p.js";var g=c(`file-exclamation-point`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),_=c(`file-question-mark`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),v=c(`file-x`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14.5 12.5-5 5`,key:`b62r18`}],[`path`,{d:`m9.5 12.5 5 5`,key:`1rk7el`}]]),y=c(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),b=c(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),x=c(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),S=e(t(),1),C=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`ico`,`avif`]);function w(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?!1:C.has(t.slice(n+1).toLowerCase())}function T(e){return e.tooLarge?`too-large`:w(e.path)?`image`:e.binary?`binary`:`text`}function E(e){return e>=1024**2?`${(e/1024**2).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} kB`:`${e} B`}var D=n();function O(e,t){let n=r(e.kind===`run`?e.runId:void 0,e.kind===`run`?t:void 0),i=a(e.kind===`repo`?t:void 0);return e.kind===`run`?n:i}function k(e,t){return e.kind===`run`?o(e.runId,t):s(t)}function A({source:e,path:t,className:n}){let r=O(e,t??void 0);if(t===null)return(0,D.jsx)(P,{className:n,children:(0,D.jsx)(d,{icon:(0,D.jsx)(x,{}),tone:`neutral`,heading:`h2`,title:`Select a file`,subtitle:`Pick a file from the tree to preview it here.`})});if(r.isPending)return(0,D.jsx)(P,{className:n,children:(0,D.jsxs)(`p`,{"data-slot":`file-preview-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground`,children:[`Loading `,t,`…`]})});if(r.isError){let e=r.error instanceof i&&r.error.status===409;return(0,D.jsx)(P,{className:n,children:(0,D.jsx)(d,{icon:e?(0,D.jsx)(v,{}):(0,D.jsx)(u,{}),tone:e?`neutral`:`danger`,heading:`h2`,title:e?`Cannot preview this file`:`Could not load this file`,subtitle:r.error.message})})}return r.data.type===`file`?(0,D.jsx)(N,{source:e,entry:r.data,className:n}):null}function j(e){return/\.(md|markdown|mdx)$/i.test(e)}var M=`rendered`;function N({source:e,entry:t,className:n}){let r=T(t),i=r===`text`&&j(t.path),[a,o]=(0,S.useState)(M),s=e=>{M=e,o(e)};return(0,D.jsxs)(P,{className:n,children:[(0,D.jsxs)(`header`,{"data-slot":`file-preview-head`,className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-[color-mix(in_oklab,var(--muted)_40%,var(--card))] px-4 py-2 text-xs shadow-[0_-1px_0_color-mix(in_oklab,var(--muted)_40%,var(--card))]`,children:[(0,D.jsx)(`span`,{className:`min-w-0 truncate font-mono font-medium`,children:t.path}),i?(0,D.jsx)(`div`,{"data-slot":`markdown-view-toggle`,className:`ml-auto flex shrink-0 overflow-hidden rounded-sm border border-border`,children:[`rendered`,`source`].map(e=>(0,D.jsx)(`button`,{type:`button`,"data-mode":e,"aria-pressed":a===e,onClick:()=>s(e),className:l(`px-2 py-0.5 capitalize`,a===e?`bg-muted font-medium text-foreground`:`text-soft-foreground hover:bg-muted`),children:e},e))}):null,(0,D.jsx)(`span`,{className:l(`shrink-0 tabular-nums text-soft-foreground`,i?`pl-2`:`ml-auto`),children:E(t.size)})]}),r===`image`?(0,D.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,D.jsx)(`img`,{"data-slot":`file-preview-image`,src:k(e,t.path),alt:t.path,className:`max-h-[70vh] max-w-full rounded-sm`})}):r===`too-large`?(0,D.jsx)(d,{icon:(0,D.jsx)(g,{}),tone:`neutral`,heading:`h2`,title:`Too large to preview`,subtitle:`${E(t.size)} — past the preview cap. Open it in your editor instead.`}):r===`binary`?(0,D.jsx)(d,{icon:(0,D.jsx)(_,{}),tone:`neutral`,heading:`h2`,title:`Binary file`,subtitle:`${E(t.size)} of binary data — no text preview.`}):i&&a===`rendered`?(0,D.jsx)(`div`,{"data-slot":`file-preview-markdown`,className:`px-4 py-3`,children:(0,D.jsx)(h,{children:t.content??``})}):(0,D.jsx)(L,{path:t.path,text:t.content??``})]})}function P({className:e,children:t}){return(0,D.jsx)(`section`,{"data-slot":`file-preview`,className:l(`overflow-clip rounded-lg border border-border bg-card`,e),children:t})}var F=1500;function I(e,t){let n=(0,S.useMemo)(()=>t.split(`
|
|
2
|
+
`).map(e=>[{content:e}]),[t]),r=(0,S.useMemo)(()=>f(e),[e]),i=n.length>F,[a,o]=(0,S.useState)(null);return(0,S.useEffect)(()=>{if(r===null||i)return;let n=!1;return m(t,r).then(r=>{n||o({key:`${e}\0${t}`,tokens:r.tokens})}),()=>{n=!0}},[e,t,r,i]),r===null||i?n:a?.key===`${e}\0${t}`?a.tokens:p(t,r)?.tokens??n}function L({path:e,text:t}){let n=I(e,t);return(0,D.jsx)(`div`,{"data-slot":`file-preview-code`,"data-lang":f(e)??`plaintext`,className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7]`,children:n.map((e,t)=>(0,D.jsxs)(`div`,{className:`flex px-4`,children:[(0,D.jsx)(`span`,{className:`w-10 shrink-0 select-none pr-3 text-right tabular-nums text-soft-foreground`,children:t+1}),(0,D.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre pr-4`,children:e.map((e,t)=>(0,D.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t))})]},t))})}export{y as a,b as i,E as n,w as r,A as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{F as e}from"./button-BNnH7COh.js";var t=e(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{r}from"./button-BNnH7COh.js";import{t as i}from"./chevron-right-Beu1pd6H.js";import{h as a}from"./dropdown-menu-CxPGHgWX.js";import{t as o}from"./file-DkvcUwxT.js";import{n as s}from"./markdown-C5F95Rt-.js";var c=e(t(),1),l=n();function u({root:e,selected:t,onSelect:n,commentCounts:r=d}){return(0,l.jsx)(f.Provider,{value:r,children:(0,l.jsx)(`nav`,{"data-slot":`changes-tree`,"aria-label":`Changed files`,className:`min-w-0 text-[13px]`,children:(0,l.jsxs)(`ul`,{className:`flex flex-col gap-px`,children:[e.dirs.map(e=>(0,l.jsx)(h,{dir:e,depth:0,selected:t,onSelect:n},e.path)),e.files.map(e=>(0,l.jsx)(_,{file:e,depth:0,selected:t,onSelect:n},e.path))]})})})}var d=new Map,f=(0,c.createContext)(d);function p(e,t){let n=0;for(let r of e.files)n+=t.get(r.path)??0;for(let r of e.dirs)n+=p(r,t);return n}function m({adds:e,dels:t}){return(0,l.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] font-medium tabular-nums`,children:[e>0?(0,l.jsxs)(`span`,{className:`text-success`,children:[`+`,e]}):null,e>0&&t>0?` `:null,t>0?(0,l.jsxs)(`span`,{className:`text-danger`,children:[`−`,t]}):null]})}function h({dir:e,depth:t,selected:n,onSelect:o}){let[u,d]=(0,c.useState)(!0),g=(0,c.useContext)(f),v=u?0:p(e,g);return(0,l.jsxs)(`li`,{children:[(0,l.jsxs)(`button`,{type:`button`,"data-slot":`tree-dir`,"data-path":e.path,"data-state":u?`open`:`closed`,"aria-expanded":u,onClick:()=>d(e=>!e),className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+t*14}px`},children:[(0,l.jsx)(i,{"aria-hidden":`true`,className:r(`size-3.5 shrink-0 transition-transform`,u&&`rotate-90`)}),(0,l.jsx)(a,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,l.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.name}),(0,l.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[(0,l.jsx)(s,{count:v}),(0,l.jsx)(m,{adds:e.adds,dels:e.dels})]})]}),u?(0,l.jsxs)(`ul`,{className:`flex flex-col gap-px`,children:[e.dirs.map(e=>(0,l.jsx)(h,{dir:e,depth:t+1,selected:n,onSelect:o},e.path)),e.files.map(e=>(0,l.jsx)(_,{file:e,depth:t+1,selected:n,onSelect:o},e.path))]}):null]})}var g={added:`text-success`,deleted:`text-danger`};function _({file:e,depth:t,selected:n,onSelect:i}){let a=n===e.path,u=(0,c.useContext)(f).get(e.path)??0;return(0,l.jsx)(`li`,{children:(0,l.jsxs)(`button`,{type:`button`,"data-slot":`tree-file`,"data-path":e.path,"aria-current":a?`true`:void 0,onClick:()=>i(e.path),className:r(`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,a?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${24+t*14}px`},children:[(0,l.jsx)(o,{"aria-hidden":`true`,className:r(`size-3.5 shrink-0`,g[e.status])}),(0,l.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,l.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[(0,l.jsx)(s,{count:u}),(0,l.jsx)(m,{adds:e.adds,dels:e.dels})]})]})})}var v=(e,t)=>e.name.localeCompare(t.name);function y(e){let t=e;for(;t.files.length===0&&t.dirs.length===1;){let e=t.dirs[0];t={...e,name:`${t.name}/${e.name}`}}return{...t,dirs:t.dirs.map(y)}}function b(e,t){let n=(e,t)=>({kind:`dir`,name:e,path:t,dirs:[],files:[]}),r=n(``,``),i=new Map([[``,r]]),a=e=>{let t=i.get(e);if(t)return t;let r=e.lastIndexOf(`/`),o=a(r===-1?``:e.slice(0,r)),s=n(r===-1?e:e.slice(r+1),e);return o.dirs.push(s),i.set(e,s),s};for(let n of e){let e=n.lastIndexOf(`/`);a(e===-1?``:n.slice(0,e)).files.push(t(n,e===-1?n:n.slice(e+1)))}let o=e=>{e.dirs.forEach(o),e.dirs.sort(v),e.files.sort(v)};return o(r),{...r,dirs:r.dirs.map(y)}}function x(e){let t=new Map(e.map(e=>[e.path,e])),n=b(e.map(e=>e.path),(e,n)=>{let r=t.get(e);return{kind:`file`,name:n,path:e,status:r.status,adds:r.adds,dels:r.dels,binary:r.binary}}),r=e=>{let t=e.dirs.map(r);return{...e,dirs:t,adds:e.files.reduce((e,t)=>e+t.adds,0)+t.reduce((e,t)=>e+t.adds,0),dels:e.files.reduce((e,t)=>e+t.dels,0)+t.reduce((e,t)=>e+t.dels,0),fileCount:e.files.length+t.reduce((e,t)=>e+t.fileCount,0)}};return r(n)}export{b as n,u as r,x as t};
|