specrails-desktop 2.29.4 → 2.30.0
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/client/dist/assets/{ActivityFeedPage-CDMzpGXd.js → ActivityFeedPage-AQgpr9qG.js} +1 -1
- package/client/dist/assets/{AgentBrowserCapture-BVTacapZ.js → AgentBrowserCapture-I7a0usG7.js} +1 -1
- package/client/dist/assets/AgentModeCodePane-BqOVg15n.js +2 -0
- package/client/dist/assets/{AgentModeJobsPane-DAjN8Au5.js → AgentModeJobsPane-4SG6FF27.js} +1 -1
- package/client/dist/assets/{AgentsPage-CebykajE.js → AgentsPage-C3FgYlEi.js} +1 -1
- package/client/dist/assets/{AnalyticsPage-BiPrVvgv.js → AnalyticsPage-BcMNByW5.js} +1 -1
- package/client/dist/assets/{CodePage-Dw9eQFRS.js → CodePage-CgdDkXp-.js} +1 -1
- package/client/dist/assets/{DesktopAnalyticsPage-cCG_JAEi.js → DesktopAnalyticsPage-DPMcS88n.js} +1 -1
- package/client/dist/assets/{DocsDialog-C1kZ_mRP.js → DocsDialog-BC7574Zi.js} +1 -1
- package/client/dist/assets/{DocsPage-3GivxWJm.js → DocsPage-Dd9yilUg.js} +1 -1
- package/client/dist/assets/{InteractiveJobComposer-KuZXGdr8.js → InteractiveJobComposer-CqC_0VQL.js} +1 -1
- package/client/dist/assets/{JobDetailModal-DWpRALkB.js → JobDetailModal-BFNXOhk1.js} +1 -1
- package/client/dist/assets/{JobDetailPage-mrXDKafj.js → JobDetailPage-DM-6zYpA.js} +1 -1
- package/client/dist/assets/{JobsPage-CUYXjcoc.js → JobsPage-1dkjPk1k.js} +1 -1
- package/client/dist/assets/{LoopBuilderPage-CwjBD5Gm.js → LoopBuilderPage-BPeqz6cG.js} +1 -1
- package/client/dist/assets/{LoopPreviewModal-CO9ton0-.js → LoopPreviewModal-EdkyYaGN.js} +1 -1
- package/client/dist/assets/{LoopsPage-CLL5UuvN.js → LoopsPage-nZfgiaK8.js} +1 -1
- package/client/dist/assets/{MinimizedChatsContext-DJAkRYps.js → MinimizedChatsContext-Cs34FPTz.js} +1 -1
- package/client/dist/assets/{PluginsPage-DZvCC5Ri.js → PluginsPage-CwFfFBzW.js} +1 -1
- package/client/dist/assets/{ProjectSettingsDialog-C7Hesadg.js → ProjectSettingsDialog-DHsxLFMT.js} +1 -1
- package/client/dist/assets/{TemplatePreviewModal-DczCzUzP.js → TemplatePreviewModal-wcI3nGNr.js} +1 -1
- package/client/dist/assets/TicketDetailModal-7EloKP1C.js +14 -0
- package/client/dist/assets/{Trans-Cm9rhdnG.js → Trans-CPISVji8.js} +1 -1
- package/client/dist/assets/agent-BABjRt0P.js +1 -0
- package/client/dist/assets/agent-BuUpgqVx.js +1 -0
- package/client/dist/assets/agent-CCDZesgU.js +1 -0
- package/client/dist/assets/agent-CVn64zWH.js +1 -0
- package/client/dist/assets/agent-CWeOny0E.js +1 -0
- package/client/dist/assets/agent-DOysmad_.js +1 -0
- package/client/dist/assets/agent-DSsjTBhn.js +1 -0
- package/client/dist/assets/agent-DlZMxfM9.js +1 -0
- package/client/dist/assets/builder-BH8Fua-g.js +1 -0
- package/client/dist/assets/builder-BoV7DgKd.js +1 -0
- package/client/dist/assets/builder-Cc_Lf79C.js +1 -0
- package/client/dist/assets/builder-CwA4T7gP.js +1 -0
- package/client/dist/assets/builder-CwZ7Bme2.js +1 -0
- package/client/dist/assets/builder-CxW-JFsR.js +1 -0
- package/client/dist/assets/builder-D94lrV7x.js +1 -0
- package/client/dist/assets/builder-cqHpCyGa.js +1 -0
- package/client/dist/assets/{dist-js-BERxOT0X.js → dist-js-Bt2zW2YG.js} +1 -1
- package/client/dist/assets/{dist-js-Di8lflPo.js → dist-js-zvt5ap3o.js} +1 -1
- package/client/dist/assets/{formatDistanceToNow-BAXZRbEO.js → formatDistanceToNow-ByKli7Q_.js} +1 -1
- package/client/dist/assets/{getTimezoneOffsetInMilliseconds-DwzZXHtg.js → getTimezoneOffsetInMilliseconds-qrcBaLW1.js} +1 -1
- package/client/dist/assets/i18n-Bf9Ckd10.js +2 -0
- package/client/dist/assets/index-Dh9i4CnN.css +2 -0
- package/client/dist/assets/index-xkzK3E5i.js +76 -0
- package/client/dist/assets/setup-3832BJCo.js +1 -0
- package/client/dist/assets/setup-B8J-gECe.js +1 -0
- package/client/dist/assets/setup-BCIOxVsc.js +1 -0
- package/client/dist/assets/setup-BciLj_tU.js +1 -0
- package/client/dist/assets/setup-CITtPjed.js +1 -0
- package/client/dist/assets/setup-CTkE3cfh.js +1 -0
- package/client/dist/assets/setup-ajB4rYm-.js +1 -0
- package/client/dist/assets/setup-xFO1wNl0.js +1 -0
- package/client/dist/assets/{spending-BLb5pj6G.js → spending-DMnCXy84.js} +1 -1
- package/client/dist/assets/{useBrowserCaptureSession-DR1_jL56.js → useBrowserCaptureSession-CkBJShUw.js} +1 -1
- package/client/dist/assets/{useDesktop-D4DxBGPU.js → useDesktop-B4pSBIDd.js} +1 -1
- package/client/dist/index.html +14 -13
- package/docs/codex.md +2 -1
- package/docs/customizing.md +1 -1
- package/docs/internals/gemini-mcp-registration.md +1 -1
- package/docs/internals/global-artifacts-alignment-contract.md +4 -4
- package/docs/internals/project-builder.md +306 -0
- package/docs/internals/safe-pr-review-flow.md +29 -19
- package/package.json +1 -1
- package/server/dist/agent-operator-prompt.js +7 -1
- package/server/dist/blueprint-chat-manager.js +335 -0
- package/server/dist/blueprint-commit.js +335 -0
- package/server/dist/blueprint-draft-parser.js +168 -0
- package/server/dist/blueprint-operator-prompt.js +149 -0
- package/server/dist/blueprint-render.js +105 -0
- package/server/dist/blueprint-router.js +173 -0
- package/server/dist/blueprint-spec-quality.js +167 -0
- package/server/dist/blueprint-store.js +49 -0
- package/server/dist/blueprint-types.js +29 -0
- package/server/dist/builder-cwd-manager.js +57 -0
- package/server/dist/chat-manager.js +435 -23
- package/server/dist/context-scope.js +6 -3
- package/server/dist/contract-refine-runner.js +143 -72
- package/server/dist/desktop-db.js +27 -0
- package/server/dist/index.js +15 -0
- package/server/dist/offline-assemble.js +203 -0
- package/server/dist/pricing.js +5 -0
- package/server/dist/project-router-chat.js +14 -2
- package/server/dist/project-router.js +130 -7
- package/server/dist/providers/claude-adapter.js +8 -2
- package/server/dist/providers/codex-adapter.js +23 -10
- package/server/dist/providers/gemini-adapter.js +16 -7
- package/server/dist/rail-isolated-launch.js +11 -1
- package/server/dist/setup-manager.js +6 -54
- package/server/dist/spec-models.js +3 -0
- package/server/dist/workspace-manager.js +3 -1
- package/server/dist/worktree-overlay.js +233 -51
- package/client/dist/assets/AgentModeCodePane-D9bhFyuy.js +0 -2
- package/client/dist/assets/TicketDetailModal-CFh7GOv5.js +0 -14
- package/client/dist/assets/agent-BXc59ARK2.js +0 -1
- package/client/dist/assets/agent-BbIFXdDq.js +0 -1
- package/client/dist/assets/agent-BqEfA5u5.js +0 -1
- package/client/dist/assets/agent-BtGzgTC4.js +0 -1
- package/client/dist/assets/agent-CIhys_5d.js +0 -1
- package/client/dist/assets/agent-CJPaqsVR.js +0 -1
- package/client/dist/assets/agent-n-hY4GuL.js +0 -1
- package/client/dist/assets/agent-tJ-efa3_2.js +0 -1
- package/client/dist/assets/i18n-cK5pPbj8.js +0 -2
- package/client/dist/assets/index-BT6xDQjB.css +0 -2
- package/client/dist/assets/index-CCq_kIrF.js +0 -76
- package/client/dist/assets/setup-CGZjy2IF2.js +0 -1
- package/client/dist/assets/setup-CXa0Sx16.js +0 -1
- package/client/dist/assets/setup-CmK87LuS.js +0 -1
- package/client/dist/assets/setup-D2ktKKMF2.js +0 -1
- package/client/dist/assets/setup-DG2H7ha5.js +0 -1
- package/client/dist/assets/setup-DK5bHDUq2.js +0 -1
- package/client/dist/assets/setup-DrWlIQTZ.js +0 -1
- package/client/dist/assets/setup-rzHUVgAu.js +0 -1
- /package/client/dist/assets/{activity-C6kJpm9q2.js → activity-C6kJpm9q.js} +0 -0
- /package/client/dist/assets/{activity-DAyekdlt2.js → activity-DAyekdlt.js} +0 -0
- /package/client/dist/assets/{addspec-DbNBbrha2.js → addspec-DbNBbrha.js} +0 -0
- /package/client/dist/assets/{addspec-htHGZHOe2.js → addspec-htHGZHOe.js} +0 -0
- /package/client/dist/assets/{agents-6ZOJXWVk2.js → agents-6ZOJXWVk.js} +0 -0
- /package/client/dist/assets/{agents-Bz-thHkB2.js → agents-Bz-thHkB.js} +0 -0
- /package/client/dist/assets/{agentstudio-BLGvxWBx2.js → agentstudio-BLGvxWBx.js} +0 -0
- /package/client/dist/assets/{agentstudio-D9UKiWTj2.js → agentstudio-D9UKiWTj.js} +0 -0
- /package/client/dist/assets/{aiedit-BoG24nlg2.js → aiedit-BoG24nlg.js} +0 -0
- /package/client/dist/assets/{aiedit-olnv3QSt2.js → aiedit-olnv3QSt.js} +0 -0
- /package/client/dist/assets/{analytics-CdsAPAwZ2.js → analytics-CdsAPAwZ.js} +0 -0
- /package/client/dist/assets/{analytics-IEsKZvpW2.js → analytics-IEsKZvpW.js} +0 -0
- /package/client/dist/assets/{attachments-D0wXXt9T2.js → attachments-D0wXXt9T.js} +0 -0
- /package/client/dist/assets/{attachments-V_WZAYXx2.js → attachments-V_WZAYXx.js} +0 -0
- /package/client/dist/assets/{browser-CyR1Kp3m2.js → browser-CyR1Kp3m.js} +0 -0
- /package/client/dist/assets/{browser-DwZljcRh2.js → browser-DwZljcRh.js} +0 -0
- /package/client/dist/assets/{chat-BR8oe53x2.js → chat-BR8oe53x.js} +0 -0
- /package/client/dist/assets/{chat-DZyu3ImY2.js → chat-DZyu3ImY.js} +0 -0
- /package/client/dist/assets/{code-D20ef9Cf2.js → code-D20ef9Cf.js} +0 -0
- /package/client/dist/assets/{code-geHmknB92.js → code-geHmknB9.js} +0 -0
- /package/client/dist/assets/{commands-BEwbAjtD2.js → commands-BEwbAjtD.js} +0 -0
- /package/client/dist/assets/{commands-DTQBF_q52.js → commands-DTQBF_q5.js} +0 -0
- /package/client/dist/assets/{common-BNbnv8cE2.js → common-BNbnv8cE.js} +0 -0
- /package/client/dist/assets/{common-DBtTzeYm2.js → common-DBtTzeYm.js} +0 -0
- /package/client/dist/assets/{dashboard-Cqmmbh3l2.js → dashboard-Cqmmbh3l.js} +0 -0
- /package/client/dist/assets/{dashboard-Dy2Um-US2.js → dashboard-Dy2Um-US.js} +0 -0
- /package/client/dist/assets/{explore-C0TjprJW2.js → explore-C0TjprJW.js} +0 -0
- /package/client/dist/assets/{explore-DsXAgnmJ2.js → explore-DsXAgnmJ.js} +0 -0
- /package/client/dist/assets/{integrations-CH0zy1Mw2.js → integrations-CH0zy1Mw.js} +0 -0
- /package/client/dist/assets/{integrations-b8pH-vfl2.js → integrations-b8pH-vfl.js} +0 -0
- /package/client/dist/assets/{jira-CNeYi06w2.js → jira-CNeYi06w.js} +0 -0
- /package/client/dist/assets/{jira-pRaL7JQo2.js → jira-pRaL7JQo.js} +0 -0
- /package/client/dist/assets/{jobs-B-sDHEay2.js → jobs-B-sDHEay.js} +0 -0
- /package/client/dist/assets/{jobs-DzSIR8V62.js → jobs-DzSIR8V6.js} +0 -0
- /package/client/dist/assets/{loops-Crc9It8o2.js → loops-Crc9It8o.js} +0 -0
- /package/client/dist/assets/{loops-DH2hZcbK2.js → loops-DH2hZcbK.js} +0 -0
- /package/client/dist/assets/{loops-DS5TmvIU2.js → loops-DS5TmvIU.js} +0 -0
- /package/client/dist/assets/{mcp-Czd_iyp02.js → mcp-Czd_iyp0.js} +0 -0
- /package/client/dist/assets/{mcp-D4ZjtIx32.js → mcp-D4ZjtIx3.js} +0 -0
- /package/client/dist/assets/{mcp-DIfBUv2D2.js → mcp-DIfBUv2D.js} +0 -0
- /package/client/dist/assets/{nav-BRJBxaGt2.js → nav-BRJBxaGt.js} +0 -0
- /package/client/dist/assets/{nav-CNskRJKQ2.js → nav-CNskRJKQ.js} +0 -0
- /package/client/dist/assets/{nav-TvumAFD22.js → nav-TvumAFD2.js} +0 -0
- /package/client/dist/assets/{settings-DAZqjX2a2.js → settings-DAZqjX2a.js} +0 -0
- /package/client/dist/assets/{settings-DRh39v1S2.js → settings-DRh39v1S.js} +0 -0
- /package/client/dist/assets/{settings-Mj1OJbfd2.js → settings-Mj1OJbfd.js} +0 -0
- /package/client/dist/assets/{specs-BcyxaCwf2.js → specs-BcyxaCwf.js} +0 -0
- /package/client/dist/assets/{specs-CLZKysq-2.js → specs-CLZKysq-.js} +0 -0
- /package/client/dist/assets/{specs-dV3Mq5Mu2.js → specs-dV3Mq5Mu.js} +0 -0
- /package/client/dist/assets/{terminal-C2NAd7BW2.js → terminal-C2NAd7BW.js} +0 -0
- /package/client/dist/assets/{terminal-IahE4LW92.js → terminal-IahE4LW9.js} +0 -0
- /package/client/dist/assets/{terminal-QpXZU2Bn2.js → terminal-QpXZU2Bn.js} +0 -0
- /package/client/dist/assets/{tickets-Bs37scwY2.js → tickets-Bs37scwY.js} +0 -0
- /package/client/dist/assets/{tickets-DQp7JS2R2.js → tickets-DQp7JS2R.js} +0 -0
- /package/client/dist/assets/{tickets-DpmdE8tv2.js → tickets-DpmdE8tv.js} +0 -0
package/client/dist/assets/{MinimizedChatsContext-DJAkRYps.js → MinimizedChatsContext-Cs34FPTz.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{t as o}from"./sparkles-DrY8hb0X.js";import{t as s}from"./x-CBMI9ejn.js";import{n as c}from"./useSharedWebSocket-DaPh7QBL.js";import{r as l}from"./useDesktop-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{t as o}from"./sparkles-DrY8hb0X.js";import{t as s}from"./x-CBMI9ejn.js";import{n as c}from"./useSharedWebSocket-DaPh7QBL.js";import{r as l}from"./useDesktop-B4pSBIDd.js";var u=a(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),d=a(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),f=a(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),p=a(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),m=e(t(),1),h=[`title`,`description`,`labels`,`priority`,`acceptanceCriteria`],g={title:``,description:``,labels:[],priority:`medium`,acceptanceCriteria:[]};function _(e){return!e||typeof e!=`object`?!1:e.type===`spec_draft.update`}var v=n(),y=42;function b(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=y?t:t.slice(0,y-1).trimEnd()+`…`}function x({chat:e,projectName:t,onRestore:n,onClose:r}){let{t:a}=i(`chat`),o=b(e.label);return(0,v.jsxs)(`div`,{"data-testid":`minimized-chat-chip-${e.id}`,className:`grid items-start gap-2 w-full max-w-full`,style:{gridTemplateColumns:`auto minmax(0, 1fr) auto`},children:[(0,v.jsx)(S,{kind:e.kind}),(0,v.jsxs)(`button`,{type:`button`,onClick:n,className:`min-w-0 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50 rounded overflow-hidden`,"aria-label":a(`chip.restore`,{label:e.label}),title:e.label,children:[(0,v.jsx)(`div`,{className:`text-sm font-medium text-foreground truncate`,children:o}),(0,v.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5 truncate`,children:a(`chip.continueEditing`,{projectName:t})})]}),(0,v.jsx)(`button`,{type:`button`,onClick:r,className:`flex items-center justify-center w-6 h-6 rounded text-muted-foreground hover:text-foreground hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50`,"aria-label":a(`chip.close`,{label:e.label}),children:(0,v.jsx)(s,{className:`w-3.5 h-3.5`})})]})}function S({kind:e}){let{t}=i(`chat`);return(0,v.jsx)(e===`ai-edit`?o:p,{className:`w-4 h-4 text-accent-primary flex-shrink-0 mt-0.5`,"aria-label":t(e===`ai-edit`?`chip.kindAiEdit`:`chip.kindExploreSpec`)})}function C({chats:e,projects:t,hidden:n,onRestore:r,onClose:a}){let{t:o}=i(`chat`),s=(0,m.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.id,n.name);return e},[t]),c=(0,m.useMemo)(()=>[...e].sort((e,t)=>t.createdAt-e.createdAt),[e]);return n||c.length===0?null:(0,v.jsxs)(`div`,{"data-testid":`minimized-chats-dock`,"aria-label":o(`dock.minimizedSessions`,{count:c.length}),className:`fixed bottom-4 right-14 z-[70] flex flex-col-reverse gap-2 w-[320px] max-w-[calc(100vw-15rem)] max-h-[70vh] overflow-y-auto pointer-events-none`,children:[c.map(e=>(0,v.jsx)(`div`,{className:`pointer-events-auto glass-card border border-border/30 rounded-lg p-3 shadow-lg w-full`,children:(0,v.jsx)(x,{chat:e,projectName:s.get(e.projectId)??o(`dock.unknownProject`),onRestore:()=>r(e.id),onClose:()=>a(e.id)})},e.id)),c.length>1&&(0,v.jsxs)(`div`,{className:`pointer-events-auto self-end inline-flex items-center gap-1 rounded-full bg-card/80 border border-border/40 px-2 py-0.5 text-[10px] text-muted-foreground backdrop-blur-sm`,children:[(0,v.jsx)(f,{className:`w-3 h-3`}),o(`dock.minimizedCount`,{count:c.length})]})]})}var w=(0,m.createContext)(null),T=`specrails-desktop:minimized-chats`,E=`specrails-desktop:minimized-chats-pending`,D=50,O=8e3;function k(){return N(T)}function A(e){F(T,e)}function j(){return N(E)}function M(e){F(E,e)}function N(e){if(typeof window>`u`)return[];try{let t=window.localStorage.getItem(e);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(I):[]}catch{return[]}}function P(e){return e.length<=D?e:[...e].sort((e,t)=>e.createdAt-t.createdAt).slice(e.length-D)}function F(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(e,JSON.stringify(P(t)))}catch{}}function I(e){if(!e||typeof e!=`object`)return!1;let t=e;return!(typeof t.id!=`string`||typeof t.projectId!=`string`||typeof t.label!=`string`||typeof t.restoreRoute!=`string`||typeof t.createdAt!=`number`||t.kind!==`explore-spec`&&t.kind!==`ai-edit`||!t.params||typeof t.params!=`object`)}function L(){return typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function R(e){return e.kind===`explore-spec`?e.params.resumeConversationId??`pending:${e.params.pendingSpecId}`:e.params.resumeRefineId??`agent:${e.params.agentId}`}function z(e,t){return e.kind!==t.kind||e.projectId!==t.projectId?!1:R(e)===R(t)}function B({children:e}){let{projects:t,activeProjectId:n,setActiveProjectId:i,setupProjectIds:a}=l(),o=r(),{registerHandler:s,unregisterHandler:u}=c(),[d,f]=(0,m.useState)(()=>k()),[p,h]=(0,m.useState)([]),g=(0,m.useRef)(d);g.current=d;let y=(0,m.useRef)(p);y.current=p;let b=(0,m.useRef)(new Map),x=(0,m.useRef)(t);x.current=t;let S=(0,m.useRef)(!1);(0,m.useEffect)(()=>{if(S.current)return;S.current=!0;let e=j();M([]),e.length!==0&&f(t=>{let n=[...t];for(let t of e)n.some(e=>e.id===t.id||z(e,t))||n.push(t);return A(n),g.current=n,n})},[]),(0,m.useEffect)(()=>{let e=b.current;return()=>{for(let t of e.values())clearTimeout(t);e.clear()}},[]),(0,m.useEffect)(()=>{A(d)},[d]),(0,m.useEffect)(()=>{M(p)},[p]);let T=(0,m.useRef)(()=>{}),E=(0,m.useRef)(()=>{});(0,m.useEffect)(()=>{let e=`minimized-chats:spec-draft`;return s(e,e=>{if(!_(e))return;let t=e.conversationId,n=g.current.find(e=>e.kind===`explore-spec`&&e.params.resumeConversationId===t);if(!n)return;let r=e.draft;r.title?.trim()&&T.current(n.id,r.title);let i={};r.title!==void 0&&(i.title=r.title),r.description!==void 0&&(i.description=r.description),r.priority!==void 0&&(i.priority=r.priority),r.labels!==void 0&&(i.labels=r.labels),r.acceptanceCriteria!==void 0&&(i.acceptanceCriteria=r.acceptanceCriteria),Object.keys(i).length>0&&E.current(n.id,i)}),()=>u(e)},[s,u]),(0,m.useEffect)(()=>{if(t.length===0)return;let e=new Set(t.map(e=>e.id));f(t=>{let n=t.filter(t=>e.has(t.projectId));return n.length===t.length?t:(A(n),g.current=n,n)}),h(t=>{let n=t.filter(t=>e.has(t.projectId));return n.length===t.length?t:(M(n),y.current=n,n)})},[t]);let D=(0,m.useCallback)(e=>{let t=L(),n={...e,id:t,createdAt:Date.now()};if(f(e=>{let t=P([...e.filter(e=>!z(e,n)),n]);return A(t),g.current=t,t}),e.kind===`explore-spec`){let t=e.params.resumeConversationId;t&&fetch(`/api/projects/${e.projectId}/chat/conversations/${t}/minimize`,{method:`POST`}).catch(()=>{})}return t},[]),N=(0,m.useCallback)(e=>{let t=b.current.get(e);t&&(clearTimeout(t),b.current.delete(e))},[]),F=(0,m.useCallback)(e=>{N(e),f(t=>{let n=t.filter(t=>t.id!==e);return A(n),g.current=n,n}),h(t=>{let n=t.filter(t=>t.id!==e);return n.length===t.length?t:(M(n),y.current=n,n)})},[N]),I=(0,m.useCallback)((e,t)=>{let n=t.trim();n&&f(t=>{let r=t.map(t=>t.id===e&&t.label!==n?{...t,label:n}:t);return r===t?t:(g.current=r,r)})},[]),R=(0,m.useCallback)((e,t)=>{f(n=>{let r=n.map(n=>{if(n.id!==e||n.kind!==`explore-spec`)return n;let r={...n.params.draftOverrides??{},...t};return{...n,params:{...n.params,draftOverrides:r}}});return g.current=r,r})},[]),B=(0,m.useCallback)(e=>{let t=g.current.find(t=>t.id===e);if(!t||x.current.length>0&&!x.current.some(e=>e.id===t.projectId))return;if(t.kind===`explore-spec`){let e=t.params.resumeConversationId;e&&fetch(`/api/projects/${t.projectId}/chat/conversations/${e}/restore`,{method:`POST`}).catch(()=>{})}n!==t.projectId&&i(t.projectId),o(t.restoreRoute),h(n=>{let r=[...n.filter(t=>t.id!==e),t];return M(r),y.current=r,r}),f(t=>{let n=t.filter(t=>t.id!==e);return A(n),g.current=n,n}),N(e);let r=setTimeout(()=>{b.current.delete(e),y.current.some(t=>t.id===e)&&(h(t=>{let n=t.filter(t=>t.id!==e);return M(n),y.current=n,n}),f(n=>{if(n.some(n=>n.id===e||z(n,t)))return n;let r=[...n,t];return A(r),g.current=r,r}))},O);b.current.set(e,r)},[n,i,o,N]),V=(0,m.useRef)(B);V.current=B;let H=(0,m.useRef)(F);H.current=F,T.current=I,E.current=R;let U=(0,m.useCallback)((e,t)=>{let n=y.current,r=n.findIndex(n=>n.kind===e&&n.projectId===t);if(r===-1)return null;let i=n[r];return N(i.id),h(e=>{let t=e.filter(e=>e.id!==i.id);return M(t),t}),y.current=n.filter(e=>e.id!==i.id),i},[N]),W=(0,m.useCallback)(e=>{let t=L(),r={...e,id:t,createdAt:Date.now()};n!==e.projectId&&i(e.projectId),o(e.restoreRoute),h(e=>{let t=[...e,r];return M(t),y.current=t,t}),N(t);let a=setTimeout(()=>{b.current.delete(t),y.current.some(e=>e.id===t)&&(h(e=>{let n=e.filter(e=>e.id!==t);return M(n),y.current=n,n}),f(e=>{if(e.some(e=>e.id===t||z(e,r)))return e;let n=[...e,r];return A(n),g.current=n,n}))},O);b.current.set(t,a)},[n,i,o,N]),G=(0,m.useMemo)(()=>({chats:d,pendingRestores:p,minimize:D,updateLabel:I,patchExploreSpecDraft:R,close:F,restore:B,takePendingRestore:U,triggerResume:W}),[d,p,D,I,R,F,B,U,W]),K=n!==null&&a.has(n);return(0,v.jsxs)(w.Provider,{value:G,children:[e,(0,v.jsx)(C,{chats:d,projects:t,hidden:K,onRestore:B,onClose:F})]})}function V(){return(0,m.useContext)(w)||{chats:[],pendingRestores:[],minimize:()=>``,updateLabel:()=>{},patchExploreSpecDraft:()=>{},close:()=>{},restore:()=>{},takePendingRestore:()=>null,triggerResume:()=>{}}}function H(e,t,n){let{pendingRestores:r,takePendingRestore:i}=V(),a=(0,m.useRef)(n);a.current=n,(0,m.useEffect)(()=>{if(!t)return;let n=i(e,t);n&&a.current(n)},[r,e,t,i])}export{h as a,f as c,g as i,d as l,V as n,_ as o,H as r,p as s,B as t,u};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r,t as i}from"./createLucideIcon-Bjbbp_KS.js";import{n as a}from"./dist-bVqfYmby.js";import{t as o}from"./download-CFHyyHcw.js";import{t as s}from"./loader-circle-DcygOQpC.js";import{t as c}from"./search-Cq_gE3Ik.js";import{t as l}from"./trash-2-BOU3WdZZ.js";import{t as u}from"./triangle-alert-H9T4jAmh.js";import{a as d}from"./auth-D_5bQv5W.js";import{n as f}from"./useSharedWebSocket-DaPh7QBL.js";import{n as p,r as m}from"./useDesktop-D4DxBGPU.js";import{t as h}from"./button-BUIIBQPT.js";import{t as g}from"./utils-BC4DHlz2.js";import{a as _,n as v,o as y,r as b,t as x}from"./dialog-CzIekCw0.js";import{t as S}from"./jira-api-BgFIr8eD.js";import{at as C,jt as w,kt as T,nt as ee,rt as te,tt as ne,u as E,ut as D}from"./index-CCq_kIrF.js";var O=i(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),re=i(`folder-kanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),k=i(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),A=i(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),ie=i(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),j=e(t(),1),M=n(),N=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],ae={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function P({state:e,onChanged:t,apiBase:n}){let{t:i}=r(`jira`),o=e.connection,[s,c]=(0,j.useState)(o.enabled),[l,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)([]),[g,_]=(0,j.useState)([]),[v,y]=(0,j.useState)(o.discardStatus??``),[b,x]=(0,j.useState)(o.statusMap??{}),C=e.outbox??{pending:0,inflight:0,done:0,dead:0},w=(0,j.useCallback)(async()=>{try{let{ops:e}=n?await S.listOutbox(`dead`,n):await S.listOutbox(`dead`);m(e)}catch{m([])}},[n]);(0,j.useEffect)(()=>{w()},[w]),(0,j.useEffect)(()=>{let e=!1;return S.listStatuses(n).then(({statuses:t})=>{e||_(t)}).catch(()=>{e||_([])}),()=>{e=!0}},[n]);async function T(e){let r=v;y(e);try{n?await S.patchConnection({discardStatus:e||null},n):await S.patchConnection({discardStatus:e||null}),t()}catch(e){y(r),a.error(I(e,i))}}async function ee(e,r){let o=b,s={...b,[e]:r||void 0};x(s);let c=Object.fromEntries(Object.entries(s).filter(([,e])=>e));try{n?await S.patchConnection({statusMap:Object.keys(c).length?c:null},n):await S.patchConnection({statusMap:Object.keys(c).length?c:null}),t()}catch(e){x(o),a.error(I(e,i))}}async function te(){let e=!s;c(e),f(!0);try{n?await S.setEnabled(e,n):await S.setEnabled(e)}catch(t){c(!e),a.error(I(t,i))}finally{f(!1)}}async function ne(){u(!0);try{let e=n?await S.syncNow(n):await S.syncNow();a.success(i(`status.syncedToast`,{count:e.upserted}))}catch(e){a.error(I(e,i))}finally{u(!1)}}async function E(){if(window.confirm(i(`status.disconnectConfirm`))){f(!0);try{n?await S.disconnect(n):await S.disconnect(),a.success(i(`status.disconnectedToast`)),t()}catch(e){a.error(I(e,i))}finally{f(!1)}}}async function D(e){try{n?await S.retryOutbox(e,n):await S.retryOutbox(e),await w()}catch(e){a.error(I(e,i))}}let O=C.pending+C.inflight;return(0,M.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:i(`status.connected`,{key:o.jiraProjectKey})}),(0,M.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[o.baseUrl,` · `,o.deployment===`cloud`?i(`review.cloud`):i(`review.dc`)]})]}),(0,M.jsx)(`a`,{href:`${o.baseUrl}/browse/${o.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:i(`badge.openInJira`)})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:i(`status.enabledLabel`)}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(s?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,M.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":s,"aria-label":i(`status.enabledLabel`),disabled:d,onClick:te,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${s?`bg-accent-success`:`bg-input`}`,children:(0,M.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${s?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,M.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:i(`wizard.step3Title`)}),(0,M.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:i(`mapping.intro`)}),(0,M.jsx)(`div`,{className:`space-y-2`,children:N.map(e=>(0,M.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`mapping.${ae[e]}`)}),(0,M.jsxs)(`select`,{value:b[e]??``,onChange:t=>void ee(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,M.jsx)(`option`,{value:``,children:i(`mapping.auto`)}),g.map(e=>(0,M.jsx)(`option`,{value:e.name,children:e.name},e.id)),b[e]&&!g.some(t=>t.name===b[e])&&(0,M.jsx)(`option`,{value:b[e],children:b[e]})]})]},e))})]}),(0,M.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:i(`discard.configLabel`)}),(0,M.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:i(`discard.configHelp`)}),(0,M.jsxs)(`select`,{value:v,onChange:e=>void T(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,M.jsx)(`option`,{value:``,children:i(`discard.configNone`)}),g.map(e=>(0,M.jsx)(`option`,{value:e.name,children:e.name},e.id)),v&&!g.some(e=>e.name===v)&&(0,M.jsx)(`option`,{value:v,children:v})]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(h,{variant:`outline`,size:`sm`,onClick:ne,disabled:l,children:i(l?`status.syncing`:`status.syncNow`)}),(0,M.jsx)(h,{variant:`ghost`,size:`sm`,onClick:E,disabled:d,className:`text-destructive`,children:i(`status.disconnect`)})]}),(0,M.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:i(`outbox.title`)}),C.dead>0?(0,M.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:i(`outbox.dead`,{count:C.dead})}):O>0?(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`outbox.pending`,{count:O})}):(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`outbox.allSynced`)}),p.length>0&&(0,M.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`outbox.deadHelp`)}),p.map(e=>(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,M.jsxs)(`span`,{className:`truncate text-xs`,children:[F(e,i),` · `,e.deadReason??e.lastError??``]}),(0,M.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>D(e.id),children:i(`outbox.retry`)})]},e.id))]})]})]})}function F(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function I(e,t){return e instanceof Error?e.message:t(`errors.generic`)}function L(e){return{provider:e,label:e===`codex`?`Codex`:`Claude`,active:!1,available:!1,detectedRoute:!1,requests:0,inputTokens:0,inputTokensSaved:0,outputTokens:0,outputTokensSaved:0,outputSavingsPercent:0,outputSavingsMethod:`none`,outputSavingsAllocated:!1}}function R(){return{updatedAt:null,proxyStatsAvailable:!1,durableSavingsAvailable:!1,outputSavingsAvailable:!1,outputSavingsMethod:null,outputConfidence:null,providers:{codex:L(`codex`),claude:L(`claude`)},lastIssue:null}}var z={installed:!1,installSource:null,version:null,executablePath:null,uvPath:null,port:8787,phase:`idle`,activeProviders:{codex:!1,claude:!1},availableProviders:{codex:!1,claude:!1},detectedRoutes:{codex:!1,claude:!1},proxyRunning:!1,proxyPid:null,learning:{enabled:!1,baselineReady:!1,baselineSamples:0,updatedAt:null,lastIssue:null},metrics:R(),lastIssue:null,updatedAt:null};function B(e){let t=e?.metrics??R();return{...z,...e,activeProviders:{...z.activeProviders,...e?.activeProviders},availableProviders:{...z.availableProviders,...e?.availableProviders},detectedRoutes:{...z.detectedRoutes,...e?.detectedRoutes},learning:{...z.learning,...e?.learning},metrics:{...R(),...t,providers:{codex:{...L(`codex`),...t.providers?.codex},claude:{...L(`claude`),...t.providers?.claude}}}}}async function V(e){let t=await e.text(),n=t?JSON.parse(t):{};if(!e.ok){let t=n.issue;throw Object.assign(Error(t?.title??n.error??`HTTP ${e.status}`),{payload:n})}return n}function H(e){return`${d}/api/projects/${e}`}function U(e,t=`en`){if(!Number.isFinite(e))return`0`;try{return Intl.NumberFormat(t,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}catch{return Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}}function W(e,t,n){return`${U(e,t)} ${n}`}function G(){let{t:e}=r(`integrations`),{projects:t}=m(),{registerHandler:n,unregisterHandler:i}=f(),[a,o]=(0,j.useState)(``),[s,l]=(0,j.useState)(`all`),[u,p]=(0,j.useState)(z),[h,S]=(0,j.useState)(!0),[C,w]=(0,j.useState)(null),[T,E]=(0,j.useState)([]),[O,A]=(0,j.useState)(!1),[ie,N]=(0,j.useState)(!1),[ae,P]=(0,j.useState)(null),[F,I]=(0,j.useState)({jira:0,serena:0,projects:0}),L=(0,j.useCallback)(async()=>{try{let e=await fetch(`${d}/api/global-plugins/headroom`).then(e=>V(e));p(B(e.state))}finally{S(!1)}},[]);(0,j.useEffect)(()=>{L()},[L]),(0,j.useEffect)(()=>(n(`plugins-page`,e=>{let t=e;t.type===`plugin.headroom_progress`&&(t.line&&E(e=>[...e.slice(-80),t.line]),L())}),()=>i(`plugins-page`)),[n,i,L]),(0,j.useEffect)(()=>{let e=!1;async function n(){let n=await Promise.all(t.map(async e=>{let[t,n]=await Promise.all([fetch(`${H(e.id)}/jira/connection`).then(e=>V(e)).catch(()=>({connected:!1})),fetch(`${H(e.id)}/plugins`).then(e=>V(e)).catch(()=>({plugins:[]}))]),r=n.plugins.find(e=>e.name===`serena`);return{jira:+!!t.connected,serena:r&&r.status!==`not-installed`&&r.status!==`orphan`?1:0}}));e||I({jira:n.reduce((e,t)=>e+t.jira,0),serena:n.reduce((e,t)=>e+t.serena,0),projects:t.length})}return n(),()=>{e=!0}},[t]);async function R(e,t){w(e),E([]);try{let e=(await t()).state;e&&p(B(e))}catch(e){let t=e.payload;t?.state&&p(B(t.state))}finally{w(null),L()}}let U=(0,j.useMemo)(()=>[{id:`headroom-ai`,title:`Headroom AI`,scope:`global`,icon:k,description:e(`plugins.catalog.headroom.description`),installed:u.installed,status:u.lastIssue?`attention`:u.installed?u.activeProviders.codex||u.activeProviders.claude?u.installSource===`system`?`external-active`:`active`:u.installSource===`system`?`external`:`installed`:`available`,statusLabel:u.lastIssue?e(`plugins.status.attention`):u.installed?u.activeProviders.codex||u.activeProviders.claude?u.installSource===`system`?e(`plugins.status.externalActive`):e(`plugins.status.active`):u.installSource===`system`?e(`plugins.status.external`):e(`plugins.status.installed`):e(`plugins.status.available`),actionKind:u.lastIssue?`review`:u.installed?`manage`:`install`,actionLabel:u.lastIssue?e(`plugins.actions.review`):u.installed?e(`plugins.actions.manage`):e(`plugins.actions.install`),busy:C===`install`,action:()=>{if(u.lastIssue||u.installed){A(!0);return}R(`install`,()=>fetch(`${d}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>V(e)))}}],[u,C,e]),W=(0,j.useMemo)(()=>[{id:`jira`,title:`Jira`,scope:`project`,icon:re,description:e(`plugins.catalog.jira.description`),installed:F.jira>0,status:F.jira>0?`configured`:`available`,statusLabel:F.jira>0?e(`plugins.status.configuredCount`,{count:F.jira}):e(`plugins.status.available`),actionKind:F.jira>0?`manage`:`install`,actionLabel:F.jira>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>P(`jira`)},{id:`serena`,title:`Serena`,scope:`project`,icon:ne,description:e(`plugins.catalog.serena.description`),installed:F.serena>0,status:F.serena>0?`installed`:`available`,statusLabel:F.serena>0?e(`plugins.status.installedCount`,{count:F.serena}):e(`plugins.status.available`),actionKind:F.serena>0?`manage`:`install`,actionLabel:F.serena>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>P(`serena`)}],[F,e]),G=a.trim().toLowerCase(),K=t=>`${t.title} ${t.description} ${t.statusLabel} ${e(`plugins.scope.${t.scope}`)}`.toLowerCase().includes(G),q=[...U,...W].filter(e=>s!==`all`&&e.scope!==s?!1:K(e)),J=q.filter(e=>e.scope===`global`&&e.installed),Y=q.filter(e=>e.scope===`project`&&e.installed),X=q.filter(e=>e.scope===`global`&&!e.installed),Z=q.filter(e=>e.scope===`project`&&!e.installed),Q=J.length>0||Y.length>0,le=X.length>0||Z.length>0,$=[u.installed,F.jira>0,F.serena>0].filter(Boolean).length;return(0,M.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[(0,M.jsxs)(`div`,{className:`border-b border-border px-6 py-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,M.jsx)(`div`,{className:`grid h-9 w-9 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,M.jsx)(D,{className:`h-4 w-4`})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`h1`,{className:`text-lg font-semibold tracking-normal`,children:e(`plugins.page.title`)}),(0,M.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e(`plugins.page.subtitle`)})]}),(0,M.jsxs)(`div`,{className:`mr-12 flex items-center gap-2 rounded-lg border border-border bg-card/60 px-3 py-2 text-xs`,children:[(0,M.jsx)(te,{className:`h-3.5 w-3.5 text-accent-success`}),(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:e(`plugins.page.readyCount`,{count:$})})]})]}),(0,M.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 md:flex-row md:items-center`,children:[(0,M.jsxs)(`label`,{className:`relative flex-1`,children:[(0,M.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,M.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:e(`plugins.search.placeholder`),className:`h-9 w-full rounded-lg border border-border bg-background pl-9 pr-3 text-sm outline-none transition-colors focus:border-accent-primary/60`})]}),(0,M.jsx)(`div`,{className:`inline-flex h-9 rounded-lg border border-border bg-card p-1`,children:[`all`,`global`,`project`].map(t=>(0,M.jsx)(`button`,{type:`button`,onClick:()=>l(t),className:g(`rounded-md px-3 text-xs capitalize transition-colors`,s===t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:e(`plugins.filters.${t}`)},t))})]})]}),(0,M.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-5`,children:[(0,M.jsxs)(`section`,{className:`mb-6`,children:[(0,M.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,M.jsx)(ee,{className:`h-3.5 w-3.5`}),e(`plugins.sections.installed`)]}),Q?(0,M.jsx)(oe,{globalPlugins:J,projectPlugins:Y}):(0,M.jsx)(se,{text:e(G?`plugins.empty.installedSearch`:`plugins.empty.installed`)})]}),(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,M.jsx)(D,{className:`h-3.5 w-3.5`}),e(`plugins.sections.available`)]}),le?(0,M.jsx)(oe,{globalPlugins:X,projectPlugins:Z}):(0,M.jsx)(se,{text:e(G?`plugins.empty.availableSearch`:`plugins.empty.allInstalled`)})]})]}),(0,M.jsx)(x,{open:O,onOpenChange:A,children:(0,M.jsxs)(v,{className:`w-[calc(100vw-2rem)] max-w-xl overflow-x-hidden p-4 sm:p-6`,children:[(0,M.jsxs)(_,{children:[(0,M.jsx)(y,{children:e(`plugins.headroom.title`)}),(0,M.jsx)(b,{children:e(`plugins.headroom.dialogDescription`)})]}),(0,M.jsx)(ce,{state:u,loading:h,busy:C,logs:T,onInstall:()=>R(`install`,()=>fetch(`${d}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>V(e))),onToggleProvider:(e,t)=>R(`${t?`deactivate`:`activate`}-${e}`,()=>fetch(`${d}/api/global-plugins/headroom/${t?`deactivate`:`activate`}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).then(e=>V(e))),onDeactivateAll:()=>R(`deactivate-all`,async()=>{let e={state:u};for(let t of[`codex`,`claude`])u.activeProviders[t]&&(e=await fetch(`${d}/api/global-plugins/headroom/deactivate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:t})}).then(e=>V(e)));return e}),onUninstall:()=>R(`uninstall`,()=>fetch(`${d}/api/global-plugins/headroom/uninstall`,{method:`POST`}).then(e=>V(e))),onSetPort:e=>R(`port`,()=>fetch(`${d}/api/global-plugins/headroom/port`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({port:e})}).then(e=>V(e))),onOpenDiagnostics:()=>N(!0)})]})}),(0,M.jsx)(ue,{plugin:ae,projects:t,onClose:()=>P(null)}),(0,M.jsx)(pe,{open:ie,onClose:()=>N(!1)})]})}function oe({globalPlugins:e,projectPlugins:t}){let{t:n}=r(`integrations`);return(0,M.jsxs)(`div`,{className:g(`grid grid-cols-1 gap-4`,e.length>0&&t.length>0&&`xl:grid-cols-2`),children:[e.length>0&&(0,M.jsxs)(`section`,{children:[(0,M.jsx)(q,{title:n(`plugins.groups.global.title`),detail:n(`plugins.groups.global.detail`),scope:`global`}),(0,M.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:e.map(e=>(0,M.jsx)(J,{plugin:e},e.id))})]}),t.length>0&&(0,M.jsxs)(`section`,{children:[(0,M.jsx)(q,{title:n(`plugins.groups.project.title`),detail:n(`plugins.groups.project.detail`),scope:`project`}),(0,M.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:t.map(e=>(0,M.jsx)(J,{plugin:e},e.id))})]})]})}function se({text:e}){return(0,M.jsx)(`div`,{className:`flex h-[74px] max-w-[320px] items-center rounded-lg border border-dashed border-border bg-card/35 px-3 text-xs text-muted-foreground`,children:e})}function K({scope:e}){let{t}=r(`integrations`);return(0,M.jsx)(`span`,{className:g(`rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wide`,e===`global`?`bg-accent-primary/10 text-accent-primary`:`bg-accent-info/10 text-accent-info`),children:t(`plugins.scope.${e}`)})}function q({title:e,detail:t,scope:n}){return(0,M.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,M.jsx)(`div`,{className:g(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card/70 px-2 py-1`,children:[(0,M.jsx)(K,{scope:n}),(0,M.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,M.jsx)(`span`,{className:`hidden text-[11px] text-muted-foreground sm:inline`,children:t})]}),(0,M.jsx)(`div`,{className:g(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)})]})}function J({plugin:e}){let{t}=r(`integrations`),n=e.icon,i=e.scope===`global`,a=e.status===`attention`,c=e.busy?s:e.actionKind===`install`?o:e.actionKind===`review`?u:C,l=g(`shrink-0 rounded border px-1.5 py-0.5 text-[10px] leading-none`,a?`border-accent-warning/30 bg-accent-warning/10 text-accent-warning`:e.installed?`border-accent-success/25 bg-accent-success/10 text-accent-success`:`border-border bg-muted text-muted-foreground`);return(0,M.jsxs)(`article`,{className:`grid h-[88px] w-full grid-cols-[38px_minmax(0,1fr)_auto] items-center gap-3 rounded-lg border border-border bg-card/70 px-3 transition-colors hover:border-accent-primary/35 hover:bg-card`,children:[(0,M.jsx)(`div`,{className:g(`grid h-[38px] w-[38px] shrink-0 place-items-center rounded-lg border`,i?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-accent-info/25 bg-accent-info/10 text-accent-info`),children:(0,M.jsx)(n,{className:`h-4 w-4`})}),(0,M.jsxs)(`div`,{className:`min-w-0`,children:[(0,M.jsx)(`h2`,{className:`truncate text-sm font-semibold leading-5`,children:e.title}),(0,M.jsx)(`p`,{className:`mt-1 truncate text-[11px] leading-4 text-muted-foreground`,children:e.description}),(0,M.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,M.jsx)(K,{scope:e.scope}),(0,M.jsx)(`span`,{className:l,children:e.statusLabel})]})]}),(0,M.jsxs)(`button`,{type:`button`,disabled:e.busy,onClick:e.action,className:`flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-xs font-medium transition-colors hover:bg-muted disabled:opacity-50`,children:[(0,M.jsx)(c,{className:g(`h-3.5 w-3.5`,e.busy&&`animate-spin`)}),e.busy?t(`plugins.actions.installing`):e.actionLabel]})]})}function ce({state:e,loading:t,busy:n,logs:i,onInstall:a,onToggleProvider:c,onDeactivateAll:u,onUninstall:d,onSetPort:f,onOpenDiagnostics:p}){let{t:m}=r(`integrations`),[h,g]=(0,j.useState)(String(e.port)),[_,v]=(0,j.useState)(!1);(0,j.useEffect)(()=>g(String(e.port)),[e.port]),(0,j.useEffect)(()=>{e.installed||v(!1)},[e.installed]);let y=e.activeProviders.codex||e.activeProviders.claude,b=e.installSource===`system`;return(0,M.jsxs)(`aside`,{className:`w-full min-w-0 overflow-hidden rounded-lg border border-border bg-card/80 p-4`,children:[(0,M.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,M.jsx)(`div`,{className:`grid h-10 w-10 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,M.jsx)(k,{className:`h-4 w-4`})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold`,children:m(`plugins.headroom.title`)}),(0,M.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:m(`plugins.headroom.panelDescription`)})]})]}),(0,M.jsxs)(`div`,{className:`mb-4 grid grid-cols-3 gap-2 text-xs`,children:[(0,M.jsx)(Y,{label:m(`plugins.headroom.metrics.install`),value:t?m(`plugins.headroom.metrics.checking`):e.installed?m(`plugins.headroom.metrics.ready`):m(`plugins.headroom.metrics.missing`),good:e.installed}),(0,M.jsx)(Y,{label:m(`plugins.headroom.metrics.source`),value:e.installSource===`system`?m(`plugins.headroom.metrics.system`):e.installSource===`managed`?m(`plugins.headroom.metrics.specrails`):m(`plugins.headroom.metrics.none`),good:e.installed}),(0,M.jsx)(Y,{label:m(`plugins.headroom.metrics.proxy`),value:e.proxyRunning?`:${e.port}`:m(y?`plugins.headroom.metrics.starting`:`plugins.headroom.metrics.off`),good:e.proxyRunning||!y})]}),e.lastIssue&&(0,M.jsx)(X,{issue:e.lastIssue}),e.installed?(0,M.jsxs)(`div`,{className:`mb-4 space-y-2`,children:[(0,M.jsx)($,{provider:`codex`,active:e.activeProviders.codex,available:e.availableProviders.codex,detectedRoute:e.detectedRoutes.codex,busy:n===`activate-codex`||n===`deactivate-codex`,onClick:()=>c(`codex`,e.activeProviders.codex)}),(0,M.jsx)($,{provider:`claude`,active:e.activeProviders.claude,available:e.availableProviders.claude,detectedRoute:e.detectedRoutes.claude,busy:n===`activate-claude`||n===`deactivate-claude`,onClick:()=>c(`claude`,e.activeProviders.claude)}),y&&(0,M.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:u,className:`flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border bg-background/45 text-xs hover:bg-muted/50 disabled:opacity-50`,children:[n===`deactivate-all`?(0,M.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(A,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.disableAllRoutes`)]})]}):(0,M.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:a,className:`mb-3 flex h-9 w-full items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 text-xs font-medium text-white disabled:opacity-50`,children:[n===`install`?(0,M.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(o,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.installWithUv`)]}),e.installed&&(0,M.jsx)(Z,{state:e}),(0,M.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,M.jsx)(`label`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:m(`plugins.headroom.port.label`)}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),className:`h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-sm`}),(0,M.jsx)(`button`,{type:`button`,disabled:!!n||Number(h)===e.port,onClick:()=>f(Number(h)),className:`rounded-md border border-border px-2 text-xs hover:bg-muted disabled:opacity-50`,children:m(`plugins.headroom.port.apply`)})]})]}),i.length>0&&(0,M.jsx)(`pre`,{className:`mb-3 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background/60 p-2 text-[10px] text-muted-foreground`,children:i.join(`
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r,t as i}from"./createLucideIcon-Bjbbp_KS.js";import{n as a}from"./dist-bVqfYmby.js";import{t as o}from"./download-CFHyyHcw.js";import{t as s}from"./loader-circle-DcygOQpC.js";import{t as c}from"./search-Cq_gE3Ik.js";import{t as l}from"./trash-2-BOU3WdZZ.js";import{t as u}from"./triangle-alert-H9T4jAmh.js";import{a as d}from"./auth-D_5bQv5W.js";import{n as f}from"./useSharedWebSocket-DaPh7QBL.js";import{n as p,r as m}from"./useDesktop-B4pSBIDd.js";import{t as h}from"./button-BUIIBQPT.js";import{t as g}from"./utils-BC4DHlz2.js";import{a as _,n as v,o as y,r as b,t as x}from"./dialog-CzIekCw0.js";import{t as S}from"./jira-api-BgFIr8eD.js";import{at as C,jt as w,kt as T,nt as ee,rt as te,tt as ne,u as E,ut as D}from"./index-xkzK3E5i.js";var O=i(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),re=i(`folder-kanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),k=i(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),A=i(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),ie=i(`wrench`,[[`path`,{d:`M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z`,key:`1ngwbx`}]]),j=e(t(),1),M=n(),N=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],ae={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function P({state:e,onChanged:t,apiBase:n}){let{t:i}=r(`jira`),o=e.connection,[s,c]=(0,j.useState)(o.enabled),[l,u]=(0,j.useState)(!1),[d,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)([]),[g,_]=(0,j.useState)([]),[v,y]=(0,j.useState)(o.discardStatus??``),[b,x]=(0,j.useState)(o.statusMap??{}),C=e.outbox??{pending:0,inflight:0,done:0,dead:0},w=(0,j.useCallback)(async()=>{try{let{ops:e}=n?await S.listOutbox(`dead`,n):await S.listOutbox(`dead`);m(e)}catch{m([])}},[n]);(0,j.useEffect)(()=>{w()},[w]),(0,j.useEffect)(()=>{let e=!1;return S.listStatuses(n).then(({statuses:t})=>{e||_(t)}).catch(()=>{e||_([])}),()=>{e=!0}},[n]);async function T(e){let r=v;y(e);try{n?await S.patchConnection({discardStatus:e||null},n):await S.patchConnection({discardStatus:e||null}),t()}catch(e){y(r),a.error(I(e,i))}}async function ee(e,r){let o=b,s={...b,[e]:r||void 0};x(s);let c=Object.fromEntries(Object.entries(s).filter(([,e])=>e));try{n?await S.patchConnection({statusMap:Object.keys(c).length?c:null},n):await S.patchConnection({statusMap:Object.keys(c).length?c:null}),t()}catch(e){x(o),a.error(I(e,i))}}async function te(){let e=!s;c(e),f(!0);try{n?await S.setEnabled(e,n):await S.setEnabled(e)}catch(t){c(!e),a.error(I(t,i))}finally{f(!1)}}async function ne(){u(!0);try{let e=n?await S.syncNow(n):await S.syncNow();a.success(i(`status.syncedToast`,{count:e.upserted}))}catch(e){a.error(I(e,i))}finally{u(!1)}}async function E(){if(window.confirm(i(`status.disconnectConfirm`))){f(!0);try{n?await S.disconnect(n):await S.disconnect(),a.success(i(`status.disconnectedToast`)),t()}catch(e){a.error(I(e,i))}finally{f(!1)}}}async function D(e){try{n?await S.retryOutbox(e,n):await S.retryOutbox(e),await w()}catch(e){a.error(I(e,i))}}let O=C.pending+C.inflight;return(0,M.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:i(`status.connected`,{key:o.jiraProjectKey})}),(0,M.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[o.baseUrl,` · `,o.deployment===`cloud`?i(`review.cloud`):i(`review.dc`)]})]}),(0,M.jsx)(`a`,{href:`${o.baseUrl}/browse/${o.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:i(`badge.openInJira`)})]}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:i(`status.enabledLabel`)}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(s?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,M.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":s,"aria-label":i(`status.enabledLabel`),disabled:d,onClick:te,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${s?`bg-accent-success`:`bg-input`}`,children:(0,M.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${s?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,M.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:i(`wizard.step3Title`)}),(0,M.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:i(`mapping.intro`)}),(0,M.jsx)(`div`,{className:`space-y-2`,children:N.map(e=>(0,M.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,M.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`mapping.${ae[e]}`)}),(0,M.jsxs)(`select`,{value:b[e]??``,onChange:t=>void ee(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,M.jsx)(`option`,{value:``,children:i(`mapping.auto`)}),g.map(e=>(0,M.jsx)(`option`,{value:e.name,children:e.name},e.id)),b[e]&&!g.some(t=>t.name===b[e])&&(0,M.jsx)(`option`,{value:b[e],children:b[e]})]})]},e))})]}),(0,M.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:i(`discard.configLabel`)}),(0,M.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:i(`discard.configHelp`)}),(0,M.jsxs)(`select`,{value:v,onChange:e=>void T(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,M.jsx)(`option`,{value:``,children:i(`discard.configNone`)}),g.map(e=>(0,M.jsx)(`option`,{value:e.name,children:e.name},e.id)),v&&!g.some(e=>e.name===v)&&(0,M.jsx)(`option`,{value:v,children:v})]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(h,{variant:`outline`,size:`sm`,onClick:ne,disabled:l,children:i(l?`status.syncing`:`status.syncNow`)}),(0,M.jsx)(h,{variant:`ghost`,size:`sm`,onClick:E,disabled:d,className:`text-destructive`,children:i(`status.disconnect`)})]}),(0,M.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium`,children:i(`outbox.title`)}),C.dead>0?(0,M.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:i(`outbox.dead`,{count:C.dead})}):O>0?(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`outbox.pending`,{count:O})}):(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:i(`outbox.allSynced`)}),p.length>0&&(0,M.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i(`outbox.deadHelp`)}),p.map(e=>(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,M.jsxs)(`span`,{className:`truncate text-xs`,children:[F(e,i),` · `,e.deadReason??e.lastError??``]}),(0,M.jsx)(h,{variant:`outline`,size:`sm`,onClick:()=>D(e.id),children:i(`outbox.retry`)})]},e.id))]})]})]})}function F(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function I(e,t){return e instanceof Error?e.message:t(`errors.generic`)}function L(e){return{provider:e,label:e===`codex`?`Codex`:`Claude`,active:!1,available:!1,detectedRoute:!1,requests:0,inputTokens:0,inputTokensSaved:0,outputTokens:0,outputTokensSaved:0,outputSavingsPercent:0,outputSavingsMethod:`none`,outputSavingsAllocated:!1}}function R(){return{updatedAt:null,proxyStatsAvailable:!1,durableSavingsAvailable:!1,outputSavingsAvailable:!1,outputSavingsMethod:null,outputConfidence:null,providers:{codex:L(`codex`),claude:L(`claude`)},lastIssue:null}}var z={installed:!1,installSource:null,version:null,executablePath:null,uvPath:null,port:8787,phase:`idle`,activeProviders:{codex:!1,claude:!1},availableProviders:{codex:!1,claude:!1},detectedRoutes:{codex:!1,claude:!1},proxyRunning:!1,proxyPid:null,learning:{enabled:!1,baselineReady:!1,baselineSamples:0,updatedAt:null,lastIssue:null},metrics:R(),lastIssue:null,updatedAt:null};function B(e){let t=e?.metrics??R();return{...z,...e,activeProviders:{...z.activeProviders,...e?.activeProviders},availableProviders:{...z.availableProviders,...e?.availableProviders},detectedRoutes:{...z.detectedRoutes,...e?.detectedRoutes},learning:{...z.learning,...e?.learning},metrics:{...R(),...t,providers:{codex:{...L(`codex`),...t.providers?.codex},claude:{...L(`claude`),...t.providers?.claude}}}}}async function V(e){let t=await e.text(),n=t?JSON.parse(t):{};if(!e.ok){let t=n.issue;throw Object.assign(Error(t?.title??n.error??`HTTP ${e.status}`),{payload:n})}return n}function H(e){return`${d}/api/projects/${e}`}function U(e,t=`en`){if(!Number.isFinite(e))return`0`;try{return Intl.NumberFormat(t,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}catch{return Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}}function W(e,t,n){return`${U(e,t)} ${n}`}function G(){let{t:e}=r(`integrations`),{projects:t}=m(),{registerHandler:n,unregisterHandler:i}=f(),[a,o]=(0,j.useState)(``),[s,l]=(0,j.useState)(`all`),[u,p]=(0,j.useState)(z),[h,S]=(0,j.useState)(!0),[C,w]=(0,j.useState)(null),[T,E]=(0,j.useState)([]),[O,A]=(0,j.useState)(!1),[ie,N]=(0,j.useState)(!1),[ae,P]=(0,j.useState)(null),[F,I]=(0,j.useState)({jira:0,serena:0,projects:0}),L=(0,j.useCallback)(async()=>{try{let e=await fetch(`${d}/api/global-plugins/headroom`).then(e=>V(e));p(B(e.state))}finally{S(!1)}},[]);(0,j.useEffect)(()=>{L()},[L]),(0,j.useEffect)(()=>(n(`plugins-page`,e=>{let t=e;t.type===`plugin.headroom_progress`&&(t.line&&E(e=>[...e.slice(-80),t.line]),L())}),()=>i(`plugins-page`)),[n,i,L]),(0,j.useEffect)(()=>{let e=!1;async function n(){let n=await Promise.all(t.map(async e=>{let[t,n]=await Promise.all([fetch(`${H(e.id)}/jira/connection`).then(e=>V(e)).catch(()=>({connected:!1})),fetch(`${H(e.id)}/plugins`).then(e=>V(e)).catch(()=>({plugins:[]}))]),r=n.plugins.find(e=>e.name===`serena`);return{jira:+!!t.connected,serena:r&&r.status!==`not-installed`&&r.status!==`orphan`?1:0}}));e||I({jira:n.reduce((e,t)=>e+t.jira,0),serena:n.reduce((e,t)=>e+t.serena,0),projects:t.length})}return n(),()=>{e=!0}},[t]);async function R(e,t){w(e),E([]);try{let e=(await t()).state;e&&p(B(e))}catch(e){let t=e.payload;t?.state&&p(B(t.state))}finally{w(null),L()}}let U=(0,j.useMemo)(()=>[{id:`headroom-ai`,title:`Headroom AI`,scope:`global`,icon:k,description:e(`plugins.catalog.headroom.description`),installed:u.installed,status:u.lastIssue?`attention`:u.installed?u.activeProviders.codex||u.activeProviders.claude?u.installSource===`system`?`external-active`:`active`:u.installSource===`system`?`external`:`installed`:`available`,statusLabel:u.lastIssue?e(`plugins.status.attention`):u.installed?u.activeProviders.codex||u.activeProviders.claude?u.installSource===`system`?e(`plugins.status.externalActive`):e(`plugins.status.active`):u.installSource===`system`?e(`plugins.status.external`):e(`plugins.status.installed`):e(`plugins.status.available`),actionKind:u.lastIssue?`review`:u.installed?`manage`:`install`,actionLabel:u.lastIssue?e(`plugins.actions.review`):u.installed?e(`plugins.actions.manage`):e(`plugins.actions.install`),busy:C===`install`,action:()=>{if(u.lastIssue||u.installed){A(!0);return}R(`install`,()=>fetch(`${d}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>V(e)))}}],[u,C,e]),W=(0,j.useMemo)(()=>[{id:`jira`,title:`Jira`,scope:`project`,icon:re,description:e(`plugins.catalog.jira.description`),installed:F.jira>0,status:F.jira>0?`configured`:`available`,statusLabel:F.jira>0?e(`plugins.status.configuredCount`,{count:F.jira}):e(`plugins.status.available`),actionKind:F.jira>0?`manage`:`install`,actionLabel:F.jira>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>P(`jira`)},{id:`serena`,title:`Serena`,scope:`project`,icon:ne,description:e(`plugins.catalog.serena.description`),installed:F.serena>0,status:F.serena>0?`installed`:`available`,statusLabel:F.serena>0?e(`plugins.status.installedCount`,{count:F.serena}):e(`plugins.status.available`),actionKind:F.serena>0?`manage`:`install`,actionLabel:F.serena>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>P(`serena`)}],[F,e]),G=a.trim().toLowerCase(),K=t=>`${t.title} ${t.description} ${t.statusLabel} ${e(`plugins.scope.${t.scope}`)}`.toLowerCase().includes(G),q=[...U,...W].filter(e=>s!==`all`&&e.scope!==s?!1:K(e)),J=q.filter(e=>e.scope===`global`&&e.installed),Y=q.filter(e=>e.scope===`project`&&e.installed),X=q.filter(e=>e.scope===`global`&&!e.installed),Z=q.filter(e=>e.scope===`project`&&!e.installed),Q=J.length>0||Y.length>0,le=X.length>0||Z.length>0,$=[u.installed,F.jira>0,F.serena>0].filter(Boolean).length;return(0,M.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[(0,M.jsxs)(`div`,{className:`border-b border-border px-6 py-4`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,M.jsx)(`div`,{className:`grid h-9 w-9 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,M.jsx)(D,{className:`h-4 w-4`})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`h1`,{className:`text-lg font-semibold tracking-normal`,children:e(`plugins.page.title`)}),(0,M.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e(`plugins.page.subtitle`)})]}),(0,M.jsxs)(`div`,{className:`mr-12 flex items-center gap-2 rounded-lg border border-border bg-card/60 px-3 py-2 text-xs`,children:[(0,M.jsx)(te,{className:`h-3.5 w-3.5 text-accent-success`}),(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:e(`plugins.page.readyCount`,{count:$})})]})]}),(0,M.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 md:flex-row md:items-center`,children:[(0,M.jsxs)(`label`,{className:`relative flex-1`,children:[(0,M.jsx)(c,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,M.jsx)(`input`,{value:a,onChange:e=>o(e.target.value),placeholder:e(`plugins.search.placeholder`),className:`h-9 w-full rounded-lg border border-border bg-background pl-9 pr-3 text-sm outline-none transition-colors focus:border-accent-primary/60`})]}),(0,M.jsx)(`div`,{className:`inline-flex h-9 rounded-lg border border-border bg-card p-1`,children:[`all`,`global`,`project`].map(t=>(0,M.jsx)(`button`,{type:`button`,onClick:()=>l(t),className:g(`rounded-md px-3 text-xs capitalize transition-colors`,s===t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:e(`plugins.filters.${t}`)},t))})]})]}),(0,M.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-5`,children:[(0,M.jsxs)(`section`,{className:`mb-6`,children:[(0,M.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,M.jsx)(ee,{className:`h-3.5 w-3.5`}),e(`plugins.sections.installed`)]}),Q?(0,M.jsx)(oe,{globalPlugins:J,projectPlugins:Y}):(0,M.jsx)(se,{text:e(G?`plugins.empty.installedSearch`:`plugins.empty.installed`)})]}),(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,M.jsx)(D,{className:`h-3.5 w-3.5`}),e(`plugins.sections.available`)]}),le?(0,M.jsx)(oe,{globalPlugins:X,projectPlugins:Z}):(0,M.jsx)(se,{text:e(G?`plugins.empty.availableSearch`:`plugins.empty.allInstalled`)})]})]}),(0,M.jsx)(x,{open:O,onOpenChange:A,children:(0,M.jsxs)(v,{className:`w-[calc(100vw-2rem)] max-w-xl overflow-x-hidden p-4 sm:p-6`,children:[(0,M.jsxs)(_,{children:[(0,M.jsx)(y,{children:e(`plugins.headroom.title`)}),(0,M.jsx)(b,{children:e(`plugins.headroom.dialogDescription`)})]}),(0,M.jsx)(ce,{state:u,loading:h,busy:C,logs:T,onInstall:()=>R(`install`,()=>fetch(`${d}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>V(e))),onToggleProvider:(e,t)=>R(`${t?`deactivate`:`activate`}-${e}`,()=>fetch(`${d}/api/global-plugins/headroom/${t?`deactivate`:`activate`}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).then(e=>V(e))),onDeactivateAll:()=>R(`deactivate-all`,async()=>{let e={state:u};for(let t of[`codex`,`claude`])u.activeProviders[t]&&(e=await fetch(`${d}/api/global-plugins/headroom/deactivate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:t})}).then(e=>V(e)));return e}),onUninstall:()=>R(`uninstall`,()=>fetch(`${d}/api/global-plugins/headroom/uninstall`,{method:`POST`}).then(e=>V(e))),onSetPort:e=>R(`port`,()=>fetch(`${d}/api/global-plugins/headroom/port`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({port:e})}).then(e=>V(e))),onOpenDiagnostics:()=>N(!0)})]})}),(0,M.jsx)(ue,{plugin:ae,projects:t,onClose:()=>P(null)}),(0,M.jsx)(pe,{open:ie,onClose:()=>N(!1)})]})}function oe({globalPlugins:e,projectPlugins:t}){let{t:n}=r(`integrations`);return(0,M.jsxs)(`div`,{className:g(`grid grid-cols-1 gap-4`,e.length>0&&t.length>0&&`xl:grid-cols-2`),children:[e.length>0&&(0,M.jsxs)(`section`,{children:[(0,M.jsx)(q,{title:n(`plugins.groups.global.title`),detail:n(`plugins.groups.global.detail`),scope:`global`}),(0,M.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:e.map(e=>(0,M.jsx)(J,{plugin:e},e.id))})]}),t.length>0&&(0,M.jsxs)(`section`,{children:[(0,M.jsx)(q,{title:n(`plugins.groups.project.title`),detail:n(`plugins.groups.project.detail`),scope:`project`}),(0,M.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:t.map(e=>(0,M.jsx)(J,{plugin:e},e.id))})]})]})}function se({text:e}){return(0,M.jsx)(`div`,{className:`flex h-[74px] max-w-[320px] items-center rounded-lg border border-dashed border-border bg-card/35 px-3 text-xs text-muted-foreground`,children:e})}function K({scope:e}){let{t}=r(`integrations`);return(0,M.jsx)(`span`,{className:g(`rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wide`,e===`global`?`bg-accent-primary/10 text-accent-primary`:`bg-accent-info/10 text-accent-info`),children:t(`plugins.scope.${e}`)})}function q({title:e,detail:t,scope:n}){return(0,M.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,M.jsx)(`div`,{className:g(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card/70 px-2 py-1`,children:[(0,M.jsx)(K,{scope:n}),(0,M.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,M.jsx)(`span`,{className:`hidden text-[11px] text-muted-foreground sm:inline`,children:t})]}),(0,M.jsx)(`div`,{className:g(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)})]})}function J({plugin:e}){let{t}=r(`integrations`),n=e.icon,i=e.scope===`global`,a=e.status===`attention`,c=e.busy?s:e.actionKind===`install`?o:e.actionKind===`review`?u:C,l=g(`shrink-0 rounded border px-1.5 py-0.5 text-[10px] leading-none`,a?`border-accent-warning/30 bg-accent-warning/10 text-accent-warning`:e.installed?`border-accent-success/25 bg-accent-success/10 text-accent-success`:`border-border bg-muted text-muted-foreground`);return(0,M.jsxs)(`article`,{className:`grid h-[88px] w-full grid-cols-[38px_minmax(0,1fr)_auto] items-center gap-3 rounded-lg border border-border bg-card/70 px-3 transition-colors hover:border-accent-primary/35 hover:bg-card`,children:[(0,M.jsx)(`div`,{className:g(`grid h-[38px] w-[38px] shrink-0 place-items-center rounded-lg border`,i?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-accent-info/25 bg-accent-info/10 text-accent-info`),children:(0,M.jsx)(n,{className:`h-4 w-4`})}),(0,M.jsxs)(`div`,{className:`min-w-0`,children:[(0,M.jsx)(`h2`,{className:`truncate text-sm font-semibold leading-5`,children:e.title}),(0,M.jsx)(`p`,{className:`mt-1 truncate text-[11px] leading-4 text-muted-foreground`,children:e.description}),(0,M.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,M.jsx)(K,{scope:e.scope}),(0,M.jsx)(`span`,{className:l,children:e.statusLabel})]})]}),(0,M.jsxs)(`button`,{type:`button`,disabled:e.busy,onClick:e.action,className:`flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-xs font-medium transition-colors hover:bg-muted disabled:opacity-50`,children:[(0,M.jsx)(c,{className:g(`h-3.5 w-3.5`,e.busy&&`animate-spin`)}),e.busy?t(`plugins.actions.installing`):e.actionLabel]})]})}function ce({state:e,loading:t,busy:n,logs:i,onInstall:a,onToggleProvider:c,onDeactivateAll:u,onUninstall:d,onSetPort:f,onOpenDiagnostics:p}){let{t:m}=r(`integrations`),[h,g]=(0,j.useState)(String(e.port)),[_,v]=(0,j.useState)(!1);(0,j.useEffect)(()=>g(String(e.port)),[e.port]),(0,j.useEffect)(()=>{e.installed||v(!1)},[e.installed]);let y=e.activeProviders.codex||e.activeProviders.claude,b=e.installSource===`system`;return(0,M.jsxs)(`aside`,{className:`w-full min-w-0 overflow-hidden rounded-lg border border-border bg-card/80 p-4`,children:[(0,M.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,M.jsx)(`div`,{className:`grid h-10 w-10 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,M.jsx)(k,{className:`h-4 w-4`})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold`,children:m(`plugins.headroom.title`)}),(0,M.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:m(`plugins.headroom.panelDescription`)})]})]}),(0,M.jsxs)(`div`,{className:`mb-4 grid grid-cols-3 gap-2 text-xs`,children:[(0,M.jsx)(Y,{label:m(`plugins.headroom.metrics.install`),value:t?m(`plugins.headroom.metrics.checking`):e.installed?m(`plugins.headroom.metrics.ready`):m(`plugins.headroom.metrics.missing`),good:e.installed}),(0,M.jsx)(Y,{label:m(`plugins.headroom.metrics.source`),value:e.installSource===`system`?m(`plugins.headroom.metrics.system`):e.installSource===`managed`?m(`plugins.headroom.metrics.specrails`):m(`plugins.headroom.metrics.none`),good:e.installed}),(0,M.jsx)(Y,{label:m(`plugins.headroom.metrics.proxy`),value:e.proxyRunning?`:${e.port}`:m(y?`plugins.headroom.metrics.starting`:`plugins.headroom.metrics.off`),good:e.proxyRunning||!y})]}),e.lastIssue&&(0,M.jsx)(X,{issue:e.lastIssue}),e.installed?(0,M.jsxs)(`div`,{className:`mb-4 space-y-2`,children:[(0,M.jsx)($,{provider:`codex`,active:e.activeProviders.codex,available:e.availableProviders.codex,detectedRoute:e.detectedRoutes.codex,busy:n===`activate-codex`||n===`deactivate-codex`,onClick:()=>c(`codex`,e.activeProviders.codex)}),(0,M.jsx)($,{provider:`claude`,active:e.activeProviders.claude,available:e.availableProviders.claude,detectedRoute:e.detectedRoutes.claude,busy:n===`activate-claude`||n===`deactivate-claude`,onClick:()=>c(`claude`,e.activeProviders.claude)}),y&&(0,M.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:u,className:`flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border bg-background/45 text-xs hover:bg-muted/50 disabled:opacity-50`,children:[n===`deactivate-all`?(0,M.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(A,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.disableAllRoutes`)]})]}):(0,M.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:a,className:`mb-3 flex h-9 w-full items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 text-xs font-medium text-white disabled:opacity-50`,children:[n===`install`?(0,M.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(o,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.installWithUv`)]}),e.installed&&(0,M.jsx)(Z,{state:e}),(0,M.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,M.jsx)(`label`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:m(`plugins.headroom.port.label`)}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),className:`h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-sm`}),(0,M.jsx)(`button`,{type:`button`,disabled:!!n||Number(h)===e.port,onClick:()=>f(Number(h)),className:`rounded-md border border-border px-2 text-xs hover:bg-muted disabled:opacity-50`,children:m(`plugins.headroom.port.apply`)})]})]}),i.length>0&&(0,M.jsx)(`pre`,{className:`mb-3 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background/60 p-2 text-[10px] text-muted-foreground`,children:i.join(`
|
|
2
2
|
`)}),(0,M.jsxs)(`button`,{type:`button`,onClick:p,className:`mb-2 flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border text-xs hover:bg-muted/50`,children:[(0,M.jsx)(ie,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.viewDiagnostics`)]}),e.installed&&(0,M.jsx)(`div`,{className:`rounded-lg border border-destructive/25 bg-destructive/5 p-3`,children:_?(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:m(b?`plugins.headroom.confirmDetach`:`plugins.headroom.confirmUninstall`)}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,disabled:!!n,onClick:()=>v(!1),className:`h-8 rounded-md border border-border text-xs hover:bg-muted/50 disabled:opacity-50`,children:m(`plugins.actions.cancel`)}),(0,M.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:d,className:`flex h-8 items-center justify-center gap-2 rounded-md bg-destructive px-2 text-xs font-medium text-destructive-foreground disabled:opacity-50`,children:[n===`uninstall`?(0,M.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(l,{className:`h-3.5 w-3.5`}),m(b?`plugins.headroom.actions.detach`:`plugins.headroom.actions.uninstall`)]})]})]}):(0,M.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:()=>v(!0),className:`flex h-8 w-full items-center justify-center gap-2 rounded-md text-xs font-medium text-destructive hover:bg-destructive/10 disabled:opacity-50`,children:[(0,M.jsx)(l,{className:`h-3.5 w-3.5`}),m(b?`plugins.headroom.actions.detachHeadroom`:`plugins.headroom.actions.uninstallHeadroom`)]})})]})}function Y({label:e,value:t,good:n}){return(0,M.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-2`,children:[(0,M.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e}),(0,M.jsx)(`div`,{className:g(`mt-0.5 font-medium`,n?`text-foreground`:`text-accent-warning`),children:t})]})}function X({issue:e}){let{t}=r(`integrations`),n=`plugins.headroom.issues.${e.code}`,i=t(`${n}.title`,{defaultValue:e.title}),a=t(`${n}.guidance`,{defaultValue:e.guidance});return(0,M.jsx)(`div`,{className:`mb-3 rounded-lg border border-accent-warning/35 bg-accent-warning/10 p-3`,children:(0,M.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,M.jsx)(u,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-warning`}),(0,M.jsxs)(`div`,{className:`min-w-0`,children:[(0,M.jsx)(`div`,{className:`text-xs font-medium`,children:i}),(0,M.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:a}),(0,M.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:t(`plugins.headroom.issueCode`,{code:e.code})})]})]})})}function Z({state:e}){let{t,i18n:n}=r(`integrations`),i=e.metrics,a=i.outputSavingsAvailable,o=[`codex`,`claude`].map(e=>({provider:e,metric:i.providers[e]})),s=t(`plugins.headroom.savings.tokens`),c=o.reduce((e,{metric:t})=>({inputTokens:e.inputTokens+t.inputTokens,inputTokensSaved:e.inputTokensSaved+t.inputTokensSaved,outputTokens:e.outputTokens+t.outputTokens,outputTokensSaved:e.outputTokensSaved+t.outputTokensSaved}),{inputTokens:0,inputTokensSaved:0,outputTokens:0,outputTokensSaved:0}),l=o.some(({metric:e})=>e.inputTokensSaved>0),u=o.some(({metric:e})=>e.active),d=t(a?`plugins.headroom.savings.statusInputOutput`:l?`plugins.headroom.savings.statusInputOnly`:u?`plugins.headroom.savings.statusRouting`:`plugins.headroom.savings.statusInactive`),f=a||l;return(0,M.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,M.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(w,{className:`h-3.5 w-3.5 text-accent-primary`}),(0,M.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t(`plugins.headroom.savings.title`)})]}),(0,M.jsx)(`span`,{className:g(`shrink-0 rounded border px-1.5 py-0.5 text-[10px]`,f?`border-accent-success/25 bg-accent-success/10 text-accent-success`:u?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-border bg-muted text-muted-foreground`),children:d})]}),(0,M.jsxs)(`div`,{className:`mb-2 rounded-md bg-muted/35 px-2.5 py-2`,children:[(0,M.jsx)(`div`,{className:`mb-1.5 text-[10px] font-medium uppercase text-muted-foreground`,children:t(`plugins.headroom.savings.totals`)}),(0,M.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,M.jsx)(Q,{label:t(`plugins.headroom.savings.input`),processed:c.inputTokens>0?W(c.inputTokens,n.language,s):t(`plugins.headroom.savings.noData`),saved:W(c.inputTokensSaved,n.language,s)}),(0,M.jsx)(Q,{align:`right`,label:t(`plugins.headroom.savings.output`),processed:c.outputTokens>0?W(c.outputTokens,n.language,s):t(`plugins.headroom.savings.noData`),saved:a?W(c.outputTokensSaved,n.language,s):t(`plugins.headroom.savings.noData`)})]})]}),(0,M.jsx)(`div`,{className:`grid gap-2`,children:o.map(({provider:e,metric:t})=>(0,M.jsx)(le,{metric:t,outputAvailable:i.outputSavingsAvailable},e))}),(0,M.jsx)(`div`,{className:`mt-2 flex items-center justify-end gap-2 text-[10px] text-muted-foreground`,children:i.updatedAt?t(`plugins.headroom.savings.updatedLive`):t(`plugins.headroom.savings.baselineSamples`,{count:e.learning.baselineSamples})})]})}function Q({label:e,processed:t,saved:n,detail:i,align:a=`left`}){let{t:o}=r(`integrations`);return(0,M.jsxs)(`div`,{className:g(`min-w-0`,a===`right`&&`text-right`),children:[(0,M.jsx)(`div`,{className:`text-[10px] font-medium uppercase text-muted-foreground`,children:e}),(0,M.jsxs)(`div`,{className:`mt-1 space-y-0.5 text-[11px]`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,M.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:o(`plugins.headroom.savings.processed`)}),(0,M.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:t})]}),(0,M.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,M.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:o(`plugins.headroom.savings.saved`)}),(0,M.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:n})]})]}),i&&(0,M.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,children:i})]})}function le({metric:e,outputAvailable:t}){let{t:n,i18n:i}=r(`integrations`),a=!e.available,o=a||!e.active,s=n(`plugins.headroom.savings.tokens`),c=e.inputTokens>0?W(e.inputTokens,i.language,s):n(`plugins.headroom.savings.noData`),l=W(e.inputTokensSaved,i.language,s),u=e.outputTokens>0?W(e.outputTokens,i.language,s):n(`plugins.headroom.savings.noData`),d=t?W(e.outputTokensSaved,i.language,s):e.active?n(`plugins.headroom.savings.noData`):n(`plugins.headroom.savings.off`),f=e.requests>0?n(`plugins.headroom.savings.requestCount`,{count:U(e.requests,i.language)}):a?n(`plugins.headroom.provider.noProjectUsesProvider`):e.active?n(`plugins.headroom.savings.inputSavingsActive`):n(`plugins.headroom.savings.routeDisabled`);return(0,M.jsxs)(`div`,{className:g(`rounded-md border border-border bg-card/45 px-2.5 py-2`,o&&`opacity-70`),children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`text-xs font-medium`,children:e.label}),e.detectedRoute&&(0,M.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-0.5 text-[9px] uppercase text-accent-primary`,children:n(`plugins.headroom.savings.detected`)})]}),(0,M.jsx)(`div`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:f}),(0,M.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-3`,children:[(0,M.jsx)(Q,{label:n(`plugins.headroom.savings.input`),processed:c,saved:l}),(0,M.jsx)(Q,{align:`right`,label:n(`plugins.headroom.savings.output`),processed:u,saved:d})]})]})}function $({provider:e,active:t,available:n,detectedRoute:i,busy:a,onClick:o}){let{t:c}=r(`integrations`),l=c(n?t?`plugins.headroom.provider.routedThroughHeadroom`:i?`plugins.headroom.provider.detectedExternalRoute`:`plugins.headroom.provider.notRouted`:`plugins.headroom.provider.noProjectUsesProvider`);return(0,M.jsxs)(`button`,{type:`button`,onClick:o,disabled:a||!n,className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background/45 p-3 text-left hover:bg-muted/35 disabled:opacity-50`,children:[(0,M.jsx)(`div`,{className:g(`grid h-8 w-8 place-items-center rounded-md`,t?`bg-accent-success/15 text-accent-success`:`bg-muted text-muted-foreground`),children:a?(0,M.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(O,{className:`h-3.5 w-3.5`})}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`div`,{className:`text-xs font-medium capitalize`,children:e}),(0,M.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:l})]}),(0,M.jsx)(`span`,{className:g(`h-5 w-9 rounded-full p-0.5 transition-colors`,t?`bg-accent-success`:`bg-muted`),children:(0,M.jsx)(`span`,{className:g(`block h-4 w-4 rounded-full bg-white shadow transition-transform`,t&&`translate-x-4`)})})]})}function ue({plugin:e,projects:t,onClose:n}){let{t:i}=r(`integrations`),[a,o]=(0,j.useState)(``);(0,j.useEffect)(()=>o(``),[e]);let s=t.find(e=>e.id===a)??null;return(0,M.jsx)(x,{open:!!e,onOpenChange:e=>{e||n()},children:(0,M.jsxs)(v,{className:`w-[calc(100vw-2rem)] max-w-3xl overflow-x-hidden p-4 sm:p-6`,children:[(0,M.jsxs)(_,{children:[(0,M.jsx)(y,{children:i(e===`jira`?`plugins.projectWizard.configureJira`:`plugins.projectWizard.installSerena`)}),(0,M.jsx)(b,{children:i(`plugins.projectWizard.description`)})]}),(0,M.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[260px_minmax(0,1fr)]`,children:[(0,M.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/70 p-3`,children:[(0,M.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:i(`plugins.projectWizard.chooseProject`)}),(0,M.jsx)(`div`,{className:`max-h-[52vh] space-y-1 overflow-auto`,children:t.map(t=>{let n=e===`serena`&&!p(t).includes(`claude`);return(0,M.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>o(t.id),className:g(`w-full rounded-md px-2 py-2 text-left transition-colors`,t.id===a?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/45 hover:text-foreground`,n&&`cursor-not-allowed opacity-45`),children:[(0,M.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t.name}),(0,M.jsx)(`div`,{className:`truncate text-[10px]`,children:n?i(`plugins.projectWizard.requiresClaudeProvider`):t.path})]},t.id)})})]}),(0,M.jsx)(`div`,{className:`min-h-[360px] rounded-lg border border-border bg-card/70 p-4`,children:s?e===`jira`?(0,M.jsx)(de,{project:s,onDone:n}):(0,M.jsx)(fe,{project:s,onDone:n}):(0,M.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:i(`plugins.projectWizard.selectProjectToContinue`)})})]})]})})}function de({project:e,onDone:t}){let{t:n}=r(`integrations`),i=H(e.id),[a,o]=(0,j.useState)(null),[c,l]=(0,j.useState)(!0),[u,d]=(0,j.useState)(null),f=(0,j.useCallback)(async()=>{l(!0),d(null);try{let e=await fetch(`${i}/jira/connection`).then(e=>V(e));o(e)}catch(e){o({connected:!1}),d(e.message)}finally{l(!1)}},[i]);return(0,j.useEffect)(()=>{f()},[f]),c?(0,M.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,M.jsx)(s,{className:`mr-2 h-4 w-4 animate-spin`}),n(`plugins.jira.loading`,{defaultValue:`Loading Jira...`})]}):a?.connected&&a.connection?(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`plugins.jira.configuredDescription`,{defaultValue:`Manage the Jira project, status mapping, discard status, sync, and connection state.`})})]}),(0,M.jsx)(P,{state:a,apiBase:i,onChanged:()=>{f()}})]}):(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:u?n(`plugins.jira.loadFailed`,{message:u,defaultValue:`Could not load the current Jira configuration: ${u}`}):n(`plugins.jira.notConfiguredDescription`,{defaultValue:`Connect this project to Jira.`})})]}),(0,M.jsx)(E,{apiBase:i,onConnected:()=>{f()},onSkip:t})]})}function fe({project:e,onDone:t}){let{t:n}=r(`integrations`),[i,a]=(0,j.useState)(null),[c,l]=(0,j.useState)(null),[d,f]=(0,j.useState)(!1),[p,m]=(0,j.useState)(null),h=(0,j.useCallback)(async()=>{m(null);let t=(await fetch(`${H(e.id)}/plugins`).then(e=>V(e))).plugins.find(e=>e.name===`serena`)??null;if(a(t),t?.status===`not-installed`){let t=await fetch(`${H(e.id)}/plugins/serena/preview-install`).then(e=>V(e));l(t)}},[e.id]);(0,j.useEffect)(()=>{h().catch(e=>m(e.message))},[h]);async function g(){f(!0),m(null);try{await fetch(`${H(e.id)}/plugins/serena/install`,{method:`POST`}).then(e=>V(e)),await h(),t()}catch(e){m(e.message)}finally{f(!1)}}let _=(c?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum),v=i?n(`plugins.projectStatus.${i.status}`,{defaultValue:i.status}):``,y=i?.name===`serena`?n(`plugins.catalog.serena.description`):i?.description;return!i&&!p?(0,M.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,M.jsx)(s,{className:`mr-2 h-4 w-4 animate-spin`}),` `,n(`plugins.serena.loading`)]}):(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.serena.titleForProject`,{name:e.name})}),(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`plugins.serena.description`)})]}),i&&(0,M.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-3`,children:[(0,M.jsx)(`div`,{className:`text-xs font-medium`,children:n(`plugins.serena.status`,{status:v})}),y&&(0,M.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:y})]}),c&&(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.files`)}),(0,M.jsx)(`ul`,{className:`space-y-1 text-xs font-mono`,children:c.files.map(e=>(0,M.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path]},e.path))})]}),(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.prerequisites`)}),(0,M.jsx)(`ul`,{className:`space-y-1 text-xs`,children:c.requirements.map(e=>(0,M.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.installed&&e.executable&&e.meetsMinimum?(0,M.jsx)(T,{className:`h-3 w-3 text-accent-success`}):(0,M.jsx)(u,{className:`h-3 w-3 text-accent-warning`}),(0,M.jsxs)(`span`,{children:[e.name,e.minVersion?` >= ${e.minVersion}`:``]}),e.version&&(0,M.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]})]},e.name))})]})]}),p&&(0,M.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-xs text-destructive`,children:p}),(0,M.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md border border-border px-3 py-1.5 text-xs`,children:n(`plugins.actions.cancel`)}),(0,M.jsxs)(`button`,{type:`button`,disabled:d||i?.status!==`not-installed`||!_,onClick:g,className:`flex items-center gap-2 rounded-md bg-accent-primary px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:[d?(0,M.jsx)(s,{className:`h-3.5 w-3.5 animate-spin`}):(0,M.jsx)(o,{className:`h-3.5 w-3.5`}),n(`plugins.actions.install`)]})]})]})}function pe({open:e,onClose:t}){let{t:n}=r(`integrations`),[i,a]=(0,j.useState)(null);return(0,j.useEffect)(()=>{e&&fetch(`${d}/api/global-plugins/headroom/diagnostics`).then(e=>V(e)).then(a).catch(e=>a({error:e.message}))},[e]),(0,M.jsx)(x,{open:e,onOpenChange:e=>{e||t()},children:(0,M.jsxs)(v,{className:`max-w-3xl`,children:[(0,M.jsxs)(_,{children:[(0,M.jsxs)(y,{className:`flex items-center gap-2`,children:[(0,M.jsx)(C,{className:`h-4 w-4`}),` `,n(`plugins.diagnostics.title`)]}),(0,M.jsx)(b,{children:n(`plugins.diagnostics.description`)})]}),(0,M.jsx)(`pre`,{className:`max-h-[62vh] overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background p-3 text-xs`,children:JSON.stringify(i,null,2)})]})})}export{G as default};
|
package/client/dist/assets/{ProjectSettingsDialog-C7Hesadg.js → ProjectSettingsDialog-DHsxLFMT.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r,t as i}from"./createLucideIcon-Bjbbp_KS.js";import{t as a}from"./git-branch-BRM0F5GN.js";import{r as o}from"./useDesktop-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r,t as i}from"./createLucideIcon-Bjbbp_KS.js";import{t as a}from"./git-branch-BRM0F5GN.js";import{r as o}from"./useDesktop-B4pSBIDd.js";import{t as s}from"./utils-BC4DHlz2.js";import{a as c,n as l,o as u,r as d,t as f}from"./dialog-CzIekCw0.js";import{Ft as p,Z as m,_ as h,g,h as _,it as v,m as y,nt as b,p as x,tt as S,v as C}from"./index-xkzK3E5i.js";var w=i(`key-round`,[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]),T=e(t(),1),E=n(),D=[{id:`general`,icon:b,labelKey:`projectDialog.nav.general`},{id:`branch`,icon:a,labelKey:`projectDialog.nav.branch`},{id:`environment`,icon:w,labelKey:`projectDialog.nav.environment`},{id:`budget`,icon:m,labelKey:`projectDialog.nav.budget`},{id:`telemetry`,icon:p,labelKey:`projectDialog.nav.telemetry`},{id:`terminal`,icon:S,labelKey:`projectDialog.nav.terminal`}];function O({open:e,onClose:t}){let{t:n}=r(`settings`),{activeProjectId:i,projects:a}=o(),p=a.find(e=>e.id===i),[m,b]=(0,T.useState)(`general`),S=e=>s(`space-y-5`,m===e?``:`hidden`);return(0,E.jsx)(f,{open:e,onOpenChange:e=>{e||t()},children:(0,E.jsxs)(l,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,E.jsxs)(c,{children:[(0,E.jsxs)(u,{className:`flex items-center gap-2`,children:[(0,E.jsx)(v,{className:`w-4 h-4`}),p?n(`projectDialog.title`,{name:p.name}):n(`page.title`)]}),(0,E.jsx)(d,{children:n(`projectDialog.description`)})]}),(0,E.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[(0,E.jsx)(`nav`,{className:`w-40 shrink-0 space-y-0.5 overflow-y-auto border-r border-border pr-2`,children:D.map(e=>{let t=e.icon;return(0,E.jsxs)(`button`,{type:`button`,onClick:()=>b(e.id),className:s(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,m===e.id?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,E.jsx)(t,{className:`w-3.5 h-3.5 shrink-0`}),(0,E.jsx)(`span`,{className:`truncate`,children:n(e.labelKey)})]},e.id)})}),(0,E.jsxs)(`div`,{className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:[(0,E.jsx)(`div`,{className:S(`general`),children:(0,E.jsx)(_,{})}),(0,E.jsx)(`div`,{className:S(`branch`),children:(0,E.jsx)(y,{})}),(0,E.jsx)(`div`,{className:S(`environment`),children:(0,E.jsx)(h,{})}),(0,E.jsx)(`div`,{className:S(`budget`),children:(0,E.jsx)(x,{})}),(0,E.jsx)(`div`,{className:S(`telemetry`),children:(0,E.jsx)(g,{})}),(0,E.jsx)(`div`,{className:S(`terminal`),children:(0,E.jsx)(C,{mode:`project`})})]})]})]})})}export{O as ProjectSettingsDialog};
|
package/client/dist/assets/{TemplatePreviewModal-DczCzUzP.js → TemplatePreviewModal-wcI3nGNr.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-zu2_FqZY.js";import{n as t}from"./createLucideIcon-Bjbbp_KS.js";import{t as n}from"./brain-DI9lHkKY.js";import{t as r}from"./download-CFHyyHcw.js";import{t as i}from"./git-branch-BRM0F5GN.js";import{t as a}from"./play-DNlrawbS.js";import{t as o}from"./button-BUIIBQPT.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./dialog-CzIekCw0.js";import{E as p,Et as m,Q as h,et as g}from"./index-
|
|
1
|
+
import{t as e}from"./jsx-runtime-zu2_FqZY.js";import{n as t}from"./createLucideIcon-Bjbbp_KS.js";import{t as n}from"./brain-DI9lHkKY.js";import{t as r}from"./download-CFHyyHcw.js";import{t as i}from"./git-branch-BRM0F5GN.js";import{t as a}from"./play-DNlrawbS.js";import{t as o}from"./button-BUIIBQPT.js";import{a as s,i as c,n as l,o as u,r as d,t as f}from"./dialog-CzIekCw0.js";import{E as p,Et as m,Q as h,et as g}from"./index-xkzK3E5i.js";var _=e(),v={start:a,"ai-step":n,shell:h,decider:i,condition:i,end:g};function y(e){return e.type===`ai-step`?typeof e.data?.prompt==`string`?e.data.prompt:null:e.type===`shell`?typeof e.data?.command==`string`?e.data.command:null:e.type===`decider`?typeof e.data?.goal==`string`?e.data.goal:null:e.type===`end`?e.data?.outcome===`failure`?`failure`:`success`:null}function b({template:e,onClose:i,onUse:a,mode:h=`use`}){let{t:b}=t(`loops`);return(0,_.jsx)(f,{open:e!==null,onOpenChange:e=>{e||i()},children:(0,_.jsx)(l,{movableResizable:!0,className:`max-w-lg`,children:e&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(s,{children:[(0,_.jsxs)(u,{className:`flex items-center gap-2`,children:[(0,_.jsx)(n,{className:`w-4 h-4 text-accent-highlight`}),e.name]}),(0,_.jsx)(d,{children:e.description})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[p(e.graph)?(0,_.jsx)(`span`,{title:b(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:b(`gallery.needsSpec`)}):(0,_.jsx)(`span`,{title:b(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:b(`gallery.standalone`)}),e.category&&(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info`,children:b(`categories.${e.category}`,{defaultValue:e.category})}),e.tags.map(e=>(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,_.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:b(`preview.limits`,{iterations:e.graph.config.maxIterations,timeout:e.graph.config.timeoutMinutes})}),(0,_.jsxs)(`div`,{className:`max-h-[50vh] overflow-y-auto space-y-1.5 pr-1`,children:[(0,_.jsx)(`span`,{className:`block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:b(`preview.steps`)}),e.graph.nodes.map((e,t)=>{let n=v[e.type]??g,r=y(e);return(0,_.jsxs)(`div`,{className:`rounded border border-border bg-surface/30 p-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,_.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,_.jsx)(n,{className:`w-3.5 h-3.5 text-accent-primary`}),b(`builder.nodes.${e.type}`)]}),r&&(0,_.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-muted-foreground font-mono`,children:r})]},e.id)})]}),(0,_.jsxs)(c,{children:[(0,_.jsx)(o,{variant:`ghost`,onClick:i,children:b(`common:actions.cancel`)}),(0,_.jsxs)(o,{onClick:()=>a(e.id),children:[h===`fork`?(0,_.jsx)(m,{className:`w-3.5 h-3.5 mr-1.5`}):(0,_.jsx)(r,{className:`w-3.5 h-3.5 mr-1.5`}),b(h===`fork`?`actions.fork`:`actions.use`)]})]})]})})})}export{b as n,y as r,v as t};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-js-zvt5ap3o.js","assets/index-xkzK3E5i.js","assets/rolldown-runtime-CNC7AqOf.js","assets/jsx-runtime-zu2_FqZY.js","assets/react-dom-DiWzBDP9.js","assets/preload-helper-Czpn1I53.js","assets/chunk-KS7C4IRE-Cx5sqopX.js","assets/i18n-Bf9Ckd10.js","assets/createLucideIcon-Bjbbp_KS.js","assets/activity-DiyjsgQV.js","assets/addspec-Rw8uVBC1.js","assets/agent-BuUpgqVx.js","assets/agents-DhG7mg6-.js","assets/agentstudio-BIUe1Im2.js","assets/aiedit-iIjz2_Qk.js","assets/analytics-DZ8Aoq3I.js","assets/attachments-B53PG733.js","assets/browser-CXUcnTMI.js","assets/builder-Cc_Lf79C.js","assets/chat-BGD7MXAy.js","assets/code-BDXEM4ml.js","assets/commands-DyUZQ1FI.js","assets/common-DHsv9N5d.js","assets/dashboard-Cslu_GCH.js","assets/explore-DgBACn39.js","assets/integrations-mB-7zoyT.js","assets/jira-CmKWERE0.js","assets/jobs-DoSaFzAa.js","assets/loops-BzfXWEwO.js","assets/mcp-uDkXYu4L.js","assets/nav-myFaXRHD.js","assets/settings-B0ypw9uw.js","assets/setup-ajB4rYm-.js","assets/specs-DII0C8gw.js","assets/terminal-BFRZnMPP.js","assets/tickets-D_yDquEw.js","assets/Trans-CPISVji8.js","assets/dist-bVqfYmby.js","assets/arrow-left-CpIR4j7G.js","assets/useBrowserCaptureSession-CkBJShUw.js","assets/auth-D_5bQv5W.js","assets/api-B2M7CtDw.js","assets/arrow-up-right-9DoMn7fD.js","assets/MinimizedChatsContext-Cs34FPTz.js","assets/sparkles-DrY8hb0X.js","assets/x-CBMI9ejn.js","assets/useSharedWebSocket-DaPh7QBL.js","assets/useDesktop-B4pSBIDd.js","assets/external-link-BcU5EWZp.js","assets/chevron-right-CViMxucY.js","assets/circle-x-CMYsN4ZH.js","assets/download-CFHyyHcw.js","assets/file-text-CFT-xXKN.js","assets/git-branch-BRM0F5GN.js","assets/loader-circle-DcygOQpC.js","assets/pencil-C9RkrIPZ.js","assets/play-DNlrawbS.js","assets/plus-CsnjfkmX.js","assets/save-28sIlCdr.js","assets/search-Cq_gE3Ik.js","assets/trash-2-BOU3WdZZ.js","assets/triangle-alert-H9T4jAmh.js","assets/zap-CHo3aCD1.js","assets/dist-Cez5CRkX.js","assets/button-BUIIBQPT.js","assets/clsx-CjueKrWZ.js","assets/utils-BC4DHlz2.js","assets/dialog-CzIekCw0.js","assets/jira-api-BgFIr8eD.js","assets/lib-CGdyxIWg.js","assets/getTimezoneOffsetInMilliseconds-qrcBaLW1.js","assets/index-Dh9i4CnN.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{l as a}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{_ as o,a as s,f as c,h as l,o as u,v as d}from"./i18n-Bf9Ckd10.js";import{t as f}from"./Trans-CPISVji8.js";import{n as p,t as m}from"./createLucideIcon-Bjbbp_KS.js";import{n as h}from"./dist-bVqfYmby.js";import{t as g}from"./arrow-left-CpIR4j7G.js";import{c as _,g as v,h as y,i as b,m as x,o as S,t as C,u as w}from"./useBrowserCaptureSession-CkBJShUw.js";import{n as T,u as E}from"./MinimizedChatsContext-Cs34FPTz.js";import{n as D,t as ee}from"./external-link-BcU5EWZp.js";import{t as te}from"./circle-x-CMYsN4ZH.js";import{t as O}from"./download-CFHyyHcw.js";import{t as ne}from"./file-text-CFT-xXKN.js";import{t as k}from"./git-branch-BRM0F5GN.js";import{t as re}from"./loader-circle-DcygOQpC.js";import{t as ie}from"./pencil-C9RkrIPZ.js";import{t as ae}from"./play-DNlrawbS.js";import{t as oe}from"./plus-CsnjfkmX.js";import{t as se}from"./save-28sIlCdr.js";import{t as A}from"./search-Cq_gE3Ik.js";import{t as ce}from"./trash-2-BOU3WdZZ.js";import{t as le}from"./triangle-alert-H9T4jAmh.js";import{t as ue}from"./x-CBMI9ejn.js";import{t as de}from"./zap-CHo3aCD1.js";import{a as j}from"./auth-D_5bQv5W.js";import{n as M}from"./useSharedWebSocket-DaPh7QBL.js";import{t as N}from"./api-B2M7CtDw.js";import{r as P}from"./useDesktop-B4pSBIDd.js";import{t as F}from"./button-BUIIBQPT.js";import{t as I}from"./utils-BC4DHlz2.js";import{a as fe,c as pe,i as me,n as he,o as ge,r as _e,s as ve,t as ye}from"./dialog-CzIekCw0.js";import{t as L}from"./jira-api-BgFIr8eD.js";import{n as be,t as xe}from"./lib-CGdyxIWg.js";import{t as R}from"./formatDistanceToNow-ByKli7Q_.js";import{n as Se}from"./spending-DMnCXy84.js";var Ce=m(`circle-arrow-right`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m12 16 4-4-4-4`,key:`1i9zcv`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]]),we=m(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Te=m(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),Ee=m(`file-minus-corner`,[[`path`,{d:`M20 14V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12`,key:`l9p8hp`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),z=m(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),B=m(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),De=m(`git-pull-request`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),V=m(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),H=m(`split`,[[`path`,{d:`M16 3h5v5`,key:`1806ms`}],[`path`,{d:`M8 3H3v5`,key:`15dfkv`}],[`path`,{d:`M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3`,key:`1qrqzj`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}]]),U=m(`ticket`,[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]),W=new Map,Oe=2e3;function ke(e){W.set(e,(W.get(e)??0)+1)}function Ae(e){(W.get(e)??0)<=0||setTimeout(()=>{let t=(W.get(e)??0)-1;t<=0?W.delete(e):W.set(e,t)},Oe)}function je(e){return e?(W.get(e)??0)>0:!1}var G=e(t(),1),Me=3e3,Ne=`
|
|
3
|
+
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Contract Layer
|
|
7
|
+
|
|
8
|
+
`;function K(e){return`${j}/api/projects/${encodeURIComponent(e)}`}function Pe(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Fe(e,t){let n=new Map(e.map(e=>[e.id,e])),r=t.map(e=>{let t=n.get(e.id);return t&&Pe(t,e)?t:e});return r.length===e.length&&r.every((t,n)=>t===e[n])?e:r}function Ie(){let{t:e}=p(`tickets`),{activeProjectId:t}=P(),[n,r]=(0,G.useState)([]),[i,a]=(0,G.useState)(!1),[o,s]=(0,G.useState)(null),[c,l]=(0,G.useState)(new Set),[u,d]=(0,G.useState)(new Set),f=(0,G.useRef)(t);f.current=t;let m=(0,G.useRef)(0),g=(0,G.useRef)(null),_=(0,G.useRef)(new Set),{registerHandler:v,unregisterHandler:y,connectionStatus:b}=M(),x=(0,G.useId)(),S=(0,G.useCallback)(async(e,t)=>{let n=K(e),r=await fetch(`${n}/tickets`,{signal:t,cache:`no-store`});if(!r.ok)throw Error(`Failed to fetch tickets: ${r.status}`);let i=await r.json();return Array.isArray(i)?i:i.tickets??[]},[]),C=(0,G.useCallback)(async(t,n)=>{let i=++m.current;g.current?.abort();let o=new AbortController;g.current=o,f.current===t&&(a(!0),s(null));try{let a=await S(t,o.signal);if(o.signal.aborted||i!==m.current||f.current!==t)return;let s=_.current,c=new Set;if(n===`merge`)for(let e of a)s.size>0&&!s.has(e.id)&&c.add(e.id);_.current=new Set(a.map(e=>e.id)),r(n===`replace`?a:e=>Fe(e,a)),c.size>0&&s.size>0&&(l(c),h.success(e(`toasts.newTicketsAdded`,{count:c.size}),{id:`tickets-added-${t}`}),setTimeout(()=>{f.current===t&&l(e=>{let t=new Set(e);for(let e of c)t.delete(e);return t})},Me))}catch(e){if(o.signal.aborted||i!==m.current||f.current!==t)return;s(e instanceof Error?e.message:String(e))}finally{i===m.current&&(g.current===o&&(g.current=null),f.current===t&&a(!1))}},[S,e]),w=(0,G.useCallback)(async()=>{t&&await C(t,`merge`)},[t,C]);(0,G.useEffect)(()=>{if(m.current+=1,g.current?.abort(),g.current=null,r([]),a(!1),s(null),_.current=new Set,l(new Set),d(new Set),t)return C(t,`replace`),()=>{m.current+=1,g.current?.abort(),g.current=null}},[t,C]);let T=(0,G.useCallback)(t=>{let n=t;if(!n||typeof n.type!=`string`)return;let i=f.current;if(!(n.projectId&&n.projectId!==i))switch(n.type){case`mcp.activity`:n.affectedProjectId&&n.affectedProjectId===i&&w();break;case`ticket_created`:{if(!n.ticket)break;let t=n.ticket;r(e=>e.some(e=>e.id===t.id)?e:[...e,t]),_.current.add(t.id),l(e=>new Set([...e,t.id])),je(i)||h.success(e(`toasts.newTicket`,{title:t.title}),{id:`new-ticket-${t.id}`}),setTimeout(()=>{l(e=>{let n=new Set(e);return n.delete(t.id),n})},Me);break}case`ticket_updated`:{if(!n.ticket)break;if(n.ticket.id===0){w();break}let e=n.ticket;r(t=>t.map(t=>t.id===e.id?e:t)),typeof e.description==`string`&&e.description.includes(Ne)&&d(t=>{if(!t.has(e.id))return t;let n=new Set(t);return n.delete(e.id),n});break}case`ticket_deleted`:{if(n.ticketId==null)break;let e=n.ticketId;r(t=>t.filter(t=>t.id!==e)),_.current.delete(e);break}case`explore.contract_refine_started`:if(n.ticketId==null)break;d(e=>new Set([...e,n.ticketId]));break;case`explore.contract_refine_failed`:{if(n.ticketId==null)break;let e=n.ticketId;d(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n});break}}},[w,e]);(0,G.useLayoutEffect)(()=>(v(`tickets-${x}`,T),()=>y(`tickets-${x}`)),[T,v,y,x]);let E=(0,G.useRef)(b);return(0,G.useEffect)(()=>{E.current!==`connected`&&b===`connected`&&f.current&&w(),E.current=b},[b,w]),{tickets:n,loading:i,isLoading:i,error:o,newTicketIds:c,contractRefiningIds:u,refetch:w,refresh:w,deleteTicket:(0,G.useCallback)(async e=>{let n=t;if(!n)return!1;try{let t=await fetch(`${K(n)}/tickets/${e}`,{method:`DELETE`});return t.ok&&f.current===n&&await C(n,`merge`),t.ok}catch{return!1}},[t,C]),updateTicketStatus:(0,G.useCallback)(async(e,n)=>{let r=t;if(!r)return!1;try{let t=await fetch(`${K(r)}/tickets/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({status:n})});return t.ok&&f.current===r&&await C(r,`merge`),t.ok}catch{return!1}},[t,C]),updateTicketPriority:(0,G.useCallback)(async(e,n)=>{let r=t;if(!r)return!1;try{let t=await fetch(`${K(r)}/tickets/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({priority:n})});return t.ok&&f.current===r&&await C(r,`merge`),t.ok}catch{return!1}},[t,C]),createTicket:(0,G.useCallback)(async e=>{let n=t;if(!n)return!1;try{let t=await fetch(`${K(n)}/tickets`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return t.ok&&f.current===n&&await C(n,`merge`),t.ok}catch{return!1}},[t,C]),updateTicket:(0,G.useCallback)(async(e,n)=>{let r=t;if(!r)return!1;try{let t=await fetch(`${K(r)}/tickets/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});return t.ok&&f.current===r&&await C(r,`merge`),t.ok}catch{return!1}},[t,C])}}var q=n(),Le=224,Re=8,ze=8;function Be({rails:e,onMoveToRail:t,onClose:n,anchorRect:r}){let{t:i}=p(`tickets`),a=(0,G.useRef)(null),[o,s]=(0,G.useState)(!1);(0,G.useLayoutEffect)(()=>{let e=requestAnimationFrame(()=>s(!0));return()=>cancelAnimationFrame(e)},[]),(0,G.useEffect)(()=>{function e(e){a.current&&(a.current.contains(e.target)||n())}function t(e){e.key===`Escape`&&n()}return document.addEventListener(`pointerdown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`pointerdown`,e),document.removeEventListener(`keydown`,t)}},[n]);let{top:c,left:l,caretLeft:u}=(0,G.useMemo)(()=>{let e=r.left+r.width/2,t=e-Le/2,n=window.innerWidth-Le-Re,i=Math.max(Re,Math.min(n,t)),a=e-i,o=Math.max(12,Math.min(Le-12,a));return{top:r.bottom+ze,left:i,caretLeft:o}},[r]);return(0,q.jsxs)(`div`,{ref:a,role:`dialog`,"aria-label":i(`rail.popoverTitle`),"data-testid":`move-to-rail-popover`,style:{top:c,left:l,width:Le,opacity:+!!o,transform:o?`translateY(0) scale(1)`:`translateY(-4px) scale(0.97)`,transformOrigin:`${u}px top`,transition:`opacity 140ms ease-out, transform 160ms cubic-bezier(0.2, 0.9, 0.3, 1)`},className:`fixed z-50 rounded-xl border border-border/60 bg-card/95 backdrop-blur shadow-xl shadow-black/40 p-1`,children:[(0,q.jsx)(`div`,{"aria-hidden":!0,className:`absolute w-2 h-2 rotate-45 bg-card/95 border-l border-t border-border/60`,style:{top:-5,left:u-4}}),(0,q.jsx)(`div`,{className:`px-2 py-1.5 text-[10px] uppercase tracking-wider text-muted-foreground/70 font-medium`,children:i(`rail.popoverTitle`)}),e.length===0?(0,q.jsx)(`div`,{className:`px-2 py-2 text-xs text-muted-foreground`,children:i(`rail.noRails`)}):(0,q.jsx)(`ul`,{className:`flex flex-col`,children:e.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{t(e.id),n()},className:`w-full flex items-center gap-2 px-2 py-1.5 rounded-lg text-left text-sm hover:bg-accent-info/10 hover:text-accent-info transition-colors`,children:[e.status===`running`?(0,q.jsx)(ae,{className:`w-3 h-3 text-accent-success animate-pulse shrink-0`,"aria-hidden":!0}):(0,q.jsx)(we,{className:`w-3 h-3 text-muted-foreground/60 shrink-0`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),(0,q.jsx)(Ce,{className:`w-3.5 h-3.5 text-muted-foreground/40 shrink-0`,"aria-hidden":!0})]})},e.id))})]})}var J=/\n*##\s*Acceptance Criteria\s*\n([\s\S]*?)(?=\n##\s|\n*$)/i;function Ve(e){if(!e)return{body:``,criteria:[]};let t=J.exec(e);if(!t)return{body:e.replace(/\s+$/,``),criteria:[]};let n=t[1],r=e.slice(0,t.index),i=e.slice(t.index+t[0].length),a=`${r.replace(/\s+$/,``)}${i?`\n\n${i.replace(/^\s+/,``)}`:``}`,o=n.split(/\r?\n/).map(e=>e.replace(/^\s*[-*+]\s+/,``).trim()).filter(e=>e.length>0);return{body:a.replace(/\s+$/,``),criteria:o}}var He=new Set([`draft`,`todo`]);function Y(e){return!!(He.has(e.status)||e.source===`jira`&&e.jira_key&&e.status!==`cancelled`)}function X(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx`.replace(/[xy]/g,e=>{let t=Math.random()*16|0;return(e===`x`?t:t&3|8).toString(16)})}var Z=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_TERMINAL_PANEL;return typeof e!=`string`||e!==`false`})(),Ue=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_AGENTS_SECTION;return typeof e!=`string`||e!==`false`})(),We=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_CODE_EXPLORER;return typeof e!=`string`||e!==`false`})(),Ge=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_JIRA;return typeof e!=`string`||e!==`false`})(),Ke=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_MCP;return typeof e!=`string`||e!==`false`})(),qe=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_AGENT_CHAT;return typeof e!=`string`||e!==`false`})(),Je=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_AGENT_MODE;return qe&&(typeof e!=`string`||e!==`false`)})();(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_INTERACTIVE_JOBS;return typeof e!=`string`||e!==`false`})();var Ye=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_LOOPS_SECTION;return typeof e!=`string`||e!==`false`})(),Xe=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_PROJECT_BUILDER;return typeof e!=`string`||e!==`false`})();function Ze(){let{activeProjectId:e}=P(),[t,n]=(0,G.useState)({connected:!1,key:null,discardStatus:null}),[r,i]=(0,G.useState)(!0);return(0,G.useEffect)(()=>{if(!Ge||!e){n({connected:!1,key:null,discardStatus:null}),i(!1);return}let t=!1;return i(!0),L.getConnection().then(e=>{if(t)return;let r=!!(e.connected&&e.connection?.enabled);n({connected:r,key:e.connection?.jiraProjectKey??null,discardStatus:r?e.connection?.discardStatus??null:null})}).catch(()=>{t||n({connected:!1,key:null,discardStatus:null})}).finally(()=>{t||i(!1)}),()=>{t=!0}},[e]),{connected:t.connected,jiraProjectKey:t.key,discardStatus:t.discardStatus,loading:r}}function Qe({open:e,onOpenChange:t,ticket:n,discardStatus:r,onDiscarded:i}){let{t:a}=p(`jira`),[o,s]=(0,G.useState)(``),[c,l]=(0,G.useState)(!1);async function u(){l(!0);try{await L.discardSpec(n.id,o.trim()||null),h.success(a(`discard.movedToast`,{status:r,key:n.jira_key??`#${n.id}`})),t(!1),s(``),i?.()}catch(e){h.error(e instanceof Error?e.message:a(`errors.generic`))}finally{l(!1)}}return(0,q.jsx)(ye,{open:e,onOpenChange:e=>{c||t(e)},children:(0,q.jsxs)(he,{movableResizable:!0,className:`max-w-md`,"data-testid":`jira-discard-dialog`,children:[(0,q.jsxs)(fe,{children:[(0,q.jsx)(ge,{children:a(`discard.title`,{status:r})}),(0,q.jsx)(_e,{children:a(`discard.body`,{status:r,key:n.jira_key??`#${n.id}`})})]}),(0,q.jsxs)(`label`,{className:`block space-y-1`,children:[(0,q.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:a(`discard.commentLabel`)}),(0,q.jsx)(`textarea`,{value:o,onChange:e=>s(e.target.value),placeholder:a(`discard.commentPlaceholder`),rows:3,className:`w-full rounded-md border border-border bg-input px-3 py-2 text-xs text-foreground placeholder:text-muted-foreground resize-none`,"data-testid":`jira-discard-comment`})]}),(0,q.jsxs)(me,{children:[(0,q.jsx)(F,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:c,children:a(`wizard.cancel`)}),(0,q.jsxs)(F,{size:`sm`,onClick:u,disabled:c,"data-testid":`jira-discard-confirm`,children:[(0,q.jsx)(v,{className:`w-3.5 h-3.5 mr-1.5`}),c?a(`discard.moving`):a(`discard.confirm`,{status:r})]})]})]})})}var $e={draft:{dotClass:`bg-accent-secondary/60`,textClass:`text-accent-secondary`,borderClass:`border-l-[3px] border-dashed border-accent-secondary/50 pl-3`,labelKey:`common:status.draft`,pulsing:!1},todo:{dotClass:`bg-slate-500/70`,textClass:`text-muted-foreground`,borderClass:`border-l-[3px] border-dashed border-slate-500/40 pl-3`,labelKey:`status.todo`,pulsing:!1},in_progress:{dotClass:`bg-blue-400 aurora-light:bg-accent-info`,textClass:`text-foreground font-semibold`,borderClass:`border-l-[3px] border-solid border-blue-500 pl-3`,labelKey:`status.inProgress`,pulsing:!0},on_review:{dotClass:`bg-accent-warning/80`,textClass:`text-accent-warning`,borderClass:`border-l-[3px] border-solid border-accent-warning/60 pl-3`,labelKey:`status.onReview`,pulsing:!1},done:{dotClass:`text-emerald-400 aurora-light:text-accent-success`,textClass:`text-emerald-400/80 aurora-light:text-accent-success`,borderClass:`border-l-[3px] border-solid border-emerald-500 pl-3`,labelKey:`status.done`,pulsing:!1},cancelled:{dotClass:`text-red-400/60 aurora-light:text-destructive/70`,textClass:`text-muted-foreground/50`,borderClass:`pl-3`,labelKey:`status.cancelled`,pulsing:!1}};function et({status:e,className:t}){let{t:n}=p(`specs`),r=$e[e];return e===`done`?(0,q.jsx)(D,{className:I(`w-3.5 h-3.5 shrink-0`,r.dotClass,t),"aria-label":n(`status.done`)}):e===`cancelled`?(0,q.jsx)(ue,{className:I(`w-3.5 h-3.5 shrink-0`,r.dotClass,t),"aria-label":n(`status.cancelled`)}):r.pulsing?(0,q.jsxs)(`span`,{className:I(`relative flex shrink-0 h-2.5 w-2.5`,t),"aria-label":n(`status.inProgress`),children:[(0,q.jsx)(`span`,{className:I(`animate-ping absolute inline-flex h-full w-full rounded-full opacity-60`,r.dotClass)}),(0,q.jsx)(`span`,{className:I(`relative inline-flex rounded-full h-2.5 w-2.5`,r.dotClass)})]}):(0,q.jsx)(`span`,{className:I(`inline-flex rounded-full h-2.5 w-2.5 shrink-0`,r.dotClass,t),"aria-label":n(r.labelKey)})}function tt({status:e,className:t}){let{t:n}=p(`specs`),r=$e[e];return(0,q.jsxs)(`span`,{className:I(`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-[11px] font-medium border`,e===`todo`&&`bg-slate-500/10 border-slate-500/30 text-slate-400 aurora-light:bg-muted aurora-light:border-border aurora-light:text-muted-foreground`,e===`in_progress`&&`bg-blue-500/10 border-blue-500/30 text-blue-400 aurora-light:bg-accent-info/10 aurora-light:border-accent-info/30 aurora-light:text-accent-info`,e===`on_review`&&`bg-accent-warning/10 border-accent-warning/30 text-accent-warning`,e===`done`&&`bg-emerald-500/10 border-emerald-500/30 text-emerald-400 aurora-light:bg-accent-success/10 aurora-light:border-accent-success/30 aurora-light:text-accent-success`,e===`cancelled`&&`bg-red-500/10 border-red-500/30 text-red-400/60 aurora-light:bg-destructive/10 aurora-light:border-destructive/30 aurora-light:text-destructive/70`,t),children:[(0,q.jsx)(et,{status:e}),n(r.labelKey)]})}async function nt(e,t,n){let r=new FormData;r.append(`file`,t);let i=await fetch(`${N()}/tickets/${e}/attachments`,{method:`POST`,body:r,signal:n});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??u.t(`attachments:errors.uploadFailed`,{status:i.status}))}return(await i.json()).attachment}async function rt(e,t){let n=await fetch(`${N()}/tickets/${e}/attachments/${t}`,{method:`DELETE`});if(!n.ok&&n.status!==404)throw Error(u.t(`attachments:errors.deleteFailed`,{status:n.status}))}async function it(e){let t=await fetch(`${N()}/tickets/${e}/attachments`,{method:`DELETE`});if(!t.ok&&t.status!==404)throw Error(u.t(`attachments:errors.bulkDeleteFailed`,{status:t.status}))}async function at(e){let t=await fetch(`${N()}/tickets/${e}/attachments`);if(!t.ok)throw Error(u.t(`attachments:errors.listFailed`,{status:t.status}));return(await t.json()).attachments}function ot(e,t){return`${N()}/tickets/${e}/attachments/${t}`}async function st(e,t){let n=await fetch(ot(e,t));if(!n.ok)throw Error(u.t(`attachments:errors.fetchFailed`,{status:n.status}));return n.blob()}var ct=`image/jpeg,image/png,image/gif,image/webp,application/pdf,text/csv,text/plain,application/json,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel,application/sql,application/x-sql,text/sql,text/x-sql,.sql`,lt=new Set(ct.split(`,`).filter(e=>!e.startsWith(`.`))),ut=/\.sql$/i,dt=/\.(png|jpe?g|gif|webp)$/i;function ft(e){return lt.has(e.type)||ut.test(e.name)||dt.test(e.name)}function pt(){return typeof window<`u`&&window.__TAURI_INTERNALS__!==void 0}function mt(e){return Function(`s`,`return import(s)`)(e).catch(()=>null)}async function ht(e){if(pt()){try{let t=await mt(`@tauri-apps/plugin-opener`);if(t?.revealItemInDir){await t.revealItemInDir(e);return}}catch{}try{await(await mt(`@tauri-apps/api/shell`))?.open?.(e)}catch{}}}async function Q(e){if(pt())try{let t=await i(()=>import(`./dist-js-zvt5ap3o.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71]));if(typeof t.open==`function`){await t.open(e);return}}catch(e){console.warn(`[openExternalUrl] tauri shell open failed:`,e)}try{window.open(e,`_blank`,`noopener,noreferrer`)}catch{}}function gt(e,t){let n=()=>l(t?.in,NaN),r=t?.additionalDigits??2,i=xt(e),a;if(i.date){let e=St(i.date,r);a=Ct(e.restDateString,e.year)}if(!a||isNaN(+a))return n();let o=+a,s=0,u;if(i.time&&(s=Tt(i.time),isNaN(s)))return n();if(i.timezone){if(u=Dt(i.timezone),isNaN(u))return n()}else{let e=new Date(o+s),n=c(0,t?.in);return n.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),n.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),n}return c(o+s+u,t?.in)}var _t={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},vt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,yt=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,bt=/^([+-])(\d{2})(?::?(\d{2}))?$/;function xt(e){let t={},n=e.split(_t.dateTimeDelimiter),r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],_t.timeZoneDelimiter.test(t.date)&&(t.date=e.split(_t.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){let e=_t.timezone.exec(r);e?(t.time=r.replace(e[1],``),t.timezone=e[1]):t.time=r}return t}function St(e,t){let n=RegExp(`^(?:(\\d{4}|[+-]\\d{`+(4+t)+`})|(\\d{2}|[+-]\\d{`+(2+t)+`})$)`),r=e.match(n);if(!r)return{year:NaN,restDateString:``};let i=r[1]?parseInt(r[1]):null,a=r[2]?parseInt(r[2]):null;return{year:a===null?i:a*100,restDateString:e.slice((r[1]||r[2]).length)}}function Ct(e,t){if(t===null)return new Date(NaN);let n=e.match(vt);if(!n)return new Date(NaN);let r=!!n[4],i=wt(n[1]),a=wt(n[2])-1,o=wt(n[3]),s=wt(n[4]),c=wt(n[5])-1;if(r)return Nt(t,s,c)?Ot(t,s,c):new Date(NaN);{let e=new Date(0);return!jt(t,a,o)||!Mt(t,i)?new Date(NaN):(e.setUTCFullYear(t,a,Math.max(i,o)),e)}}function wt(e){return e?parseInt(e):1}function Tt(e){let t=e.match(yt);if(!t)return NaN;let n=Et(t[1]),r=Et(t[2]),i=Et(t[3]);return Pt(n,r,i)?n*o+r*d+i*1e3:NaN}function Et(e){return e&&parseFloat(e.replace(`,`,`.`))||0}function Dt(e){if(e===`Z`)return 0;let t=e.match(bt);if(!t)return 0;let n=t[1]===`+`?-1:1,r=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return Ft(r,i)?n*(r*o+i*d):NaN}function Ot(e,t,n){let r=new Date(0);r.setUTCFullYear(e,0,4);let i=r.getUTCDay()||7,a=(t-1)*7+n+1-i;return r.setUTCDate(r.getUTCDate()+a),r}var kt=[31,null,31,30,31,30,31,31,30,31,30,31];function At(e){return e%400==0||e%4==0&&e%100!=0}function jt(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(kt[t]||(At(e)?29:28))}function Mt(e,t){return t>=1&&t<=(At(e)?366:365)}function Nt(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function Pt(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function Ft(e,t){return t>=0&&t<=59}function It({ticketKey:e,attachment:t,onClose:n}){let{t:r}=p(`attachments`),[i,a]=(0,G.useState)(null),[o,s]=(0,G.useState)(null);if((0,G.useEffect)(()=>{if(!t)return;function e(e){e.key===`Escape`&&n()}document.addEventListener(`keydown`,e);let r=document.body.style.overflow;return document.body.style.overflow=`hidden`,()=>{document.removeEventListener(`keydown`,e),document.body.style.overflow=r}},[t,n]),(0,G.useEffect)(()=>{if(!t){a(null),s(null);return}let n=!1;return a(null),s(null),st(e,t.id).then(e=>{n||a(URL.createObjectURL(e))}).catch(e=>{n||s(e instanceof Error?e.message:r(`errors.loadFailed`))}),()=>{n=!0}},[t,e]),(0,G.useEffect)(()=>()=>{i&&URL.revokeObjectURL(i)},[i]),!t)return null;let c=t.mimeType.startsWith(`image/`),l=t.mimeType===`application/pdf`;return(0,q.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":r(`lightbox.preview`,{name:t.filename}),className:`fixed inset-0 z-[100] flex flex-col bg-black/85 backdrop-blur-sm animate-in fade-in-0 duration-200`,onClick:n,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between px-4 py-3 border-b border-white/10 bg-black/40`,onClick:e=>e.stopPropagation(),children:[(0,q.jsxs)(`button`,{type:`button`,onClick:n,"aria-label":r(`lightbox.backToDesktop`),className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-sm text-white/85 hover:bg-white/10 hover:text-white transition-colors`,children:[(0,q.jsx)(g,{className:`w-4 h-4`}),r(`common:actions.back`)]}),(0,q.jsxs)(`div`,{className:`flex-1 text-center min-w-0 px-4`,children:[(0,q.jsx)(`div`,{className:`text-sm font-medium text-white/95 truncate`,children:t.filename}),(0,q.jsx)(`div`,{className:`text-[11px] text-white/50`,children:t.mimeType})]}),(0,q.jsxs)(`a`,{href:i??`#`,download:t.filename,onClick:e=>{e.stopPropagation(),i||e.preventDefault()},className:`inline-flex items-center gap-2 px-3 py-1.5 rounded-md text-sm text-white/85 hover:bg-white/10 hover:text-white transition-colors`,"aria-label":r(`lightbox.download`),children:[(0,q.jsx)(O,{className:`w-4 h-4`}),r(`lightbox.download`)]})]}),(0,q.jsx)(`div`,{className:I(`flex-1 flex items-center justify-center overflow-auto p-6`),onClick:n,children:o?(0,q.jsx)(`div`,{onClick:e=>e.stopPropagation(),className:`text-center text-white/80 px-8 py-10 rounded-lg bg-white/5 border border-white/10`,children:(0,q.jsx)(`p`,{className:`text-sm`,children:r(`lightbox.loadError`,{error:o})})}):i?c?(0,q.jsx)(`img`,{src:i,alt:t.filename,onClick:e=>e.stopPropagation(),className:`max-h-full max-w-full rounded-lg shadow-2xl animate-in zoom-in-95 duration-200`}):l?(0,q.jsx)(`iframe`,{src:i,title:t.filename,onClick:e=>e.stopPropagation(),className:`w-full h-full max-w-5xl bg-white rounded-lg shadow-2xl`}):(0,q.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:`text-center text-white/80 px-8 py-10 rounded-lg bg-white/5 border border-white/10`,children:[(0,q.jsx)(`p`,{className:`text-sm mb-3`,children:r(`lightbox.previewUnavailable`)}),(0,q.jsxs)(`a`,{href:i,download:t.filename,className:`inline-flex items-center gap-2 px-4 py-2 rounded-md bg-white/10 hover:bg-white/20 text-white transition-colors`,children:[(0,q.jsx)(O,{className:`w-4 h-4`}),r(`lightbox.downloadFile`,{name:t.filename})]})]}):(0,q.jsx)(`div`,{onClick:e=>e.stopPropagation(),className:`text-center text-white/70 px-8 py-10 rounded-lg bg-white/5 border border-white/10`,children:(0,q.jsx)(`p`,{className:`text-sm`,children:r(`lightbox.loading`)})})})]})}function Lt(e,t){let n=new Set,r=[];for(let i of[...e,...t])n.has(i.id)||(n.add(i.id),r.push(i));return r}function Rt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function zt(e){return e.startsWith(`image/`)?`🖼`:e===`application/pdf`?`📄`:e===`text/csv`||e.includes(`spreadsheetml`)||e===`application/vnd.ms-excel`?`📊`:e===`application/json`?`{ }`:e===`text/plain`||e.includes(`sql`)?`📝`:`📎`}function Bt(e){try{return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}catch{return e}}function Vt({ticketKey:e,attachments:t,onChange:n,className:r}){let{t:i}=p(`attachments`),[a,o]=(0,G.useState)(new Set),[s,c]=(0,G.useState)(null),[l,u]=(0,G.useState)(null);if((0,G.useEffect)(()=>{let r=!1;return at(e).then(e=>{if(r)return;let i=Lt(t,e);i.length!==t.length&&n?.(i)}).catch(()=>{}),()=>{r=!0}},[e]),!t||t.length===0)return null;let d=[...t].sort((e,t)=>e.addedAt<t.addedAt?1:-1);async function f(r){c(null),o(e=>{let t=new Set(e);return t.add(r.id),t});try{await rt(e,r.id),await new Promise(e=>setTimeout(e,160)),n?.(t.filter(e=>e.id!==r.id))}catch(e){c(e instanceof Error?e.message:i(`errors.removeFailed`)),o(e=>{let t=new Set(e);return t.delete(r.id),t})}}return(0,q.jsxs)(`section`,{className:I(`mt-4`,r),"aria-label":i(`section.ariaLabel`),children:[(0,q.jsxs)(`header`,{className:`flex items-center justify-between mb-2`,children:[(0,q.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:i(`section.title`)}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:i(`section.fileCount`,{count:d.length})})]}),(0,q.jsx)(`ul`,{className:`flex flex-col gap-1`,children:d.map(e=>{let t=a.has(e.id);return(0,q.jsxs)(`li`,{className:I(`flex items-center gap-3 px-2.5 py-2 rounded-md border border-border bg-card/60 hover:bg-card transition-all duration-200`,t&&`opacity-0 scale-95 max-h-0 py-0 border-transparent overflow-hidden`),children:[(0,q.jsx)(`span`,{"aria-hidden":!0,className:`w-6 text-center text-sm shrink-0`,children:zt(e.mimeType)}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>u(e),className:`flex-1 min-w-0 flex flex-col text-sm text-left hover:text-primary transition-colors`,children:[(0,q.jsx)(`span`,{className:`font-medium truncate text-foreground`,children:e.filename}),(0,q.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[Rt(e.size),` · `,Bt(e.addedAt)]})]}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:`text-[11px] text-primary hover:underline shrink-0`,children:i(`common:actions.open`)}),(0,q.jsx)(`button`,{type:`button`,onClick:()=>f(e),"aria-label":i(`removeFile`,{name:e.filename}),disabled:t,className:`w-6 h-6 inline-flex items-center justify-center rounded text-muted-foreground hover:text-destructive hover:bg-destructive/10 transition-colors disabled:opacity-50`,children:`×`})]},e.id)})}),s&&(0,q.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:s}),(0,q.jsx)(It,{ticketKey:e,attachment:l,onClose:()=>u(null)})]})}function Ht({ticketId:e,onClose:t}){let{t:n}=p(`code`),r=a(),{activeProjectId:i}=P(),[o,s]=(0,G.useState)(null);return(0,G.useEffect)(()=>{if(!We)return;let t=new AbortController;return s(null),fetch(`${N()}/code/provenance?ticketId=${e}`,{signal:t.signal}).then(e=>e.ok?e.json():[]).then(e=>{s(Array.isArray(e)?e:[])}).catch(e=>{e?.name!==`AbortError`&&s([])}),()=>t.abort()},[e,i]),!We||!o||o.length===0?null:(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:n(`ticketFiles.title`)}),(0,q.jsx)(`ul`,{className:`space-y-1`,children:o.map((e,i)=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{t(),r(`/code?path=${encodeURIComponent(e.path)}`)},className:`w-full text-left flex items-center gap-2 rounded px-2 py-1 text-xs hover:bg-muted/40`,children:[(0,q.jsx)(e.kind===`created`?z:e.kind===`deleted`?Ee:ne,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,q.jsx)(`span`,{className:`font-mono truncate flex-1`,children:e.path}),e.jobId&&(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] text-muted-foreground font-mono shrink-0`,title:n(`ticketFiles.jobTitle`,{jobId:e.jobId}),children:[(0,q.jsx)(B,{className:`h-3 w-3`}),e.jobId.length>10?e.jobId.slice(0,10):e.jobId]}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider shrink-0`,children:n(`kind.${e.kind}`)})]})},`${e.path}-${i}`))})]})}var Ut={critical:`bg-red-500/15 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,high:`bg-orange-500/15 aurora-light:bg-accent-warning/10 text-orange-400 aurora-light:text-accent-warning border-orange-500/30 aurora-light:border-accent-warning/30`,medium:``,low:`bg-gray-500/15 aurora-light:bg-muted text-gray-400 aurora-light:text-muted-foreground border-gray-500/30 aurora-light:border-border`};function Wt(e){try{return R(new Date(e),{addSuffix:!0,locale:s()})}catch{return e}}function Gt({tickets:e,excludeIds:t,onSelect:n}){let{t:r}=p(`tickets`),[i,a]=(0,G.useState)(``),o=(0,G.useMemo)(()=>{let n=new Set(t),r=e.filter(e=>e.status!==`cancelled`&&!n.has(e.id));if(!i.trim())return r;let a=i.toLowerCase();return r.filter(e=>e.title.toLowerCase().includes(a)||e.description.toLowerCase().includes(a))},[e,t,i]);return(0,q.jsxs)(`div`,{"data-testid":`spec-compare-picker`,className:`h-full flex flex-col rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 overflow-hidden`,children:[(0,q.jsxs)(`div`,{className:`px-4 py-3 border-b border-border/30 flex items-center gap-2`,children:[(0,q.jsx)(U,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,q.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:r(`comparePicker.title`)}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`comparePicker.count`,{n:o.length})})]}),(0,q.jsx)(`div`,{className:`px-4 py-2 border-b border-border/20`,children:(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(A,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,q.jsx)(`input`,{type:`text`,value:i,onChange:e=>a(e.target.value),placeholder:r(`comparePicker.searchPlaceholder`),className:`w-full h-7 rounded border border-border bg-input pl-7 pr-2 text-[11px] text-foreground placeholder:text-muted-foreground outline-none focus:border-accent-primary/60`})]})}),(0,q.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`spec-compare-picker-list`,children:o.length===0?(0,q.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center px-4 py-8 gap-2`,children:[(0,q.jsx)(U,{className:`w-6 h-6 text-muted-foreground/40`}),(0,q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.trim()?r(`comparePicker.noMatches`):r(`comparePicker.empty`)})]}):(0,q.jsx)(`ul`,{className:`divide-y divide-border/10`,children:o.map(e=>(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,"data-testid":`spec-compare-card-${e.id}`,onClick:()=>n(e.id),className:`w-full text-left px-4 py-2.5 hover:bg-accent/30 transition-colors flex items-start gap-2 group`,children:[(0,q.jsx)(et,{status:e.status}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,q.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:[`#`,e.id]}),e.priority&&Ut[e.priority]&&(0,q.jsx)(`span`,{className:`inline-flex items-center rounded px-1 py-0.5 text-[9px] font-medium border ${Ut[e.priority]}`,children:r(`priority.${e.priority}`)})]}),(0,q.jsx)(`p`,{className:`mt-0.5 text-xs text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title||r(`untitled`)}),e.description&&(0,q.jsx)(`p`,{className:`mt-0.5 text-[10px] text-muted-foreground line-clamp-1`,children:e.description.slice(0,120)}),e.labels&&e.labels.length>0&&(0,q.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:[e.labels.slice(0,3).map(e=>(0,q.jsx)(`span`,{className:`inline-flex items-center rounded px-1 py-0.5 text-[9px] bg-accent/40 text-foreground/60`,children:e},e)),e.labels.length>3&&(0,q.jsxs)(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.labels.length-3]})]}),(0,q.jsx)(`p`,{className:`mt-1 text-[9px] text-muted-foreground`,children:r(`meta.updatedAgo`,{time:Wt(e.updated_at)})})]})]})},e.id))})})]})}var Kt=.25,qt=.75;function Jt({state:e,leftTicket:t,rightTicket:n,allTickets:r,allLabels:i,onSave:a,onDelete:o,onOpenTicket:s,onCloseAll:c,onSetCompared:l,onSetRatio:u,onExitSplit:d}){let f=(0,G.useRef)(null),p=(0,G.useRef)(null),[m,h]=(0,G.useState)(!0);(0,G.useEffect)(()=>{let e=setTimeout(()=>h(!1),320);return()=>clearTimeout(e)},[]);let g=(0,G.useCallback)(e=>{if(!p.current)return;let t=window.innerWidth,n=e.clientX/t;u(Math.min(qt,Math.max(Kt,n)))},[u]),_=(0,G.useCallback)(e=>{if(!p.current)return;let{pointerId:t,element:n}=p.current;try{n.releasePointerCapture(t)}catch{}p.current=null,window.removeEventListener(`pointermove`,g),window.removeEventListener(`pointerup`,_),window.removeEventListener(`pointercancel`,_)},[g]),v=(0,G.useCallback)(e=>{let t=e.currentTarget;try{t.setPointerCapture(e.pointerId)}catch{}p.current={pointerId:e.pointerId,element:t},window.addEventListener(`pointermove`,g),window.addEventListener(`pointerup`,_),window.addEventListener(`pointercancel`,_)},[g,_]);(0,G.useEffect)(()=>()=>{window.removeEventListener(`pointermove`,g),window.removeEventListener(`pointerup`,_),window.removeEventListener(`pointercancel`,_);let e=p.current;if(e){try{e.element.releasePointerCapture(e.pointerId)}catch{}p.current=null}},[g,_]);let y=(0,G.useCallback)(t=>{let n=.04;t.key===`ArrowLeft`?(t.preventDefault(),u(Math.max(Kt,e.splitRatio-n))):t.key===`ArrowRight`?(t.preventDefault(),u(Math.min(qt,e.splitRatio+n))):t.key===`Home`?(t.preventDefault(),u(Kt)):t.key===`End`?(t.preventDefault(),u(qt)):t.key===`0`&&(t.preventDefault(),u(.5))},[u,e.splitRatio]),b=e=>{e.target===e.currentTarget&&c()},x=u=>{let d=u===e.originSide,f=u===`left`?t:n;return f?(0,q.jsx)(Un,{ticket:f,allLabels:i,allTickets:r,onClose:d?c:()=>l(null,u),onOpenTicket:s,onSave:a,onDelete:o,embedded:!0},`${u}-${f.id}`):(0,q.jsx)(Gt,{tickets:r,excludeIds:[t?.id,n?.id].filter(e=>e!=null),onSelect:e=>l(e,u)})},S=(e.splitRatio*100).toFixed(2),C=((1-e.splitRatio)*100).toFixed(2);return(0,q.jsxs)(`div`,{ref:f,"data-testid":`split-view-shell`,className:`fixed inset-0 z-[68] flex`,onClick:b,children:[(0,q.jsx)(`div`,{className:`absolute inset-0 bg-black/70 pointer-events-none`,"aria-hidden":!0}),(0,q.jsxs)(`div`,{className:`relative flex w-full h-full`,style:{transition:m?`opacity 280ms cubic-bezier(0.34, 1.56, 0.64, 1)`:void 0},children:[(0,q.jsx)(`div`,{"data-testid":`split-panel-left`,className:`relative h-full overflow-hidden`,style:{width:`${S}%`,transition:m?`width 280ms cubic-bezier(0.34, 1.56, 0.64, 1)`:void 0},children:(0,q.jsx)(`div`,{className:`h-full flex items-center justify-center p-2`,children:(0,q.jsx)(`div`,{className:`w-full h-full max-h-[95vh]`,children:x(`left`)})})}),(0,q.jsx)(`div`,{"data-testid":`split-divider`,role:`separator`,"aria-orientation":`vertical`,"aria-valuenow":Math.round(e.splitRatio*100),"aria-valuemin":Math.round(Kt*100),"aria-valuemax":Math.round(qt*100),tabIndex:0,onPointerDown:v,onKeyDown:y,className:`relative z-10 w-2 cursor-col-resize bg-border/40 hover:bg-accent-primary/40 transition-colors focus:outline-none focus:bg-accent-primary/60`}),(0,q.jsx)(`div`,{"data-testid":`split-panel-right`,className:`relative h-full overflow-hidden`,style:{width:`${C}%`,transition:m?`width 280ms cubic-bezier(0.34, 1.56, 0.64, 1)`:void 0},children:(0,q.jsx)(`div`,{className:`h-full flex items-center justify-center p-2`,children:(0,q.jsx)(`div`,{className:`w-full h-full max-h-[95vh]`,children:x(`right`)})})})]})]})}var Yt=.5,Xt=.25,Zt=.75,Qt={leftId:null,rightId:null,originSide:null,splitRatio:Yt};function $t(e){return Number.isFinite(e)?Math.min(Zt,Math.max(Xt,e)):Yt}function en(e,t){switch(t.type){case`openCentered`:return e.originSide!==null&&e.leftId!==t.id&&e.rightId!==t.id?{leftId:t.id,rightId:null,originSide:null,splitRatio:Yt}:e.originSide!==null&&(e.leftId===t.id||e.rightId===t.id)?e:{...Qt,leftId:t.id};case`closeAll`:return Qt;case`enterSplit`:{let n=t.ticketId??e.leftId;return n===null||e.originSide!==null?e:t.side===`left`?{leftId:n,rightId:null,originSide:`left`,splitRatio:Yt}:{leftId:null,rightId:n,originSide:`right`,splitRatio:Yt}}case`setComparedTicket`:{if(e.originSide===null)return e;let n=e.originSide===`left`?`right`:`left`;return t.side===n?t.side===`left`?{...e,leftId:t.id}:{...e,rightId:t.id}:e}case`exitSplit`:{if(e.originSide===null)return e;let t=e.originSide===`left`?e.leftId:e.rightId;return{...Qt,leftId:t}}case`setSplitRatio`:return{...e,splitRatio:$t(t.ratio)};default:return e}}var tn=(0,G.createContext)(null),nn=900;function rn({children:e}){let[t,n]=(0,G.useReducer)(en,Qt),{tickets:r,updateTicket:i,deleteTicket:a}=Ie(),{activeProjectId:o,setActiveProjectId:s}=P(),c=(0,G.useRef)(null);(0,G.useEffect)(()=>{n({type:`closeAll`});let e=c.current;e&&(c.current=null,e.projectId===o&&n({type:`openCentered`,id:e.ticketId}))},[o]);let l=(0,G.useCallback)(e=>n({type:`openCentered`,id:e}),[]),u=(0,G.useCallback)((e,t)=>{if(e===o){n({type:`openCentered`,id:t});return}c.current={projectId:e,ticketId:t},s(e)},[o,s]),d=(0,G.useCallback)(()=>n({type:`closeAll`}),[]),f=(0,G.useCallback)((e,t)=>{typeof window<`u`&&window.innerWidth<nn||n({type:`enterSplit`,side:e,ticketId:t})},[]),p=(0,G.useCallback)((e,t)=>n({type:`setComparedTicket`,id:e,side:t}),[]),m=(0,G.useCallback)(()=>n({type:`exitSplit`}),[]),h=(0,G.useCallback)(e=>n({type:`setSplitRatio`,ratio:e}),[]);(0,G.useEffect)(()=>{if(typeof window>`u`)return;function e(){window.innerWidth<nn&&n({type:`exitSplit`})}return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let g=(0,G.useMemo)(()=>{let e=new Set;for(let t of r)for(let n of t.labels??[])e.add(n);return Array.from(e).sort()},[r]),_=t.leftId==null?null:r.find(e=>e.id===t.leftId)??null,v=t.rightId==null?null:r.find(e=>e.id===t.rightId)??null,y=(0,G.useMemo)(()=>({openTicketDetail:l,openTicketDetailInProject:u,closeTicketDetail:d,enterSplit:f,setComparedTicket:p,exitSplit:m,setSplitRatio:h,state:t}),[l,u,d,f,p,m,h,t]),b=t.originSide!==null;return(0,q.jsxs)(tn.Provider,{value:y,children:[e,!b&&_&&(0,q.jsx)(Un,{ticket:_,allLabels:g,allTickets:r,onClose:d,onOpenTicket:l,onSave:i,onDelete:a},_.id),b&&(0,q.jsx)(Jt,{state:t,leftTicket:_,rightTicket:v,allTickets:r,allLabels:g,onSave:i,onDelete:a,onOpenTicket:l,onCloseAll:d,onSetCompared:p,onSetRatio:h,onExitSplit:m})]})}function an(){return(0,G.useContext)(tn)||{openTicketDetail:()=>{typeof console<`u`&&console.warn(`[TicketDetailModalContext] openTicketDetail called without provider`)},openTicketDetailInProject:()=>{typeof console<`u`&&console.warn(`[TicketDetailModalContext] openTicketDetailInProject called without provider`)},closeTicketDetail:()=>{},enterSplit:()=>{},setComparedTicket:()=>{},exitSplit:()=>{},setSplitRatio:()=>{},state:Qt}}function on(e){return e<.005?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function sn(e){return e<1e3?`${e} ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.floor(e%6e4/1e3)}s`}function cn({ticketId:e}){let{t}=p(`tickets`),[n,r]=(0,G.useState)(null),i=a(),{activeProjectId:o}=P(),{closeTicketDetail:s}=an();if((0,G.useEffect)(()=>{let t=new AbortController;return r(null),fetch(`${N()}/tickets/${e}/spending-summary`,{signal:t.signal}).then(e=>e.ok?e.json():null).then(e=>{e&&r(e)}).catch(()=>{}),()=>t.abort()},[e,o]),!n||!n.bySurface||!n.totalRuns||n.totalRuns===0)return null;let c=Object.entries(n.bySurface).filter(([,e])=>e.count>0).map(([e,n])=>t(`spendingLine.breakdownItem`,{n:n.count,label:Se[e].toLowerCase()})).join(` + `);return(0,q.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),s(),i(`/analytics?ticketId=${e}`)},className:`mt-1.5 group inline-flex items-center gap-1.5 text-[11px] text-muted-foreground hover:text-foreground transition-colors cursor-pointer`,"aria-label":t(`spendingLine.ariaLabel`),children:[(0,q.jsxs)(`span`,{className:`tabular-nums font-medium text-foreground`,title:(n.estimatedCostUsd??0)>0?t(`spendingLine.estimatedTooltip`):void 0,children:[(n.estimatedCostUsd??0)>0?`~`:``,on(n.totalCostUsd)]}),(0,q.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:t(`spendingLine.turns`,{count:n.totalTurns})}),(0,q.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,q.jsx)(`span`,{className:`tabular-nums`,children:t(`spendingLine.active`,{duration:sn(n.activeDurationMs)})}),c&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,q.jsx)(`span`,{children:c})]}),(0,q.jsx)(v,{className:`w-3 h-3 opacity-0 group-hover:opacity-100 transition-opacity`})]})}var ln=/^\d{4}-\d{2}-\d{2}T/;function un(e){if(ln.test(e))try{return{text:R(gt(e),{addSuffix:!0,locale:s()}),title:e}}catch{}return{text:e}}function dn({localId:e}){let{t}=p(`jira`),{activeProjectId:n}=P(),r=Ze(),[i,a]=(0,G.useState)(null);if((0,G.useEffect)(()=>{if(!Ge||!r.connected)return;let t=!1;return a(null),L.getSpecDetails(e).then(e=>{t||a(e)}).catch(()=>{t||a(null)}),()=>{t=!0}},[e,n,r.connected]),!Ge||!r.connected||!i)return null;let o=i.development,s=i.fields.length>0,c=o.pullRequests.length>0,l=o.branches.length>0,u=(o.commits?.length??0)>0;return!s&&!c&&!l&&!u?null:(0,q.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-details-panel`,children:[s&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:t(`detail.detailsTitle`)}),(0,q.jsx)(`div`,{className:`space-y-1.5`,children:i.fields.map((e,t)=>{let n=un(e.value);return(0,q.jsxs)(`div`,{className:`text-xs`,children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block`,children:e.label}),e.href?(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{Q(e.href)},className:`inline-flex items-center gap-1 text-accent-info hover:underline text-left`,children:[(0,q.jsx)(`span`,{className:`truncate`,children:e.value}),(0,q.jsx)(ee,{className:`w-3 h-3 shrink-0`})]}):(0,q.jsx)(`span`,{className:`text-foreground/80 whitespace-pre-line`,title:n.title,children:n.text})]},`${e.label}-${t}`)})})]}),(c||l||u)&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:t(`detail.developmentTitle`)}),c&&(0,q.jsxs)(`div`,{className:`mb-2`,children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.pullRequests`)}),(0,q.jsx)(`div`,{className:`space-y-1`,children:o.pullRequests.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{Q(e.url)},className:`w-full flex items-start gap-1.5 text-left text-xs hover:bg-accent-info/10 rounded px-1 py-0.5`,"data-testid":`jira-dev-pr`,children:[(0,q.jsx)(De,{className:`w-3 h-3 mt-0.5 shrink-0 text-accent-info`}),(0,q.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,q.jsx)(`span`,{className:`truncate text-foreground/80 block`,children:e.title}),(0,q.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[e.status,e.sourceBranch?` · ${e.sourceBranch} → ${e.destBranch??``}`:``]})]})]},e.url))})]}),l&&(0,q.jsxs)(`div`,{className:`mb-2`,children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.branches`)}),(0,q.jsx)(`div`,{className:`space-y-1`,children:o.branches.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{Q(e.url)},className:`w-full flex items-center gap-1.5 text-left text-xs hover:bg-accent-info/10 rounded px-1 py-0.5`,"data-testid":`jira-dev-branch`,children:[(0,q.jsx)(k,{className:`w-3 h-3 shrink-0 text-accent-info`}),(0,q.jsx)(`span`,{className:`truncate font-mono text-foreground/80`,children:e.name}),e.repo&&(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate`,children:e.repo})]},e.url))})]}),u&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.commits`)}),(0,q.jsx)(`div`,{className:`space-y-1`,children:o.commits.map(e=>(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{Q(e.url)},className:`w-full flex items-center gap-1.5 text-left text-xs hover:bg-accent-info/10 rounded px-1 py-0.5`,"data-testid":`jira-dev-commit`,children:[(0,q.jsx)(B,{className:`w-3 h-3 shrink-0 text-accent-info`}),(0,q.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground shrink-0`,children:e.displayId}),(0,q.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.message})]},e.url))})]})]})]})}var fn=e(r(),1);function pn({open:e,url:t,projectId:n,onClose:r}){let{t:i}=p(`browser`),a=C({projectId:n,open:e,initialUrl:t}),{canvasRef:o,viewport:s,status:c,errorMsg:l,url:u,title:d,popup:f}=a,[m,h]=(0,G.useState)(t),S=(0,G.useRef)(a.forwardInput);S.current=a.forwardInput;let T=(0,G.useRef)(null),E=(0,G.useCallback)(()=>(T.current??=b(e=>S.current(e)),T.current),[]);(0,G.useEffect)(()=>()=>{T.current?.dispose(),T.current=null},[]),(0,G.useEffect)(()=>{u&&h(u)},[u]),(0,G.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,r]);let D=(0,G.useCallback)((e,t)=>{let n=o.current?.getBoundingClientRect();return n?_({x:e,y:t},{left:n.left,top:n.top,width:n.width,height:n.height},s):{x:0,y:0}},[o,s]),te=e=>e===2?`right`:e===1?`middle`:`left`,O=(0,G.useCallback)(e=>{let t=D(e.clientX,e.clientY);E().move(t.x,t.y)},[D,E]),ne=(0,G.useCallback)(e=>{let t=D(e.clientX,e.clientY),n=E();n.move(t.x,t.y),n.flush(),a.forwardInput({type:`mouse`,action:`down`,x:t.x,y:t.y,button:te(e.button),clickCount:e.detail||1})},[D,a,E]),k=(0,G.useCallback)(e=>{let t=D(e.clientX,e.clientY),n=E();n.move(t.x,t.y),n.flush(),a.forwardInput({type:`mouse`,action:`up`,x:t.x,y:t.y,button:te(e.button),clickCount:e.detail||1})},[D,a,E]),re=(0,G.useCallback)(e=>{let t=D(e.clientX,e.clientY);E().wheel(t.x,t.y,e.deltaX,e.deltaY)},[D,E]),ie=(0,G.useCallback)(e=>{if(e.key===`Escape`)return;let t=e.metaKey||e.ctrlKey;if(t&&(e.key===`c`||e.key===`v`||e.key===`x`)){e.preventDefault();let t=e.key;(async()=>{try{if(t===`v`){let e=await navigator.clipboard.readText();e&&await a.clipboard(`paste`,e)}else{let{text:e}=await a.clipboard(t===`x`?`cut`:`copy`);e&&await navigator.clipboard.writeText(e)}}catch{}})();return}let n={type:`key`,action:`down`,key:e.key,code:e.code,text:!t&&e.key.length===1?e.key:void 0};a.forwardInput(n),(e.key===`Tab`||e.key===` `||e.key.startsWith(`Arrow`))&&e.preventDefault()},[a]),ae=(0,G.useCallback)(e=>{e.key!==`Escape`&&a.forwardInput({type:`key`,action:`up`,key:e.key,code:e.code})},[a]),oe=(0,G.useCallback)(()=>{a.navigate(`goto`,m)},[a,m]);return!e||typeof document>`u`?null:(0,fn.createPortal)((0,q.jsx)(`div`,{className:`fixed inset-0 z-[80] bg-background-deep/50 backdrop-blur-sm pointer-events-auto`,onClick:e=>{e.target===e.currentTarget&&r()},"data-testid":`webview-modal`,children:(0,q.jsxs)(`div`,{className:`absolute inset-2 flex flex-col border border-border rounded-lg bg-background-deep overflow-hidden`,role:`dialog`,"aria-modal":`true`,"aria-label":i(`modal.dialogLabel`),onClick:e=>e.stopPropagation(),children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-1.5 border-b border-border/50 bg-surface/80 shrink-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,q.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`common:actions.back`),onClick:()=>a.navigate(`back`),children:(0,q.jsx)(g,{className:`w-4 h-4`})}),(0,q.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.nav.forward`),onClick:()=>a.navigate(`forward`),children:(0,q.jsx)(v,{className:`w-4 h-4`})}),(0,q.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.nav.reload`),onClick:()=>a.navigate(`reload`),children:(0,q.jsx)(x,{className:`w-4 h-4`})})]}),(0,q.jsxs)(`form`,{className:`flex-1 flex items-center gap-2 min-w-0`,onSubmit:e=>{e.preventDefault(),oe()},children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-2 flex-1 min-w-0 rounded-md border border-border bg-background px-2.5 py-1`,children:[(0,q.jsx)(y,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,q.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),oe())},placeholder:i(`modal.address.placeholder`),"aria-label":i(`modal.address.label`),className:`flex-1 min-w-0 bg-transparent outline-none text-sm`})]}),(0,q.jsx)(F,{type:`submit`,size:`sm`,variant:`secondary`,className:`shrink-0`,disabled:c===`error`,children:i(`modal.address.go`)})]}),(0,q.jsx)(F,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.closeBrowser`),onClick:r,children:(0,q.jsx)(ue,{className:`w-4 h-4`})})]}),(0,q.jsxs)(`div`,{className:`px-3 py-1 text-[11px] text-muted-foreground truncate shrink-0 flex items-center gap-2`,children:[(0,q.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full shrink-0 ${c===`ready`?`bg-accent-success`:c===`error`?`bg-destructive`:`bg-accent-warning animate-pulse`}`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`truncate`,children:c===`connecting`?i(`modal.status.connecting`):c===`error`?l??i(`modal.status.unavailable`):d||``})]}),f&&(0,q.jsxs)(`div`,{"data-testid":`webview-popup-bar`,className:`flex items-center gap-2 px-3 py-1.5 text-xs border-b shrink-0 ${f.active?`bg-accent-info/10 border-accent-info/30 text-accent-info`:`bg-surface/70 border-border/40 text-muted-foreground`}`,children:[(0,q.jsx)(ee,{className:`w-3.5 h-3.5 shrink-0`}),f.active?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(`span`,{className:`truncate font-medium`,children:i(`popup.loginWindow`,{origin:w(f.url)})}),f.count>1&&(0,q.jsx)(`span`,{className:`shrink-0 opacity-70`,children:i(`popup.stacked`,{count:f.count-1})}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>a.setPopupView(`root`),className:`ml-auto shrink-0 inline-flex items-center gap-1 h-6 px-2 rounded-md border border-current/30 hover:bg-card/60 transition-colors`,children:[(0,q.jsx)(g,{className:`w-3 h-3`}),i(`popup.backToPage`)]})]}):(0,q.jsxs)(`button`,{type:`button`,onClick:()=>a.setPopupView(`popup`),className:`inline-flex items-center gap-1 h-6 px-2 rounded-md border border-border/50 hover:bg-card/60 hover:text-foreground transition-colors`,children:[i(`popup.show`),f.count>1&&(0,q.jsx)(`span`,{className:`opacity-70`,children:i(`popup.stacked`,{count:f.count-1})})]})]}),(0,q.jsx)(`div`,{className:`relative flex-1 min-h-0 overflow-hidden flex items-center justify-center outline-none`,tabIndex:0,onKeyDown:ie,onKeyUp:ae,children:c===`error`?(0,q.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center max-w-md px-6`,children:[(0,q.jsx)(le,{className:`w-8 h-8 text-accent-warning`}),(0,q.jsx)(`p`,{className:`text-sm text-foreground/90`,children:l??i(`modal.error.unavailable`)})]}):(0,q.jsx)(`canvas`,{ref:o,className:`max-w-full max-h-full block shadow-2xl cursor-default`,onPointerMove:O,onPointerDown:ne,onPointerUp:k,onContextMenu:e=>e.preventDefault(),onWheel:re})})]})}),document.body)}var mn=(0,G.createContext)(null);function hn({children:e}){let{activeProjectId:t}=P(),[n,r]=(0,G.useState)(null),i=(0,G.useCallback)(e=>r(e),[]),a=S();return(0,q.jsxs)(mn.Provider,{value:{openWebView:i,canOpenWebView:a&&!!t},children:[e,a&&n&&t&&(0,q.jsx)(pn,{open:!0,url:n,projectId:t,onClose:()=>r(null)})]})}function gn(){return(0,G.useContext)(mn)??{openWebView:()=>{},canOpenWebView:!1}}var _n={analyzing:`activity:smash.stage.analyzing`,identifying:`activity:smash.stage.identifying`,ordering:`activity:smash.stage.ordering`},vn=(0,G.createContext)(null);function $(e){return`smash:${e}`}async function yn(e,t){try{let n=await fetch(`${j}/api/projects/${e}/tickets/${t}/smash`,{method:`POST`});if(n.ok)h.loading(u.t(`activity:smash.retrying`),{id:$(t)});else{let e=await n.json().catch(()=>({}));h.error(e.reason?u.t(`activity:smash.couldNotRetryWithReason`,{reason:e.reason}):u.t(`activity:smash.couldNotRetry`),{id:$(t)})}}catch(e){h.error(u.t(`activity:smash.retryFailed`,{message:e.message}),{id:$(t)})}}async function bn(e,t,n){try{let r=await fetch(`${j}/api/projects/${e}/tickets/${t}/smash/undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({smashedAt:n})});if(r.ok)h.success(u.t(`activity:smash.undone`),{id:$(t),duration:3e3});else{let e=await r.json().catch(()=>({}));h.error(e.reason?u.t(`activity:smash.undoFailedWithReason`,{reason:e.reason}):u.t(`activity:smash.undoFailed`),{id:$(t)})}}catch(e){h.error(u.t(`activity:smash.undoFailedWithReason`,{reason:e.message}),{id:$(t)})}}function xn({children:e}){let{registerHandler:t,unregisterHandler:n}=M(),[r,i]=(0,G.useState)({}),a=(0,G.useRef)(new Map),o=(0,G.useRef)(new Map),s=(0,G.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.started`)return;let n=t.ticketId,r=t.runId,o=t.projectId,s=t.timestamp,c=t.ticketTitle;typeof n!=`number`||!r||!o||(a.current.set(n,o),i(e=>({...e,[n]:{ticketId:n,runId:r,stage:`analyzing`,startedAt:s??new Date().toISOString(),ticketTitle:c}})),h.loading(u.t(_n.analyzing),{id:$(n),description:c?u.t(`activity:smash.onTitled`,{title:c}):u.t(`activity:smash.onThisSpec`)}))},[]),c=(0,G.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.progress`)return;let n=t.ticketId,r=t.stage;if(typeof n!=`number`||!r)return;let a;i(e=>{let t=e[n];return t?(a=t.ticketTitle,{...e,[n]:{...t,stage:r}}):e}),h.loading(u.t(_n[r]),{id:$(n),description:a?u.t(`activity:smash.onTitled`,{title:a}):u.t(`activity:smash.onThisSpec`)})},[]),l=(0,G.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.completed`)return;let n=t.ticketId,r=t.runId,a=t.projectId,s=t.smashedAt,c=t.childrenIds;typeof n!=`number`||!r||!a||!s||!c||(o.current.set(r,s),i(e=>{let t={...e};return delete t[n],t}),h.success(u.t(`activity:smash.split`,{count:c.length}),{id:$(n),duration:1e4,action:{label:u.t(`activity:smash.undoAction`),onClick:()=>void bn(a,n,s)}}))},[]),d=(0,G.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.failed`)return;let n=t.ticketId,r=t.projectId,o=t.reason??`unknown`;if(typeof n!=`number`||!r)return;a.current.set(n,r),i(e=>{let t={...e};return delete t[n],t});let s=o===`invalid-output`?u.t(`activity:smash.failReason.invalidOutput`):o===`timeout`?u.t(`activity:smash.failReason.timeout`):o===`model_error`?u.t(`activity:smash.failReason.modelError`):o===`crashed`?u.t(`activity:smash.failReason.crashed`):u.t(`activity:smash.failReason.generic`,{reason:o});h.error(u.t(`activity:smash.couldNotComplete`),{id:$(n),description:s,action:{label:u.t(`common:actions.retry`),onClick:()=>void yn(r,n)},duration:15e3})},[]),f=(0,G.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.undone`)return;let n=t.ticketId;typeof n==`number`&&(h.dismiss($(n)),h.success(u.t(`activity:smash.undone`),{id:$(n),duration:3e3}))},[]);(0,G.useLayoutEffect)(()=>(t(`_smash_started`,s),t(`_smash_progress`,c),t(`_smash_completed`,l),t(`_smash_failed`,d),t(`_smash_undone`,f),()=>{n(`_smash_started`),n(`_smash_progress`),n(`_smash_completed`),n(`_smash_failed`),n(`_smash_undone`)}),[t,n,s,c,l,d,f]),(0,G.useEffect)(()=>()=>{a.current.clear(),o.current.clear()},[]);let p=(0,G.useMemo)(()=>({inflight:r}),[r]);return(0,q.jsx)(vn.Provider,{value:p,children:e})}function Sn(e){let t=(0,G.useContext)(vn);return!t||e==null?null:t.inflight[e]??null}var Cn=150,wn={analyzing:0,identifying:1,ordering:2},Tn={analyzing:`smash.stage.analyzing`,identifying:`smash.stage.identifying`,ordering:`smash.stage.ordering`};function En({stage:e,minDisplayMs:t=Cn}){let{t:n}=p(`activity`),[r,i]=(0,G.useState)(e),a=(0,G.useRef)(Date.now()),o=(0,G.useRef)(null);if((0,G.useEffect)(()=>{if(e===r)return;let n=Date.now()-a.current,s=Math.max(0,t-n);return o.current&&clearTimeout(o.current),o.current=setTimeout(()=>{i(e),a.current=Date.now(),o.current=null},s),()=>{o.current&&clearTimeout(o.current)}},[e,r,t]),!r)return null;let s=wn[r];return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 rounded-md border border-accent-highlight/40 bg-accent-highlight/10 text-sm text-foreground`,role:`status`,"aria-live":`polite`,"data-testid":`smash-status-pills`,children:[(0,q.jsx)(re,{className:`h-4 w-4 animate-spin text-accent-highlight`,"aria-hidden":!0}),(0,q.jsx)(`div`,{className:`flex items-center gap-1.5`,children:[`analyzing`,`identifying`,`ordering`].map(e=>(0,q.jsx)(`span`,{className:[`inline-block w-1.5 h-1.5 rounded-full transition-all`,wn[e]<=s?`bg-accent-highlight`:`bg-muted`,e===r?`scale-125`:`scale-100`].join(` `),"aria-hidden":!0},e))}),(0,q.jsx)(`span`,{className:`font-medium`,children:n(Tn[r])})]})}var Dn={simple:{titleKey:`smashModal.modes.simple.title`,bulletKeys:[`smashModal.modes.simple.bullet1`,`smashModal.modes.simple.bullet2`,`smashModal.modes.simple.bullet3`],etaKey:`smashModal.modes.simple.eta`},full:{titleKey:`smashModal.modes.full.title`,bulletKeys:[`smashModal.modes.full.bullet1`,`smashModal.modes.full.bullet2`,`smashModal.modes.full.bullet3`,`smashModal.modes.full.bullet4`],etaKey:`smashModal.modes.full.eta`}};function On({open:e,ticketTitle:t,isReSmash:n,childrenCount:r,submitting:i=!1,onCancel:a,onConfirm:o}){let{t:s}=p(`activity`),[c,l]=(0,G.useState)(`simple`),{panelRef:u,panelStyle:d,headerHandleProps:m,resizeHandles:h,isFloating:g,guardBackdrop:_}=pe();return e?(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[60] flex items-center justify-center`,role:`dialog`,"aria-modal":`true`,"data-testid":`smash-confirm-modal`,children:[(0,q.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:_(a)}),(0,q.jsxs)(`div`,{ref:u,className:`relative w-full max-w-lg m-4 rounded-xl glass-card border border-border/30 animate-in fade-in zoom-in-95 duration-150`,style:d,children:[(0,q.jsxs)(`div`,{...m,className:`flex items-start justify-between gap-3 px-5 py-4 border-b border-border/30 ${g?`cursor-grab active:cursor-grabbing`:``}`,children:[(0,q.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,q.jsx)(H,{className:`w-5 h-5 text-accent-highlight shrink-0 mt-0.5`,"aria-hidden":!0}),(0,q.jsxs)(`div`,{className:`min-w-0`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:s(`smashModal.title`)}),(0,q.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate`,title:t,children:t})]})]}),(0,q.jsx)(`button`,{type:`button`,onClick:a,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors shrink-0`,"aria-label":s(`common:actions.close`),children:(0,q.jsx)(ue,{className:`w-4 h-4`})})]}),n&&r>0&&(0,q.jsx)(`div`,{className:`mx-5 mt-4 rounded-md border border-accent-warning/40 bg-accent-warning/10 px-3 py-2 text-xs text-foreground`,children:(0,q.jsx)(f,{t:s,i18nKey:`smashModal.reSmashWarning`,count:r})}),(0,q.jsxs)(`div`,{className:`px-5 py-4 space-y-3`,children:[(0,q.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-medium`,children:s(`smashModal.modePickerLabel`)}),[`simple`,`full`].map(e=>{let t=Dn[e],n=c===e;return(0,q.jsx)(`button`,{type:`button`,onClick:()=>l(e),disabled:i,className:`w-full text-left rounded-lg border px-3 py-3 transition-colors ${n?`border-accent-highlight/60 bg-accent-highlight/10`:`border-border/40 bg-card/40 hover:bg-card/60 hover:border-border/60`}`,"data-testid":`smash-mode-${e}`,children:(0,q.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,q.jsx)(`div`,{className:`mt-0.5 h-3.5 w-3.5 rounded-full border-2 shrink-0 ${n?`border-accent-highlight bg-accent-highlight`:`border-muted-foreground/60`}`,"aria-hidden":!0}),(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,q.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[e===`full`&&(0,q.jsx)(de,{className:`w-3.5 h-3.5 text-accent-highlight`,"aria-hidden":!0}),s(t.titleKey)]}),(0,q.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:s(t.etaKey)})]}),(0,q.jsx)(`ul`,{className:`space-y-0.5`,children:t.bulletKeys.map(e=>(0,q.jsxs)(`li`,{className:`text-[11px] text-foreground/70 leading-snug`,children:[`• `,s(e)]},e))})]})]})},e)})]}),(0,q.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-5 py-3 border-t border-border/30 bg-surface/20`,children:[(0,q.jsx)(F,{variant:`ghost`,size:`sm`,onClick:a,disabled:i,children:s(`common:actions.cancel`)}),(0,q.jsxs)(F,{size:`sm`,onClick:()=>o(c),disabled:i,"data-testid":`smash-confirm-modal-continue`,children:[(0,q.jsx)(H,{className:`w-3.5 h-3.5 mr-1.5`}),s(i?`smashModal.starting`:n?`smashModal.confirmReSmash`:`smashModal.smash`)]})]})]}),(0,q.jsx)(ve,{handles:h})]}):null}var kn=`## Contract Layer`;function An(e,t){return!(!t||e.status===`draft`||e.parent_epic_id!=null||!e.description?.includes(kn))}function jn({ticket:e,projectId:t,featureFlagOn:n,childrenCount:r}){let{t:i}=p(`activity`),a=Sn(e.id),[o,s]=(0,G.useState)(!1),[c,l]=(0,G.useState)(!1),u=e.is_epic===!0,d=!u&&An(e,n),f=u&&n,m=u&&r>0,g=(0,G.useCallback)(async n=>{l(!0);try{let r=await fetch(`${j}/api/projects/${t}/tickets/${e.id}/smash`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({mode:n})});if(!r.ok){let e=await r.json().catch(()=>({}));h.error(e.reason?i(`smash.couldNotStartWithReason`,{reason:e.reason}):i(`smash.couldNotStart`));return}s(!1)}catch(e){h.error(i(`smash.smashFailed`,{message:e.message}))}finally{l(!1)}},[t,e.id,i]),_=(0,G.useCallback)(async n=>{if(m){l(!0);try{if(!(await fetch(`${j}/api/projects/${t}/tickets/${e.id}/children`,{method:`DELETE`})).ok){h.error(i(`smash.couldNotDeleteChildren`)),l(!1);return}}catch(e){h.error(i(`smash.deleteFailed`,{message:e.message})),l(!1);return}}await g(n)},[m,g,t,e.id,i]);return!d&&!f?null:a?(0,q.jsx)(`div`,{className:`flex flex-col gap-2`,"data-testid":`smash-actions-streaming`,children:(0,q.jsx)(En,{stage:a.stage})}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(F,{size:`sm`,variant:`outline`,onClick:()=>s(!0),className:`border-accent-highlight/40 text-accent-highlight hover:bg-accent-highlight/10`,"data-testid":f?`resmash-button`:`smash-button`,children:[(0,q.jsx)(H,{className:`w-3.5 h-3.5 mr-1.5`}),i(f?`smash.reSmashButton`:`smash.smashButton`)]}),(0,q.jsx)(On,{open:o,ticketTitle:e.title,isReSmash:m,childrenCount:r,submitting:c,onCancel:()=>s(!1),onConfirm:_})]})}function Mn({epic:e,childExecutionOrder:t,totalChildren:n,onOpenEpic:r}){let{t:i}=p(`activity`);return(0,q.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-accent-secondary/30 bg-accent-secondary/10 px-3 py-1.5 text-xs`,"data-testid":`epic-breadcrumb`,children:[(0,q.jsxs)(`button`,{type:`button`,onClick:r,className:`text-accent-secondary hover:underline font-medium`,children:[`← `,e.title]}),t!=null&&n>0&&(0,q.jsx)(`span`,{className:`text-foreground/60`,children:i(`epicChildren.step`,{order:t,total:n})})]})}var Nn={critical:`bg-red-400`,high:`bg-orange-400`,medium:`bg-yellow-400`,low:`bg-slate-400`};function Pn(e){return e?Nn[e]:`bg-muted`}function Fn(e){return[...e].sort((e,t)=>{let n=e.execution_order??1/0,r=t.execution_order??1/0;return n===r?e.id-t.id:n-r})}function In({ticket:e,allTickets:t,onOpenTicket:n}){let{t:r}=p(`activity`),i=e.is_epic===!0,a=e.parent_epic_id!=null;if(!i&&!a)return null;if(i){let i=Fn(t.filter(t=>t.parent_epic_id===e.id));return(0,q.jsx)(Ln,{header:r(`family.subSpecsHeader`,{count:i.length}),rows:i,currentId:e.id,onOpenTicket:n,emptyMessage:r(`family.emptySubSpecs`)})}let o=t.find(t=>t.id===e.parent_epic_id)??null,s=Fn(t.filter(t=>t.parent_epic_id===e.parent_epic_id)),c=o?[o,...s]:s;return(0,q.jsx)(Ln,{header:r(`family.familyHeader`,{count:s.length}),rows:c,currentId:e.id,onOpenTicket:n,emptyMessage:r(`family.noSiblings`)})}function Ln({header:e,rows:t,currentId:n,onOpenTicket:r,emptyMessage:i}){let{t:a}=p(`activity`);return(0,q.jsxs)(`div`,{"data-testid":`epic-family-sidebar`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,q.jsx)(H,{className:`w-3 h-3 text-accent-highlight`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:e})]}),t.length===0?(0,q.jsx)(`p`,{className:`text-[10px] text-foreground/50 italic`,children:i}):(0,q.jsx)(`ul`,{className:`flex flex-col gap-0.5`,children:t.map(e=>{let t=e.id===n,i=e.is_epic===!0;return(0,q.jsx)(`li`,{children:(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{t||r(e.id)},disabled:t,"aria-label":a(i?`family.openParentEpic`:`family.openSubSpec`,{title:e.title}),"aria-current":t?`page`:void 0,className:[`w-full flex items-center gap-1.5 rounded px-1.5 py-1 text-left transition-colors`,t?`bg-accent-highlight/15 cursor-default`:`hover:bg-muted/30 cursor-pointer`].join(` `),"data-testid":`epic-family-row-${e.id}`,children:[i?(0,q.jsx)(E,{className:`w-3 h-3 text-accent-highlight flex-shrink-0`,"aria-hidden":!0}):(0,q.jsx)(`span`,{className:`text-[9px] tabular-nums text-foreground/40 w-3 text-center flex-shrink-0`,children:e.execution_order??`–`}),(0,q.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full flex-shrink-0 ${Pn(e.priority)}`,"aria-hidden":!0}),(0,q.jsx)(`span`,{className:`text-[11px] truncate ${t?`text-foreground font-medium`:`text-foreground/80`}`,title:e.title,children:e.title})]})},e.id)})})]})}var Rn=900,zn=.2,Bn=[{value:`critical`,labelKey:`priority.critical`,className:`text-red-400`},{value:`high`,labelKey:`priority.high`,className:`text-orange-400`},{value:`medium`,labelKey:`priority.medium`,className:`text-yellow-400`},{value:`low`,labelKey:`priority.low`,className:`text-slate-400`}];function Vn(e){return e.jira_epic_key&&e.jira_url?e.jira_url.replace(/\/browse\/[^/]+$/,`/browse/${e.jira_epic_key}`):null}var Hn={manual:`source.manual`,"product-backlog":`source.productBacklog`,"propose-spec":`source.proposeSpec`,"get-backlog-specs":`source.getBacklogSpecs`,"free-prompt":`source.freePrompt`};function Un({ticket:e,allLabels:t,allTickets:n,onClose:r,onOpenTicket:i,onSave:a,onDelete:o,rails:s,onMoveToRail:c,onRemoveFromRail:l,embedded:u=!1}){let{t:d}=p(`tickets`),{t:m}=p(`jira`),{activeProjectId:g,projects:_}=P(),{enterSplit:y,state:b}=an(),x=b.originSide!==null,S=_.find(e=>e.id===g)?.provider!==`codex`,C=(0,G.useMemo)(()=>(n??[]).filter(t=>t.parent_epic_id===e.id),[n,e.id]),w=(0,G.useMemo)(()=>e.parent_epic_id==null?null:(n??[]).find(t=>t.id===e.parent_epic_id)??null,[n,e.parent_epic_id]),T=(0,G.useMemo)(()=>w?(n??[]).filter(e=>e.parent_epic_id===w.id).length:0,[n,w]),[E,D]=(0,G.useState)(e.title),[O,ne]=(0,G.useState)(e.description),[k,ae]=(0,G.useState)(e.priority??`medium`),[A,le]=(0,G.useState)([...e.labels??[]]),[de,j]=(0,G.useState)(!1),[M,N]=(0,G.useState)(!1),[I,L]=(0,G.useState)(``),[be,xe]=(0,G.useState)(!1),[R,Se]=(0,G.useState)(!1),[Ce,we]=(0,G.useState)(!1),[Ee,z]=(0,G.useState)(!1),[B,De]=(0,G.useState)(!1),[V,H]=(0,G.useState)(!1),U=Ze(),W=U.connected&&!!U.discardStatus&&e.source===`jira`&&!!e.jira_key,Oe=U.connected&&e.source===`jira`&&!!e.jira_key,[ke,Ae]=(0,G.useState)(e.attachments??[]);(0,G.useEffect)(()=>{Ae(e.attachments??[])},[e.attachments,e.id]);let je=(0,G.useRef)(null),Me=(0,G.useRef)(null),Ne=(0,G.useRef)(null),K=(0,G.useMemo)(()=>E!==e.title||O!==e.description||k!==e.priority||JSON.stringify(A)!==JSON.stringify(e.labels),[E,O,k,A,e]);(0,G.useEffect)(()=>{de&&je.current?.focus()},[de]),(0,G.useEffect)(()=>{if(M){let e=Me.current;e&&(e.focus(),e.selectionStart=e.value.length)}},[M]),(0,G.useEffect)(()=>{be&&Ne.current?.focus()},[be]),(0,G.useEffect)(()=>{function e(e){e.key===`Escape`&&!de&&!M&&!R&&r()}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,de,M,R]);let Pe=(0,G.useMemo)(()=>{if(!I.trim())return[];let e=I.toLowerCase();return t.filter(t=>t.toLowerCase().includes(e)&&!A.includes(t)).slice(0,5)},[I,t,A]),Fe=(0,G.useCallback)(e=>{let t=e.trim();t&&!A.includes(t)&&le(e=>[...e,t]),L(``)},[A]),Ie=(0,G.useCallback)(e=>{le(t=>t.filter(t=>t!==e))},[]),Le=(0,G.useCallback)(async()=>{let t={};if(E!==e.title&&(t.title=E),O!==e.description&&(t.description=O),k!==e.priority&&(t.priority=k),JSON.stringify(A)!==JSON.stringify(e.labels)&&(t.labels=A),Object.keys(t).length===0){r();return}De(!0);let n=await a(e.id,t);De(!1),n?(h.success(d(`detailModal.toast.updated`)),r()):h.error(d(`detailModal.toast.updateFailed`))},[E,O,k,A,e,a,r,d]),Re=(0,G.useCallback)(async()=>{if(V)return;H(!0);let t=!1;try{t=await o(e.id)}catch{t=!1}if(H(!1),!t){h.error(d(`detailModal.toast.deleteFailed`));return}Se(!1),r()},[V,e.id,o,r,d]),[ze,Be]=(0,G.useState)(0),J=(0,G.useRef)(null),[Ve,He]=(0,G.useState)(()=>typeof window<`u`&&window.innerWidth>=Rn);(0,G.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>He(window.innerWidth>=Rn);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let Y=!u&&!x&&Ve,X=(0,G.useCallback)(e=>{J.current&&Be(e.clientX-J.current.startX)},[]),Z=(0,G.useCallback)(t=>{if(!J.current)return;let n=t.clientX-J.current.startX,i=window.innerWidth*zn;if(window.removeEventListener(`pointermove`,X),window.removeEventListener(`pointerup`,Z),window.removeEventListener(`pointercancel`,Z),J.current=null,Be(0),Math.abs(n)>=i&&window.innerWidth>=Rn){let t=b.leftId===e.id;y(n<0?`left`:`right`,e.id),t||r()}},[y,X,b.leftId,e.id,r]),Ue=(0,G.useCallback)(e=>{Y&&e.button===0&&(e.target.closest(`button, input, textarea, select, [contenteditable="true"]`)||(J.current={startX:e.clientX,pointerId:e.pointerId},window.addEventListener(`pointermove`,X),window.addEventListener(`pointerup`,Z),window.addEventListener(`pointercancel`,Z)))},[Y,X,Z]);(0,G.useEffect)(()=>()=>{J.current&&(window.removeEventListener(`pointermove`,X),window.removeEventListener(`pointerup`,Z),window.removeEventListener(`pointercancel`,Z))},[X,Z]);let We=(0,G.useCallback)(()=>{if(!Y||window.innerWidth<Rn)return;let t=b.leftId===e.id;y(`right`,e.id),t||r()},[Y,y,b.leftId,e.id,r]),{panelRef:Ge,panelStyle:Ke,resizeHandles:qe,guardBackdrop:Je}=pe({enabled:!u,allowMove:!1}),Ye=(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(`div`,{ref:Ge,className:u?`relative w-full h-full rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 flex flex-col overflow-hidden`:`relative w-full max-w-[67rem] m-4 rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 flex flex-col animate-in fade-in zoom-in-95 duration-200 h-[90vh]`,style:{...ze===0?{transition:`transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1)`}:{transform:`translateX(${ze}px)`,transition:`none`},...Ke},children:[w&&(0,q.jsx)(`div`,{className:`px-5 pt-3`,children:(0,q.jsx)(Mn,{epic:w,childExecutionOrder:e.execution_order??null,totalChildren:T,onOpenEpic:()=>i?.(w.id)})}),(0,q.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-5 py-4 border-b border-border/30 ${Y?`cursor-grab active:cursor-grabbing`:``}`,onPointerDown:Ue,"data-testid":`ticket-modal-header`,children:[(0,q.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[de?(0,q.jsx)(`input`,{ref:je,value:E,onChange:e=>D(e.target.value),onBlur:()=>j(!1),onKeyDown:t=>{t.key===`Enter`&&j(!1),t.key===`Escape`&&(D(e.title),j(!1))},className:`w-full bg-transparent border-b border-accent-primary/50 text-sm font-semibold text-foreground outline-none pb-0.5`}):(0,q.jsxs)(`button`,{type:`button`,onClick:()=>j(!0),className:`group flex items-center gap-1.5 text-left w-full`,children:[(0,q.jsx)(`h2`,{className:`text-sm font-semibold text-foreground truncate`,children:E||d(`untitled`)}),(0,q.jsx)(ie,{className:`w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0`})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,q.jsxs)(`span`,{className:`text-[10px] text-foreground font-mono`,children:[`#`,e.id]}),e.status===`on_review`&&(0,q.jsx)(`span`,{title:d(`specs:status.onReviewHint`),"data-testid":`ticket-modal-on-review-badge`,children:(0,q.jsx)(tt,{status:`on_review`})})]}),(0,q.jsx)(cn,{ticketId:e.id})]}),g&&(0,q.jsx)(`div`,{className:`shrink-0`,children:(0,q.jsx)(jn,{ticket:e,projectId:g,featureFlagOn:S,childrenCount:C.length})}),(0,q.jsx)(Gn,{ticket:e,title:E,description:O,priority:k,labels:A,onClose:r}),s&&(c||l)&&(0,q.jsx)(Kn,{ticket:e,rails:s,onMoveToRail:c,onRemoveFromRail:l}),Y&&(0,q.jsxs)(F,{variant:`outline`,size:`sm`,className:`shrink-0 mr-1 gap-1.5`,"data-testid":`ticket-modal-compare`,onClick:We,title:d(`detailModal.compareTooltip`),children:[(0,q.jsx)(Te,{className:`w-3.5 h-3.5`}),d(`detailModal.compare`)]}),(0,q.jsx)(`button`,{onClick:r,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors cursor-pointer shrink-0`,"data-testid":`ticket-modal-close`,children:(0,q.jsx)(ue,{className:`w-4 h-4`})})]}),(0,q.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:(0,q.jsxs)(`div`,{className:`flex flex-col sm:flex-row h-full`,children:[(0,q.jsxs)(`div`,{className:`flex-1 min-w-0 px-5 py-4 space-y-4 flex flex-col`,children:[(0,q.jsxs)(`div`,{className:`flex-1 flex flex-col`,children:[(0,q.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5`,children:d(`fields.description`)}),!M&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>N(!0),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,q.jsx)(ie,{className:`w-2.5 h-2.5`}),d(`common:actions.edit`)]})]}),M?(0,q.jsxs)(`div`,{className:`space-y-1.5 flex-1 flex flex-col`,children:[(0,q.jsx)(`textarea`,{ref:Me,value:O,onChange:e=>ne(e.target.value),className:`w-full flex-1 rounded-lg border border-border bg-input px-3 py-2 text-xs text-foreground placeholder:text-muted-foreground resize-none min-h-[300px]`,placeholder:d(`fields.markdownPlaceholder`)}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,q.jsx)(F,{variant:`ghost`,size:`sm`,className:`h-6 text-[10px]`,onClick:()=>N(!1),children:d(`detailModal.doneEditing`)}),(0,q.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:d(`fields.supportsMarkdown`)})]})]}):O?(0,q.jsx)(Xn,{description:O,onEdit:()=>N(!0)}):(0,q.jsx)(`button`,{type:`button`,onClick:()=>N(!0),className:`w-full rounded-lg border border-dashed border-border/40 bg-muted/10 px-3 py-4 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/20 transition-colors text-center`,children:d(`detailModal.addDescription`)})]}),(0,q.jsx)(Vt,{ticketKey:e.id,attachments:ke,onChange:Ae}),(0,q.jsx)(Ht,{ticketId:e.id,onClose:r}),e.prerequisites&&e.prerequisites.length>0&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`detailModal.prerequisites`)}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.prerequisites.map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[10px] font-mono bg-accent/60 text-foreground/70`,children:[`#`,e]},e))})]})]}),(0,q.jsxs)(`div`,{className:`sm:w-56 sm:border-l border-t sm:border-t-0 border-border/30 px-4 py-4 space-y-4 bg-muted/5`,children:[e.jira_url&&e.jira_key&&(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{Q(e.jira_url)},"data-testid":`jira-go-to-ticket`,className:`w-full inline-flex items-center justify-center gap-1.5 h-7 rounded border border-accent-info/50 bg-accent-info/10 px-2 text-xs font-medium text-accent-info hover:bg-accent-info/20 transition-colors`,children:[(0,q.jsx)(ee,{className:`w-3.5 h-3.5 shrink-0`}),m(`detail.goToTicket`,{key:e.jira_key})]}),e.jira_epic_key&&(0,q.jsxs)(`div`,{"data-testid":`jira-epic`,children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:m(`detail.epic`)}),(0,q.jsxs)(`button`,{type:`button`,onClick:()=>{let t=Vn(e);t&&Q(t)},title:e.jira_epic_name??e.jira_epic_key,className:`w-full inline-flex items-center gap-1.5 rounded border border-accent-highlight/40 bg-accent-highlight/5 px-2 py-1.5 text-left text-xs hover:bg-accent-highlight/10 transition-colors`,children:[(0,q.jsx)(`span`,{className:`font-mono text-accent-highlight shrink-0`,children:e.jira_epic_key}),e.jira_epic_name&&(0,q.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.jira_epic_name})]})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`fields.priority`)}),(0,q.jsx)(`select`,{value:k,onChange:e=>ae(e.target.value),className:`w-full h-7 rounded border border-border bg-input px-2 text-xs text-foreground`,children:Bn.map(e=>(0,q.jsx)(`option`,{value:e.value,children:d(e.labelKey)},e.value))})]}),(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`fields.labels`)}),(0,q.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:A.map(e=>(0,q.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 rounded px-1.5 py-0.5 text-[10px] font-medium bg-accent/60 text-foreground/70 group`,children:[e,(0,q.jsx)(`button`,{type:`button`,onClick:()=>Ie(e),className:`text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,q.jsx)(te,{className:`w-2.5 h-2.5`})})]},e))}),be?(0,q.jsxs)(`div`,{className:`relative`,children:[(0,q.jsx)(`input`,{ref:Ne,value:I,onChange:e=>L(e.target.value),onKeyDown:e=>{e.key===`Enter`&&I.trim()&&(e.preventDefault(),Fe(I)),e.key===`Escape`&&(xe(!1),L(``))},onBlur:()=>{I.trim()&&Fe(I),xe(!1),L(``)},placeholder:d(`detailModal.addLabelPlaceholder`),className:`w-full h-6 rounded border border-border bg-input px-2 text-[10px] text-foreground placeholder:text-muted-foreground`}),Pe.length>0&&(0,q.jsx)(`div`,{className:`absolute left-0 right-0 top-full mt-0.5 rounded border border-border/50 bg-popover shadow-lg z-10 py-0.5`,children:Pe.map(e=>(0,q.jsx)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),Fe(e)},className:`w-full text-left px-2 py-1 text-[10px] hover:bg-accent/50 text-foreground/80`,children:e},e))})]}):(0,q.jsxs)(`button`,{type:`button`,onClick:()=>xe(!0),className:`flex items-center gap-1 text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:[(0,q.jsx)(oe,{className:`w-2.5 h-2.5`}),d(`detailModal.addLabel`)]})]}),(0,q.jsx)(In,{ticket:e,allTickets:n??[],onOpenTicket:e=>i?.(e)}),e.source===`jira`&&e.jira_key&&(0,q.jsx)(dn,{localId:e.id}),e.metadata?.effort_level&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-0.5`,children:d(`detailModal.effort`)}),(0,q.jsx)(`span`,{className:`text-xs text-foreground/70`,children:e.metadata.effort_level})]}),e.assignee&&(0,q.jsxs)(`div`,{children:[(0,q.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-0.5`,children:d(`detailModal.assignee`)}),(0,q.jsx)(`span`,{className:`text-xs text-foreground/70`,children:e.assignee})]})]})]})}),(0,q.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-t border-border/30`,children:[(0,q.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground`,children:[(0,q.jsx)(`span`,{children:d(`meta.createdAgo`,{time:Wn(e.created_at)})}),(0,q.jsx)(`span`,{children:d(`meta.updatedAgo`,{time:Wn(e.updated_at)})}),e.source&&(0,q.jsx)(`span`,{className:`bg-muted/30 rounded px-1.5 py-0.5`,children:Hn[e.source]?d(Hn[e.source]):e.source})]}),(0,q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[W?(0,q.jsxs)(F,{variant:`ghost`,size:`sm`,className:`h-7 text-xs text-accent-info hover:bg-accent-info/10`,onClick:()=>we(!0),"data-testid":`jira-move-to-button`,children:[(0,q.jsx)(v,{className:`w-3 h-3 mr-1`}),m(`discard.moveButton`,{status:U.discardStatus})]}):(0,q.jsxs)(F,{variant:`ghost`,size:`sm`,className:`h-7 text-xs text-red-400 aurora-light:text-destructive hover:text-red-300 aurora-light:hover:text-destructive hover:bg-red-500/10 aurora-light:hover:bg-destructive/10`,onClick:()=>Se(!0),children:[(0,q.jsx)(ce,{className:`w-3 h-3 mr-1`}),d(`common:actions.delete`)]}),K&&(0,q.jsxs)(F,{size:`sm`,className:`h-7 text-xs`,onClick:()=>{Oe?z(!0):Le()},disabled:B||!E.trim(),children:[(0,q.jsx)(se,{className:`w-3 h-3 mr-1`}),d(B?`common:states.saving`:`common:actions.save`)]})]})]})]}),(0,q.jsx)(ye,{open:R,onOpenChange:e=>{V||Se(e)},children:(0,q.jsxs)(he,{className:`max-w-sm`,children:[(0,q.jsxs)(fe,{children:[(0,q.jsx)(ge,{children:d(`deleteDialog.title`)}),(0,q.jsx)(_e,{children:(0,q.jsx)(f,{t:d,i18nKey:`deleteDialog.body`,values:{id:e.id,title:e.title},components:{strong:(0,q.jsx)(`span`,{className:`font-semibold text-foreground`})}})})]}),(0,q.jsxs)(me,{children:[(0,q.jsx)(F,{variant:`outline`,size:`sm`,onClick:()=>Se(!1),disabled:V,children:d(`common:actions.cancel`)}),(0,q.jsxs)(F,{variant:`destructive`,size:`sm`,onClick:()=>{Re()},disabled:V,"aria-busy":V,children:[V?(0,q.jsx)(re,{className:`w-3.5 h-3.5 mr-1.5 animate-spin`}):(0,q.jsx)(ce,{className:`w-3.5 h-3.5 mr-1.5`}),d(`common:actions.delete`)]})]})]})}),W&&U.discardStatus&&(0,q.jsx)(Qe,{open:Ce,onOpenChange:we,ticket:{id:e.id,title:e.title,jira_key:e.jira_key},discardStatus:U.discardStatus,onDiscarded:r}),(0,q.jsx)(ye,{open:Ee,onOpenChange:z,children:(0,q.jsxs)(he,{className:`max-w-md`,"data-testid":`jira-save-confirm`,children:[(0,q.jsxs)(fe,{children:[(0,q.jsx)(ge,{children:m(`detail.saveTitle`)}),(0,q.jsx)(_e,{children:m(`detail.saveBody`,{key:e.jira_key??`#${e.id}`})})]}),(0,q.jsxs)(me,{children:[(0,q.jsx)(F,{variant:`outline`,size:`sm`,onClick:()=>z(!1),children:d(`common:actions.cancel`)}),(0,q.jsxs)(F,{size:`sm`,onClick:()=>{z(!1),Le()},disabled:B,"data-testid":`jira-save-confirm-btn`,children:[(0,q.jsx)(se,{className:`w-3.5 h-3.5 mr-1.5`}),m(`detail.saveConfirm`)]})]})]})})]});return u?Ye:(0,q.jsxs)(`div`,{className:`fixed inset-0 z-[68] flex items-center justify-center`,children:[(0,q.jsx)(`div`,{className:`absolute inset-0 bg-black/70`,onClick:Je(r)}),Ye,(0,q.jsx)(ve,{handles:qe})]})}function Wn(e){try{return R(new Date(e),{addSuffix:!0,locale:s()})}catch{return e}}function Gn({ticket:e,title:t,description:n,priority:r,labels:i,onClose:a}){let{t:o}=p(`tickets`),{triggerResume:s}=T(),{activeProjectId:c}=P(),{closeTicketDetail:l}=an();return Y(e)?(0,q.jsxs)(F,{variant:`default`,size:`sm`,onClick:()=>{if(!c)return;let{body:u,criteria:d}=Ve(n);s({kind:`explore-spec`,projectId:c,label:t||e.title||o(`detailModal.ticketFallbackLabel`,{id:e.id}),restoreRoute:`/`,params:{initialIdea:``,pendingSpecId:X(),initialAttachmentIds:[],resumeConversationId:e.origin_conversation_id??void 0,editTicket:{id:e.id,title:t,description:u,labels:i,priority:r,acceptanceCriteria:d,status:e.status}}}),l(),a()},className:`shrink-0 mr-2`,"data-testid":`continue-editing`,children:[(0,q.jsx)(V,{className:`w-3.5 h-3.5 mr-1.5`}),o(`detailModal.continueEditing`)]}):null}function Kn({ticket:e,rails:t,onMoveToRail:n,onRemoveFromRail:r}){let{t:i}=p(`tickets`),[a,o]=(0,G.useState)(null),s=(0,G.useRef)(null),c=t.find(t=>t.ticketIds.includes(e.id));return c?r?(0,q.jsxs)(F,{variant:`outline`,size:`sm`,className:`shrink-0 mr-2 gap-1.5 border-accent-warning/30 text-accent-warning hover:bg-accent-warning/10 hover:text-accent-warning`,"data-testid":`modal-remove-from-rail`,onClick:()=>r(e.id),title:i(`rail.currentlyOn`,{rail:c.label}),children:[(0,q.jsx)(g,{className:`w-3.5 h-3.5`,"aria-hidden":!0}),i(`rail.removeFromRail`)]}):null:n?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsxs)(F,{ref:s,variant:`outline`,size:`sm`,className:`shrink-0 mr-2 gap-1.5 border-accent-info/30 text-accent-info hover:bg-accent-info/10 hover:text-accent-info`,"data-testid":`modal-move-to-rail`,onClick:()=>{s.current&&o(s.current.getBoundingClientRect())},children:[i(`rail.moveToRail`),(0,q.jsx)(v,{className:`w-3.5 h-3.5`,"aria-hidden":!0})]}),a&&(0,q.jsx)(Be,{rails:t,anchorRect:a,onMoveToRail:t=>n(e.id,t),onClose:()=>o(null)})]}):null}var qn=`
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Contract Layer
|
|
13
|
+
|
|
14
|
+
`;function Jn(e){let t=e.indexOf(qn);return t<0?{user:e,contract:null}:{user:e.slice(0,t),contract:e.slice(t+26)}}function Yn(e){let t=[`### Naming Contract`,`### Data Shapes`,`### State Machine`,`### Invariants`,`### File Touch List`],n=0;for(let r of t){let t=e.indexOf(r);if(t<0)continue;let i=e.slice(t+r.length),a=i.indexOf(`N/A — model did not produce items`),o=i.indexOf(`### `);a>=0&&(o<0||a<o)||n++}return n}function Xn({description:e,onEdit:t}){let{t:n}=p(`tickets`),{openWebView:r}=gn(),{user:i,contract:a}=Jn(e),o=i||e,s=(0,G.useMemo)(()=>({a:({href:e,children:t})=>(0,q.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,onClick:t=>{typeof e==`string`&&/^https?:\/\//i.test(e)&&(t.preventDefault(),t.stopPropagation(),r(e))},children:t})}),[r]);return(0,q.jsxs)(`div`,{className:`flex-1 rounded-lg bg-muted/20 px-3 py-2 overflow-y-auto transition-colors`,onClick:e=>{e.target.closest(`details, summary`)||t()},role:`button`,style:{cursor:`pointer`},children:[(0,q.jsx)(`div`,{className:`prose prose-invert prose-xs max-w-none prose-p:my-1 prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold prose-ul:my-1 prose-ol:my-1 prose-li:my-0 prose-code:text-cyan-300 prose-code:text-[10px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded text-foreground/80 text-xs`,children:(0,q.jsx)(be,{remarkPlugins:[xe],components:s,children:o})}),a&&(0,q.jsxs)(`details`,{"data-testid":`contract-layer-disclosure`,className:`mt-3 rounded-md border border-border/40 bg-muted/10 px-2 py-1`,onClick:e=>e.stopPropagation(),children:[(0,q.jsxs)(`summary`,{className:`cursor-pointer text-[10px] font-medium text-foreground/80 select-none flex items-center gap-2`,children:[n(`contractLayer.title`),(0,q.jsx)(`span`,{className:`rounded-full bg-muted/40 px-1.5 text-[9px] text-foreground/60`,children:n(`contractLayer.populated`,{n:Yn(a)})})]}),(0,q.jsx)(`div`,{className:`mt-2 prose prose-invert prose-xs max-w-none prose-p:my-1 prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold prose-ul:my-1 prose-ol:my-1 prose-li:my-0 prose-code:text-cyan-300 prose-code:text-[10px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded text-foreground/80 text-xs`,children:(0,q.jsx)(be,{remarkPlugins:[xe],components:s,children:a})})]})]})}export{Be as A,Te as B,Ye as C,X as D,Z as E,V as F,De as I,B as L,ke as M,Ae as N,Y as O,U as P,z as R,Ge as S,Xe as T,we as V,Ze as _,rn as a,Je as b,pt as c,ct as d,it as f,Qe as g,et as h,gn as i,Ie as j,Ve as k,Q as l,nt as m,xn as n,an as o,ft as p,hn as r,mt as s,Un as t,ht as u,Ue as v,Ke as w,We as x,qe as y,Ee as z};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,t}from"./rolldown-runtime-CNC7AqOf.js";import{n}from"./jsx-runtime-zu2_FqZY.js";import{S as r}from"./i18n-
|
|
1
|
+
import{a as e,t}from"./rolldown-runtime-CNC7AqOf.js";import{n}from"./jsx-runtime-zu2_FqZY.js";import{S as r}from"./i18n-Bf9Ckd10.js";import{a as i,d as a,f as o,i as s,l as c,p as l,s as u,u as d}from"./createLucideIcon-Bjbbp_KS.js";var f=t(((e,t)=>{t.exports={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}})),p=e(n()),m=e(f()),h=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function g(e){var t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(m.default[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){var r=e.indexOf(`-->`);return{type:`comment`,comment:r===-1?``:e.slice(4,r)}}for(var i=new RegExp(h),a=null;(a=i.exec(e))!==null;)if(a[0].trim())if(a[1]){var o=a[1].trim(),s=[o,``];o.indexOf(`=`)>-1&&(s=o.split(`=`)),t.attrs[s[0]]=s[1],i.lastIndex--}else a[2]&&(t.attrs[a[2]]=a[3].trim().substring(1,a[3].length-1));return t}var _=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,v=/^\s*$/,y=Object.create(null);function b(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:return e+=`<`+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+`="`+e[n]+`"`);return t.length?` `+t.join(` `):``}(t.attrs):``)+(t.voidElement?`/>`:`>`),t.voidElement?e:e+t.children.reduce(b,``)+`</`+t.name+`>`;case`comment`:return e+`<!--`+t.comment+`-->`}}var x={parse:function(e,t){t||={},t.components||=y;var n,r=[],i=[],a=-1,o=!1;if(e.indexOf(`<`)!==0){var s=e.indexOf(`<`);r.push({type:`text`,content:s===-1?e:e.substring(0,s)})}return e.replace(_,function(s,c){if(o){if(s!==`</`+n.name+`>`)return;o=!1}var l,u=s.charAt(1)!==`/`,d=s.startsWith(`<!--`),f=c+s.length,p=e.charAt(f);if(d){var m=g(s);return a<0?(r.push(m),r):((l=i[a]).children.push(m),r)}if(u&&(a++,(n=g(s)).type===`tag`&&t.components[n.name]&&(n.type=`component`,o=!0),n.voidElement||o||!p||p===`<`||n.children.push({type:`text`,content:e.slice(f,e.indexOf(`<`,f))}),a===0&&r.push(n),(l=i[a-1])&&l.children.push(n),i[a]=n),(!u||n.voidElement)&&(a>-1&&(n.voidElement||n.name===s.slice(2,-1))&&(a--,n=a===-1?r:i[a]),!o&&p!==`<`&&p)){l=a===-1?r:i[a].children;var h=e.indexOf(`<`,f),_=e.slice(f,h===-1?void 0:h);v.test(_)&&(_=` `),(h>-1&&a+l.length>=0||_!==` `)&&l.push({type:`text`,content:_})}}),r},stringify:function(e){return e.reduce(function(e,t){return e+b(``,t)},``)}},S=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},C=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?T(t):t},w=e=>Array.isArray(e)&&e.every(p.isValidElement),T=e=>Array.isArray(e)?e:[e],E=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},D=e=>{let t={};if(!e)return t;let n=e=>{T(e).forEach(e=>{a(e)||(S(e)?n(C(e)):d(e)&&!(0,p.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},O=(e,t,n,r)=>{if(!e)return``;let i=``,s=T(e),c=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return s.forEach((e,s)=>{if(a(e)){i+=`${e}`;return}if((0,p.isValidElement)(e)){let{props:o,type:l}=e,u=Object.keys(o).length,d=c.indexOf(l)>-1,f=o.children;if(!f&&d&&!u){i+=`<${l}/>`;return}if(!f&&(!d||u)||o.i18nIsDynamicList){i+=`<${s}></${s}>`;return}if(d&&u<=1){let e=a(f)?f:O(f,t,n,r);i+=`<${l}>${e}</${l}>`;return}let p=O(f,t,n,r);i+=`<${s}>${p}</${s}>`;return}if(e===null){o(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(d(e)){let{format:t,...a}=e,s=Object.keys(a);if(s.length===1){let e=t?`${s[0]}, ${t}`:s[0];i+=`{{${e}}}`;return}o(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}o(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},k=(e,t=[],n={})=>{if(!e)return e;let r=Object.keys(n),i=[...t,...r],a=``,o=0;for(;o<e.length;)if(e[o]===`<`){let t=!1,n=e.slice(o).match(/^<\/(\d+|[a-zA-Z][a-zA-Z0-9_-]*)>/);if(n){let e=n[1];(/^\d+$/.test(e)||i.includes(e))&&(t=!0,a+=n[0],o+=n[0].length)}if(!t){let n=e.slice(o).match(/^<(\d+|[a-zA-Z][a-zA-Z0-9_-]*)(\s+[\w-]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?)*\s*(\/)?>/);if(n){let e=n[1];(/^\d+$/.test(e)||i.includes(e))&&(t=!0,a+=n[0],o+=n[0].length)}}t||(a+=`<`,o+=1)}else a+=e[o],o+=1;return a},A=(e,t,n,r,i,o,s)=>{if(n===``)return[];let l=i.transKeepBasicHtmlNodesFor||[],f=n&&new RegExp(l.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!f&&!s)return[n];let m=t??{},h=e=>{T(e).forEach(e=>{a(e)||(S(e)?h(C(e)):d(e)&&!(0,p.isValidElement)(e)&&Object.assign(m,e))})};h(e);let g=k(n,l,m),_=x.parse(`<0>${g}</0>`),v={...m,...o},y=(e,t,n)=>{let r=C(e),i=D(r,t.children,n);return w(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},b=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,p.cloneElement)(e,{key:r},i?void 0:t))):n.push(...p.Children.map([e],e=>{if(e.type===p.Fragment||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`children`||t===`i18nIsDynamicList`||(n[t]=e.props[t])}),(0,p.createElement)(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`ref`||t===`children`||(n[t]=e.props[t])}),(0,p.cloneElement)(e,n,i?null:t)}))},D=(e,n,o)=>{let m=T(e),h=T(n),g={};return h.reduce((e,n,h)=>{let _=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,v,r.language);if(n.type===`tag`){let u=m[parseInt(n.name,10)];!u&&t&&(u=t[n.name]),o.length===1&&!u&&(u=o[0][n.name]),u||={};let x={...n.attrs};s&&Object.keys(x).forEach(e=>{let t=x[e];a(t)&&(x[e]=c(t))});let w=Object.keys(x).length===0?u:E({props:x},u),O=(0,p.isValidElement)(w),k=O&&S(n,!0)&&!n.voidElement,A=f&&d(w)&&w.dummy&&!O,j=d(t)&&Object.hasOwnProperty.call(t,n.name);if(a(w)){let t=r.services.interpolator.interpolate(w,v,r.language);e.push(t)}else if(S(w)||k){let t=y(w,n,o);b(w,t,e,h)}else if(A){let t=D(m,n.children,o);b(w,t,e,h)}else if(Number.isNaN(parseFloat(n.name)))if(j){let t=y(w,n,o);b(w,t,e,h,n.voidElement)}else if(i.transSupportBasicHtmlNodes&&l.indexOf(n.name)>-1)if(n.voidElement)e.push((0,p.createElement)(n.name,{key:`${n.name}-${h}`}));else{let t=g[n.name]||0;g[n.name]=t+1;let r,i=0;for(let e=0;e<m.length;e+=1){let a=m[e];if((0,p.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let a=r?T(C(r)):m,s=D(a,n.children,o);e.push((0,p.createElement)(n.name,{key:`${n.name}-${h}`},s))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=D(m,n.children,o);e.push(`<${n.name}>${t}</${n.name}>`)}else if(d(w)&&!O){let t=n.children[0]?_:null;t&&e.push(t)}else b(w,_,e,h,n.children.length!==1||!_)}else if(n.type===`text`){let t=i.transWrapTextNodes,a=typeof i.unescape==`function`?i.unescape:u().unescape,o=s?a(r.services.interpolator.interpolate(n.content,v,r.language)):r.services.interpolator.interpolate(n.content,v,r.language);t?e.push((0,p.createElement)(t,{key:`${n.name}-${h}`},o)):e.push(o)}return e},[])};return C(D([{dummy:!0,children:e||[]}],_,T(e||[]))[0])},j=(e,t,n)=>{let r=e.key||t,i=(0,p.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,p.createElement)(p.Fragment,null,i)}return(0,p.createElement)(a,{key:r})},M=(e,t)=>e.map((e,n)=>j(e,n,t)),N=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:j(e[r],r,t)})}),n},P=(e,t,n,r)=>e?Array.isArray(e)?M(e,t):d(e)?N(e,t):(l(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,F=e=>!d(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function I({children:e,count:t,parent:n,i18nKey:o,context:s,tOptions:c={},values:d,defaults:f,components:m,ns:h,i18n:g,t:_,shouldUnescape:v,...y}){let b=g||i();if(!b)return l(b,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using i18nextReactModule`,{i18nKey:o}),e;let x=_||b.t.bind(b)||(e=>e),S={...u(),...b.options?.react},C=h||x.ns||b.options?.defaultNS;C=a(C)?[C]:C||[`translation`];let{transDefaultProps:w}=S,T=w?.tOptions?{...w.tOptions,...c}:c,E=v??w?.shouldUnescape,k=w?.values?{...w.values,...d}:d,j=w?.components?{...w.components,...m}:m,M=O(e,S,b,o),N=f||T?.defaultValue||M||S.transEmptyNodeValue||(typeof o==`function`?r(o):o),{hashTransKey:I}=S,L=o||(I?I(M||N):M||N);d=b.options?.interpolation?.defaultVariables?k&&Object.keys(k).length>0?{...k,...b.options.interpolation.defaultVariables}:{...b.options.interpolation.defaultVariables}:k;let R=D(e);R&&typeof R.count==`number`&&t===void 0&&(t=R.count);let z=d||t!==void 0&&!b.options?.interpolation?.alwaysFormat||!e?T.interpolation:{interpolation:{...T.interpolation,prefix:`#$?`,suffix:`?$#`}},B={...T,context:s||T.context,count:t,...d,...z,defaultValue:N,ns:C},V=L?x(L,B):N;V===L&&N&&(V=N);let H=P(j,V,b,o),U=H||e,W=null;F(H)&&(W=H,U=e);let G=A(U,W,V,b,S,B,E),K=n??S.defaultTransParent;return K?(0,p.createElement)(K,y,G):G}function L({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:o={},values:c,defaults:l,components:u,ns:d,i18n:f,t:m,shouldUnescape:h,...g}){let{i18n:_,defaultNS:v}=(0,p.useContext)(s)||{},y=f||_||i(),b=m||y?.t.bind(y);return I({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:o,values:c,defaults:l,components:u,ns:d||b?.ns||v||y?.options?.defaultNS,i18n:y,t:m,shouldUnescape:h,...g})}export{L as t};
|