specrails-desktop 2.49.2 → 2.51.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/client/dist/assets/ActivityFeedPage-Bu6_Fxfa.js +1 -0
  2. package/client/dist/assets/{AgentBrowserCapture-DBGaKW4u.js → AgentBrowserCapture-ChIVaQ4N.js} +1 -1
  3. package/client/dist/assets/AgentModeAnalyticsPane-Dq59o2ZO.js +2 -0
  4. package/client/dist/assets/AgentModeCodePane-VjaDQOAZ.js +2 -0
  5. package/client/dist/assets/{AgentModeJobsPane-DkhcBtoZ.js → AgentModeJobsPane-DQST3Y8L.js} +1 -1
  6. package/client/dist/assets/AgentsPage-9ajYQTPV.js +87 -0
  7. package/client/dist/assets/{AnalyticsPage-DisrtBr7.js → AnalyticsPage-DgHAcKnO.js} +1 -1
  8. package/client/dist/assets/CodePage-tDBdWNkc.js +3 -0
  9. package/client/dist/assets/{DesktopAnalyticsPage-BFB-Pn-D.js → DesktopAnalyticsPage-fxggfmsY.js} +1 -1
  10. package/client/dist/assets/{DocsDialog-BwiFrwEJ.js → DocsDialog-0J6gUakl.js} +1 -1
  11. package/client/dist/assets/{DocsPage-ByS0ZCco.js → DocsPage-bQ6h2xx0.js} +1 -1
  12. package/client/dist/assets/{ExportDropdown-IPutNYvD.js → ExportDropdown-y2k4CoRJ.js} +1 -1
  13. package/client/dist/assets/InteractiveJobComposer-BI-y4fFH.js +19 -0
  14. package/client/dist/assets/{JobDetailModal-BnO_V8KR.js → JobDetailModal-B4cur32x.js} +1 -1
  15. package/client/dist/assets/JobDetailPage--VZYZ76E.js +1 -0
  16. package/client/dist/assets/JobsPage-K4wj2mXV.js +1 -0
  17. package/client/dist/assets/{LoopBuilderPage-WmqNpDw2.js → LoopBuilderPage-Cu9bNaZf.js} +2 -2
  18. package/client/dist/assets/{LoopPreviewModal-BY5dDezY.js → LoopPreviewModal-DmwboMLZ.js} +1 -1
  19. package/client/dist/assets/{LoopsPage-BcegqJyY.js → LoopsPage-Db8wSZSW.js} +1 -1
  20. package/client/dist/assets/{MinimizedChatsContext-CX1i2kQ8.js → MinimizedChatsContext-CoRyZxu4.js} +1 -1
  21. package/client/dist/assets/{PluginsPage-BhG3qPda.js → PluginsPage-A4dSzbGE.js} +2 -2
  22. package/client/dist/assets/{ProjectSettingsDialog-JQdLwCy2.js → ProjectSettingsDialog-DLrka37M.js} +1 -1
  23. package/client/dist/assets/{RepositoryDeliveries-DqmlG0Zs.js → RepositoryDeliveries-FYr8nbCo.js} +1 -1
  24. package/client/dist/assets/{RepositoryScopeSelector-DG8KKPrm.js → RepositoryScopeSelector-CBkDsqpz.js} +1 -1
  25. package/client/dist/assets/ReviewPacketPage-BGsesCFL.js +4 -0
  26. package/client/dist/assets/{TemplatePreviewModal-1AVv-hu4.js → TemplatePreviewModal-uGbE-mTU.js} +1 -1
  27. package/client/dist/assets/TicketDetailModalContext-lmkauO0-.js +16 -0
  28. package/client/dist/assets/{Trans-BLljsfHR.js → Trans-92vqs9mz.js} +1 -1
  29. package/client/dist/assets/{agent-BII69Nc0.js → agent-BaG10AN6.js} +1 -1
  30. package/client/dist/assets/{agent-CYFBDwFD.js → agent-CH4aJ884.js} +1 -1
  31. package/client/dist/assets/{agent-CVeMLIu4.js → agent-CLc9fA7v.js} +1 -1
  32. package/client/dist/assets/{agent-B76BhAyE.js → agent-DHh9-AdL.js} +1 -1
  33. package/client/dist/assets/{agent-DSrflYFL.js → agent-DkKnd6Wv.js} +1 -1
  34. package/client/dist/assets/{agent-BIO4q6b0.js → agent-aiVhqFW1.js} +1 -1
  35. package/client/dist/assets/{agent-ButS6kwl.js → agent-dbznD3eO.js} +1 -1
  36. package/client/dist/assets/{agent-D3jkMipn.js → agent-sMVFcPwL.js} +1 -1
  37. package/client/dist/assets/{formatDistanceToNow-CbQZkD8M.js → formatDistanceToNow-Cuoagaiu.js} +1 -1
  38. package/client/dist/assets/{getTimezoneOffsetInMilliseconds-pBVK3rJC.js → getTimezoneOffsetInMilliseconds-BLaUfsdD.js} +1 -1
  39. package/client/dist/assets/index-BAtqmAZR.css +2 -0
  40. package/client/dist/assets/index-Cxdhikml.js +80 -0
  41. package/client/dist/assets/{jira-api-f-sYCIuX.js → jira-api-DqYxW5BY.js} +1 -1
  42. package/client/dist/assets/layers-eDMjG41I.js +1 -0
  43. package/client/dist/assets/{packet-DQ_GnT2b.js → packet-CjS_478C.js} +1 -1
  44. package/client/dist/assets/{packet-r7J14m89.js → packet-D69dKsHN.js} +1 -1
  45. package/client/dist/assets/{packet-DF-iwqqY.js → packet-D9rU6Oxo.js} +1 -1
  46. package/client/dist/assets/{packet-Nb8BLI5h.js → packet-DMDFoamg.js} +1 -1
  47. package/client/dist/assets/{packet-C0pcMd6x.js → packet-Dd2RMs1h.js} +1 -1
  48. package/client/dist/assets/{packet-BsRimSfZ.js → packet-DjC9OibC.js} +1 -1
  49. package/client/dist/assets/packet-DwPtJoDz.js +1 -0
  50. package/client/dist/assets/{packet-C8qzvgrZ.js → packet-ceahDg8_.js} +1 -1
  51. package/client/dist/assets/{project-repositories-DAjJbFhm.js → project-repositories-DbVfkVQJ.js} +1 -1
  52. package/client/dist/assets/rotate-ccw-Wh4id13q.js +1 -0
  53. package/client/dist/assets/specs-Bqvtz2kz.js +1 -0
  54. package/client/dist/assets/specs-CKes-kz6.js +1 -0
  55. package/client/dist/assets/specs-CfXxPDNB.js +1 -0
  56. package/client/dist/assets/specs-CyF9HuTI.js +1 -0
  57. package/client/dist/assets/specs-DMj035Mt.js +1 -0
  58. package/client/dist/assets/specs-DfIdoU5L.js +1 -0
  59. package/client/dist/assets/specs-j5pGLQeU.js +1 -0
  60. package/client/dist/assets/specs-xW5pkkB7.js +1 -0
  61. package/client/dist/assets/{spending-DJBbdJyD.js → spending-ul_XBA3M.js} +1 -1
  62. package/client/dist/assets/{tickets-Bc71ce1C.js → tickets--tiSOCcn.js} +1 -1
  63. package/client/dist/assets/{tickets-CLg7VTJ8.js → tickets-BUJ3DMWU.js} +1 -1
  64. package/client/dist/assets/{tickets-CZNBiHbq.js → tickets-C1WNPODq.js} +1 -1
  65. package/client/dist/assets/{tickets-DlX2mEkD.js → tickets-CDjhWmiE.js} +1 -1
  66. package/client/dist/assets/{tickets-B4rjuSYi.js → tickets-CLgPC3uO.js} +1 -1
  67. package/client/dist/assets/tickets-D41ZMQpf.js +1 -0
  68. package/client/dist/assets/{tickets-CP9U1GJt.js → tickets-DEaQC06P.js} +1 -1
  69. package/client/dist/assets/{tickets-_yKvCt4Y.js → tickets-kcMzbLCp.js} +1 -1
  70. package/client/dist/assets/{useDesktop-BJ8IRBRt.js → useDesktop-BC_4XGnf.js} +1 -1
  71. package/client/dist/assets/{useRuntimeRuns-Ch1KUc7k.js → useRuntimeRuns-B_YsBTsN.js} +1 -1
  72. package/client/dist/assets/{useSharedWebSocket-BN3Lmehi.js → useSharedWebSocket-8NyZpT6v.js} +2 -2
  73. package/client/dist/assets/zap-CUOlvtT1.js +1 -0
  74. package/client/dist/index.html +22 -20
  75. package/docs/creating-specs.md +31 -0
  76. package/docs/guide/de/specs/1-specs-and-the-backlog.md +4 -0
  77. package/docs/guide/en/specs/1-specs-and-the-backlog.md +4 -0
  78. package/docs/guide/es/specs/1-specs-and-the-backlog.md +4 -0
  79. package/docs/guide/fr/specs/1-specs-and-the-backlog.md +4 -0
  80. package/docs/guide/it/specs/1-specs-and-the-backlog.md +4 -0
  81. package/docs/guide/ja/specs/1-specs-and-the-backlog.md +4 -0
  82. package/docs/guide/pt/specs/1-specs-and-the-backlog.md +4 -0
  83. package/docs/guide/zh/specs/1-specs-and-the-backlog.md +4 -0
  84. package/docs/internals/safe-pr-review-flow.md +80 -0
  85. package/docs/internals/spec-addenda.md +166 -0
  86. package/docs/mcp.md +1 -1
  87. package/package.json +1 -1
  88. package/server/dist/agent-context-resolver.js +5 -0
  89. package/server/dist/agent-operator-prompt.js +41 -1
  90. package/server/dist/db.js +22 -0
  91. package/server/dist/jira/jira-materializer.js +3 -0
  92. package/server/dist/loop-run-manager.js +6 -1
  93. package/server/dist/mcp/guide.js +10 -0
  94. package/server/dist/mcp/tools/rails.js +24 -0
  95. package/server/dist/mcp/tools/specs.js +68 -3
  96. package/server/dist/multi-repo-delivery.js +4 -0
  97. package/server/dist/pr-follow-up-scope.js +224 -0
  98. package/server/dist/pr-follow-up.js +75 -0
  99. package/server/dist/project-registry.js +43 -0
  100. package/server/dist/project-router-tickets.js +223 -0
  101. package/server/dist/queue-manager.js +34 -1
  102. package/server/dist/rail-isolated-launch.js +16 -0
  103. package/server/dist/rail-launch-parser.js +12 -0
  104. package/server/dist/rail-pr-decision.js +20 -3
  105. package/server/dist/rail-pr-store.js +40 -3
  106. package/server/dist/rail-pr-ticket-effects.js +21 -0
  107. package/server/dist/rails-router.js +63 -3
  108. package/server/dist/review-packet.js +45 -0
  109. package/server/dist/spec-addenda-core.js +281 -0
  110. package/server/dist/spec-addenda.js +338 -0
  111. package/server/dist/ticket-store.js +5 -1
  112. package/client/dist/assets/ActivityFeedPage-CyOxof-U.js +0 -1
  113. package/client/dist/assets/AgentModeAnalyticsPane-WZpPaNMa.js +0 -2
  114. package/client/dist/assets/AgentModeCodePane-nHYnJUdP.js +0 -2
  115. package/client/dist/assets/AgentsPage-CX90q-nY.js +0 -87
  116. package/client/dist/assets/CodePage-ixqxftCT.js +0 -3
  117. package/client/dist/assets/InteractiveJobComposer-BEok7ntM.js +0 -19
  118. package/client/dist/assets/JobDetailPage-BnS8aHKD.js +0 -1
  119. package/client/dist/assets/JobsPage-BC0mq-MF.js +0 -1
  120. package/client/dist/assets/ReviewPacketPage-DSSi3x16.js +0 -4
  121. package/client/dist/assets/TicketDetailModalContext-D2MEhRwJ.js +0 -14
  122. package/client/dist/assets/index-DEqG4WdV.js +0 -80
  123. package/client/dist/assets/index-UDzndadF.css +0 -2
  124. package/client/dist/assets/packet-BTRySHoQ.js +0 -1
  125. package/client/dist/assets/specs-BcyxaCwf.js +0 -1
  126. package/client/dist/assets/specs-C1q9geAi.js +0 -1
  127. package/client/dist/assets/specs-CLZKysq-.js +0 -1
  128. package/client/dist/assets/specs-DII0C8gw.js +0 -1
  129. package/client/dist/assets/specs-DZMS9o54.js +0 -1
  130. package/client/dist/assets/specs-Dm6zUI-R.js +0 -1
  131. package/client/dist/assets/specs-V3TvhKLX.js +0 -1
  132. package/client/dist/assets/specs-dV3Mq5Mu.js +0 -1
  133. package/client/dist/assets/tickets-W6pBmbrX.js +0 -1
  134. package/client/dist/assets/zap-CHo3aCD1.js +0 -1
