specrails-desktop 2.62.0 → 2.63.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (181) hide show
  1. package/cli/dist/specrails-desktop.js +39 -5
  2. package/client/dist/assets/{ActivityFeedPage-C_pqc281.js → ActivityFeedPage-B1bpTy7O.js} +1 -1
  3. package/client/dist/assets/{AgentBrowserCapture-vz6rbDtu.js → AgentBrowserCapture-BussBbN3.js} +1 -1
  4. package/client/dist/assets/AgentModeAnalyticsPane-BiT1n3BU.js +2 -0
  5. package/client/dist/assets/AgentModeCodePane-CUjNfeKa.js +2 -0
  6. package/client/dist/assets/{AgentModeJobsPane-99fBBLri.js → AgentModeJobsPane-RVEwyS59.js} +1 -1
  7. package/client/dist/assets/AgentsPage-DKE-eMC5.js +118 -0
  8. package/client/dist/assets/AnalyticsPage-Bser2Ly3.js +1 -0
  9. package/client/dist/assets/BarChart-BDMqVFJy.js +55 -0
  10. package/client/dist/assets/CodePage-BK0grm6e.js +3 -0
  11. package/client/dist/assets/DesktopAnalyticsPage-DEBidZbs.js +1 -0
  12. package/client/dist/assets/{DocsDialog-XUCYKoq0.js → DocsDialog-Dhyo57n9.js} +1 -1
  13. package/client/dist/assets/{DocsPage-dOLC8bXA.js → DocsPage-BcEkPXd6.js} +1 -1
  14. package/client/dist/assets/{ExportDropdown-BvKQgwM9.js → ExportDropdown-mRmqdkjr.js} +1 -1
  15. package/client/dist/assets/IntegrationsPage-EAipiDWm.js +1 -0
  16. package/client/dist/assets/InteractiveJobComposer-BlCe3vrU.js +19 -0
  17. package/client/dist/assets/{JobDetailModal-CkiubrkZ.js → JobDetailModal-CkAejD1F.js} +1 -1
  18. package/client/dist/assets/{JobDetailPage-CNe4Wn7l.js → JobDetailPage-P-FS_lKz.js} +1 -1
  19. package/client/dist/assets/JobsPage-CoUXgYse.js +1 -0
  20. package/client/dist/assets/LoopBuilderPage-iFylNk68.js +1 -0
  21. package/client/dist/assets/{LoopPreviewModal-Dv3dxHr_.js → LoopPreviewModal-4obS_Ptg.js} +1 -1
  22. package/client/dist/assets/{LoopWindowSurface-DN2lbSnL.js → LoopWindowSurface-CLr5OPqj.js} +1 -1
  23. package/client/dist/assets/LoopsPage-eKpWFtCp.js +2 -0
  24. package/client/dist/assets/MinimizedChatsContext-BHIUPVmC.js +1 -0
  25. package/client/dist/assets/PluginsPage-BgTC2CQx.js +2 -0
  26. package/client/dist/assets/ProjectSettingsDialog-B4chTfU8.js +1 -0
  27. package/client/dist/assets/RepositoryDeliveries-DAIxIYsl.js +5 -0
  28. package/client/dist/assets/{RepositoryScopeSelector-DrtPqvc_.js → RepositoryScopeSelector-DeCoUsRN.js} +1 -1
  29. package/client/dist/assets/ReviewPacketPage-Cktv0-9b.js +4 -0
  30. package/client/dist/assets/{TemplatePreviewModal-DcFlhUxy.js → TemplatePreviewModal-BZTV1TM1.js} +1 -1
  31. package/client/dist/assets/TicketDetailModalContext-DiPngt2g.js +16 -0
  32. package/client/dist/assets/Trans-ZiXIfj50.js +1 -0
  33. package/client/dist/assets/{agentRuntime-TKQyg137.js → agentRuntime-BDvbJMmS.js} +1 -1
  34. package/client/dist/assets/{agentRuntime-DvhEe1um.js → agentRuntime-BKJfv5YD.js} +1 -1
  35. package/client/dist/assets/{agentRuntime-DxC6-9rN.js → agentRuntime-BxF81z52.js} +1 -1
  36. package/client/dist/assets/{agentRuntime-C_yLPKDy.js → agentRuntime-BxYS5V7u.js} +1 -1
  37. package/client/dist/assets/{agentRuntime-WSv8G0pW.js → agentRuntime-BzuwQQgn.js} +1 -1
  38. package/client/dist/assets/{agentRuntime-D2kYQqNO.js → agentRuntime-Dc9HG3BA.js} +1 -1
  39. package/client/dist/assets/{agentRuntime-Bjt7Ij6_.js → agentRuntime-DiCldqGG.js} +1 -1
  40. package/client/dist/assets/{agentRuntime-B-myNBUP.js → agentRuntime-es2ymSl-.js} +1 -1
  41. package/client/dist/assets/ban-wqfdzoXt.js +1 -0
  42. package/client/dist/assets/{button-D1xExSTF.js → button-4FS1ZDTp.js} +1 -1
  43. package/client/dist/assets/chevron-up-6EFqEHBj.js +1 -0
  44. package/client/dist/assets/chunk-OB3PAWPO-B1EMk45A.js +3 -0
  45. package/client/dist/assets/circle-x-D2ttKotB.js +1 -0
  46. package/client/dist/assets/createLucideIcon-DtODIU64.js +1 -0
  47. package/client/dist/assets/{dialog-CMgps2MY.js → dialog-DtdR05v1.js} +1 -1
  48. package/client/dist/assets/download-C9wP_42h.js +1 -0
  49. package/client/dist/assets/external-link-CZ6Q-v1-.js +1 -0
  50. package/client/dist/assets/file-text-C0blZHLh.js +1 -0
  51. package/client/dist/assets/{formatDistanceToNow-DlQY1Lm_.js → formatDistanceToNow-CdN5lTyD.js} +1 -1
  52. package/client/dist/assets/{getTimezoneOffsetInMilliseconds-COUeq65G.js → getTimezoneOffsetInMilliseconds-62h40I4t.js} +1 -1
  53. package/client/dist/assets/git-branch-yf6LE1Bw.js +1 -0
  54. package/client/dist/assets/index-BgbCbIua.css +2 -0
  55. package/client/dist/assets/{index-CONHvEJw.js → index-CECj3joE.js} +40 -40
  56. package/client/dist/assets/jira-api-C_D_RDhl.js +1 -0
  57. package/client/dist/assets/jsx-runtime-BbYvbtY8.js +1 -0
  58. package/client/dist/assets/layers-BCLTgHXO.js +1 -0
  59. package/client/dist/assets/{lib-C7Mhm-gT.js → lib-CQJT8S6Q.js} +1 -1
  60. package/client/dist/assets/{lib-CGdyxIWg.js → lib-DWJfei6y.js} +1 -1
  61. package/client/dist/assets/loader-circle-BqV9xYGf.js +1 -0
  62. package/client/dist/assets/{loop-layout-BF8xMiNv.js → loop-layout-CyXj9223.js} +1 -1
  63. package/client/dist/assets/pencil-CxrRbDwb.js +1 -0
  64. package/client/dist/assets/plus-fHDdjBk1.js +1 -0
  65. package/client/dist/assets/{project-repositories-Cc3oNv8X.js → project-repositories-Be0CWklo.js} +1 -1
  66. package/client/dist/assets/react-dom-DDD8FYaU.js +1 -0
  67. package/client/dist/assets/rotate-ccw-DalJAQQX.js +1 -0
  68. package/client/dist/assets/save-LmPSfsvZ.js +1 -0
  69. package/client/dist/assets/search-BDVp3fkH.js +1 -0
  70. package/client/dist/assets/{settings-BKJZ2KEM.js → settings-BO2N-oPf.js} +1 -1
  71. package/client/dist/assets/{settings-LfFnl1UH.js → settings-BQChAs_w.js} +1 -1
  72. package/client/dist/assets/{settings-BV3jocIx.js → settings-BzmYlcQB.js} +1 -1
  73. package/client/dist/assets/{settings-BjM2Dw8_.js → settings-CGjXb6TX.js} +1 -1
  74. package/client/dist/assets/{settings-DA77M48m.js → settings-CMxEWY46.js} +1 -1
  75. package/client/dist/assets/{settings-P1IQvhnL.js → settings-C_dRSgI2.js} +1 -1
  76. package/client/dist/assets/{settings-eIMJjyK_.js → settings-Hw7av-B1.js} +1 -1
  77. package/client/dist/assets/{settings-CKu0LTib.js → settings-nryN6wuS.js} +1 -1
  78. package/client/dist/assets/sparkles-CCfUdFGY.js +1 -0
  79. package/client/dist/assets/spending-eWiZGhC_.js +1 -0
  80. package/client/dist/assets/square-D0JTbRSR.js +1 -0
  81. package/client/dist/assets/trash-D8zYUmTg.js +1 -0
  82. package/client/dist/assets/triangle-alert-Cxpn8bqr.js +1 -0
  83. package/client/dist/assets/upload-CCHvUkRs.js +1 -0
  84. package/client/dist/assets/{useDesktop-9Lwoel_8.js → useDesktop-C0mRIlHT.js} +1 -1
  85. package/client/dist/assets/{useRuntimeRuns-DL0xYoZ2.js → useRuntimeRuns-B1a6GChu.js} +1 -1
  86. package/client/dist/assets/useSharedWebSocket-CcsE5986.js +2 -0
  87. package/client/dist/assets/{value-s-gzBeyF.js → value-DtOOK0wQ.js} +1 -1
  88. package/client/dist/assets/x-Bu7X_eR2.js +1 -0
  89. package/client/dist/assets/zap-bugHyWzQ.js +1 -0
  90. package/client/dist/index.html +44 -45
  91. package/docs/ci-cd.md +8 -1
  92. package/docs/customizing.md +1 -0
  93. package/docs/getting-started.md +1 -1
  94. package/docs/guide/de/settings/5-project-environment.md +27 -0
  95. package/docs/guide/en/settings/5-project-environment.md +27 -0
  96. package/docs/guide/es/settings/5-project-environment.md +27 -0
  97. package/docs/guide/fr/settings/5-project-environment.md +27 -0
  98. package/docs/guide/it/settings/5-project-environment.md +27 -0
  99. package/docs/guide/ja/settings/5-project-environment.md +27 -0
  100. package/docs/guide/pt/settings/5-project-environment.md +27 -0
  101. package/docs/guide/zh/settings/5-project-environment.md +27 -0
  102. package/docs/internals/api-reference.md +3 -1
  103. package/docs/internals/configuration.md +46 -5
  104. package/docs/internals/core-runtime-updates.md +3 -3
  105. package/docs/internals/desktop-owned-workflows.md +10 -0
  106. package/docs/internals/programmatic-agent-runtime.md +16 -0
  107. package/docs/internals/safe-pr-review-flow.md +15 -0
  108. package/docs/internals/source-map.md +6 -1
  109. package/docs/mcp.md +1 -1
  110. package/docs/platforms/macos.md +2 -0
  111. package/docs/platforms/windows-parity.md +4 -4
  112. package/docs/platforms/windows.md +9 -9
  113. package/local-runner/dist/specrails-local-runner.js +1 -1
  114. package/package.json +8 -9
  115. package/server/dist/mcp/tools/env.js +38 -3
  116. package/server/dist/mcp/tools/loops.js +1 -1
  117. package/server/dist/modules/agent-runtime/runtime/agent-runtime-bridge.js +13 -3
  118. package/server/dist/modules/delivery/runtime/rail-isolated-launch.js +1 -1
  119. package/server/dist/modules/execution/runtime/queue-manager.js +8 -0
  120. package/server/dist/modules/loops/runtime/loop-executors.js +1 -0
  121. package/server/dist/modules/loops/runtime/loop-implement-recipe.js +13 -6
  122. package/server/dist/modules/loops/runtime/loop-run-manager.js +7 -0
  123. package/server/dist/modules/loops/runtime/loop-turn-limits.js +64 -0
  124. package/server/dist/modules/loops/runtime/loops-router.js +3 -1
  125. package/server/dist/modules/missions/runtime/agent-operator-prompt.js +8 -0
  126. package/server/dist/modules/project-settings/adapters/http.js +24 -0
  127. package/server/dist/path-resolver.js +135 -20
  128. package/server/dist/project-env.js +265 -17
  129. package/server/dist/project-registry.js +14 -0
  130. package/server/dist/project-router-settings.js +17 -0
  131. package/server/dist/schemas/agent-runtime.schema.json +1 -1
  132. package/server/dist/worktree-node-modules.js +95 -1
  133. package/client/dist/assets/AgentModeAnalyticsPane-BHCcUahS.js +0 -2
  134. package/client/dist/assets/AgentModeCodePane-DhmxgG3W.js +0 -2
  135. package/client/dist/assets/AgentsPage-CTwm_6T8.js +0 -118
  136. package/client/dist/assets/AnalyticsPage-YD8MLoPa.js +0 -1
  137. package/client/dist/assets/BarChart-nBOMNfiy.js +0 -33
  138. package/client/dist/assets/CodePage-CLJn2F2e.js +0 -3
  139. package/client/dist/assets/DesktopAnalyticsPage-MWGQVbwp.js +0 -1
  140. package/client/dist/assets/IntegrationsPage-Bhy58lnQ.js +0 -1
  141. package/client/dist/assets/InteractiveJobComposer-DxOvwmBF.js +0 -19
  142. package/client/dist/assets/JobsPage-DSts_L_d.js +0 -1
  143. package/client/dist/assets/LoopBuilderPage-C9D9eer5.js +0 -1
  144. package/client/dist/assets/LoopsPage-DHgIreEW.js +0 -2
  145. package/client/dist/assets/MinimizedChatsContext-Ds2-R6qJ.js +0 -1
  146. package/client/dist/assets/PluginsPage-D1EJ9oja.js +0 -2
  147. package/client/dist/assets/ProjectSettingsDialog-DKpa1wKk.js +0 -1
  148. package/client/dist/assets/RepositoryDeliveries-CW4eKG3x.js +0 -5
  149. package/client/dist/assets/ReviewPacketPage-BtjPI0Cc.js +0 -4
  150. package/client/dist/assets/TicketDetailModalContext-Dea22CI-.js +0 -16
  151. package/client/dist/assets/Trans-CAY2Rd2f.js +0 -1
  152. package/client/dist/assets/ban-E4EaZe3a.js +0 -1
  153. package/client/dist/assets/chevron-up-CwGUHd6D.js +0 -1
  154. package/client/dist/assets/chunk-KS7C4IRE-DEKu087k.js +0 -3
  155. package/client/dist/assets/circle-x-CMYsN4ZH.js +0 -1
  156. package/client/dist/assets/createLucideIcon-Bjbbp_KS.js +0 -1
  157. package/client/dist/assets/dist-Bq10nS2m.js +0 -1
  158. package/client/dist/assets/download-CFHyyHcw.js +0 -1
  159. package/client/dist/assets/external-link-D6XxC_Cu.js +0 -1
  160. package/client/dist/assets/file-text-BcLCfcWZ.js +0 -1
  161. package/client/dist/assets/git-branch-BRM0F5GN.js +0 -1
  162. package/client/dist/assets/index-BacrO_ub.css +0 -2
  163. package/client/dist/assets/jira-api-C94VNHNY.js +0 -1
  164. package/client/dist/assets/jsx-runtime-zu2_FqZY.js +0 -1
  165. package/client/dist/assets/layers-eDMjG41I.js +0 -1
  166. package/client/dist/assets/loader-circle-DcygOQpC.js +0 -1
  167. package/client/dist/assets/pencil-C9RkrIPZ.js +0 -1
  168. package/client/dist/assets/plus-CsnjfkmX.js +0 -1
  169. package/client/dist/assets/react-dom-DiWzBDP9.js +0 -1
  170. package/client/dist/assets/rotate-ccw-Wh4id13q.js +0 -1
  171. package/client/dist/assets/save-B6wGWwBR.js +0 -1
  172. package/client/dist/assets/search-Cq_gE3Ik.js +0 -1
  173. package/client/dist/assets/sparkles-DrY8hb0X.js +0 -1
  174. package/client/dist/assets/spending-DemeFfrH.js +0 -1
  175. package/client/dist/assets/square-Ci-PFcFe.js +0 -1
  176. package/client/dist/assets/trash-2-BOU3WdZZ.js +0 -1
  177. package/client/dist/assets/triangle-alert-H9T4jAmh.js +0 -1
  178. package/client/dist/assets/upload-DYMjAQ6M.js +0 -1
  179. package/client/dist/assets/useSharedWebSocket-BEHPeU1Y.js +0 -2
  180. package/client/dist/assets/x-CBMI9ejn.js +0 -1
  181. package/client/dist/assets/zap-CHo3aCD1.js +0 -1