@@ -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-xXB2q5HJ.js";import{t as f}from"./button-Ccc9Dc-D.js";import{Ht as p,Pt as m,q as h,st as g}from"./index-DEqG4WdV.js";var _=e(),v={start:i,"ai-step":p,shell:g,decider:r,condition:r,end:a};function y(e){return e.type===`ai-step`?typeof e.data?.prompt==`string`?e.data.prompt:null:e.type===`shell`?typeof e.data?.command==`string`?e.data.command:null:e.type===`decider`?typeof e.data?.goal==`string`?e.data.goal:null:e.type===`end`?e.data?.outcome===`failure`?`failure`:`success`:null}function b({template:e,onClose:r,onUse:i,mode:g=`use`}){let{t:b}=t(`loops`);return(0,_.jsx)(d,{open:e!==null,onOpenChange:e=>{e||r()},children:(0,_.jsx)(u,{movableResizable:!0,className:`max-w-lg`,children:e&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(l,{children:[(0,_.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,_.jsx)(p,{className:`w-4 h-4 text-accent-highlight`}),e.name]}),(0,_.jsx)(s,{children:e.description})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[h(e.graph)?(0,_.jsx)(`span`,{title:b(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:b(`gallery.needsSpec`)}):(0,_.jsx)(`span`,{title:b(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:b(`gallery.standalone`)}),e.category&&(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info`,children:b(`categories.${e.category}`,{defaultValue:e.category})}),e.tags.map(e=>(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,_.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.graph.config.timeoutMinutes>0?b(`preview.limits`,{iterations:e.graph.config.maxIterations,timeout:e.graph.config.timeoutMinutes}):b(`preview.limitsNoTimeout`,{iterations:e.graph.config.maxIterations})}),(0,_.jsxs)(`div`,{className:`max-h-[50vh] overflow-y-auto space-y-1.5 pr-1`,children:[(0,_.jsx)(`span`,{className:`block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:b(`preview.steps`)}),e.graph.nodes.map((e,t)=>{let n=v[e.type]??a,r=y(e);return(0,_.jsxs)(`div`,{className:`rounded border border-border bg-surface/30 p-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,_.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,_.jsx)(n,{className:`w-3.5 h-3.5 text-accent-primary`}),b(`builder.nodes.${e.type}`)]}),r&&(0,_.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-muted-foreground font-mono`,children:r})]},e.id)})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(f,{variant:`ghost`,onClick:r,children:b(`common:actions.cancel`)}),(0,_.jsxs)(f,{onClick:()=>i(e.id),children:[g===`fork`?(0,_.jsx)(m,{className:`w-3.5 h-3.5 mr-1.5`}):(0,_.jsx)(n,{className:`w-3.5 h-3.5 mr-1.5`}),b(g===`fork`?`actions.fork`:`actions.use`)]})]})]})})})}export{b as n,y as r,v as t};
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-xXB2q5HJ.js";import{t as f}from"./button-Ccc9Dc-D.js";import{Nt as p,Vt as m,q as h,st as g}from"./index-Cxdhikml.js";var _=e(),v={start:i,"ai-step":m,shell:g,decider:r,condition:r,end:a};function y(e){return e.type===`ai-step`?typeof e.data?.prompt==`string`?e.data.prompt:null:e.type===`shell`?typeof e.data?.command==`string`?e.data.command:null:e.type===`decider`?typeof e.data?.goal==`string`?e.data.goal:null:e.type===`end`?e.data?.outcome===`failure`?`failure`:`success`:null}function b({template:e,onClose:r,onUse:i,mode:g=`use`}){let{t:b}=t(`loops`);return(0,_.jsx)(d,{open:e!==null,onOpenChange:e=>{e||r()},children:(0,_.jsx)(u,{movableResizable:!0,className:`max-w-lg`,children:e&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(l,{children:[(0,_.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,_.jsx)(m,{className:`w-4 h-4 text-accent-highlight`}),e.name]}),(0,_.jsx)(s,{children:e.description})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[h(e.graph)?(0,_.jsx)(`span`,{title:b(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:b(`gallery.needsSpec`)}):(0,_.jsx)(`span`,{title:b(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:b(`gallery.standalone`)}),e.category&&(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info`,children:b(`categories.${e.category}`,{defaultValue:e.category})}),e.tags.map(e=>(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,_.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.graph.config.timeoutMinutes>0?b(`preview.limits`,{iterations:e.graph.config.maxIterations,timeout:e.graph.config.timeoutMinutes}):b(`preview.limitsNoTimeout`,{iterations:e.graph.config.maxIterations})}),(0,_.jsxs)(`div`,{className:`max-h-[50vh] overflow-y-auto space-y-1.5 pr-1`,children:[(0,_.jsx)(`span`,{className:`block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:b(`preview.steps`)}),e.graph.nodes.map((e,t)=>{let n=v[e.type]??a,r=y(e);return(0,_.jsxs)(`div`,{className:`rounded border border-border bg-surface/30 p-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,_.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,_.jsx)(n,{className:`w-3.5 h-3.5 text-accent-primary`}),b(`builder.nodes.${e.type}`)]}),r&&(0,_.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-muted-foreground font-mono`,children:r})]},e.id)})]}),(0,_.jsxs)(o,{children:[(0,_.jsx)(f,{variant:`ghost`,onClick:r,children:b(`common:actions.cancel`)}),(0,_.jsxs)(f,{onClick:()=>i(e.id),children:[g===`fork`?(0,_.jsx)(p,{className:`w-3.5 h-3.5 mr-1.5`}):(0,_.jsx)(n,{className:`w-3.5 h-3.5 mr-1.5`}),b(g===`fork`?`actions.fork`:`actions.use`)]})]})]})})})}export{b as n,y as r,v 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/dist-js-Rlh4FLH5.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-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{u as a}from"./chunk-KS7C4IRE-DEKu087k.js";import{D as o,E as s,a as c,h as l,l as u,m as d,r as f,w as p,x as m}from"./useSharedWebSocket-8NyZpT6v.js";import{t as h}from"./Trans-92vqs9mz.js";import{n as g,t as _}from"./createLucideIcon-Bjbbp_KS.js";import{a as v,r as y,s as b}from"./useDesktop-BC_4XGnf.js";import{a as x}from"./provider-capabilities-Vi1ZGvAK.js";import{n as S,t as C}from"./save-B6wGWwBR.js";import{n as w,r as T}from"./spending-ul_XBA3M.js";import{c as E,d as D,n as O,u as k}from"./MinimizedChatsContext-CoRyZxu4.js";import{n as A,t as j}from"./zap-CUOlvtT1.js";import{t as ee}from"./circle-x-CMYsN4ZH.js";import{t as M}from"./download-CFHyyHcw.js";import{t as te}from"./file-text-CFT-xXKN.js";import{t as N}from"./git-branch-BRM0F5GN.js";import{t as ne}from"./layers-eDMjG41I.js";import{t as P}from"./loader-circle-DcygOQpC.js";import{t as F}from"./pencil-C9RkrIPZ.js";import{n as I,t as L}from"./square-Ci-PFcFe.js";import{t as re}from"./plus-CsnjfkmX.js";import{t as R}from"./rotate-ccw-Wh4id13q.js";import{t as ie}from"./search-Cq_gE3Ik.js";import{t as ae}from"./trash-2-BOU3WdZZ.js";import{t as z}from"./triangle-alert-H9T4jAmh.js";import{t as oe}from"./wrench-BfmNO9Vw.js";import{t as se}from"./x-CBMI9ejn.js";import{M as ce,N as le,a as ue,i as de,j as fe,l as pe,o as me,r as he,t as ge}from"./dialog-xXB2q5HJ.js";import{t as B}from"./utils-BC4DHlz2.js";import{n as _e,t as V}from"./lib-CGdyxIWg.js";import{t as H}from"./formatDistanceToNow-Cuoagaiu.js";import{t as U}from"./button-Ccc9Dc-D.js";import{t as ve}from"./jira-api-DqYxW5BY.js";import{t as ye}from"./RepositoryScopeSelector-CBkDsqpz.js";function be(){return typeof window<`u`&&window.__TAURI_INTERNALS__!==void 0}async function xe(e){if(!be())return;let{invoke:t}=await i(async()=>{let{invoke:e}=await import(`./core-B3mKBIh5.js`).then(e=>e.i);return{invoke:e}},__vite__mapDeps([0,1]));await t(`desktop_reveal_path`,{path:e})}async function W(e){if(be())try{let t=await i(()=>import(`./dist-js-Rlh4FLH5.js`),__vite__mapDeps([2,0,1]));if(typeof t.open==`function`){await t.open(e);return}}catch(e){console.warn(`[openExternalUrl] tauri shell open failed:`,e)}try{window.open(e,`_blank`,`noopener,noreferrer`)}catch{}}function Se(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 Ce=Se(),we=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_TERMINAL_PANEL;return typeof e!=`string`||e!==`false`})(),Te=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_AGENTS_SECTION;return typeof e!=`string`||e!==`false`})(),Ee=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_CODE_EXPLORER;return typeof e!=`string`||e!==`false`})(),De=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_JIRA;return typeof e!=`string`||e!==`false`})(),Oe=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_MCP;return typeof e!=`string`||e!==`false`})(),ke=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_AGENT_CHAT;return typeof e!=`string`||e!==`false`})(),Ae=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_AGENT_MODE;return ke&&(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 je=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_LOOPS_SECTION;return typeof e!=`string`||e!==`false`})(),Me=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_NATIVE_BROWSER;return typeof e!=`string`||e!==`false`})(),Ne=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_PROJECT_BUILDER;return typeof e!=`string`||e!==`false`})(),Pe=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_REVIEW_PACKET;return typeof e!=`string`||e!==`false`})(),Fe=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_NARRATED_PROGRESS;return typeof e!=`string`||e!==`false`})(),Ie=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_LOCAL_ENGINES;return typeof e!=`string`||e!==`false`})();function Le(){return Ie}var Re=(()=>{let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_MISSION_RAIL_CARDS;return typeof e!=`string`||e!==`false`})(),ze=_(`arrow-right`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}],[`path`,{d:`m12 5 7 7-7 7`,key:`xquz4c`}]]),Be=_(`camera`,[[`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`}]]),Ve=_(`circle-arrow-right`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m12 16 4-4-4-4`,key:`1i9zcv`}],[`path`,{d:`M8 12h8`,key:`1wcyev`}]]),G=_(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),He=_(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),Ue=_(`columns-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M12 3v18`,key:`108xh3`}]]),We=_(`droplet`,[[`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`}]]),Ge=_(`file-minus-corner`,[[`path`,{d:`M20 14V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12`,key:`l9p8hp`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 18h6`,key:`1m8k6r`}]]),Ke=_(`file-plus-corner`,[[`path`,{d:`M11.35 22H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v5.35`,key:`17jvcc`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M14 19h6`,key:`bvotb8`}],[`path`,{d:`M17 16v6`,key:`18yu1i`}]]),qe=_(`git-commit-horizontal`,[[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}],[`line`,{x1:`3`,x2:`9`,y1:`12`,y2:`12`,key:`1dyftd`}],[`line`,{x1:`15`,x2:`21`,y1:`12`,y2:`12`,key:`oup4p8`}]]),Je=_(`git-pull-request-arrow`,[[`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`}]]),Ye=_(`git-pull-request`,[[`circle`,{cx:`18`,cy:`18`,r:`3`,key:`1xkwt0`}],[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v7`,key:`1yeb86`}],[`line`,{x1:`6`,x2:`6`,y1:`9`,y2:`21`,key:`rroup`}]]),Xe=_(`globe`,[[`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`}]]),Ze=_(`hash`,[[`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`}]]),Qe=_(`message-square-text`,[[`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`}]]),$e=_(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),et=_(`mouse-pointer-2`,[[`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`}]]),tt=_(`redo-2`,[[`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`}]]),K=_(`rotate-cw`,[[`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`}]]),nt=_(`shield-alert`,[[`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`}]]),rt=_(`split`,[[`path`,{d:`M16 3h5v5`,key:`1806ms`}],[`path`,{d:`M8 3H3v5`,key:`15dfkv`}],[`path`,{d:`M12 22v-8.3a4 4 0 0 0-1.172-2.872L3 3`,key:`1qrqzj`}],[`path`,{d:`m15 9 6-6`,key:`ko1vev`}]]),q=_(`ticket`,[[`path`,{d:`M2 9a3 3 0 0 1 0 6v2a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-2a3 3 0 0 1 0-6V7a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2Z`,key:`qn84l0`}],[`path`,{d:`M13 5v2`,key:`dyzc3o`}],[`path`,{d:`M13 17v2`,key:`1ont0d`}],[`path`,{d:`M13 11v2`,key:`1wjjxi`}]]),it=_(`type`,[[`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`}]]),J=_(`undo-2`,[[`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`}]]),at=_(`zoom-in`,[[`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`}]]),ot=_(`zoom-out`,[[`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`}]]),st=new Map,ct=2e3;function lt(e){st.set(e,(st.get(e)??0)+1)}function ut(e){(st.get(e)??0)<=0||setTimeout(()=>{let t=(st.get(e)??0)-1;t<=0?st.delete(e):st.set(e,t)},ct)}function dt(e){return e?(st.get(e)??0)>0:!1}var Y=e(t(),1),ft=3e3,pt=`
3
+
4
+ ---
5
+
6
+ ## Contract Layer
7
+
8
+ `;function mt(e){return`${u}/api/projects/${encodeURIComponent(e)}`}function ht(e,t){return JSON.stringify(e)===JSON.stringify(t)}function gt(e,t){let n=new Map(e.map(e=>[e.id,e])),r=t.map(e=>{let t=n.get(e.id);return t&&ht(t,e)?t:e});return r.length===e.length&&r.every((t,n)=>t===e[n])?e:r}function _t(){let{t:e}=g(`tickets`),{activeProjectId:t}=y(),[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(new Set),[u,d]=(0,Y.useState)(new Set),p=(0,Y.useRef)(t);p.current=t;let m=(0,Y.useRef)(0),h=(0,Y.useRef)(null),_=(0,Y.useRef)(new Set),{registerHandler:v,unregisterHandler:x,connectionStatus:S}=f(),C=(0,Y.useId)(),w=(0,Y.useCallback)(async(e,t)=>{let n=mt(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,Y.useCallback)(async(t,n)=>{let i=++m.current;h.current?.abort();let o=new AbortController;h.current=o,p.current===t&&(a(!0),s(null));try{let a=await w(t,o.signal);if(o.signal.aborted||i!==m.current||p.current!==t)return;let s=_.current,c=new Set;if(n===`merge`)for(let e of a)s.size>0&&!s.has(e.id)&&c.add(e.id);_.current=new Set(a.map(e=>e.id)),r(n===`replace`?a:e=>gt(e,a)),c.size>0&&s.size>0&&(l(c),b.success(e(`toasts.newTicketsAdded`,{count:c.size}),{id:`tickets-added-${t}`}),setTimeout(()=>{p.current===t&&l(e=>{let t=new Set(e);for(let e of c)t.delete(e);return t})},ft))}catch(e){if(o.signal.aborted||i!==m.current||p.current!==t)return;s(e instanceof Error?e.message:String(e))}finally{i===m.current&&(h.current===o&&(h.current=null),p.current===t&&a(!1))}},[w,e]),E=(0,Y.useCallback)(async()=>{t&&await T(t,`merge`)},[t,T]);(0,Y.useEffect)(()=>{if(m.current+=1,h.current?.abort(),h.current=null,r([]),a(!1),s(null),_.current=new Set,l(new Set),d(new Set),t)return T(t,`replace`),()=>{m.current+=1,h.current?.abort(),h.current=null}},[t,T]);let D=(0,Y.useCallback)(t=>{let n=t;if(!n||typeof n.type!=`string`)return;let i=p.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]),_.current.add(t.id),l(e=>new Set([...e,t.id])),dt(i)||b.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})},ft);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(pt)&&d(t=>{if(!t.has(e.id))return t;let n=new Set(t);return n.delete(e.id),n});break}case`ticket_deleted`:{if(n.ticketId==null)break;let e=n.ticketId;r(t=>t.filter(t=>t.id!==e)),_.current.delete(e);break}case`explore.contract_refine_started`:if(n.ticketId==null)break;d(e=>new Set([...e,n.ticketId]));break;case`explore.contract_refine_failed`:{if(n.ticketId==null)break;let e=n.ticketId;d(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n});break}}},[E,e]);(0,Y.useLayoutEffect)(()=>(v(`tickets-${C}`,D),()=>x(`tickets-${C}`)),[D,v,x,C]);let O=(0,Y.useRef)(S);return(0,Y.useEffect)(()=>{O.current!==`connected`&&S===`connected`&&p.current&&E(),O.current=S},[S,E]),{tickets:n,loading:i,isLoading:i,error:o,newTicketIds:c,contractRefiningIds:u,refetch:E,refresh:E,deleteTicket:(0,Y.useCallback)(async e=>{let n=t;if(!n)return!1;try{let t=await fetch(`${mt(n)}/tickets/${e}`,{method:`DELETE`});return t.ok&&p.current===n&&await T(n,`merge`),t.ok}catch{return!1}},[t,T]),updateTicketStatus:(0,Y.useCallback)(async(e,n)=>{let r=t;if(!r)return!1;try{let t=await fetch(`${mt(r)}/tickets/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({status:n})});return t.ok&&p.current===r&&await T(r,`merge`),t.ok}catch{return!1}},[t,T]),updateTicketPriority:(0,Y.useCallback)(async(e,n)=>{let r=t;if(!r)return!1;try{let t=await fetch(`${mt(r)}/tickets/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify({priority:n})});return t.ok&&p.current===r&&await T(r,`merge`),t.ok}catch{return!1}},[t,T]),createTicket:(0,Y.useCallback)(async e=>{let n=t;if(!n)return!1;try{let t=await fetch(`${mt(n)}/tickets`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});return t.ok&&p.current===n&&await T(n,`merge`),t.ok}catch{return!1}},[t,T]),updateTicket:(0,Y.useCallback)(async(e,n)=>{let r=t;if(!r)return!1;try{let t=await fetch(`${mt(r)}/tickets/${e}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});return t.ok&&p.current===r&&await T(r,`merge`),t.ok}catch{return!1}},[t,T])}}function vt(e,t){let n=()=>p(t?.in,NaN),r=t?.additionalDigits??2,i=Ct(e),a;if(i.date){let e=wt(i.date,r);a=Tt(e.restDateString,e.year)}if(!a||isNaN(+a))return n();let o=+a,s=0,c;if(i.time&&(s=Dt(i.time),isNaN(s)))return n();if(i.timezone){if(c=kt(i.timezone),isNaN(c))return n()}else{let e=new Date(o+s),n=m(0,t?.in);return n.setFullYear(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()),n.setHours(e.getUTCHours(),e.getUTCMinutes(),e.getUTCSeconds(),e.getUTCMilliseconds()),n}return m(o+s+c,t?.in)}var yt={dateTimeDelimiter:/[T ]/,timeZoneDelimiter:/[Z ]/i,timezone:/([Z+-].*)$/},bt=/^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/,xt=/^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/,St=/^([+-])(\d{2})(?::?(\d{2}))?$/;function Ct(e){let t={},n=e.split(yt.dateTimeDelimiter),r;if(n.length>2)return t;if(/:/.test(n[0])?r=n[0]:(t.date=n[0],r=n[1],yt.timeZoneDelimiter.test(t.date)&&(t.date=e.split(yt.timeZoneDelimiter)[0],r=e.substr(t.date.length,e.length))),r){let e=yt.timezone.exec(r);e?(t.time=r.replace(e[1],``),t.timezone=e[1]):t.time=r}return t}function wt(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 Tt(e,t){if(t===null)return new Date(NaN);let n=e.match(bt);if(!n)return new Date(NaN);let r=!!n[4],i=Et(n[1]),a=Et(n[2])-1,o=Et(n[3]),s=Et(n[4]),c=Et(n[5])-1;if(r)return Ft(t,s,c)?At(t,s,c):new Date(NaN);{let e=new Date(0);return!Nt(t,a,o)||!Pt(t,i)?new Date(NaN):(e.setUTCFullYear(t,a,Math.max(i,o)),e)}}function Et(e){return e?parseInt(e):1}function Dt(e){let t=e.match(xt);if(!t)return NaN;let n=Ot(t[1]),r=Ot(t[2]),i=Ot(t[3]);return It(n,r,i)?n*s+r*o+i*1e3:NaN}function Ot(e){return e&&parseFloat(e.replace(`,`,`.`))||0}function kt(e){if(e===`Z`)return 0;let t=e.match(St);if(!t)return 0;let n=t[1]===`+`?-1:1,r=parseInt(t[2]),i=t[3]&&parseInt(t[3])||0;return Lt(r,i)?n*(r*s+i*o):NaN}function At(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 jt=[31,null,31,30,31,30,31,31,30,31,30,31];function Mt(e){return e%400==0||e%4==0&&e%100!=0}function Nt(e,t,n){return t>=0&&t<=11&&n>=1&&n<=(jt[t]||(Mt(e)?29:28))}function Pt(e,t){return t>=1&&t<=(Mt(e)?366:365)}function Ft(e,t,n){return t>=1&&t<=53&&n>=0&&n<=6}function It(e,t,n){return e===24?t===0&&n===0:n>=0&&n<60&&t>=0&&t<60&&e>=0&&e<25}function Lt(e,t){return t>=0&&t<=59}async function Rt(e,t,n){let r=new FormData;r.append(`file`,t);let i=await fetch(`${v()}/tickets/${e}/attachments`,{method:`POST`,body:r,signal:n});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.error??l.t(`attachments:errors.uploadFailed`,{status:i.status}))}return(await i.json()).attachment}async function zt(e,t){let n=await fetch(`${v()}/tickets/${e}/attachments/${t}`,{method:`DELETE`});if(!n.ok&&n.status!==404)throw Error(l.t(`attachments:errors.deleteFailed`,{status:n.status}))}async function Bt(e){let t=await fetch(`${v()}/tickets/${e}/attachments`,{method:`DELETE`});if(!t.ok&&t.status!==404)throw Error(l.t(`attachments:errors.bulkDeleteFailed`,{status:t.status}))}async function Vt(e){let t=await fetch(`${v()}/tickets/${e}/attachments`);if(!t.ok)throw Error(l.t(`attachments:errors.listFailed`,{status:t.status}));return(await t.json()).attachments}function Ht(e,t){return`${v()}/tickets/${e}/attachments/${t}`}async function Ut(e,t){let n=await fetch(Ht(e,t));if(!n.ok)throw Error(l.t(`attachments:errors.fetchFailed`,{status:n.status}));return n.blob()}var Wt=`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`,Gt=new Set(Wt.split(`,`).filter(e=>!e.startsWith(`.`))),Kt=/\.sql$/i,qt=/\.(png|jpe?g|gif|webp)$/i;function Jt(e){return Gt.has(e.type)||Kt.test(e.name)||qt.test(e.name)}var X=n();function Yt({ticketKey:e,attachment:t,onClose:n}){let{t:r}=g(`attachments`),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null);if((0,Y.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,Y.useEffect)(()=>{if(!t){a(null),s(null);return}let n=!1;return a(null),s(null),Ut(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,Y.useEffect)(()=>()=>{i&&URL.revokeObjectURL(i)},[i]),!t)return null;let c=t.mimeType.startsWith(`image/`),l=t.mimeType===`application/pdf`;return(0,X.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,X.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,X.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,X.jsx)(S,{className:`w-4 h-4`}),r(`common:actions.back`)]}),(0,X.jsxs)(`div`,{className:`flex-1 text-center min-w-0 px-4`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-white/95 truncate`,children:t.filename}),(0,X.jsx)(`div`,{className:`text-[11px] text-white/50`,children:t.mimeType})]}),(0,X.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,X.jsx)(M,{className:`w-4 h-4`}),r(`lightbox.download`)]})]}),(0,X.jsx)(`div`,{className:B(`flex-1 flex items-center justify-center overflow-auto p-6`),onClick:n,children:o?(0,X.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,X.jsx)(`p`,{className:`text-sm`,children:r(`lightbox.loadError`,{error:o})})}):i?c?(0,X.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,X.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,X.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,X.jsx)(`p`,{className:`text-sm mb-3`,children:r(`lightbox.previewUnavailable`)}),(0,X.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,X.jsx)(M,{className:`w-4 h-4`}),r(`lightbox.downloadFile`,{name:t.filename})]})]}):(0,X.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,X.jsx)(`p`,{className:`text-sm`,children:r(`lightbox.loading`)})})})]})}function Xt(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 Zt(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Qt(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 $t(e){try{return new Date(e).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`})}catch{return e}}function en({ticketKey:e,attachments:t,onChange:n,className:r}){let{t:i}=g(`attachments`),[a,o]=(0,Y.useState)(new Set),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null);if((0,Y.useEffect)(()=>{let r=!1;return Vt(e).then(e=>{if(r)return;let i=Xt(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 zt(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,X.jsxs)(`section`,{className:B(`mt-4`,r),"aria-label":i(`section.ariaLabel`),children:[(0,X.jsxs)(`header`,{className:`flex items-center justify-between mb-2`,children:[(0,X.jsx)(`h3`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:i(`section.title`)}),(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:i(`section.fileCount`,{count:d.length})})]}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-1`,children:d.map(e=>{let t=a.has(e.id);return(0,X.jsxs)(`li`,{className:B(`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,X.jsx)(`span`,{"aria-hidden":!0,className:`w-6 text-center text-sm shrink-0`,children:Qt(e.mimeType)}),(0,X.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,X.jsx)(`span`,{className:`font-medium truncate text-foreground`,children:e.filename}),(0,X.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[Zt(e.size),` · `,$t(e.addedAt)]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>u(e),className:`text-[11px] text-primary hover:underline shrink-0`,children:i(`common:actions.open`)}),(0,X.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,X.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:s}),(0,X.jsx)(Yt,{ticketKey:e,attachment:l,onClose:()=>u(null)})]})}function tn({ticketId:e,onClose:t}){let{t:n}=g(`code`),r=a(),{activeProjectId:i}=y(),o=`${i}:${e}`,s=(0,Y.useRef)(o);s.current=o;let c=(0,Y.useRef)(0),l=(0,Y.useRef)(null),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(!1),[_,b]=(0,Y.useState)(null),x=(0,Y.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),b(t);try{let r=new URLSearchParams({ticketId:String(e),limit:`50`});t&&r.set(`cursor`,t);let a=await fetch(`${v()}/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,Y.useEffect)(()=>{if(Ee)return d(null),x(),()=>{l.current?.abort(),c.current++}},[x]),!Ee)return null;let S=u?.scope===o?u:null;return!f&&!m&&S&&!S.rows.length&&!S.truncated&&!S.nextCursor?null:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:n(`ticketFiles.title`)}),f&&!S&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,role:`status`,children:n(`ticketFiles.loading`)}),m&&(0,X.jsxs)(`div`,{className:`text-xs`,role:`alert`,children:[(0,X.jsx)(`span`,{children:n(`ticketFiles.loadFailed`)}),` `,(0,X.jsx)(`button`,{type:`button`,onClick:()=>{x(_)},className:`underline`,children:n(`ticketFiles.retry`)})]}),S?.truncated&&(0,X.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[n(`ticketFiles.partial`),` `,(0,X.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>{x()},className:`underline`,children:n(`ticketFiles.retry`)})]}),(0,X.jsx)(`ul`,{className:`space-y-1`,children:S?.rows.map(e=>(0,X.jsx)(`li`,{children:(0,X.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,X.jsx)(e.kind===`created`?Ke:e.kind===`deleted`?Ge:te,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate max-w-24`,title:e.repositoryName,children:e.repositoryName}),(0,X.jsx)(`span`,{className:`font-mono truncate flex-1`,children:e.path}),e.jobId&&(0,X.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,X.jsx)(qe,{className:`h-3 w-3`}),e.jobId.length>10?e.jobId.slice(0,10):e.jobId]}),(0,X.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,X.jsx)(`button`,{type:`button`,disabled:f,onClick:()=>{x(S.nextCursor)},className:`text-xs underline mt-2`,children:n(f?`ticketFiles.loading`:`ticketFiles.loadMore`)})]})}var nn=8e3,rn=[`change-request`,`review-feedback`,`clarification`,`constraint`],an=[`open`,`in_flight`,`applied`,`dismissed`],on=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`SpecAddendumValidationError`}};function sn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function cn(e){return typeof e==`string`&&rn.includes(e)}function ln(e){return typeof e==`string`&&an.includes(e)}function un(e){if(!sn(e))throw new on(`not_object`,`addendum must be an object`);if((e.version===void 0?1:e.version)!==1)throw new on(`unsupported_version`,`addendum.version must be 1`);let t=e.kind===void 0||e.kind===null?`change-request`:e.kind;if(!cn(t))throw new on(`invalid_kind`,`addendum.kind must be one of ${rn.join(`, `)}`);if(e.body!==void 0&&e.body!==null&&typeof e.body!=`string`)throw new on(`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 on(`body_required`,`addendum.body is required`);if(n.length>8e3)throw new on(`body_too_long`,`addendum.body exceeds ${nn} characters`);if(e.title!==void 0&&e.title!==null&&typeof e.title!=`string`)throw new on(`title_required`,`addendum.title must be a string`);let r=typeof e.title==`string`?e.title.replace(/\s+/g,` `).trim():``;if(r||=dn(n),r.length>200)throw new on(`title_too_long`,`addendum.title exceeds 200 characters`);return{kind:t,title:r,body:n}}function dn(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 fn(e){if(!sn(e)||typeof e.id!=`string`||!e.id||typeof e.hash!=`string`||!e.hash)return null;let t;try{t=un({version:e.version,kind:e.kind,title:e.title,body:e.body})}catch{return null}let n=ln(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 pn(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let r of e){let e=fn(r);!e||n.has(e.id)||(n.add(e.id),t.push(e))}return t}function mn(e){return(e??[]).filter(e=>e.status===`open`)}var hn={"change-request":Je,"review-feedback":Qe,clarification:G,constraint:nt},gn={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`},_n=`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`,vn={kind:`change-request`,title:``,body:``};function yn({ticket:e,onChanged:t}){let{t:n}=g(`tickets`),[r,i]=(0,Y.useState)(()=>pn(e.addenda)),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(()=>new Set),_=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{i(pn(e.addenda))},[e.id,e.updated_at,e.addenda]),(0,Y.useEffect)(()=>{a&&_.current?.focus()},[a]);let y=(0,Y.useMemo)(()=>mn(r).length,[r]),x=`${v()}/tickets/${e.id}/addenda`,S=(0,Y.useCallback)(e=>{let n=e.ticket?pn(e.ticket.addenda):null;n&&(i(n),t?.(n))},[t]),C=(0,Y.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?(S(a),!0):(a.error===`addendum_in_flight`?b.info(n(`addenda.toast.inFlight`)):b.error(a.detail?`${n(`addenda.toast.failed`)}: ${a.detail}`:n(`addenda.toast.failed`)),!1)}catch{return b.error(n(`addenda.toast.failed`)),!1}finally{u(!1)}},[S,n]),w=()=>{c(null),o({...vn}),p(null)},T=e=>{c(e.id),o({kind:e.kind,title:e.title,body:e.body}),p(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`,`${x}/${encodeURIComponent(s)}`,e):await C(`POST`,x,e))&&(b.success(n(s?`addenda.toast.updated`:`addenda.toast.added`)),E())},O=async(e,t,r=!1)=>{await C(`PATCH`,`${x}/${encodeURIComponent(e.id)}`,r?{status:t,force:!0}:{status:t})&&b.success(n(`addenda.toast.updated`))},j=async e=>{if(f!==e.id){p(e.id);return}p(null),await C(`DELETE`,`${x}/${encodeURIComponent(e.id)}`)&&b.success(n(`addenda.toast.removed`))},ee=e=>h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),M=e=>n(`addenda.who.${e===`agent`||e===`mcp`?e:`user`}`),te=e=>{let t=new Date(e);return Number.isNaN(t.getTime())?``:H(t,{addSuffix:!0,locale:d()})},N=()=>a&&(0,X.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,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`label`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`uppercase tracking-wider`,children:n(`addenda.form.kind`)}),(0,X.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:rn.map(e=>(0,X.jsx)(`option`,{value:e,children:n(`addenda.kind.${e}`)},e))})]}),(0,X.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,X.jsx)(`textarea`,{ref:_,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,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:n(`addenda.form.hint`)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(U,{variant:`ghost`,size:`sm`,className:`h-6 text-[10px]`,onClick:E,disabled:l,children:n(`addenda.form.cancel`)}),(0,X.jsxs)(U,{size:`sm`,className:`h-6 text-[10px]`,onClick:()=>void D(),disabled:l||!a.body.trim(),"data-testid":`spec-addenda-save`,children:[l?(0,X.jsx)(P,{className:`mr-1 h-3 w-3 animate-spin`}):(0,X.jsx)(k,{className:`mr-1 h-3 w-3`}),n(l?`addenda.form.saving`:`addenda.form.save`)]})]})]})]});return(0,X.jsxs)(`section`,{"data-testid":`spec-addenda-section`,className:`space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.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,X.jsx)(ne,{className:`h-3 w-3`}),n(`addenda.title`),r.length>0&&(0,X.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 ${y>0?gn.open:`border-border text-muted-foreground`}`,children:y>0?n(`addenda.openCount`,{count:y}):r.length})]}),!a&&(0,X.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,X.jsx)(re,{className:`h-2.5 w-2.5`}),n(`addenda.add`)]})]}),a&&!s&&N(),r.length===0&&!a?(0,X.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,X.jsx)(`ul`,{className:`space-y-1.5`,children:r.map(e=>{let t=hn[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`,d=e.status!==`in_flight`;return(0,X.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?N():(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.jsx)(t,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-primary/80`}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>ee(e.id),className:`min-w-0 flex-1 text-left`,"aria-expanded":r,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-foreground/90 ${e.status===`dismissed`?`line-through`:``}`,children:e.title}),(0,X.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,X.jsx)(`span`,{className:`rounded-full border px-1.5 py-px text-[9px] font-medium ${gn[e.status]}`,title:n(`addenda.statusHint.${e.status}`),"data-testid":`spec-addendum-status`,children:n(`addenda.status.${e.status}`)})]}),!r&&(0,X.jsx)(`p`,{className:`mt-0.5 line-clamp-2 text-[11px] leading-snug text-muted-foreground`,children:e.body})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[o&&(0,X.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,X.jsx)(F,{className:`h-3 w-3`})}),e.status===`in_flight`&&(0,X.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,X.jsx)(R,{className:`h-3 w-3`})}),u&&(0,X.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,X.jsx)(R,{className:`h-3 w-3`})}),c&&(0,X.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,X.jsx)(A,{className:`h-3 w-3`})}),d&&(f===e.id?(0,X.jsxs)(`span`,{className:`flex items-center gap-0.5`,children:[(0,X.jsx)(`button`,{type:`button`,title:n(`addenda.actions.confirmDelete`),"aria-label":n(`addenda.actions.confirmDelete`),onClick:()=>void j(e),disabled:l,className:`rounded p-1 text-destructive transition-colors hover:bg-destructive/10`,children:(0,X.jsx)(k,{className:`h-3 w-3`})}),(0,X.jsx)(`button`,{type:`button`,"aria-label":n(`addenda.form.cancel`),onClick:()=>p(null),className:`rounded p-1 text-muted-foreground transition-colors hover:bg-muted/40`,children:(0,X.jsx)(se,{className:`h-3 w-3`})})]}):(0,X.jsx)(`button`,{type:`button`,title:n(`addenda.actions.delete`),"aria-label":n(`addenda.actions.delete`),onClick:()=>void j(e),disabled:l,className:`rounded p-1 text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive`,children:(0,X.jsx)(ae,{className:`h-3 w-3`})}))]})]}),r&&(0,X.jsxs)(`div`,{className:`mt-2 space-y-1.5 pl-5`,children:[(0,X.jsx)(`div`,{className:_n,"data-testid":`spec-addendum-body`,children:(0,X.jsx)(_e,{remarkPlugins:[V],children:e.body})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[9px] text-muted-foreground`,children:[(0,X.jsxs)(`span`,{children:[te(e.created_at),` · `,n(`addenda.meta.by`,{who:M(e.created_by)})]}),e.run_id&&(0,X.jsx)(`span`,{className:`font-mono`,children:n(`addenda.meta.run`,{id:e.run_id.slice(0,8)})}),e.applied_at&&(0,X.jsx)(`span`,{children:n(`addenda.meta.applied`,{when:te(e.applied_at)})}),(0,X.jsx)(`span`,{className:`font-mono`,children:n(`addenda.meta.hash`,{hash:e.hash.slice(0,12)})})]})]})]})},e.id)})})]})}function bn(e){return e<.005?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function xn(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 Sn({ticketId:e}){let{t}=g(`tickets`),[n,r]=(0,Y.useState)(null),i=a(),{activeProjectId:o}=y(),{closeTicketDetail:s}=Qi();if((0,Y.useEffect)(()=>{let t=new AbortController;return r(null),fetch(`${v()}/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:w[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,X.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,X.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?`≥`:``}${bn(n.totalCostUsd)}`}),(0,X.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,X.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,X.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,X.jsx)(`span`,{className:`tabular-nums`,children:t(`spendingLine.active`,{duration:xn(n.activeDurationMs)})}),c&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,X.jsx)(`span`,{children:c})]}),(0,X.jsx)(ze,{className:`w-3 h-3 opacity-0 group-hover:opacity-100 transition-opacity`})]})}var Cn={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 wn({status:e,className:t}){let{t:n}=g(`specs`),r=Cn[e];return e===`done`?(0,X.jsx)(k,{className:B(`w-3.5 h-3.5 shrink-0`,r.dotClass,t),"aria-label":n(`status.done`)}):e===`cancelled`?(0,X.jsx)(se,{className:B(`w-3.5 h-3.5 shrink-0`,r.dotClass,t),"aria-label":n(`status.cancelled`)}):r.pulsing?(0,X.jsxs)(`span`,{className:B(`relative flex shrink-0 h-2.5 w-2.5`,t),"aria-label":n(`status.inProgress`),children:[(0,X.jsx)(`span`,{className:B(`animate-ping absolute inline-flex h-full w-full rounded-full opacity-60`,r.dotClass)}),(0,X.jsx)(`span`,{className:B(`relative inline-flex rounded-full h-2.5 w-2.5`,r.dotClass)})]}):(0,X.jsx)(`span`,{className:B(`inline-flex rounded-full h-2.5 w-2.5 shrink-0`,r.dotClass,t),"aria-label":n(r.labelKey)})}function Tn({status:e,className:t}){let{t:n}=g(`specs`),r=Cn[e];return(0,X.jsxs)(`span`,{className:B(`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,X.jsx)(wn,{status:e}),n(r.labelKey)]})}function En(){let{activeProjectId:e}=y(),[t,n]=(0,Y.useState)({connected:!1,key:null,discardStatus:null}),[r,i]=(0,Y.useState)(!0);return(0,Y.useEffect)(()=>{if(!De||!e){n({connected:!1,key:null,discardStatus:null}),i(!1);return}let t=!1;return i(!0),ve.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 Dn({open:e,onOpenChange:t,ticket:n,discardStatus:r,onDiscarded:i}){let{t:a}=g(`jira`),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(!1);async function u(){l(!0);try{await ve.discardSpec(n.id,o.trim()||null),b.success(a(`discard.movedToast`,{status:r,key:n.jira_key??`#${n.id}`})),t(!1),s(``),i?.()}catch(e){b.error(e instanceof Error?e.message:a(`errors.generic`))}finally{l(!1)}}return(0,X.jsx)(ge,{open:e,onOpenChange:e=>{c||t(e)},children:(0,X.jsxs)(he,{movableResizable:!0,className:`max-w-md`,"data-testid":`jira-discard-dialog`,children:[(0,X.jsxs)(me,{children:[(0,X.jsx)(pe,{children:a(`discard.title`,{status:r})}),(0,X.jsx)(de,{children:a(`discard.body`,{status:r,key:n.jira_key??`#${n.id}`})})]}),(0,X.jsxs)(`label`,{className:`block space-y-1`,children:[(0,X.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:a(`discard.commentLabel`)}),(0,X.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,X.jsxs)(ue,{children:[(0,X.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>t(!1),disabled:c,children:a(`wizard.cancel`)}),(0,X.jsxs)(U,{size:`sm`,onClick:u,disabled:c,"data-testid":`jira-discard-confirm`,children:[(0,X.jsx)(ze,{className:`w-3.5 h-3.5 mr-1.5`}),c?a(`discard.moving`):a(`discard.confirm`,{status:r})]})]})]})})}var On=/^\d{4}-\d{2}-\d{2}T/;function kn(e){if(On.test(e))try{return{text:H(vt(e),{addSuffix:!0,locale:d()}),title:e}}catch{}return{text:e}}function An({localId:e}){let{t}=g(`jira`),{activeProjectId:n}=y(),r=En(),[i,a]=(0,Y.useState)(null);if((0,Y.useEffect)(()=>{if(!De||!r.connected)return;let t=!1;return a(null),ve.getSpecDetails(e).then(e=>{t||a(e)}).catch(()=>{t||a(null)}),()=>{t=!0}},[e,n,r.connected]),!De||!r.connected||!i)return null;let o=i.development,s=i.fields.length>0,c=o.pullRequests.length>0,l=o.branches.length>0,u=(o.commits?.length??0)>0;return!s&&!c&&!l&&!u?null:(0,X.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-details-panel`,children:[s&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:t(`detail.detailsTitle`)}),(0,X.jsx)(`div`,{className:`space-y-1.5`,children:i.fields.map((e,t)=>{let n=kn(e.value);return(0,X.jsxs)(`div`,{className:`text-xs`,children:[(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block`,children:e.label}),e.href?(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{W(e.href)},className:`inline-flex items-center gap-1 text-accent-info hover:underline text-left`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:e.value}),(0,X.jsx)(E,{className:`w-3 h-3 shrink-0`})]}):(0,X.jsx)(`span`,{className:`text-foreground/80 whitespace-pre-line`,title:n.title,children:n.text})]},`${e.label}-${t}`)})})]}),(c||l||u)&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:t(`detail.developmentTitle`)}),c&&(0,X.jsxs)(`div`,{className:`mb-2`,children:[(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.pullRequests`)}),(0,X.jsx)(`div`,{className:`space-y-1`,children:o.pullRequests.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{W(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,X.jsx)(Ye,{className:`w-3 h-3 mt-0.5 shrink-0 text-accent-info`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`truncate text-foreground/80 block`,children:e.title}),(0,X.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[e.status,e.sourceBranch?` · ${e.sourceBranch} → ${e.destBranch??``}`:``]})]})]},e.url))})]}),l&&(0,X.jsxs)(`div`,{className:`mb-2`,children:[(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.branches`)}),(0,X.jsx)(`div`,{className:`space-y-1`,children:o.branches.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{W(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,X.jsx)(N,{className:`w-3 h-3 shrink-0 text-accent-info`}),(0,X.jsx)(`span`,{className:`truncate font-mono text-foreground/80`,children:e.name}),e.repo&&(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground truncate`,children:e.repo})]},e.url))})]}),u&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide block mb-1`,children:t(`detail.dev.commits`)}),(0,X.jsx)(`div`,{className:`space-y-1`,children:o.commits.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{W(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,X.jsx)(qe,{className:`w-3 h-3 shrink-0 text-accent-info`}),(0,X.jsx)(`span`,{className:`font-mono text-[10px] text-muted-foreground shrink-0`,children:e.displayId}),(0,X.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.message})]},e.url))})]})]})]})}var jn=/\n*##\s*Acceptance Criteria\s*\n([\s\S]*?)(?=\n##\s|\n*$)/i;function Mn(e){if(!e)return{body:``,criteria:[]};let t=jn.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 Nn=new Set([`draft`,`todo`]);function Pn(e){return!!(Nn.has(e.status)||e.source===`jira`&&e.jira_key&&e.status!==`cancelled`)}function Fn(){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 In(){let e={BASE_URL:`/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_FEATURE_BROWSER_CAPTURE;return typeof e!=`string`||e!==`false`}var Ln={desktop:{width:1280,height:800},tablet:{width:768,height:1024},mobile:{width:375,height:667}},Rn=class extends Error{},zn=class extends Error{};function Bn(e){if(!e)throw Error(`A project owner is required for browser sessions`);return`${u}/api/projects/${encodeURIComponent(e)}`}async function Vn(e,t){let n=await fetch(`${Bn(e)}/browser/sessions`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({initialUrl:t})});if(n.status===409)throw new Rn(`Too many open browser sessions`);if(n.status===502)throw new zn(`The browser failed to launch`);if(!n.ok)throw Error(`Failed to open browser (${n.status})`);return(await n.json()).session}async function Hn(e,t,n,r){let i=await fetch(`${Bn(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 Un(e,t,n,r,i){let a=await fetch(`${Bn(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 Wn(a));return await a.json()}async function Wn(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 Gn(e,t,n,r,i,a=Ln){let o=await fetch(`${Bn(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 Wn(o));return await o.json()}async function Kn(e,t,n){let r=new FormData;r.append(`file`,t,n);let i=await fetch(`${v()}/tickets/${e}/attachments`,{method:`POST`,body:r});if(!i.ok)throw Error(`Upload failed (${i.status})`);return(await i.json()).attachment}async function qn(e,t,n,r){let i=await fetch(`${Bn(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 Jn(e,t,n,r){let i=await fetch(`${Bn(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 Yn(e,t,n){let r=await fetch(`${Bn(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 Xn(e){if(!e||e===`about:blank`)return`…`;try{return new URL(e).hostname||`…`}catch{return`…`}}async function Zn(e,t){try{await fetch(`${Bn(e)}/browser/sessions/${t}`,{method:`DELETE`})}catch{}}function Qn(e,t){return`${Ce||(typeof window<`u`?`${window.location.protocol===`https:`?`wss:`:`ws:`}//${window.location.host}`:`ws://localhost:4200`)}/ws/browser/${e}?projectId=${encodeURIComponent(t)}`}function $n(e,t){let n=Qn(e,t),r=c(),i=r?new WebSocket(n,[`specrails-desktop`,r]):new WebSocket(n);return i.binaryType=`arraybuffer`,i}function er(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 tr(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 nr(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 rr(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 ir(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 or(e){return{nodeCount:e.nodes.length,htmlBytes:e.html.length,truncated:e.htmlTruncated,networkCount:e.networkRequests?.length??0}}function sr(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 cr={objects:[],past:[],future:[]};function lr(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 ur(e){let t=e.filter(e=>e.kind===`step`).map(e=>e.n);return t.length===0?1:Math.max(...t)+1}function dr(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 fr(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 pr(e,t,n=.01){return Math.abs(e.x-t.x)>=n||Math.abs(e.y-t.y)>=n}function mr(e,t=.05){let n=e=>Math.min(1+t,Math.max(-t,e));return{x:n(e.x),y:n(e.y)}}function hr(e,t,n){return{schemaVersion:1,objects:e,baseWidth:t,baseHeight:n}}function gr({result:e,pendingSpecId:t,onConfirm:n,...r}){let i=(0,Y.useCallback)(async r=>{if(!r.annotations){await n(e);return}let i=`screen-annotated-${Date.now()}.png`,a=await Kn(t,sr(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,X.jsx)(Sr,{...r,responsive:Object.keys(e.breakpoints??{}).length>1,screenshotDataUrl:e.screenshotDataUrl,onConfirm:i})}var _r=[`#ef4444`,`#f59e0b`,`#3b82f6`,`#22c55e`,`#ffffff`],vr=`#111827`,yr=[{tool:`arrow`,icon:T,labelKey:`editor.tools.arrow`,key:`a`},{tool:`box`,icon:L,labelKey:`editor.tools.box`,key:`r`},{tool:`text`,icon:it,labelKey:`editor.tools.text`,key:`t`},{tool:`blur`,icon:We,labelKey:`editor.tools.blur`,key:`b`},{tool:`step`,icon:Ze,labelKey:`editor.tools.step`,key:`n`}],br=0,xr=()=>`a${++br}-${Date.now().toString(36)}`;function Sr({screenshotDataUrl:e,responsive:t,macOverlay:n,confirmLabel:r,onConfirm:i,onReselect:a,onCancel:o}){let{t:s}=g(`browser`),[c,l]=(0,Y.useReducer)(lr,cr),[u,d]=(0,Y.useState)(`arrow`),[f,p]=(0,Y.useState)(_r[0]),[m,h]=(0,Y.useState)(null),[_,v]=(0,Y.useState)({w:1,h:1}),[y,b]=(0,Y.useState)(!1),[x,C]=(0,Y.useState)(!1),w=(0,Y.useRef)(!1),T=(0,Y.useRef)(null),E=(0,Y.useRef)(null),D=c.objects,O=(0,Y.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;v(e=>e.w===r&&e.h===i?e:{w:r,h:i})},[]);(0,Y.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 A=(0,Y.useCallback)((e,t)=>{let n=T.current;if(!n)return{x:0,y:0};let r=n.getBoundingClientRect();return mr({x:r.width>0?(e-r.left)/r.width:0,y:r.height>0?(t-r.top)/r.height:0})},[]),j=(0,Y.useCallback)(e=>{if(y)return;e.target.setPointerCapture?.(e.pointerId);let t=A(e.clientX,e.clientY);if(u===`text`){let e=window.prompt(s(`editor.notePrompt`))?.trim();e&&l({type:`add`,obj:{id:xr(),kind:`text`,x:t.x,y:t.y,text:e,color:f}});return}if(u===`step`){l({type:`add`,obj:{id:xr(),kind:`step`,x:t.x,y:t.y,n:ur(D),color:f}});return}h({start:t,cur:t})},[y,u,f,D,A,s]),ee=(0,Y.useCallback)(e=>{m&&h(t=>t&&{...t,cur:A(e.clientX,e.clientY)})},[m,A]),M=(0,Y.useCallback)(()=>{if(!m)return;let{start:e,cur:t}=m;if(h(null),pr(e,t)){if(u===`arrow`)l({type:`add`,obj:{id:xr(),kind:`arrow`,from:e,to:t,color:f}});else if(u===`box`){let n=dr(e,t);l({type:`add`,obj:{id:xr(),kind:`box`,...n,color:f}})}else if(u===`blur`){let n=dr(e,t);l({type:`add`,obj:{id:xr(),kind:`blur`,...n}})}}},[m,u,f]),te=(0,Y.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=vr,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=fr(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:hr(D,t,n)}},[D]),N=(0,Y.useCallback)(async()=>{if(!w.current){w.current=!0,b(!0),C(!1);try{await i(D.length===0?{screenshotDataUrl:e}:te())}catch{C(!0)}finally{w.current=!1,b(!1)}}},[D,te,e,i]),ne=(0,Y.useCallback)(()=>{D.length>0&&!window.confirm(s(`editor.discardConfirm`))||o()},[D.length,o,s]);(0,Y.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(),N();return}if(t)return;let n=yr.find(t=>t.key===e.key.toLowerCase());if(n){d(n.tool);return}e.key===`Escape`&&(e.preventDefault(),ne())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[y,N,ne]);let F=(e,t)=>e*(t===`w`?_.w:_.h),I=m?dr(m.start,m.cur):null;return(0,X.jsxs)(`div`,{className:`flex-1 min-h-0 min-w-0 flex flex-col items-center overflow-hidden p-3 gap-2`,children:[(0,X.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:[yr.map(({tool:e,icon:t,labelKey:n})=>(0,X.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,X.jsx)(t,{className:`w-3.5 h-3.5`})},e)),(0,X.jsx)(`span`,{className:`w-px h-5 bg-border/60 mx-0.5`}),_r.map(e=>(0,X.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,X.jsx)(`span`,{className:`w-px h-5 bg-border/60 mx-0.5`}),(0,X.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,X.jsx)(J,{className:`w-3.5 h-3.5`})}),(0,X.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,X.jsx)(tt,{className:`w-3.5 h-3.5`})})]}),t&&(0,X.jsx)(`p`,{className:`shrink-0 max-w-prose text-center text-xs text-muted-foreground`,children:s(`editor.responsiveHint`)}),(0,X.jsx)(`div`,{ref:E,className:`relative flex-1 min-h-0 w-full flex items-center justify-center`,children:(0,X.jsxs)(`div`,{className:`relative shrink-0`,style:{width:_.w,height:_.h},children:[(0,X.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,X.jsx)(`div`,{className:`absolute pointer-events-none`,style:{backgroundColor:vr,left:`${e.x*100}%`,top:`${e.y*100}%`,width:`${e.w*100}%`,height:`${e.h*100}%`}},e.id):null),m&&u===`blur`&&I&&(0,X.jsx)(`div`,{className:`absolute border border-accent-info pointer-events-none`,style:{backgroundColor:vr,left:`${I.x*100}%`,top:`${I.y*100}%`,width:`${I.w*100}%`,height:`${I.h*100}%`}}),(0,X.jsxs)(`svg`,{className:`absolute inset-0 w-full h-full ${u===`text`||u===`step`?`cursor-pointer`:`cursor-crosshair`}`,viewBox:`0 0 ${_.w} ${_.h}`,preserveAspectRatio:`none`,onPointerDown:j,onPointerMove:ee,onPointerUp:M,children:[D.map(e=>{if(e.kind===`box`)return(0,X.jsx)(`rect`,{x:F(e.x,`w`),y:F(e.y,`h`),width:F(e.w,`w`),height:F(e.h,`h`),fill:`none`,stroke:e.color,strokeWidth:Math.max(2,_.w*.004)},e.id);if(e.kind===`arrow`){let t=fr(e.from,e.to,.035),n=Math.max(2,_.w*.004);return(0,X.jsxs)(`g`,{stroke:e.color,strokeWidth:n,strokeLinecap:`round`,fill:`none`,children:[(0,X.jsx)(`line`,{x1:F(e.from.x,`w`),y1:F(e.from.y,`h`),x2:F(e.to.x,`w`),y2:F(e.to.y,`h`)}),(0,X.jsx)(`polyline`,{points:`${F(t.left.x,`w`)},${F(t.left.y,`h`)} ${F(e.to.x,`w`)},${F(e.to.y,`h`)} ${F(t.right.x,`w`)},${F(t.right.y,`h`)}`})]},e.id)}if(e.kind===`text`)return(0,X.jsx)(`text`,{x:F(e.x,`w`),y:F(e.y,`h`),dominantBaseline:`hanging`,fontSize:Math.max(12,_.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,_.h*.025);return(0,X.jsxs)(`g`,{children:[(0,X.jsx)(`circle`,{cx:F(e.x,`w`),cy:F(e.y,`h`),r:t,fill:e.color}),(0,X.jsx)(`text`,{x:F(e.x,`w`),y:F(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`&&I&&(0,X.jsx)(`rect`,{x:F(I.x,`w`),y:F(I.y,`h`),width:F(I.w,`w`),height:F(I.h,`h`),fill:`none`,stroke:f,strokeDasharray:`4 3`,strokeWidth:Math.max(2,_.w*.004)}),m&&u===`arrow`&&(0,X.jsx)(`line`,{x1:F(m.start.x,`w`),y1:F(m.start.y,`h`),x2:F(m.cur.x,`w`),y2:F(m.cur.y,`h`),stroke:f,strokeWidth:Math.max(2,_.w*.004),strokeLinecap:`round`})]}),y&&(0,X.jsxs)(`div`,{className:`absolute inset-0 flex items-center justify-center gap-2 bg-background-deep/50 text-sm text-foreground`,children:[(0,X.jsx)(P,{className:`w-4 h-4 animate-spin`}),` `,s(`common:states.saving`)]})]})}),x&&(0,X.jsx)(`p`,{role:`alert`,className:`shrink-0 text-sm text-destructive`,children:s(`modal.toast.captureFailed`)}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[(0,X.jsxs)(U,{size:`sm`,variant:`ghost`,className:`gap-1.5`,onClick:a,disabled:y,children:[(0,X.jsx)(S,{className:`w-3.5 h-3.5`}),` `,s(`editor.reselect`)]}),(0,X.jsxs)(U,{size:`sm`,variant:`ghost`,className:`gap-1.5`,onClick:ne,disabled:y,children:[(0,X.jsx)(se,{className:`w-3.5 h-3.5`}),` `,s(`common:actions.cancel`)]}),(0,X.jsxs)(U,{size:`sm`,className:`gap-1.5`,onClick:()=>void N(),disabled:y,"data-testid":`annotation-confirm`,children:[(0,X.jsx)(k,{className:`w-3.5 h-3.5`}),` `,D.length>0?r??s(`editor.createSpec`):s(`editor.skipContinue`)]})]})]})}var Cr=`native-browser:event`;function wr(e){let t=(e??``).trim();if(!t)return null;if(t===`about:blank`)return t;let n=Tr(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=Tr(`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 Tr(e){try{return new URL(e)}catch{return null}}function Er(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 Dr=null,Or=null,kr=Promise.resolve();async function Ar(){return(await i(()=>import(`./core-B3mKBIh5.js`).then(e=>e.i),__vite__mapDeps([0,1]))).invoke}function jr(e){let t=e?.flag??Me,n=e?.tauri??be();return!t||!n?Promise.resolve(!1):(Dr||=(async()=>{try{return await(await Ar())(`browser_supported`)===!0}catch{return Dr=null,!1}})(),Dr)}async function Mr(e){return await jr(e)?(Or||=Z(`browser_capture_supported`).then(e=>e===!0).catch(()=>(Or=null,!1)),Or):!1}async function Z(e,t){return(await Ar())(e,t)}function Nr(e){let t=kr.then(e,e);return kr=t.catch(()=>{}),t}var Q={open:(e,t,n)=>Nr(()=>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=>Nr(()=>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([3,1,0]));return r(Cr,n)}},Pr=e(r(),1),Fr=new Map,Ir=new Map;function Lr(e,t){let n=(Ir.get(e)??Promise.resolve()).catch(()=>{}).then(t);return Ir.set(e,n),n.finally(()=>{Ir.get(e)===n&&Ir.delete(e)}).catch(()=>{}),n}function Rr({ownerId:e,leaseRevision:t=0,onBusyChange:n,transferError:r,url:i,onClose:a,onFallback:o,onUrlChange:s,onCaptured:c,confirmLabel:l,selectLabel:u}){let{t:d}=g(`browser`),f=(0,Y.useRef)(null),p=(0,Y.useRef)(!1),[m,h]=(0,Y.useState)(i),[_,v]=(0,Y.useState)(i),[y,b]=(0,Y.useState)(null),[x,C]=(0,Y.useState)(!0),[w,T]=(0,Y.useState)(!1),[D,O]=(0,Y.useState)(null),[k,A]=(0,Y.useState)(!1),[j,ee]=(0,Y.useState)(null),[M,te]=(0,Y.useState)(!1),[N,ne]=(0,Y.useState)(null);(0,Y.useEffect)(()=>(n?.(k||j!==null||M||N!==null),()=>{n?.(!1)}),[n,k,j,M,N]);let P=(0,Y.useRef)(1),F=(0,Y.useRef)(null),I=(0,Y.useRef)(!1),L=(0,Y.useRef)(!1),re=(0,Y.useRef)(!1),R=(0,Y.useRef)(null),ie=(0,Y.useRef)(i),ae=(0,Y.useRef)({url:i,onFallback:o,onUrlChange:s});ae.current={url:i,onFallback:o,onUrlChange:s},re.current=N!==null;let z=(0,Y.useCallback)(async e=>{let t=F.current;if(!(!t||!I.current)){O(null);try{await e(t)}catch(e){F.current===t&&O(e instanceof Error?e.message:String(e))}}},[]);(0,Y.useEffect)(()=>{let t=!1,n=null,r=0,i=null,a=e??crypto.randomUUID(),o=Symbol(a);Fr.set(a,o);let s=()=>{Lr(a,async()=>{Fr.get(a)===o&&(Fr.delete(a),await Q.close(a))}).catch(()=>{})};F.current=a,I.current=!1,T(!1);let c=()=>{t||r||(r=requestAnimationFrame(()=>{if(r=0,!I.current||re.current||L.current)return;let e=f.current?.getBoundingClientRect();if(!e||e.width<=0||e.height<=0)return;let t=Er(e);JSON.stringify(t)!==JSON.stringify(R.current)&&(R.current=t,Q.setBounds(a,t).catch(()=>{R.current=null}))}))};return(async()=>{try{let e=await Q.onEvent(a,e=>{if(!t){if(e.kind===`resume`){!re.current&&!L.current&&Lr(a,async()=>{if(t||Fr.get(a)!==o||re.current||L.current)return;let n=f.current?.getBoundingClientRect();n&&await Q.open(a,e.url??ie.current,Er(n))}).catch(e=>{t||O(String(e))});return}e.kind===`nav`&&e.url?(v(e.url),ae.current.onUrlChange?.(e.url),ee(null),A(!1),p.current||h(e.url)):e.kind===`title`?b(e.title??null):e.kind===`load-started`?C(!0):e.kind===`load-finished`?(C(!1),e.url&&!p.current&&h(e.url)):e.kind===`popup-error`?O(d(`popup.openFailed`)):e.kind===`popup-opened`&&O(null)}});if(t){e();return}n=e;let r=f.current?.getBoundingClientRect();if(!r)throw Error(`hole not measurable`);ie.current=wr(ae.current.url)??`about:blank`,R.current=Er(r);let l=R.current;if(!await Lr(a,async()=>t||Fr.get(a)!==o?!1:(await Q.open(a,ie.current,l),!0)))return;if(t){s();return}I.current=!0,T(!0),i=new ResizeObserver(c),f.current&&i.observe(f.current),window.addEventListener(`resize`,c),window.addEventListener(`scroll`,c,!0),window.visualViewport?.addEventListener(`resize`,c),window.visualViewport?.addEventListener(`scroll`,c),c()}catch{t||ae.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?.(),F.current===a&&(F.current=null,I.current=!1),s()}},[e,t]),(0,Y.useEffect)(()=>{let e=wr(i)??`about:blank`;!w||e===ie.current||(ie.current=e,h(e),z(t=>Q.navigate(t,e)))},[i,w,z]);let ce=(0,Y.useCallback)(async e=>{let t=F.current;if(!(!t||!I.current||L.current)){L.current=!0,te(!0),O(null);try{let n=await Q.capture(t,e);if(F.current!==t||(await Q.hide(t),F.current!==t))return;re.current=!0,A(!1),ne(n)}catch(e){F.current===t&&O(e instanceof Error?e.message:String(e))}finally{L.current=!1,F.current===t&&te(!1)}}},[]);(0,Y.useEffect)(()=>{if(!k||!w)return;let e=F.current,t=!1,n,r=async()=>{try{let n=await Q.selection(e);if(t||F.current!==e)return;if(n){if(await Q.setSelectMode(e,!1),t||F.current!==e)return;ee(n),A(!1),await ce(!0);return}}catch(n){if(t||F.current!==e)return;O(String(n));try{await Q.setSelectMode(e,!1),!t&&F.current===e&&A(!1)}catch(n){!t&&F.current===e&&O(String(n))}return}t||(n=setTimeout(r,200))};return r(),()=>{t=!0,clearTimeout(n)}},[k,w,ce]);let le=async()=>{await z(async e=>{await Q.setSelectMode(e,!k),ee(null),A(!k)})},ue=async()=>{ne(null),await z(async e=>{await new Promise(e=>requestAnimationFrame(()=>e()));let t=f.current?.getBoundingClientRect();t&&t.width>0&&t.height>0&&(R.current=Er(t),await Q.setBounds(e,R.current)),await Q.show(e)})};(0,Y.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!re.current&&a()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[a]);let de=(0,Y.useCallback)(()=>{let e=wr(m);e&&(h(e),z(t=>Q.navigate(t,e)))},[m,z]),fe=(0,Y.useCallback)(e=>{P.current=Math.min(3,Math.max(.25,e)),z(e=>Q.zoom(e,P.current))},[z]);return typeof document>`u`?null:(0,Pr.createPortal)((0,X.jsx)(`div`,{className:`fixed inset-0 z-[80] bg-background-deep/60 backdrop-blur-md pointer-events-auto`,onClick:e=>{e.target===e.currentTarget&&!N&&a()},"data-testid":`native-browser-modal`,children:(0,X.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":d(`modal.dialogLabel`),onClick:e=>e.stopPropagation(),children:[!N&&(0,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(U,{disabled:!w,variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":d(`common:actions.back`),onClick:()=>void z(Q.back),children:(0,X.jsx)(S,{className:`w-4 h-4`})}),(0,X.jsx)(U,{disabled:!w,variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":d(`modal.nav.forward`),onClick:()=>void z(Q.forward),children:(0,X.jsx)(ze,{className:`w-4 h-4`})}),(0,X.jsx)(U,{disabled:!w,variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":d(`modal.nav.reload`),onClick:()=>void z(Q.reload),children:(0,X.jsx)(K,{className:`w-4 h-4`})})]}),(0,X.jsxs)(`form`,{className:`flex-1 flex items-center gap-2 min-w-0`,onSubmit:e=>{e.preventDefault(),de()},children:[(0,X.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,X.jsx)(Xe,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,X.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),onFocus:()=>{p.current=!0},onBlur:()=>{p.current=!1},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),de())},placeholder:d(`modal.address.placeholder`),"aria-label":d(`modal.address.label`),className:`flex-1 min-w-0 bg-transparent outline-none text-sm`})]}),(0,X.jsx)(U,{type:`submit`,size:`sm`,variant:`secondary`,className:`shrink-0`,children:d(`modal.address.go`)})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":d(`native.zoomOut`),title:d(`native.zoomOut`),onClick:()=>fe(P.current-.1),children:(0,X.jsx)(ot,{className:`w-4 h-4`})}),(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":d(`native.zoomIn`),title:d(`native.zoomIn`),onClick:()=>fe(P.current+.1),children:(0,X.jsx)(at,{className:`w-4 h-4`})}),(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":d(`native.devtools`),title:d(`native.devtools`),onClick:()=>void z(Q.devtools),children:(0,X.jsx)(oe,{className:`w-4 h-4`})}),(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":d(`native.openExternal`),title:d(`native.openExternal`),onClick:()=>void W(_),children:(0,X.jsx)(E,{className:`w-4 h-4`})}),(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":d(`modal.closeBrowser`),onClick:a,children:(0,X.jsx)(se,{className:`w-4 h-4`})})]})]}),(0,X.jsxs)(`div`,{className:`px-3 py-1 text-[11px] text-muted-foreground truncate shrink-0 flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-full shrink-0 ${x?`bg-accent-warning animate-pulse`:`bg-accent-success`}`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:y||_}),(0,X.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:d(`native.badge`)})]}),c&&(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-b border-border/50 px-3 py-2 shrink-0`,children:[(0,X.jsxs)(U,{variant:k?`secondary`:`ghost`,size:`sm`,disabled:!w||M,"aria-pressed":k,onClick:()=>void le(),children:[(0,X.jsx)(et,{className:`mr-1.5 h-3.5 w-3.5`}),u??d(`native.selectElement`)]}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-muted-foreground`,children:k?d(`native.selectHint`):j?.selector}),(0,X.jsxs)(U,{variant:`secondary`,size:`sm`,disabled:!w||M||k||_===`about:blank`,onClick:()=>void ce(j!==null),children:[(0,X.jsx)(Be,{className:`mr-1.5 h-3.5 w-3.5`}),d(M?`native.capturing`:j?`native.captureSelection`:`native.capturePage`)]})]})]}),(D||r)&&(0,X.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}),N&&c&&(0,X.jsx)(Sr,{screenshotDataUrl:N.screenshotDataUrl,confirmLabel:l,onConfirm:async e=>{await c({...N,screenshotDataUrl:e.screenshotDataUrl})},onReselect:()=>{ue()},onCancel:a}),(0,X.jsx)(`div`,{ref:f,className:N?`hidden`:`relative flex-1 min-h-0 overflow-hidden`,children:x&&(0,X.jsx)(`div`,{className:`absolute inset-0 flex items-center justify-center text-sm text-muted-foreground`,children:d(`modal.status.opening`)})})]})}),document.body)}function zr(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 Br=`specrails-desktop:browser-capture-debug`;function Vr(){try{return typeof localStorage<`u`&&localStorage.getItem(Br)===`1`}catch{return!1}}function Hr(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 Ur(e,t=e=>console.table([e]),n=2e3,r=()=>Date.now()){let i=e(),a=r(),o=setInterval(()=>{let n=e(),o=r();t(Hr(i,n,o-a)),i=n,a=o},n);return()=>clearInterval(o)}function Wr(e){let{projectId:t,open:n,initialUrl:r}=e,i=(0,Y.useRef)(null),a=(0,Y.useRef)(null),o=(0,Y.useRef)(null),s=(0,Y.useRef)(0),c=(0,Y.useRef)(0),u=(0,Y.useRef)(null),d=(0,Y.useRef)(null),f=(0,Y.useCallback)(()=>{let e=u.current,t=d.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}})),d.current=e}catch{}},[]),p=(0,Y.useRef)(0),m=(0,Y.useRef)(new Map),h=(0,Y.useCallback)(()=>{if(p.current!==0||m.current.size===0)return;let e=[...m.current.values()];m.current.clear();for(let t of e)Zn(t.projectId,t.sessionId)},[]),[g,_]=(0,Y.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,Y.useEffect)(()=>{if(!n||!t)return;let e=!1,c=null;d.current=null,_(e=>({...e,status:`connecting`,errorMsg:null,popup:null,popupError:null}));let h=zr({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=Vr()?Ur(()=>h.stats()):null;return(async()=>{try{let n=await Vn(t,r);if(e){Zn(t,n.id);return}c=n.id,o.current={id:n.id,projectId:t},_(e=>({...e,url:n.url,title:n.title,viewport:u.current??{width:n.viewportWidth,height:n.viewportHeight}}));let i=$n(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:u.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:l.t(`browser:session.connectionError`)}))},i.onclose=()=>{e||_(e=>({...e,status:`error`,errorMsg:l.t(`browser:session.lostConnection`)}))}}catch(t){if(e)return;let n=t instanceof Rn?l.t(`browser:session.tooManySessions`):t instanceof zn?l.t(`browser:session.launchFailed`):l.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}):Zn(t,r))}},[n,t,r,h,f]);let v=(0,Y.useCallback)(e=>{let t=a.current;if(t&&t.readyState===WebSocket.OPEN)try{t.send(JSON.stringify({type:`input`,event:e}))}catch{}},[]),y=(0,Y.useCallback)(async(e,t)=>{let n=o.current;if(n)try{let r=await Hn(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,Y.useCallback)(async(e,t,n)=>{let r=o.current;if(!r)throw Error(`No active browser session`);p.current+=1;try{return await Un(r.projectId,r.id,e,t,n)}finally{p.current=Math.max(0,p.current-1),h()}},[h]),x=(0,Y.useCallback)(async(e,t,n,r)=>{let i=o.current;if(!i)throw Error(`No active browser session`);p.current+=1;try{return await Gn(i.projectId,i.id,e,t,n,r)}finally{p.current=Math.max(0,p.current-1),h()}},[h]),S=(0,Y.useCallback)(async(e,t)=>{let n=o.current;return n?qn(n.projectId,n.id,e,t):{text:``}},[]),C=(0,Y.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));u.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,Y.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,Y.useCallback)(()=>{_(e=>e.hoverRect||e.hoverPath?{...e,hoverRect:null,hoverSelector:null,hoverPath:null}:e)},[]),E=(0,Y.useCallback)(async(e,t)=>{let n=o.current;return n?Jn(n.projectId,n.id,e,t):null},[]),D=(0,Y.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 Yn(t.projectId,t.id,e),i()&&_(e=>({...e,popupError:null}))}catch{i()&&_(e=>({...e,popupError:l.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 Gr(e,t,n,r){let i=(0,Y.useRef)(t);i.current=t,(0,Y.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 Kr({open:e,url:t,projectId:n,onClose:r}){let[i,a]=(0,Y.useState)(`probing`);(0,Y.useEffect)(()=>{if(!e||i!==`probing`)return;let t=!0;return jr().then(e=>{t&&a(e?`native`:`screencast`)}),()=>{t=!1}},[e,i]);let o=(0,Y.useCallback)(()=>a(`screencast`),[]);return!e||i===`probing`?null:i===`native`?(0,X.jsx)(Rr,{url:t,onClose:r,onFallback:o}):(0,X.jsx)(qr,{open:e,url:t,projectId:n,onClose:r})}function qr({open:e,url:t,projectId:n,onClose:r}){let{t:i}=g(`browser`),a=Wr({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,_]=(0,Y.useState)(t),v=(0,Y.useRef)(null);Gr(v,m,e);let y=(0,Y.useRef)(a.forwardInput);y.current=a.forwardInput;let b=(0,Y.useRef)(null),x=(0,Y.useCallback)(()=>(b.current??=er(e=>y.current(e)),b.current),[]);(0,Y.useEffect)(()=>()=>{b.current?.dispose(),b.current=null},[]);let C=f?.active?f.url??`about:blank`:u??``;(0,Y.useEffect)(()=>{_(C)},[C,f?.active]),(0,Y.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&r()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,r]);let w=(0,Y.useCallback)((e,t)=>{let n=o.current?.getBoundingClientRect();return n?tr({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`,D=(0,Y.useCallback)(e=>{let t=w(e.clientX,e.clientY);x().move(t.x,t.y)},[w,x]),O=(0,Y.useCallback)(e=>{let t=w(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})},[w,a,x]),k=(0,Y.useCallback)(e=>{let t=w(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})},[w,a,x]),A=(0,Y.useCallback)(e=>{let t=w(e.clientX,e.clientY);x().wheel(t.x,t.y,e.deltaX,e.deltaY)},[w,x]),j=(0,Y.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]),ee=(0,Y.useCallback)(e=>{e.key!==`Escape`&&a.forwardInput({type:`key`,action:`up`,key:e.key,code:e.code})},[a]),M=(0,Y.useCallback)(()=>{a.navigate(`goto`,h)},[a,h]);return!e||typeof document>`u`?null:(0,Pr.createPortal)((0,X.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,X.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,X.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,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`common:actions.back`),onClick:()=>a.navigate(`back`),children:(0,X.jsx)(S,{className:`w-4 h-4`})}),(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.nav.forward`),onClick:()=>a.navigate(`forward`),children:(0,X.jsx)(ze,{className:`w-4 h-4`})}),(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.nav.reload`),onClick:()=>a.navigate(`reload`),children:(0,X.jsx)(K,{className:`w-4 h-4`})})]}),(0,X.jsxs)(`form`,{className:`flex-1 flex items-center gap-2 min-w-0`,onSubmit:e=>{e.preventDefault(),M()},children:[(0,X.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,X.jsx)(Xe,{className:`w-3.5 h-3.5 text-muted-foreground shrink-0`}),(0,X.jsx)(`input`,{value:h,onChange:e=>_(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,X.jsx)(U,{type:`submit`,size:`sm`,variant:`secondary`,className:`shrink-0`,disabled:c===`error`,children:i(`modal.address.go`)})]}),(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`h-7 w-7`,"aria-label":i(`modal.closeBrowser`),onClick:r,children:(0,X.jsx)(se,{className:`w-4 h-4`})})]}),(0,X.jsxs)(`div`,{className:`px-3 py-1 text-[11px] text-muted-foreground truncate shrink-0 flex items-center gap-2`,children:[(0,X.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,X.jsx)(`span`,{className:`truncate`,children:c===`connecting`?i(`modal.status.connecting`):c===`error`?l??i(`modal.status.unavailable`):f?.active?i(`popup.loginWindow`,{origin:Xn(f.url)}):d||``})]}),p&&(0,X.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,X.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,X.jsx)(E,{className:`w-3.5 h-3.5 shrink-0`}),f.active?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`truncate font-medium`,children:i(`popup.loginWindow`,{origin:Xn(f.url)})}),f.count>1&&(0,X.jsx)(`span`,{className:`shrink-0 opacity-70`,children:i(`popup.stacked`,{count:f.count-1})}),(0,X.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,X.jsx)(S,{className:`w-3 h-3`}),i(`popup.backToPage`)]})]}):(0,X.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,X.jsx)(`span`,{className:`opacity-70`,children:i(`popup.stacked`,{count:f.count-1})})]})]}),(0,X.jsx)(`div`,{ref:v,className:`relative flex-1 min-h-0 overflow-hidden flex items-center justify-center outline-none`,tabIndex:0,onKeyDown:j,onKeyUp:ee,children:c===`error`?(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-2 text-center max-w-md px-6`,children:[(0,X.jsx)(z,{className:`w-8 h-8 text-accent-warning`}),(0,X.jsx)(`p`,{className:`text-sm text-foreground/90`,children:l??i(`modal.error.unavailable`)})]}):(0,X.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:D,onPointerDown:O,onPointerUp:k,onContextMenu:e=>e.preventDefault(),onWheel:A})})]})}),document.body)}var Jr=(0,Y.createContext)(null);function Yr({children:e}){let{activeProjectId:t}=y(),[n,r]=(0,Y.useState)(null),i=(0,Y.useCallback)(e=>r(e),[]),a=In();return(0,X.jsxs)(Jr.Provider,{value:{openWebView:i,canOpenWebView:a&&!!t},children:[e,a&&n&&t&&(0,X.jsx)(Kr,{open:!0,url:n,projectId:t,onClose:()=>r(null)})]})}function Xr(){return(0,Y.useContext)(Jr)??{openWebView:()=>{},canOpenWebView:!1}}var Zr={analyzing:`activity:smash.stage.analyzing`,identifying:`activity:smash.stage.identifying`,ordering:`activity:smash.stage.ordering`},Qr=(0,Y.createContext)(null);function $(e){return`smash:${e}`}async function $r(e,t){try{let n=await fetch(`${u}/api/projects/${e}/tickets/${t}/smash`,{method:`POST`});if(n.ok)b.loading(l.t(`activity:smash.retrying`),{id:$(t)});else{let e=await n.json().catch(()=>({}));b.error(e.reason?l.t(`activity:smash.couldNotRetryWithReason`,{reason:e.reason}):l.t(`activity:smash.couldNotRetry`),{id:$(t)})}}catch(e){b.error(l.t(`activity:smash.retryFailed`,{message:e.message}),{id:$(t)})}}async function ei(e,t,n){try{let r=await fetch(`${u}/api/projects/${e}/tickets/${t}/smash/undo`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({smashedAt:n})});if(r.ok)b.success(l.t(`activity:smash.undone`),{id:$(t),duration:3e3});else{let e=await r.json().catch(()=>({}));b.error(e.reason?l.t(`activity:smash.undoFailedWithReason`,{reason:e.reason}):l.t(`activity:smash.undoFailed`),{id:$(t)})}}catch(e){b.error(l.t(`activity:smash.undoFailedWithReason`,{reason:e.message}),{id:$(t)})}}function ti({children:e}){let{registerHandler:t,unregisterHandler:n}=f(),[r,i]=(0,Y.useState)({}),a=(0,Y.useRef)(new Map),o=(0,Y.useRef)(new Map),s=(0,Y.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}})),b.loading(l.t(Zr.analyzing),{id:$(n),description:c?l.t(`activity:smash.onTitled`,{title:c}):l.t(`activity:smash.onThisSpec`)}))},[]),c=(0,Y.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}),b.loading(l.t(Zr[r]),{id:$(n),description:a?l.t(`activity:smash.onTitled`,{title:a}):l.t(`activity:smash.onThisSpec`)})},[]),u=(0,Y.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}),b.success(l.t(`activity:smash.split`,{count:c.length}),{id:$(n),duration:1e4,action:{label:l.t(`activity:smash.undoAction`),onClick:()=>void ei(a,n,s)}}))},[]),d=(0,Y.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`?l.t(`activity:smash.failReason.invalidOutput`):o===`timeout`?l.t(`activity:smash.failReason.timeout`):o===`model_error`?l.t(`activity:smash.failReason.modelError`):o===`crashed`?l.t(`activity:smash.failReason.crashed`):l.t(`activity:smash.failReason.generic`,{reason:o});b.error(l.t(`activity:smash.couldNotComplete`),{id:$(n),description:s,action:{label:l.t(`common:actions.retry`),onClick:()=>void $r(r,n)},duration:15e3})},[]),p=(0,Y.useCallback)(e=>{let t=e;if(!t||t.type!==`smash.undone`)return;let n=t.ticketId;typeof n==`number`&&(b.dismiss($(n)),b.success(l.t(`activity:smash.undone`),{id:$(n),duration:3e3}))},[]);(0,Y.useLayoutEffect)(()=>(t(`_smash_started`,s),t(`_smash_progress`,c),t(`_smash_completed`,u),t(`_smash_failed`,d),t(`_smash_undone`,p),()=>{n(`_smash_started`),n(`_smash_progress`),n(`_smash_completed`),n(`_smash_failed`),n(`_smash_undone`)}),[t,n,s,c,u,d,p]),(0,Y.useEffect)(()=>()=>{a.current.clear(),o.current.clear()},[]);let m=(0,Y.useMemo)(()=>({inflight:r}),[r]);return(0,X.jsx)(Qr.Provider,{value:m,children:e})}function ni(e){let t=(0,Y.useContext)(Qr);return!t||e==null?null:t.inflight[e]??null}var ri=150,ii={analyzing:0,identifying:1,ordering:2},ai={analyzing:`smash.stage.analyzing`,identifying:`smash.stage.identifying`,ordering:`smash.stage.ordering`};function oi({stage:e,minDisplayMs:t=ri}){let{t:n}=g(`activity`),[r,i]=(0,Y.useState)(e),a=(0,Y.useRef)(Date.now()),o=(0,Y.useRef)(null);if((0,Y.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=ii[r];return(0,X.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,X.jsx)(P,{className:`h-4 w-4 animate-spin text-accent-highlight`,"aria-hidden":!0}),(0,X.jsx)(`div`,{className:`flex items-center gap-1.5`,children:[`analyzing`,`identifying`,`ordering`].map(e=>(0,X.jsx)(`span`,{className:[`inline-block w-1.5 h-1.5 rounded-full transition-all`,ii[e]<=s?`bg-accent-highlight`:`bg-muted`,e===r?`scale-125`:`scale-100`].join(` `),"aria-hidden":!0},e))}),(0,X.jsx)(`span`,{className:`font-medium`,children:n(ai[r])})]})}var si={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 ci({open:e,ticketTitle:t,isReSmash:n,childrenCount:r,submitting:i=!1,onCancel:a,onConfirm:o}){let{t:s}=g(`activity`),[c,l]=(0,Y.useState)(`simple`),{panelRef:u,panelStyle:d,headerHandleProps:f,resizeHandles:p,isFloating:m,guardBackdrop:_}=ce();return e?(0,Pr.createPortal)((0,X.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,X.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:_(a)}),(0,X.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,X.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,X.jsxs)(`div`,{className:`flex items-start gap-2 min-w-0`,children:[(0,X.jsx)(rt,{className:`w-5 h-5 text-accent-highlight shrink-0 mt-0.5`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:s(`smashModal.title`)}),(0,X.jsx)(`p`,{className:`text-[11px] text-muted-foreground truncate`,title:t,children:t})]})]}),(0,X.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,X.jsx)(se,{className:`w-4 h-4`})})]}),n&&r>0&&(0,X.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,X.jsx)(h,{t:s,i18nKey:`smashModal.reSmashWarning`,count:r})}),(0,X.jsxs)(`div`,{className:`px-5 py-4 space-y-3`,children:[(0,X.jsx)(`p`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground font-medium`,children:s(`smashModal.modePickerLabel`)}),[`simple`,`full`].map(e=>{let t=si[e],n=c===e;return(0,X.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,X.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,X.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,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 mb-1`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-1.5 text-sm font-semibold text-foreground`,children:[e===`full`&&(0,X.jsx)(j,{className:`w-3.5 h-3.5 text-accent-highlight`,"aria-hidden":!0}),s(t.titleKey)]}),(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:s(t.etaKey)})]}),(0,X.jsx)(`ul`,{className:`space-y-0.5`,children:t.bulletKeys.map(e=>(0,X.jsxs)(`li`,{className:`text-[11px] text-foreground/70 leading-snug`,children:[`• `,s(e)]},e))})]})]})},e)})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-2 px-5 py-3 border-t border-border/30 bg-surface/20`,children:[(0,X.jsx)(U,{variant:`ghost`,size:`sm`,onClick:a,disabled:i,children:s(`common:actions.cancel`)}),(0,X.jsxs)(U,{size:`sm`,onClick:()=>o(c),disabled:i,"data-testid":`smash-confirm-modal-continue`,children:[(0,X.jsx)(rt,{className:`w-3.5 h-3.5 mr-1.5`}),s(i?`smashModal.starting`:n?`smashModal.confirmReSmash`:`smashModal.smash`)]})]})]}),(0,X.jsx)(fe,{handles:p})]}),document.body):null}var li=`## Contract Layer`;function ui(e,t){return!(!t||e.status===`draft`||e.parent_epic_id!=null||!e.description?.includes(li))}function di({ticket:e,projectId:t,provider:n,featureFlagOn:r,childrenCount:i}){let{t:a}=g(`activity`),o=ni(e.id),[s,c]=(0,Y.useState)(!1),[l,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(e.origin_conversation_id?void 0:null);(0,Y.useEffect)(()=>{let r=e.origin_conversation_id;if(!r){p(null);return}let i=!1;return p(void 0),fetch(`${u}/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?f:n,h=r&&x(m),_=e.is_epic===!0,v=!_&&ui(e,h),y=_&&h,S=_&&i>0,C=(0,Y.useCallback)(async n=>{if(h){d(!0);try{let r=await fetch(`${u}/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(()=>({}));b.error(e.reason?a(`smash.couldNotStartWithReason`,{reason:e.reason}):a(`smash.couldNotStart`));return}c(!1)}catch(e){b.error(a(`smash.smashFailed`,{message:e.message}))}finally{d(!1)}}},[t,e.id,a,h]),w=(0,Y.useCallback)(async n=>{if(h){if(S){d(!0);try{if(!(await fetch(`${u}/api/projects/${t}/tickets/${e.id}/children`,{method:`DELETE`})).ok){b.error(a(`smash.couldNotDeleteChildren`)),d(!1);return}}catch(e){b.error(a(`smash.deleteFailed`,{message:e.message})),d(!1);return}}await C(n)}},[S,C,t,e.id,a,h]);return!v&&!y?null:o?(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,"data-testid":`smash-actions-streaming`,children:(0,X.jsx)(oi,{stage:o.stage})}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(U,{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,X.jsx)(rt,{className:`w-3.5 h-3.5 mr-1.5`}),a(y?`smash.reSmashButton`:`smash.smashButton`)]}),(0,X.jsx)(ci,{open:s,ticketTitle:e.title,isReSmash:S,childrenCount:i,submitting:l,onCancel:()=>c(!1),onConfirm:w})]})}function fi({epic:e,childExecutionOrder:t,totalChildren:n,onOpenEpic:r}){let{t:i}=g(`activity`);return(0,X.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,X.jsxs)(`button`,{type:`button`,onClick:r,className:`text-accent-secondary hover:underline font-medium`,children:[`← `,e.title]}),t!=null&&n>0&&(0,X.jsx)(`span`,{className:`text-foreground/60`,children:i(`epicChildren.step`,{order:t,total:n})})]})}var pi={critical:`bg-red-400`,high:`bg-orange-400`,medium:`bg-yellow-400`,low:`bg-slate-400`};function mi(e){return e?pi[e]:`bg-muted`}function hi(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 gi({ticket:e,allTickets:t,onOpenTicket:n}){let{t:r}=g(`activity`),i=e.is_epic===!0,a=e.parent_epic_id!=null;if(!i&&!a)return null;if(i){let i=hi(t.filter(t=>t.parent_epic_id===e.id));return(0,X.jsx)(_i,{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=hi(t.filter(t=>t.parent_epic_id===e.parent_epic_id)),c=o?[o,...s]:s;return(0,X.jsx)(_i,{header:r(`family.familyHeader`,{count:s.length}),rows:c,currentId:e.id,onOpenTicket:n,emptyMessage:r(`family.noSiblings`)})}function _i({header:e,rows:t,currentId:n,onOpenTicket:r,emptyMessage:i}){let{t:a}=g(`activity`);return(0,X.jsxs)(`div`,{"data-testid":`epic-family-sidebar`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 mb-1.5`,children:[(0,X.jsx)(rt,{className:`w-3 h-3 text-accent-highlight`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:e})]}),t.length===0?(0,X.jsx)(`p`,{className:`text-[10px] text-foreground/50 italic`,children:i}):(0,X.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,X.jsx)(`li`,{children:(0,X.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,X.jsx)(D,{className:`w-3 h-3 text-accent-highlight flex-shrink-0`,"aria-hidden":!0}):(0,X.jsx)(`span`,{className:`text-[9px] tabular-nums text-foreground/40 w-3 text-center flex-shrink-0`,children:e.execution_order??`–`}),(0,X.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full flex-shrink-0 ${mi(e.priority)}`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`text-[11px] truncate ${t?`text-foreground font-medium`:`text-foreground/80`}`,title:e.title,children:e.title})]})},e.id)})})]})}var vi=224,yi=8,bi=8;function xi({rails:e,onMoveToRail:t,onClose:n,anchorRect:r}){let{t:i}=g(`tickets`),a=(0,Y.useRef)(null),[o,s]=(0,Y.useState)(!1);(0,Y.useLayoutEffect)(()=>{let e=requestAnimationFrame(()=>s(!0));return()=>cancelAnimationFrame(e)},[]),(0,Y.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,Y.useMemo)(()=>{let e=r.left+r.width/2,t=e-vi/2,n=window.innerWidth-vi-yi,i=Math.max(yi,Math.min(n,t)),a=e-i,o=Math.max(12,Math.min(vi-12,a));return{top:r.bottom+bi,left:i,caretLeft:o}},[r]);return(0,X.jsxs)(`div`,{ref:a,role:`dialog`,"aria-label":i(`rail.popoverTitle`),"data-testid":`move-to-rail-popover`,style:{top:c,left:l,width:vi,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,X.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,X.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,X.jsx)(`div`,{className:`px-2 py-2 text-xs text-muted-foreground`,children:i(`rail.noRails`)}):(0,X.jsx)(`ul`,{className:`flex flex-col`,children:e.map(e=>(0,X.jsx)(`li`,{children:(0,X.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,X.jsx)(I,{className:`w-3 h-3 text-accent-success animate-pulse shrink-0`,"aria-hidden":!0}):(0,X.jsx)(He,{className:`w-3 h-3 text-muted-foreground/60 shrink-0`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`flex-1 truncate`,children:e.label}),(0,X.jsx)(Ve,{className:`w-3.5 h-3.5 text-muted-foreground/40 shrink-0`,"aria-hidden":!0})]})},e.id))})]})}var Si=900,Ci=.2,wi=[`todo`,`in_progress`,`done`,`cancelled`],Ti={draft:`ticketStatus.draft`,todo:`ticketStatus.todo`,in_progress:`ticketStatus.inProgress`,on_review:`ticketStatus.onReview`,done:`ticketStatus.done`,cancelled:`ticketStatus.cancelled`},Ei=[{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 Di(e){return e.jira_epic_key&&e.jira_url?e.jira_url.replace(/\/browse\/[^/]+$/,`/browse/${e.jira_epic_key}`):null}var Oi={manual:`source.manual`,"product-backlog":`source.productBacklog`,"propose-spec":`source.proposeSpec`,"get-backlog-specs":`source.getBacklogSpecs`,"free-prompt":`source.freePrompt`};function ki({ticket:e,allLabels:t,allTickets:n,onClose:r,onOpenTicket:i,onSave:a,onDelete:o,rails:s,onMoveToRail:c,onRemoveFromRail:l,embedded:u=!1}){let{t:d}=g(`tickets`),{t:f}=g(`jira`),{activeProjectId:p,projects:m}=y(),{enterSplit:_,state:v}=Qi(),S=v.originSide!==null,w=m.find(e=>e.id===p)?.provider,T=x(w),D=(0,Y.useMemo)(()=>(n??[]).filter(t=>t.parent_epic_id===e.id),[n,e.id]),O=(0,Y.useMemo)(()=>e.parent_epic_id==null?null:(n??[]).find(t=>t.id===e.parent_epic_id)??null,[n,e.parent_epic_id]),k=(0,Y.useMemo)(()=>O?(n??[]).filter(e=>e.parent_epic_id===O.id).length:0,[n,O]),[A,j]=(0,Y.useState)(e.title),[M,te]=(0,Y.useState)(e.description),[N,ne]=(0,Y.useState)(e.priority??`medium`),[I,L]=(0,Y.useState)([...e.labels??[]]),[R,ie]=(0,Y.useState)(e.repositoryIds),[z,oe]=(0,Y.useState)(!1),[B,_e]=(0,Y.useState)(!1),[V,H]=(0,Y.useState)(``),[be,xe]=(0,Y.useState)(!1),[Se,Ce]=(0,Y.useState)(!1),[we,Te]=(0,Y.useState)(!1),[Ee,De]=(0,Y.useState)(!1),[Oe,ke]=(0,Y.useState)(!1),[Ae,je]=(0,Y.useState)(!1),Me=En(),Ne=Me.connected&&!!Me.discardStatus&&e.source===`jira`&&!!e.jira_key,Pe=Me.connected&&e.source===`jira`&&!!e.jira_key,[Fe,Ie]=(0,Y.useState)(e.attachments??[]);(0,Y.useEffect)(()=>{Ie(e.attachments??[])},[e.attachments,e.id]);let[Le,Re]=(0,Y.useState)(!1),[Be,Ve]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!Pe)return;let e=!0;return ve.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)}}},We=async t=>{if(!(!t||t===G)){Re(!0);try{await ve.moveSpecToStatus(e.id,t),b.success(f(`moveToStatus.queued`,{status:t}))}catch{b.error(f(`moveToStatus.failed`))}finally{Re(!1)}}},Ge=(0,Y.useRef)(null),Ke=(0,Y.useRef)(null),qe=(0,Y.useRef)(null),Je=(0,Y.useMemo)(()=>A!==e.title||M!==e.description||N!==e.priority||JSON.stringify(I)!==JSON.stringify(e.labels)||JSON.stringify(R)!==JSON.stringify(e.repositoryIds),[A,M,N,I,R,e]);(0,Y.useEffect)(()=>{z&&Ge.current?.focus()},[z]),(0,Y.useEffect)(()=>{if(B){let e=Ke.current;e&&(e.focus(),e.selectionStart=e.value.length)}},[B]),(0,Y.useEffect)(()=>{be&&qe.current?.focus()},[be]),(0,Y.useEffect)(()=>{function e(e){e.key===`Escape`&&!z&&!B&&!Se&&r()}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,z,B,Se]);let Ye=(0,Y.useMemo)(()=>{if(!V.trim())return[];let e=V.toLowerCase();return t.filter(t=>t.toLowerCase().includes(e)&&!I.includes(t)).slice(0,5)},[V,t,I]),Xe=(0,Y.useCallback)(e=>{let t=e.trim();t&&!I.includes(t)&&L(e=>[...e,t]),H(``)},[I]),Ze=(0,Y.useCallback)(e=>{L(t=>t.filter(t=>t!==e))},[]),Qe=(0,Y.useCallback)(async()=>{let t={};if(A!==e.title&&(t.title=A),M!==e.description&&(t.description=M),N!==e.priority&&(t.priority=N),JSON.stringify(I)!==JSON.stringify(e.labels)&&(t.labels=I),JSON.stringify(R)!==JSON.stringify(e.repositoryIds)&&(t.repositoryIds=R),Object.keys(t).length===0){r();return}ke(!0);let n=await a(e.id,t);ke(!1),n?(b.success(d(`detailModal.toast.updated`)),r()):b.error(d(`detailModal.toast.updateFailed`))},[A,M,N,I,R,e,a,r,d]),$e=(0,Y.useCallback)(async()=>{if(Ae)return;je(!0);let t=!1;try{t=await o(e.id)}catch{t=!1}if(je(!1),!t){b.error(d(`detailModal.toast.deleteFailed`));return}Ce(!1),r()},[Ae,e.id,o,r,d]),[et,tt]=(0,Y.useState)(0),K=(0,Y.useRef)(null),[nt,rt]=(0,Y.useState)(()=>typeof window<`u`&&window.innerWidth>=Si);(0,Y.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>rt(window.innerWidth>=Si);return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let q=!u&&!S&&nt,it=(0,Y.useCallback)(e=>{K.current&&tt(e.clientX-K.current.startX)},[]),J=(0,Y.useCallback)(t=>{if(!K.current)return;let n=t.clientX-K.current.startX,i=window.innerWidth*Ci;if(window.removeEventListener(`pointermove`,it),window.removeEventListener(`pointerup`,J),window.removeEventListener(`pointercancel`,J),K.current=null,tt(0),Math.abs(n)>=i&&window.innerWidth>=Si){let t=v.leftId===e.id;_(n<0?`left`:`right`,e.id),t||r()}},[_,it,v.leftId,e.id,r]),at=(0,Y.useCallback)(e=>{q&&e.button===0&&(e.target.closest(`button, input, textarea, select, [contenteditable="true"]`)||(K.current={startX:e.clientX,pointerId:e.pointerId},window.addEventListener(`pointermove`,it),window.addEventListener(`pointerup`,J),window.addEventListener(`pointercancel`,J)))},[q,it,J]);(0,Y.useEffect)(()=>()=>{K.current&&(window.removeEventListener(`pointermove`,it),window.removeEventListener(`pointerup`,J),window.removeEventListener(`pointercancel`,J))},[it,J]);let ot=(0,Y.useCallback)(()=>{if(!q||window.innerWidth<Si)return;let t=v.leftId===e.id;_(`right`,e.id),t||r()},[q,_,v.leftId,e.id,r]),{panelRef:st,panelStyle:ct,resizeHandles:lt,guardBackdrop:ut}=ce({enabled:!u,allowMove:!1}),dt=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{ref:st,className:u?`relative w-full h-full rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 flex flex-col overflow-hidden`:`relative w-full max-w-[67rem] m-4 rounded-xl bg-card border border-border/40 shadow-2xl shadow-black/50 flex flex-col animate-in fade-in zoom-in-95 duration-200 h-[90vh] 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`},...ct},children:[O&&(0,X.jsx)(`div`,{className:`px-5 pt-3`,children:(0,X.jsx)(fi,{epic:O,childExecutionOrder:e.execution_order??null,totalChildren:k,onOpenEpic:()=>i?.(O.id)})}),(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3 px-5 py-4 border-b border-border/30 ${q?`cursor-grab active:cursor-grabbing`:``}`,onPointerDown:at,"data-testid":`ticket-modal-header`,children:[(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[z?(0,X.jsx)(`input`,{ref:Ge,value:A,onChange:e=>j(e.target.value),onBlur:()=>oe(!1),onKeyDown:t=>{t.key===`Enter`&&oe(!1),t.key===`Escape`&&(j(e.title),oe(!1))},className:`w-full bg-transparent border-b border-accent-primary/50 text-sm font-semibold text-foreground outline-none pb-0.5`}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>oe(!0),className:`group flex items-center gap-1.5 text-left w-full`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold text-foreground truncate`,children:A||d(`untitled`)}),(0,X.jsx)(F,{className:`w-3 h-3 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0`})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mt-1.5`,children:[(0,X.jsxs)(`span`,{className:`text-[10px] text-foreground font-mono`,children:[`#`,e.id]}),e.status===`on_review`&&(0,X.jsx)(`span`,{title:d(`specs:status.onReviewHint`),"data-testid":`ticket-modal-on-review-badge`,children:(0,X.jsx)(Tn,{status:`on_review`})})]}),(0,X.jsx)(Sn,{ticketId:e.id})]}),p&&(0,X.jsx)(`div`,{className:`shrink-0`,children:(0,X.jsx)(di,{ticket:e,projectId:p,provider:w,featureFlagOn:T,childrenCount:D.length})}),(0,X.jsx)(ji,{ticket:e,title:A,description:M,priority:N,labels:I,repositoryIds:R,onClose:r}),s&&(c||l)&&(0,X.jsx)(Mi,{ticket:e,rails:s,onMoveToRail:c,onRemoveFromRail:l}),q&&(0,X.jsxs)(U,{variant:`outline`,size:`sm`,className:`shrink-0 mr-1 gap-1.5`,"data-testid":`ticket-modal-compare`,onClick:ot,title:d(`detailModal.compareTooltip`),children:[(0,X.jsx)(Ue,{className:`w-3.5 h-3.5`}),d(`detailModal.compare`)]}),(0,X.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,X.jsx)(se,{className:`w-4 h-4`})})]}),(0,X.jsx)(`div`,{className:`flex-1 overflow-y-auto min-h-0`,children:(0,X.jsxs)(`div`,{className:`flex flex-col sm:flex-row h-full`,children:[(0,X.jsxs)(`div`,{className:`flex-1 min-w-0 px-5 py-4 space-y-4 flex flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex-1 flex flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider flex items-center gap-1.5`,children:d(`fields.description`)}),!B&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>_e(!0),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,X.jsx)(F,{className:`w-2.5 h-2.5`}),d(`common:actions.edit`)]})]}),B?(0,X.jsxs)(`div`,{className:`space-y-1.5 flex-1 flex flex-col`,children:[(0,X.jsx)(`textarea`,{ref:Ke,value:M,onChange:e=>te(e.target.value),className:`w-full flex-1 rounded-lg border border-border bg-input px-3 py-2 text-xs text-foreground placeholder:text-muted-foreground resize-none min-h-[300px]`,placeholder:d(`fields.markdownPlaceholder`)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(U,{variant:`ghost`,size:`sm`,className:`h-6 text-[10px]`,onClick:()=>_e(!1),children:d(`detailModal.doneEditing`)}),(0,X.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:d(`fields.supportsMarkdown`)})]})]}):M?(0,X.jsx)(Ii,{description:M,onEdit:()=>_e(!0)}):(0,X.jsx)(`button`,{type:`button`,onClick:()=>_e(!0),className:`w-full rounded-lg border border-dashed border-border/40 bg-muted/10 px-3 py-4 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/20 transition-colors text-center`,children:d(`detailModal.addDescription`)})]}),(0,X.jsx)(yn,{ticket:e}),(0,X.jsx)(en,{ticketKey:e.id,attachments:Fe,onChange:Ie}),(0,X.jsx)(tn,{ticketId:e.id,onClose:r}),e.prerequisites&&e.prerequisites.length>0&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`detailModal.prerequisites`)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.prerequisites.map(e=>(0,X.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,X.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,X.jsxs)(`button`,{type:`button`,onClick:()=>{W(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,X.jsx)(E,{className:`w-3.5 h-3.5 shrink-0`}),f(`detail.goToTicket`,{key:e.jira_key})]}),e.jira_epic_key&&(0,X.jsxs)(`div`,{"data-testid":`jira-epic`,children:[(0,X.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:f(`detail.epic`)}),(0,X.jsxs)(`button`,{type:`button`,onClick:()=>{let t=Di(e);t&&W(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,X.jsx)(`span`,{className:`font-mono text-accent-highlight shrink-0`,children:e.jira_epic_key}),e.jira_epic_name&&(0,X.jsx)(`span`,{className:`truncate text-foreground/80`,children:e.jira_epic_name})]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`fields.status`)}),Pe?(0,X.jsx)(`select`,{value:G,disabled:Le||Be===null,onChange:e=>{We(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,X.jsx)(`option`,{value:G,children:G||d(`states.loading`,{ns:`common`})}):(0,X.jsxs)(X.Fragment,{children:[G&&!Be.some(e=>e.name===G)&&(0,X.jsx)(`option`,{value:G,children:G}),Be.map(e=>(0,X.jsx)(`option`,{value:e.name,children:e.name},e.name))]})}):(0,X.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:[!wi.includes(e.status)&&(0,X.jsx)(`option`,{value:e.status,children:d(Ti[e.status],{ns:`tickets`})}),wi.map(e=>(0,X.jsx)(`option`,{value:e,children:d(Ti[e],{ns:`tickets`})},e))]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`fields.priority`)}),(0,X.jsx)(`select`,{value:N,onChange:e=>ne(e.target.value),className:`w-full h-7 rounded border border-border bg-input px-2 text-xs text-foreground`,children:Ei.map(e=>(0,X.jsx)(`option`,{value:e.value,children:d(e.labelKey)},e.value))})]}),(0,X.jsx)(ye,{value:R,onChange:ie,disabled:Oe}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-1.5`,children:d(`fields.labels`)}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1 mb-1.5`,children:I.map(e=>(0,X.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,X.jsx)(`button`,{type:`button`,onClick:()=>Ze(e),className:`text-muted-foreground hover:text-foreground opacity-0 group-hover:opacity-100 transition-opacity`,children:(0,X.jsx)(ee,{className:`w-2.5 h-2.5`})})]},e))}),be?(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(`input`,{ref:qe,value:V,onChange:e=>H(e.target.value),onKeyDown:e=>{e.key===`Enter`&&V.trim()&&(e.preventDefault(),Xe(V)),e.key===`Escape`&&(xe(!1),H(``))},onBlur:()=>{V.trim()&&Xe(V),xe(!1),H(``)},placeholder:d(`detailModal.addLabelPlaceholder`),className:`w-full h-6 rounded border border-border bg-input px-2 text-[10px] text-foreground placeholder:text-muted-foreground`}),Ye.length>0&&(0,X.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,X.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,X.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,X.jsx)(re,{className:`w-2.5 h-2.5`}),d(`detailModal.addLabel`)]})]}),(0,X.jsx)(gi,{ticket:e,allTickets:n??[],onOpenTicket:e=>i?.(e)}),e.source===`jira`&&e.jira_key&&(0,X.jsx)(An,{localId:e.id}),e.metadata?.effort_level&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-0.5`,children:d(`detailModal.effort`)}),(0,X.jsx)(`span`,{className:`text-xs text-foreground/70`,children:e.metadata.effort_level})]}),e.assignee&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-[10px] font-medium text-muted-foreground uppercase tracking-wider block mb-0.5`,children:d(`detailModal.assignee`)}),(0,X.jsx)(`span`,{className:`text-xs text-foreground/70`,children:e.assignee})]})]})]})}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between px-5 py-3 border-t border-border/30`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground`,children:[(0,X.jsx)(`span`,{children:d(`meta.createdAgo`,{time:Ai(e.created_at)})}),(0,X.jsx)(`span`,{children:d(`meta.updatedAgo`,{time:Ai(e.updated_at)})}),e.source&&(0,X.jsx)(`span`,{className:`bg-muted/30 rounded px-1.5 py-0.5`,children:Oi[e.source]?d(Oi[e.source]):e.source})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[Ne?(0,X.jsxs)(U,{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,X.jsx)(ze,{className:`w-3 h-3 mr-1`}),f(`discard.moveButton`,{status:Me.discardStatus})]}):(0,X.jsxs)(U,{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,X.jsx)(ae,{className:`w-3 h-3 mr-1`}),d(`common:actions.delete`)]}),Je&&(0,X.jsxs)(U,{size:`sm`,className:`h-7 text-xs`,onClick:()=>{Pe?De(!0):Qe()},disabled:Oe||!A.trim(),children:[(0,X.jsx)(C,{className:`w-3 h-3 mr-1`}),d(Oe?`common:states.saving`:`common:actions.save`)]})]})]})]}),(0,X.jsx)(ge,{open:Se,onOpenChange:e=>{Ae||Ce(e)},children:(0,X.jsxs)(he,{className:`max-w-sm`,children:[(0,X.jsxs)(me,{children:[(0,X.jsx)(pe,{children:d(`deleteDialog.title`)}),(0,X.jsx)(de,{children:(0,X.jsx)(h,{t:d,i18nKey:`deleteDialog.body`,values:{id:e.id,title:e.title},components:{strong:(0,X.jsx)(`span`,{className:`font-semibold text-foreground`})}})})]}),(0,X.jsxs)(ue,{children:[(0,X.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>Ce(!1),disabled:Ae,children:d(`common:actions.cancel`)}),(0,X.jsxs)(U,{variant:`destructive`,size:`sm`,onClick:()=>{$e()},disabled:Ae,"aria-busy":Ae,children:[Ae?(0,X.jsx)(P,{className:`w-3.5 h-3.5 mr-1.5 animate-spin`}):(0,X.jsx)(ae,{className:`w-3.5 h-3.5 mr-1.5`}),d(`common:actions.delete`)]})]})]})}),Ne&&Me.discardStatus&&(0,X.jsx)(Dn,{open:we,onOpenChange:Te,ticket:{id:e.id,title:e.title,jira_key:e.jira_key},discardStatus:Me.discardStatus,onDiscarded:r}),(0,X.jsx)(ge,{open:Ee,onOpenChange:De,children:(0,X.jsxs)(he,{className:`max-w-md`,"data-testid":`jira-save-confirm`,children:[(0,X.jsxs)(me,{children:[(0,X.jsx)(pe,{children:f(`detail.saveTitle`)}),(0,X.jsx)(de,{children:f(`detail.saveBody`,{key:e.jira_key??`#${e.id}`})})]}),(0,X.jsxs)(ue,{children:[(0,X.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>De(!1),children:d(`common:actions.cancel`)}),(0,X.jsxs)(U,{size:`sm`,onClick:()=>{De(!1),Qe()},disabled:Oe,"data-testid":`jira-save-confirm-btn`,children:[(0,X.jsx)(C,{className:`w-3.5 h-3.5 mr-1.5`}),f(`detail.saveConfirm`)]})]})]})})]});return u?dt:(0,Pr.createPortal)((0,X.jsxs)(`div`,{style:le(),className:`fixed inset-0 z-[68] flex items-center justify-center`,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-black/70`,onClick:ut(r)}),dt,(0,X.jsx)(fe,{handles:lt})]}),document.body)}function Ai(e){try{return H(new Date(e),{addSuffix:!0,locale:d()})}catch{return e}}function ji({ticket:e,title:t,description:n,priority:r,labels:i,repositoryIds:a,onClose:o}){let{t:s}=g(`tickets`),{triggerResume:c}=O(),{activeProjectId:l}=y(),{closeTicketDetail:u}=Qi();return Pn(e)?(0,X.jsxs)(U,{variant:`default`,size:`sm`,onClick:()=>{if(!l)return;let{body:d,criteria:f}=Mn(n);c({kind:`explore-spec`,projectId:l,label:t||e.title||s(`detailModal.ticketFallbackLabel`,{id:e.id}),restoreRoute:`/`,params:{initialIdea:``,pendingSpecId:Fn(),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,X.jsx)($e,{className:`w-3.5 h-3.5 mr-1.5`}),s(`detailModal.continueEditing`)]}):null}function Mi({ticket:e,rails:t,onMoveToRail:n,onRemoveFromRail:r}){let{t:i}=g(`tickets`),[a,o]=(0,Y.useState)(null),s=(0,Y.useRef)(null),c=t.find(t=>t.ticketIds.includes(e.id));return c?r?(0,X.jsxs)(U,{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,X.jsx)(S,{className:`w-3.5 h-3.5`,"aria-hidden":!0}),i(`rail.removeFromRail`)]}):null:n?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(U,{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,X.jsx)(ze,{className:`w-3.5 h-3.5`,"aria-hidden":!0})]}),a&&(0,X.jsx)(xi,{rails:t,anchorRect:a,onMoveToRail:t=>n(e.id,t),onClose:()=>o(null)})]}):null}var Ni=`
11
+
12
+ ---
13
+
14
+ ## Contract Layer
15
+
16
+ `;function Pi(e){let t=e.indexOf(Ni);return t<0?{user:e,contract:null}:{user:e.slice(0,t),contract:e.slice(t+26)}}function Fi(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 Ii({description:e,onEdit:t}){let{t:n}=g(`tickets`),{openWebView:r}=Xr(),{user:i,contract:a}=Pi(e),o=i||e,s=(0,Y.useMemo)(()=>({a:({href:e,children:t})=>(0,X.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,X.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,X.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,X.jsx)(_e,{remarkPlugins:[V],components:s,children:o})}),a&&(0,X.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,X.jsxs)(`summary`,{className:`cursor-pointer text-[10px] font-medium text-foreground/80 select-none flex items-center gap-2`,children:[n(`contractLayer.title`),(0,X.jsx)(`span`,{className:`rounded-full bg-muted/40 px-1.5 text-[9px] text-foreground/60`,children:n(`contractLayer.populated`,{n:Fi(a)})})]}),(0,X.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,X.jsx)(_e,{remarkPlugins:[V],components:s,children:a})})]})]})}var Li={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 Ri(e){try{return H(new Date(e),{addSuffix:!0,locale:d()})}catch{return e}}function zi({tickets:e,excludeIds:t,onSelect:n}){let{t:r}=g(`tickets`),[i,a]=(0,Y.useState)(``),o=(0,Y.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,X.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,X.jsxs)(`div`,{className:`px-4 py-3 border-b border-border/30 flex items-center gap-2`,children:[(0,X.jsx)(q,{className:`w-3.5 h-3.5 text-muted-foreground`}),(0,X.jsx)(`span`,{className:`text-xs font-semibold text-foreground`,children:r(`comparePicker.title`)}),(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`comparePicker.count`,{n:o.length})})]}),(0,X.jsx)(`div`,{className:`px-4 py-2 border-b border-border/20`,children:(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(ie,{className:`absolute left-2 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,X.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,X.jsx)(`div`,{className:`flex-1 overflow-y-auto`,"data-testid":`spec-compare-picker-list`,children:o.length===0?(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-full text-center px-4 py-8 gap-2`,children:[(0,X.jsx)(q,{className:`w-6 h-6 text-muted-foreground/40`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:i.trim()?r(`comparePicker.noMatches`):r(`comparePicker.empty`)})]}):(0,X.jsx)(`ul`,{className:`divide-y divide-border/10`,children:o.map(e=>(0,X.jsx)(`li`,{children:(0,X.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,X.jsx)(wn,{status:e.status}),(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground`,children:[`#`,e.id]}),e.priority&&Li[e.priority]&&(0,X.jsx)(`span`,{className:`inline-flex items-center rounded px-1 py-0.5 text-[9px] font-medium border ${Li[e.priority]}`,children:r(`priority.${e.priority}`)})]}),(0,X.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,X.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,X.jsxs)(`div`,{className:`mt-1 flex flex-wrap gap-1`,children:[e.labels.slice(0,3).map(e=>(0,X.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,X.jsxs)(`span`,{className:`text-[9px] text-muted-foreground`,children:[`+`,e.labels.length-3]})]}),(0,X.jsx)(`p`,{className:`mt-1 text-[9px] text-muted-foreground`,children:r(`meta.updatedAgo`,{time:Ri(e.updated_at)})})]})]})},e.id))})})]})}var Bi=.25,Vi=.75;function Hi({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,Y.useRef)(null),p=(0,Y.useRef)(null),[m,h]=(0,Y.useState)(!0);(0,Y.useEffect)(()=>{let e=setTimeout(()=>h(!1),320);return()=>clearTimeout(e)},[]);let g=(0,Y.useCallback)(e=>{if(!p.current)return;let t=window.innerWidth,n=e.clientX/t;u(Math.min(Vi,Math.max(Bi,n)))},[u]),_=(0,Y.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,Y.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,Y.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,Y.useCallback)(t=>{let n=.04;t.key===`ArrowLeft`?(t.preventDefault(),u(Math.max(Bi,e.splitRatio-n))):t.key===`ArrowRight`?(t.preventDefault(),u(Math.min(Vi,e.splitRatio+n))):t.key===`Home`?(t.preventDefault(),u(Bi)):t.key===`End`?(t.preventDefault(),u(Vi)):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,X.jsx)(ki,{ticket:f,allLabels:i,allTickets:r,onClose:d?c:()=>l(null,u),onOpenTicket:s,onSave:a,onDelete:o,embedded:!0},`${u}-${f.id}`):(0,X.jsx)(zi,{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,Pr.createPortal)((0,X.jsxs)(`div`,{ref:f,"data-testid":`split-view-shell`,style:le(),className:`fixed inset-0 z-[68] flex`,onClick:b,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-black/70 pointer-events-none`,"aria-hidden":!0}),(0,X.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,X.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,X.jsx)(`div`,{className:`h-full flex items-center justify-center p-2`,children:(0,X.jsx)(`div`,{className:`w-full h-full max-h-[95vh]`,children:x(`left`)})})}),(0,X.jsx)(`div`,{"data-testid":`split-divider`,role:`separator`,"aria-orientation":`vertical`,"aria-valuenow":Math.round(e.splitRatio*100),"aria-valuemin":Math.round(Bi*100),"aria-valuemax":Math.round(Vi*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,X.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,X.jsx)(`div`,{className:`h-full flex items-center justify-center p-2`,children:(0,X.jsx)(`div`,{className:`w-full h-full max-h-[95vh]`,children:x(`right`)})})})]})]}),document.body)}var Ui=.5,Wi=.25,Gi=.75,Ki={leftId:null,rightId:null,originSide:null,splitRatio:Ui};function qi(e){return Number.isFinite(e)?Math.min(Gi,Math.max(Wi,e)):Ui}function Ji(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:Ui}:e.originSide!==null&&(e.leftId===t.id||e.rightId===t.id)?e:{...Ki,leftId:t.id};case`closeAll`:return Ki;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:Ui}:{leftId:null,rightId:n,originSide:`right`,splitRatio:Ui}}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{...Ki,leftId:t}}case`setSplitRatio`:return{...e,splitRatio:qi(t.ratio)};default:return e}}var Yi=(0,Y.createContext)(null),Xi=900;function Zi({children:e}){let[t,n]=(0,Y.useReducer)(Ji,Ki),{tickets:r,updateTicket:i,deleteTicket:a}=_t(),{activeProjectId:o,setActiveProjectId:s}=y(),c=(0,Y.useRef)(null);(0,Y.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,Y.useCallback)(e=>n({type:`openCentered`,id:e}),[]),u=(0,Y.useCallback)((e,t)=>{if(e===o){n({type:`openCentered`,id:t});return}c.current={projectId:e,ticketId:t},s(e)},[o,s]),d=(0,Y.useCallback)(()=>n({type:`closeAll`}),[]),f=(0,Y.useCallback)((e,t)=>{typeof window<`u`&&window.innerWidth<Xi||n({type:`enterSplit`,side:e,ticketId:t})},[]),p=(0,Y.useCallback)((e,t)=>n({type:`setComparedTicket`,id:e,side:t}),[]),m=(0,Y.useCallback)(()=>n({type:`exitSplit`}),[]),h=(0,Y.useCallback)(e=>n({type:`setSplitRatio`,ratio:e}),[]);(0,Y.useEffect)(()=>{if(typeof window>`u`)return;function e(){window.innerWidth<Xi&&n({type:`exitSplit`})}return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let g=(0,Y.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,b=(0,Y.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]),x=t.originSide!==null;return(0,X.jsxs)(Yi.Provider,{value:b,children:[e,!x&&_&&(0,X.jsx)(ki,{ticket:_,allLabels:g,allTickets:r,onClose:d,onOpenTicket:l,onSave:i,onDelete:a},_.id),x&&(0,X.jsx)(Hi,{state:t,leftTicket:_,rightTicket:v,allTickets:r,allLabels:g,onSave:i,onDelete:a,onOpenTicket:l,onCloseAll:d,onSetCompared:p,onSetRatio:h,onExitSplit:m})]})}function Qi(){return(0,Y.useContext)(Yi)||{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:Ki}}export{Be as $,wn as A,nt as B,Xn as C,Mn as D,Pn as E,Rt as F,Xe as G,$e as H,_t as I,Ke as J,Ye as K,lt as L,Wt as M,Bt as N,Dn as O,Jt as P,G as Q,ut as R,nr as S,Fn as T,Qe as U,K as V,Ze as W,Ue as X,Ge as Y,He as Z,er as _,W as _t,ti as a,De as at,ir as b,Gr as c,Oe as ct,Mr as d,Ne as dt,ze as et,wr as f,Pe as ft,ar as g,be as gt,Ln as h,Ce as ht,xi as i,Ee as it,mn as j,En as k,Wr as l,Re as lt,sr as m,Le as mt,Qi as n,ke as nt,Yr as o,Ie as ot,gr as p,we as pt,qe as q,ki as r,Ae as rt,Xr as s,je as st,Zi as t,Te as tt,Rr as u,Fe as ut,or as v,xe as vt,rr as w,tr as x,In as y,q as z};
@@ -1 +1 @@
1
- import{a as e,t}from"./rolldown-runtime-CNC7AqOf.js";import{n}from"./jsx-runtime-zu2_FqZY.js";import{j as r}from"./useSharedWebSocket-BN3Lmehi.js";import{a as i,d as a,f as o,i as s,l as c,p as l,s as u,u as d}from"./createLucideIcon-Bjbbp_KS.js";var f=t(((e,t)=>{t.exports={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}})),p=e(n()),m=e(f()),h=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function g(e){var t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(m.default[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){var r=e.indexOf(`-->`);return{type:`comment`,comment:r===-1?``:e.slice(4,r)}}for(var i=new RegExp(h),a=null;(a=i.exec(e))!==null;)if(a[0].trim())if(a[1]){var o=a[1].trim(),s=[o,``];o.indexOf(`=`)>-1&&(s=o.split(`=`)),t.attrs[s[0]]=s[1],i.lastIndex--}else a[2]&&(t.attrs[a[2]]=a[3].trim().substring(1,a[3].length-1));return t}var _=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,v=/^\s*$/,y=Object.create(null);function b(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:return e+=`<`+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+`="`+e[n]+`"`);return t.length?` `+t.join(` `):``}(t.attrs):``)+(t.voidElement?`/>`:`>`),t.voidElement?e:e+t.children.reduce(b,``)+`</`+t.name+`>`;case`comment`:return e+`<!--`+t.comment+`-->`}}var x={parse:function(e,t){t||={},t.components||=y;var n,r=[],i=[],a=-1,o=!1;if(e.indexOf(`<`)!==0){var s=e.indexOf(`<`);r.push({type:`text`,content:s===-1?e:e.substring(0,s)})}return e.replace(_,function(s,c){if(o){if(s!==`</`+n.name+`>`)return;o=!1}var l,u=s.charAt(1)!==`/`,d=s.startsWith(`<!--`),f=c+s.length,p=e.charAt(f);if(d){var m=g(s);return a<0?(r.push(m),r):((l=i[a]).children.push(m),r)}if(u&&(a++,(n=g(s)).type===`tag`&&t.components[n.name]&&(n.type=`component`,o=!0),n.voidElement||o||!p||p===`<`||n.children.push({type:`text`,content:e.slice(f,e.indexOf(`<`,f))}),a===0&&r.push(n),(l=i[a-1])&&l.children.push(n),i[a]=n),(!u||n.voidElement)&&(a>-1&&(n.voidElement||n.name===s.slice(2,-1))&&(a--,n=a===-1?r:i[a]),!o&&p!==`<`&&p)){l=a===-1?r:i[a].children;var h=e.indexOf(`<`,f),_=e.slice(f,h===-1?void 0:h);v.test(_)&&(_=` `),(h>-1&&a+l.length>=0||_!==` `)&&l.push({type:`text`,content:_})}}),r},stringify:function(e){return e.reduce(function(e,t){return e+b(``,t)},``)}},S=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},C=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?T(t):t},w=e=>Array.isArray(e)&&e.every(p.isValidElement),T=e=>Array.isArray(e)?e:[e],E=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},D=e=>{let t={};if(!e)return t;let n=e=>{T(e).forEach(e=>{a(e)||(S(e)?n(C(e)):d(e)&&!(0,p.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},O=(e,t,n,r)=>{if(!e)return``;let i=``,s=T(e),c=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return s.forEach((e,s)=>{if(a(e)){i+=`${e}`;return}if((0,p.isValidElement)(e)){let{props:o,type:l}=e,u=Object.keys(o).length,d=c.indexOf(l)>-1,f=o.children;if(!f&&d&&!u){i+=`<${l}/>`;return}if(!f&&(!d||u)||o.i18nIsDynamicList){i+=`<${s}></${s}>`;return}if(d&&u<=1){let e=a(f)?f:O(f,t,n,r);i+=`<${l}>${e}</${l}>`;return}let p=O(f,t,n,r);i+=`<${s}>${p}</${s}>`;return}if(e===null){o(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(d(e)){let{format:t,...a}=e,s=Object.keys(a);if(s.length===1){let e=t?`${s[0]}, ${t}`:s[0];i+=`{{${e}}}`;return}o(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}o(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},k=(e,t=[],n={})=>{if(!e)return e;let r=Object.keys(n),i=[...t,...r],a=``,o=0;for(;o<e.length;)if(e[o]===`<`){let t=!1,n=e.slice(o).match(/^<\/(\d+|[a-zA-Z][a-zA-Z0-9_-]*)>/);if(n){let e=n[1];(/^\d+$/.test(e)||i.includes(e))&&(t=!0,a+=n[0],o+=n[0].length)}if(!t){let n=e.slice(o).match(/^<(\d+|[a-zA-Z][a-zA-Z0-9_-]*)(\s+[\w-]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?)*\s*(\/)?>/);if(n){let e=n[1];(/^\d+$/.test(e)||i.includes(e))&&(t=!0,a+=n[0],o+=n[0].length)}}t||(a+=`&lt;`,o+=1)}else a+=e[o],o+=1;return a},A=(e,t,n,r,i,o,s)=>{if(n===``)return[];let l=i.transKeepBasicHtmlNodesFor||[],f=n&&new RegExp(l.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!f&&!s)return[n];let m=t??{},h=e=>{T(e).forEach(e=>{a(e)||(S(e)?h(C(e)):d(e)&&!(0,p.isValidElement)(e)&&Object.assign(m,e))})};h(e);let g=k(n,l,m),_=x.parse(`<0>${g}</0>`),v={...m,...o},y=(e,t,n)=>{let r=C(e),i=D(r,t.children,n);return w(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},b=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,p.cloneElement)(e,{key:r},i?void 0:t))):n.push(...p.Children.map([e],e=>{if(e.type===p.Fragment||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`children`||t===`i18nIsDynamicList`||(n[t]=e.props[t])}),(0,p.createElement)(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`ref`||t===`children`||(n[t]=e.props[t])}),(0,p.cloneElement)(e,n,i?null:t)}))},D=(e,n,o)=>{let m=T(e),h=T(n),g={};return h.reduce((e,n,h)=>{let _=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,v,r.language);if(n.type===`tag`){let u=m[parseInt(n.name,10)];!u&&t&&(u=t[n.name]),o.length===1&&!u&&(u=o[0][n.name]),u||={};let x={...n.attrs};s&&Object.keys(x).forEach(e=>{let t=x[e];a(t)&&(x[e]=c(t))});let w=Object.keys(x).length===0?u:E({props:x},u),O=(0,p.isValidElement)(w),k=O&&S(n,!0)&&!n.voidElement,A=f&&d(w)&&w.dummy&&!O,j=d(t)&&Object.hasOwnProperty.call(t,n.name);if(a(w)){let t=r.services.interpolator.interpolate(w,v,r.language);e.push(t)}else if(S(w)||k){let t=y(w,n,o);b(w,t,e,h)}else if(A){let t=D(m,n.children,o);b(w,t,e,h)}else if(Number.isNaN(parseFloat(n.name)))if(j){let t=y(w,n,o);b(w,t,e,h,n.voidElement)}else if(i.transSupportBasicHtmlNodes&&l.indexOf(n.name)>-1)if(n.voidElement)e.push((0,p.createElement)(n.name,{key:`${n.name}-${h}`}));else{let t=g[n.name]||0;g[n.name]=t+1;let r,i=0;for(let e=0;e<m.length;e+=1){let a=m[e];if((0,p.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let a=r?T(C(r)):m,s=D(a,n.children,o);e.push((0,p.createElement)(n.name,{key:`${n.name}-${h}`},s))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=D(m,n.children,o);e.push(`<${n.name}>${t}</${n.name}>`)}else if(d(w)&&!O){let t=n.children[0]?_:null;t&&e.push(t)}else b(w,_,e,h,n.children.length!==1||!_)}else if(n.type===`text`){let t=i.transWrapTextNodes,a=typeof i.unescape==`function`?i.unescape:u().unescape,o=s?a(r.services.interpolator.interpolate(n.content,v,r.language)):r.services.interpolator.interpolate(n.content,v,r.language);t?e.push((0,p.createElement)(t,{key:`${n.name}-${h}`},o)):e.push(o)}return e},[])};return C(D([{dummy:!0,children:e||[]}],_,T(e||[]))[0])},j=(e,t,n)=>{let r=e.key||t,i=(0,p.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,p.createElement)(p.Fragment,null,i)}return(0,p.createElement)(a,{key:r})},M=(e,t)=>e.map((e,n)=>j(e,n,t)),N=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:j(e[r],r,t)})}),n},P=(e,t,n,r)=>e?Array.isArray(e)?M(e,t):d(e)?N(e,t):(l(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,F=e=>!d(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function I({children:e,count:t,parent:n,i18nKey:o,context:s,tOptions:c={},values:d,defaults:f,components:m,ns:h,i18n:g,t:_,shouldUnescape:v,...y}){let b=g||i();if(!b)return l(b,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using i18nextReactModule`,{i18nKey:o}),e;let x=_||b.t.bind(b)||(e=>e),S={...u(),...b.options?.react},C=h||x.ns||b.options?.defaultNS;C=a(C)?[C]:C||[`translation`];let{transDefaultProps:w}=S,T=w?.tOptions?{...w.tOptions,...c}:c,E=v??w?.shouldUnescape,k=w?.values?{...w.values,...d}:d,j=w?.components?{...w.components,...m}:m,M=O(e,S,b,o),N=f||T?.defaultValue||M||S.transEmptyNodeValue||(typeof o==`function`?r(o):o),{hashTransKey:I}=S,L=o||(I?I(M||N):M||N);d=b.options?.interpolation?.defaultVariables?k&&Object.keys(k).length>0?{...k,...b.options.interpolation.defaultVariables}:{...b.options.interpolation.defaultVariables}:k;let R=D(e);R&&typeof R.count==`number`&&t===void 0&&(t=R.count);let z=d||t!==void 0&&!b.options?.interpolation?.alwaysFormat||!e?T.interpolation:{interpolation:{...T.interpolation,prefix:`#$?`,suffix:`?$#`}},B={...T,context:s||T.context,count:t,...d,...z,defaultValue:N,ns:C},V=L?x(L,B):N;V===L&&N&&(V=N);let H=P(j,V,b,o),U=H||e,W=null;F(H)&&(W=H,U=e);let G=A(U,W,V,b,S,B,E),K=n??S.defaultTransParent;return K?(0,p.createElement)(K,y,G):G}function L({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:o={},values:c,defaults:l,components:u,ns:d,i18n:f,t:m,shouldUnescape:h,...g}){let{i18n:_,defaultNS:v}=(0,p.useContext)(s)||{},y=f||_||i(),b=m||y?.t.bind(y);return I({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:o,values:c,defaults:l,components:u,ns:d||b?.ns||v||y?.options?.defaultNS,i18n:y,t:m,shouldUnescape:h,...g})}export{L as t};
1
+ import{a as e,t}from"./rolldown-runtime-CNC7AqOf.js";import{n}from"./jsx-runtime-zu2_FqZY.js";import{j as r}from"./useSharedWebSocket-8NyZpT6v.js";import{a as i,d as a,f as o,i as s,l as c,p as l,s as u,u as d}from"./createLucideIcon-Bjbbp_KS.js";var f=t(((e,t)=>{t.exports={area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0}})),p=e(n()),m=e(f()),h=/\s([^'"/\s><]+?)[\s/>]|([^\s=]+)=\s?(".*?"|'.*?')/g;function g(e){var t={type:`tag`,name:``,voidElement:!1,attrs:{},children:[]},n=e.match(/<\/?([^\s]+?)[/\s>]/);if(n&&(t.name=n[1],(m.default[n[1]]||e.charAt(e.length-2)===`/`)&&(t.voidElement=!0),t.name.startsWith(`!--`))){var r=e.indexOf(`-->`);return{type:`comment`,comment:r===-1?``:e.slice(4,r)}}for(var i=new RegExp(h),a=null;(a=i.exec(e))!==null;)if(a[0].trim())if(a[1]){var o=a[1].trim(),s=[o,``];o.indexOf(`=`)>-1&&(s=o.split(`=`)),t.attrs[s[0]]=s[1],i.lastIndex--}else a[2]&&(t.attrs[a[2]]=a[3].trim().substring(1,a[3].length-1));return t}var _=/<[a-zA-Z0-9\-\!\/](?:"[^"]*"|'[^']*'|[^'">])*>/g,v=/^\s*$/,y=Object.create(null);function b(e,t){switch(t.type){case`text`:return e+t.content;case`tag`:return e+=`<`+t.name+(t.attrs?function(e){var t=[];for(var n in e)t.push(n+`="`+e[n]+`"`);return t.length?` `+t.join(` `):``}(t.attrs):``)+(t.voidElement?`/>`:`>`),t.voidElement?e:e+t.children.reduce(b,``)+`</`+t.name+`>`;case`comment`:return e+`<!--`+t.comment+`-->`}}var x={parse:function(e,t){t||={},t.components||=y;var n,r=[],i=[],a=-1,o=!1;if(e.indexOf(`<`)!==0){var s=e.indexOf(`<`);r.push({type:`text`,content:s===-1?e:e.substring(0,s)})}return e.replace(_,function(s,c){if(o){if(s!==`</`+n.name+`>`)return;o=!1}var l,u=s.charAt(1)!==`/`,d=s.startsWith(`<!--`),f=c+s.length,p=e.charAt(f);if(d){var m=g(s);return a<0?(r.push(m),r):((l=i[a]).children.push(m),r)}if(u&&(a++,(n=g(s)).type===`tag`&&t.components[n.name]&&(n.type=`component`,o=!0),n.voidElement||o||!p||p===`<`||n.children.push({type:`text`,content:e.slice(f,e.indexOf(`<`,f))}),a===0&&r.push(n),(l=i[a-1])&&l.children.push(n),i[a]=n),(!u||n.voidElement)&&(a>-1&&(n.voidElement||n.name===s.slice(2,-1))&&(a--,n=a===-1?r:i[a]),!o&&p!==`<`&&p)){l=a===-1?r:i[a].children;var h=e.indexOf(`<`,f),_=e.slice(f,h===-1?void 0:h);v.test(_)&&(_=` `),(h>-1&&a+l.length>=0||_!==` `)&&l.push({type:`text`,content:_})}}),r},stringify:function(e){return e.reduce(function(e,t){return e+b(``,t)},``)}},S=(e,t)=>{if(!e)return!1;let n=e.props?.children??e.children;return t?n.length>0:!!n},C=e=>{if(!e)return[];let t=e.props?.children??e.children;return e.props?.i18nIsDynamicList?T(t):t},w=e=>Array.isArray(e)&&e.every(p.isValidElement),T=e=>Array.isArray(e)?e:[e],E=(e,t)=>{let n={...t};return n.props={...t.props,...e.props},n},D=e=>{let t={};if(!e)return t;let n=e=>{T(e).forEach(e=>{a(e)||(S(e)?n(C(e)):d(e)&&!(0,p.isValidElement)(e)&&Object.assign(t,e))})};return n(e),t},O=(e,t,n,r)=>{if(!e)return``;let i=``,s=T(e),c=t?.transSupportBasicHtmlNodes?t.transKeepBasicHtmlNodesFor??[]:[];return s.forEach((e,s)=>{if(a(e)){i+=`${e}`;return}if((0,p.isValidElement)(e)){let{props:o,type:l}=e,u=Object.keys(o).length,d=c.indexOf(l)>-1,f=o.children;if(!f&&d&&!u){i+=`<${l}/>`;return}if(!f&&(!d||u)||o.i18nIsDynamicList){i+=`<${s}></${s}>`;return}if(d&&u<=1){let e=a(f)?f:O(f,t,n,r);i+=`<${l}>${e}</${l}>`;return}let p=O(f,t,n,r);i+=`<${s}>${p}</${s}>`;return}if(e===null){o(n,`TRANS_NULL_VALUE`,`Passed in a null value as child`,{i18nKey:r});return}if(d(e)){let{format:t,...a}=e,s=Object.keys(a);if(s.length===1){let e=t?`${s[0]}, ${t}`:s[0];i+=`{{${e}}}`;return}o(n,`TRANS_INVALID_OBJ`,`Invalid child - Object should only have keys {{ value, format }} (format is optional).`,{i18nKey:r,child:e});return}o(n,`TRANS_INVALID_VAR`,`Passed in a variable like {number} - pass variables for interpolation as full objects like {{number}}.`,{i18nKey:r,child:e})}),i},k=(e,t=[],n={})=>{if(!e)return e;let r=Object.keys(n),i=[...t,...r],a=``,o=0;for(;o<e.length;)if(e[o]===`<`){let t=!1,n=e.slice(o).match(/^<\/(\d+|[a-zA-Z][a-zA-Z0-9_-]*)>/);if(n){let e=n[1];(/^\d+$/.test(e)||i.includes(e))&&(t=!0,a+=n[0],o+=n[0].length)}if(!t){let n=e.slice(o).match(/^<(\d+|[a-zA-Z][a-zA-Z0-9_-]*)(\s+[\w-]+(?:=(?:"[^"]*"|'[^']*'|[^\s>]+))?)*\s*(\/)?>/);if(n){let e=n[1];(/^\d+$/.test(e)||i.includes(e))&&(t=!0,a+=n[0],o+=n[0].length)}}t||(a+=`&lt;`,o+=1)}else a+=e[o],o+=1;return a},A=(e,t,n,r,i,o,s)=>{if(n===``)return[];let l=i.transKeepBasicHtmlNodesFor||[],f=n&&new RegExp(l.map(e=>`<${e}`).join(`|`)).test(n);if(!e&&!t&&!f&&!s)return[n];let m=t??{},h=e=>{T(e).forEach(e=>{a(e)||(S(e)?h(C(e)):d(e)&&!(0,p.isValidElement)(e)&&Object.assign(m,e))})};h(e);let g=k(n,l,m),_=x.parse(`<0>${g}</0>`),v={...m,...o},y=(e,t,n)=>{let r=C(e),i=D(r,t.children,n);return w(r)&&i.length===0||e.props?.i18nIsDynamicList?r:i},b=(e,t,n,r,i)=>{e.dummy?(e.children=t,n.push((0,p.cloneElement)(e,{key:r},i?void 0:t))):n.push(...p.Children.map([e],e=>{if(e.type===p.Fragment||e.props?.i18nIsDynamicList!==void 0){let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`children`||t===`i18nIsDynamicList`||(n[t]=e.props[t])}),(0,p.createElement)(e.type,n,i?null:t)}let n={key:r};return e&&e.props&&Object.keys(e.props).forEach(t=>{t===`ref`||t===`children`||(n[t]=e.props[t])}),(0,p.cloneElement)(e,n,i?null:t)}))},D=(e,n,o)=>{let m=T(e),h=T(n),g={};return h.reduce((e,n,h)=>{let _=n.children?.[0]?.content&&r.services.interpolator.interpolate(n.children[0].content,v,r.language);if(n.type===`tag`){let u=m[parseInt(n.name,10)];!u&&t&&(u=t[n.name]),o.length===1&&!u&&(u=o[0][n.name]),u||={};let x={...n.attrs};s&&Object.keys(x).forEach(e=>{let t=x[e];a(t)&&(x[e]=c(t))});let w=Object.keys(x).length===0?u:E({props:x},u),O=(0,p.isValidElement)(w),k=O&&S(n,!0)&&!n.voidElement,A=f&&d(w)&&w.dummy&&!O,j=d(t)&&Object.hasOwnProperty.call(t,n.name);if(a(w)){let t=r.services.interpolator.interpolate(w,v,r.language);e.push(t)}else if(S(w)||k){let t=y(w,n,o);b(w,t,e,h)}else if(A){let t=D(m,n.children,o);b(w,t,e,h)}else if(Number.isNaN(parseFloat(n.name)))if(j){let t=y(w,n,o);b(w,t,e,h,n.voidElement)}else if(i.transSupportBasicHtmlNodes&&l.indexOf(n.name)>-1)if(n.voidElement)e.push((0,p.createElement)(n.name,{key:`${n.name}-${h}`}));else{let t=g[n.name]||0;g[n.name]=t+1;let r,i=0;for(let e=0;e<m.length;e+=1){let a=m[e];if((0,p.isValidElement)(a)&&a.type===n.name){if(i===t){r=a;break}i+=1}}let a=r?T(C(r)):m,s=D(a,n.children,o);e.push((0,p.createElement)(n.name,{key:`${n.name}-${h}`},s))}else if(n.voidElement)e.push(`<${n.name} />`);else{let t=D(m,n.children,o);e.push(`<${n.name}>${t}</${n.name}>`)}else if(d(w)&&!O){let t=n.children[0]?_:null;t&&e.push(t)}else b(w,_,e,h,n.children.length!==1||!_)}else if(n.type===`text`){let t=i.transWrapTextNodes,a=typeof i.unescape==`function`?i.unescape:u().unescape,o=s?a(r.services.interpolator.interpolate(n.content,v,r.language)):r.services.interpolator.interpolate(n.content,v,r.language);t?e.push((0,p.createElement)(t,{key:`${n.name}-${h}`},o)):e.push(o)}return e},[])};return C(D([{dummy:!0,children:e||[]}],_,T(e||[]))[0])},j=(e,t,n)=>{let r=e.key||t,i=(0,p.cloneElement)(e,{key:r});if(!i.props||!i.props.children||n.indexOf(`${t}/>`)<0&&n.indexOf(`${t} />`)<0)return i;function a(){return(0,p.createElement)(p.Fragment,null,i)}return(0,p.createElement)(a,{key:r})},M=(e,t)=>e.map((e,n)=>j(e,n,t)),N=(e,t)=>{let n={};return Object.keys(e).forEach(r=>{Object.assign(n,{[r]:j(e[r],r,t)})}),n},P=(e,t,n,r)=>e?Array.isArray(e)?M(e,t):d(e)?N(e,t):(l(n,`TRANS_INVALID_COMPONENTS`,`<Trans /> "components" prop expects an object or array`,{i18nKey:r}),null):null,F=e=>!d(e)||Array.isArray(e)?!1:Object.keys(e).reduce((e,t)=>e&&Number.isNaN(Number.parseFloat(t)),!0);function I({children:e,count:t,parent:n,i18nKey:o,context:s,tOptions:c={},values:d,defaults:f,components:m,ns:h,i18n:g,t:_,shouldUnescape:v,...y}){let b=g||i();if(!b)return l(b,`NO_I18NEXT_INSTANCE`,`Trans: You need to pass in an i18next instance using i18nextReactModule`,{i18nKey:o}),e;let x=_||b.t.bind(b)||(e=>e),S={...u(),...b.options?.react},C=h||x.ns||b.options?.defaultNS;C=a(C)?[C]:C||[`translation`];let{transDefaultProps:w}=S,T=w?.tOptions?{...w.tOptions,...c}:c,E=v??w?.shouldUnescape,k=w?.values?{...w.values,...d}:d,j=w?.components?{...w.components,...m}:m,M=O(e,S,b,o),N=f||T?.defaultValue||M||S.transEmptyNodeValue||(typeof o==`function`?r(o):o),{hashTransKey:I}=S,L=o||(I?I(M||N):M||N);d=b.options?.interpolation?.defaultVariables?k&&Object.keys(k).length>0?{...k,...b.options.interpolation.defaultVariables}:{...b.options.interpolation.defaultVariables}:k;let R=D(e);R&&typeof R.count==`number`&&t===void 0&&(t=R.count);let z=d||t!==void 0&&!b.options?.interpolation?.alwaysFormat||!e?T.interpolation:{interpolation:{...T.interpolation,prefix:`#$?`,suffix:`?$#`}},B={...T,context:s||T.context,count:t,...d,...z,defaultValue:N,ns:C},V=L?x(L,B):N;V===L&&N&&(V=N);let H=P(j,V,b,o),U=H||e,W=null;F(H)&&(W=H,U=e);let G=A(U,W,V,b,S,B,E),K=n??S.defaultTransParent;return K?(0,p.createElement)(K,y,G):G}function L({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:o={},values:c,defaults:l,components:u,ns:d,i18n:f,t:m,shouldUnescape:h,...g}){let{i18n:_,defaultNS:v}=(0,p.useContext)(s)||{},y=f||_||i(),b=m||y?.t.bind(y);return I({children:e,count:t,parent:n,i18nKey:r,context:a,tOptions:o,values:c,defaults:l,components:u,ns:d||b?.ns||v||y?.options?.defaultNS,i18n:y,t:m,shouldUnescape:h,...g})}export{L as t};