@@ -0,0 +1,4 @@
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-BbYvbtY8.js";import{d as r,f as i,u as a}from"./chunk-OB3PAWPO-B1EMk45A.js";import{n as ee,t as o}from"./createLucideIcon-DtODIU64.js";import{a as s,r as te}from"./useDesktop-C0mRIlHT.js";import{H as ne,K as re,n as ie}from"./TicketDetailModalContext-DiPngt2g.js";import{C as ae,E as oe,b as se,r as ce,t as le,w as ue}from"./RepositoryDeliveries-DAIxIYsl.js";import{n as de}from"./save-LmPSfsvZ.js";import{t as fe}from"./ban-wqfdzoXt.js";import{n as pe}from"./chevron-up-6EFqEHBj.js";import{n as c}from"./file-text-C0blZHLh.js";import{t as l}from"./loader-circle-BqV9xYGf.js";import{t as u}from"./sparkles-CCfUdFGY.js";import{t as me}from"./triangle-alert-Cxpn8bqr.js";import{t as he}from"./utils-BC4DHlz2.js";import{n as d,t as f}from"./lib-DWJfei6y.js";import{Tt as ge,Xt as p,xt as m,y as _e}from"./index-CECj3joE.js";var h={name:`circle-dollar-sign`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`,key:`1h4pet`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}]]};h.node;var ve=o(h),g={name:`file-diff`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]};g.node;var _=o(g),v=e(t(),1),y=n();function b(e){return e.split(/\n{2,}/).map(e=>{if(e.includes(`
2
+ `))return e;let t=e.match(/(?:^|\s)(\d{1,2})\.\s+(?=\S)/g);return!t||t.length<3?e:e.replace(/\s+(\d{1,2})\.\s+(?=\S)/g,(e,t,n)=>n===0?e:`\n${t}. `)}).join(`
3
+
4
+ `)}function x({children:e,muted:t=!1,className:n}){let r=(0,v.useMemo)(()=>({a:({href:e,children:t})=>(0,y.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,className:`text-accent-primary underline decoration-accent-primary/40 underline-offset-2 hover:decoration-accent-primary`,children:t}),img:()=>null,code:({className:e,children:t})=>e?(0,y.jsx)(`code`,{className:e,children:t}):(0,y.jsx)(`code`,{className:`rounded-md border border-border/50 bg-background-deep/60 px-1.5 py-px font-mono text-[0.85em] text-accent-info`,children:t})}),[]);return(0,y.jsx)(`div`,{"data-testid":`packet-markdown`,className:he(`prose prose-invert prose-sm max-w-none leading-relaxed`,`prose-p:my-1.5 prose-headings:mt-3 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold`,`prose-strong:text-foreground prose-ul:my-1.5 prose-ol:my-1.5 prose-li:my-0.5 prose-li:marker:text-accent-primary/70`,`prose-pre:my-2 prose-pre:rounded-lg prose-pre:border prose-pre:border-border/50 prose-pre:bg-background-deep/60 prose-pre:text-xs`,`prose-blockquote:border-accent-primary/40 prose-blockquote:text-muted-foreground prose-hr:border-border/50`,t?`text-muted-foreground`:`text-foreground/85`,n),children:(0,y.jsx)(d,{remarkPlugins:[f],skipHtml:!0,components:r,children:b(e)})})}var S=(e={})=>({verbs:[],acceptMeaning:null,fineControlOnly:!1,inFlight:!1,terminal:!1,requiresIrreversibleConfirm:!1,...e});function ye(e){let{decision:t,presentation:n,prUrl:r,canCreatePr:i}=e;if(t===`building`)return S({inFlight:!0});if(t===`merged`||t===`discarded`||n.superseded)return S({terminal:!0});if(n.manualRecovery||n.recoveryUnavailable||n.recoveryRecheck||n.retryablePush||n.retryablePrCreation||n.closed||n.deliveryBlocked&&!n.implementationFailed)return S({fineControlOnly:!0});if(n.noChanges)return S({verbs:[`accept`,`request-changes`],acceptMeaning:`mark-done`});if(n.implementationFailed)return S({verbs:n.succeededCount>0?[`request-changes`,`discard`]:[`discard`]});if(t===`pr_draft`)return S(r?{verbs:[`accept`,`request-changes`,`discard`],acceptMeaning:`publish`}:{fineControlOnly:!0});if(t===`pr_ready`)return S({verbs:[`request-changes`,`discard`]});if(t===`on_review`){let e=i?`create-pr`:`merge-local`;return S({verbs:[`accept`,`request-changes`,`discard`],acceptMeaning:e,requiresIrreversibleConfirm:e===`merge-local`})}return S({fineControlOnly:!0})}function be(e,t){if(e===`discard`)return`discard`;if(e===`request-changes`)return null;switch(t.acceptMeaning){case`create-pr`:return`create-pr`;case`publish`:return`publish`;case`merge-local`:return`merge-local`;case`mark-done`:return`acknowledge-no-changes`;default:return null}}var xe=[`app-verified`,`ai-reported`,`reviewer-score`],Se={"app-verified":m,"ai-reported":u,"reviewer-score":_},Ce={"app-verified":`text-accent-success border-accent-success/30 bg-accent-success/5`,"ai-reported":`text-accent-highlight border-accent-highlight/30 bg-accent-highlight/5`,"reviewer-score":`text-accent-info border-accent-info/30 bg-accent-info/5`};function C({item:e}){let{t}=ee(`packet`);return(0,y.jsxs)(`li`,{className:`flex flex-col gap-1 py-1.5`,children:[(0,y.jsx)(`span`,{className:`text-sm text-foreground`,children:t(e.code,{...e.values??{},defaultValue:e.code})}),e.rawExcerpt?(0,y.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded border border-border/60 bg-background-deep/60 p-2 text-[11px] leading-relaxed text-muted-foreground whitespace-pre-wrap`,children:e.rawExcerpt}):null]})}function we(e){return e.implementationOutcome===`failed`?`failed`:e.deliveryOutcome===`no_changes`||e.implementationOutcome===`succeeded`&&e.changed===!1?`noChanges`:e.deliveryOutcome===`not_started`?`notStarted`:e.implementationOutcome===`succeeded`?`succeeded`:`unknown`}var w={resolved:`border-accent-success/40 bg-accent-success/10 text-accent-success`,partial:`border-accent-warning/40 bg-accent-warning/10 text-accent-warning`,blocked:`border-destructive/40 bg-destructive/10 text-destructive`,unreported:`border-border bg-background-deep/50 text-muted-foreground`},Te={succeeded:`border-accent-success/40 bg-accent-success/10 text-accent-success`,noChanges:`border-accent-info/40 bg-accent-info/10 text-accent-info`,failed:`border-destructive/40 bg-destructive/10 text-destructive`,notStarted:`border-border bg-background-deep/50 text-muted-foreground`,unknown:`border-border bg-background-deep/50 text-muted-foreground`};function T({title:e,children:t,defaultOpen:n=!1,badge:r}){let[i,a]=(0,v.useState)(n);return(0,y.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-surface/40`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-2 px-4 py-3 text-left`,"aria-expanded":i,children:[i?(0,y.jsx)(p,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,y.jsx)(c,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,y.jsx)(`span`,{className:`flex-1 text-sm font-medium text-foreground`,children:e}),r]}),i?(0,y.jsx)(`div`,{className:`border-t border-border/60 px-4 py-3`,children:t}):null]})}function E(e={}){let t=r(),n=e.prDeliveryId??t.prDeliveryId,{t:o}=ee([`packet`,`common`]),c=a(),[u,he]=i(),d=u.get(`repositoryId`),f=(0,v.useRef)(0),p=e.onClose??(()=>c(`/`)),{activeProjectId:m}=te(),h=ce(m),g=n?h.has(n):!1,{act:_,checkout:b}=_e(),{openTicketDetail:S}=ie(),E=JSON.stringify([m,n,d]),D=(0,v.useRef)({key:E,epoch:0});D.current.key!==E&&(D.current={key:E,epoch:D.current.epoch+1});let O=D.current.epoch,k=(0,v.useRef)(!0);(0,v.useEffect)(()=>(k.current=!0,()=>{k.current=!1}),[]);let A=(0,v.useCallback)(()=>k.current&&D.current.key===E&&D.current.epoch===O,[E,O]),[j,M]=(0,v.useState)(null),N=j?.key===E&&j.epoch===O?j:null,P=N?.data??null,F=N?.loading??!0,I=N?.error??null,[L,R]=(0,v.useState)(null),[Ee,z]=(0,v.useState)(!1),[B,V]=(0,v.useState)(null),[H,U]=(0,v.useState)(``),[W,G]=(0,v.useState)(!1),[De,K]=(0,v.useState)(null),[Oe,q]=(0,v.useState)(!1),J=(0,v.useCallback)(async()=>{if(!n||!m||!A())return;let e=++f.current,t=()=>A()&&f.current===e;M(e=>({key:E,epoch:O,data:e?.key===E&&e.epoch===O?e.data:null,loading:!0,error:null}));try{let e=d?`?repositoryId=${encodeURIComponent(d)}`:``,r=await fetch(`${s()}/rails/pr-deliveries/${n}/packet${e}`);if(!t())return;if(!r.ok){M({key:E,epoch:O,data:null,loading:!1,error:r.status===404?`notFound`:`loadFailed`});return}let i=await r.json();if(!t())return;M({key:E,epoch:O,data:i,loading:!1,error:null})}catch{if(!t())return;M({key:E,epoch:O,data:null,loading:!1,error:`loadFailed`})}},[n,m,d,E,O,A]);(0,v.useEffect)(()=>(J(),z(!1),q(!1),R(null),V(null),K(null),G(!1),U(``),()=>{f.current++}),[J]);let Y=(0,v.useMemo)(()=>ue(P?.snapshot),[P?.snapshot]),X=P?.packet??null,Z=F||L!==null||W||!!Y?.operation,ke=P?.acceptCapability??null,Q=(0,v.useMemo)(()=>{if(!X)return null;let e=oe({decision:X.decision,ticketIds:X.ticketIds,prState:X.prUrl?`pr-created`:`none`,statusCode:X.statusCode,prUrl:X.prUrl,runIds:X.runIds});return ye({decision:X.decision,presentation:e,prUrl:X.prUrl,canCreatePr:ke?.target===`create-pr`})},[X,ke]),$=(0,v.useCallback)(async e=>{if(!X||!Q||Z||!A())return;let t=be(e,Q);if(t){V(null),R(e);try{let e=await(d&&Y?_(Y.railIndex,t,Y.decision,Y.prDeliveryId,d):_(X.railIndex,t,X.decision,X.prDeliveryId));if(!A())return;e.ok?m&&se(m):V(e.status===409&&e.error===`stale_decision`?`alreadyResolved`:`actionFailed`),await J()}finally{A()&&(R(null),z(!1))}}},[_,m,J,X,Q,Y,d,Z,A]),Ae=(0,v.useCallback)(async()=>{if(!(!X||!H.trim()||!m||Z||!A())){K(null),G(!0);try{let t=await fetch(`${s()}/rails/${X.railIndex}/launch`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({loopId:`factory:sdd-quick-openspec`,revisionOfDeliveryId:Y?.prDeliveryId??X.prDeliveryId,revisionNote:H.trim(),...Y?.executionManifest?{repositoryIds:Y.executionManifest.selectedRepositoryIds}:{}})});if(!A())return;if(!t.ok){let e=await t.json().catch(()=>null);if(!A())return;K(e?.error===`invalid_revision_target`?`revisionStale`:`revisionFailed`);return}U(``),q(!1);let r=await t.json().catch(()=>null);if(!A())return;r?.prDeliveryId&&r.prDeliveryId!==n?e.onClose?e.onClose():c(`/review/${encodeURIComponent(r.prDeliveryId)}`):await J()}catch{A()&&K(`revisionFailed`)}finally{A()&&G(!1)}}},[m,J,X,H,Y,Z,A,n,e.onClose,c]);if(F&&!X)return(0,y.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,y.jsx)(l,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}),o(`common:states.loading`)]});if(I||!X||!Q)return(0,y.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col items-center gap-4 p-10 text-center`,children:[(0,y.jsx)(me,{className:`size-6 text-accent-warning`,"aria-hidden":!0}),(0,y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:o(I===`notFound`?`error.notFound`:`error.loadFailed`)}),(0,y.jsx)(`button`,{type:`button`,onClick:p,className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface`,children:o(`backToBoard`)})]});let je=xe.map(e=>({tier:e,items:X.proof.filter(t=>t.tier===e)})).filter(e=>e.items.length>0),Me=X.cost.totalUsd===null?`—`:`${X.cost.estimated?`~`:``}$${X.cost.totalUsd.toFixed(2)}`;return(0,y.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 p-6`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:p,className:`flex w-fit items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,y.jsx)(de,{className:`size-3.5`,"aria-hidden":!0}),o(`backToBoard`)]}),Y?.repositoryDeliveries?.length?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[o(`common:repositories.select`),(0,y.jsxs)(`select`,{value:d??``,onChange:e=>{let t=new URLSearchParams(u);e.target.value?t.set(`repositoryId`,e.target.value):t.delete(`repositoryId`),he(t,{replace:!0})},className:`rounded border border-border bg-background px-2 py-1`,children:[(0,y.jsx)(`option`,{value:``,children:o(`common:repositories.all`)}),Y.repositoryDeliveries.map(e=>(0,y.jsx)(`option`,{value:e.repositoryId,children:e.name},e.repositoryId))]})]}),(0,y.jsx)(le,{deliveryId:Y.prDeliveryId,repositories:Y.repositoryDeliveries,busy:Z,onAct:async(e,t)=>{if(!(Z||!A())){R(`accept`);try{let n=await _(Y.railIndex,e,Y.decision,Y.prDeliveryId,t);if(!A())return;n.ok||V(`actionFailed`),await J()}finally{A()&&R(null)}}},onCheckout:async e=>{if(!(Z||!A())){R(`accept`);try{let t=await b(Y.railIndex,Y.prDeliveryId,e);if(!A())return;t.ok||V(`actionFailed`),await J()}finally{A()&&R(null)}}}})]}):null,(0,y.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-surface/60 p-5 shadow-sm`,children:[(0,y.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:o(X.headlineCode,{count:X.totalCount,succeeded:X.succeededCount,total:X.totalCount,defaultValue:X.headlineCode})}),(0,y.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[X.confidence?.overall!==null&&X.confidence?.overall!==void 0?(0,y.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-accent-info/30 bg-accent-info/10 px-2 py-0.5 text-accent-info`,title:o(`confidence.tooltip`),children:o(`confidence.pill`,{overall:X.confidence.overall})}):(0,y.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border bg-background-deep/50 px-2 py-0.5 text-muted-foreground`,children:o(`confidence.unavailable`)}),(0,y.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,y.jsx)(ve,{className:`size-3.5`,"aria-hidden":!0}),o(`cost.thisBuild`,{amount:Me})]}),X.prUrl?(0,y.jsxs)(`a`,{href:X.prUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-accent-info hover:underline`,children:[(0,y.jsx)(re,{className:`size-3.5`,"aria-hidden":!0}),o(`openPr`,{number:X.prNumber??``})]}):null]}),Q.fineControlOnly?(0,y.jsx)(`p`,{className:`mt-4 rounded-md border border-accent-warning/30 bg-accent-warning/5 px-3 py-2 text-xs text-accent-warning`,children:o(`fineControlOnly`)}):Q.inFlight?(0,y.jsxs)(`p`,{className:`mt-4 flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,y.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}),o(`stillWorking`)]}):Q.terminal?(0,y.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:o(`alreadyResolved`)}):(0,y.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[Q.verbs.includes(`accept`)&&(!Y?.repositoryDeliveries?.length||d)?Ee?(0,y.jsxs)(`div`,{className:`flex w-full flex-col gap-2 rounded-md border border-destructive/40 bg-destructive/5 p-3`,children:[(0,y.jsx)(`p`,{className:`text-xs text-foreground`,children:o(`accept.irreversibleWarning`)}),(0,y.jsxs)(`div`,{className:`flex gap-2`,children:[(0,y.jsx)(`button`,{type:`button`,onClick:()=>void $(`accept`),disabled:Z,className:`rounded-md bg-destructive px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50`,"data-testid":`packet-accept-confirm`,children:o(`accept.irreversibleConfirm`)}),(0,y.jsx)(`button`,{type:`button`,onClick:()=>z(!1),className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground`,children:o(`common:actions.cancel`)})]})]}):(0,y.jsxs)(`button`,{type:`button`,onClick:()=>{Q.requiresIrreversibleConfirm?z(!0):$(`accept`)},disabled:Z,className:`inline-flex items-center gap-1.5 rounded-md bg-accent-success px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50`,"data-testid":`packet-accept`,children:[L===`accept`?(0,y.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,y.jsx)(pe,{className:`size-4`,"aria-hidden":!0}),o(`accept.${Q.acceptMeaning??`generic`}`)]}):null,Q.verbs.includes(`request-changes`)?(0,y.jsxs)(`button`,{type:`button`,onClick:()=>q(e=>!e),disabled:Z||W,"aria-expanded":Oe,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface disabled:opacity-50`,"data-testid":`packet-request-changes`,children:[(0,y.jsx)(ne,{className:`size-4`,"aria-hidden":!0}),o(`requestChanges.label`)]}):null,Q.verbs.includes(`discard`)?(0,y.jsxs)(`button`,{type:`button`,onClick:()=>void $(`discard`),disabled:Z,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface disabled:opacity-50`,"data-testid":`packet-discard`,children:[L===`discard`?(0,y.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,y.jsx)(fe,{className:`size-4`,"aria-hidden":!0}),o(`discard.label`)]}):null]}),g&&Q.verbs.includes(`discard`)?(0,y.jsx)(`p`,{className:`mt-3 rounded-md border border-accent-warning/40 bg-accent-warning/10 px-3 py-2 text-xs text-accent-warning`,"data-testid":`packet-discard-stacked-note`,children:o(`discard.stackedNote`)}):null,B?(0,y.jsx)(`p`,{className:`mt-3 text-xs text-accent-warning`,children:o(`error.${B}`)}):null,Oe?(0,y.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2 rounded-md border border-border/70 bg-background-deep/40 p-3`,children:[(0,y.jsx)(`label`,{htmlFor:`packet-revision-note`,className:`text-xs font-medium text-foreground`,children:o(`requestChanges.prompt`)}),(0,y.jsx)(`textarea`,{id:`packet-revision-note`,value:H,onChange:e=>U(e.target.value),rows:2,placeholder:o(`requestChanges.placeholder`),className:`resize-y rounded-md border border-border bg-surface px-2 py-1.5 text-sm text-foreground placeholder:text-muted-foreground`,"data-testid":`packet-revision-input`}),(0,y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:()=>void Ae(),disabled:Z||H.trim().length===0,className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50`,"data-testid":`packet-revision-submit`,children:[W?(0,y.jsx)(l,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,y.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),o(`requestChanges.submit`)]}),(0,y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:o(`requestChanges.hint`)})]}),De?(0,y.jsx)(`p`,{className:`text-xs text-accent-warning`,children:o(`error.${De}`)}):null]}):null]}),X.driftNudges.length>0?(0,y.jsxs)(`div`,{className:`rounded-lg border border-accent-highlight/30 bg-accent-highlight/5 p-4`,"data-testid":`packet-drift-nudges`,children:[(0,y.jsx)(`h2`,{className:`mb-1 text-sm font-medium text-accent-highlight`,children:o(`drift.title`)}),(0,y.jsx)(`ul`,{className:`space-y-1 text-xs text-foreground`,children:X.driftNudges.map(e=>(0,y.jsx)(`li`,{children:o(e.code,{...e.values,defaultValue:e.code})},e.code))}),(0,y.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:o(`drift.advisory`)})]}):null,X.versions.length>1?(0,y.jsxs)(T,{title:o(`versions.title`,{count:X.versions.length}),badge:(0,y.jsx)(ge,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),children:[(0,y.jsx)(`ol`,{className:`space-y-2`,"data-testid":`packet-versions`,children:X.versions.map(e=>(0,y.jsxs)(`li`,{className:`flex flex-col gap-0.5 text-sm`,children:[(0,y.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,y.jsx)(`span`,{className:e.current?`font-medium text-foreground`:`text-muted-foreground`,children:o(`versions.label`,{version:e.version})}),e.current?(0,y.jsx)(`span`,{className:`rounded-full border border-accent-primary/40 bg-accent-primary/10 px-1.5 text-[10px] text-accent-primary`,children:o(`versions.current`)}):null,(0,y.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.costUsd===null?`—`:`${e.costEstimated?`~`:``}$${e.costUsd.toFixed(2)}`})]}),(0,y.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.revisionNote??o(`versions.originalBuild`)})]},e.prDeliveryId))}),(0,y.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:o(`cost.allVersions`,{amount:X.chainCostUsd===null?`—`:`${X.chainCostEstimated?`~`:``}$${X.chainCostUsd.toFixed(2)}`})})]}):null,X.watchOut.length>0?(0,y.jsxs)(`div`,{className:`rounded-lg border border-accent-warning/30 bg-accent-warning/5 p-4`,children:[(0,y.jsxs)(`h2`,{className:`mb-2 flex items-center gap-1.5 text-sm font-medium text-accent-warning`,children:[(0,y.jsx)(me,{className:`size-4`,"aria-hidden":!0}),o(`watchOut.title`)]}),(0,y.jsx)(`ul`,{className:`space-y-1`,children:X.watchOut.map((e,t)=>(0,y.jsx)(C,{item:e},`${e.code}-${t}`))})]}):null,(0,y.jsx)(T,{title:o(`sections.whatYouAsked`),defaultOpen:!0,children:(0,y.jsx)(`ul`,{className:`space-y-3`,children:X.sections.map(e=>(0,y.jsxs)(`li`,{className:`text-sm`,children:[(0,y.jsxs)(`button`,{type:`button`,onClick:()=>S(e.ticketId),className:`text-accent-primary hover:underline`,children:[`#`,e.ticketId,` `,e.title??``]}),e.problem?(0,y.jsx)(x,{muted:!0,className:`mt-1`,children:e.problem}):null]},e.ticketId))})}),X.followUp&&(0,y.jsxs)(T,{title:o(`followUp.title`,{count:X.followUp.comments.length}),defaultOpen:!0,children:[(0,y.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:o(`followUp.caveat`)}),(0,y.jsx)(`ul`,{className:`space-y-3`,"data-testid":`packet-follow-up`,children:X.followUp.comments.map(e=>{let t=X.followUpReport?.find(t=>t.commentId===e.id)??null,n=t?t.verdict:`unreported`;return(0,y.jsxs)(`li`,{className:`rounded-md border border-border/50 bg-background-deep/30 px-3 py-2 text-sm`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsx)(`span`,{className:`rounded bg-surface/70 px-1 font-mono text-[10px] text-muted-foreground`,children:e.id}),e.path?(0,y.jsxs)(`span`,{className:`font-mono text-xs text-accent-info`,children:[e.path,e.line?`:${e.line}`:``]}):null,(0,y.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${w[n]}`,"data-testid":`packet-follow-up-verdict`,children:o(`followUp.verdict.${n}`)}),(0,y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[o(`followUp.source.${e.source===`github`?`github`:`pasted`}`),e.author?` · ${e.author}`:``]})]}),(0,y.jsx)(x,{muted:!0,className:`mt-1`,children:e.body}),t?(0,y.jsxs)(`dl`,{className:`mt-1 grid gap-x-3 gap-y-0.5 text-xs text-muted-foreground sm:grid-cols-[auto_1fr]`,children:[t.files?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.files`)}),(0,y.jsx)(`dd`,{className:`font-mono`,children:t.files})]}):null,t.tests?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.tests`)}),(0,y.jsx)(`dd`,{children:t.tests})]}):null,t.notes?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.notes`)}),(0,y.jsx)(`dd`,{children:t.notes})]}):null]}):(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o(`followUp.noReport`)})]},e.id)})}),X.followUp.scope.excludedChanges.length>0&&(0,y.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[(0,y.jsxs)(`span`,{className:`font-medium`,children:[o(`followUp.excluded`),`:`]}),` `,X.followUp.scope.excludedChanges.join(` · `)]})]}),X.specAddenda&&X.specAddenda.length>0&&(0,y.jsxs)(T,{title:o(`addenda.title`,{count:X.specAddenda.length}),defaultOpen:!0,children:[(0,y.jsx)(`p`,{className:`mb-2 text-xs text-muted-foreground`,children:o(`addenda.caveat`)}),(0,y.jsx)(`ul`,{className:`space-y-2`,"data-testid":`packet-addenda`,children:X.specAddenda.map(e=>{let t=X.specAddendaReport?.find(t=>t.addendumId===e.id)??null,n=t?t.verdict:`unreported`,r=n===`applied`?w.resolved:w[n];return(0,y.jsxs)(`li`,{className:`rounded-md border border-border/50 bg-background-deep/30 px-3 py-2 text-sm`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`span`,{className:`font-mono text-xs text-accent-primary`,children:[`#`,e.ticketId]}),(0,y.jsx)(`span`,{className:`rounded-full border border-border/50 px-1.5 py-px text-[10px] text-muted-foreground`,children:o(`addenda.kind.${e.kind}`)}),(0,y.jsx)(`span`,{className:`font-medium`,children:e.title}),(0,y.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${r}`,"data-testid":`packet-addenda-verdict`,children:o(`addenda.verdict.${n}`)})]}),t?(0,y.jsxs)(`dl`,{className:`mt-1 grid gap-x-3 gap-y-0.5 text-xs text-muted-foreground sm:grid-cols-[auto_1fr]`,children:[t.files?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.files`)}),(0,y.jsx)(`dd`,{className:`font-mono`,children:t.files})]}):null,t.tests?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.tests`)}),(0,y.jsx)(`dd`,{children:t.tests})]}):null,t.notes?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`dt`,{className:`font-medium`,children:o(`followUp.notes`)}),(0,y.jsx)(`dd`,{children:t.notes})]}):null]}):(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o(`addenda.noReport`)})]},e.id)})})]}),(0,y.jsx)(T,{title:o(`sections.whatIDid`),children:(0,y.jsx)(`ul`,{className:`space-y-3`,children:X.sections.map(e=>(0,y.jsxs)(`li`,{className:`text-sm`,"data-testid":`packet-done-${e.ticketId}`,children:[(0,y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,y.jsxs)(`span`,{className:`font-medium text-foreground`,children:[`#`,e.ticketId]}),e.title?(0,y.jsx)(`span`,{className:`text-foreground/80`,children:e.title}):null,(()=>{let t=we(e);return(0,y.jsx)(`span`,{className:`rounded-full border px-2 py-0.5 text-[10px] font-medium ${Te[t]}`,"data-testid":`packet-outcome-pill`,children:o(`outcome.${t}`)})})()]}),e.churn?(0,y.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[o(`churn.line`,{files:e.churn.filesTouched,added:e.churn.addedLines,removed:e.churn.removedLines}),` · `,e.churn.testFilesTouched.length>0?o(`churn.testFiles`,{count:e.churn.testFilesTouched.length}):o(`churn.noTestFiles`)]}):(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o(`churn.batchNotSplittable`)}),e.solution?(0,y.jsxs)(`details`,{className:`group mt-2 rounded-md border border-border/50 bg-background-deep/30 px-3 py-2`,children:[(0,y.jsx)(`summary`,{className:`cursor-pointer select-none text-xs font-medium text-muted-foreground group-open:text-foreground/80`,children:o(`planned.title`)}),(0,y.jsx)(`p`,{className:`mt-1 text-[11px] italic text-muted-foreground/80`,children:o(`planned.caveat`)}),(0,y.jsx)(x,{className:`mt-2`,children:e.solutionOverflow??e.solution})]}):(0,y.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:o(`noSolutionRecorded`)})]},e.ticketId))})}),(0,y.jsx)(T,{title:o(`sections.howItWasChecked`),badge:X.evidenceUnavailable?(0,y.jsx)(`span`,{className:`rounded-full border border-border bg-background-deep/50 px-2 py-0.5 text-[10px] text-muted-foreground`,children:o(`proof.evidenceUnavailable`)}):void 0,children:(0,y.jsx)(`div`,{className:`space-y-4`,children:je.map(({tier:e,items:t})=>{let n=Se[e];return(0,y.jsxs)(`div`,{className:`rounded-md border px-3 py-2 ${Ce[e]}`,children:[(0,y.jsxs)(`h3`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium`,children:[(0,y.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),o(`tier.${e}.title`)]}),(0,y.jsx)(`p`,{className:`mb-2 text-[11px] opacity-80`,children:o(`tier.${e}.caveat`)}),(0,y.jsx)(`ul`,{className:`space-y-1`,children:t.map((e,t)=>(0,y.jsx)(C,{item:e},`${e.code}-${t}`))})]},e)})})})]})}export{E as default};
@@ -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"./download-CFHyyHcw.js";import{t as r}from"./git-branch-BRM0F5GN.js";import{n as i,t as a}from"./square-Ci-PFcFe.js";import{a as o,i as s,l as c,o as l,r as u,t as d}from"./dialog-CMgps2MY.js";import{t as f}from"./button-D1xExSTF.js";import{$t as p,_t as m,rt as h}from"./index-CONHvEJw.js";var g=e(),_={core:p,start:i,"ai-step":p,shell:m,decider:r,condition:r,end:a};function v(e){if(e.type===`core`){let t=e.data?.params;return t?String(t.text??t.prompt??t.goal??t.expr??t.question??t.message??t.ref??t.body??t.outcome??JSON.stringify(t,null,2)):null}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 y({template:e,onClose:r,onUse:i}){let{t:m}=t(`loops`);return(0,g.jsx)(d,{open:e!==null,onOpenChange:e=>{e||r()},children:(0,g.jsx)(u,{movableResizable:!0,className:`max-w-lg`,children:e&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(l,{children:[(0,g.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,g.jsx)(p,{className:`w-4 h-4 text-accent-highlight`}),e.name]}),(0,g.jsx)(s,{children:e.description})]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[h(e.graph)?(0,g.jsx)(`span`,{title:m(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:m(`gallery.needsSpec`)}):(0,g.jsx)(`span`,{title:m(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:m(`gallery.standalone`)}),e.category&&(0,g.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info`,children:m(`categories.${e.category}`,{defaultValue:e.category})}),e.tags.map(e=>(0,g.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,g.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.graph.config.timeoutMinutes>0?m(`preview.limits`,{iterations:e.graph.config.maxIterations,timeout:e.graph.config.timeoutMinutes}):m(`preview.limitsNoTimeout`,{iterations:e.graph.config.maxIterations})}),(0,g.jsxs)(`div`,{className:`max-h-[50vh] overflow-y-auto space-y-1.5 pr-1`,children:[(0,g.jsx)(`span`,{className:`block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:m(`preview.steps`)}),e.graph.nodes.map((e,t)=>{let n=_[e.type]??a,r=v(e);return(0,g.jsxs)(`div`,{className:`rounded border border-border bg-surface/30 p-2`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,g.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,g.jsx)(n,{className:`w-3.5 h-3.5 text-accent-primary`}),m(e.type===`core`?`builder.core.pieces.${e.data?.kind}`:`builder.nodes.${e.type}`)]}),r&&(0,g.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-muted-foreground font-mono`,children:r})]},e.id)})]}),(0,g.jsxs)(o,{children:[(0,g.jsx)(f,{variant:`ghost`,onClick:r,children:m(`common:actions.cancel`)}),(0,g.jsxs)(f,{onClick:()=>i(e.id),children:[(0,g.jsx)(n,{className:`w-3.5 h-3.5 mr-1.5`}),m(`actions.use`)]})]})]})})})}export{y as n,v as r,_ as t};
1
+ import{t as e}from"./jsx-runtime-BbYvbtY8.js";import{n as t}from"./createLucideIcon-DtODIU64.js";import{t as n}from"./download-C9wP_42h.js";import{t as r}from"./git-branch-yf6LE1Bw.js";import{n as i,t as a}from"./square-D0JTbRSR.js";import{a as o,i as s,l as c,o as l,r as u,t as d}from"./dialog-DtdR05v1.js";import{t as f}from"./button-4FS1ZDTp.js";import{$t as p,_t as m,rt as h}from"./index-CECj3joE.js";var g=e(),_={core:p,start:i,"ai-step":p,shell:m,decider:r,condition:r,end:a};function v(e){if(e.type===`core`){let t=e.data?.params;return t?String(t.text??t.prompt??t.goal??t.expr??t.question??t.message??t.ref??t.body??t.outcome??JSON.stringify(t,null,2)):null}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 y({template:e,onClose:r,onUse:i}){let{t:m}=t(`loops`);return(0,g.jsx)(d,{open:e!==null,onOpenChange:e=>{e||r()},children:(0,g.jsx)(u,{movableResizable:!0,className:`max-w-lg`,children:e&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsxs)(l,{children:[(0,g.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,g.jsx)(p,{className:`w-4 h-4 text-accent-highlight`}),e.name]}),(0,g.jsx)(s,{children:e.description})]}),(0,g.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[h(e.graph)?(0,g.jsx)(`span`,{title:m(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:m(`gallery.needsSpec`)}):(0,g.jsx)(`span`,{title:m(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:m(`gallery.standalone`)}),e.category&&(0,g.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info`,children:m(`categories.${e.category}`,{defaultValue:e.category})}),e.tags.map(e=>(0,g.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,g.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.graph.config.timeoutMinutes>0?m(`preview.limits`,{iterations:e.graph.config.maxIterations,timeout:e.graph.config.timeoutMinutes}):m(`preview.limitsNoTimeout`,{iterations:e.graph.config.maxIterations})}),(0,g.jsxs)(`div`,{className:`max-h-[50vh] overflow-y-auto space-y-1.5 pr-1`,children:[(0,g.jsx)(`span`,{className:`block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:m(`preview.steps`)}),e.graph.nodes.map((e,t)=>{let n=_[e.type]??a,r=v(e);return(0,g.jsxs)(`div`,{className:`rounded border border-border bg-surface/30 p-2`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,g.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,g.jsx)(n,{className:`w-3.5 h-3.5 text-accent-primary`}),m(e.type===`core`?`builder.core.pieces.${e.data?.kind}`:`builder.nodes.${e.type}`)]}),r&&(0,g.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-muted-foreground font-mono`,children:r})]},e.id)})]}),(0,g.jsxs)(o,{children:[(0,g.jsx)(f,{variant:`ghost`,onClick:r,children:m(`common:actions.cancel`)}),(0,g.jsxs)(f,{onClick:()=>i(e.id),children:[(0,g.jsx)(n,{className:`w-3.5 h-3.5 mr-1.5`}),m(`actions.use`)]})]})]})})})}export{y as n,v as r,_ as t};
@@ -0,0 +1,16 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/core-B3mKBIh5.js","assets/rolldown-runtime-CNC7AqOf.js","assets/event-Bt7f3wXe.js"])))=>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-BbYvbtY8.js";import{t as r}from"./react-dom-DDD8FYaU.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{u as a}from"./chunk-OB3PAWPO-B1EMk45A.js";import{n as o,t as s}from"./tauri-shell-DE6LfGPw.js";import{D as c,E as l,a as u,h as d,l as f,m as p,r as m,w as h,x as g}from"./useSharedWebSocket-CcsE5986.js";import{t as _}from"./Trans-ZiXIfj50.js";import{n as v,t as y}from"./createLucideIcon-DtODIU64.js";import{a as b,r as x,s as S}from"./useDesktop-C0mRIlHT.js";import{a as C}from"./provider-capabilities-lePfeT_Y.js";import{n as w,t as T}from"./save-LmPSfsvZ.js";import{n as E,r as D}from"./spending-eWiZGhC_.js";import{c as O,n as k}from"./MinimizedChatsContext-BHIUPVmC.js";import{t as A}from"./ban-wqfdzoXt.js";import{n as j}from"./chevron-up-6EFqEHBj.js";import{t as M}from"./file-text-C0blZHLh.js";import{t as ee}from"./circle-x-D2ttKotB.js";import{t as N}from"./download-C9wP_42h.js";import{t as P}from"./external-link-CZ6Q-v1-.js";import{t as F}from"./git-branch-yf6LE1Bw.js";import{t as I}from"./layers-BCLTgHXO.js";import{t as te}from"./loader-circle-BqV9xYGf.js";import{t as L}from"./pencil-CxrRbDwb.js";import{n as R,t as z}from"./square-D0JTbRSR.js";import{t as ne}from"./plus-fHDdjBk1.js";import{t as B}from"./rotate-ccw-DalJAQQX.js";import{t as re}from"./search-BDVp3fkH.js";import{t as ie}from"./trash-D8zYUmTg.js";import{t as V}from"./triangle-alert-Cxpn8bqr.js";import{n as ae,t as oe}from"./jira-api-C_D_RDhl.js";import{t as se}from"./x-Bu7X_eR2.js";import{t as ce}from"./zap-bugHyWzQ.js";import{F as le,I as ue,P as de,a as fe,i as pe,l as me,o as he,r as ge,t as _e}from"./dialog-DtdR05v1.js";import{t as H}from"./utils-BC4DHlz2.js";import{n as U,t as ve}from"./lib-DWJfei6y.js";import{t as ye}from"./formatDistanceToNow-CdN5lTyD.js";import{t as W}from"./button-4FS1ZDTp.js";import{t as be}from"./RepositoryScopeSelector-DeCoUsRN.js";function xe(e=``){return e||(typeof window<`u`&&(`__TAURI_INTERNALS__`in window||window.location.hostname===`tauri.localhost`)||typeof window<`u`&&window.location.protocol!==`http:`&&window.location.protocol!==`https:`?`ws://127.0.0.1:4200`:`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}`)}var Se=xe(),Ce=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_TERMINAL_PANEL;return typeof e!=`string`||e!==`false`})(),we=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_AGENTS_SECTION;return typeof e!=`string`||e!==`false`})(),Te=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_CODE_EXPLORER;return typeof e!=`string`||e!==`false`})(),Ee=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_JIRA;return typeof e!=`string`||e!==`false`})(),De=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_MCP;return typeof e!=`string`||e!==`false`})(),Oe=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_AGENT_CHAT;return typeof e!=`string`||e!==`false`})(),ke=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_AGENT_MODE;return Oe&&(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 Ae=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_LOOPS_SECTION;return typeof e!=`string`||e!==`false`})(),je=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_NATIVE_BROWSER;return typeof e!=`string`||e!==`false`})(),Me=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_PROJECT_BUILDER;return typeof e!=`string`||e!==`false`})(),Ne=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_REVIEW_PACKET;return typeof e!=`string`||e!==`false`})(),Pe=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_NARRATED_PROGRESS;return typeof e!=`string`||e!==`false`})(),Fe=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_LOCAL_ENGINES;return typeof e!=`string`||e!==`false`})();function Ie(){return Fe}var Le=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_MISSION_RAIL_CARDS;return typeof e!=`string`||e!==`false`})(),Re={name:`arrow-right`,size:24,node:[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]};Re.node;var ze=y(Re),Be={name:`camera`,size:24,node:[[`path`,{d:`M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z`,key:`18u6gg`}],[`circle`,{cx:`12`,cy:`13`,r:`3`,key:`1vg3eu`}]]};Be.node;var Ve=y(Be),G={name:`circle-arrow-right`,size:24,node:[[`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`}]],aliases:[`arrow-right-circle`]};G.node;var He=y(G),Ue={name:`circle-question-mark`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]],aliases:[`help-circle`,`circle-help`]};Ue.node;var We=y(Ue),Ge={name:`circle`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]};Ge.node;var Ke=y(Ge),qe={name:`columns-2`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]],aliases:[`columns`]};qe.node;var Je=y(qe),Ye={name:`droplet`,size:24,node:[[`path`,{d:`M12 22a7 7 0 0 0 7-7c0-2-1-3.9-3-5.5s-3.5-4-4-6.5c-.5 2.5-2 4.9-4 6.5C6 11.1 5 13 5 15a7 7 0 0 0 7 7z`,key:`c7niix`}]]};Ye.node;var Xe=y(Ye),Ze={name:`file-minus-corner`,size:24,node:[[`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`}]],aliases:[`file-minus-2`]};Ze.node;var Qe=y(Ze),$e={name:`file-plus-corner`,size:24,node:[[`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`}]],aliases:[`file-plus-2`]};$e.node;var et=y($e),tt={name:`git-commit-horizontal`,size:24,node:[[`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`}]],aliases:[`git-commit`]};tt.node;var K=y(tt),nt={name:`git-pull-request-arrow`,size:24,node:[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v12`,key:`ih889a`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}]]};nt.node;var rt=y(nt),it={name:`git-pull-request`,size:24,node:[[`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`}]]};it.node;var at=y(it),q={name:`globe`,size:24,node:[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]};q.node;var ot=y(q),st={name:`hash`,size:24,node:[[`line`,{x1:`4`,x2:`20`,y1:`9`,y2:`9`,key:`4lhtct`}],[`line`,{x1:`4`,x2:`20`,y1:`15`,y2:`15`,key:`vyu0kd`}],[`line`,{x1:`10`,x2:`8`,y1:`3`,y2:`21`,key:`1ggp8o`}],[`line`,{x1:`16`,x2:`14`,y1:`3`,y2:`21`,key:`weycgp`}]]};st.node;var ct=y(st),lt={name:`message-square-text`,size:24,node:[[`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`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]};lt.node;var ut=y(lt),dt={name:`message-square`,size:24,node:[[`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`}]]};dt.node;var ft=y(dt),pt={name:`mouse-pointer-2`,size:24,node:[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]};pt.node;var mt=y(pt),ht={name:`redo-2`,size:24,node:[[`path`,{d:`m15 14 5-5-5-5`,key:`12vg1m`}],[`path`,{d:`M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13`,key:`6uklza`}]]};ht.node;var gt=y(ht),_t={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};_t.node;var vt=y(_t),yt={name:`shield-alert`,size:24,node:[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`M12 8v4`,key:`1got3b`}],[`path`,{d:`M12 16h.01`,key:`1drbdi`}]]};yt.node;var bt=y(yt),xt={name:`split`,size:24,node:[[`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`}]]};xt.node;var St=y(xt),Ct={name:`ticket`,size:24,node:[[`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`}]]};Ct.node;var wt=y(Ct),Tt={name:`type`,size:24,node:[[`path`,{d:`M12 4v16`,key:`1654pz`}],[`path`,{d:`M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2`,key:`e0r10z`}],[`path`,{d:`M9 20h6`,key:`s66wpe`}]]};Tt.node;var Et=y(Tt),Dt={name:`undo-2`,size:24,node:[[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}],[`path`,{d:`M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11`,key:`f3b9sd`}]]};Dt.node;var Ot=y(Dt),kt={name:`zoom-in`,size:24,node:[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`11`,x2:`11`,y1:`8`,y2:`14`,key:`1vmskp`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]};kt.node;var At=y(kt),jt={name:`zoom-out`,size:24,node:[[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`line`,{x1:`21`,x2:`16.65`,y1:`21`,y2:`16.65`,key:`13gj7c`}],[`line`,{x1:`8`,x2:`14`,y1:`11`,y2:`11`,key:`durymu`}]]};jt.node;var Mt=y(jt),Nt=new Map,Pt=2e3;function Ft(e){Nt.set(e,(Nt.get(e)??0)+1)}function It(e){(Nt.get(e)??0)<=0||setTimeout(()=>{let t=(Nt.get(e)??0)-1;t<=0?Nt.delete(e):Nt.set(e,t)},Pt)}function Lt(e){return e?(Nt.get(e)??0)>0:!1}var J=e(t(),1),Rt=3e3,zt=`
3
+
4
+ ---
5
+
6
+ ## Contract Layer
7
+
8
+ `;function Bt(e){return`${f}/api/projects/${encodeURIComponent(e)}`}function Vt(e,t){return JSON.stringify(e)===JSON.stringify(t)}function Ht(e,t){let n=new Map(e.map(e=>[e.id,e])),r=t.map(e=>{let t=n.get(e.id);return t&&Vt(t,e)?t:e});return r.length===e.length&&r.every((t,n)=>t===e[n])?e:r}function Ut(){let{t:e}=v(`tickets`),{activeProjectId:t}=x(),[n,r]=(0,J.useState)([]),[i,a]=(0,J.useState)(!1),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)(new Set),[u,d]=(0,J.useState)(new Set),f=(0,J.useRef)(t);f.current=t;let p=(0,J.useRef)(0),h=(0,J.useRef)(null),g=(0,J.useRef)(new Set),{registerHandler:_,unregisterHandler:y,connectionStatus:b}=m(),C=(0,J.useId)(),w=(0,J.useCallback)(async(e,t)=>{let n=Bt(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??[]},[]),T=(0,J.useCallback)(async(t,n)=>{let i=++p.current;h.current?.abort();let o=new AbortController;h.current=o,f.current===t&&(a(!0),s(null));try{let a=await w(t,o.signal);if(o.signal.aborted||i!==p.current||f.current!==t)return;let s=g.current,c=new Set;if(n===`merge`)for(let e of a)s.size>0&&!s.has(e.id)&&c.add(e.id);g.current=new Set(a.map(e=>e.id)),r(n===`replace`?a:e=>Ht(e,a)),c.size>0&&s.size>0&&(l(c),S.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})},Rt))}catch(e){if(o.signal.aborted||i!==p.current||f.current!==t)return;s(e instanceof Error?e.message:String(e))}finally{i===p.current&&(h.current===o&&(h.current=null),f.current===t&&a(!1))}},[w,e]),E=(0,J.useCallback)(async()=>{t&&await T(t,`merge`)},[t,T]);(0,J.useEffect)(()=>{if(p.current+=1,h.current?.abort(),h.current=null,r([]),a(!1),s(null),g.current=new Set,l(new Set),d(new Set),t)return T(t,`replace`),()=>{p.current+=1,h.current?.abort(),h.current=null}},[t,T]);let D=(0,J.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`desktop.project_recovered`:n.projectId===i&&E();break;case`mcp.activity`:n.affectedProjectId&&n.affectedProjectId===i&&E();break;case`ticket_created`:{if(!n.ticket)break;let t=n.ticket;r(e=>e.some(e=>e.id===t.id)?e:[...e,t]),g.current.add(t.id),l(e=>new Set([...e,t.id])),Lt(i)||S.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})},Rt);break}case`ticket_updated`:{if(!n.ticket)break;if(n.ticket.id===0){E();break}let e=n.ticket;r(t=>t.map(t=>t.id===e.id?e:t)),typeof e.description==`string`&&e.description.includes(zt)&&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)),g.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}}},[E,e]);(0,J.useLayoutEffect)(()=>(_(`tickets-${C}`,D),()=>y(`tickets-${C}`)),[D,_,y,C]);let O=(0,J.useRef)(b);return(0,J.useEffect)(()=>{O.current!==`connected`&&b===`connected`&&f.current&&E(),O.current=b},[b,E]),{tickets:n,loading:i,isLoading:i,error:o,newTicketIds:c,contractRefiningIds:u,refetch:E,refresh:E,deleteTicket:(0,J.useCallback)(async e=>{let n=t;if(!n)return!1;try{let t=await fetch(`${Bt(n)}/tickets/${e}`,{method:`DELETE`});return t.ok&&f.current===n&&await T(n,`merge`),t.ok}catch{return!1}},[t,T]),updateTicketStatus:(0,J.useCallback)(async(e,n)=>{let r=t;if(!r)return!1;try{let t=await fetch(`${Bt(r)}/tickets/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({status:n})});return t.ok&&f.current===r&&await T(r,`merge`),t.ok}catch{return!1}},[t,T]),updateTicketPriority:(0,J.useCallback)(async(e,n)=>{let r=t;if(!r)return!1;try{let t=await fetch(`${Bt(r)}/tickets/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({priority:n})});return t.ok&&f.current===r&&await T(r,`merge`),t.ok}catch{return!1}},[t,T]),createTicket:(0,J.useCallback)(async e=>{let n=t;if(!n)return!1;try{let t=await fetch(`${Bt(n)}/tickets`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return t.ok&&f.current===n&&await T(n,`merge`),t.ok}catch{return!1}},[t,T]),updateTicket:(0,J.useCallback)(async(e,n)=>{let r=t;if(!r)return!1;try{let t=await fetch(`${Bt(r)}/tickets/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});return t.ok&&f.current===r&&await T(r,`merge`),t.ok}catch{return!1}},[t,T])}}function Wt(e,t){let n=()=>h(t?.in,NaN),r=t?.additionalDigits??2,i=Yt(e),a;if(i.date){let e=Xt(i.date,r);a=Zt(e.restDateString,e.year)}if(!a||isNaN(+a))return n();let o=+a,s=0,c;if(i.time&&(s=$t(i.time),isNaN(s)))return n();if(i.timezone){if(c=tn(i.timezone),isNaN(c))return n()}else{let e=new Date(o+s),n=g(0,t?.in);return n.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),n.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),n}return g(o+s+c,t?.in)}var Gt={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},Kt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,qt=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,Jt=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Yt(e){let t={},n=e.split(Gt.dateTimeDelimiter),r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],Gt.timeZoneDelimiter.test(t.date)&&(t.date=e.split(Gt.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){let e=Gt.timezone.exec(r);e?(t.time=r.replace(e[1],``),t.timezone=e[1]):t.time=r}return t}function Xt(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 Zt(e,t){if(t===null)return new Date(NaN);let n=e.match(Kt);if(!n)return new Date(NaN);let r=!!n[4],i=Qt(n[1]),a=Qt(n[2])-1,o=Qt(n[3]),s=Qt(n[4]),c=Qt(n[5])-1;if(r)return cn(t,s,c)?nn(t,s,c):new Date(NaN);{let e=new Date(0);return!on(t,a,o)||!sn(t,i)?new Date(NaN):(e.setUTCFullYear(t,a,Math.max(i,o)),e)}}function Qt(e){return e?parseInt(e):1}function $t(e){let t=e.match(qt);if(!t)return NaN;let n=en(t[1]),r=en(t[2]),i=en(t[3]);return ln(n,r,i)?n*l+r*c+i*1e3:NaN}function en(e){return e&&parseFloat(e.replace(`,`,`.`))||0}function tn(e){if(e===`Z`)return 0;let t=e.match(Jt);if(!t)return 0;let n=t[1]===`+`?-1:1,r=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return un(r,i)?n*(r*l+i*c):NaN}function nn(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 rn=[31,null,31,30,31,30,31,31,30,31,30,31];function an(e){return e%400==0||e%4==0&&e%100!=0}function on(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(rn[t]||(an(e)?29:28))}function sn(e,t){return t>=1&&t<=(an(e)?366:365)}function cn(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function ln(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function un(e,t){return t>=0&&t<=59}async function dn(e,t,n){let r=new FormData;r.append(`file`,t);let i=await fetch(`${b()}/tickets/${e}/attachments`,{method:`POST`,body:r,signal:n});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??d.t(`attachments:errors.uploadFailed`,{status:i.status}))}return(await i.json()).attachment}async function fn(e,t){let n=await fetch(`${b()}/tickets/${e}/attachments/${t}`,{method:`DELETE`});if(!n.ok&&n.status!==404)throw Error(d.t(`attachments:errors.deleteFailed`,{status:n.status}))}async function pn(e){let t=await fetch(`${b()}/tickets/${e}/attachments`,{method:`DELETE`});if(!t.ok&&t.status!==404)throw Error(d.t(`attachments:errors.bulkDeleteFailed`,{status:t.status}))}async function mn(e){let t=await fetch(`${b()}/tickets/${e}/attachments`);if(!t.ok)throw Error(d.t(`attachments:errors.listFailed`,{status:t.status}));return(await t.json()).attachments}function hn(e,t){return`${b()}/tickets/${e}/attachments/${t}`}async function gn(e,t){let n=await fetch(hn(e,t));if(!n.ok)throw Error(d.t(`attachments:errors.fetchFailed`,{status:n.status}));return n.blob()}var _n=`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`,vn=new Set(_n.split(`,`).filter(e=>!e.startsWith(`.`))),yn=/\.sql$/i,bn=/\.(png|jpe?g|gif|webp)$/i;function xn(e){return vn.has(e.type)||yn.test(e.name)||bn.test(e.name)}var Y=n();function Sn({ticketKey:e,attachment:t,onClose:n}){let{t:r}=v(`attachments`),[i,a]=(0,J.useState)(null),[o,s]=(0,J.useState)(null);if((0,J.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,J.useEffect)(()=>{if(!t){a(null),s(null);return}let n=!1;return a(null),s(null),gn(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,J.useEffect)(()=>()=>{i&&URL.revokeObjectURL(i)},[i]),!t)return null;let c=t.mimeType.startsWith(`image/`),l=t.mimeType===`application/pdf`;return(0,Y.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,Y.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,Y.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,Y.jsx)(w,{className:`w-4 h-4`}),r(`common:actions.back`)]}),(0,Y.jsxs)(`div`,{className:`flex-1 text-center min-w-0 px-4`,children:[(0,Y.jsx)(`div`,{className:`text-sm font-medium text-white/95 truncate`,children:t.filename}),(0,Y.jsx)(`div`,{className:`text-[11px] text-white/50`,children:t.mimeType})]}),(0,Y.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,Y.jsx)(N,{className:`w-4 h-4`}),r(`lightbox.download`)]})]}),(0,Y.jsx)(`div`,{className:H(`flex-1 flex items-center justify-center overflow-auto p-6`),onClick:n,children:o?(0,Y.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,Y.jsx)(`p`,{className:`text-sm`,children:r(`lightbox.loadError`,{error:o})})}):i?c?(0,Y.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,Y.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,Y.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,Y.jsx)(`p`,{className:`text-sm mb-3`,children:r(`lightbox.previewUnavailable`)}),(0,Y.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,Y.jsx)(N,{className:`w-4 h-4`}),r(`lightbox.downloadFile`,{name:t.filename})]})]}):(0,Y.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,Y.jsx)(`p`,{className:`text-sm`,children:r(`lightbox.loading`)})})})]})}function Cn(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 wn(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Tn(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 En(e){try{return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}catch{return e}}function Dn({ticketKey:e,attachments:t,onChange:n,className:r}){let{t:i}=v(`attachments`),[a,o]=(0,J.useState)(new Set),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(null);if((0,J.useEffect)(()=>{let r=!1;return mn(e).then(e=>{if(r)return;let i=Cn(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 fn(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,Y.jsxs)(`section`,{className:H(`mt-4`,r),"aria-label":i(`section.ariaLabel`),children:[(0,Y.jsxs)(`header`,{className:`flex items-center justify-between mb-2`,children:[(0,Y.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:i(`section.title`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:i(`section.fileCount`,{count:d.length})})]}),(0,Y.jsx)(`ul`,{className:`flex flex-col gap-1`,children:d.map(e=>{let t=a.has(e.id);return(0,Y.jsxs)(`li`,{className:H(`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,Y.jsx)(`span`,{"aria-hidden":!0,className:`w-6 text-center text-sm shrink-0`,children:Tn(e.mimeType)}),(0,Y.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,Y.jsx)(`span`,{className:`font-medium truncate text-foreground`,children:e.filename}),(0,Y.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[wn(e.size),` · `,En(e.addedAt)]})]}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:`text-[11px] text-primary hover:underline shrink-0`,children:i(`common:actions.open`)}),(0,Y.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,Y.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:s}),(0,Y.jsx)(Sn,{ticketKey:e,attachment:l,onClose:()=>u(null)})]})}function On({ticketId:e,onClose:t}){let{t:n}=v(`code`),r=a(),{activeProjectId:i}=x(),o=`${i}:${e}`,s=(0,J.useRef)(o);s.current=o;let c=(0,J.useRef)(0),l=(0,J.useRef)(null),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(null),y=(0,J.useCallback)(async(t=null)=>{l.current?.abort();let n=new AbortController;l.current=n;let r=++c.current,i=()=>!n.signal.aborted&&c.current===r&&s.current===o;p(!0),h(!1),_(t);try{let r=new URLSearchParams({ticketId:String(e),limit:`50`});t&&r.set(`cursor`,t);let a=await fetch(`${b()}/code/activity?${r}`,{signal:n.signal});if(!a.ok)throw Error(`activity unavailable`);let s=await a.json();if(!Array.isArray(s.entries))throw Error(`invalid activity response`);if(!i())return;d(e=>{let n=t&&e?.scope===o?[...e.rows]:[],r=new Set(n.map(e=>`${e.repositoryId}\0${e.path}`));for(let e of s.entries){let t=`${e.repositoryId}\0${e.path}`;r.has(t)||(r.add(t),n.push(e))}return{scope:o,rows:n,nextCursor:s.nextCursor,truncated:!!s.truncated||!!t&&!!e?.truncated}})}catch{i()&&h(!0)}finally{i()&&p(!1)}},[o,e]);if((0,J.useEffect)(()=>{if(Te)return d(null),y(),()=>{l.current?.abort(),c.current++}},[y]),!Te)return null;let S=u?.scope===o?u:null;return!f&&!m&&S&&!S.rows.length&&!S.truncated&&!S.nextCursor?null:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:n(`ticketFiles.title`)}),f&&!S&&(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,role:`status`,children:n(`ticketFiles.loading`)}),m&&(0,Y.jsxs)(`div`,{className:`text-xs`,role:`alert`,children:[(0,Y.jsx)(`span`,{children:n(`ticketFiles.loadFailed`)}),` `,(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{y(g)},className:`underline`,children:n(`ticketFiles.retry`)})]}),S?.truncated&&(0,Y.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[n(`ticketFiles.partial`),` `,(0,Y.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>{y()},className:`underline`,children:n(`ticketFiles.retry`)})]}),(0,Y.jsx)(`ul`,{className:`space-y-1`,children:S?.rows.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{let n=new URLSearchParams({repositoryId:e.repositoryId,path:e.path});e.jobId&&n.set(`changeJobId`,e.jobId),t(),r(`/code?${n}`)},className:`w-full text-left flex items-center gap-2 rounded px-2 py-1 text-xs hover:bg-muted/40`,children:[(0,Y.jsx)(e.kind===`created`?et:e.kind===`deleted`?Qe:M,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate max-w-24`,title:e.repositoryName,children:e.repositoryName}),(0,Y.jsx)(`span`,{className:`font-mono truncate flex-1`,children:e.path}),e.jobId&&(0,Y.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,Y.jsx)(K,{className:`h-3 w-3`}),e.jobId.length>10?e.jobId.slice(0,10):e.jobId]}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wider shrink-0`,children:n(`kind.${e.kind}`)})]})},`${e.repositoryId}:${e.path}`))}),S?.nextCursor&&(0,Y.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>{y(S.nextCursor)},className:`text-xs underline mt-2`,children:n(f?`ticketFiles.loading`:`ticketFiles.loadMore`)})]})}var kn=8e3,An=[`change-request`,`review-feedback`,`clarification`,`constraint`],jn=[`open`,`in_flight`,`applied`,`dismissed`],Mn=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`SpecAddendumValidationError`}};function Nn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pn(e){return typeof e==`string`&&An.includes(e)}function Fn(e){return typeof e==`string`&&jn.includes(e)}function In(e){if(!Nn(e))throw new Mn(`not_object`,`addendum must be an object`);if((e.version===void 0?1:e.version)!==1)throw new Mn(`unsupported_version`,`addendum.version must be 1`);let t=e.kind===void 0||e.kind===null?`change-request`:e.kind;if(!Pn(t))throw new Mn(`invalid_kind`,`addendum.kind must be one of ${An.join(`, `)}`);if(e.body!==void 0&&e.body!==null&&typeof e.body!=`string`)throw new Mn(`body_required`,`addendum.body must be a string`);let n=typeof e.body==`string`?e.body.replace(/\r\n?/g,`
9
+ `).trim():``;if(!n)throw new Mn(`body_required`,`addendum.body is required`);if(n.length>8e3)throw new Mn(`body_too_long`,`addendum.body exceeds ${kn} characters`);if(e.title!==void 0&&e.title!==null&&typeof e.title!=`string`)throw new Mn(`title_required`,`addendum.title must be a string`);let r=typeof e.title==`string`?e.title.replace(/\s+/g,` `).trim():``;if(r||=Ln(n),r.length>200)throw new Mn(`title_too_long`,`addendum.title exceeds 200 characters`);return{kind:t,title:r,body:n}}function Ln(e){let t=e.split(`
10
+ `).map(e=>e.replace(/^[\s#>*-]+/,``).trim()).find(e=>e.length>0)??`Addendum`;return t.length>120?`${t.slice(0,117).trimEnd()}…`:t}function Rn(e){if(!Nn(e)||typeof e.id!=`string`||!e.id||typeof e.hash!=`string`||!e.hash)return null;let t;try{t=In({version:e.version,kind:e.kind,title:e.title,body:e.body})}catch{return null}let n=Fn(e.status)?e.status:`open`,r=e=>typeof e==`string`&&e?e:null;return{id:e.id,version:1,...t,status:n,hash:e.hash,created_at:r(e.created_at)??``,updated_at:r(e.updated_at)??r(e.created_at)??``,created_by:r(e.created_by)??`user`,origin_conversation_id:r(e.origin_conversation_id),run_id:r(e.run_id),applied_at:r(e.applied_at)}}function zn(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let r of e){let e=Rn(r);!e||n.has(e.id)||(n.add(e.id),t.push(e))}return t}function Bn(e){return(e??[]).filter(e=>e.status===`open`)}var Vn={"change-request":rt,"review-feedback":ut,clarification:We,constraint:bt},Hn={open:`border-accent-primary/50 bg-accent-primary/10 text-accent-primary`,in_flight:`border-accent-info/50 bg-accent-info/10 text-accent-info animate-pulse`,applied:`border-accent-success/50 bg-accent-success/10 text-accent-success`,dismissed:`border-border bg-muted/30 text-muted-foreground`},Un=`prose prose-invert prose-xs max-w-none prose-p:my-1 prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-xs 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`,Wn={kind:`change-request`,title:``,body:``};function Gn({ticket:e,onChanged:t}){let{t:n}=v(`tickets`),[r,i]=(0,J.useState)(()=>zn(e.addenda)),[a,o]=(0,J.useState)(null),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(!1),[d,f]=(0,J.useState)(null),[m,h]=(0,J.useState)(()=>new Set),g=(0,J.useRef)(null);(0,J.useEffect)(()=>{i(zn(e.addenda))},[e.id,e.updated_at,e.addenda]),(0,J.useEffect)(()=>{a&&g.current?.focus()},[a]);let _=(0,J.useMemo)(()=>Bn(r).length,[r]),y=`${b()}/tickets/${e.id}/addenda`,x=(0,J.useCallback)(e=>{let n=e.ticket?zn(e.ticket.addenda):null;n&&(i(n),t?.(n))},[t]),C=(0,J.useCallback)(async(e,t,r)=>{u(!0);try{let i=await fetch(t,{method:e,headers:r===void 0?void 0:{"Content-Type":`application/json`},body:r===void 0?void 0:JSON.stringify(r)}),a=await i.json().catch(()=>({}));return i.ok?(x(a),!0):(a.error===`addendum_in_flight`?S.info(n(`addenda.toast.inFlight`)):S.error(a.detail?`${n(`addenda.toast.failed`)}: ${a.detail}`:n(`addenda.toast.failed`)),!1)}catch{return S.error(n(`addenda.toast.failed`)),!1}finally{u(!1)}},[x,n]),w=()=>{c(null),o({...Wn}),f(null)},T=e=>{c(e.id),o({kind:e.kind,title:e.title,body:e.body}),f(null)},E=()=>{o(null),c(null)},D=async()=>{if(!a||!a.body.trim())return;let e={kind:a.kind,title:a.title.trim()||void 0,body:a.body};(s?await C(`PATCH`,`${y}/${encodeURIComponent(s)}`,e):await C(`POST`,y,e))&&(S.success(n(s?`addenda.toast.updated`:`addenda.toast.added`)),E())},O=async(e,t,r=!1)=>{await C(`PATCH`,`${y}/${encodeURIComponent(e.id)}`,r?{status:t,force:!0}:{status:t})&&S.success(n(`addenda.toast.updated`))},k=async e=>{if(d!==e.id){f(e.id);return}f(null),await C(`DELETE`,`${y}/${encodeURIComponent(e.id)}`)&&S.success(n(`addenda.toast.removed`))},M=e=>h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),ee=e=>n(`addenda.who.${e===`agent`||e===`mcp`?e:`user`}`),N=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:ye(t,{addSuffix:!0,locale:p()})},P=()=>a&&(0,Y.jsxs)(`div`,{"data-testid":`spec-addenda-form`,className:`rounded-lg border border-accent-primary/30 bg-accent-primary/[0.04] px-3 py-2.5 space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,Y.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{className:`uppercase tracking-wider`,children:n(`addenda.form.kind`)}),(0,Y.jsx)(`select`,{value:a.kind,onChange:e=>o({...a,kind:e.target.value}),className:`h-6 rounded-md border border-border/60 bg-input px-1.5 text-[11px] text-foreground outline-none focus:border-accent-primary/50`,"data-testid":`spec-addenda-kind`,children:An.map(e=>(0,Y.jsx)(`option`,{value:e,children:n(`addenda.kind.${e}`)},e))})]}),(0,Y.jsx)(`input`,{value:a.title,onChange:e=>o({...a,title:e.target.value}),placeholder:n(`addenda.form.titlePlaceholder`),className:`h-6 min-w-0 flex-1 rounded-md border border-border/60 bg-input px-2 text-[11px] text-foreground outline-none placeholder:text-muted-foreground/70 focus:border-accent-primary/50`,"data-testid":`spec-addenda-title`})]}),(0,Y.jsx)(`textarea`,{ref:g,value:a.body,maxLength:8e3,onChange:e=>o({...a,body:e.target.value}),onKeyDown:e=>{(e.metaKey||e.ctrlKey)&&e.key===`Enter`&&(e.preventDefault(),D()),e.key===`Escape`&&(e.preventDefault(),E())},placeholder:n(`addenda.form.bodyPlaceholder`),className:`w-full min-h-[96px] rounded-md border border-border/60 bg-input px-2.5 py-1.5 text-xs text-foreground outline-none placeholder:text-muted-foreground/70 focus:border-accent-primary/50 resize-y`,"data-testid":`spec-addenda-body`}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:n(`addenda.form.hint`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,className:`h-6 text-[10px]`,onClick:E,disabled:l,children:n(`addenda.form.cancel`)}),(0,Y.jsxs)(W,{size:`sm`,className:`h-6 text-[10px]`,onClick:()=>void D(),disabled:l||!a.body.trim(),"data-testid":`spec-addenda-save`,children:[l?(0,Y.jsx)(te,{className:`mr-1 h-3 w-3 animate-spin`}):(0,Y.jsx)(j,{className:`mr-1 h-3 w-3`}),n(l?`addenda.form.saving`:`addenda.form.save`)]})]})]})]});return(0,Y.jsxs)(`section`,{"data-testid":`spec-addenda-section`,className:`space-y-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] font-medium uppercase tracking-wider text-muted-foreground`,title:n(`addenda.hint`),children:[(0,Y.jsx)(I,{className:`h-3 w-3`}),n(`addenda.title`),r.length>0&&(0,Y.jsx)(`span`,{"data-testid":`spec-addenda-open-count`,className:`rounded-full border px-1.5 py-px text-[9px] font-semibold normal-case tracking-normal ${_>0?Hn.open:`border-border text-muted-foreground`}`,children:_>0?n(`addenda.openCount`,{count:_}):r.length})]}),!a&&(0,Y.jsxs)(`button`,{type:`button`,onClick:w,className:`flex items-center gap-1 text-[10px] text-muted-foreground transition-colors hover:text-foreground`,"data-testid":`spec-addenda-add`,children:[(0,Y.jsx)(ne,{className:`h-2.5 w-2.5`}),n(`addenda.add`)]})]}),a&&!s&&P(),r.length===0&&!a?(0,Y.jsx)(`button`,{type:`button`,onClick:w,className:`w-full rounded-lg border border-dashed border-border/40 bg-muted/10 px-3 py-3 text-left text-[11px] leading-relaxed text-muted-foreground transition-colors hover:bg-muted/20 hover:text-foreground`,"data-testid":`spec-addenda-empty`,children:n(`addenda.emptyCta`)}):(0,Y.jsx)(`ul`,{className:`space-y-1.5`,children:r.map(e=>{let t=Vn[e.kind],r=m.has(e.id),i=s===e.id&&a,o=e.status===`open`||e.status===`dismissed`,c=e.status===`open`||e.status===`applied`,u=e.status===`dismissed`||e.status===`applied`,p=e.status!==`in_flight`;return(0,Y.jsx)(`li`,{"data-testid":`spec-addendum-${e.id}`,"data-status":e.status,className:`rounded-lg border px-3 py-2 transition-colors ${e.status===`dismissed`?`border-border/30 bg-muted/5 opacity-70`:`border-border/50 bg-muted/15`}`,children:i?P():(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.jsx)(t,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-primary/80`}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>M(e.id),className:`min-w-0 flex-1 text-left`,"aria-expanded":r,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-foreground/90 ${e.status===`dismissed`?`line-through`:``}`,children:e.title}),(0,Y.jsx)(`span`,{className:`rounded-full border border-border/50 px-1.5 py-px text-[9px] text-muted-foreground`,children:n(`addenda.kind.${e.kind}`)}),(0,Y.jsx)(`span`,{className:`rounded-full border px-1.5 py-px text-[9px] font-medium ${Hn[e.status]}`,title:n(`addenda.statusHint.${e.status}`),"data-testid":`spec-addendum-status`,children:n(`addenda.status.${e.status}`)})]}),!r&&(0,Y.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[11px] leading-snug text-muted-foreground`,children:e.body})]}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[o&&(0,Y.jsx)(`button`,{type:`button`,title:n(`addenda.actions.edit`),"aria-label":n(`addenda.actions.edit`),onClick:()=>T(e),disabled:l,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground`,children:(0,Y.jsx)(L,{className:`h-3 w-3`})}),e.status===`in_flight`&&(0,Y.jsx)(`button`,{type:`button`,title:n(`addenda.actions.releaseHint`),"aria-label":n(`addenda.actions.release`),onClick:()=>void O(e,`open`,!0),disabled:l,className:`rounded p-1 text-muted-foreground/60 transition-colors hover:bg-muted/40 hover:text-foreground`,"data-testid":`spec-addendum-release`,children:(0,Y.jsx)(B,{className:`h-3 w-3`})}),u&&(0,Y.jsx)(`button`,{type:`button`,title:n(`addenda.actions.reopen`),"aria-label":n(`addenda.actions.reopen`),onClick:()=>void O(e,`open`),disabled:l,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground`,children:(0,Y.jsx)(B,{className:`h-3 w-3`})}),c&&(0,Y.jsx)(`button`,{type:`button`,title:n(`addenda.actions.dismiss`),"aria-label":n(`addenda.actions.dismiss`),onClick:()=>void O(e,`dismissed`),disabled:l,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted/40 hover:text-foreground`,children:(0,Y.jsx)(A,{className:`h-3 w-3`})}),p&&(d===e.id?(0,Y.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,Y.jsx)(`button`,{type:`button`,title:n(`addenda.actions.confirmDelete`),"aria-label":n(`addenda.actions.confirmDelete`),onClick:()=>void k(e),disabled:l,className:`rounded p-1 text-destructive transition-colors hover:bg-destructive/10`,children:(0,Y.jsx)(j,{className:`h-3 w-3`})}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":n(`addenda.form.cancel`),onClick:()=>f(null),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted/40`,children:(0,Y.jsx)(se,{className:`h-3 w-3`})})]}):(0,Y.jsx)(`button`,{type:`button`,title:n(`addenda.actions.delete`),"aria-label":n(`addenda.actions.delete`),onClick:()=>void k(e),disabled:l,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,children:(0,Y.jsx)(ie,{className:`h-3 w-3`})}))]})]}),r&&(0,Y.jsxs)(`div`,{className:`mt-2 space-y-1.5 pl-5`,children:[(0,Y.jsx)(`div`,{className:Un,"data-testid":`spec-addendum-body`,children:(0,Y.jsx)(U,{remarkPlugins:[ve],children:e.body})}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[9px] text-muted-foreground`,children:[(0,Y.jsxs)(`span`,{children:[N(e.created_at),` · `,n(`addenda.meta.by`,{who:ee(e.created_by)})]}),e.run_id&&(0,Y.jsx)(`span`,{className:`font-mono`,children:n(`addenda.meta.run`,{id:e.run_id.slice(0,8)})}),e.applied_at&&(0,Y.jsx)(`span`,{children:n(`addenda.meta.applied`,{when:N(e.applied_at)})}),(0,Y.jsx)(`span`,{className:`font-mono`,children:n(`addenda.meta.hash`,{hash:e.hash.slice(0,12)})})]})]})]})},e.id)})})]})}function Kn(e){return e<.005?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function qn(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 Jn({ticketId:e}){let{t}=v(`tickets`),[n,r]=(0,J.useState)(null),i=a(),{activeProjectId:o}=x(),{closeTicketDetail:s}=Ca();if((0,J.useEffect)(()=>{let t=new AbortController;return r(null),fetch(`${b()}/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:E[e].toLowerCase()})).join(` + `),l=n.unpricedRuns??0,u=n.pricedRuns??Math.max(0,n.totalRuns-l),d=l>0&&u===0,f=l>0&&u>0,p=n.turnsUnavailableRuns??0,m=n.totalTurns==null||p>0&&(n.turnsReportedRuns??0)===0,h=!m&&p>0;return(0,Y.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,Y.jsx)(`span`,{className:`tabular-nums font-medium text-foreground`,"data-testid":d?`ticket-cost-unavailable`:void 0,title:d?t(`spendingLine.costUnavailableTooltip`):f?t(`spendingLine.costPartiallyUnavailableTooltip`):(n.estimatedCostUsd??0)>0?t(`spendingLine.estimatedTooltip`):void 0,children:d?`—`:`${(n.estimatedCostUsd??0)>0?`~`:``}${f?`≥`:``}${Kn(n.totalCostUsd)}`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,Y.jsx)(`span`,{className:`tabular-nums`,"data-testid":m?`ticket-turns-unavailable`:void 0,title:m?t(`spendingLine.turnsUnavailableTooltip`):h?t(`spendingLine.turnsPartiallyUnavailableTooltip`):void 0,children:m?`—`:`${h?`≥`:``}${t(`spendingLine.turns`,{count:n.totalTurns})}`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,Y.jsx)(`span`,{className:`tabular-nums`,children:t(`spendingLine.active`,{duration:qn(n.activeDurationMs)})}),c&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,Y.jsx)(`span`,{children:c})]}),(0,Y.jsx)(ze,{className:`w-3 h-3 opacity-0 group-hover:opacity-100 transition-opacity`})]})}var Yn={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 Xn({status:e,className:t}){let{t:n}=v(`specs`),r=Yn[e];return e===`done`?(0,Y.jsx)(j,{className:H(`w-3.5 h-3.5 shrink-0`,r.dotClass,t),"aria-label":n(`status.done`)}):e===`cancelled`?(0,Y.jsx)(se,{className:H(`w-3.5 h-3.5 shrink-0`,r.dotClass,t),"aria-label":n(`status.cancelled`)}):r.pulsing?(0,Y.jsxs)(`span`,{className:H(`relative flex shrink-0 h-2.5 w-2.5`,t),"aria-label":n(`status.inProgress`),children:[(0,Y.jsx)(`span`,{className:H(`animate-ping absolute inline-flex h-full w-full rounded-full opacity-60`,r.dotClass)}),(0,Y.jsx)(`span`,{className:H(`relative inline-flex rounded-full h-2.5 w-2.5`,r.dotClass)})]}):(0,Y.jsx)(`span`,{className:H(`inline-flex rounded-full h-2.5 w-2.5 shrink-0`,r.dotClass,t),"aria-label":n(r.labelKey)})}function Zn({status:e,className:t}){let{t:n}=v(`specs`),r=Yn[e];return(0,Y.jsxs)(`span`,{className:H(`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,Y.jsx)(Xn,{status:e}),n(r.labelKey)]})}function Qn(){let{activeProjectId:e}=x(),[t,n]=(0,J.useState)({connected:!1,key:null,discardStatus:null}),[r,i]=(0,J.useState)(!0);return(0,J.useEffect)(()=>{if(!Ee||!e){n({connected:!1,key:null,discardStatus:null}),i(!1);return}let t=!1;return i(!0),oe.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 $n({open:e,onOpenChange:t,ticket:n,discardStatus:r,onDiscarded:i}){let{t:a}=v(`jira`),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1);async function u(){l(!0);try{await oe.discardSpec(n.id,o.trim()||null),S.success(a(`discard.movedToast`,{status:r,key:n.jira_key??`#${n.id}`})),t(!1),s(``),i?.()}catch(e){S.error(e instanceof Error?e.message:a(`errors.generic`))}finally{l(!1)}}return(0,Y.jsx)(_e,{open:e,onOpenChange:e=>{c||t(e)},children:(0,Y.jsxs)(ge,{movableResizable:!0,className:`max-w-md`,"data-testid":`jira-discard-dialog`,children:[(0,Y.jsxs)(he,{children:[(0,Y.jsx)(me,{children:a(`discard.title`,{status:r})}),(0,Y.jsx)(pe,{children:a(`discard.body`,{status:r,key:n.jira_key??`#${n.id}`})})]}),(0,Y.jsxs)(`label`,{className:`block space-y-1`,children:[(0,Y.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:a(`discard.commentLabel`)}),(0,Y.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,Y.jsxs)(fe,{children:[(0,Y.jsx)(W,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:c,children:a(`wizard.cancel`)}),(0,Y.jsxs)(W,{size:`sm`,onClick:u,disabled:c,"data-testid":`jira-discard-confirm`,children:[(0,Y.jsx)(ze,{className:`w-3.5 h-3.5 mr-1.5`}),c?a(`discard.moving`):a(`discard.confirm`,{status:r})]})]})]})})}var er=/^\d{4}-\d{2}-\d{2}T/;function tr(e){if(er.test(e))try{return{text:ye(Wt(e),{addSuffix:!0,locale:p()}),title:e}}catch{}return{text:e}}function nr({localId:e}){let{t}=v(`jira`),{activeProjectId:n}=x(),r=Qn(),[i,a]=(0,J.useState)(null);if((0,J.useEffect)(()=>{if(!Ee||!r.connected)return;let t=!1;return a(null),oe.getSpecDetails(e).then(e=>{t||a(e)}).catch(()=>{t||a(null)}),()=>{t=!0}},[e,n,r.connected]),!Ee||!r.connected||!i)return null;let s=i.development,c=i.fields.length>0,l=s.pullRequests.length>0,u=s.branches.length>0,d=(s.commits?.length??0)>0;return!c&&!l&&!u&&!d?null:(0,Y.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-details-panel`,children:[c&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:t(`detail.detailsTitle`)}),(0,Y.jsx)(`div`,{className:`space-y-1.5`,children:i.fields.map((e,t)=>{let n=tr(e.value);return(0,Y.jsxs)(`div`,{className:`text-xs`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block`,children:e.label}),e.href?(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.href)},className:`inline-flex items-center gap-1 text-accent-info hover:underline text-left`,children:[(0,Y.jsx)(`span`,{className:`truncate`,children:e.value}),(0,Y.jsx)(P,{className:`w-3 h-3 shrink-0`})]}):(0,Y.jsx)(`span`,{className:`text-foreground/80 whitespace-pre-line`,title:n.title,children:n.text})]},`${e.label}-${t}`)})})]}),(l||u||d)&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:t(`detail.developmentTitle`)}),l&&(0,Y.jsxs)(`div`,{className:`mb-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.pullRequests`)}),(0,Y.jsx)(`div`,{className:`space-y-1`,children:s.pullRequests.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{o(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,Y.jsx)(at,{className:`w-3 h-3 mt-0.5 shrink-0 text-accent-info`}),(0,Y.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`span`,{className:`truncate text-foreground/80 block`,children:e.title}),(0,Y.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[e.status,e.sourceBranch?` · ${e.sourceBranch} → ${e.destBranch??``}`:``]})]})]},e.url))})]}),u&&(0,Y.jsxs)(`div`,{className:`mb-2`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.branches`)}),(0,Y.jsx)(`div`,{className:`space-y-1`,children:s.branches.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{o(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,Y.jsx)(F,{className:`w-3 h-3 shrink-0 text-accent-info`}),(0,Y.jsx)(`span`,{className:`truncate font-mono text-foreground/80`,children:e.name}),e.repo&&(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate`,children:e.repo})]},e.url))})]}),d&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.commits`)}),(0,Y.jsx)(`div`,{className:`space-y-1`,children:s.commits.map(e=>(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{o(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,Y.jsx)(K,{className:`w-3 h-3 shrink-0 text-accent-info`}),(0,Y.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground shrink-0`,children:e.displayId}),(0,Y.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.message})]},e.url))})]})]})]})}var rr=/\n*##\s*Acceptance Criteria\s*\n([\s\S]*?)(?=\n##\s|\n*$)/i;function ir(e){if(!e)return{body:``,criteria:[]};let t=rr.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 ar=new Set([`draft`,`todo`]);function or(e){return!!(ar.has(e.status)||e.source===`jira`&&e.jira_key&&e.status!==`cancelled`)}function sr(){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)})}function cr(){let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_BROWSER_CAPTURE;return typeof e!=`string`||e!==`false`}var lr={desktop:{width:1280,height:800},tablet:{width:768,height:1024},mobile:{width:375,height:667}},ur=class extends Error{},dr=class extends Error{};function X(e){if(!e)throw Error(`A project owner is required for browser sessions`);return`${f}/api/projects/${encodeURIComponent(e)}`}async function fr(e,t){let n=await fetch(`${X(e)}/browser/sessions`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({initialUrl:t})});if(n.status===409)throw new ur(`Too many open browser sessions`);if(n.status===502)throw new dr(`The browser failed to launch`);if(!n.ok)throw Error(`Failed to open browser (${n.status})`);return(await n.json()).session}async function pr(e,t,n,r){let i=await fetch(`${X(e)}/browser/sessions/${t}/navigate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:n,url:r})});if(!i.ok)throw Error(`Navigation failed (${i.status})`);return await i.json()}async function mr(e,t,n,r,i){let a=await fetch(`${X(e)}/browser/sessions/${t}/capture`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({rect:n,pendingSpecId:r,captureNetwork:i?.captureNetwork??!0})});if(!a.ok)throw Error(await hr(a));return await a.json()}async function hr(e){let t=await e.json().then(e=>e.error).catch(()=>void 0);return t?`Capture failed (${e.status}): ${t}`:`Capture failed (${e.status})`}async function gr(e,t,n,r,i,a=lr){let o=await fetch(`${X(e)}/browser/sessions/${t}/capture-breakpoints`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({rect:n,anchorPoint:r,pendingSpecId:i,breakpoints:a})});if(!o.ok)throw Error(await hr(o));return await o.json()}async function _r(e,t,n){let r=new FormData;r.append(`file`,t,n);let i=await fetch(`${b()}/tickets/${e}/attachments`,{method:`POST`,body:r});if(!i.ok)throw Error(`Upload failed (${i.status})`);return(await i.json()).attachment}async function vr(e,t,n,r){let i=await fetch(`${X(e)}/browser/sessions/${t}/clipboard`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:n,text:r})});if(!i.ok)throw Error(`Clipboard failed (${i.status})`);return await i.json()}async function yr(e,t,n,r){let i=await fetch(`${X(e)}/browser/sessions/${t}/element`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({selector:n,direction:r})});if(!i.ok)throw Error(`Element navigate failed (${i.status})`);return(await i.json()).probe}async function br(e,t,n){let r=await fetch(`${X(e)}/browser/sessions/${t}/popup-view`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({target:n})});if(!r.ok)throw Error(`Could not switch browser view (${r.status})`)}function xr(e){if(!e||e===`about:blank`)return`…`;try{return new URL(e).hostname||`…`}catch{return`…`}}async function Sr(e,t){try{await fetch(`${X(e)}/browser/sessions/${t}`,{method:`DELETE`})}catch{}}function Cr(e,t){return`${Se||(typeof window<`u`?`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}`:`ws://localhost:4200`)}/ws/browser/${e}?projectId=${encodeURIComponent(t)}`}function wr(e,t){let n=Cr(e,t),r=u(),i=r?new WebSocket(n,[`specrails-desktop`,r]):new WebSocket(n);return i.binaryType=`arraybuffer`,i}function Tr(e,t=e=>requestAnimationFrame(e),n=e=>cancelAnimationFrame(e)){let r=null,i=null,a=null,o=!1,s=()=>{a!=null&&(n(a),a=null);let t=r,o=i;r=null,i=null,t&&(!o||t.x!==o.x||t.y!==o.y)&&e({type:`mouse`,action:`move`,x:t.x,y:t.y}),o&&e({type:`wheel`,x:o.x,y:o.y,deltaX:o.deltaX,deltaY:o.deltaY})},c=()=>{a==null&&!o&&(a=t(()=>{a=null,s()}))};return{move(e,t){o||(r={x:e,y:t},c())},wheel(e,t,n,r){o||(i?(i.x=e,i.y=t,i.deltaX+=n,i.deltaY+=r):i={x:e,y:t,deltaX:n,deltaY:r},c())},flush(){o||s()},dispose(){o||(o=!0,a!=null&&(n(a),a=null),r=null,i=null)}}}function Er(e,t,n){let r=t.width>0?(e.x-t.left)/t.width:0,i=t.height>0?(e.y-t.top)/t.height:0,a=Math.min(Math.max(r,0),1)*n.width,o=Math.min(Math.max(i,0),1)*n.height;return{x:Math.round(a),y:Math.round(o)}}function Dr(e,t,n){let r=n.width>0?t.width/n.width:0,i=n.height>0?t.height/n.height:0;return{left:t.left+e.x*r,top:t.top+e.y*i,width:e.width*r,height:e.height*i}}function Or(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),width:Math.abs(e.x-t.x),height:Math.abs(e.y-t.y)}}function kr(e,t=8){return e.width>=t&&e.height>=t}function Ar(e,t){let n=Math.max(1,t.width),r=Math.max(1,t.height),i=Math.max(0,Math.min(e.x,n-1)),a=Math.max(0,Math.min(e.y,r-1)),o=Math.min(n,Math.max(i+1,e.x+e.width)),s=Math.min(r,Math.max(a+1,e.y+e.height));return{x:Math.round(i),y:Math.round(a),width:Math.round(o-i),height:Math.round(s-a)}}function jr(e){return{nodeCount:e.nodes.length,htmlBytes:e.html.length,truncated:e.htmlTruncated,networkCount:e.networkRequests?.length??0}}function Mr(e,t){let n=e.indexOf(`,`);if(!e.startsWith(`data:`)||n===-1)throw Error(`dataUrlToFile: not a data URL`);let r=e.slice(0,n),i=/^data:([^;,]+)/.exec(r)?.[1]||`application/octet-stream`,a=e.slice(n+1);if(/;base64$/i.test(r)){let e=atob(a),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return new File([n],t,{type:i})}return new File([decodeURIComponent(a)],t,{type:i})}var Nr={objects:[],past:[],future:[]};function Pr(e,t){switch(t.type){case`add`:return{objects:[...e.objects,t.obj],past:[...e.past,e.objects],future:[]};case`delete`:return e.objects.some(e=>e.id===t.id)?{objects:e.objects.filter(e=>e.id!==t.id),past:[...e.past,e.objects],future:[]}:e;case`undo`:return e.past.length===0?e:{objects:e.past[e.past.length-1],past:e.past.slice(0,-1),future:[e.objects,...e.future]};case`redo`:return e.future.length===0?e:{objects:e.future[0],past:[...e.past,e.objects],future:e.future.slice(1)};case`clear`:return e.objects.length===0?e:{objects:[],past:[...e.past,e.objects],future:[]};default:return e}}function Fr(e){let t=e.filter(e=>e.kind===`step`).map(e=>e.n);return t.length===0?1:Math.max(...t)+1}function Ir(e,t){return{x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),w:Math.abs(e.x-t.x),h:Math.abs(e.y-t.y)}}function Lr(e,t,n=.04){let r=Math.atan2(t.y-e.y,t.x-e.x),i=r-Math.PI/7,a=r+Math.PI/7;return{left:{x:t.x-n*Math.cos(i),y:t.y-n*Math.sin(i)},right:{x:t.x-n*Math.cos(a),y:t.y-n*Math.sin(a)}}}function Rr(e,t,n=.01){return Math.abs(e.x-t.x)>=n||Math.abs(e.y-t.y)>=n}function zr(e,t=.05){let n=e=>Math.min(1+t,Math.max(-t,e));return{x:n(e.x),y:n(e.y)}}function Br(e,t,n){return{schemaVersion:1,objects:e,baseWidth:t,baseHeight:n}}function Vr({result:e,pendingSpecId:t,onConfirm:n,...r}){let i=(0,J.useCallback)(async r=>{if(!r.annotations){await n(e);return}let i=`screen-annotated-${Date.now()}.png`,a=await _r(t,Mr(r.screenshotDataUrl,i),i);await n({...e,rawScreenshot:e.screenshot,screenshot:a,screenshotDataUrl:r.screenshotDataUrl,annotations:r.annotations,...e.breakpoints?{breakpoints:Object.fromEntries(Object.entries(e.breakpoints).map(([t,n])=>[t,n.attachment.id===e.screenshot.id?{...n,attachment:a,dataUrl:r.screenshotDataUrl}:n]))}:{}})},[n,t,e]);return(0,Y.jsx)(qr,{...r,responsive:Object.keys(e.breakpoints??{}).length>1,screenshotDataUrl:e.screenshotDataUrl,onConfirm:i})}var Hr=[`#ef4444`,`#f59e0b`,`#3b82f6`,`#22c55e`,`#ffffff`],Ur=`#111827`,Wr=[{tool:`arrow`,icon:D,labelKey:`editor.tools.arrow`,key:`a`},{tool:`box`,icon:z,labelKey:`editor.tools.box`,key:`r`},{tool:`text`,icon:Et,labelKey:`editor.tools.text`,key:`t`},{tool:`blur`,icon:Xe,labelKey:`editor.tools.blur`,key:`b`},{tool:`step`,icon:ct,labelKey:`editor.tools.step`,key:`n`}],Gr=0,Kr=()=>`a${++Gr}-${Date.now().toString(36)}`;function qr({screenshotDataUrl:e,responsive:t,macOverlay:n,confirmLabel:r,onConfirm:i,onReselect:a,onCancel:o}){let{t:s}=v(`browser`),[c,l]=(0,J.useReducer)(Pr,Nr),[u,d]=(0,J.useState)(`arrow`),[f,p]=(0,J.useState)(Hr[0]),[m,h]=(0,J.useState)(null),[g,_]=(0,J.useState)({w:1,h:1}),[y,b]=(0,J.useState)(!1),[x,S]=(0,J.useState)(!1),C=(0,J.useRef)(!1),T=(0,J.useRef)(null),E=(0,J.useRef)(null),D=c.objects,O=(0,J.useCallback)(()=>{let e=T.current;if(!e)return;let t=E.current?.getBoundingClientRect();if(!t||t.width<=0||t.height<=0||e.naturalWidth<=0||e.naturalHeight<=0)return;let n=Math.min(1,t.width/e.naturalWidth,t.height/e.naturalHeight),r=e.naturalWidth*n,i=e.naturalHeight*n;_(e=>e.w===r&&e.h===i?e:{w:r,h:i})},[]);(0,J.useEffect)(()=>{O();let e=typeof ResizeObserver>`u`?null:new ResizeObserver(O);return E.current&&e?.observe(E.current),window.addEventListener(`resize`,O),()=>{e?.disconnect(),window.removeEventListener(`resize`,O)}},[O]);let k=(0,J.useCallback)((e,t)=>{let n=T.current;if(!n)return{x:0,y:0};let r=n.getBoundingClientRect();return zr({x:r.width>0?(e-r.left)/r.width:0,y:r.height>0?(t-r.top)/r.height:0})},[]),A=(0,J.useCallback)(e=>{if(y)return;e.target.setPointerCapture?.(e.pointerId);let t=k(e.clientX,e.clientY);if(u===`text`){let e=window.prompt(s(`editor.notePrompt`))?.trim();e&&l({type:`add`,obj:{id:Kr(),kind:`text`,x:t.x,y:t.y,text:e,color:f}});return}if(u===`step`){l({type:`add`,obj:{id:Kr(),kind:`step`,x:t.x,y:t.y,n:Fr(D),color:f}});return}h({start:t,cur:t})},[y,u,f,D,k,s]),M=(0,J.useCallback)(e=>{m&&h(t=>t&&{...t,cur:k(e.clientX,e.clientY)})},[m,k]),ee=(0,J.useCallback)(()=>{if(!m)return;let{start:e,cur:t}=m;if(h(null),Rr(e,t)){if(u===`arrow`)l({type:`add`,obj:{id:Kr(),kind:`arrow`,from:e,to:t,color:f}});else if(u===`box`){let n=Ir(e,t);l({type:`add`,obj:{id:Kr(),kind:`box`,...n,color:f}})}else if(u===`blur`){let n=Ir(e,t);l({type:`add`,obj:{id:Kr(),kind:`blur`,...n}})}}},[m,u,f]),N=(0,J.useCallback)(()=>{let e=T.current;if(!e||!e.naturalWidth||!e.naturalHeight)throw Error(`Capture image is not loaded`);let t=e.naturalWidth,n=e.naturalHeight,r=document.createElement(`canvas`);r.width=t,r.height=n;let i=r.getContext(`2d`);if(!i)throw Error(`Image rendering is unavailable`);i.drawImage(e,0,0,t,n);for(let e of D)e.kind===`blur`&&(i.fillStyle=Ur,i.fillRect(e.x*t,e.y*n,e.w*t,e.h*n));let a=Math.max(2,t*.004);for(let e of D)if(e.kind===`box`)i.strokeStyle=e.color,i.lineWidth=a,i.strokeRect(e.x*t,e.y*n,e.w*t,e.h*n);else if(e.kind===`arrow`){let r={x:e.from.x*t,y:e.from.y*n},o={x:e.to.x*t,y:e.to.y*n},s=Lr(e.from,e.to,.035);i.strokeStyle=e.color,i.lineWidth=a,i.lineCap=`round`,i.beginPath(),i.moveTo(r.x,r.y),i.lineTo(o.x,o.y),i.moveTo(s.left.x*t,s.left.y*n),i.lineTo(o.x,o.y),i.lineTo(s.right.x*t,s.right.y*n),i.stroke()}else if(e.kind===`text`){let r=Math.max(12,n*.03);i.font=`600 ${r}px sans-serif`,i.textBaseline=`top`,i.lineWidth=Math.max(2,r*.18),i.strokeStyle=`rgba(0,0,0,0.55)`,i.strokeText(e.text,e.x*t,e.y*n),i.fillStyle=e.color,i.fillText(e.text,e.x*t,e.y*n)}else if(e.kind===`step`){let r=Math.max(10,n*.025);i.beginPath(),i.arc(e.x*t,e.y*n,r,0,Math.PI*2),i.fillStyle=e.color,i.fill(),i.fillStyle=`#000`,i.font=`700 ${r*1.1}px sans-serif`,i.textAlign=`center`,i.textBaseline=`middle`,i.fillText(String(e.n),e.x*t,e.y*n),i.textAlign=`start`}let o=r.toDataURL(`image/png`);if(!o.startsWith(`data:image/png;base64,`))throw Error(`Image encoding failed`);return{screenshotDataUrl:o,annotations:Br(D,t,n)}},[D]),P=(0,J.useCallback)(async()=>{if(!C.current){C.current=!0,b(!0),S(!1);try{await i(D.length===0?{screenshotDataUrl:e}:N())}catch{S(!0)}finally{C.current=!1,b(!1)}}},[D,N,e,i]),F=(0,J.useCallback)(()=>{D.length>0&&!window.confirm(s(`editor.discardConfirm`))||o()},[D.length,o,s]);(0,J.useEffect)(()=>{let e=e=>{if(y)return;let t=e.metaKey||e.ctrlKey;if(t&&e.key.toLowerCase()===`z`){e.preventDefault(),l({type:e.shiftKey?`redo`:`undo`});return}if(t&&e.key===`Enter`){e.preventDefault(),P();return}if(t)return;let n=Wr.find(t=>t.key===e.key.toLowerCase());if(n){d(n.tool);return}e.key===`Escape`&&(e.preventDefault(),F())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[y,P,F]);let I=(e,t)=>e*(t===`w`?g.w:g.h),L=m?Ir(m.start,m.cur):null;return(0,Y.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 flex flex-col items-center overflow-hidden p-3 gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex shrink-0 max-w-full items-center gap-1 overflow-x-auto rounded-lg border border-border/60 bg-surface/90 px-1.5 py-1 shadow-xl ${n?`ml-[80px]`:``}`,children:[Wr.map(({tool:e,icon:t,labelKey:n})=>(0,Y.jsx)(`button`,{type:`button`,title:s(n),"aria-label":s(n),"aria-pressed":u===e,onClick:()=>d(e),className:`h-7 w-7 inline-flex items-center justify-center rounded transition-colors ${u===e?`bg-primary/15 text-primary`:`text-muted-foreground hover:text-foreground hover:bg-card/60`}`,children:(0,Y.jsx)(t,{className:`w-3.5 h-3.5`})},e)),(0,Y.jsx)(`span`,{className:`w-px h-5 bg-border/60 mx-0.5`}),Hr.map(e=>(0,Y.jsx)(`button`,{type:`button`,"aria-label":s(`editor.colorLabel`,{color:e}),onClick:()=>p(e),className:`h-5 w-5 rounded-full border transition-transform ${f===e?`scale-110 border-foreground`:`border-border/60`}`,style:{background:e}},e)),(0,Y.jsx)(`span`,{className:`w-px h-5 bg-border/60 mx-0.5`}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":s(`editor.undo`),title:s(`editor.undoTitle`),disabled:c.past.length===0,onClick:()=>l({type:`undo`}),className:`h-7 w-7 inline-flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-card/60 disabled:opacity-40`,children:(0,Y.jsx)(Ot,{className:`w-3.5 h-3.5`})}),(0,Y.jsx)(`button`,{type:`button`,"aria-label":s(`editor.redo`),title:s(`editor.redoTitle`),disabled:c.future.length===0,onClick:()=>l({type:`redo`}),className:`h-7 w-7 inline-flex items-center justify-center rounded text-muted-foreground hover:text-foreground hover:bg-card/60 disabled:opacity-40`,children:(0,Y.jsx)(gt,{className:`w-3.5 h-3.5`})})]}),t&&(0,Y.jsx)(`p`,{className:`shrink-0 max-w-prose text-center text-xs text-muted-foreground`,children:s(`editor.responsiveHint`)}),(0,Y.jsx)(`div`,{ref:E,className:`relative flex-1 min-h-0 w-full flex items-center justify-center`,children:(0,Y.jsxs)(`div`,{className:`relative shrink-0`,style:{width:g.w,height:g.h},children:[(0,Y.jsx)(`img`,{ref:T,src:e,alt:s(`editor.capturedAlt`),onLoad:O,draggable:!1,className:`block w-full h-full select-none rounded shadow-2xl`}),D.map(e=>e.kind===`blur`?(0,Y.jsx)(`div`,{className:`absolute pointer-events-none`,style:{backgroundColor:Ur,left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.w*100}%`,height:`${e.h*100}%`}},e.id):null),m&&u===`blur`&&L&&(0,Y.jsx)(`div`,{className:`absolute border border-accent-info pointer-events-none`,style:{backgroundColor:Ur,left:`${L.x*100}%`,top:`${L.y*100}%`,width:`${L.w*100}%`,height:`${L.h*100}%`}}),(0,Y.jsxs)(`svg`,{className:`absolute inset-0 w-full h-full ${u===`text`||u===`step`?`cursor-pointer`:`cursor-crosshair`}`,viewBox:`0 0 ${g.w} ${g.h}`,preserveAspectRatio:`none`,onPointerDown:A,onPointerMove:M,onPointerUp:ee,children:[D.map(e=>{if(e.kind===`box`)return(0,Y.jsx)(`rect`,{x:I(e.x,`w`),y:I(e.y,`h`),width:I(e.w,`w`),height:I(e.h,`h`),fill:`none`,stroke:e.color,strokeWidth:Math.max(2,g.w*.004)},e.id);if(e.kind===`arrow`){let t=Lr(e.from,e.to,.035),n=Math.max(2,g.w*.004);return(0,Y.jsxs)(`g`,{stroke:e.color,strokeWidth:n,strokeLinecap:`round`,fill:`none`,children:[(0,Y.jsx)(`line`,{x1:I(e.from.x,`w`),y1:I(e.from.y,`h`),x2:I(e.to.x,`w`),y2:I(e.to.y,`h`)}),(0,Y.jsx)(`polyline`,{points:`${I(t.left.x,`w`)},${I(t.left.y,`h`)} ${I(e.to.x,`w`)},${I(e.to.y,`h`)} ${I(t.right.x,`w`)},${I(t.right.y,`h`)}`})]},e.id)}if(e.kind===`text`)return(0,Y.jsx)(`text`,{x:I(e.x,`w`),y:I(e.y,`h`),dominantBaseline:`hanging`,fontSize:Math.max(12,g.h*.03),fontWeight:600,fill:e.color,stroke:`rgba(0,0,0,0.55)`,strokeWidth:1,paintOrder:`stroke`,children:e.text},e.id);if(e.kind===`step`){let t=Math.max(10,g.h*.025);return(0,Y.jsxs)(`g`,{children:[(0,Y.jsx)(`circle`,{cx:I(e.x,`w`),cy:I(e.y,`h`),r:t,fill:e.color}),(0,Y.jsx)(`text`,{x:I(e.x,`w`),y:I(e.y,`h`),textAnchor:`middle`,dominantBaseline:`central`,fontSize:t*1.1,fontWeight:700,fill:`#000`,children:e.n})]},e.id)}return null}),m&&u===`box`&&L&&(0,Y.jsx)(`rect`,{x:I(L.x,`w`),y:I(L.y,`h`),width:I(L.w,`w`),height:I(L.h,`h`),fill:`none`,stroke:f,strokeDasharray:`4 3`,strokeWidth:Math.max(2,g.w*.004)}),m&&u===`arrow`&&(0,Y.jsx)(`line`,{x1:I(m.start.x,`w`),y1:I(m.start.y,`h`),x2:I(m.cur.x,`w`),y2:I(m.cur.y,`h`),stroke:f,strokeWidth:Math.max(2,g.w*.004),strokeLinecap:`round`})]}),y&&(0,Y.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center gap-2 bg-background-deep/50 text-sm text-foreground`,children:[(0,Y.jsx)(te,{className:`w-4 h-4 animate-spin`}),` `,s(`common:states.saving`)]})]})}),x&&(0,Y.jsx)(`p`,{role:`alert`,className:`shrink-0 text-sm text-destructive`,children:s(`modal.toast.captureFailed`)}),(0,Y.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Y.jsxs)(W,{size:`sm`,variant:`ghost`,className:`gap-1.5`,onClick:a,disabled:y,children:[(0,Y.jsx)(w,{className:`w-3.5 h-3.5`}),` `,s(`editor.reselect`)]}),(0,Y.jsxs)(W,{size:`sm`,variant:`ghost`,className:`gap-1.5`,onClick:F,disabled:y,children:[(0,Y.jsx)(se,{className:`w-3.5 h-3.5`}),` `,s(`common:actions.cancel`)]}),(0,Y.jsxs)(W,{size:`sm`,className:`gap-1.5`,onClick:()=>void P(),disabled:y,"data-testid":`annotation-confirm`,children:[(0,Y.jsx)(j,{className:`w-3.5 h-3.5`}),` `,D.length>0?r??s(`editor.createSpec`):s(`editor.skipContinue`)]})]})]})}var Jr=`native-browser:event`;function Yr(e){let t=(e??``).trim();if(!t)return null;if(t===`about:blank`)return t;let n=Xr(t);if(n){if(n.protocol===`http:`||n.protocol===`https:`)return n.toString();let e=`${n.pathname}${n.search}${n.hash}`;if(!/^\d+([/?#].*)?$/.test(e))return null}let r=Xr(`https://${t}`);if(r&&r.protocol===`https:`){let e=r.hostname.toLowerCase();return(e===`localhost`||e.endsWith(`.localhost`)||e===`[::1]`||/^127\./.test(e))&&(r.protocol=`http:`),r.toString()}return null}function Xr(e){try{return new URL(e)}catch{return null}}function Zr(e){let t=(e,t)=>Number.isFinite(e)?e:t;return{x:Math.max(0,Math.round(t(e.left,0))),y:Math.max(0,Math.round(t(e.top,0))),width:Math.max(1,Math.round(t(e.width,1))),height:Math.max(1,Math.round(t(e.height,1)))}}var Qr=null,$r=null,ei=Promise.resolve();async function ti(){return(await i(()=>import(`./core-B3mKBIh5.js`).then(e=>e.i),__vite__mapDeps([0,1]))).invoke}function ni(e){let t=e?.flag??je,n=e?.tauri??s();return!t||!n?Promise.resolve(!1):(Qr||=(async()=>{try{return await(await ti())(`browser_supported`)===!0}catch{return Qr=null,!1}})(),Qr)}async function ri(e){return await ni(e)?($r||=Z(`browser_capture_supported`).then(e=>e===!0).catch(()=>($r=null,!1)),$r):!1}async function Z(e,t){return(await ti())(e,t)}function ii(e){let t=ei.then(e,e);return ei=t.catch(()=>{}),t}var Q={open:(e,t,n)=>ii(()=>Z(`browser_open`,{ownerId:e,url:t,bounds:n})),navigate:(e,t)=>Z(`browser_navigate`,{ownerId:e,url:t}),back:e=>Z(`browser_back`,{ownerId:e}),forward:e=>Z(`browser_forward`,{ownerId:e}),reload:e=>Z(`browser_reload`,{ownerId:e}),setBounds:(e,t)=>Z(`browser_set_bounds`,{ownerId:e,bounds:t}),show:e=>Z(`browser_show`,{ownerId:e}),hide:e=>Z(`browser_hide`,{ownerId:e}),close:e=>ii(()=>Z(`browser_close`,{ownerId:e})),devtools:e=>Z(`browser_devtools`,{ownerId:e}),zoom:(e,t)=>Z(`browser_zoom`,{ownerId:e,factor:t}),setSelectMode:(e,t)=>Z(`browser_set_select_mode`,{ownerId:e,enabled:t}),selection:e=>Z(`browser_selection`,{ownerId:e}),capture:(e,t)=>Z(`browser_capture`,{ownerId:e,selectionOnly:t}),onEvent:async(e,t)=>{let n=n=>{n.payload.ownerId===e&&t(n.payload)},{listen:r}=await i(async()=>{let{listen:e}=await import(`./event-Bt7f3wXe.js`).then(e=>e.i);return{listen:e}},__vite__mapDeps([2,1,0]));return r(Jr,n)}},ai=e(r(),1),oi=new Map,si=new Map;function ci(e,t){let n=(si.get(e)??Promise.resolve()).catch(()=>{}).then(t);return si.set(e,n),n.finally(()=>{si.get(e)===n&&si.delete(e)}).catch(()=>{}),n}function li({ownerId:e,leaseRevision:t=0,onBusyChange:n,transferError:r,url:i,onClose:a,onFallback:s,onUrlChange:c,onCaptured:l,confirmLabel:u,selectLabel:d}){let{t:f}=v(`browser`),p=(0,J.useRef)(null),m=(0,J.useRef)(!1),[h,g]=(0,J.useState)(i),[_,y]=(0,J.useState)(i),[b,x]=(0,J.useState)(null),[S,C]=(0,J.useState)(!0),[T,E]=(0,J.useState)(!1),[D,O]=(0,J.useState)(null),[k,A]=(0,J.useState)(!1),[j,M]=(0,J.useState)(null),[ee,N]=(0,J.useState)(!1),[F,I]=(0,J.useState)(null);(0,J.useEffect)(()=>(n?.(k||j!==null||ee||F!==null),()=>{n?.(!1)}),[n,k,j,ee,F]);let te=(0,J.useRef)(1),L=(0,J.useRef)(null),R=(0,J.useRef)(!1),z=(0,J.useRef)(!1),ne=(0,J.useRef)(!1),B=(0,J.useRef)(null),re=(0,J.useRef)(i),ie=(0,J.useRef)({url:i,onFallback:s,onUrlChange:c});ie.current={url:i,onFallback:s,onUrlChange:c},ne.current=F!==null;let V=(0,J.useCallback)(async e=>{let t=L.current;if(!(!t||!R.current)){O(null);try{await e(t)}catch(e){L.current===t&&O(e instanceof Error?e.message:String(e))}}},[]);(0,J.useEffect)(()=>{let t=!1,n=null,r=0,i=null,a=e??crypto.randomUUID(),o=Symbol(a);oi.set(a,o);let s=()=>{ci(a,async()=>{oi.get(a)===o&&(oi.delete(a),await Q.close(a))}).catch(()=>{})};L.current=a,R.current=!1,E(!1);let c=()=>{t||r||(r=requestAnimationFrame(()=>{if(r=0,!R.current||ne.current||z.current)return;let e=p.current?.getBoundingClientRect();if(!e||e.width<=0||e.height<=0)return;let t=Zr(e);JSON.stringify(t)!==JSON.stringify(B.current)&&(B.current=t,Q.setBounds(a,t).catch(()=>{B.current=null}))}))};return(async()=>{try{let e=await Q.onEvent(a,e=>{if(!t){if(e.kind===`resume`){!ne.current&&!z.current&&ci(a,async()=>{if(t||oi.get(a)!==o||ne.current||z.current)return;let n=p.current?.getBoundingClientRect();n&&await Q.open(a,e.url??re.current,Zr(n))}).catch(e=>{t||O(String(e))});return}e.kind===`nav`&&e.url?(y(e.url),ie.current.onUrlChange?.(e.url),M(null),A(!1),m.current||g(e.url)):e.kind===`title`?x(e.title??null):e.kind===`load-started`?C(!0):e.kind===`load-finished`?(C(!1),e.url&&!m.current&&g(e.url)):e.kind===`popup-error`?O(f(`popup.openFailed`)):e.kind===`popup-opened`&&O(null)}});if(t){e();return}n=e;let r=p.current?.getBoundingClientRect();if(!r)throw Error(`hole not measurable`);re.current=Yr(ie.current.url)??`about:blank`,B.current=Zr(r);let l=B.current;if(!await ci(a,async()=>t||oi.get(a)!==o?!1:(await Q.open(a,re.current,l),!0)))return;if(t){s();return}R.current=!0,E(!0),i=new ResizeObserver(c),p.current&&i.observe(p.current),window.addEventListener(`resize`,c),window.addEventListener(`scroll`,c,!0),window.visualViewport?.addEventListener(`resize`,c),window.visualViewport?.addEventListener(`scroll`,c),c()}catch{t||ie.current.onFallback()}})(),()=>{t=!0,cancelAnimationFrame(r),i?.disconnect(),window.removeEventListener(`resize`,c),window.removeEventListener(`scroll`,c,!0),window.visualViewport?.removeEventListener(`resize`,c),window.visualViewport?.removeEventListener(`scroll`,c),n?.(),L.current===a&&(L.current=null,R.current=!1),s()}},[e,t]),(0,J.useEffect)(()=>{let e=Yr(i)??`about:blank`;!T||e===re.current||(re.current=e,g(e),V(t=>Q.navigate(t,e)))},[i,T,V]);let oe=(0,J.useCallback)(async e=>{let t=L.current;if(!(!t||!R.current||z.current)){z.current=!0,N(!0),O(null);try{let n=await Q.capture(t,e);if(L.current!==t||(await Q.hide(t),L.current!==t))return;ne.current=!0,A(!1),I(n)}catch(e){L.current===t&&O(e instanceof Error?e.message:String(e))}finally{z.current=!1,L.current===t&&N(!1)}}},[]);(0,J.useEffect)(()=>{if(!k||!T)return;let e=L.current,t=!1,n,r=async()=>{try{let n=await Q.selection(e);if(t||L.current!==e)return;if(n){if(await Q.setSelectMode(e,!1),t||L.current!==e)return;M(n),A(!1),await oe(!0);return}}catch(n){if(t||L.current!==e)return;O(String(n));try{await Q.setSelectMode(e,!1),!t&&L.current===e&&A(!1)}catch(n){!t&&L.current===e&&O(String(n))}return}t||(n=setTimeout(r,200))};return r(),()=>{t=!0,clearTimeout(n)}},[k,T,oe]);let ce=async()=>{await V(async e=>{await Q.setSelectMode(e,!k),M(null),A(!k)})},le=async()=>{I(null),await V(async e=>{await new Promise(e=>requestAnimationFrame(()=>e()));let t=p.current?.getBoundingClientRect();t&&t.width>0&&t.height>0&&(B.current=Zr(t),await Q.setBounds(e,B.current)),await Q.show(e)})};(0,J.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!ne.current&&a()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]);let ue=(0,J.useCallback)(()=>{let e=Yr(h);e&&(g(e),V(t=>Q.navigate(t,e)))},[h,V]),de=(0,J.useCallback)(e=>{te.current=Math.min(3,Math.max(.25,e)),V(e=>Q.zoom(e,te.current))},[V]);return typeof document>`u`?null:(0,ai.createPortal)((0,Y.jsx)(`div`,{className:`fixed inset-0 z-[80] bg-background-deep/60 backdrop-blur-md pointer-events-auto`,onClick:e=>{e.target===e.currentTarget&&!F&&a()},"data-testid":`native-browser-modal`,children:(0,Y.jsxs)(`div`,{className:`absolute inset-x-[4%] inset-y-[3.5%] flex flex-col border border-border/70 rounded-2xl bg-background-deep overflow-hidden shadow-2xl ring-1 ring-black/20`,role:`dialog`,"aria-modal":`true`,"aria-label":f(`modal.dialogLabel`),onClick:e=>e.stopPropagation(),children:[!F&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(W,{disabled:!T,variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":f(`common:actions.back`),onClick:()=>void V(Q.back),children:(0,Y.jsx)(w,{className:`w-4 h-4`})}),(0,Y.jsx)(W,{disabled:!T,variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":f(`modal.nav.forward`),onClick:()=>void V(Q.forward),children:(0,Y.jsx)(ze,{className:`w-4 h-4`})}),(0,Y.jsx)(W,{disabled:!T,variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":f(`modal.nav.reload`),onClick:()=>void V(Q.reload),children:(0,Y.jsx)(vt,{className:`w-4 h-4`})})]}),(0,Y.jsxs)(`form`,{className:`flex-1 flex items-center gap-2 min-w-0`,onSubmit:e=>{e.preventDefault(),ue()},children:[(0,Y.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,Y.jsx)(ot,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),onFocus:()=>{m.current=!0},onBlur:()=>{m.current=!1},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),ue())},placeholder:f(`modal.address.placeholder`),"aria-label":f(`modal.address.label`),className:`flex-1 min-w-0 bg-transparent outline-none text-sm`})]}),(0,Y.jsx)(W,{type:`submit`,size:`sm`,variant:`secondary`,className:`shrink-0`,children:f(`modal.address.go`)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(W,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":f(`native.zoomOut`),title:f(`native.zoomOut`),onClick:()=>de(te.current-.1),children:(0,Y.jsx)(Mt,{className:`w-4 h-4`})}),(0,Y.jsx)(W,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":f(`native.zoomIn`),title:f(`native.zoomIn`),onClick:()=>de(te.current+.1),children:(0,Y.jsx)(At,{className:`w-4 h-4`})}),(0,Y.jsx)(W,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":f(`native.devtools`),title:f(`native.devtools`),onClick:()=>void V(Q.devtools),children:(0,Y.jsx)(ae,{className:`w-4 h-4`})}),(0,Y.jsx)(W,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":f(`native.openExternal`),title:f(`native.openExternal`),onClick:()=>void o(_),children:(0,Y.jsx)(P,{className:`w-4 h-4`})}),(0,Y.jsx)(W,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":f(`modal.closeBrowser`),onClick:a,children:(0,Y.jsx)(se,{className:`w-4 h-4`})})]})]}),(0,Y.jsxs)(`div`,{className:`px-3 py-1 text-[11px] text-muted-foreground truncate shrink-0 flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full shrink-0 ${S?`bg-accent-warning animate-pulse`:`bg-accent-success`}`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`truncate`,children:b||_}),(0,Y.jsx)(`span`,{className:`ml-auto shrink-0 rounded-full border border-accent-success/30 bg-accent-success/10 text-accent-success px-2 py-px text-[10px] font-medium`,children:f(`native.badge`)})]}),l&&(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/50 px-3 py-2 shrink-0`,children:[(0,Y.jsxs)(W,{variant:k?`secondary`:`ghost`,size:`sm`,disabled:!T||ee,"aria-pressed":k,onClick:()=>void ce(),children:[(0,Y.jsx)(mt,{className:`mr-1.5 h-3.5 w-3.5`}),d??f(`native.selectElement`)]}),(0,Y.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:k?f(`native.selectHint`):j?.selector}),(0,Y.jsxs)(W,{variant:`secondary`,size:`sm`,disabled:!T||ee||k||_===`about:blank`,onClick:()=>void oe(j!==null),children:[(0,Y.jsx)(Ve,{className:`mr-1.5 h-3.5 w-3.5`}),f(ee?`native.capturing`:j?`native.captureSelection`:`native.capturePage`)]})]})]}),(D||r)&&(0,Y.jsx)(`div`,{role:`alert`,className:`border-b border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive shrink-0`,children:D||r}),F&&l&&(0,Y.jsx)(qr,{screenshotDataUrl:F.screenshotDataUrl,confirmLabel:u,onConfirm:async e=>{await l({...F,screenshotDataUrl:e.screenshotDataUrl})},onReselect:()=>{le()},onCancel:a}),(0,Y.jsx)(`div`,{ref:p,className:F?`hidden`:`relative flex-1 min-h-0 overflow-hidden`,children:S&&(0,Y.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm text-muted-foreground`,children:f(`modal.status.opening`)})})]})}),document.body)}function ui(e){let t=e.schedule??(e=>requestAnimationFrame(e)),n=e.cancel??(e=>cancelAnimationFrame(e)),r=e.now??(()=>typeof performance<`u`?performance.now():Date.now()),i=e.release??(()=>{}),a={received:0,decoded:0,drawn:0,droppedStale:0,droppedUndrawn:0,decodeMsTotal:0,drawMsTotal:0},o=!1,s=!1,c=null,l=null,u=null,d=()=>{u=null;let t=l;if(l=null,t==null||o){t!=null&&f(t);return}let n=r();try{e.draw(t),a.drawn++,a.drawMsTotal+=r()-n}catch{}finally{f(t)}},f=e=>{try{i(e)}catch{}},p=()=>{u==null&&!o&&(u=t(d))},m=t=>{s=!0;let n=r();e.decode(t).then(e=>{if(o){f(e);return}a.decoded++,a.decodeMsTotal+=r()-n,l!=null&&(a.droppedUndrawn++,f(l)),l=e,p(),h()},()=>{h()})},h=()=>{if(o){s=!1;return}let e=c;c=null,e==null?s=!1:m(e)};return{push(e){if(!o){if(a.received++,s){c!=null&&a.droppedStale++,c=e;return}m(e)}},stats(){return{...a}},dispose(){if(!o){if(o=!0,c=null,u!=null){try{n(u)}catch{}u=null}l!=null&&(f(l),l=null)}}}}var di=`specrails-desktop:browser-capture-debug`;function fi(){try{return typeof localStorage<`u`&&localStorage.getItem(di)===`1`}catch{return!1}}function pi(e,t,n){let r=Math.max(1,n),i=t.decoded-e.decoded,a=t.drawn-e.drawn,o=e=>Math.round(e*10)/10;return{fpsReceived:o((t.received-e.received)*1e3/r),fpsDrawn:o(a*1e3/r),droppedStale:t.droppedStale-e.droppedStale,droppedUndrawn:t.droppedUndrawn-e.droppedUndrawn,avgDecodeMs:i>0?o((t.decodeMsTotal-e.decodeMsTotal)/i):0,avgDrawMs:a>0?o((t.drawMsTotal-e.drawMsTotal)/a):0}}function mi(e,t=e=>console.table([e]),n=2e3,r=()=>Date.now()){let i=e(),a=r(),o=setInterval(()=>{let n=e(),o=r();t(pi(i,n,o-a)),i=n,a=o},n);return()=>clearInterval(o)}function hi(e){let{projectId:t,open:n,initialUrl:r}=e,i=(0,J.useRef)(null),a=(0,J.useRef)(null),o=(0,J.useRef)(null),s=(0,J.useRef)(0),c=(0,J.useRef)(0),l=(0,J.useRef)(null),u=(0,J.useRef)(null),f=(0,J.useCallback)(()=>{let e=l.current,t=u.current,n=a.current;if(!(!e||!n||n.readyState!==WebSocket.OPEN)&&!(t&&t.width===e.width&&t.height===e.height&&t.deviceScaleFactor===e.deviceScaleFactor))try{n.send(JSON.stringify({type:`input`,event:{type:`resize`,...e}})),u.current=e}catch{}},[]),p=(0,J.useRef)(0),m=(0,J.useRef)(new Map),h=(0,J.useCallback)(()=>{if(p.current!==0||m.current.size===0)return;let e=[...m.current.values()];m.current.clear();for(let t of e)Sr(t.projectId,t.sessionId)},[]),[g,_]=(0,J.useState)({status:`connecting`,errorMsg:null,url:null,title:null,viewport:{width:1280,height:800},hoverRect:null,hoverSelector:null,hoverPath:null,popup:null,popupError:null});(0,J.useEffect)(()=>{if(!n||!t)return;let e=!1,c=null;u.current=null,_(e=>({...e,status:`connecting`,errorMsg:null,popup:null,popupError:null}));let h=ui({decode:e=>createImageBitmap(new Blob([e],{type:`image/jpeg`})),draw:e=>{let t=i.current;t&&(t.width!==e.width&&(t.width=e.width),t.height!==e.height&&(t.height=e.height),t.getContext(`2d`)?.drawImage(e,0,0))},release:e=>e.close()}),g=fi()?mi(()=>h.stats()):null;return(async()=>{try{let n=await fr(t,r);if(e){Sr(t,n.id);return}c=n.id,o.current={id:n.id,projectId:t},_(e=>({...e,url:n.url,title:n.title,viewport:l.current??{width:n.viewportWidth,height:n.viewportHeight}}));let i=wr(n.id,t);a.current=i,i.onmessage=e=>{if(typeof e.data==`string`){try{let t=JSON.parse(e.data);if(t.type===`ready`)_(e=>({...e,status:`ready`,url:t.url??e.url,title:t.title??e.title,viewport:l.current??t.viewport??e.viewport})),f();else if(t.type===`nav`)_(e=>({...e,url:t.url??e.url,title:t.title??e.title}));else if(t.type===`hover`)_(e=>({...e,hoverRect:t.rect??null,hoverSelector:t.selector??null,hoverPath:t.path??null}));else if(t.type===`popup`){let e=typeof t.count==`number`?t.count:0;s.current+=1,_(n=>({...n,popup:e>0?{count:e,active:t.active===!0,url:t.url??null}:null,popupError:null}))}}catch{}return}h.push(e.data)},i.onopen=()=>{e||(f(),_(e=>({...e,status:`ready`})))},i.onerror=()=>{e||_(e=>({...e,status:`error`,errorMsg:d.t(`browser:session.connectionError`)}))},i.onclose=()=>{e||_(e=>({...e,status:`error`,errorMsg:d.t(`browser:session.lostConnection`)}))}}catch(t){if(e)return;let n=t instanceof ur?d.t(`browser:session.tooManySessions`):t instanceof dr?d.t(`browser:session.launchFailed`):d.t(`browser:session.openFailed`);_(e=>({...e,status:`error`,errorMsg:n}))}})(),()=>{e=!0,g?.(),h.dispose();let n=a.current;if(n){n.onmessage=null,n.onopen=null,n.onerror=null,n.onclose=null;try{n.close()}catch{}}a.current=null;let r=c;r&&o.current?.id===r&&o.current.projectId===t&&(o.current=null),r&&(p.current>0?m.current.set(`${t}\0${r}`,{sessionId:r,projectId:t}):Sr(t,r))}},[n,t,r,h,f]);let v=(0,J.useCallback)(e=>{let t=a.current;if(t&&t.readyState===WebSocket.OPEN)try{t.send(JSON.stringify({type:`input`,event:e}))}catch{}},[]),y=(0,J.useCallback)(async(e,t)=>{let n=o.current;if(n)try{let r=await pr(n.projectId,n.id,e,t);if(o.current!==n)return;r.target!==`popup`&&_(e=>({...e,url:r.url,title:r.title}))}catch{}},[]),b=(0,J.useCallback)(async(e,t,n)=>{let r=o.current;if(!r)throw Error(`No active browser session`);p.current+=1;try{return await mr(r.projectId,r.id,e,t,n)}finally{p.current=Math.max(0,p.current-1),h()}},[h]),x=(0,J.useCallback)(async(e,t,n,r)=>{let i=o.current;if(!i)throw Error(`No active browser session`);p.current+=1;try{return await gr(i.projectId,i.id,e,t,n,r)}finally{p.current=Math.max(0,p.current-1),h()}},[h]),S=(0,J.useCallback)(async(e,t)=>{let n=o.current;return n?vr(n.projectId,n.id,e,t):{text:``}},[]),C=(0,J.useCallback)((e,t,n=window.devicePixelRatio||1)=>{if(!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0)return;let r=Math.max(1,Math.round(e)),i=Math.max(1,Math.round(t));l.current={width:r,height:i,deviceScaleFactor:Number.isFinite(n)?Math.min(2,Math.max(1,n)):1},_(e=>e.viewport.width===r&&e.viewport.height===i?e:{...e,viewport:{width:r,height:i}}),f()},[f]),w=(0,J.useCallback)(e=>{let t=a.current;if(t&&t.readyState===WebSocket.OPEN)try{t.send(JSON.stringify({type:`probe`,x:e.x,y:e.y}))}catch{}},[]),T=(0,J.useCallback)(()=>{_(e=>e.hoverRect||e.hoverPath?{...e,hoverRect:null,hoverSelector:null,hoverPath:null}:e)},[]),E=(0,J.useCallback)(async(e,t)=>{let n=o.current;return n?yr(n.projectId,n.id,e,t):null},[]),D=(0,J.useCallback)(async e=>{let t=o.current;if(!t)return;let n=s.current,r=++c.current,i=()=>o.current===t&&s.current===n&&c.current===r;try{await br(t.projectId,t.id,e),i()&&_(e=>({...e,popupError:null}))}catch{i()&&_(e=>({...e,popupError:d.t(`browser:session.connectionError`)}))}},[]);return{...g,canvasRef:i,forwardInput:v,navigate:y,capture:b,captureBreakpoints:x,clipboard:S,navigateElement:E,setViewport:C,probe:w,clearHover:T,setPopupView:D}}function gi(e,t,n,r){let i=(0,J.useRef)(t);i.current=t,(0,J.useEffect)(()=>{let t=e.current;if(!n||!t)return;let a=!1,o=null,s=0,c=0,l=0,u=null,d=()=>{if(o=null,a)return;let e=r??t.getBoundingClientRect();if(!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0)return;let n=Math.max(1,Math.round(e.width)),u=Math.max(1,Math.round(e.height)),d=window.devicePixelRatio,f=Number.isFinite(d)?Math.min(2,Math.max(1,d)):1;n===s&&u===c&&f===l||(s=n,c=u,l=f,i.current(n,u,f))},f=()=>{a||o===null&&(o=requestAnimationFrame(d))},p=()=>{u?.removeEventListener(`change`,m),u=typeof window.matchMedia==`function`?window.matchMedia(`(resolution: ${window.devicePixelRatio||1}dppx)`):null,u?.addEventListener(`change`,m)},m=()=>{f(),p()};d();let h=typeof ResizeObserver>`u`?null:new ResizeObserver(f);return h?.observe(t),window.addEventListener(`resize`,f),p(),()=>{a=!0,o!==null&&cancelAnimationFrame(o),h?.disconnect(),u?.removeEventListener(`change`,m),window.removeEventListener(`resize`,f)}},[e,n,r?.width,r?.height])}function _i({open:e,url:t,projectId:n,onClose:r}){let[i,a]=(0,J.useState)(`probing`);(0,J.useEffect)(()=>{if(!e||i!==`probing`)return;let t=!0;return ni().then(e=>{t&&a(e?`native`:`screencast`)}),()=>{t=!1}},[e,i]);let o=(0,J.useCallback)(()=>a(`screencast`),[]);return!e||i===`probing`?null:i===`native`?(0,Y.jsx)(li,{url:t,onClose:r,onFallback:o}):(0,Y.jsx)(vi,{open:e,url:t,projectId:n,onClose:r})}function vi({open:e,url:t,projectId:n,onClose:r}){let{t:i}=v(`browser`),a=hi({projectId:n,open:e,initialUrl:t}),{canvasRef:o,viewport:s,status:c,errorMsg:l,url:u,title:d,popup:f,popupError:p,setViewport:m}=a,[h,g]=(0,J.useState)(t),_=(0,J.useRef)(null);gi(_,m,e);let y=(0,J.useRef)(a.forwardInput);y.current=a.forwardInput;let b=(0,J.useRef)(null),x=(0,J.useCallback)(()=>(b.current??=Tr(e=>y.current(e)),b.current),[]);(0,J.useEffect)(()=>()=>{b.current?.dispose(),b.current=null},[]);let S=f?.active?f.url??`about:blank`:u??``;(0,J.useEffect)(()=>{g(S)},[S,f?.active]),(0,J.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,r]);let C=(0,J.useCallback)((e,t)=>{let n=o.current?.getBoundingClientRect();return n?Er({x:e,y:t},{left:n.left,top:n.top,width:n.width,height:n.height},s):{x:0,y:0}},[o,s]),T=e=>e===2?`right`:e===1?`middle`:`left`,E=(0,J.useCallback)(e=>{let t=C(e.clientX,e.clientY);x().move(t.x,t.y)},[C,x]),D=(0,J.useCallback)(e=>{let t=C(e.clientX,e.clientY),n=x();n.move(t.x,t.y),n.flush(),a.forwardInput({type:`mouse`,action:`down`,x:t.x,y:t.y,button:T(e.button),clickCount:e.detail||1})},[C,a,x]),O=(0,J.useCallback)(e=>{let t=C(e.clientX,e.clientY),n=x();n.move(t.x,t.y),n.flush(),a.forwardInput({type:`mouse`,action:`up`,x:t.x,y:t.y,button:T(e.button),clickCount:e.detail||1})},[C,a,x]),k=(0,J.useCallback)(e=>{let t=C(e.clientX,e.clientY);x().wheel(t.x,t.y,e.deltaX,e.deltaY)},[C,x]),A=(0,J.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]),j=(0,J.useCallback)(e=>{e.key!==`Escape`&&a.forwardInput({type:`key`,action:`up`,key:e.key,code:e.code})},[a]),M=(0,J.useCallback)(()=>{a.navigate(`goto`,h)},[a,h]);return!e||typeof document>`u`?null:(0,ai.createPortal)((0,Y.jsx)(`div`,{className:`fixed inset-0 z-[80] bg-background-deep/60 backdrop-blur-md pointer-events-auto`,onClick:e=>{e.target===e.currentTarget&&r()},"data-testid":`webview-modal`,children:(0,Y.jsxs)(`div`,{className:`absolute inset-x-[4%] inset-y-[3.5%] flex flex-col border border-border/70 rounded-2xl bg-background-deep overflow-hidden shadow-2xl ring-1 ring-black/20`,role:`dialog`,"aria-modal":`true`,"aria-label":i(`modal.dialogLabel`),onClick:e=>e.stopPropagation(),children:[(0,Y.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,Y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,Y.jsx)(W,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`common:actions.back`),onClick:()=>a.navigate(`back`),children:(0,Y.jsx)(w,{className:`w-4 h-4`})}),(0,Y.jsx)(W,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.nav.forward`),onClick:()=>a.navigate(`forward`),children:(0,Y.jsx)(ze,{className:`w-4 h-4`})}),(0,Y.jsx)(W,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.nav.reload`),onClick:()=>a.navigate(`reload`),children:(0,Y.jsx)(vt,{className:`w-4 h-4`})})]}),(0,Y.jsxs)(`form`,{className:`flex-1 flex items-center gap-2 min-w-0`,onSubmit:e=>{e.preventDefault(),M()},children:[(0,Y.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,Y.jsx)(ot,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,Y.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),M())},placeholder:i(`modal.address.placeholder`),"aria-label":i(`modal.address.label`),className:`flex-1 min-w-0 bg-transparent outline-none text-sm`})]}),(0,Y.jsx)(W,{type:`submit`,size:`sm`,variant:`secondary`,className:`shrink-0`,disabled:c===`error`,children:i(`modal.address.go`)})]}),(0,Y.jsx)(W,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.closeBrowser`),onClick:r,children:(0,Y.jsx)(se,{className:`w-4 h-4`})})]}),(0,Y.jsxs)(`div`,{className:`px-3 py-1 text-[11px] text-muted-foreground truncate shrink-0 flex items-center gap-2`,children:[(0,Y.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,Y.jsx)(`span`,{className:`truncate`,children:c===`connecting`?i(`modal.status.connecting`):c===`error`?l??i(`modal.status.unavailable`):f?.active?i(`popup.loginWindow`,{origin:xr(f.url)}):d||``})]}),p&&(0,Y.jsx)(`div`,{role:`alert`,className:`px-3 py-1.5 text-xs text-destructive border-b border-border/40 shrink-0`,children:p}),f&&(0,Y.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,Y.jsx)(P,{className:`w-3.5 h-3.5 shrink-0`}),f.active?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:i(`popup.loginWindow`,{origin:xr(f.url)})}),f.count>1&&(0,Y.jsx)(`span`,{className:`shrink-0 opacity-70`,children:i(`popup.stacked`,{count:f.count-1})}),(0,Y.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,Y.jsx)(w,{className:`w-3 h-3`}),i(`popup.backToPage`)]})]}):(0,Y.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,Y.jsx)(`span`,{className:`opacity-70`,children:i(`popup.stacked`,{count:f.count-1})})]})]}),(0,Y.jsx)(`div`,{ref:_,className:`relative flex-1 min-h-0 overflow-hidden flex items-center justify-center outline-none`,tabIndex:0,onKeyDown:A,onKeyUp:j,children:c===`error`?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center max-w-md px-6`,children:[(0,Y.jsx)(V,{className:`w-8 h-8 text-accent-warning`}),(0,Y.jsx)(`p`,{className:`text-sm text-foreground/90`,children:l??i(`modal.error.unavailable`)})]}):(0,Y.jsx)(`canvas`,{ref:o,style:{maxWidth:`min(100%, ${s.width}px)`,maxHeight:`min(100%, ${s.height}px)`},className:`max-w-full max-h-full block shadow-2xl cursor-default`,onPointerMove:E,onPointerDown:D,onPointerUp:O,onContextMenu:e=>e.preventDefault(),onWheel:k})})]})}),document.body)}var yi=(0,J.createContext)(null);function bi({children:e}){let{activeProjectId:t}=x(),[n,r]=(0,J.useState)(null),i=(0,J.useCallback)(e=>r(e),[]),a=cr();return(0,Y.jsxs)(yi.Provider,{value:{openWebView:i,canOpenWebView:a&&!!t},children:[e,a&&n&&t&&(0,Y.jsx)(_i,{open:!0,url:n,projectId:t,onClose:()=>r(null)})]})}function xi(){return(0,J.useContext)(yi)??{openWebView:()=>{},canOpenWebView:!1}}var Si={analyzing:`activity:smash.stage.analyzing`,identifying:`activity:smash.stage.identifying`,ordering:`activity:smash.stage.ordering`},Ci=(0,J.createContext)(null);function $(e){return`smash:${e}`}async function wi(e,t){try{let n=await fetch(`${f}/api/projects/${e}/tickets/${t}/smash`,{method:`POST`});if(n.ok)S.loading(d.t(`activity:smash.retrying`),{id:$(t)});else{let e=await n.json().catch(()=>({}));S.error(e.reason?d.t(`activity:smash.couldNotRetryWithReason`,{reason:e.reason}):d.t(`activity:smash.couldNotRetry`),{id:$(t)})}}catch(e){S.error(d.t(`activity:smash.retryFailed`,{message:e.message}),{id:$(t)})}}async function Ti(e,t,n){try{let r=await fetch(`${f}/api/projects/${e}/tickets/${t}/smash/undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({smashedAt:n})});if(r.ok)S.success(d.t(`activity:smash.undone`),{id:$(t),duration:3e3});else{let e=await r.json().catch(()=>({}));S.error(e.reason?d.t(`activity:smash.undoFailedWithReason`,{reason:e.reason}):d.t(`activity:smash.undoFailed`),{id:$(t)})}}catch(e){S.error(d.t(`activity:smash.undoFailedWithReason`,{reason:e.message}),{id:$(t)})}}function Ei({children:e}){let{registerHandler:t,unregisterHandler:n}=m(),[r,i]=(0,J.useState)({}),a=(0,J.useRef)(new Map),o=(0,J.useRef)(new Map),s=(0,J.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}})),S.loading(d.t(Si.analyzing),{id:$(n),description:c?d.t(`activity:smash.onTitled`,{title:c}):d.t(`activity:smash.onThisSpec`)}))},[]),c=(0,J.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}),S.loading(d.t(Si[r]),{id:$(n),description:a?d.t(`activity:smash.onTitled`,{title:a}):d.t(`activity:smash.onThisSpec`)})},[]),l=(0,J.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}),S.success(d.t(`activity:smash.split`,{count:c.length}),{id:$(n),duration:1e4,action:{label:d.t(`activity:smash.undoAction`),onClick:()=>void Ti(a,n,s)}}))},[]),u=(0,J.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`?d.t(`activity:smash.failReason.invalidOutput`):o===`timeout`?d.t(`activity:smash.failReason.timeout`):o===`model_error`?d.t(`activity:smash.failReason.modelError`):o===`crashed`?d.t(`activity:smash.failReason.crashed`):d.t(`activity:smash.failReason.generic`,{reason:o});S.error(d.t(`activity:smash.couldNotComplete`),{id:$(n),description:s,action:{label:d.t(`common:actions.retry`),onClick:()=>void wi(r,n)},duration:15e3})},[]),f=(0,J.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.undone`)return;let n=t.ticketId;typeof n==`number`&&(S.dismiss($(n)),S.success(d.t(`activity:smash.undone`),{id:$(n),duration:3e3}))},[]);(0,J.useLayoutEffect)(()=>(t(`_smash_started`,s),t(`_smash_progress`,c),t(`_smash_completed`,l),t(`_smash_failed`,u),t(`_smash_undone`,f),()=>{n(`_smash_started`),n(`_smash_progress`),n(`_smash_completed`),n(`_smash_failed`),n(`_smash_undone`)}),[t,n,s,c,l,u,f]),(0,J.useEffect)(()=>()=>{a.current.clear(),o.current.clear()},[]);let p=(0,J.useMemo)(()=>({inflight:r}),[r]);return(0,Y.jsx)(Ci.Provider,{value:p,children:e})}function Di(e){let t=(0,J.useContext)(Ci);return!t||e==null?null:t.inflight[e]??null}var Oi=150,ki={analyzing:0,identifying:1,ordering:2},Ai={analyzing:`smash.stage.analyzing`,identifying:`smash.stage.identifying`,ordering:`smash.stage.ordering`};function ji({stage:e,minDisplayMs:t=Oi}){let{t:n}=v(`activity`),[r,i]=(0,J.useState)(e),a=(0,J.useRef)(Date.now()),o=(0,J.useRef)(null);if((0,J.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=ki[r];return(0,Y.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,Y.jsx)(te,{className:`h-4 w-4 animate-spin text-accent-highlight`,"aria-hidden":!0}),(0,Y.jsx)(`div`,{className:`flex items-center gap-1.5`,children:[`analyzing`,`identifying`,`ordering`].map(e=>(0,Y.jsx)(`span`,{className:[`inline-block w-1.5 h-1.5 rounded-full transition-all`,ki[e]<=s?`bg-accent-highlight`:`bg-muted`,e===r?`scale-125`:`scale-100`].join(` `),"aria-hidden":!0},e))}),(0,Y.jsx)(`span`,{className:`font-medium`,children:n(Ai[r])})]})}var Mi={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 Ni({open:e,ticketTitle:t,isReSmash:n,childrenCount:r,submitting:i=!1,onCancel:a,onConfirm:o}){let{t:s}=v(`activity`),[c,l]=(0,J.useState)(`simple`),{panelRef:u,panelStyle:d,headerHandleProps:f,resizeHandles:p,isFloating:m,guardBackdrop:h}=le();return e?(0,ai.createPortal)((0,Y.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,Y.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:h(a)}),(0,Y.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,Y.jsxs)(`div`,{...f,className:`flex items-start justify-between gap-3 px-5 py-4 border-b border-border/30 ${m?`cursor-grab active:cursor-grabbing`:``}`,children:[(0,Y.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,Y.jsx)(St,{className:`w-5 h-5 text-accent-highlight shrink-0 mt-0.5`,"aria-hidden":!0}),(0,Y.jsxs)(`div`,{className:`min-w-0`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:s(`smashModal.title`)}),(0,Y.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate`,title:t,children:t})]})]}),(0,Y.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,Y.jsx)(se,{className:`w-4 h-4`})})]}),n&&r>0&&(0,Y.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,Y.jsx)(_,{t:s,i18nKey:`smashModal.reSmashWarning`,count:r})}),(0,Y.jsxs)(`div`,{className:`px-5 py-4 space-y-3`,children:[(0,Y.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-medium`,children:s(`smashModal.modePickerLabel`)}),[`simple`,`full`].map(e=>{let t=Mi[e],n=c===e;return(0,Y.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,Y.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,Y.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,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,Y.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[e===`full`&&(0,Y.jsx)(ce,{className:`w-3.5 h-3.5 text-accent-highlight`,"aria-hidden":!0}),s(t.titleKey)]}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:s(t.etaKey)})]}),(0,Y.jsx)(`ul`,{className:`space-y-0.5`,children:t.bulletKeys.map(e=>(0,Y.jsxs)(`li`,{className:`text-[11px] text-foreground/70 leading-snug`,children:[`• `,s(e)]},e))})]})]})},e)})]}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-5 py-3 border-t border-border/30 bg-surface/20`,children:[(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,onClick:a,disabled:i,children:s(`common:actions.cancel`)}),(0,Y.jsxs)(W,{size:`sm`,onClick:()=>o(c),disabled:i,"data-testid":`smash-confirm-modal-continue`,children:[(0,Y.jsx)(St,{className:`w-3.5 h-3.5 mr-1.5`}),s(i?`smashModal.starting`:n?`smashModal.confirmReSmash`:`smashModal.smash`)]})]})]}),(0,Y.jsx)(de,{handles:p})]}),document.body):null}var Pi=`## Contract Layer`;function Fi(e,t){return!(!t||e.status===`draft`||e.parent_epic_id!=null||!e.description?.includes(Pi))}function Ii({ticket:e,projectId:t,provider:n,featureFlagOn:r,childrenCount:i}){let{t:a}=v(`activity`),o=Di(e.id),[s,c]=(0,J.useState)(!1),[l,u]=(0,J.useState)(!1),[d,p]=(0,J.useState)(e.origin_conversation_id?void 0:null);(0,J.useEffect)(()=>{let r=e.origin_conversation_id;if(!r){p(null);return}let i=!1;return p(void 0),fetch(`${f}/api/projects/${t}/chat/conversations/${encodeURIComponent(r)}`).then(async e=>{if(!e.ok)throw Error(`origin conversation lookup failed (${e.status})`);let t=await e.json();i||p(t.conversation?.provider??n??null)}).catch(()=>{i||p(null)}),()=>{i=!0}},[t,n,e.origin_conversation_id]);let m=e.origin_conversation_id?d:n,h=r&&C(m),g=e.is_epic===!0,_=!g&&Fi(e,h),y=g&&h,b=g&&i>0,x=(0,J.useCallback)(async n=>{if(h){u(!0);try{let r=await fetch(`${f}/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(()=>({}));S.error(e.reason?a(`smash.couldNotStartWithReason`,{reason:e.reason}):a(`smash.couldNotStart`));return}c(!1)}catch(e){S.error(a(`smash.smashFailed`,{message:e.message}))}finally{u(!1)}}},[t,e.id,a,h]),w=(0,J.useCallback)(async n=>{if(h){if(b){u(!0);try{if(!(await fetch(`${f}/api/projects/${t}/tickets/${e.id}/children`,{method:`DELETE`})).ok){S.error(a(`smash.couldNotDeleteChildren`)),u(!1);return}}catch(e){S.error(a(`smash.deleteFailed`,{message:e.message})),u(!1);return}}await x(n)}},[b,x,t,e.id,a,h]);return!_&&!y?null:o?(0,Y.jsx)(`div`,{className:`flex flex-col gap-2`,"data-testid":`smash-actions-streaming`,children:(0,Y.jsx)(ji,{stage:o.stage})}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(W,{size:`sm`,variant:`outline`,onClick:()=>c(!0),className:`border-accent-highlight/40 text-accent-highlight hover:bg-accent-highlight/10`,"data-testid":y?`resmash-button`:`smash-button`,children:[(0,Y.jsx)(St,{className:`w-3.5 h-3.5 mr-1.5`}),a(y?`smash.reSmashButton`:`smash.smashButton`)]}),(0,Y.jsx)(Ni,{open:s,ticketTitle:e.title,isReSmash:b,childrenCount:i,submitting:l,onCancel:()=>c(!1),onConfirm:w})]})}function Li({epic:e,childExecutionOrder:t,totalChildren:n,onOpenEpic:r}){let{t:i}=v(`activity`);return(0,Y.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,Y.jsxs)(`button`,{type:`button`,onClick:r,className:`text-accent-secondary hover:underline font-medium`,children:[`← `,e.title]}),t!=null&&n>0&&(0,Y.jsx)(`span`,{className:`text-foreground/60`,children:i(`epicChildren.step`,{order:t,total:n})})]})}var Ri={critical:`bg-red-400`,high:`bg-orange-400`,medium:`bg-yellow-400`,low:`bg-slate-400`};function zi(e){return e?Ri[e]:`bg-muted`}function Bi(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 Vi({ticket:e,allTickets:t,onOpenTicket:n}){let{t:r}=v(`activity`),i=e.is_epic===!0,a=e.parent_epic_id!=null;if(!i&&!a)return null;if(i){let i=Bi(t.filter(t=>t.parent_epic_id===e.id));return(0,Y.jsx)(Hi,{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=Bi(t.filter(t=>t.parent_epic_id===e.parent_epic_id)),c=o?[o,...s]:s;return(0,Y.jsx)(Hi,{header:r(`family.familyHeader`,{count:s.length}),rows:c,currentId:e.id,onOpenTicket:n,emptyMessage:r(`family.noSiblings`)})}function Hi({header:e,rows:t,currentId:n,onOpenTicket:r,emptyMessage:i}){let{t:a}=v(`activity`);return(0,Y.jsxs)(`div`,{"data-testid":`epic-family-sidebar`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,Y.jsx)(St,{className:`w-3 h-3 text-accent-highlight`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:e})]}),t.length===0?(0,Y.jsx)(`p`,{className:`text-[10px] text-foreground/50 italic`,children:i}):(0,Y.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,Y.jsx)(`li`,{children:(0,Y.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,Y.jsx)(O,{className:`w-3 h-3 text-accent-highlight flex-shrink-0`,"aria-hidden":!0}):(0,Y.jsx)(`span`,{className:`text-[9px] tabular-nums text-foreground/40 w-3 text-center flex-shrink-0`,children:e.execution_order??`–`}),(0,Y.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full flex-shrink-0 ${zi(e.priority)}`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`text-[11px] truncate ${t?`text-foreground font-medium`:`text-foreground/80`}`,title:e.title,children:e.title})]})},e.id)})})]})}var Ui=224,Wi=8,Gi=8;function Ki({rails:e,onMoveToRail:t,onClose:n,anchorRect:r}){let{t:i}=v(`tickets`),a=(0,J.useRef)(null),[o,s]=(0,J.useState)(!1);(0,J.useLayoutEffect)(()=>{let e=requestAnimationFrame(()=>s(!0));return()=>cancelAnimationFrame(e)},[]),(0,J.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,J.useMemo)(()=>{let e=r.left+r.width/2,t=e-Ui/2,n=window.innerWidth-Ui-Wi,i=Math.max(Wi,Math.min(n,t)),a=e-i,o=Math.max(12,Math.min(Ui-12,a));return{top:r.bottom+Gi,left:i,caretLeft:o}},[r]);return(0,Y.jsxs)(`div`,{ref:a,role:`dialog`,"aria-label":i(`rail.popoverTitle`),"data-testid":`move-to-rail-popover`,style:{top:c,left:l,width:Ui,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,Y.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,Y.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,Y.jsx)(`div`,{className:`px-2 py-2 text-xs text-muted-foreground`,children:i(`rail.noRails`)}):(0,Y.jsx)(`ul`,{className:`flex flex-col`,children:e.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.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,Y.jsx)(R,{className:`w-3 h-3 text-accent-success animate-pulse shrink-0`,"aria-hidden":!0}):(0,Y.jsx)(Ke,{className:`w-3 h-3 text-muted-foreground/60 shrink-0`,"aria-hidden":!0}),(0,Y.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),(0,Y.jsx)(He,{className:`w-3.5 h-3.5 text-muted-foreground/40 shrink-0`,"aria-hidden":!0})]})},e.id))})]})}var qi=900,Ji=.2,Yi=[`todo`,`in_progress`,`done`,`cancelled`],Xi={draft:`ticketStatus.draft`,todo:`ticketStatus.todo`,in_progress:`ticketStatus.inProgress`,on_review:`ticketStatus.onReview`,done:`ticketStatus.done`,cancelled:`ticketStatus.cancelled`},Zi=[{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 Qi(e){return e.jira_epic_key&&e.jira_url?e.jira_url.replace(/\/browse\/[^/]+$/,`/browse/${e.jira_epic_key}`):null}var $i={manual:`source.manual`,"product-backlog":`source.productBacklog`,"propose-spec":`source.proposeSpec`,"get-backlog-specs":`source.getBacklogSpecs`,"free-prompt":`source.freePrompt`};function ea({ticket:e,allLabels:t,allTickets:n,onClose:r,onOpenTicket:i,onSave:a,onDelete:s,rails:c,onMoveToRail:l,onRemoveFromRail:u,embedded:d=!1}){let{t:f}=v(`tickets`),{t:p}=v(`jira`),{activeProjectId:m,projects:h}=x(),{enterSplit:g,state:y}=Ca(),b=y.originSide!==null,w=h.find(e=>e.id===m)?.provider,E=C(w),D=(0,J.useMemo)(()=>(n??[]).filter(t=>t.parent_epic_id===e.id),[n,e.id]),O=(0,J.useMemo)(()=>e.parent_epic_id==null?null:(n??[]).find(t=>t.id===e.parent_epic_id)??null,[n,e.parent_epic_id]),k=(0,J.useMemo)(()=>O?(n??[]).filter(e=>e.parent_epic_id===O.id).length:0,[n,O]),[A,j]=(0,J.useState)(e.title),[M,N]=(0,J.useState)(e.description),[F,I]=(0,J.useState)(e.priority??`medium`),[R,z]=(0,J.useState)([...e.labels??[]]),[B,re]=(0,J.useState)(e.repositoryIds),[V,ae]=(0,J.useState)(!1),[ce,H]=(0,J.useState)(!1),[U,ve]=(0,J.useState)(``),[ye,xe]=(0,J.useState)(!1),[Se,Ce]=(0,J.useState)(!1),[we,Te]=(0,J.useState)(!1),[Ee,De]=(0,J.useState)(!1),[Oe,ke]=(0,J.useState)(!1),[Ae,je]=(0,J.useState)(!1),Me=Qn(),Ne=Me.connected&&!!Me.discardStatus&&e.source===`jira`&&!!e.jira_key,Pe=Me.connected&&e.source===`jira`&&!!e.jira_key,[Fe,Ie]=(0,J.useState)(e.attachments??[]);(0,J.useEffect)(()=>{Ie(e.attachments??[])},[e.attachments,e.id]);let[Le,Re]=(0,J.useState)(!1),[Be,Ve]=(0,J.useState)(null);(0,J.useEffect)(()=>{if(!Pe)return;let e=!0;return oe.listStatuses().then(t=>{e&&Ve(t.statuses)}).catch(()=>{e&&Ve([])}),()=>{e=!1}},[Pe,e.id]);let G=e.jira_status??``,He=async t=>{if(t!==e.status){Re(!0);try{await a(e.id,{status:t})}finally{Re(!1)}}},Ue=async t=>{if(!(!t||t===G)){Re(!0);try{await oe.moveSpecToStatus(e.id,t),S.success(p(`moveToStatus.queued`,{status:t}))}catch{S.error(p(`moveToStatus.failed`))}finally{Re(!1)}}},We=(0,J.useRef)(null),Ge=(0,J.useRef)(null),Ke=(0,J.useRef)(null),qe=(0,J.useMemo)(()=>A!==e.title||M!==e.description||F!==e.priority||JSON.stringify(R)!==JSON.stringify(e.labels)||JSON.stringify(B)!==JSON.stringify(e.repositoryIds),[A,M,F,R,B,e]);(0,J.useEffect)(()=>{V&&We.current?.focus()},[V]),(0,J.useEffect)(()=>{if(ce){let e=Ge.current;e&&(e.focus(),e.selectionStart=e.value.length)}},[ce]),(0,J.useEffect)(()=>{ye&&Ke.current?.focus()},[ye]),(0,J.useEffect)(()=>{function e(e){e.key===`Escape`&&!V&&!ce&&!Se&&r()}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,V,ce,Se]);let Ye=(0,J.useMemo)(()=>{if(!U.trim())return[];let e=U.toLowerCase();return t.filter(t=>t.toLowerCase().includes(e)&&!R.includes(t)).slice(0,5)},[U,t,R]),Xe=(0,J.useCallback)(e=>{let t=e.trim();t&&!R.includes(t)&&z(e=>[...e,t]),ve(``)},[R]),Ze=(0,J.useCallback)(e=>{z(t=>t.filter(t=>t!==e))},[]),Qe=(0,J.useCallback)(async()=>{let t={};if(A!==e.title&&(t.title=A),M!==e.description&&(t.description=M),F!==e.priority&&(t.priority=F),JSON.stringify(R)!==JSON.stringify(e.labels)&&(t.labels=R),JSON.stringify(B)!==JSON.stringify(e.repositoryIds)&&(t.repositoryIds=B),Object.keys(t).length===0){r();return}ke(!0);let n=await a(e.id,t);ke(!1),n?(S.success(f(`detailModal.toast.updated`)),r()):S.error(f(`detailModal.toast.updateFailed`))},[A,M,F,R,B,e,a,r,f]),$e=(0,J.useCallback)(async()=>{if(Ae)return;je(!0);let t=!1;try{t=await s(e.id)}catch{t=!1}if(je(!1),!t){S.error(f(`detailModal.toast.deleteFailed`));return}Ce(!1),r()},[Ae,e.id,s,r,f]),[et,tt]=(0,J.useState)(0),K=(0,J.useRef)(null),[nt,rt]=(0,J.useState)(()=>typeof window<`u`&&window.innerWidth>=qi);(0,J.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>rt(window.innerWidth>=qi);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let it=!d&&!b&&nt,at=(0,J.useCallback)(e=>{K.current&&tt(e.clientX-K.current.startX)},[]),q=(0,J.useCallback)(t=>{if(!K.current)return;let n=t.clientX-K.current.startX,i=window.innerWidth*Ji;if(window.removeEventListener(`pointermove`,at),window.removeEventListener(`pointerup`,q),window.removeEventListener(`pointercancel`,q),K.current=null,tt(0),Math.abs(n)>=i&&window.innerWidth>=qi){let t=y.leftId===e.id;g(n<0?`left`:`right`,e.id),t||r()}},[g,at,y.leftId,e.id,r]),ot=(0,J.useCallback)(e=>{it&&e.button===0&&(e.target.closest(`button, input, textarea, select, [contenteditable="true"]`)||(K.current={startX:e.clientX,pointerId:e.pointerId},window.addEventListener(`pointermove`,at),window.addEventListener(`pointerup`,q),window.addEventListener(`pointercancel`,q)))},[it,at,q]);(0,J.useEffect)(()=>()=>{K.current&&(window.removeEventListener(`pointermove`,at),window.removeEventListener(`pointerup`,q),window.removeEventListener(`pointercancel`,q))},[at,q]);let st=(0,J.useCallback)(()=>{if(!it||window.innerWidth<qi)return;let t=y.leftId===e.id;g(`right`,e.id),t||r()},[it,g,y.leftId,e.id,r]),{panelRef:ct,panelStyle:lt,resizeHandles:ut,guardBackdrop:dt}=le({enabled:!d,allowMove:!1}),ft=(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{ref:ct,className:d?`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] max-h-[calc(100%-2rem)]`,style:{...et===0?{transition:`transform 220ms cubic-bezier(0.34, 1.56, 0.64, 1)`}:{transform:`translateX(${et}px)`,transition:`none`},...lt},children:[O&&(0,Y.jsx)(`div`,{className:`px-5 pt-3`,children:(0,Y.jsx)(Li,{epic:O,childExecutionOrder:e.execution_order??null,totalChildren:k,onOpenEpic:()=>i?.(O.id)})}),(0,Y.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-5 py-4 border-b border-border/30 ${it?`cursor-grab active:cursor-grabbing`:``}`,onPointerDown:ot,"data-testid":`ticket-modal-header`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[V?(0,Y.jsx)(`input`,{ref:We,value:A,onChange:e=>j(e.target.value),onBlur:()=>ae(!1),onKeyDown:t=>{t.key===`Enter`&&ae(!1),t.key===`Escape`&&(j(e.title),ae(!1))},className:`w-full bg-transparent border-b border-accent-primary/50 text-sm font-semibold text-foreground outline-none pb-0.5`}):(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>ae(!0),className:`group flex items-center gap-1.5 text-left w-full`,children:[(0,Y.jsx)(`h2`,{className:`text-sm font-semibold text-foreground truncate`,children:A||f(`untitled`)}),(0,Y.jsx)(L,{className:`w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0`})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,Y.jsxs)(`span`,{className:`text-[10px] text-foreground font-mono`,children:[`#`,e.id]}),e.status===`on_review`&&(0,Y.jsx)(`span`,{title:f(`specs:status.onReviewHint`),"data-testid":`ticket-modal-on-review-badge`,children:(0,Y.jsx)(Zn,{status:`on_review`})})]}),(0,Y.jsx)(Jn,{ticketId:e.id})]}),m&&(0,Y.jsx)(`div`,{className:`shrink-0`,children:(0,Y.jsx)(Ii,{ticket:e,projectId:m,provider:w,featureFlagOn:E,childrenCount:D.length})}),(0,Y.jsx)(na,{ticket:e,title:A,description:M,priority:F,labels:R,repositoryIds:B,onClose:r}),c&&(l||u)&&(0,Y.jsx)(ra,{ticket:e,rails:c,onMoveToRail:l,onRemoveFromRail:u}),it&&(0,Y.jsxs)(W,{variant:`outline`,size:`sm`,className:`shrink-0 mr-1 gap-1.5`,"data-testid":`ticket-modal-compare`,onClick:st,title:f(`detailModal.compareTooltip`),children:[(0,Y.jsx)(Je,{className:`w-3.5 h-3.5`}),f(`detailModal.compare`)]}),(0,Y.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,Y.jsx)(se,{className:`w-4 h-4`})})]}),(0,Y.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:(0,Y.jsxs)(`div`,{className:`flex flex-col sm:flex-row h-full`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0 px-5 py-4 space-y-4 flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex-1 flex flex-col`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5`,children:f(`fields.description`)}),!ce&&(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>H(!0),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,Y.jsx)(L,{className:`w-2.5 h-2.5`}),f(`common:actions.edit`)]})]}),ce?(0,Y.jsxs)(`div`,{className:`space-y-1.5 flex-1 flex flex-col`,children:[(0,Y.jsx)(`textarea`,{ref:Ge,value:M,onChange:e=>N(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:f(`fields.markdownPlaceholder`)}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Y.jsx)(W,{variant:`ghost`,size:`sm`,className:`h-6 text-[10px]`,onClick:()=>H(!1),children:f(`detailModal.doneEditing`)}),(0,Y.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:f(`fields.supportsMarkdown`)})]})]}):M?(0,Y.jsx)(sa,{description:M,onEdit:()=>H(!0)}):(0,Y.jsx)(`button`,{type:`button`,onClick:()=>H(!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:f(`detailModal.addDescription`)})]}),(0,Y.jsx)(Gn,{ticket:e}),(0,Y.jsx)(Dn,{ticketKey:e.id,attachments:Fe,onChange:Ie}),(0,Y.jsx)(On,{ticketId:e.id,onClose:r}),e.prerequisites&&e.prerequisites.length>0&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:f(`detailModal.prerequisites`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.prerequisites.map(e=>(0,Y.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,Y.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,Y.jsxs)(`button`,{type:`button`,onClick:()=>{o(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,Y.jsx)(P,{className:`w-3.5 h-3.5 shrink-0`}),p(`detail.goToTicket`,{key:e.jira_key})]}),e.jira_epic_key&&(0,Y.jsxs)(`div`,{"data-testid":`jira-epic`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:p(`detail.epic`)}),(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>{let t=Qi(e);t&&o(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,Y.jsx)(`span`,{className:`font-mono text-accent-highlight shrink-0`,children:e.jira_epic_key}),e.jira_epic_name&&(0,Y.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.jira_epic_name})]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:f(`fields.status`)}),Pe?(0,Y.jsx)(`select`,{value:G,disabled:Le||Be===null,onChange:e=>{Ue(e.target.value)},className:`w-full h-7 rounded border border-border bg-input px-2 text-xs text-foreground disabled:opacity-60`,"data-testid":`ticket-jira-status-select`,children:Be===null?(0,Y.jsx)(`option`,{value:G,children:G||f(`states.loading`,{ns:`common`})}):(0,Y.jsxs)(Y.Fragment,{children:[G&&!Be.some(e=>e.name===G)&&(0,Y.jsx)(`option`,{value:G,children:G}),Be.map(e=>(0,Y.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}):(0,Y.jsxs)(`select`,{value:e.status,disabled:Le,onChange:e=>{He(e.target.value)},className:`w-full h-7 rounded border border-border bg-input px-2 text-xs text-foreground disabled:opacity-60`,"data-testid":`ticket-status-select`,children:[!Yi.includes(e.status)&&(0,Y.jsx)(`option`,{value:e.status,children:f(Xi[e.status],{ns:`tickets`})}),Yi.map(e=>(0,Y.jsx)(`option`,{value:e,children:f(Xi[e],{ns:`tickets`})},e))]})]}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:f(`fields.priority`)}),(0,Y.jsx)(`select`,{value:F,onChange:e=>I(e.target.value),className:`w-full h-7 rounded border border-border bg-input px-2 text-xs text-foreground`,children:Zi.map(e=>(0,Y.jsx)(`option`,{value:e.value,children:f(e.labelKey)},e.value))})]}),(0,Y.jsx)(be,{value:B,onChange:re,disabled:Oe}),(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:f(`fields.labels`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:R.map(e=>(0,Y.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,Y.jsx)(`button`,{type:`button`,onClick:()=>Ze(e),className:`text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,Y.jsx)(ee,{className:`w-2.5 h-2.5`})})]},e))}),ye?(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(`input`,{ref:Ke,value:U,onChange:e=>ve(e.target.value),onKeyDown:e=>{e.key===`Enter`&&U.trim()&&(e.preventDefault(),Xe(U)),e.key===`Escape`&&(xe(!1),ve(``))},onBlur:()=>{U.trim()&&Xe(U),xe(!1),ve(``)},placeholder:f(`detailModal.addLabelPlaceholder`),className:`w-full h-6 rounded border border-border bg-input px-2 text-[10px] text-foreground placeholder:text-muted-foreground`}),Ye.length>0&&(0,Y.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:Ye.map(e=>(0,Y.jsx)(`button`,{type:`button`,onMouseDown:t=>{t.preventDefault(),Xe(e)},className:`w-full text-left px-2 py-1 text-[10px] hover:bg-accent/50 text-foreground/80`,children:e},e))})]}):(0,Y.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,Y.jsx)(ne,{className:`w-2.5 h-2.5`}),f(`detailModal.addLabel`)]})]}),(0,Y.jsx)(Vi,{ticket:e,allTickets:n??[],onOpenTicket:e=>i?.(e)}),e.source===`jira`&&e.jira_key&&(0,Y.jsx)(nr,{localId:e.id}),e.metadata?.effort_level&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-0.5`,children:f(`detailModal.effort`)}),(0,Y.jsx)(`span`,{className:`text-xs text-foreground/70`,children:e.metadata.effort_level})]}),e.assignee&&(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-0.5`,children:f(`detailModal.assignee`)}),(0,Y.jsx)(`span`,{className:`text-xs text-foreground/70`,children:e.assignee})]})]})]})}),(0,Y.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-t border-border/30`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground`,children:[(0,Y.jsx)(`span`,{children:f(`meta.createdAgo`,{time:ta(e.created_at)})}),(0,Y.jsx)(`span`,{children:f(`meta.updatedAgo`,{time:ta(e.updated_at)})}),e.source&&(0,Y.jsx)(`span`,{className:`bg-muted/30 rounded px-1.5 py-0.5`,children:$i[e.source]?f($i[e.source]):e.source})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Ne?(0,Y.jsxs)(W,{variant:`ghost`,size:`sm`,className:`h-7 text-xs text-accent-info hover:bg-accent-info/10`,onClick:()=>Te(!0),"data-testid":`jira-move-to-button`,children:[(0,Y.jsx)(ze,{className:`w-3 h-3 mr-1`}),p(`discard.moveButton`,{status:Me.discardStatus})]}):(0,Y.jsxs)(W,{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:()=>Ce(!0),children:[(0,Y.jsx)(ie,{className:`w-3 h-3 mr-1`}),f(`common:actions.delete`)]}),qe&&(0,Y.jsxs)(W,{size:`sm`,className:`h-7 text-xs`,onClick:()=>{Pe?De(!0):Qe()},disabled:Oe||!A.trim(),children:[(0,Y.jsx)(T,{className:`w-3 h-3 mr-1`}),f(Oe?`common:states.saving`:`common:actions.save`)]})]})]})]}),(0,Y.jsx)(_e,{open:Se,onOpenChange:e=>{Ae||Ce(e)},children:(0,Y.jsxs)(ge,{className:`max-w-sm`,children:[(0,Y.jsxs)(he,{children:[(0,Y.jsx)(me,{children:f(`deleteDialog.title`)}),(0,Y.jsx)(pe,{children:(0,Y.jsx)(_,{t:f,i18nKey:`deleteDialog.body`,values:{id:e.id,title:e.title},components:{strong:(0,Y.jsx)(`span`,{className:`font-semibold text-foreground`})}})})]}),(0,Y.jsxs)(fe,{children:[(0,Y.jsx)(W,{variant:`outline`,size:`sm`,onClick:()=>Ce(!1),disabled:Ae,children:f(`common:actions.cancel`)}),(0,Y.jsxs)(W,{variant:`destructive`,size:`sm`,onClick:()=>{$e()},disabled:Ae,"aria-busy":Ae,children:[Ae?(0,Y.jsx)(te,{className:`w-3.5 h-3.5 mr-1.5 animate-spin`}):(0,Y.jsx)(ie,{className:`w-3.5 h-3.5 mr-1.5`}),f(`common:actions.delete`)]})]})]})}),Ne&&Me.discardStatus&&(0,Y.jsx)($n,{open:we,onOpenChange:Te,ticket:{id:e.id,title:e.title,jira_key:e.jira_key},discardStatus:Me.discardStatus,onDiscarded:r}),(0,Y.jsx)(_e,{open:Ee,onOpenChange:De,children:(0,Y.jsxs)(ge,{className:`max-w-md`,"data-testid":`jira-save-confirm`,children:[(0,Y.jsxs)(he,{children:[(0,Y.jsx)(me,{children:p(`detail.saveTitle`)}),(0,Y.jsx)(pe,{children:p(`detail.saveBody`,{key:e.jira_key??`#${e.id}`})})]}),(0,Y.jsxs)(fe,{children:[(0,Y.jsx)(W,{variant:`outline`,size:`sm`,onClick:()=>De(!1),children:f(`common:actions.cancel`)}),(0,Y.jsxs)(W,{size:`sm`,onClick:()=>{De(!1),Qe()},disabled:Oe,"data-testid":`jira-save-confirm-btn`,children:[(0,Y.jsx)(T,{className:`w-3.5 h-3.5 mr-1.5`}),p(`detail.saveConfirm`)]})]})]})})]});return d?ft:(0,ai.createPortal)((0,Y.jsxs)(`div`,{style:ue(),className:`fixed inset-0 z-[68] flex items-center justify-center`,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 bg-black/70`,onClick:dt(r)}),ft,(0,Y.jsx)(de,{handles:ut})]}),document.body)}function ta(e){try{return ye(new Date(e),{addSuffix:!0,locale:p()})}catch{return e}}function na({ticket:e,title:t,description:n,priority:r,labels:i,repositoryIds:a,onClose:o}){let{t:s}=v(`tickets`),{triggerResume:c}=k(),{activeProjectId:l}=x(),{closeTicketDetail:u}=Ca();return or(e)?(0,Y.jsxs)(W,{variant:`default`,size:`sm`,onClick:()=>{if(!l)return;let{body:d,criteria:f}=ir(n);c({kind:`explore-spec`,projectId:l,label:t||e.title||s(`detailModal.ticketFallbackLabel`,{id:e.id}),restoreRoute:`/`,params:{initialIdea:``,pendingSpecId:sr(),initialAttachmentIds:[],resumeConversationId:e.origin_conversation_id??void 0,editTicket:{id:e.id,title:t,description:d,labels:i,priority:r,repositoryIds:a,acceptanceCriteria:f,status:e.status}}}),u(),o()},className:`shrink-0 mr-2`,"data-testid":`continue-editing`,children:[(0,Y.jsx)(ft,{className:`w-3.5 h-3.5 mr-1.5`}),s(`detailModal.continueEditing`)]}):null}function ra({ticket:e,rails:t,onMoveToRail:n,onRemoveFromRail:r}){let{t:i}=v(`tickets`),[a,o]=(0,J.useState)(null),s=(0,J.useRef)(null),c=t.find(t=>t.ticketIds.includes(e.id));return c?r?(0,Y.jsxs)(W,{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,Y.jsx)(w,{className:`w-3.5 h-3.5`,"aria-hidden":!0}),i(`rail.removeFromRail`)]}):null:n?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(W,{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,Y.jsx)(ze,{className:`w-3.5 h-3.5`,"aria-hidden":!0})]}),a&&(0,Y.jsx)(Ki,{rails:t,anchorRect:a,onMoveToRail:t=>n(e.id,t),onClose:()=>o(null)})]}):null}var ia=`
11
+
12
+ ---
13
+
14
+ ## Contract Layer
15
+
16
+ `;function aa(e){let t=e.indexOf(ia);return t<0?{user:e,contract:null}:{user:e.slice(0,t),contract:e.slice(t+26)}}function oa(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 sa({description:e,onEdit:t}){let{t:n}=v(`tickets`),{openWebView:r}=xi(),{user:i,contract:a}=aa(e),o=i||e,s=(0,J.useMemo)(()=>({a:({href:e,children:t})=>(0,Y.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,Y.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,Y.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,Y.jsx)(U,{remarkPlugins:[ve],components:s,children:o})}),a&&(0,Y.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,Y.jsxs)(`summary`,{className:`cursor-pointer text-[10px] font-medium text-foreground/80 select-none flex items-center gap-2`,children:[n(`contractLayer.title`),(0,Y.jsx)(`span`,{className:`rounded-full bg-muted/40 px-1.5 text-[9px] text-foreground/60`,children:n(`contractLayer.populated`,{n:oa(a)})})]}),(0,Y.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,Y.jsx)(U,{remarkPlugins:[ve],components:s,children:a})})]})]})}var ca={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 la(e){try{return ye(new Date(e),{addSuffix:!0,locale:p()})}catch{return e}}function ua({tickets:e,excludeIds:t,onSelect:n}){let{t:r}=v(`tickets`),[i,a]=(0,J.useState)(``),o=(0,J.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,Y.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,Y.jsxs)(`div`,{className:`px-4 py-3 border-b border-border/30 flex items-center gap-2`,children:[(0,Y.jsx)(wt,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,Y.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:r(`comparePicker.title`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`comparePicker.count`,{n:o.length})})]}),(0,Y.jsx)(`div`,{className:`px-4 py-2 border-b border-border/20`,children:(0,Y.jsxs)(`div`,{className:`relative`,children:[(0,Y.jsx)(re,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,Y.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,Y.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`spec-compare-picker-list`,children:o.length===0?(0,Y.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center px-4 py-8 gap-2`,children:[(0,Y.jsx)(wt,{className:`w-6 h-6 text-muted-foreground/40`}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.trim()?r(`comparePicker.noMatches`):r(`comparePicker.empty`)})]}):(0,Y.jsx)(`ul`,{className:`divide-y divide-border/10`,children:o.map(e=>(0,Y.jsx)(`li`,{children:(0,Y.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,Y.jsx)(Xn,{status:e.status}),(0,Y.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:[`#`,e.id]}),e.priority&&ca[e.priority]&&(0,Y.jsx)(`span`,{className:`inline-flex items-center rounded px-1 py-0.5 text-[9px] font-medium border ${ca[e.priority]}`,children:r(`priority.${e.priority}`)})]}),(0,Y.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,Y.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,Y.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:[e.labels.slice(0,3).map(e=>(0,Y.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,Y.jsxs)(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.labels.length-3]})]}),(0,Y.jsx)(`p`,{className:`mt-1 text-[9px] text-muted-foreground`,children:r(`meta.updatedAgo`,{time:la(e.updated_at)})})]})]})},e.id))})})]})}var da=.25,fa=.75;function pa({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,J.useRef)(null),p=(0,J.useRef)(null),[m,h]=(0,J.useState)(!0);(0,J.useEffect)(()=>{let e=setTimeout(()=>h(!1),320);return()=>clearTimeout(e)},[]);let g=(0,J.useCallback)(e=>{if(!p.current)return;let t=window.innerWidth,n=e.clientX/t;u(Math.min(fa,Math.max(da,n)))},[u]),_=(0,J.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,J.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,J.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,J.useCallback)(t=>{let n=.04;t.key===`ArrowLeft`?(t.preventDefault(),u(Math.max(da,e.splitRatio-n))):t.key===`ArrowRight`?(t.preventDefault(),u(Math.min(fa,e.splitRatio+n))):t.key===`Home`?(t.preventDefault(),u(da)):t.key===`End`?(t.preventDefault(),u(fa)):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,Y.jsx)(ea,{ticket:f,allLabels:i,allTickets:r,onClose:d?c:()=>l(null,u),onOpenTicket:s,onSave:a,onDelete:o,embedded:!0},`${u}-${f.id}`):(0,Y.jsx)(ua,{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,ai.createPortal)((0,Y.jsxs)(`div`,{ref:f,"data-testid":`split-view-shell`,style:ue(),className:`fixed inset-0 z-[68] flex`,onClick:b,children:[(0,Y.jsx)(`div`,{className:`absolute inset-0 bg-black/70 pointer-events-none`,"aria-hidden":!0}),(0,Y.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,Y.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,Y.jsx)(`div`,{className:`h-full flex items-center justify-center p-2`,children:(0,Y.jsx)(`div`,{className:`w-full h-full max-h-[95vh]`,children:x(`left`)})})}),(0,Y.jsx)(`div`,{"data-testid":`split-divider`,role:`separator`,"aria-orientation":`vertical`,"aria-valuenow":Math.round(e.splitRatio*100),"aria-valuemin":Math.round(da*100),"aria-valuemax":Math.round(fa*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,Y.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,Y.jsx)(`div`,{className:`h-full flex items-center justify-center p-2`,children:(0,Y.jsx)(`div`,{className:`w-full h-full max-h-[95vh]`,children:x(`right`)})})})]})]}),document.body)}var ma=.5,ha=.25,ga=.75,_a={leftId:null,rightId:null,originSide:null,splitRatio:ma};function va(e){return Number.isFinite(e)?Math.min(ga,Math.max(ha,e)):ma}function ya(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:ma}:e.originSide!==null&&(e.leftId===t.id||e.rightId===t.id)?e:{..._a,leftId:t.id};case`closeAll`:return _a;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:ma}:{leftId:null,rightId:n,originSide:`right`,splitRatio:ma}}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{..._a,leftId:t}}case`setSplitRatio`:return{...e,splitRatio:va(t.ratio)};default:return e}}var ba=(0,J.createContext)(null),xa=900;function Sa({children:e}){let[t,n]=(0,J.useReducer)(ya,_a),{tickets:r,updateTicket:i,deleteTicket:a}=Ut(),{activeProjectId:o,setActiveProjectId:s}=x(),c=(0,J.useRef)(null);(0,J.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,J.useCallback)(e=>n({type:`openCentered`,id:e}),[]),u=(0,J.useCallback)((e,t)=>{if(e===o){n({type:`openCentered`,id:t});return}c.current={projectId:e,ticketId:t},s(e)},[o,s]),d=(0,J.useCallback)(()=>n({type:`closeAll`}),[]),f=(0,J.useCallback)((e,t)=>{typeof window<`u`&&window.innerWidth<xa||n({type:`enterSplit`,side:e,ticketId:t})},[]),p=(0,J.useCallback)((e,t)=>n({type:`setComparedTicket`,id:e,side:t}),[]),m=(0,J.useCallback)(()=>n({type:`exitSplit`}),[]),h=(0,J.useCallback)(e=>n({type:`setSplitRatio`,ratio:e}),[]);(0,J.useEffect)(()=>{if(typeof window>`u`)return;function e(){window.innerWidth<xa&&n({type:`exitSplit`})}return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let g=(0,J.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,J.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,Y.jsxs)(ba.Provider,{value:y,children:[e,!b&&_&&(0,Y.jsx)(ea,{ticket:_,allLabels:g,allTickets:r,onClose:d,onOpenTicket:l,onSave:i,onDelete:a},_.id),b&&(0,Y.jsx)(pa,{state:t,leftTicket:_,rightTicket:v,allTickets:r,allLabels:g,onSave:i,onDelete:a,onOpenTicket:l,onCloseAll:d,onSetCompared:p,onSetRatio:h,onExitSplit:m})]})}function Ca(){return(0,J.useContext)(ba)||{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:_a}}export{Ve as $,Xn as A,bt as B,xr as C,ir as D,or as E,dn as F,ot as G,ft as H,Ut as I,et as J,at as K,Ft as L,_n as M,pn as N,$n as O,xn as P,We as Q,It as R,Dr as S,sr as T,ut as U,vt as V,ct as W,Je as X,Qe as Y,Ke as Z,Tr as _,Ei as a,Ee as at,kr as b,gi as c,De as ct,ri as d,Me as dt,ze as et,Yr as f,Ne as ft,Ar as g,lr as h,Se as ht,Ki as i,Te as it,Bn as j,Qn as k,hi as l,Le as lt,Mr as m,Ie as mt,Ca as n,Oe as nt,bi as o,Fe as ot,Vr as p,Ce as pt,K as q,ea as r,ke as rt,xi as s,Ae as st,Sa as t,we as tt,li as u,Pe as ut,jr as v,Or as w,Er as x,cr as y,wt as z};
@@ -0,0 +1 @@
1
+ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t}from"./jsx-runtime-BbYvbtY8.js";import{j as n}from"./useSharedWebSocket-CcsE5986.js";import{a as r,d as i,f as a,i as o,l as s,p as c,s as l,u}from"./createLucideIcon-DtODIU64.js";var d=e(t()),f={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,"!doctype":!0,"!DOCTYPE":!0},p=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?("[^"]*"|'[^']*')/g;function m(e){let t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(f[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){let t=e.indexOf(`-->`);return{type:`comment`,comment:t===-1?``:e.slice(4,t)}}let r=new RegExp(p),i=null;for(;i=r.exec(e),i!==null;)if(i[0].trim())if(i[1]){let e=i[1].trim(),n=[e,null],a=e.indexOf(`=`);a>-1&&(n=[e.slice(0,a),e.slice(a+1)]),t.attrs[n[0]]=n[1],r.lastIndex--}else i[2]&&(t.attrs[i[2]]=i[3].trim().substring(1,i[3].length-1));return t}var h=/<!--[\s\S]*?-->|<[a-zA-Z0-9\-!/](?:"[^"]*"|'[^']*'|[^'">])*>/g,g=/<\/?([^\s]+?)[/\s>]/,_=/^\s*$/,v=/^(script|style)$/i,y=`\0`,b=Object.create(null);function x(e){e.forEach(function(e){if(e.type===`text`){e.content=e.content.split(y).join(`<`);return}if(e.type===`comment`){e.comment=e.comment.split(y).join(`<`);return}for(let t in e.attrs){let n=e.attrs[t];typeof n==`string`&&n.indexOf(y)>-1&&(e.attrs[t]=n.split(y).join(`<`))}e.children.length&&x(e.children)})}function S(e,t){let n=t&&t.components||b,r=t&&t.allowedTags,i=!1;if(r){let t=typeof r==`function`?r:function(e){return r.indexOf(e)>-1},n=``,a=0;h.lastIndex=0;let o;for(;o=h.exec(e);){let r=o[0];n+=e.slice(a,o.index);let s=r.match(g);r.startsWith(`<!--`)||s&&t(s[1])?(n+=r,a=o.index+r.length):(i=!0,n+=y,a=o.index+1,h.lastIndex=a)}e=n+e.slice(a)}let a=[],o=[],s,c=-1,l=!1,u=0,d;if(e.indexOf(`<`)!==0){let t=e.indexOf(`<`);a.push({type:`text`,content:t===-1?e:e.substring(0,t)})}let f=[],p;for(;p=h.exec(e);)f.push(p);return f.forEach(function(e,t){let n=e[0];if(!n||n.startsWith(`<!--`))return;let r=0,i=0,a=-1,o=null;for(let e=0;e<n.length;e++){let t=n.charAt(e);o?t===o&&(o=null):t===`"`||t===`'`?o=t:t===`<`?(r++,r===2&&(a=e)):t===`>`&&i++}let s=a>-1&&/[a-zA-Z0-9\-!/]/.test(n.charAt(a+1));if(r>i&&s){let e=n.substring(0,a),r=n.substring(e.length);f[t][0]=r,f[t].index+=e.length}}),f.forEach(function(t,r){let i=t[0];if(!i)return;let p=t.index;if(p<u)return;if(l){if(i!==`</`+s.name+`>`)return;l=!1}let h=i.charAt(1)!==`/`,g=i.startsWith(`<!--`),y=p+i.length,b=e.charAt(y),x=f[r+1],S;if(b===`<`&&x){let t=e.substring(y,x.index);S=t.split(`<`).length>t.split(`>`).length}let C;if(g){let t=m(i);if(c<0)return a.push(t),a;C=o[c],C.children.push(t);let n=e.slice(y,x?x.index:void 0);return n.length>0&&C.children.push({type:`text`,content:n}),a}if(h){c++,s=m(i),s.type===`tag`&&n[s.name]&&(s.type=`component`,l=!0);let t=!1;if(!l&&!s.voidElement&&v.test(s.name)){t=!0,d||=e.toLowerCase();let n=d.indexOf(`</`+s.name.toLowerCase()+`>`,y),r=n===-1?e.length:n,i=e.slice(y,r);i&&s.children.push({type:`text`,content:i}),u=r}!s.voidElement&&!l&&!t&&b&&b!==`<`&&s.children.push({type:`text`,content:e.slice(y,x?x.index:void 0)}),c===0&&a.push(s),C=o[c-1],C&&C.children.push(s),o[c]=s}if((!h||s.voidElement)&&(c>-1&&(s.voidElement||s.name===i.slice(2,-1))&&(c--,s=c===-1?a:o[c]),!l&&(b!==`<`||S)&&b)){C=c===-1?a:o[c].children;let t=x?x.index:-1,n=e.slice(y,t===-1?void 0:t);_.test(n)&&(n=` `),(t>-1&&c+C.length>=0||n!==` `)&&C.push({type:`text`,content:n})}}),i&&x(a),a}function C(e){let t=[];for(let n in e)e[n]===null?t.push(n):t.push(n+`="`+String(e[n]).replace(/"/g,`&quot;`)+`"`);return t.length?` `+t.join(` `):``}function w(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:{let n=t.voidElement&&t.name.toLowerCase()!==`!doctype`?`/>`:`>`;return e+=`<`+t.name+(t.attrs?C(t.attrs):``)+n,t.voidElement?e:e+t.children.reduce(w,``)+`</`+t.name+`>`}case`comment`:return e+=`<!--`+t.comment+`-->`,e}}function T(e){return e.reduce(function(e,t){return e+w(``,t)},``)}var E={parse:S,stringify:T},D=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},O=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?A(t):t},k=e=>A(e).every(d.isValidElement),A=e=>Array.isArray(e)?e:[e],j=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},M=e=>{let t={};if(!e)return t;let n=e=>{A(e).forEach(e=>{i(e)||(D(e)?n(O(e)):u(e)&&!(0,d.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},N=(e,t,n,r)=>{if(!e)return``;let o=``,s=A(e),c=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return s.forEach((e,s)=>{if(i(e)){o+=`${e}`;return}if((0,d.isValidElement)(e)){let{props:a,type:l}=e,u=Object.keys(a).length,d=c.indexOf(l)>-1,f=a.children;if(!f&&d&&!u){o+=`<${l}/>`;return}if(!f&&(!d||u)||a.i18nIsDynamicList){o+=`<${s}></${s}>`;return}if(d&&u<=1){let e=i(f)?f:N(f,t,n,r);o+=`<${l}>${e}</${l}>`;return}let p=N(f,t,n,r);o+=`<${s}>${p}</${s}>`;return}if(e===null){a(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(u(e)){let{format:t,...i}=e,s=Object.keys(i);if(s.length===1){let e=t?`${s[0]}, ${t}`:s[0];o+=`{{${e}}}`;return}a(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}a(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),o},P=(e,t,n,r,a,o,c)=>{if(n===``)return[];let f=a.transKeepBasicHtmlNodesFor||[],p=n&&new RegExp(f.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!p&&!c)return[n];let m=t??{},h=e=>{A(e).forEach(e=>{i(e)||(D(e)?h(O(e)):u(e)&&!(0,d.isValidElement)(e)&&Object.assign(m,e))})};h(e);let g=Object.keys(m),_=E.parse(`<0>${n}</0>`,{allowedTags:e=>/^\d+$/.test(e)||f.indexOf(e)>-1||g.indexOf(e)>-1}),v={...m,...o},y=(e,t,n)=>{let r=O(e),i=x(r,t.children,n);return k(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},b=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,d.cloneElement)(e,{key:r},i?void 0:t))):n.push(...d.Children.map([e],e=>{if(e.type===d.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,d.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,d.cloneElement)(e,n,i?null:t)}))},x=(e,n,o)=>{let m=A(e),h=A(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 l=m[parseInt(n.name,10)];!l&&t&&(l=t[n.name]),o.length===1&&!l&&(l=o[0][n.name]),l||={};let S={...n.attrs};c&&Object.keys(S).forEach(e=>{let t=S[e];i(t)&&(S[e]=s(t))});let C=Object.keys(S).length===0?l:j({props:S},l),w=(0,d.isValidElement)(C),T=w&&D(n,!0)&&!n.voidElement,E=p&&u(C)&&C.dummy&&!w,k=u(t)&&Object.hasOwnProperty.call(t,n.name);if(i(C)){let t=r.services.interpolator.interpolate(C,v,r.language);e.push(t)}else if(D(C)||T){let t=y(C,n,o);b(C,t,e,h)}else if(E){let t=x(m,n.children,o);b(C,t,e,h)}else if(Number.isNaN(parseFloat(n.name)))if(k){let t=y(C,n,o);b(C,t,e,h,n.voidElement)}else if(a.transSupportBasicHtmlNodes&&f.indexOf(n.name)>-1)if(n.voidElement)e.push((0,d.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,d.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let a=r?A(O(r)):m,s=x(a,n.children,o);e.push((0,d.createElement)(n.name,{key:`${n.name}-${h}`},s))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=x(m,n.children,o);e.push(`<${n.name}>${t}</${n.name}>`)}else if(u(C)&&!w){let t=n.children[0]?_:null;t&&e.push(t)}else b(C,_,e,h,n.children.length!==1||!_)}else if(n.type===`text`){let t=a.transWrapTextNodes,i=typeof a.unescape==`function`?a.unescape:l().unescape,o=c?i(r.services.interpolator.interpolate(n.content,v,r.language)):r.services.interpolator.interpolate(n.content,v,r.language);t?e.push((0,d.createElement)(t,{key:`${n.name}-${h}`},o)):e.push(o)}return e},[])};return O(x([{dummy:!0,children:e||[]}],_,A(e||[]))[0])},F=(e,t,n)=>{let r=e.key||t,i=(0,d.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,d.createElement)(d.Fragment,null,i)}return(0,d.createElement)(a,{key:r})},I=(e,t)=>e.map((e,n)=>F(e,n,t)),L=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:F(e[r],r,t)})}),n},R=(e,t,n,r)=>e?Array.isArray(e)?I(e,t):u(e)?L(e,t):(c(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,z=e=>!u(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function B({children:e,count:t,parent:a,i18nKey:o,context:s,tOptions:u={},values:f,defaults:p,components:m,ns:h,i18n:g,t:_,shouldUnescape:v,...y}){let b=g||r();if(!b)return c(b,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using initReactI18next or by passing it via props or context. In monorepo setups, make sure there is only one instance of react-i18next.`,{i18nKey:o}),e;let x=_||b.t.bind(b)||(e=>e),S={...l(),...b.options?.react},C=h||(x.ns?void 0:b.options?.defaultNS||`translation`);i(C)&&(C=[C]);let{transDefaultProps:w}=S,T=w?.tOptions?{...w.tOptions,...u}:u,E=v??w?.shouldUnescape,D=w?.values?{...w.values,...f}:f,O=w?.components?{...w.components,...m}:m,k=N(e,S,b,o),A=p||T?.defaultValue||k||S.transEmptyNodeValue||(typeof o==`function`?n(o):o),{hashTransKey:j}=S,F=o||(j?j(k||A):k||A);f=b.options?.interpolation?.defaultVariables?D&&Object.keys(D).length>0?{...D,...b.options.interpolation.defaultVariables}:{...b.options.interpolation.defaultVariables}:D;let I=M(e);I&&typeof I.count==`number`&&t===void 0&&(t=I.count);let L=f||t!==void 0&&!b.options?.interpolation?.alwaysFormat||!e?T.interpolation:{interpolation:{...T.interpolation,prefix:`#$?`,suffix:`?$#`}},B={...T,context:s||T.context,count:t,...f,...L,defaultValue:A,ns:C},V=F?x(F,B):A;V===F&&A&&(V=A);let H=R(O,V,b,o),U=H||e,W=null;z(H)&&(W=H,U=e);let G=P(U,W,V,b,S,B,E),K=a??S.defaultTransParent;return K?(0,d.createElement)(K,y,G):G}function V({children:e,count:t,parent:n,i18nKey:i,context:a,tOptions:s={},values:c,defaults:l,components:u,ns:f,i18n:p,t:m,shouldUnescape:h,...g}){let{i18n:_,defaultNS:v}=(0,d.useContext)(o)||{},y=p||_||r(),b=m||y?.t.bind(y);return B({children:e,count:t,parent:n,i18nKey:i,context:a,tOptions:s,values:c,defaults:l,components:u,ns:f||(b?.ns?void 0:v||y?.options?.defaultNS),i18n:y,t:m,shouldUnescape:h,...g})}export{V as t};