frizz 0.12.8 → 0.12.10

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 (90) hide show
  1. package/dist/claude-agent-broker.js +7792 -7759
  2. package/dist/dev-child.js +26 -14
  3. package/package.json +1 -1
  4. package/web-dist/assets/{TerminalPane-CDk5zKv9.js → TerminalPane-BLyRh8S1.js} +1 -1
  5. package/web-dist/assets/{abnfDiagram-VRR7QNED-DmkK2qjk.js → abnfDiagram-VRR7QNED-B0n1m57h.js} +1 -1
  6. package/web-dist/assets/architecture-TIHT7OUA-BOgxi8qb.js +1 -0
  7. package/web-dist/assets/{architectureDiagram-ZJ3FMSHR-BFbA3OG6.js → architectureDiagram-ZJ3FMSHR-CW78Jo4Q.js} +1 -1
  8. package/web-dist/assets/{blockDiagram-677ZJIJ3-DTslTfq9.js → blockDiagram-677ZJIJ3-DasDnytT.js} +1 -1
  9. package/web-dist/assets/{c4Diagram-LMCZKHZV-Dmugni-f.js → c4Diagram-LMCZKHZV-B7cCJxqg.js} +1 -1
  10. package/web-dist/assets/channel-cwFXt8Vr.js +1 -0
  11. package/web-dist/assets/{chunk-32BRIVSS-DS7QIaUB.js → chunk-32BRIVSS-BBBSn1aq.js} +1 -1
  12. package/web-dist/assets/{chunk-52WLFC77-CnnFIjVe.js → chunk-52WLFC77-B5lATDKz.js} +1 -1
  13. package/web-dist/assets/{chunk-C7G6YPKG-BZxNdEVe.js → chunk-C7G6YPKG-B86e9JiF.js} +1 -1
  14. package/web-dist/assets/{chunk-EX3LRPZG-Zv7RLgbb.js → chunk-EX3LRPZG-CpKL4dGX.js} +1 -1
  15. package/web-dist/assets/{chunk-FWX5IMBZ-6-Zb5eo-.js → chunk-FWX5IMBZ-Dp3AvQlT.js} +2 -2
  16. package/web-dist/assets/{chunk-HOUHSVGY-J5Ui6IxH.js → chunk-HOUHSVGY-i9yVPrLo.js} +1 -1
  17. package/web-dist/assets/{chunk-ICXQ74PX-DH6GE_Om.js → chunk-ICXQ74PX--Y7uMkOf.js} +1 -1
  18. package/web-dist/assets/{chunk-MOJQB5TN-Bjd1ChDq.js → chunk-MOJQB5TN-DyMHpsmW.js} +1 -1
  19. package/web-dist/assets/{chunk-OGEWGWER-BNvzjYRM.js → chunk-OGEWGWER-1mtDKLBA.js} +1 -1
  20. package/web-dist/assets/{chunk-PUDLZKDR-CdtfylsO.js → chunk-PUDLZKDR-CFgSrqyc.js} +1 -1
  21. package/web-dist/assets/{chunk-Q4XR5HBZ-C7N3sKog.js → chunk-Q4XR5HBZ-BPhNENQ8.js} +1 -1
  22. package/web-dist/assets/{chunk-V7JOEXUC-vX-c4OzH.js → chunk-V7JOEXUC-CMrXD-em.js} +1 -1
  23. package/web-dist/assets/{chunk-VAUOI2AC-DtbheJmZ.js → chunk-VAUOI2AC-B6lbggln.js} +1 -1
  24. package/web-dist/assets/{chunk-VR4S4FIN-BpE1AOJR.js → chunk-VR4S4FIN-B9qypAjb.js} +1 -1
  25. package/web-dist/assets/{chunk-WYO6CB5R-BupZRR1a.js → chunk-WYO6CB5R-CI9tkIhS.js} +1 -1
  26. package/web-dist/assets/{chunk-ZGVPDNZ5-XoWDM-02.js → chunk-ZGVPDNZ5-DFJPi6M6.js} +1 -1
  27. package/web-dist/assets/classDiagram-OUVF2IWQ-BLP_ClYo.js +1 -0
  28. package/web-dist/assets/classDiagram-v2-EOCWNBFH-BLP_ClYo.js +1 -0
  29. package/web-dist/assets/{cynefin-VYW2F7L2-DOIzVENe.js → cynefin-VYW2F7L2-g28vb2Hf.js} +1 -1
  30. package/web-dist/assets/{cynefinDiagram-TSTJHNR4-DGq-kl_q.js → cynefinDiagram-TSTJHNR4-bBtOt0pp.js} +1 -1
  31. package/web-dist/assets/{dagre-VKFMJZFB-Brs6wxcd.js → dagre-VKFMJZFB-DuIcY2-t.js} +1 -1
  32. package/web-dist/assets/{diagram-FQU43EPY-BrQd5FEw.js → diagram-FQU43EPY-CsYoD3ve.js} +1 -1
  33. package/web-dist/assets/{diagram-G47NLZAW-B-DN7aQk.js → diagram-G47NLZAW-H3NxrIKS.js} +1 -1
  34. package/web-dist/assets/{diagram-NH7WQ7WH-DB-NFs3X.js → diagram-NH7WQ7WH-DIojGMfZ.js} +1 -1
  35. package/web-dist/assets/{diagram-OA4YK3LP-DsrBhvMB.js → diagram-OA4YK3LP-D0L444Xe.js} +1 -1
  36. package/web-dist/assets/{diagram-WEI45ONY-DYctq6PN.js → diagram-WEI45ONY-C3PEfMxp.js} +1 -1
  37. package/web-dist/assets/{ebnfDiagram-CCIWWBDH-C6ghRrJP.js → ebnfDiagram-CCIWWBDH-Dknugppg.js} +1 -1
  38. package/web-dist/assets/{erDiagram-Q63AITRT-C_iK-Ja6.js → erDiagram-Q63AITRT-Ds5u_SEw.js} +1 -1
  39. package/web-dist/assets/eventmodeling-45OFAUF4-DgF-cIkx.js +1 -0
  40. package/web-dist/assets/flowDiagram-23GEKE2U-CB3C8FCr.js +1 -0
  41. package/web-dist/assets/{ganttDiagram-NO4QXBWP-Y9GZAgbA.js → ganttDiagram-NO4QXBWP-KFFdgLKc.js} +1 -1
  42. package/web-dist/assets/{gitGraph-TEB2WS4Q-BgqW4vt7.js → gitGraph-TEB2WS4Q-B62DXBoO.js} +1 -1
  43. package/web-dist/assets/{gitGraphDiagram-IHSO6WYX-eImStPZ8.js → gitGraphDiagram-IHSO6WYX-BPtTY3Ld.js} +1 -1
  44. package/web-dist/assets/{index-BOACK0Xu.js → index-B-zUKqGI.js} +7 -7
  45. package/web-dist/assets/{info-DKCQHKI2-BtbNWkY3.js → info-DKCQHKI2-Ct-TkGHr.js} +1 -1
  46. package/web-dist/assets/{infoDiagram-FWYZ7A6U-DMIPEeRd.js → infoDiagram-FWYZ7A6U-j0jFbDdJ.js} +1 -1
  47. package/web-dist/assets/{ishikawaDiagram-FXEZZL3T-08_raW8G.js → ishikawaDiagram-FXEZZL3T-DgfNQn9k.js} +1 -1
  48. package/web-dist/assets/{journeyDiagram-5HDEW3XC-hPkkufFj.js → journeyDiagram-5HDEW3XC-BfykOv3I.js} +1 -1
  49. package/web-dist/assets/{kanban-definition-HUTT4EX6-CDBcUNEE.js → kanban-definition-HUTT4EX6-BvhHHrMj.js} +1 -1
  50. package/web-dist/assets/{line-Njg200Gq.js → line-DZ-APW6S.js} +1 -1
  51. package/web-dist/assets/{mermaid-parser.core-1A-yH2Ql.js → mermaid-parser.core-BWisef3-.js} +3 -3
  52. package/web-dist/assets/{mermaid.core-D5Mvu4fo.js → mermaid.core-DnlDGPhM.js} +3 -3
  53. package/web-dist/assets/{mindmap-definition-LN4V7U3C-r-0LqhPG.js → mindmap-definition-LN4V7U3C-BoTGWSEy.js} +1 -1
  54. package/web-dist/assets/{packet-7NZHBO7P-Dj8tWs_Q.js → packet-7NZHBO7P-DaifVkPE.js} +1 -1
  55. package/web-dist/assets/{pegDiagram-2B236MQR-BHoUQUjJ.js → pegDiagram-2B236MQR-DpLfBJwm.js} +1 -1
  56. package/web-dist/assets/{pie-RZYD4A2V-GZmPkAjn.js → pie-RZYD4A2V-BvB0Jxcm.js} +1 -1
  57. package/web-dist/assets/{pieDiagram-ENE6RG2P-CL0ZHN1y.js → pieDiagram-ENE6RG2P-CSdBcMSK.js} +1 -1
  58. package/web-dist/assets/{quadrantDiagram-ABIIQ3AL-vZJzUcfC.js → quadrantDiagram-ABIIQ3AL-i7k-hoMS.js} +1 -1
  59. package/web-dist/assets/{radar-I7S5WNFK-D3x_tyhl.js → radar-I7S5WNFK-DpnvOCzG.js} +1 -1
  60. package/web-dist/assets/{railroad-3IZDKUUU-HVHtGCKZ.js → railroad-3IZDKUUU-Bj4Lhzob.js} +1 -1
  61. package/web-dist/assets/railroad-abnf-AHOZXSZD-scsBBZv_.js +1 -0
  62. package/web-dist/assets/railroad-ebnf-EBAXGLYW-z2-UIe31.js +1 -0
  63. package/web-dist/assets/railroad-peg-LSFZ7HO6-Dm1rBPEF.js +1 -0
  64. package/web-dist/assets/{railroadDiagram-RFXS5EU6-Dfw0JONh.js → railroadDiagram-RFXS5EU6-3HJeC9YI.js} +1 -1
  65. package/web-dist/assets/{requirementDiagram-TGXJPOKE-DLM4etHl.js → requirementDiagram-TGXJPOKE-CeBCsZVw.js} +1 -1
  66. package/web-dist/assets/{sankeyDiagram-HTMAVEWB-2nsrE-nL.js → sankeyDiagram-HTMAVEWB-BPhonqDa.js} +1 -1
  67. package/web-dist/assets/{sequenceDiagram-DBY2YBRQ-VkpQVaPX.js → sequenceDiagram-DBY2YBRQ-C5nocNwQ.js} +1 -1
  68. package/web-dist/assets/{stateDiagram-2N3HPSRC-xvBH0825.js → stateDiagram-2N3HPSRC-CzAZsCPb.js} +1 -1
  69. package/web-dist/assets/stateDiagram-v2-6OUMAXLB-DEGF_nZS.js +1 -0
  70. package/web-dist/assets/{swimlanes-5IMT3BWC-DA8H4qPO.js → swimlanes-5IMT3BWC-DRn8Vs4e.js} +1 -1
  71. package/web-dist/assets/swimlanesDiagram-G3AALYLV-CBLKdauI.js +8 -0
  72. package/web-dist/assets/{timeline-definition-FHXFAJF6-npL1KNyH.js → timeline-definition-FHXFAJF6-Bc99eShR.js} +1 -1
  73. package/web-dist/assets/{treeView-QDETBFTQ-Cea7MDUV.js → treeView-QDETBFTQ--Hn_52w1.js} +1 -1
  74. package/web-dist/assets/{treemap-6X3UGDF4-CGHINewA.js → treemap-6X3UGDF4-BCI_8eXP.js} +1 -1
  75. package/web-dist/assets/{vennDiagram-L72KCM5P-D-RIigY2.js → vennDiagram-L72KCM5P-BR-5GJF6.js} +1 -1
  76. package/web-dist/assets/{wardley-OPB4EBWU-BXdXDctR.js → wardley-OPB4EBWU-4HuUekM-.js} +1 -1
  77. package/web-dist/assets/{wardleyDiagram-EHGQE667-tLo8yxD2.js → wardleyDiagram-EHGQE667-BI9w8zpX.js} +1 -1
  78. package/web-dist/assets/{xychartDiagram-FW5EYKEG-I4H6c-9Q.js → xychartDiagram-FW5EYKEG-BZ72575j.js} +1 -1
  79. package/web-dist/index.html +1 -1
  80. package/web-dist/assets/architecture-TIHT7OUA-c0q2ebfx.js +0 -1
  81. package/web-dist/assets/channel-CZ15urUA.js +0 -1
  82. package/web-dist/assets/classDiagram-OUVF2IWQ-DFxJiEZ1.js +0 -1
  83. package/web-dist/assets/classDiagram-v2-EOCWNBFH-DFxJiEZ1.js +0 -1
  84. package/web-dist/assets/eventmodeling-45OFAUF4-BdXQ9Pv4.js +0 -1
  85. package/web-dist/assets/flowDiagram-23GEKE2U-rTXtf38R.js +0 -1
  86. package/web-dist/assets/railroad-abnf-AHOZXSZD-BD2umz4T.js +0 -1
  87. package/web-dist/assets/railroad-ebnf-EBAXGLYW-C1IGySZs.js +0 -1
  88. package/web-dist/assets/railroad-peg-LSFZ7HO6-BVCH7yeK.js +0 -1
  89. package/web-dist/assets/stateDiagram-v2-6OUMAXLB-B3bLucl6.js +0 -1
  90. package/web-dist/assets/swimlanesDiagram-G3AALYLV-cYXAfa4Q.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPane-CDk5zKv9.js","assets/rolldown-runtime-Bh1tDfsg.js","assets/mermaid.core-D5Mvu4fo.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-C4XfhTaE.js","assets/chunk-WYO6CB5R-BupZRR1a.js","assets/chunk-ICXQ74PX-DH6GE_Om.js","assets/dist-DoH_9pyS.js","assets/chunk-VAUOI2AC-DtbheJmZ.js","assets/chunk-HOUHSVGY-J5Ui6IxH.js","assets/chunk-Q4XR5HBZ-C7N3sKog.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-BNvzjYRM.js","assets/chunk-C7G6YPKG-BZxNdEVe.js","assets/chunk-ZGVPDNZ5-XoWDM-02.js","assets/rough.esm-CSKSodPl.js","assets/chunk-52WLFC77-CnnFIjVe.js","assets/line-Njg200Gq.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-FWX5IMBZ-6-Zb5eo-.js","assets/chunk-ZIRB5QZD-C6fEPe3t.js"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPane-BLyRh8S1.js","assets/rolldown-runtime-Bh1tDfsg.js","assets/mermaid.core-DnlDGPhM.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-C4XfhTaE.js","assets/chunk-WYO6CB5R-CI9tkIhS.js","assets/chunk-ICXQ74PX--Y7uMkOf.js","assets/dist-DoH_9pyS.js","assets/chunk-VAUOI2AC-B6lbggln.js","assets/chunk-HOUHSVGY-i9yVPrLo.js","assets/chunk-Q4XR5HBZ-BPhNENQ8.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-1mtDKLBA.js","assets/chunk-C7G6YPKG-B86e9JiF.js","assets/chunk-ZGVPDNZ5-DFJPi6M6.js","assets/rough.esm-CSKSodPl.js","assets/chunk-52WLFC77-B5lATDKz.js","assets/line-DZ-APW6S.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-FWX5IMBZ-Dp3AvQlT.js","assets/chunk-ZIRB5QZD-C6fEPe3t.js"])))=>i.map(i=>d[i]);
2
2
  import{n as e,t}from"./rolldown-runtime-Bh1tDfsg.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),r=t(((e,t)=>{t.exports=n()})),i=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ee(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var F=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},te={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=te,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ee}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,F)}catch(e){F(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.7`})),a=t(((e,t)=>{t.exports=i()})),o=t((e=>{var t=a();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return s(e,t,null,r)},e.flushSync=function(e){var t=c.T,n=i.p;try{if(c.T=null,i.p=2,e)return e()}finally{c.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.7`})),s=t(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=o()})),c=t((e=>{var t=r(),n=a(),i=s();function o(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(l(e)!==e)throw Error(o(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return f(i),e;if(a===r)return f(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,c=i.child;c;){if(c===n){s=!0,n=i,r=a;break}if(c===r){s=!0,r=i,n=a;break}c=c.sibling}if(!s){for(c=a.child;c;){if(c===n){s=!0,n=a,r=i;break}if(c===r){s=!0,r=a,n=i;break}c=c.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var N=Symbol.for(`react.client.reference`);function P(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===N?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?P(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return P(e(t))}catch{}}return null}var ee=Array.isArray,F=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne={pending:!1,data:null,method:null,action:null},re=[],ie=-1;function ae(e){return{current:e}}function oe(e){0>ie||(e.current=re[ie],re[ie]=null,ie--)}function se(e,t){ie++,re[ie]=e.current,e.current=t}var ce=ae(null),le=ae(null),ue=ae(null),de=ae(null);function fe(e,t){switch(se(ue,t),se(le,e),se(ce,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Kd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Kd(t),e=qd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}oe(ce),se(ce,e)}function pe(){oe(ce),oe(le),oe(ue)}function me(e){e.memoizedState!==null&&se(de,e);var t=ce.current,n=qd(t,e.type);t!==n&&(se(le,e),se(ce,n))}function he(e){le.current===e&&(oe(ce),oe(le)),de.current===e&&(oe(de),ep._currentValue=ne)}var ge,_e;function ve(e){if(ge===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ge=t&&t[1]||``,_e=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+ge+e+_e}var ye=!1;function be(e,t){if(!e||ye)return``;ye=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -118,9 +118,9 @@ $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\
118
118
  `)&&!e.includes(`\r`),`must be a single line`).refine(e=>Fs(e)<=t,`must be at most ${t} UTF-8 bytes`)}var Rs=Is(256,512),zs=ks,Bs=W().int().nonnegative().max(2**53-1),Vs=U().datetime({offset:!0}).transform(e=>new Date(e).toISOString()),Hs=Is(160,512),Us=Is(4e3,8e3,!0),Ws=Is(16e3,24e3,!0).refine(e=>e.split(/\r?\n/u).length<=256,`must be at most 256 lines`),Gs=U().min(1).max(128).regex(/^[A-Za-z_][A-Za-z0-9_.:-]*$/).refine(e=>![`__proto__`,`constructor`,`prototype`].includes(e),`reserved field id`),Ks=U().min(1).max(80).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/),qs=q({kind:J([`claude`,`codex`,`frizz`]),name:Hs.optional(),version:Rs.optional()}).strict(),Js=q({kind:J([`runtime`,`agent`,`tool`,`mcp-server`,`frizz`]),id:Rs,label:Hs.optional()}).strict(),Ys=q({projectId:Rs,threadSlug:zs,sessionId:Rs,turnId:Rs,itemId:Rs,sessionEpoch:Bs,capabilityRevision:Bs}).strict(),Xs=q({id:Ks,semantic:J([`approve`,`deny`,`cancel`,`accept`,`decline`,`answer`]),label:Hs,description:Us.optional()}).strict(),Zs=W().finite().min(-0x38d7ea4c68000).max(Ns),Qs=ws([Ls(4e3,8e3,!0),Zs,G()]),$s=ws([Qs,K(Ls(1e3,2e3,!0)).max(32)]),ec={id:Gs,label:Hs,description:Us.optional(),required:G(),secret:G().default(!1)},tc=q({value:Qs,label:Hs}).strict(),nc=q({value:Ls(1e3,2e3,!0),label:Hs}).strict(),rc=Ts(`input`,[q({...ec,input:J([`text`,`multiline`]),minLength:W().int().nonnegative().max(4e3).optional(),maxLength:W().int().nonnegative().max(4e3).optional(),format:J([`email`,`uri`,`date`,`date-time`]).optional(),default:Ls(4e3,8e3,!0).optional()}).strict(),q({...ec,input:J([`number`,`integer`]),minimum:Zs.optional(),maximum:Zs.optional(),default:Zs.optional()}).strict(),q({...ec,input:Os(`boolean`),default:G().optional()}).strict(),q({...ec,input:Os(`select`),options:K(tc).min(1).max(64),default:Qs.optional()}).strict(),q({...ec,input:Os(`multi-select`),options:K(nc).min(1).max(64),minItems:W().int().nonnegative().max(32).optional(),maxItems:W().int().nonnegative().max(32).optional(),default:K(Ls(1e3,2e3,!0)).max(32).optional()}).strict()]);function ic(e){if(!/^\d{4}-\d{2}-\d{2}$/.test(e))return!1;let t=new Date(`${e}T00:00:00Z`);return Number.isFinite(t.getTime())&&t.toISOString().slice(0,10)===e}function ac(e,t){if(e.input===`text`||e.input===`multiline`){if(typeof t!=`string`)return`must be text`;if(e.input===`text`&&(t.includes(`
119
119
  `)||t.includes(`\r`)))return`must be a single line`;if(e.minLength!==void 0&&t.length<e.minLength)return`is shorter than minLength`;if(e.maxLength!==void 0&&t.length>e.maxLength)return`is longer than maxLength`;if(e.format===`email`&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(t))return`must be an email address`;if(e.format===`uri`)try{new URL(t)}catch{return`must be a URL`}return e.format===`date`&&!ic(t)?`must be a date`:e.format===`date-time`&&!Vs.safeParse(t).success?`must be a date-time`:void 0}return e.input===`number`||e.input===`integer`?typeof t!=`number`||!Number.isFinite(t)?`must be a number`:e.input===`integer`&&!Number.isInteger(t)?`must be an integer`:e.minimum!==void 0&&t<e.minimum?`is below minimum`:e.maximum!==void 0&&t>e.maximum?`is above maximum`:void 0:e.input===`boolean`?typeof t==`boolean`?void 0:`must be a boolean`:e.input===`select`?Array.isArray(t)?`must be one option`:e.options.some(e=>JSON.stringify(e.value)===JSON.stringify(t))?void 0:`is not an advertised option`:e.input===`multi-select`?Array.isArray(t)?new Set(t).size===t.length?e.minItems!==void 0&&t.length<e.minItems?`contains fewer than minItems`:e.maxItems!==void 0&&t.length>e.maxItems?`contains more than maxItems`:t.every(t=>e.options.some(e=>e.value===t))?void 0:`contains an unadvertised option`:`contains duplicate options`:`must be a list of options`:`has an unsupported input type`}var oc=rc.superRefine((e,t)=>{if(e.secret&&e.default!==void 0&&t.addIssue({code:z.custom,message:`secret fields cannot advertise defaults`,path:[`default`]}),(e.input===`text`||e.input===`multiline`)&&e.minLength!==void 0&&e.maxLength!==void 0&&e.minLength>e.maxLength&&t.addIssue({code:z.custom,message:`minLength exceeds maxLength`}),(e.input===`number`||e.input===`integer`)&&e.minimum!==void 0&&e.maximum!==void 0&&e.minimum>e.maximum&&t.addIssue({code:z.custom,message:`minimum exceeds maximum`}),e.input===`select`||e.input===`multi-select`){let n=new Set;for(let[r,i]of e.options.entries()){let e=JSON.stringify(i.value);n.has(e)&&t.addIssue({code:z.custom,message:`duplicate option value`,path:[`options`,r,`value`]}),n.add(e)}e.input===`multi-select`&&e.minItems!==void 0&&e.maxItems!==void 0&&e.minItems>e.maxItems&&t.addIssue({code:z.custom,message:`minItems exceeds maxItems`})}if(e.default!==void 0){let n=ac(e,e.default);n&&t.addIssue({code:z.custom,message:`invalid default: ${n}`,path:[`default`]})}}),sc={title:Hs,message:Us.optional()},cc=q({kind:J([`read`,`list-files`,`search`,`unknown`]),commandPreview:Ws,resourceLabel:Is(2048,4096).optional(),queryLabel:Is(1024,2048).optional()}).strict(),lc=Is(2048,4096),uc=Ts(`kind`,[q({kind:Os(`network`),enabled:G().nullable(),hosts:K(lc).max(24)}).strict(),q({kind:Os(`filesystem`),access:J([`read`,`write`,`deny`]),resources:K(lc).min(1).max(32)}).strict(),q({kind:Os(`glob-scan`),depth:W().int().nonnegative().max(256)}).strict(),q({kind:Os(`exec-policy`),prefixes:K(lc).min(1).max(32)}).strict(),q({kind:Os(`network-policy`),access:J([`allow`,`deny`]),hosts:K(lc).min(1).max(24)}).strict()]),dc=q({operation:J([`create`,`write`,`move`,`delete`]),pathLabel:Is(2048,4096),destinationLabel:Is(2048,4096).optional(),diffPreview:Ws.optional()}).strict(),fc=Ts(`kind`,[q({...sc,kind:Os(`command-approval`),command:q({summary:Hs,preview:Ws,redacted:Os(!0),workingDirectoryLabel:Is(1024,2048).optional(),actions:K(cc).max(16).optional()}).strict(),capabilities:K(uc).max(32).optional()}).strict(),q({...sc,kind:Os(`file-approval`),operation:J([`read`,`create`,`write`,`move`,`delete`,`execute`,`other`]),pathLabel:Is(1024,2048),destinationLabel:Is(1024,2048).optional(),grantRootLabel:Is(2048,4096).optional(),scopeLabel:Us.optional(),diffPreview:Ws.optional(),changes:K(dc).min(1).max(16).optional()}).strict(),q({...sc,kind:Os(`permission-approval`),permission:Rs,preview:Ws.optional(),promptLabel:Is(256,512).optional(),resourceLabel:Is(1024,2048).optional(),workingDirectoryLabel:Is(1024,2048).optional(),scopeLabel:Us.optional(),capabilities:K(uc).min(1).max(32).optional()}).strict(),q({kind:Os(`mcp-elicitation-form`),title:Hs,message:Us,protocolVersion:Rs,fields:K(oc).max(32)}).strict(),q({kind:Os(`mcp-elicitation-url`),title:Hs,message:Us,protocolVersion:Rs,elicitationId:Rs,url:U().min(1).max(2048).url().superRefine((e,t)=>{let n;try{n=new URL(e)}catch{return}let r=n.protocol===`http:`&&[`localhost`,`127.0.0.1`,`::1`,`[::1]`].includes(n.hostname);n.protocol!==`https:`&&!r&&t.addIssue({code:z.custom,message:`URL elicitation requires HTTPS (except localhost development)`}),(n.username||n.password)&&t.addIssue({code:z.custom,message:`URL elicitation must not contain userinfo credentials`})})}).strict(),q({kind:Os(`agent-question`),title:Hs,message:Us.optional(),fields:K(oc).min(1).max(32)}).strict()]),pc=q({protocolVersion:Os(1),contentFormat:Os(`plain-text`),provider:qs,source:Js,owner:Ys,providerRequestId:Rs,allowedDecisions:K(Xs).min(1).max(8),payload:fc,expiresAt:Vs.nullable()}).strict(),mc={"command-approval":new Set([`approve`,`deny`,`cancel`]),"file-approval":new Set([`approve`,`deny`,`cancel`]),"permission-approval":new Set([`approve`,`deny`,`cancel`]),"mcp-elicitation-form":new Set([`accept`,`decline`,`cancel`]),"mcp-elicitation-url":new Set([`accept`,`decline`,`cancel`]),"agent-question":new Set([`answer`,`decline`,`cancel`])};function hc(e,t){let n=mc[e.payload.kind],r=new Set;for(let[i,a]of e.allowedDecisions.entries())r.has(a.id)&&t.addIssue({code:z.custom,message:`duplicate decision id`,path:[`allowedDecisions`,i,`id`]}),r.add(a.id),n.has(a.semantic)||t.addIssue({code:z.custom,message:`decision is invalid for ${e.payload.kind}`,path:[`allowedDecisions`,i,`semantic`]});let i=e.payload.kind===`mcp-elicitation-form`||e.payload.kind===`agent-question`?e.payload.fields:[],a=new Set;for(let[n,r]of i.entries())a.has(r.id)&&t.addIssue({code:z.custom,message:`duplicate field id`,path:[`payload`,`fields`,n,`id`]}),a.add(r.id),e.payload.kind===`mcp-elicitation-form`&&r.secret&&t.addIssue({code:z.custom,message:`MCP form elicitation cannot request secret fields; use URL mode`,path:[`payload`,`fields`,n,`secret`]});Fs({protocolVersion:e.protocolVersion,contentFormat:e.contentFormat,provider:e.provider,source:e.source,owner:e.owner,providerRequestId:e.providerRequestId,allowedDecisions:e.allowedDecisions,payload:e.payload,expiresAt:e.expiresAt})>65536&&t.addIssue({code:z.custom,message:`interaction request exceeds ${As} bytes`})}pc.superRefine(hc);var gc=J([`pending`,`resolved`,`cancelled`,`expired`]),_c=q({effect:J([`awaiting-user`,`sending`,`reconnect-required`])}).strict(),vc=J([`user-cancelled`,`provider-cancelled`,`turn-ended`,`session-replaced`,`session-deleted`,`capabilities-changed`,`expired`]),yc=Es(Gs,$s).superRefine((e,t)=>{Object.keys(e).length>32&&t.addIssue({code:z.custom,message:`too many response fields`}),Fs(e)>24576&&t.addIssue({code:z.custom,message:`interaction response exceeds ${js} bytes`})}),bc=q({responseId:Rs,decisionId:Ks,values:yc.optional(),redactedFieldIds:K(Gs).max(32),resolvedAt:Vs}).strict(),xc=pc.extend({id:Rs,lifecycle:gc,delivery:_c.optional(),recordRevision:Bs,createdAt:Vs,updatedAt:Vs,completedAt:Vs.nullable(),resolution:bc.nullable(),cancellationReason:vc.nullable()}).strict().superRefine((e,t)=>{if(hc(e,t),e.delivery&&e.lifecycle!==`pending`&&t.addIssue({code:z.custom,message:`terminal interaction cannot advertise a delivery effect`}),e.lifecycle===`pending`?((e.completedAt||e.resolution||e.cancellationReason)&&t.addIssue({code:z.custom,message:`pending interaction has terminal data`}),(e.recordRevision!==0||e.updatedAt!==e.createdAt)&&t.addIssue({code:z.custom,message:`pending interaction has invalid revision or timestamps`})):e.completedAt?(e.recordRevision<1||e.updatedAt!==e.completedAt||e.updatedAt<e.createdAt)&&t.addIssue({code:z.custom,message:`terminal interaction has invalid revision or timestamps`}):t.addIssue({code:z.custom,message:`terminal interaction is missing completedAt`}),e.lifecycle===`resolved`?(!e.resolution||e.cancellationReason)&&t.addIssue({code:z.custom,message:`resolved interaction has invalid terminal data`}):e.resolution&&t.addIssue({code:z.custom,message:`non-resolved interaction contains a resolution`}),e.lifecycle===`cancelled`&&(!e.cancellationReason||e.cancellationReason===`expired`)&&t.addIssue({code:z.custom,message:`cancelled interaction has invalid reason`}),e.lifecycle===`expired`&&e.cancellationReason!==`expired`&&t.addIssue({code:z.custom,message:`expired interaction has invalid reason`}),e.resolution){e.resolution.resolvedAt!==e.completedAt&&t.addIssue({code:z.custom,message:`resolution timestamp does not match its terminal record`});let n=e.allowedDecisions.find(t=>t.id===e.resolution.decisionId);n||t.addIssue({code:z.custom,message:`resolution names an unadvertised decision`,path:[`resolution`,`decisionId`]});let r=e.payload.kind===`mcp-elicitation-form`||e.payload.kind===`agent-question`?e.payload.fields:[],i=new Map(r.map(e=>[e.id,e])),a=new Set(e.resolution.redactedFieldIds);a.size!==e.resolution.redactedFieldIds.length&&t.addIssue({code:z.custom,message:`resolution contains duplicate redaction markers`,path:[`resolution`,`redactedFieldIds`]});for(let n of e.resolution.redactedFieldIds)i.get(n)?.secret||t.addIssue({code:z.custom,message:`redaction marker does not name a secret field`,path:[`resolution`,`redactedFieldIds`]});for(let[n,r]of Object.entries(e.resolution.values??{})){let e=i.get(n);e?e.secret?t.addIssue({code:z.custom,message:`secret value persisted in resolution`,path:[`resolution`,`values`,n]}):ac(e,r)&&t.addIssue({code:z.custom,message:`persisted response failed advertised validation`,path:[`resolution`,`values`,n]}):t.addIssue({code:z.custom,message:`resolution contains an unadvertised field`,path:[`resolution`,`values`,n]})}if(n)if(!(e.payload.kind===`mcp-elicitation-form`&&n.semantic===`accept`||e.payload.kind===`agent-question`&&n.semantic===`answer`))(e.resolution.values!==void 0||e.resolution.redactedFieldIds.length>0)&&t.addIssue({code:z.custom,message:`resolution decision cannot contain response fields`,path:[`resolution`]});else for(let n of r){let r=n.secret?a.has(n.id):Object.prototype.hasOwnProperty.call(e.resolution.values??{},n.id);n.required&&!r&&t.addIssue({code:z.custom,message:`resolution is missing a required field`,path:[`resolution`,`values`,n.id]})}}}),Sc=q({slug:zs,sessionId:Rs}).strict();q({interactions:K(xc).max(128)}).strict();var Cc=Sc.extend({interactionId:Rs}).strict();q({interaction:xc}).strict(),Cc.extend({sessionEpoch:Bs,capabilityRevision:Bs,expectedRecordRevision:Bs,responseId:Rs,decisionId:Ks,values:yc.optional()}).strict(),q({effect:J([`resolved`,`already-resolved`,`queued`,`already-queued`]),interaction:xc}).strict(),Cc.extend({sessionEpoch:Bs,capabilityRevision:Bs,expectedRecordRevision:Bs}).strict(),q({effect:J([`cancelled`,`already-cancelled`]),interaction:xc}).strict();var wc=/^ {0,3}(`{3,}|~{3,})(.*)$/;function Tc(e){let t=[],n=0,r=null;for(let i of e.split(`
120
120
  `)){let a=n+i.length+1,o=i.replace(/\r$/,``).match(wc);r?o&&o[1][0]===r.char&&o[1].length>=r.len&&o[2].trim()===``&&(t.push([r.from,n]),r=null):o&&!(o[1][0]==="`"&&o[2].includes("`"))&&(r={char:o[1][0],len:o[1].length,from:Math.min(a,e.length)}),n=a}return r&&t.push([r.from,e.length]),t}function Ec(e){let t=Tc(e);return t.length===0?()=>!1:e=>t.some(([t,n])=>e>=t&&e<n)}function Dc(e,t){if(t.upserts.length){let n=new Map;e.threads.forEach((e,t)=>n.set(e.id,t));for(let r of t.upserts){let t=n.get(r.id);t===void 0?e.threads.push(r):e.threads[t]=r}}if(t.removed.length){let n=new Set(t.removed);for(let t=e.threads.length-1;t>=0;t--)n.has(e.threads[t].id)&&e.threads.splice(t,1)}t.meta&&(e.projectDir=t.meta.projectDir,e.projectName=t.meta.projectName,e.projectLabel=t.meta.projectLabel,e.errors=t.meta.errors,e.warnings=t.meta.warnings,e.errorItems=t.meta.errorItems)}function Oc(e,t){return e<0?`resync`:t<=e?`ignore`:t===e+1?`apply`:`resync`}function kc(e,t){return t?e===null?`record`:e===t?`noop`:`adopt`:`noop`}var Ac=e=>JSON.stringify(e);Ac({t:`ping`,id:`keepalive`}),Ac({t:`pong`,id:`keepalive`});var jc=[`png`,`jpg`,`jpeg`,`gif`,`webp`],Mc=`pdf.svg.txt.text.log.md.markdown.csv.tsv.json.jsonl.ndjson.yaml.yml.toml.ini.xml.html.htm.css.scss.sql.sh.bash.zsh.js.mjs.cjs.jsx.ts.tsx.py.rb.go.rs.java.kt.c.h.cpp.cc.hpp.cs.php.swift.lua.r`.split(`.`),Nc=[`xlsx`,`xlsm`,`xls`,`docx`,`doc`,`pptx`,`ppt`,`odt`,`ods`,`odp`,`rtf`,`epub`],Pc=[`parquet`,`avro`,`orc`,`arrow`,`feather`,`ipynb`,`db`,`sqlite`,`sqlite3`],Fc=[`zip`,`tar`,`gz`,`tgz`,`bz2`,`xz`,`zst`,`7z`],Ic=[...Mc,...Nc,...Pc,...Fc],Lc=[...jc,...Ic],Rc=625e4*3,zc=new Set(Lc);function Bc(e){let t=/\.([a-zA-Z0-9]+)$/.exec(e.trim());return t?t[1].toLowerCase():``}function Vc(e){return zc.has(Bc(e))}var Hc=Lc.map(e=>`.${e}`).join(`,`),Uc=J([`planning`,`planned`,`active`,`needs-human`,`blocked`,`done`,`dismissed`]),Wc=J([`human`,`threads`,`timer`]),Gc=J([`none`,`spawning`,`running`,`perm-prompt`,`turn-idle`,`exited`]),Kc=J([`claude`,`codex`]);q({slug:U(),displayName:U(),defaultEffort:U(),efforts:K(U())});var qc=q({model:U().min(1),label:U().min(1),defaultEffort:U().min(1),efforts:K(U().min(1)).min(1)}),Jc=q({id:U(),label:U().optional(),state:U().optional()}),Yc=q({label:U(),startedAt:U(),state:J([`running`,`stale`,`rested`]),subagentType:U().optional(),id:U().optional(),taskId:U().optional(),stoppable:G().optional(),lastActivityAt:U().optional(),activity:U().optional(),activityDetail:U().optional(),summary:U().optional(),toolUses:W().optional(),tokens:W().optional(),durationMs:W().optional(),depth:W().optional(),parentId:U().optional()});function Xc(e){return(e.depth??1)===1}var Zc=q({label:U(),startedAt:U(),state:J([`running`,`stale`]),id:U().optional(),stoppable:G().optional(),outputUnavailable:G().optional(),command:U().optional(),lastActivityAt:U().optional(),taskId:U().optional()}),Qc=q({label:U(),state:J([`running`,`stale`])});q({turnInFlight:G().default(!1),unobservable:G().default(!1),subAgents:K(Qc).default([]),subAgentCount:W().default(0),bgShells:K(Qc).default([]),bgShellCount:W().default(0),cutOff:G().optional()});var $c=q({label:U(),description:U().optional()}),el=q({question:U(),header:U().optional(),multiSelect:G().optional(),options:K($c)}),tl=q({questions:K(el)}),nl=q({kind:J([`shell`,`agent`,`timer`,`pr`,`for`,`title`]),value:U()}),rl=[`watch`,`pr-watch`,`human`,`ci`,`session`,`shell`,`agent`,`timer`,`pr`,`reason`];RegExp(`^\\s*(${rl.join(`|`)}):\\s*\\S`,`im`);var il=/^([a-z][a-z-]*):\s*(\S.*)?$/i,al=new Set([`shells`,`agents`,`timers`,`prs`,`for`,`title`]),ol={shells:`shell`,agents:`agent`,timers:`timer`,prs:`pr`};function sl(e){let t=e.replace(/\s+/g,` `).trim();if(t.length<=40)return t;let n=t.slice(0,40),r=n.lastIndexOf(` `);return`${(r>40/2?n.slice(0,r):n).replace(/[.,;:–—-]$/,``).trimEnd()}…`}function cl(e){let t=e.split(`
121
- `).map(e=>e.replace(/\r$/,``)),n=t.findIndex(e=>/^\s*---+\s*$/.test(e)),r=n===-1?t:t.slice(0,n),i=n===-1?[]:t.slice(n+1),a=[],o=[],s=!0;for(let e of r){let t=e.match(il),n=t?.[1].toLowerCase();t&&n?s=al.has(n):e.trim()!==``&&!/^\s/.test(e)&&!/^\s*-\s/.test(e)&&(s=!1),(s?o:a).push(e)}let c=ll(o.join(`
122
- `));return c.ok||a.push(...o),a.push(...i),{body:a.join(`
123
- `).trim(),hints:c.hints.slice(0,8)}}function ll(e){if(!e.trim())return{ok:!0,hints:[]};let t;try{t=Ga(e)}catch{return{ok:!1,hints:[]}}if(!t||typeof t!=`object`||Array.isArray(t))return{ok:!1,hints:[]};let n=[],r=(e,t)=>{if(t==null||typeof t==`object`)return;let r=String(t).trim();r&&n.push({kind:e,value:r.slice(0,200)})};for(let[e,n]of Object.entries(t)){let t=e.toLowerCase(),i=ol[t];if(i)for(let e of Array.isArray(n)?n:[n])r(i,e);else t===`for`?r(`for`,n):t===`title`&&(typeof n==`string`||typeof n==`number`)&&r(`title`,sl(String(n)))}return{ok:!0,hints:n}}function ul(e){let t=null;for(let n of e??[]){if(n.kind!==`title`)continue;let e=sl(n.value);e&&(t=e)}return t}var dl=U().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,`Snooze time must be an ISO-8601 UTC instant`).refine(e=>{let t=Date.parse(e);return Number.isFinite(t)&&new Date(t).toISOString()===e},`Snooze time must be valid`),fl=4e3,pl=U().trim().min(1).max(fl),ml=fl,hl=1440*60,gl=U().trim().min(1).max(ml),_l=`If additional work remains on the original task, keep going. Make decisions autonomously.`,vl=W().int().min(60).max(hl),yl=q({prompt:U(),stopHook:G(),heartbeat:G(),postCompaction:G(),intervalSeconds:W().int().positive().optional(),armedAt:U(),lastRestFiredAt:U().optional(),lastScheduleFiredAt:U().optional(),lastCompactFiredAt:U().optional()}).strict(),bl=/\n\n\((?:Goal|Recurring prompt|Stop hook|Heartbeat) — (?:sent (?:(each time you come to rest)|every ([^.)]+))|(your context was just compacted))\. [^)]*\)$/;function xl(e){if(typeof e!=`string`)return;if(e.trimStart().startsWith(`**This message is from frizz, not from the human.**`))return{kind:`signoff`,prompt:``};let t=bl.exec(e.trimEnd());if(!t)return;let n=e.trimEnd().slice(0,t.index).trim();if(n)return t[3]?{kind:`compaction`,prompt:n}:t[2]?{kind:`schedule`,every:t[2].trim(),prompt:n}:{kind:`rest`,prompt:n}}var Sl=fl,Cl=U().trim().min(1).max(Sl),wl=`(This watcher is spent — there is nothing further to report on a finished PR.)`,Tl="(Registered PR watcher — STILL ARMED. It reports again on the next CI change, review, comment, label, conflict or review request. Drop it with `mcp__frizz__watch_pr` when it stops mattering.)",El=`(Frizz sends this because it finished after you came to rest, where your runtime's own completion notification does not reach you. Read its output if you still need it.)`,Dl=/^⏰ Your background shell (finished|FAILED|was STOPPED): (?:`([^`]+)` — )?(.+)\.$/;function Ol(e){let t=Dl.exec(e.trim().split(`
121
+ `).map(e=>e.replace(/\r$/,``)),n=t.findIndex(e=>/^\s*---+\s*$/.test(e)),r=n===-1?t:t.slice(0,n),i=n===-1?[]:t.slice(n+1),a=[],o=[],s=[],c=!0,l=!1;for(let e of r){let t=e.match(il),n=t?.[1].toLowerCase();t&&n?(c=al.has(n),l=n===`title`):e.trim()!==``&&!/^\s/.test(e)&&!/^\s*-\s/.test(e)&&(c=!1,l=!1),l?s.push(t&&n===`title`?t[2]??``:e):(c?o:a).push(e)}let u=ll(o.join(`
122
+ `));u.ok||a.push(...o),a.push(...i);let d=sl(s.join(` `));return d&&u.hints.push({kind:`title`,value:d}),{body:a.join(`
123
+ `).trim(),hints:u.hints.slice(0,8)}}function ll(e){if(!e.trim())return{ok:!0,hints:[]};let t;try{t=Ga(e)}catch{return{ok:!1,hints:[]}}if(!t||typeof t!=`object`||Array.isArray(t))return{ok:!1,hints:[]};let n=[],r=(e,t)=>{if(t==null||typeof t==`object`)return;let r=String(t).trim();r&&n.push({kind:e,value:r.slice(0,200)})};for(let[e,n]of Object.entries(t)){let t=e.toLowerCase(),i=ol[t];if(i)for(let e of Array.isArray(n)?n:[n])r(i,e);else t===`for`&&r(`for`,n)}return{ok:!0,hints:n}}function ul(e){let t=null;for(let n of e??[]){if(n.kind!==`title`)continue;let e=sl(n.value);e&&(t=e)}return t}var dl=U().regex(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/,`Snooze time must be an ISO-8601 UTC instant`).refine(e=>{let t=Date.parse(e);return Number.isFinite(t)&&new Date(t).toISOString()===e},`Snooze time must be valid`),fl=4e3,pl=U().trim().min(1).max(fl),ml=fl,hl=1440*60,gl=U().trim().min(1).max(ml),_l=`If additional work remains on the original task, keep going. Make decisions autonomously.`,vl=W().int().min(60).max(hl),yl=q({prompt:U(),stopHook:G(),heartbeat:G(),postCompaction:G(),intervalSeconds:W().int().positive().optional(),armedAt:U(),lastRestFiredAt:U().optional(),lastScheduleFiredAt:U().optional(),lastCompactFiredAt:U().optional()}).strict(),bl=/\n\n\((?:Goal|Recurring prompt|Stop hook|Heartbeat) — (?:sent (?:(each time you come to rest)|every ([^.)]+))|(your context was just compacted))\. [^)]*\)$/;function xl(e){if(typeof e!=`string`)return;if(e.trimStart().startsWith(`**This message is from frizz, not from the human.**`))return{kind:`signoff`,prompt:``};let t=bl.exec(e.trimEnd());if(!t)return;let n=e.trimEnd().slice(0,t.index).trim();if(n)return t[3]?{kind:`compaction`,prompt:n}:t[2]?{kind:`schedule`,every:t[2].trim(),prompt:n}:{kind:`rest`,prompt:n}}var Sl=fl,Cl=U().trim().min(1).max(Sl),wl=`(This watcher is spent — there is nothing further to report on a finished PR.)`,Tl="(Registered PR watcher — STILL ARMED. It reports again on the next CI change, review, comment, label, conflict or review request. Drop it with `mcp__frizz__watch_pr` when it stops mattering.)",El=`(Frizz sends this because it finished after you came to rest, where your runtime's own completion notification does not reach you. Read its output if you still need it.)`,Dl=/^⏰ Your background shell (finished|FAILED|was STOPPED): (?:`([^`]+)` — )?(.+)\.$/;function Ol(e){let t=Dl.exec(e.trim().split(`
124
124
  `)[0]?.trim()??``);if(!t)return null;let n=t[1]===`FAILED`?`failed`:t[1]===`was STOPPED`?`stopped`:`finished`;return{...t[2]?{taskId:t[2]}:{},label:t[3],outcome:n}}"**This message is from frizz, not from the human.** Nothing about your task has changed, and no new work is being asked of you.((You rested without a fence, so this thread cannot be triaged.((**IF THE TASK STILL HAS PARTS LEFT, THE FENCE IS NOT WHAT YOU OWE — THE WORK IS.** If ANY part of the(original task is unfinished, unverified, or deferred, resume it NOW, in THIS turn, and sign off once it(is genuinely finished. A milestone, a green test run and a long turn are none of them endings, and(neither is naming the next step or writing it into a scratch file.((**AND THAT TASK IS ALSO THE CEILING — finish it, and nothing else.** Work you notice on the way is a(FINDING TO REPORT in your sign-off, never work to take on: the bug beside the one you were sent for,(the refactor the code obviously wants, the second issue the first one touches. Widening the job is not(thoroughness — it is a different job nobody asked for, and it buries the answer they did ask for under(changes they now have to review. If it should be done, name it in one line and let the human dispatch(it.((**IF WHAT YOU WERE ASKED FOR IS A DOCUMENT, THE DOCUMENT IS THE ENDING.** A triage, a review, an(investigation, a recommendation, a plan — when that is the deliverable, the finished write-up IS the(work. Implementing what it proposes is the NEXT job, and not yours unless you were asked. Sign off with(the write-up.((**DECIDE RATHER THAN ASK.** Stop only for a decision that is genuinely the human's AND that blocks you(right now: ask that one in a question fence. Every other open choice INSIDE the task — a name, a(default, a reversible design call — is yours to make: decide it, say in one line which way you went and(what would reverse it, and carry on. A choice that would ENLARGE the task is not one of those: an(unanswered question is not permission to go build the answer.((Otherwise, add a fence at the END of your next message:((- `` ```question `` — you need the human. One question per fence, lettered options, one recommended.(- `` ```done `` — genuinely FINISHED. A DISMISSAL: the card is filed away and nobody looks again, so( if anything is still owed, it is not done. Body: 1-3 sentences, then bullets, each opening with a( **bolded verb phrase**.(- `` ```awaiting `` — you are WAITING on work that is actually running. FRONTMATTER, THEN MARKDOWN:( one structural line per thing you are waiting on, a REQUIRED `for:` duration, then a `---` line and( as much prose as you want. The prose is OPTIONAL; the lines above it are not.(( ```awaiting( shell: <the id your runtime gave you>( pr: owner/repo#123( for: 2h( ---( What you are waiting for, in your own words — this is what the human reads on your card.( ```(( Frizz CHECKS every line: name something that is not running and you are bumped rather than parked.( A fence that names NOTHING is not a park at all — if you are not waiting on anything, you are not( awaiting, you are done. Register a PR with `mcp__frizz__watch_pr` and a timer with( `mcp__frizz__timer`; `mcp__frizz__activity` reads back everything you have running, with its id.((**STILL OWED counts things you are not going to do yourself.** A decision you are RECOMMENDING, a(draft you wrote but did not send, follow-up work you discovered — all of it dies with the card, even(the part that is someone else's to do. Each ends on a question with your recommendation as option A,(or you DO it first — a sub-agent's result comes BACK to you, so it lands on your card; a new card via(`mcp__frizz__spawn_thread` is the LAST resort, since nothing it learns returns to you or its siblings.(None of them is a `done`. And what is not(worth a card is not worth a SENTENCE: delete the dangling \"one thing to carry forward\", never park it(in the handoff.((**DO NOT REPEAT YOURSELF.** If the message you just wrote already stands on its own, reply with the(fence ALONE — the human reads both together, so restating it costs them the second read for nothing.(The same holds inside one message: the card is the ledger of what shipped, the prose is only what a(ledger cannot hold, and a sentence that reads the same in either belongs in exactly one of them.((Only if it does NOT stand alone, fix that first, briefly. It has to be readable cold: the human has(seen nothing since their own last message — the Goal, this reminder, a watcher wake all came from(frizz — so anything you assumed they had followed, they have not.".split(`(`).join(`
125
125
  `);var kl=/\n\n\(One-off timer, set for (\S+?)\. It has fired and will not repeat\.\)$/;function Al(e){let t=e.trimEnd(),n=kl.exec(t);if(!n)return null;let r=t.slice(0,n.index).trim();return r?{prompt:r,at:n[1]}:null}var jl=/^⏳ The (.+?) limit that interrupted you is still closed — frizz restarted this thread on (.+?)\. Continue exactly where you left off\.$/;function Ml(e){let t=jl.exec(e.trim());return t?{capped:t[1],to:t[2]}:null}var Nl=/^⏳ The (weekly usage limit|session usage limit|model usage limit|usage limit) that interrupted you has reset\. Continue exactly where you left off\.$/;function Pl(e){let t=Nl.exec(e.trim());return t?{window:t[1]===`weekly usage limit`?`weekly`:t[1]===`session usage limit`?`session`:t[1]===`model usage limit`?`model`:`unknown`}:null}var Fl=/^⏰ Your wait expired, nothing resolved\./,Il=/^✅ (?:The work you parked on has|Everything you parked on has) FINISHED, so the park is over/;function Ll(e){return e.split(`
126
126
  `).filter(e=>e.trimStart().startsWith(`- `))}function Rl(e){let t=e.trim();return Fl.test(t)?{kind:`expired`,items:Ll(t)}:Il.test(t)?{kind:`finished`,items:Ll(t)}:null}var zl=/^⏰ Your watcher on (\S+) has expired and is no longer armed\b/;function Bl(e){let t=zl.exec(e.trim());return t?{ref:t[1]}:null}var Vl=J([`shell`,`github`,`timer`]),Hl=J([`none`,`running`,`passing`,`failing`]),Ul=J([`mergeable`,`blocked`,`conflicting`,`unknown`]),Wl=q({checks:Hl,running:W().int().nonnegative(),passed:W().int().nonnegative(),failed:W().int().nonnegative(),skipped:W().int().nonnegative().default(0),gated:W().int().nonnegative().default(0),gating:K(U()).max(8).default([]),failing:K(U()).max(8).default([]),merge:Ul,state:J([`open`,`closed`,`merged`]),polledAt:U(),head:U().optional(),failureSig:U().optional()}).strict(),Gl=q({id:U(),kind:Vl,target:U(),state:J([`armed`,`fired`,`dropped`]),createdAt:U(),github:Wl.optional(),timer:q({fireAt:U(),prompt:U()}).strict().optional()}).strict(),Kl=q({id:U(),target:U(),state:J([`armed`,`dropped`,`settled`]),createdAt:U(),github:Wl.optional()}).strict();q({slug:ks,target:U().trim().min(1).max(200),for:U().trim().min(1).max(16).optional()}).strict(),q({id:U(),target:U(),alreadyArmed:G(),expiresAt:U(),clampedFrom:U().optional(),watches:K(Kl)}).strict(),q({slug:ks,id:U().min(1).max(64)}).strict(),q({dropped:G(),watches:K(Kl)}).strict();var ql=J([`shell`,`agent`]);q({slug:ks,kind:ql,target:U().trim().min(1).max(200),for:U().trim().min(1).max(16)}).strict();var Jl=q({id:U(),kind:ql,target:U(),label:U().optional(),createdAt:U(),expiresAt:U()}).strict();q({id:U(),kind:ql,target:U(),alreadyArmed:G(),clampedFrom:U().optional(),watches:K(Jl)}).strict(),q({slug:ks,id:U().min(1).max(64)}).strict(),q({dropped:G(),watches:K(Jl)}).strict();var Yl=J([`question`,`multi`]),Xl=Ds(()=>q({label:U().trim().min(1).max(400),description:U().trim().max(2e4).optional(),recommended:G().optional(),preview:U().max(4e3).optional(),followUps:K(Zl).optional()}).strict()),Zl=Ds(()=>q({question:U().trim().min(1).max(4e3),header:U().trim().max(24).optional(),kind:Yl,danger:G().optional(),options:K(Xl).optional()}).strict());q({slug:ks,questions:K(Zl).min(1)}).strict();var Ql=q({id:U(),spec:Zl,askedAt:U()}).strict();q({registered:K(Ql),open:K(Ql)}).strict(),q({slug:ks,id:U().min(1).max(64)}).strict(),q({withdrawn:G(),open:K(Ql)}).strict();var $l=Ds(()=>q({questionId:U().min(1).max(64),question:U().min(1).max(4e3),chosen:K(U().max(400)),text:U().max(8e3).optional(),followUps:K($l).optional()}).strict());q({slug:ks,answers:K($l).min(1)}).strict(),q({answered:K(U()),open:K(Ql)}).strict(),q({slug:ks,ids:K(U().min(1).max(64)).min(1)}).strict(),q({dismissed:K(U()),open:K(Ql)}).strict();var eu=`Answers to earlier questions:`,tu=/^(\d+) questions? you registered (?:was|were) CANCELLED without an answer\./;function nu(e){let t=tu.exec(e.trim());return t?{count:Number(t[1])}:void 0}q({slug:ks,body:U().trim().min(1).max(2e4)}).strict(),q({done:G(),blockingQuestions:K(q({id:U(),question:U()}).strict()),blockingWatches:K(q({id:U(),what:U()}).strict())}).strict(),q({slug:ks}).strict(),q({watches:K(Kl)}).strict();var ru=q({id:U(),prompt:U(),fireAt:U(),state:J([`armed`,`fired`,`cancelled`]),createdAt:U()}).strict(),iu=q({kind:J([`done`,`awaiting`]),body:U(),hints:K(nl).default([]),registered:Os(!0).optional()}),au=q({backend:Kc,window:J([`session`,`weekly`,`model`,`unknown`]),at:U(),resumesAt:W().optional(),autoResume:G()}),ou=q({message:U(),code:U().optional(),details:U().optional(),retrying:G().optional(),at:U().optional()}),su=q({id:ks,title:U(),status:Uc,statusText:U().optional(),activity:U().optional(),next:U().optional(),hasPlan:G().default(!1),mechanism:Wc.nullable(),humanBlocked:G(),ready:G(),dependsOn:K(ks),externalDeps:K(U()),owner:U().optional(),revalidate:U().optional(),agents:K(Jc),errors:K(U()),warnings:K(U()),runtime:Gc,sessionId:U().optional(),threadName:U().optional(),unread:G(),archived:G(),lastAssistant:U().optional(),spawnedAt:U().optional(),lastActivityAt:U().optional(),lastAssistantAt:U().optional(),aiTitle:U().optional(),titleAuto:G().optional(),titleLocked:G().optional(),subAgents:K(Yc).default([]),bgShells:K(Zc).default([]),watches:K(Gl).default([]),pendingAsk:tl.optional(),pendingQuestion:G().default(!1),questions:K(Ql).default([]),answersInFlight:U().optional(),lastUserAt:U().optional(),providerFault:q({backend:J([`claude`,`codex`]),category:J([`authentication_required`,`authentication_rejected`])}).optional(),limitPause:au.optional(),providerError:ou.optional(),kind:J([`session`,`legacy`]).optional(),foreign:G().optional(),state:J([`open`,`archived`]).optional(),snoozedUntil:dl.optional(),snoozePrompt:U().optional(),pinnedAt:U().optional(),bgSnoozed:G().optional(),claudeRuntime:Os(`broker`).optional(),recurringPrompt:yl.optional(),lastFence:iu.optional(),needsYou:G().optional(),crashed:G().optional(),awaitingBackground:G().optional(),pendingInteraction:G().optional(),actionableInteraction:G().optional(),seenAt:U().optional(),backend:Kc.optional(),permissionMode:J([`auto`,`default`,`acceptEdits`,`plan`,`bypassPermissions`]).optional(),permissionPending:J([`auto`,`default`,`acceptEdits`,`plan`,`bypassPermissions`]).optional(),permissionChangePending:G().optional(),permPolicy:q({decision:Os(`deny`),rule:U(),reason:U(),tool:U().nullable(),at:U(),command:U().optional()}).optional(),permDenies:W().optional(),profilePendingModel:U().optional(),profilePendingEffort:U().optional(),profileChangePending:G().optional(),runtimeControlPending:G().optional(),controlError:U().optional(),model:U().optional(),effort:U().optional(),context:q({tokens:W(),window:W()}).optional()});function cu(e){return e.kind===`session`&&e.foreign!==!0&&e.needsYou===!0&&e.state!==`archived`}var lu=q({file:U(),kind:J([`no-frontmatter`,`other`]),message:U()}),uu=q({projectDir:U(),projectName:U(),projectLabel:U(),githubRepo:U().optional(),projectSlug:U().optional(),homeDir:U().optional(),threads:K(su),errors:K(U()),warnings:K(U()),errorItems:K(lu).optional()}),du=q({key:U(),label:U(),usedPercent:W(),resetsAt:W().optional()}),fu=q({status:J([`ok`,`unavailable`]),planType:U().optional(),windows:K(du),detail:U().optional()});q({claude:fu,codex:fu});var pu=J([`authed`,`signed-out`,`unknown`]);q({claude:pu,codex:pu,emails:q({claude:U().max(320).optional(),codex:U().max(320).optional()})}),q({backend:J([`claude`,`codex`])}).strict(),q({status:J([`done`,`blocked`,`failed`]),auth:pu,activeThreads:W().int().positive().optional(),detail:U().max(200).optional()}),q({backend:J([`claude`,`codex`])}).strict(),q({attemptId:ks}),q({attemptId:ks}).strict(),q({state:J([`running`,`exited`,`unknown`]),auth:pu});var mu=J([`auto`,`default`,`acceptEdits`,`plan`,`bypassPermissions`]),hu=J([`system`,`cursor`,`vscode`,`finder`,`copy`]),gu=q({permissionMode:mu,model:U().optional(),backend:Kc.optional(),effort:J([`low`,`medium`,`high`,`xhigh`,`max`,`ultra`,`ultracode`]).optional(),notifications:G(),projectRail:G(),font:J([`mono`,`sans`]).optional(),localFileOpener:hu.optional(),autoCompactWindow:W().int().positive().optional(),promptCacheTtl:J([`auto`,`5m`,`1h`]).optional(),githubPrompt:U().optional()}),_u=q({model:U().trim().min(1).max(200).optional(),effort:gu.shape.effort,permissionMode:mu.optional()});q({backend:Kc,claude:_u,codex:_u});var vu=q({backend:Kc,model:U().trim().min(1).max(200),effort:gu.shape.effort.unwrap(),permissionMode:mu.optional()}).strict();Ts(`field`,[q({field:Os(`backend`),value:Kc}),q({field:Os(`profile`),backend:Kc,model:U().trim().min(1).max(200),effort:gu.shape.effort.unwrap()}),q({field:Os(`model`),backend:Kc,value:U().trim().min(1).max(200)}),q({field:Os(`effort`),backend:Kc,value:gu.shape.effort.unwrap()})]),q({title:U().min(1).optional(),prompt:U().min(1),slug:ks.optional(),permissionMode:mu.optional(),model:U().optional(),backend:Kc.optional(),effort:gu.shape.effort}),q({slug:ks,message:U().max(64*1024).optional()}).strict(),q({slug:ks,sessionId:U().min(1)}).strict(),q({sessionId:ks,backend:J([`claude`,`codex`]),title:U().max(200).optional()}).strict(),q({slug:ks,sessionId:U().min(1),message:U().min(1),deliveryId:U().min(1).max(200).optional(),freshProcess:G().optional(),interrupt:G().optional()}),q({slug:ks,sessionId:U().min(1),deliveryId:U().min(1).max(200)}).strict(),q({unqueued:G(),reason:U().optional()}).strict(),q({slug:ks,sessionId:U().min(1)}).strict(),q({interrupted:G(),reason:U().optional()}).strict(),q({slug:ks,sessionId:U().min(1),until:dl.nullable(),prompt:pl.nullable().optional()}).strict(),q({slug:ks,sessionId:U().min(1),pinned:G()}).strict(),q({slug:ks,sessionId:U().min(1),prompt:gl.nullable(),stopHook:G(),heartbeat:G(),postCompaction:G().default(!1),intervalSeconds:vl.optional()}).strict(),q({slug:ks,prompt:gl.nullable(),stopHook:G(),heartbeat:G(),postCompaction:G().default(!1),pauseOnQuestions:G().optional(),intervalSeconds:vl.optional()}).strict(),q({replaced:yl.nullable()}).strict(),q({slug:ks}).strict(),q({recurringPrompt:yl.nullable()}).strict(),q({slug:ks,prompt:Cl,fireAt:dl}).strict(),q({slug:ks,id:U().min(1).max(64)}).strict(),q({slug:ks}).strict(),q({timers:K(ru)}).strict();var yu=q({kind:J([`shell`,`agent`,`timer`,`pr`]),id:U(),label:U(),since:U().optional(),until:U().optional(),watchId:U().optional()}).strict();q({slug:ks}).strict(),q({activity:K(yu),questions:K(Ql).default([])}).strict(),q({id:U(),fireAt:U(),timers:K(ru)}).strict(),q({cancelled:G(),timers:K(ru)}).strict(),q({slug:ks,prompt:gl.nullable(),enabled:G()}).strict(),q({slug:ks,prompt:gl.nullable(),intervalSeconds:vl.optional(),enabled:G().optional()}).strict(),q({plugins:W().int().min(0),commands:W().int().min(0),agents:W().int().min(0),mcpServers:K(U()),errorCount:W().int().min(0)}).strict(),q({slug:ks,title:U().trim().min(1).max(200)}),q({slug:ks}),q({title:U().min(1).max(200)}),q({slug:ks,title:U().trim().min(1).max(200)}).strict(),q({accepted:G(),title:U(),lockedByHuman:G()}).strict(),q({slug:ks,permissionMode:mu}),q({effect:J([`applied`,`next-turn`,`next-resume`])}),q({slug:ks}).strict(),q({backend:Kc,options:K(qc)});var bu=J([`project`,`user`,`builtin`,`plugin`]),xu=q({name:U().min(1).max(512),description:U().max(1024),source:bu.optional()}).strict();q({slug:ks}).strict(),q({skills:K(xu).max(1024)}).strict(),q({slug:ks,model:U().trim().min(1).max(200),effort:U().trim().min(1).max(100)}).strict(),q({effect:J([`applied`,`next-resume`])}),`${[`===============================================================`,`====================== YOUR TASK ========================`,`===============================================================`].join(`
@@ -196,7 +196,7 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
196
196
  `),n=t[0]?.match(/^(@\S+) \((.+?)(?:, line (\d+)|, lines (\d+)-(\d+))?\):$/);if(!n)return null;let r=n[2],a=n[3]===void 0?n[4]===void 0?void 0:Number(n[4]):Number(n[3]),o=n[3]===void 0?n[5]===void 0?void 0:Number(n[5]):Number(n[3]),s=1,c=[];for(;s<t.length&&t[s].startsWith(`>`);s++)c.push(t[s].replace(/^> ?/,``));if(!c.length||s<t.length)return null;i.push({token:n[1],display:r,startLine:a,endLine:o,text:c.join(`
197
197
  `)})}return!i.length||!i.every(e=>xL(n,e.token))?null:{body:n,items:i}}function NL(e){return e.key===`Enter`&&!e.altKey&&!e.shiftKey&&!e.isComposing&&e.keyCode!==229}function PL(e,t){return t&&NL(e)&&!e.metaKey&&!e.ctrlKey}function FL(e,t){return t&&NL(e)&&(e.metaKey||e.ctrlKey)}function IL(e){return NL(e)}function LL(e){return e.key===`Enter`&&e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing}function RL(e,t,n){return e===`queueComposer`&&t===`Enter`&&n}var zL=`gap-3`,BL=`-mx-1`,VL=`-mx-[3px]`,HL=`right-2`,UL=`right-[71px]`,WL=`right-[44px]`,GL=`pr-[6.6875rem]`,KL=`pr-20`;async function qL(e,t){let n=Nd(),r=await e.arrayBuffer(),i=``,a=new Uint8Array(r);for(let e=0;e<a.length;e+=32768)i+=String.fromCharCode(...a.subarray(e,e+32768));let o=await fetch(`${n}/attach`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t,data:btoa(i)})});return o.ok?(await o.json()).path??null:null}var JL={project:`project`,user:`global`,builtin:`built-in`,plugin:`plugin`};function YL(e,t){e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,t)}px`}function XL({value:e,onChange:t,onSubmit:n,surface:r,placeholder:i,id:a,minHeight:o=44,maxHeight:s=220,autoFocus:c,busy:l,footer:u,leftAction:d,contextTokens:f,slashSuggest:p,onInterruptSubmit:m}){let h=(0,I.useRef)(null),g=(0,I.useRef)(null),_=(0,I.useRef)(null),[v,y]=(0,I.useState)(!1),[b,x]=(0,I.useState)(!1),{prose:S,attachments:C}=(0,I.useMemo)(()=>hL(e),[e]),w=C.map(e=>e.path),T=(0,I.useRef)(e);T.current=e;let E=e=>t(gL(e,w)),D=e=>t(gL(S,e));async function O(e){if(!e)return;if(b){Z(`An upload is already in progress — try again in a moment`);return}let n=[...e].map(e=>{let t=e.type.startsWith(`image/`)?e.type.slice(6).toLowerCase():``,n=t===`jpeg`?`jpg`:t===`svg+xml`?`svg`:t;return{file:e,name:e.name||(n?`pasted.${n}`:``)}}).filter(({name:e})=>Vc(e)?!0:(Z(`${e||`File`}: unsupported file type`),!1));if(!n.length)return;let r=n.filter(({file:e,name:t})=>e.size>Rc?(Z(`${t} is too large (max ${Math.floor(Rc/1e6)} MB)`),!1):!0);if(!r.length)return;let i=T.current;x(!0);let a=[];try{for(let{file:e,name:t}of r){let n=await qL(e,t);n?a.push(n):Z(`Could not attach ${t}`)}}finally{x(!1)}if(a.length&&i!==``&&T.current===``){Z(`Attachment discarded — the message was sent before the upload finished`),requestAnimationFrame(()=>h.current?.focus());return}if(a.length){let e=hL(T.current);t(gL(e.prose,[...e.attachments.map(e=>e.path),...a]))}requestAnimationFrame(()=>h.current?.focus())}(0,I.useLayoutEffect)(()=>{let e=!0,t=()=>{let t=h.current;!t||!e||YL(t,s)};t();let n=requestAnimationFrame(t);document.fonts?.ready.then(t);let r=h.current,i=r?.clientWidth??0,a,o=r?new ResizeObserver(([e])=>{let n=Math.round(e.contentRect.width);n!==i&&(i=n,a!==void 0&&cancelAnimationFrame(a),a=requestAnimationFrame(t))}):void 0;return r&&o?.observe(r),()=>{e=!1,cancelAnimationFrame(n),a!==void 0&&cancelAnimationFrame(a),o?.disconnect()}},[e,s,!!u]);let k=(0,I.useMemo)(()=>f??[],[f]),A=(0,I.useMemo)(()=>{if(k.length===0)return null;let e=TL(S,k);return e.some(e=>e.token)?e.map((e,t)=>e.token?(0,L.jsx)(`span`,{className:`rounded bg-panel-2 py-0.5 -mx-0.5 px-0.5 ring-1 ring-inset ring-border`,children:e.text},t):e.text):null},[S,k]),j=()=>{let e=h.current,t=g.current;e&&t&&(t.scrollTop=e.scrollTop)};(0,I.useLayoutEffect)(j);let M=(0,I.useRef)(!1);(0,I.useEffect)(()=>{let e=h.current;if(!e)return;let t=()=>{M.current=e.disabled};return e.addEventListener(`focusout`,t),()=>e.removeEventListener(`focusout`,t)},[]),(0,I.useEffect)(()=>{if(l||!M.current)return;M.current=!1;let e=h.current,t=document.activeElement;e&&(!t||t.contains(e))&&e.focus({preventScroll:!0})},[l]);let[N,P]=(0,I.useState)(null),[ee,F]=(0,I.useState)({prose:``,index:0}),te=ee.prose===S?ee.index:0,ne=e=>F({prose:S,index:typeof e==`function`?e(te):e}),[re,ie]=(0,I.useState)(null),ae=!!p&&/^\/\S*$/.test(S);(0,I.useEffect)(()=>{if(!ae||N!==null)return;let e=!0;return p().then(t=>{e&&P(t)},()=>{e&&P([])}),()=>{e=!1}},[ae,N,p]);let oe=(0,I.useMemo)(()=>{if(!ae||!N||re===S)return[];let e=S.slice(1).toLowerCase(),t=N.filter(t=>t.name.toLowerCase().startsWith(e)),n=N.filter(t=>!t.name.toLowerCase().startsWith(e)&&t.name.toLowerCase().includes(e));return[...t,...n]},[ae,N,re,S]),se=oe.length>0,ce=(0,I.useMemo)(()=>{let e=new Set;for(let t of oe)t.source&&e.add(JL[t.source]);return[...e]},[oe]),le=(0,I.useRef)(null);(0,I.useEffect)(()=>{le.current?.querySelector(`[data-suggest-index="${te}"]`)?.scrollIntoView({block:`nearest`})},[te]);function ue(e){let t=`/${e.name} `;E(t),requestAnimationFrame(()=>h.current?.setSelectionRange(t.length,t.length))}let de=e.trim().length>0,fe=d??null;function pe(e){let t=e.currentTarget,i={key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.keyCode};if(se&&!e.nativeEvent.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),ne(t=>(t+(e.key===`ArrowDown`?1:-1)+oe.length)%oe.length);return}if((e.key===`Enter`||e.key===`Tab`)&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey){e.preventDefault(),e.stopPropagation(),ue(oe[te]??oe[0]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),ie(S);return}}if(e.key===`Backspace`&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&k.length>0&&t.selectionStart===t.selectionEnd){let n=t.selectionStart,r=TL(t.value.slice(0,n),k).at(-1);if(r?.token){e.preventDefault();let i=n-r.text.length;E(t.value.slice(0,i)+t.value.slice(n)),requestAnimationFrame(()=>t.setSelectionRange(i,i));return}}if(RL(r,e.key,e.altKey)){e.preventDefault(),e.stopPropagation();let n=t.selectionStart??t.value.length,r=t.selectionEnd??n;E(t.value.slice(0,n)+`
198
198
  `+t.value.slice(r)),requestAnimationFrame(()=>t.setSelectionRange(n+1,n+1));return}let a=de&&!l&&!b;if(PL(i,a)){e.preventDefault(),e.stopPropagation(),n();return}if(FL(i,a)){e.preventDefault(),e.stopPropagation(),(m??n)();return}if(LL(i)){let e=t.value,n=t.selectionStart??e.length,r=t.selectionEnd??n;requestAnimationFrame(()=>{t.value===e&&(E(e.slice(0,n)+`
199
- `+e.slice(r)),requestAnimationFrame(()=>t.setSelectionRange(n+1,n+1)))})}e.key===`Escape`&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.stopPropagation(),t.blur())}return(0,L.jsxs)(`div`,{className:`group relative rounded-xl border bg-bg transition-colors focus-within:border-accent ${v?`border-dashed border-accent`:`border-border`}`,onDragOver:e=>{[...e.dataTransfer.items].some(e=>e.kind===`file`)&&(e.preventDefault(),y(!0))},onDragLeave:()=>y(!1),onDrop:e=>{e.preventDefault(),y(!1),O(e.dataTransfer.files)},children:[v&&(0,L.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-bg/80 text-[12px] text-muted`,children:`Drop file to attach`}),se&&(0,L.jsx)(`div`,{ref:le,"data-slash-menu":!0,className:`absolute bottom-full left-0 right-0 z-20 mb-1.5 max-h-56 overflow-y-auto rounded-lg border border-border bg-bg py-1 shadow-lg`,children:oe.map((e,t)=>(0,L.jsxs)(`button`,{type:`button`,"data-suggest-index":t,onMouseDown:e=>e.preventDefault(),onClick:()=>ue(e),onMouseEnter:()=>ne(t),className:`flex w-full items-baseline gap-2 px-3.5 py-1.5 text-left ${t===te?`bg-panel-2`:``}`,children:[(0,L.jsxs)(`span`,{className:`shrink-0 text-[12px] font-medium text-fg`,children:[`/`,e.name]}),e.description&&(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-muted`,children:e.description}),ce.length>0&&(0,L.jsxs)(`span`,{className:`ml-auto grid shrink-0 text-[10px]`,children:[ce.map(e=>(0,L.jsx)(`span`,{"aria-hidden":!0,className:`petite-caps invisible col-start-1 row-start-1`,children:e},e)),(0,L.jsx)(`span`,{className:`petite-caps col-start-1 row-start-1 text-right text-muted/70`,children:e.source?JL[e.source]:``})]})]},e.name))}),(0,L.jsxs)(`div`,{className:`relative`,children:[A&&(0,L.jsx)(`div`,{ref:g,"aria-hidden":!0,"data-composer-context-backdrop":!0,className:`pointer-events-none absolute inset-0 select-none overflow-hidden whitespace-pre-wrap [overflow-wrap:break-word] px-3.5 ${u?`py-2.5 pb-3`:`py-2.5 ${fe?`pr-[6.6875rem]`:`pr-20`}`} text-[13px] leading-relaxed text-transparent`,children:A}),(0,L.jsx)(`textarea`,{id:a,ref:h,onScroll:A?j:void 0,"data-surface":r,value:S,autoFocus:c,disabled:l,onChange:e=>E(e.target.value),onKeyDown:pe,onPaste:e=>{let t=[...e.clipboardData.items].filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(Boolean);t.length&&(e.preventDefault(),O(t))},placeholder:i,rows:1,spellCheck:!1,style:{minHeight:o,maxHeight:s},className:`relative block w-full resize-none bg-transparent px-3.5 ${u?`py-2.5 pb-3`:`py-2.5 ${fe?GL:KL}`} text-[13px] leading-relaxed text-fg outline-none placeholder:text-muted scrollbar-none disabled:opacity-60`})]}),C.length>0&&(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-3 pb-2 ${fe?`pr-[6.6875rem]`:`pr-20`}`,children:C.map((e,t)=>(0,L.jsx)(ZL,{attachment:e,disabled:l,onRemove:()=>D(w.filter((e,n)=>n!==t))},`${e.path}-${t}`))}),u&&(0,L.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1 pl-1.5 pb-1.5 ${fe?`pr-[6.6875rem]`:`pr-20`}`,children:u}),fe&&(0,L.jsx)(`div`,{className:`absolute bottom-2 right-[43px] flex items-center`,children:fe}),(0,L.jsx)(`input`,{ref:_,type:`file`,multiple:!0,accept:Hc,className:`hidden`,onChange:e=>{O(e.target.files),e.target.value=``}}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>_.current?.click(),disabled:l||b,title:`Attach files`,"aria-label":`Attach files`,className:`absolute bottom-2 ${fe?UL:WL} flex h-7 w-7 items-center justify-center rounded-lg text-muted transition-[color,background-color] enabled:hover:bg-panel-2/70 enabled:hover:text-fg disabled:opacity-50`,children:b?(0,L.jsx)(Mm,{size:15,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(Bm,{size:15,strokeWidth:2})}),(0,L.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:n,disabled:!de||l||b,title:`Send (Enter · ⌘⏎ sends now)`,"aria-label":`Send`,className:`absolute bottom-2 ${HL} flex h-7 w-7 items-center justify-center rounded-lg transition-all ${de&&!l&&!b?`bg-fg text-bg hover:opacity-90 active:scale-95`:`bg-panel-2 text-muted`}`,children:l?(0,L.jsx)(Mm,{size:14,strokeWidth:2.5,className:`animate-spin`}):(0,L.jsx)(Jp,{size:14,strokeWidth:2.5})})]})}function ZL({attachment:e,disabled:t,onRemove:n}){let[r,i]=(0,I.useState)(!1),a=e.path.split(`/`).filter(Boolean).pop()||e.path,o=(a.includes(`.`)?a.split(`.`).pop():``).toUpperCase();return(0,L.jsxs)(`div`,{className:`group/att relative h-11 w-11`,title:a,children:[e.kind===`image`&&!r?(0,L.jsx)(`img`,{src:jS(e.path),alt:a,onError:()=>i(!0),className:`h-11 w-11 rounded-md border border-border object-cover`}):(0,L.jsxs)(`div`,{className:`flex h-11 w-11 flex-col items-center justify-center gap-0.5 rounded-md border border-border bg-panel-2 px-1`,children:[(0,L.jsx)(gm,{size:15,strokeWidth:2,className:`shrink-0 text-muted`}),o&&(0,L.jsx)(`span`,{className:`-mx-1 max-w-[calc(100%+0.5rem)] truncate text-[8px] font-medium leading-none text-muted/80`,children:o})]}),(0,L.jsx)(`button`,{type:`button`,onClick:n,disabled:t,title:`Remove ${a}`,"aria-label":`Remove ${a}`,className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full border border-border bg-bg text-muted opacity-0 transition-opacity hover:text-fg focus-visible:opacity-100 group-hover/att:opacity-100 disabled:hidden`,children:(0,L.jsx)(ah,{size:10,strokeWidth:2.5})})]})}function QL(){return nt({queryKey:[`githubStatus`],queryFn:()=>Y.githubStatus(),staleTime:3e4,refetchOnWindowFocus:!0,refetchInterval:e=>{let t=e.state.data;return t?.inRepo&&t.authed?!1:6e4}})}function $L(){let e=QL();return!!(e.data?.inRepo&&e.data.authed)}function eR({className:e=``}){return $L()?(0,L.jsx)(`button`,{type:`button`,onClick:Gf,onMouseDown:e=>e.preventDefault(),title:`Investigate this issue and make recommendations`,"aria-label":`Investigate this issue and make recommendations`,className:`flex h-7 w-7 items-center justify-center rounded-lg text-muted outline-none transition-[color,background-color,box-shadow] enabled:hover:bg-panel-2/70 enabled:hover:text-fg enabled:focus-visible:bg-panel-2/70 enabled:focus-visible:text-muted enabled:focus-visible:ring-1 enabled:focus-visible:ring-muted/80 enabled:focus-visible:ring-offset-1 enabled:focus-visible:ring-offset-bg enabled:active:bg-elevated enabled:active:text-muted disabled:bg-transparent disabled:text-muted/35 ${e}`,children:(0,L.jsx)(wm,{size:15,strokeWidth:2})}):null}var tR=`prompt-control-type petite-caps`,nR=tR,rR=tR,iR=`profile-grid-cell relative flex h-6 cursor-pointer select-none items-center justify-start rounded border border-transparent px-1 text-left text-muted outline-none transition-colors ${nR} data-[highlighted]:border-border data-[highlighted]:bg-panel-2 data-[highlighted]:text-fg data-[highlighted]:outline data-[highlighted]:outline-1 data-[highlighted]:outline-offset-1 data-[highlighted]:outline-fg/55 data-[state=checked]:border-accent/70 data-[state=checked]:bg-accent/10 data-[state=checked]:font-medium data-[state=checked]:text-fg data-[state=checked]:ring-1 data-[state=checked]:ring-inset data-[state=checked]:ring-accent/90`;function aR(e){return`minmax(6rem, 7rem) repeat(${Math.max(0,e)}, auto)`}var oR=[`ultra`,`ultracode`],sR=[`low`,`medium`,`high`,`xhigh`,`max`,...oR];function cR(e){return[...new Set(e.flatMap(e=>e.options.flatMap(e=>e.efforts)))].sort((e,t)=>{let n=sR.indexOf(e),r=sR.indexOf(t);return n===-1&&r===-1?e.localeCompare(t):n===-1?1:r===-1?-1:n-r})}function lR(e){let t=[];for(let n of cR(e)){let e=oR.includes(n)?t.find(e=>oR.includes(e[0])):void 0;e?e.push(n):t.push([n])}return t}function uR(e){return e.flatMap(e=>e.options.flatMap(t=>t.efforts.map(n=>({provider:e.id,model:t.model,effort:n}))))}function dR(e){return JSON.stringify([e.provider,e.model,e.effort])}function fR(e,t){return uR(e).find(e=>dR(e)===t)}function pR(e,t){return!t?.model||!t.effort?!1:e.some(e=>(!t.provider||e.id===t.provider)&&e.options.some(e=>e.model===t.model&&e.efforts.includes(t.effort)))}function mR(e,t,n=`Profile unknown`){if(!t?.model&&!t?.effort)return n;let r=e.flatMap(e=>e.options).find(e=>e.model===t.model)?.label??t.model??`Model unknown`;return t.effort?`${r} › ${t.effort}`:r}function hR(e,t,n){let r=lR(e),i=e=>r.findIndex(t=>t.includes(e)),a=e.flatMap(e=>e.options.map(t=>({provider:e.id,option:t}))),o=a.findIndex(e=>e.provider===t.provider&&e.option.model===t.model);if(o===-1)return null;let s=a[o],c=s.option.efforts.indexOf(t.effort);if(c===-1)return null;if(n===`Home`||n===`End`||n===`ArrowLeft`||n===`ArrowRight`){let e=n===`Home`?0:n===`End`?s.option.efforts.length-1:c+(n===`ArrowLeft`?-1:1),t=s.option.efforts[e];return t?{provider:s.provider,model:s.option.model,effort:t}:null}let l=a[o+(n===`ArrowUp`?-1:1)];if(!l)return null;let u=i(t.effort),d=l.option.efforts.reduce((e,t)=>e?Math.abs(i(t)-u)<Math.abs(i(e)-u)?t:e:t,void 0);return d?{provider:l.provider,model:l.option.model,effort:d}:null}var gR,_R=!1;function vR(){_R||typeof window>`u`||(_R=!0,window.addEventListener(`keydown`,e=>{e.key!==`Escape`||!gR||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),bR())},{capture:!0}))}function yR(e){vR();let t={dismiss:e};return gR=t,()=>{gR===t&&(gR=void 0)}}function bR(){let e=gR;return e?(gR=void 0,e.dismiss(),!0):!1}function xR(e){bR()&&e.preventDefault(),e.stopPropagation()}function SR(e){return e===`xhigh`?`X-high`:e.charAt(0).toUpperCase()+e.slice(1)}function CR({groups:e,value:t,pending:n,onValueChange:r,placeholder:i,ariaLabel:a,menuAriaLabel:o=`Choose model and effort`,title:s,disabled:c=!1,compact:l=!1,side:u=`bottom`,menuZClass:d=Nj,className:f=``}){let[p,m]=(0,I.useState)(!1),h=(0,I.useRef)(p),g=(0,I.useRef)(c),_=(0,I.useRef)(void 0),v=(0,I.useRef)(new Map),y=(0,I.useRef)(void 0),b=(0,I.useMemo)(()=>lR(e),[e]),x=(0,I.useMemo)(()=>e.flatMap(e=>e.options.flatMap(t=>t.efforts.map(n=>({provider:e.id,model:t.model,effort:n})))),[e]),S=l?rR:nR,C=c?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors hover:border-border hover:bg-panel-2 hover:text-fg`,w=pR(e,t),T=w&&t?.provider&&t.model&&t.effort?dR(t):void 0,E=n?.model||n?.effort?mR(e,n,`Pending profile`):void 0;h.current=p,g.current=c;function D(){h.current=!1,_.current=void 0,m(!1)}(0,I.useLayoutEffect)(()=>{let e=e=>{e.key!==`Escape`||!h.current||g.current||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),_.current?.(),D())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]),(0,I.useLayoutEffect)(()=>{!c||!p||(_.current?.(),D())},[c,p]),(0,I.useLayoutEffect)(()=>()=>_.current?.(),[]),(0,I.useLayoutEffect)(()=>{T===y.current&&(y.current=void 0)},[T]);function O(e){let t=dR(e);y.current!==t&&(y.current=t,r(e))}function k(t,n){if(![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(t.key))return;let r=hR(e,n,t.key);r&&(t.preventDefault(),t.stopPropagation(),v.current.get(dR(r))?.focus())}return(0,L.jsxs)(fI,{modal:!1,open:p,onOpenChange:e=>{_.current?.(),_.current=void 0,h.current=e,m(e),e&&(_.current=yR(D))},children:[(0,L.jsx)(pI,{asChild:!0,disabled:c,children:(0,L.jsxs)(`button`,{type:`button`,"aria-label":a,"aria-invalid":!w&&(t?.model||t?.effort)?!0:void 0,"aria-description":E?`Pending ${E}`:void 0,title:s,"data-profile-known":w?`true`:`false`,"data-profile-pending":E?`true`:void 0,className:`profile-grid-trigger group inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md border border-border/50 bg-transparent px-2 py-1 text-left text-muted outline-none data-[state=open]:border-border data-[state=open]:bg-panel-2 ${C} ${f} ${S}`,children:[(0,L.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 flex-1 truncate text-left ${S}`,children:mR(e,t,i)}),E&&(0,L.jsx)(Mm,{"aria-hidden":`true`,size:l?10:11,className:`shrink-0 animate-spin text-muted/65`}),(0,L.jsx)($p,{"aria-hidden":`true`,size:l?11:13,className:`shrink-0 text-fg/65 transition-transform group-data-[state=open]:rotate-180`})]})}),(0,L.jsx)(mI,{children:(0,L.jsxs)(hI,{"aria-label":o,align:`start`,side:u,sideOffset:5,collisionPadding:8,onEscapeKeyDown:e=>e.stopPropagation(),className:`profile-grid-menu ${d} ${Mj} max-h-[min(360px,var(--radix-dropdown-menu-content-available-height))] max-w-[calc(100vw-1rem)] overflow-auto rounded-lg p-1.5 ${S}`,children:[e.map(t=>(0,L.jsxs)(gI,{children:[t.label&&(0,L.jsx)(_I,{className:`px-1.5 pb-1 pt-1 text-left font-medium tracking-[0.07em] text-muted/55 first:pt-0.5`,children:t.label}),(0,L.jsx)(yI,{value:T,onValueChange:t=>{let n=fR(e,t);n&&O(n)},children:t.options.map(e=>(0,L.jsxs)(`div`,{"data-profile-grid-row":e.model,className:`grid w-max items-center gap-1 py-0.5`,style:{gridTemplateColumns:aR(b.length)},children:[(0,L.jsx)(`span`,{className:`profile-grid-model-label min-w-0 max-w-[9.5rem] truncate px-1.5 text-left text-muted ${S}`,title:e.label,children:e.label}),b.map(n=>{let r=n.find(t=>e.efforts.includes(t)),i=n.reduce((e,t)=>SR(t).length>SR(e).length?t:e);if(!r)return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`invisible cursor-default border border-transparent px-1 text-left font-medium ${S}`,children:SR(i)},i);let a={provider:t.id,model:e.model,effort:r},o=dR(a);return(0,L.jsx)(bI,{value:o,ref:e=>{e?v.current.set(o,e):v.current.delete(o)},onKeyDown:e=>k(e,a),onSelect:e=>{e.preventDefault(),O(a),_.current?.(),D()},"aria-label":`${e.label}, ${SR(r)} effort`,title:`${e.label} › ${SR(r)}`,className:iR,children:(0,L.jsxs)(`span`,{className:`grid`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`invisible col-start-1 row-start-1 font-medium`,children:SR(r)}),(0,L.jsx)(`span`,{className:`col-start-1 row-start-1`,children:SR(r)})]})},r)})]},e.model))}),t!==e.at(-1)&&(0,L.jsx)(SI,{className:`my-1 h-px bg-border`})]},t.id)),x.length===0&&(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-muted/60`,children:`No profiles available`})]})})]})}async function wR(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(!TR(e))throw Error(`the browser blocked clipboard access`)}function TR(e){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`0`,t.style.left=`0`,t.style.opacity=`0`,document.body.append(t);let n=document.getSelection(),r=n&&n.rangeCount>0?n.getRangeAt(0):null;t.select(),t.setSelectionRange(0,e.length);let i=!1;try{i=document.execCommand(`copy`)}catch{i=!1}return t.remove(),r&&n&&(n.removeAllRanges(),n.addRange(r)),i}var ER={claude:`claude auth login`,codex:`codex login`},DR={claude:`Claude`,codex:`Codex`};function OR(e){let t=e.trim();return t===`/login`?`login`:t===`/logout`?`logout`:null}var kR=(0,I.lazy)(()=>By(()=>import(`./TerminalPane-CDk5zKv9.js`).then(e=>({default:e.TerminalPane})),__vite__mapDeps([0,1])));function AR({backend:e,onClose:t,onAuthed:n}){let r=Ve(),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(null),c=(0,I.useRef)(!1),l=ER[e],u=DR[e],d=it({mutationFn:()=>Y.accountLoginStart({backend:e}),onSuccess:e=>{c.current=!1,s(e.attemptId)},onError:e=>Z(`Couldn't start the sign-in terminal: ${e.message.slice(0,80)} — use the command below instead`,{duration:7e3})}),f=nt({queryKey:[`accountLoginStatus`,o],queryFn:()=>Y.accountLoginStatus({attemptId:o}),enabled:!!o,refetchInterval:2e3});(0,I.useEffect)(()=>{if(!o||c.current)return;let t=f.data;if(!(!t||t.state===`running`||t.state===`unknown`)){if(c.current=!0,t.auth!==`signed-out`){r.setQueryData([`authStatus`],n=>n&&{...n,[e]:t.auth}),Z(`Signed in to ${u}`),n();return}Z(`${u} sign-in didn't complete — try again or use the command below`,{duration:7e3}),s(null)}},[o,f.data,e,u]);function p(){o&&!c.current&&Y.accountLoginCancel({attemptId:o}).catch(()=>{})}let m=(0,I.useRef)({attempt:null,settled:!1});m.current={attempt:o,settled:c.current},(0,I.useEffect)(()=>()=>{let{attempt:e,settled:t}=m.current;e&&!t&&Y.accountLoginCancel({attemptId:e}).catch(()=>{})},[]);async function h(){try{await wR(l),a(!0),window.setTimeout(()=>a(!1),1500)}catch{Z(`Couldn't copy — select the command and copy it manually`,{duration:6e3})}}let g=it({mutationFn:()=>Y.authStatus(),onSuccess:t=>{if(r.setQueryData([`authStatus`],t),t[e]===`signed-out`){Z(`Still signed out of ${u} — run the command, then retry`,{duration:6e3});return}n()},onError:()=>n()});return(0,L.jsx)(PI,{open:!0,onOpenChange:e=>{e||(p(),t())},children:(0,L.jsxs)(BI,{children:[(0,L.jsx)(HI,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(KI,{"aria-modal":`true`,"aria-describedby":void 0,className:`fixed left-1/2 top-1/2 z-[210] ${o?`w-[680px]`:`w-[440px]`} max-w-[92vw] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-panel p-5 shadow-2xl shadow-black/50 outline-none`,children:[(0,L.jsxs)(ZI,{className:`mb-1 text-[14px] font-medium`,children:[`Signed out of `,u]}),o?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`mb-3 text-[12.5px] leading-relaxed text-muted`,children:[`This terminal is running `,(0,L.jsx)(`code`,{className:`font-mono-keep text-fg/90`,children:l}),` — follow its prompts (it may open your browser). Frizz detects completion automatically.`]}),(0,L.jsx)(`div`,{className:`mb-4 h-[340px] overflow-hidden rounded-lg border border-border bg-[#0d0e10]`,children:(0,L.jsx)(I.Suspense,{fallback:(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center text-[12px] text-muted`,children:`Opening terminal…`}),children:(0,L.jsx)(kR,{slug:o})})}),(0,L.jsx)(`div`,{className:`flex items-center justify-end gap-2`,children:(0,L.jsx)(`button`,{type:`button`,onClick:()=>{p(),s(null)},className:`rounded-md px-3 py-1.5 text-[12.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg`,children:`Cancel sign-in`})})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`mb-4 text-[12.5px] leading-relaxed text-muted`,children:[`Frizz can't start a `,u,` thread until you're signed in. Sign in here, or run the command in your own terminal and retry:`]}),(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg border border-border bg-panel-2 px-3 py-2`,children:[(0,L.jsx)(`code`,{className:`flex-1 select-all font-mono-keep text-[12.5px] text-fg`,children:l}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,onClick:h,className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted outline-none transition-colors hover:bg-panel hover:text-fg`,children:i?(0,L.jsx)(Qp,{size:14,strokeWidth:2,className:`text-green-400`}):(0,L.jsx)(fm,{size:14,strokeWidth:1.8})})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md px-3 py-1.5 text-[12.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>g.mutate(),disabled:g.isPending,className:`flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-[12.5px] text-fg/90 outline-none transition-colors hover:bg-panel-2 disabled:opacity-60`,children:[g.isPending&&(0,L.jsx)(Mm,{size:13,className:`animate-spin`}),`Retry`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>d.mutate(),disabled:d.isPending,className:`flex items-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-[12.5px] font-medium text-white outline-none transition-opacity hover:opacity-90 disabled:opacity-60`,children:[d.isPending&&(0,L.jsx)(Mm,{size:13,className:`animate-spin`}),`Sign in here`]})]})]})]})]})})}function jR({backend:e,onClose:t}){let n=Ve(),r=DR[e],i=it({mutationFn:()=>Y.accountLogout({backend:e}),onSuccess:i=>{n.setQueryData([`authStatus`],t=>t&&{...t,[e]:i.auth}),i.status===`done`?Z(`Signed out of ${r}`):i.status===`blocked`?Z(`Not signed out — ${i.activeThreads} active ${r} thread${i.activeThreads===1?``:`s`}. Let them finish (or complete them) first.`,{duration:7e3}):Z(`${r} sign-out failed: ${i.detail??`unknown error`}`,{duration:7e3}),t()},onError:e=>{Z(`${r} sign-out failed: ${e.message.slice(0,80)}`,{duration:7e3}),t()}});return(0,L.jsx)(PI,{open:!0,onOpenChange:e=>{!e&&!i.isPending&&t()},children:(0,L.jsxs)(BI,{children:[(0,L.jsx)(HI,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(KI,{"aria-modal":`true`,"aria-describedby":void 0,className:`fixed left-1/2 top-1/2 z-[210] w-[420px] max-w-[86vw] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-panel p-5 shadow-2xl shadow-black/50 outline-none`,children:[(0,L.jsxs)(ZI,{className:`mb-1 text-[14px] font-medium`,children:[`Sign out of `,r,`?`]}),(0,L.jsxs)(`p`,{className:`mb-4 text-[12.5px] leading-relaxed text-muted`,children:[`New `,r,` threads will be blocked until you sign in again. Running `,r,` threads are left untouched — sign-out is refused while any are active.`]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:t,disabled:i.isPending,className:`rounded-md px-3 py-1.5 text-[12.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:opacity-60`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i.mutate(),disabled:i.isPending,className:`flex items-center gap-1.5 rounded-md bg-red-500/90 px-3 py-1.5 text-[12.5px] font-medium text-white outline-none transition-opacity hover:opacity-90 disabled:opacity-60`,children:[i.isPending&&(0,L.jsx)(Mm,{size:13,className:`animate-spin`}),`Sign out`]})]})]})]})})}var MR=mu.options,NR={auto:`Auto`,default:`Default`,acceptEdits:`Accept edits`,plan:`Plan`,bypassPermissions:`Bypass`},PR={auto:`auto — safe actions auto-approved, risky ones prompt`,default:`default — prompt for every permission`,acceptEdits:`accept edits — file edits auto-approved`,plan:`plan — read-only planning, approval before changes`,bypassPermissions:`bypass — never prompt (dangerous)`};MR.filter(e=>e!==`plan`).map(e=>({value:e,label:NR[e],title:PR[e]}));var FR=[`auto`,`bypassPermissions`].map(e=>({value:e,label:NR[e],title:PR[e]})),IR=[{value:`fable`,label:`Fable`},{value:`opus`,label:`Opus`},{value:`sonnet`,label:`Sonnet`},{value:`haiku`,label:`Haiku`}];new Set([{slug:`gpt-6-astra`,displayName:`GPT-6 Astra`,defaultEffort:`low`,efforts:[`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]},{slug:`gpt-5.6-sol`,displayName:`GPT-5.6 Sol`,defaultEffort:`medium`,efforts:[`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]},{slug:`gpt-5.6-terra`,displayName:`GPT-5.6 Terra`,defaultEffort:`medium`,efforts:[`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]},{slug:`gpt-5.6-luna`,displayName:`GPT-5.6 Luna`,defaultEffort:`medium`,efforts:[`low`,`medium`,`high`,`xhigh`,`max`]},{slug:`gpt-5.5`,displayName:`GPT-5.5`,defaultEffort:`medium`,efforts:[`low`,`medium`,`high`,`xhigh`]}].map(e=>e.slug));function LR(e){return e===`plan`?`auto`:e}var RR=[`low`,`medium`,`high`,`xhigh`,`max`],zR=`ultracode`,BR=new Set([`fable`,`opus`,`sonnet`]);function VR(e){return e&&BR.has(e)?[...RR,zR]:[...RR]}var HR={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-high`,max:`Max`,ultra:`Ultra`,ultracode:`Ultracode`};function UR(e){return HR[e]??e.charAt(0).toUpperCase()+e.slice(1)}function WR(e,t){let n=VR(e).map(e=>({value:e,label:UR(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function GR(e,t){let n=(e?.efforts??[]).map(e=>({value:e,label:UR(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function KR(e,t){return t.field===`backend`?{...e,backend:t.value}:t.field===`profile`?{...e,backend:t.backend,[t.backend]:{...e[t.backend],model:t.model,effort:t.effort}}:{...e,...t.field===`model`?{backend:t.backend}:{},[t.backend]:{...e[t.backend],[t.field]:t.value}}}function qR(e){return[{id:`claude`,label:`Claude Code`,options:IR.map(e=>({model:e.value,label:e.label,defaultEffort:`high`,efforts:VR(e.value)}))},{id:`codex`,label:`Codex`,options:e.map(e=>({model:e.slug,label:e.displayName,defaultEffort:e.defaultEffort,efforts:e.efforts}))}]}function JR(e,t){let n=e.backend,r=e[n],i=r.model??(n===`claude`?`opus`:t[0]?.slug??``),a=n===`codex`?t.find(e=>e.slug===i):void 0,o=n===`claude`?IR.some(e=>e.value===i):t.some(e=>e.slug===i),s=n===`claude`?`high`:a?.defaultEffort??``,c=r.effort??s,l=n===`claude`?WR(i,{withDefault:!1}):GR(a,{withDefault:!1}),u=l.some(e=>e.value===c);return{backend:n,model:i,effort:c,codexModel:a,modelAvailable:o,effortAvailable:u,effortOptions:c&&!u?[{value:c,label:`${c} (unavailable)`,title:`Saved reasoning level is not available for this model`},...l]:l}}function YR(){let e=Ve(),t=nt({queryKey:[`dispatchPreferencesGet`],queryFn:()=>Y.dispatchPreferencesGet()}),n=nt({queryKey:[`codexModels`],queryFn:()=>Y.codexModels()}),r=n.data??[],i=it({mutationFn:e=>Y.dispatchPreferenceSet(e),scope:{id:`dispatch-preferences`},onMutate:t=>{let n=e.getQueryData([`dispatchPreferencesGet`]);n&&e.setQueryData([`dispatchPreferencesGet`],KR(n,t))},onError:t=>{e.invalidateQueries({queryKey:[`dispatchPreferencesGet`]}),Z(`Could not save new-thread preference: ${t.message.slice(0,80)}`)}}),a=!!t.data&&!!n.data;return{resolved:(0,I.useMemo)(()=>a?JR(t.data,r):void 0,[a,t.data,r]),codexList:r,loadError:t.isError||n.isError,saveProfile:i.mutate}}var XR=`frizz-drafts:v1`,ZR=80,QR=512*1024,$R=2*1024*1024,ez=new TextEncoder;function tz(e){return ez.encode(e).byteLength}function nz(){return{version:1,entries:{}}}function rz(e){if(!e)return nz();try{let t=JSON.parse(e);if(!t||typeof t!=`object`||t.version!==1)return nz();let n=t.entries;if(!n||typeof n!=`object`||Array.isArray(n))return nz();let r={};for(let[e,t]of Object.entries(n))typeof t?.value!=`string`||typeof t?.touchedAt!=`number`||!Number.isFinite(t.touchedAt)||e.length>512||tz(t.value)>QR||(r[e]={value:t.value,touchedAt:t.touchedAt});return{version:1,entries:r}}catch{return nz()}}function iz(e){let t=Object.entries(e.entries).filter(([,e])=>e.value&&tz(e.value)<=QR).sort((e,t)=>t[1].touchedAt-e[1].touchedAt),n={};for(let[e,r]of t){if(Object.keys(n).length>=ZR)break;n[e]=r,tz(JSON.stringify({version:1,entries:n}))>$R&&delete n[e]}return{version:1,entries:n}}var az=new class{snapshot;listeners=new Set;storage;constructor(e=typeof sessionStorage>`u`?void 0:sessionStorage){this.storage=e;let t=null;try{t=e?.getItem(`frizz-drafts:v1`)??null}catch{}this.snapshot=iz(rz(t))}getSnapshot=()=>this.snapshot;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));get(e){return this.snapshot.entries[e]?.value??``}set(e,t){let n={...this.snapshot.entries};t?n[e]={value:t,touchedAt:Date.now()}:delete n[e],this.commit({version:1,entries:n})}clear(e){this.snapshot.entries[e]&&this.commit({version:1,entries:Object.fromEntries(Object.entries(this.snapshot.entries).filter(([t])=>t!==e))})}commit(e){this.snapshot=e;try{this.storage?.setItem(XR,JSON.stringify(iz(e)))}catch{}for(let e of this.listeners)e()}};function oz(e){return encodeURIComponent(e||`unresolved-project`)}var sz={dispatch:e=>`dispatch:${oz(e)}:new`,followUp:(e,t,n)=>`followup:${oz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}`,adopt:(e,t)=>`adopt:${oz(e)}:${encodeURIComponent(t)}`,answer:(e,t,n,r,i)=>`answer:${oz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}:${encodeURIComponent(r)}:${i}`,interaction:(e,t,n,r,i,a,o)=>`interaction:${oz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}:${i}:${encodeURIComponent(a)}:${encodeURIComponent(o)}`,question:(e,t,n,r)=>`question:${oz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}`};function cz(){return Zt(X).board?.projectDir}function lz(e){return Zt(X).board?.threads.find(t=>t.id===e)?.sessionId}function uz(e){let t=(0,I.useCallback)(()=>az.get(e),[e]);return[(0,I.useSyncExternalStore)(az.subscribe,t,t),(0,I.useCallback)(t=>az.set(e,t),[e]),(0,I.useCallback)(()=>az.clear(e),[e])]}function dz(e){let t=(0,I.useCallback)(()=>JSON.stringify(Object.fromEntries(e.map(e=>[e,az.get(e)]))),[e.join(`\0`)]),n=(0,I.useSyncExternalStore)(az.subscribe,t,t);return(0,I.useMemo)(()=>new Map(Object.entries(JSON.parse(n))),[n])}function fz({autoFocus:e,onDispatched:t}){let{resolved:n,codexList:r,loadError:i,saveProfile:a}=YR(),o=$L(),s=cz(),[c,l,u]=uz(sz.dispatch(s)),d=sz.dispatch(s),f=(0,I.useRef)(``),[p,m]=(0,I.useState)(null),h=nt({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4}),[g,_]=(0,I.useState)(null),[v,y]=(0,I.useState)(null),b=(0,I.useRef)(null),x=it({mutationFn:e=>Y.dispatch(e),onMutate:()=>Z(`Starting thread…`,{spinner:!0,sticky:!0}),onSuccess:e=>{m(null),t?.(),Z(`Thread started`,{link:{label:`Open thread`,slug:e.slug}})},onError:(e,t)=>{az.get(d)||l(f.current||t.prompt),m(null);let n=/^AUTH_REQUIRED:(claude|codex)$/.exec(e.message);if(n){b.current=t,_(n[1]),Z(`Signed out of ${n[1]===`claude`?`Claude`:`Codex`}`,{duration:3e3});return}Z(`Dispatch failed: ${e.message.slice(0,80)}`)}});function S(e){f.current=c,u(),m(e.prompt),x.mutate(e)}function C(){if(!c.trim()||!n)return;let e=OR(c);if(e){u(),e===`login`?(b.current=null,_(n.backend)):y(n.backend);return}if(!n.modelAvailable){Z(`Saved model is unavailable — choose a model before starting the thread`);return}if(!n.effortAvailable){Z(`Saved reasoning level is unavailable for this model — choose another level`);return}let t={prompt:c.trim(),model:n.model,backend:n.backend,effort:n.effort};if(h.data?.[n.backend]===`signed-out`){b.current=t,_(n.backend);return}S(t)}let w=(0,I.useMemo)(()=>n?(0,L.jsx)(CR,{groups:qR(r),value:{provider:n.backend,model:n.model,effort:n.effort},onValueChange:e=>a({field:`profile`,backend:e.provider,model:e.model,effort:e.effort}),ariaLabel:`Model and effort`,title:n.modelAvailable&&n.effortAvailable?`Model and reasoning effort`:`Saved model or reasoning effort unavailable — choose a supported pair`,className:`max-w-[min(21rem,72vw)]`}):(0,L.jsx)(CR,{groups:[],value:void 0,onValueChange:()=>{},placeholder:i?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort loading`,disabled:!0}),[n,r,i,a]);return(0,L.jsxs)(`div`,{className:`w-full flex flex-col gap-3`,children:[(0,L.jsx)(XL,{surface:`newComposer`,autoFocus:e,value:c,onChange:l,onSubmit:C,placeholder:`Describe the task…`,minHeight:96,maxHeight:340,busy:x.isPending,footer:w,leftAction:o?(0,L.jsx)(eR,{}):void 0}),x.isError&&(0,L.jsx)(`span`,{className:`px-0.5 text-[11px] text-red-400 truncate`,children:x.error.message}),p&&(0,L.jsxs)(`div`,{"data-pending-dispatch":!0,role:`status`,className:`rounded-lg border border-border bg-panel-2 px-3 py-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted`,children:[(0,L.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-accent`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{children:`Starting thread…`})]}),(0,L.jsx)(`p`,{className:`mt-1 line-clamp-2 whitespace-pre-wrap text-[12px] leading-relaxed text-fg`,children:p})]}),g&&(0,L.jsx)(AR,{backend:g,onClose:()=>_(null),onAuthed:()=>{let e=b.current;b.current=null,_(null),e&&S(e)}}),v&&(0,L.jsx)(jR,{backend:v,onClose:()=>y(null)})]})}function pz({onClose:e}){let t=(0,I.useRef)(null),n=(0,I.useRef)(typeof document<`u`&&document.activeElement instanceof HTMLElement?document.activeElement:null);return(0,I.useEffect)(()=>()=>{let e=n.current;window.setTimeout(()=>{e?.isConnected&&e.focus({preventScroll:!0})},0)},[]),(0,L.jsx)(PI,{open:!0,onOpenChange:t=>{t||e()},children:(0,L.jsxs)(BI,{children:[(0,L.jsx)(HI,{className:`fixed inset-0 z-50 bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(KI,{ref:t,"aria-modal":`true`,"aria-describedby":void 0,onEscapeKeyDown:xR,onCloseAutoFocus:e=>{e.preventDefault();let t=n.current;t?.isConnected&&t.focus({preventScroll:!0})},onOpenAutoFocus:e=>{e.preventDefault(),t.current?.querySelector(`textarea`)?.focus({preventScroll:!0})},className:`fixed left-1/2 top-1/2 z-50 w-[640px] max-w-[86vw] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-panel p-5 shadow-2xl shadow-black/50 outline-none max-[700px]:top-[calc(env(safe-area-inset-top)+56px)] max-[700px]:w-[calc(100vw-24px)] max-[700px]:max-w-none max-[700px]:translate-y-0`,children:[(0,L.jsx)(ZI,{className:`mb-1 text-[14px] font-medium`,children:`New thread`}),(0,L.jsx)(fz,{autoFocus:!0,onDispatched:e})]})]})})}function mz({children:e,onClose:t}){return(0,L.jsx)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center bg-black/30 backdrop-blur-md backdrop-saturate-150`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:e})}var hz=`-mx-1.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-fg/75 outline-none transition-colors hover:bg-elevated hover:text-fg focus-visible:ring-1 focus-visible:ring-border-strong disabled:opacity-55`,gz={claude:`size-[11px] translate-y-px`,codex:`size-[10px]`},_z={claude:{backend:`claude`,label:`Claude Code`},codex:{backend:`codex`,label:`OpenAI Codex`}};function vz(e){return e===`claude`||e===`codex`?_z[e]:void 0}function yz({backend:e,className:t}){let n=vz(e);return n?(0,L.jsx)(`span`,{role:`img`,"aria-label":n.label,className:`inline-flex shrink-0 text-muted/65 ${gz[n.backend]} ${t??``}`,children:n.backend===`codex`?(0,L.jsx)(bz,{}):(0,L.jsx)(xz,{})}):null}function bz(){return(0,L.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,L.jsx)(`path`,{d:`M22.282 9.821a6 6 0 0 0-.516-4.91a6.05 6.05 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a6 6 0 0 0-3.998 2.9a6.05 6.05 0 0 0 .743 7.097a5.98 5.98 0 0 0 .51 4.911a6.05 6.05 0 0 0 6.515 2.9A6 6 0 0 0 13.26 24a6.06 6.06 0 0 0 5.772-4.206a6 6 0 0 0 3.997-2.9a6.06 6.06 0 0 0-.747-7.073M13.26 22.43a4.48 4.48 0 0 1-2.876-1.04l.141-.081l4.779-2.758a.8.8 0 0 0 .392-.681v-6.737l2.02 1.168a.07.07 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494M3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085l4.783 2.759a.77.77 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646M2.34 7.896a4.5 4.5 0 0 1 2.366-1.973V11.6a.77.77 0 0 0 .388.677l5.815 3.354l-2.02 1.168a.08.08 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855l-5.833-3.387L15.119 7.2a.08.08 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667m2.01-3.023l-.141-.085l-4.774-2.782a.78.78 0 0 0-.785 0L9.409 9.23V6.897a.07.07 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135l-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.8.8 0 0 0-.393.681zm1.097-2.365l2.602-1.5l2.607 1.5v2.999l-2.597 1.5l-2.607-1.5Z`})})}function xz(){return(0,L.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,L.jsx)(`path`,{d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`})})}typeof window<`u`&&window.document&&window.document.createElement;function Sz(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)}}function Cz(e,t=[]){let n=[];function r(t,r){let i=I.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=I.useMemo(()=>o,Object.values(o));return(0,L.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=I.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>I.createContext(e));return function(n){let r=n?.[e]||t;return I.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,wz(i,...t)]}function wz(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return I.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var Tz=`DismissableLayer`,Ez=`dismissableLayer.update`,Dz=`dismissableLayer.pointerDownOutside`,Oz=`dismissableLayer.focusOutside`,kz,Az=I.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),jz=I.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=I.useContext(Az),[d,f]=I.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=I.useState({}),h=aD(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=_?g.indexOf(_):-1,y=d?g.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,S=I.useRef(!1),C=Fz(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:I.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return x&&!t},[u.branches,x])}),w=Iz(e=>{if(r&&S.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),T=d?y===g.length-1:!1,E=CD(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return I.useEffect(()=>{if(T)return p.addEventListener(`keydown`,E,{capture:!0}),()=>p.removeEventListener(`keydown`,E,{capture:!0})},[p,T,E]),I.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(kz=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Lz(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=kz))}},[d,p,n,u]),I.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Lz())},[d,u]),I.useEffect(()=>{let e=()=>m({});return document.addEventListener(Ez,e),()=>document.removeEventListener(Ez,e)},[]),(0,L.jsx)(xD.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:Sz(e.onFocusCapture,w.onFocusCapture),onBlurCapture:Sz(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:Sz(e.onPointerDownCapture,C.onPointerDownCapture)})});jz.displayName=Tz;var Mz=`DismissableLayerBranch`,Nz=I.forwardRef((e,t)=>{let n=I.useContext(Az),r=I.useRef(null),i=aD(t,r);return I.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,L.jsx)(xD.div,{...e,ref:i})});Nz.displayName=Mz;var Pz=()=>!0;function Fz(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Pz}=t,s=CD(e),c=I.useRef(!1),l=I.useRef(!1),u=I.useRef(new Map),d=I.useRef(()=>{});return I.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}function t(){return Array.from(u.current.values()).some(Boolean)}function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}function p(e){l.current&&u.current.set(e.type,!1)}let m=a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||Rz(Dz,s,p,{discrete:!0})};if(!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:()=>c.current=!0}}function Iz(e,t=globalThis?.document){let n=CD(e),r=I.useRef(!1);return I.useEffect(()=>{let e=e=>{e.target&&!r.current&&Rz(Oz,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Lz(){let e=new CustomEvent(Ez);document.dispatchEvent(e)}function Rz(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?SD(i,a):i.dispatchEvent(a)}var zz=`focusScope.autoFocusOnMount`,Bz=`focusScope.autoFocusOnUnmount`,Vz={bubbles:!1,cancelable:!0},Hz=`FocusScope`,Uz=I.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=I.useState(null),l=CD(i),u=CD(a),d=I.useRef(null),f=aD(t,c),p=I.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;I.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:Xz(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Xz(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Xz(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),I.useEffect(()=>{if(s){Zz.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(zz,Vz);s.addEventListener(zz,l),s.dispatchEvent(t),t.defaultPrevented||(Wz(eB(Kz(s)),{select:!0}),document.activeElement===e&&Xz(s))}return()=>{s.removeEventListener(zz,l),setTimeout(()=>{let t=new CustomEvent(Bz,Vz);s.addEventListener(Bz,u),s.dispatchEvent(t),t.defaultPrevented||Xz(e??document.body,{select:!0}),s.removeEventListener(Bz,u),Zz.remove(p)},0)}}},[s,l,u,p]);let m=I.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=Gz(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Xz(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Xz(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,L.jsx)(xD.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});Uz.displayName=Hz;function Wz(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Xz(r,{select:t}),document.activeElement!==n)return}function Gz(e){let t=Kz(e);return[qz(t,e),qz(t.reverse(),e)]}function Kz(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function qz(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Jz(r,{upTo:t})))return r}function Jz(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Yz(e){return e instanceof HTMLInputElement&&`select`in e}function Xz(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Yz(e)&&t&&e.select()}}var Zz=Qz();function Qz(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=$z(e,t),e.unshift(t)},remove(t){e=$z(e,t),e[0]?.resume()}}}function $z(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function eB(e){return e.filter(e=>e.tagName!==`A`)}var tB=`Popper`,[nB,rB]=Cz(tB),[iB,aB]=nB(tB),oB=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null),[a,o]=I.useState(void 0);return(0,L.jsx)(iB,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};oB.displayName=tB;var sB=`PopperAnchor`,cB=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=aB(sB,n),o=I.useRef(null),s=a.onAnchorChange,c=aD(t,I.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=I.useRef(null);I.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&vB(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,L.jsx)(xD.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})});cB.displayName=sB;var lB=`PopperContent`,[uB,dB]=nB(lB),fB=I.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=aB(lB,n),[_,v]=I.useState(null),y=aD(t,v),[b,x]=I.useState(null),S=oA(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(gB),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=Jk({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>Pk(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[Xk({mainAxis:i+w,alignmentAxis:o}),c&&Zk({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Qk():void 0,...k}),c&&$k({...k}),eA({...k,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&nA({element:b,padding:s}),_B({arrowWidth:C,arrowHeight:w}),f&&tA({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ee=g.setPlacementState;wD(()=>(ee(M),()=>{ee(void 0)}),[M,ee]);let[F,te]=vB(M),ne=CD(m);wD(()=>{N&&ne?.()},[N,ne]);let re=P.arrow?.x,ie=P.arrow?.y,ae=P.arrow?.centerOffset!==0,[oe,se]=I.useState();return wD(()=>{_&&se(window.getComputedStyle(_).zIndex)},[_]),(0,L.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:N?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,L.jsx)(uB,{scope:n,placedSide:F,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,L.jsx)(xD.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});fB.displayName=lB;var pB=`PopperArrow`,mB={top:`bottom`,right:`left`,bottom:`top`,left:`right`},hB=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=dB(pB,n),a=mB[i.placedSide];return(0,L.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,L.jsx)(aA,{...r,ref:t,style:{...r.style,display:`block`}})})});hB.displayName=pB;function gB(e){return e!==null}var _B=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=vB(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function vB(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var yB=oB,bB=cB,xB=fB,SB=hB;function CB(e,t){return I.useReducer((e,n)=>t[e][n]??e,e)}var wB=e=>{let{present:t,children:n}=e,r=TB(t),i=typeof n==`function`?n({present:r.isPresent}):I.Children.only(n),a=DB(r.ref,kB(i));return typeof n==`function`||r.isPresent?I.cloneElement(i,{ref:a}):null};wB.displayName=`Presence`;function TB(e){let[t,n]=I.useState(),r=I.useRef(null),i=I.useRef(e),a=I.useRef(`none`),o=I.useRef(void 0),[s,c]=CB(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return I.useEffect(()=>{s===`mounted`?(a.current=o.current??OB(r.current),o.current=void 0):a.current=`none`},[s]),wD(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=OB(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),wD(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=OB(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},s=e=>{e.target===t&&(a.current=OB(r.current))};return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:I.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=OB(t)}else r.current=null;n(e)},[])}}function EB(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function DB(...e){let t=I.useRef(e);return t.current=e,I.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=EB(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():EB(n[e],null)}}},[])}function OB(e){return e?.animationName||`none`}function kB(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var AB=`Popover`,[jB,MB]=Cz(AB,[rB]),NB=rB(),[PB,FB]=jB(AB),IB=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=NB(t),c=I.useRef(null),[l,u]=I.useState(!1),[d,f]=zA({prop:r,defaultProp:i??!1,onChange:a,caller:AB});return(0,L.jsx)(yB,{...s,children:(0,L.jsx)(PB,{scope:t,contentId:WD(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:I.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:I.useCallback(()=>u(!0),[]),onCustomAnchorRemove:I.useCallback(()=>u(!1),[]),modal:o,children:n})})};IB.displayName=AB;var LB=`PopoverAnchor`,RB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=FB(LB,n),a=NB(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return I.useEffect(()=>(o(),()=>s()),[o,s]),(0,L.jsx)(bB,{...a,...r,ref:t})});RB.displayName=LB;var zB=`PopoverTrigger`,BB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=FB(zB,n),a=NB(n),o=aD(t,i.triggerRef),s=(0,L.jsx)(xD.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":tV(i.open),...r,ref:o,onClick:Sz(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,L.jsx)(bB,{asChild:!0,...a,children:s})});BB.displayName=zB;var VB=`PopoverPortal`,[HB,UB]=jB(VB,{forceMount:void 0}),WB=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=FB(VB,t);return(0,L.jsx)(HB,{scope:t,forceMount:n,children:(0,L.jsx)(wB,{present:n||a.open,children:(0,L.jsx)(AA,{asChild:!0,container:i,children:r})})})};WB.displayName=VB;var GB=`PopoverContent`,KB=I.forwardRef((e,t)=>{let n=UB(GB,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=FB(GB,e.__scopePopover);return(0,L.jsx)(wB,{present:r||a.open,children:a.modal?(0,L.jsx)(JB,{...i,ref:t}):(0,L.jsx)(YB,{...i,ref:t})})});KB.displayName=GB;var qB=cD(`PopoverContent.RemoveScroll`),JB=I.forwardRef((e,t)=>{let n=FB(GB,e.__scopePopover),r=I.useRef(null),i=aD(t,r),a=I.useRef(!1);return I.useEffect(()=>{let e=r.current;if(e)return BM(e)},[]),(0,L.jsx)(YN,{as:qB,allowPinchZoom:!0,children:(0,L.jsx)(XB,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Sz(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Sz(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:Sz(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),YB=I.forwardRef((e,t)=>{let n=FB(GB,e.__scopePopover),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(XB,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),XB=I.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=FB(GB,n),p=NB(n);return qj(),(0,L.jsx)(Uz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(jz,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,L.jsx)(xB,{"data-state":tV(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),ZB=`PopoverClose`,QB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=FB(ZB,n);return(0,L.jsx)(xD.button,{type:`button`,...r,ref:t,onClick:Sz(e.onClick,()=>i.onOpenChange(!1))})});QB.displayName=ZB;var $B=`PopoverArrow`,eV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=NB(n);return(0,L.jsx)(SB,{...i,...r,ref:t})});eV.displayName=$B;function tV(e){return e?`open`:`closed`}var nV=IB,rV=RB,iV=BB,aV=WB,oV=KB;function sV({modal:e=!1,...t}){return(0,L.jsx)(nV,{modal:e,...t})}var cV=iV,lV=rV;function uV({children:e,side:t=`top`,align:n=`center`,sideOffset:r=6,className:i=``,...a}){return(0,L.jsx)(aV,{children:(0,L.jsx)(oV,{side:t,align:n,sideOffset:r,avoidCollisions:!0,collisionPadding:12,onEscapeKeyDown:e=>e.stopPropagation(),className:`${Mj} ${Ij} rounded-lg outline-none ${i}`,...a,children:e})})}var dV=3e4,fV=45e3;function pV(e,t){return t?AbortSignal.any([t,AbortSignal.timeout(e)]):AbortSignal.timeout(e)}var mV=`text-[9px]`,hV={claude:`text-fg/75! size-[14px]! translate-y-0!`,codex:`text-fg/75! size-[12.75px]! translate-y-0!`};function gV(){let e=nt({queryKey:[`quota`],queryFn:()=>Y.quota(),staleTime:1e4}),t=nt({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4});return[`claude`,`codex`].some(n=>_V(e.data?.[n],t.data?.[n],e.isLoading))}function _V(e,t,n){return t===`signed-out`||!e&&n?!1:!!e&&e.status===`ok`&&e.windows.length>0}function vV(){let e=Ve(),t=(0,I.useRef)(null),[n,r]=(0,I.useState)(!1),i=nt({queryKey:[`quota`],queryFn:({signal:e})=>Y.quota(void 0,{signal:pV(dV,e)}),refetchInterval:e=>{let t=e.state.data;return!t||t.claude.status!==`ok`||t.codex.status!==`ok`?15e3:3e4},staleTime:1e4,refetchOnWindowFocus:!0}),a=nt({queryKey:[`authStatus`],queryFn:({signal:e})=>Y.authStatus(void 0,{signal:pV(dV,e)}),refetchInterval:12e4,staleTime:3e4,refetchOnWindowFocus:!0}),o=n=>{if(t.current)return;r(!0);let i=Promise.all([Y.quota({force:n===`claude`},{signal:pV(fV)}).then(t=>e.setQueryData([`quota`],t)),e.refetchQueries({queryKey:[`authStatus`]})]).then(()=>{}).catch(()=>{}).finally(()=>{t.current=null,r(!1)});t.current=i};return(0,L.jsxs)(`div`,{"data-quota-bar":!0,className:`flex shrink-0 items-center gap-3 ${mV}`,children:[(0,L.jsx)(yV,{backend:`claude`,quota:i.data?.claude,auth:a.data?.claude,email:a.data?.emails?.claude,loading:i.isLoading,fetching:i.isFetching||n,onRecheck:()=>o(`claude`)}),(0,L.jsx)(yV,{backend:`codex`,quota:i.data?.codex,auth:a.data?.codex,email:a.data?.emails?.codex,loading:i.isLoading,fetching:i.isFetching||n,onRecheck:()=>o(`codex`)})]})}function yV({backend:e,quota:t,auth:n,email:r,loading:i,fetching:a,onRecheck:o}){let s=DR[e];if(!_V(t,n,i))return null;let c=bV(100-SV(t.windows).usedPercent);return(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(sV,{onOpenChange:e=>{e&&o()},children:[(0,L.jsx)(cV,{asChild:!0,children:(0,L.jsxs)(`button`,{type:`button`,"aria-label":`${s} quota: ${c}% remaining`,className:`flex items-center gap-1.5 min-w-0 rounded outline-none transition-opacity hover:opacity-80 focus-visible:ring-1 focus-visible:ring-border-strong`,children:[(0,L.jsx)(yz,{backend:e,className:hV[e]}),(0,L.jsxs)(`span`,{className:`tabular-nums ${CV(c)}`,children:[c,`%`]})]})}),(0,L.jsxs)(uV,{side:`bottom`,align:`start`,className:`w-[min(15rem,calc(100vw-1.5rem))] p-3 text-[11px] leading-relaxed text-fg`,children:[(0,L.jsxs)(`div`,{className:`mb-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,L.jsx)(yz,{backend:e}),(0,L.jsx)(`span`,{children:s}),t?.planType&&(0,L.jsxs)(`span`,{className:`text-muted/70`,children:[`· `,wV(t.planType),` plan`]}),a&&(0,L.jsx)(Mm,{size:11,className:`animate-spin text-muted/60`,"aria-label":`Rechecking`})]}),r&&(0,L.jsx)(`div`,{"data-quota-account":!0,className:`truncate text-muted/70 select-text`,title:r,children:r})]}),(0,L.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[t.windows.map(e=>{let t=bV(100-e.usedPercent),n=TV(e);return(0,L.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsx)(`span`,{className:`text-muted/80`,children:e.label}),(0,L.jsxs)(`span`,{className:`flex items-center gap-2 tabular-nums`,children:[(0,L.jsxs)(`span`,{className:CV(t),children:[t,`% left`]}),n&&(0,L.jsxs)(`span`,{className:`text-muted/55`,children:[`resets `,n]})]})]},e.key)}),t.detail&&(0,L.jsx)(`li`,{className:`pt-1 text-muted/55`,children:t.detail})]})]})]})})}function bV(e){return Math.max(0,Math.min(100,Math.round(e)))}var xV=25;function SV(e){return e.find(e=>e.key===`5h`)??e.reduce((e,t)=>t.usedPercent>e.usedPercent?t:e)}function CV(e){return e<=8?`text-red-400`:e<=xV?`text-accent`:`text-fg/70`}function wV(e){return e&&e[0].toUpperCase()+e.slice(1)}function TV(e){if(!e.resetsAt)return null;let t=e.resetsAt*1e3,n=new Date(t);if(Number.isNaN(n.getTime()))return null;let r=t-Date.now();if(r<=0)return null;if(r<24*36e5){let e=n.getHours(),t=n.getMinutes(),r=e>=12?`pm`:`am`;return e=e%12||12,t===0?`${e}${r}`:`${e}:${String(t).padStart(2,`0`)}${r}`}return n.toLocaleDateString(void 0,{weekday:`short`})}var EV=`frizz:supervisor-status-wake`;function DV(e){return e!==null}function OV(e){return e?.updateRestart===!0&&e.updateAvailable!==!1}function kV(e){return e?.dev===!0}async function AV(e=fetch){try{let t=await e(`/_frizz/control/status`,{headers:{"cache-control":`no-store`}});if(!t.ok||!t.headers.get(`content-type`)?.includes(`application/json`))return null;let n=await t.json();return n.protocol===1&&(n.state===`ready`||n.state===`restarting`||n.state===`failed`)?n:null}catch{return null}}async function jV(e,t){let n=await t(e,{method:`POST`,headers:{"cache-control":`no-store`}}),r;try{r=await n.json()}catch{}if(!n.headers.get(`content-type`)?.includes(`application/json`)||!r||r.protocol!==1||r.state!==`ready`&&r.state!==`restarting`&&r.state!==`failed`)throw Error(`Frizz restart controls are unavailable for this server`);if(!n.ok)throw Error(r.message??`Restart request failed (${n.status})`);if(r.state===`failed`)throw Error(r.message??`Frizz did not become ready`);return r}function MV(e=fetch){return jV(`/_frizz/control/restart`,e)}function NV(e=fetch){return jV(`/_frizz/control/update-restart`,e)}var PV=8e3,FV=500,IV=[`supervisorStatus`];function LV(e,t){return e===`restarting`||t?FV:PV}var RV=rt({queryKey:IV,queryFn:()=>AV(),refetchInterval:e=>LV(e.state.data?.state,X.controlPlaneRestartPending),staleTime:e=>LV(e.state.data?.state,X.controlPlaneRestartPending)});function zV(){return nt(RV)}var BV=null;function VV(e){BV||(BV=e,window.addEventListener(EV,()=>{e.refetchQueries({queryKey:IV,exact:!0})}))}var HV=`Install the latest version of Frizz. Your running threads will not be affected.`,UV=`A newer version of Frizz is available. Your running threads will not be affected.`,WV=`Restart Frizz. Your running threads will not be affected.`,GV=`fixed left-3 right-3 top-12 z-50 w-auto text-left font-sans sm:absolute sm:right-auto sm:-left-[17px] sm:top-[calc(100%+0.65rem)]`,KV=`absolute -top-[7px] left-4 h-3 w-3 rotate-45 border-l border-t bg-elevated`,qV=`sm:w-[min(23rem,calc(100vw-1.5rem))]`,JV=`sm:w-[min(34rem,calc(100vw-1.5rem))]`,YV=`rounded-xl bg-elevated p-3.5 shadow-xl shadow-black/45`;function XV({open:e,update:t,version:n,updateVersion:r}){if(!e)return null;let i=t?`Update Frizz`:`Restart Frizz`,a=t?r:void 0;return(0,L.jsxs)(`div`,{id:`update-restart-popover`,role:`tooltip`,"aria-label":i,className:`${GV} ${qV} ${YV} border border-border-strong`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${KV} border-border-strong`}),(0,L.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,L.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-fg/10 text-fg`,children:(0,L.jsx)(Gm,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,L.jsx)(`span`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:i}),n&&(0,L.jsx)(`span`,{className:`font-mono text-[11px] leading-snug text-muted`,children:a?`${n} → ${a}`:n})]})]}),(0,L.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:t?a?UV:HV:WV})]})}var ZV=`Frizz kept running the previous version, and your threads are unaffected.`;function QV({update:e,message:t,onDismiss:n}){return(0,L.jsxs)(`div`,{role:`alert`,className:`${GV} ${JV} ${YV} border border-red-500/45`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${KV} border-red-500/45`}),(0,L.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,L.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-red-500/15 text-red-300`,children:(0,L.jsx)(rh,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,L.jsx)(`span`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:e?`Update failed`:`Restart failed`}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,onClick:n,className:`-mr-1 ml-auto flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-border-strong`,children:(0,L.jsx)(ah,{"aria-hidden":`true`,size:14,strokeWidth:2.25})})]}),(0,L.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:ZV}),(0,L.jsx)(`pre`,{className:`relative mt-2.5 max-h-64 overflow-y-auto whitespace-pre-wrap break-words rounded-md border border-border bg-panel px-2.5 py-2 font-mono text-[11px] leading-relaxed text-fg/70`,children:t})]})}function $V({update:e,busy:t,updateVersion:n,onFocus:r,onBlur:i,onClick:a}){return(0,L.jsxs)(`button`,{type:`button`,"aria-describedby":`update-restart-popover`,"aria-label":e?`Update Frizz`:`Restart Frizz`,disabled:t,"aria-busy":t||void 0,className:`relative ${hz}`,onFocus:r,onBlur:i,onClick:a,children:[(0,L.jsx)(Gm,{size:14,"aria-hidden":`true`,className:t?`animate-spin`:void 0}),e&&!t&&n&&(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-[2px] top-[2px] h-[4px] w-[4px] rounded-full bg-accent`})]})}function eH(){let e=Zt(X),[t,n]=(0,I.useState)(!1),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(),[s,c]=(0,I.useState)(),l=(0,I.useRef)(!1),u=(0,I.useRef)(null),d=zV().data??null,f=OV(d),p={version:d?.version,updateVersion:d?.updateVersion};if(!DV(d))return null;let m=l.current&&e.controlPlaneState===`failed`?e.controlPlaneMessage??`Frizz did not become ready`:void 0,h=a??m,g=h&&h!==s?h:void 0,_=async()=>{if(r)return;l.current=!0,n(!1),i(!0),o(void 0),c(void 0);let e=`${window.location.pathname}${window.location.search}${window.location.hash}`;f&&(X.controlPlaneState=`restarting`,X.controlPlaneMessage=null,X.controlPlaneRestartPending=!0);try{f?await NV():await MV(),f?(sessionStorage.setItem(`frizz:reload-after-update-restart`,e),window.dispatchEvent(new Event(EV)),i(!1)):window.location.replace(e)}catch(e){f&&(X.controlPlaneRestartPending=!1,X.controlPlaneState=`ready`,X.controlPlaneMessage=null);let t=e.message.slice(0,140);i(!1),o(t),Z(`${f?`Update & Restart`:`Restart Frizz`} failed`)}};return(0,L.jsxs)(`div`,{ref:u,className:`relative`,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[(0,L.jsx)($V,{update:f,busy:r,updateVersion:p.updateVersion,onFocus:()=>n(!0),onBlur:()=>n(!1),onClick:()=>void _()}),g&&(0,L.jsx)(QV,{update:f,message:g,onDismiss:()=>c(g)}),(0,L.jsx)(XV,{open:t&&!g,update:f,version:p.version,updateVersion:p.updateVersion})]})}function tH(){return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px shrink-0 bg-border`})}function nH({text:e,title:t,className:n}){return(0,L.jsx)(`span`,{dir:`rtl`,className:`block min-w-0 overflow-hidden text-ellipsis whitespace-nowrap ${n??``}`,title:t,children:(0,L.jsx)(`span`,{dir:`ltr`,className:`[unicode-bidi:isolate]`,children:e})})}function rH(){let e=kC(),t=IU(e),n=gV(),r=e?.githubRepo??null,i=t.state===`verified`?t.label:t.state===`local`?t.name:null,a=t.state===`verified`?`Project: ${t.label}`:t.state===`local`?`Project: ${t.name}; local repository with no git remote`:t.state===`loading`?`Project identity loading`:`Project identity unavailable`;return(0,L.jsxs)(`div`,{"data-status-row":!0,className:`mb-2.5 flex min-w-0 items-center gap-3 text-[12px]`,children:[(0,L.jsx)(fb,{to:`/`,title:`All projects`,"aria-label":`All projects`,className:`${hz} -ml-px`,children:(0,L.jsx)(Em,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(tH,{}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Settings`,title:`Settings`,className:hz,onClick:()=>X.showSettings=!0,children:(0,L.jsx)(Ym,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(eH,{}),n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(tH,{}),(0,L.jsx)(vV,{})]}),(0,L.jsx)(`span`,{className:`ml-auto flex min-w-0 items-center`,"data-project-identity-state":t.state,"aria-label":a,"aria-busy":t.state===`loading`||void 0,children:i&&r?(0,L.jsx)(`a`,{href:`https://github.com/${r}`,target:`_blank`,rel:`noopener`,title:`Open ${i} on GitHub`,"aria-label":`Open ${i} on GitHub`,className:`block min-w-0 rounded-sm font-semibold text-fg/90 underline-offset-2 outline-none transition-colors hover:text-fg hover:underline focus-visible:ring-1 focus-visible:ring-border-strong`,children:(0,L.jsx)(nH,{text:i})}):i?(0,L.jsx)(nH,{text:i,title:i,className:`font-semibold text-fg/90`}):(0,L.jsx)(`span`,{className:`identity-placeholder w-24`,"aria-hidden":`true`})})]})}var iH=qt({at:{}}),aH=12e3,oH=new Map;function sH(e,t=Date.now()){iH.at[e]=t;let n=oH.get(e);n!==void 0&&clearTimeout(n),oH.set(e,setTimeout(()=>{oH.delete(e),delete iH.at[e]},aH))}function cH(e){let t=oH.get(e);t!==void 0&&(clearTimeout(t),oH.delete(e)),delete iH.at[e]}function lH(e,t,n=Date.now()){if(t===void 0||n-t>12e3)return!1;let r=e.lastActivityAt?Date.parse(e.lastActivityAt):NaN;return!(Number.isFinite(r)&&r>t)}function uH(){return Zt(iH).at}function dH(e,t,n=Date.now()){return t===void 0||!lH(e,t,n)?e:{...e,runtime:`running`,needsYou:!1,pendingAsk:void 0,pendingQuestion:!1,actionableInteraction:!1,lastUserAt:new Date(t).toISOString()}}function fH(e){let t=uH();return(0,I.useMemo)(()=>e.map(e=>dH(e,t[e.id])),[e,t])}var pH=0;function mH(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(pH+=1,`browser-${Date.now()}-${pH}`)}function hH({optimistic:e,request:t,success:n,failure:r}){e(),t().then(()=>n?.(),e=>r(e instanceof Error?e:Error(String(e))))}var gH=new Map;function _H(e,t){let n=(gH.get(e)??Promise.resolve()).then(t,t);return gH.set(e,n.then(()=>{},()=>{})),n}var vH=[300,800,1800,3500],yH=12e4,bH=e=>new Promise(t=>{setTimeout(t,e)});async function xH(e,t,n=bH){for(let r=0;;r++){try{await e()}catch(e){if(r>=vH.length||!lf(e))throw e;t(),await n(vH[r]);continue}t();return}}function SH(e,t,n,r,i,a=yH){let o=new AbortController,s=setTimeout(()=>o.abort(Error(`Frizz did not answer this send`)),a);return Y.followUp({slug:e,sessionId:Dp(X.board,e)?.sessionId??``,message:t,deliveryId:n,freshProcess:r,interrupt:i},{signal:o.signal}).finally(()=>clearTimeout(s))}function CH(e,t,n,r,i){return xH(()=>SH(e,t,n,r,i),()=>sH(e))}function wH(e,t,n,r={}){let i=n.trim();if(!i)return!1;let a=mH();return hH({optimistic:()=>{r.onOptimistic?.(),qC(e,t,i,{scrollToBottom:r.scrollToBottom,deliveryId:a}),sH(t),Y.markRead({slug:t}).catch(()=>{})},request:()=>_H(t,()=>CH(t,i,a,r.freshProcess,r.interrupt)),success:()=>r.onSuccess?.(),failure:n=>{JC(e,t,i,a),cH(t),r.onRollback?.(),Z(r.failureToast?.(n.message)??`Steer failed — ${n.message.slice(0,90)}`)}}),!0}function TH(e){let t=Ve(),[n,r]=(0,I.useState)(0);return{submit:(0,I.useCallback)((n,i={})=>wH(t,e,n,{...i,onOptimistic:()=>{r(e=>e+1),i.onOptimistic?.()},onSuccess:()=>{r(e=>Math.max(0,e-1)),i.onSuccess?.()},onRollback:()=>{r(e=>Math.max(0,e-1)),i.onRollback?.()}}),[t,e]),pending:n>0}}function EH(e,t){return new Promise(n=>{wH(e,t,`Continue exactly where you left off.`,{onSuccess:()=>{Z(`Retrying…`),n()},onRollback:()=>n(),failureToast:e=>`Retry failed: ${e.slice(0,80)}`})||n()})}function DH(e){let t=/^([A-Za-z0-9][\w.-]*)\/([A-Za-z0-9][\w.-]*)#(\d+)$/.exec(e.trim());return t?`https://github.com/${t[1]}/${t[2]}/pull/${t[3]}`:null}var OH=`Waiting for an external update.`;function kH(e){let t=new Set;return e.flatMap(e=>{if(e.kind!==`pr`)return[];let n=e.value.trim();return!n||t.has(n)?[]:(t.add(n),[{ref:n,url:DH(n)}])})}function AH(e){let t=(e.body??``).split(/\n\s*\n/).map(e=>e.trim()).find(Boolean);return t?NH(jH(t.replace(/\s*\n\s*/g,` `))):null}function jH(e){if(e.length<=MH)return e;let t=e.slice(0,MH),n=t.lastIndexOf(` `);return`${(n>MH/2?t.slice(0,n):t).replace(/[.,;:]$/,``)}…`}var MH=240;function NH(e){let t=(e.split(/\s/,1)[0]??``).replace(/[.,:;]+$/,``);return/[^a-zA-Z]/.test(t)||/[A-Z]/.test(t.slice(1))||PH.has(t)?e:e.charAt(0).toUpperCase()+e.slice(1)}var PH=new Set([`npm`,`npx`,`pnpm`,`nub`,`nubx`,`gh`,`git`,`node`,`bun`,`tsc`,`vite`,`curl`,`ssh`]);function FH(e){return e&&LH(e)||null}var IH=new Set([...rl,`shells`,`agents`,`timers`,`prs`,`for`,`title`]);function LH(e){return e.split(`
199
+ `+e.slice(r)),requestAnimationFrame(()=>t.setSelectionRange(n+1,n+1)))})}e.key===`Escape`&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.stopPropagation(),t.blur())}return(0,L.jsxs)(`div`,{className:`group relative rounded-xl border bg-bg transition-colors focus-within:border-accent ${v?`border-dashed border-accent`:`border-border`}`,onDragOver:e=>{[...e.dataTransfer.items].some(e=>e.kind===`file`)&&(e.preventDefault(),y(!0))},onDragLeave:()=>y(!1),onDrop:e=>{e.preventDefault(),y(!1),O(e.dataTransfer.files)},children:[v&&(0,L.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-bg/80 text-[12px] text-muted`,children:`Drop file to attach`}),se&&(0,L.jsx)(`div`,{ref:le,"data-slash-menu":!0,className:`absolute bottom-full left-0 right-0 z-20 mb-1.5 max-h-56 overflow-y-auto rounded-lg border border-border bg-bg py-1 shadow-lg`,children:oe.map((e,t)=>(0,L.jsxs)(`button`,{type:`button`,"data-suggest-index":t,onMouseDown:e=>e.preventDefault(),onClick:()=>ue(e),onMouseEnter:()=>ne(t),className:`flex w-full items-baseline gap-2 px-3.5 py-1.5 text-left ${t===te?`bg-panel-2`:``}`,children:[(0,L.jsxs)(`span`,{className:`shrink-0 text-[12px] font-medium text-fg`,children:[`/`,e.name]}),e.description&&(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-muted`,children:e.description}),ce.length>0&&(0,L.jsxs)(`span`,{className:`ml-auto grid shrink-0 text-[10px]`,children:[ce.map(e=>(0,L.jsx)(`span`,{"aria-hidden":!0,className:`petite-caps invisible col-start-1 row-start-1`,children:e},e)),(0,L.jsx)(`span`,{className:`petite-caps col-start-1 row-start-1 text-right text-muted/70`,children:e.source?JL[e.source]:``})]})]},e.name))}),(0,L.jsxs)(`div`,{className:`relative`,children:[A&&(0,L.jsx)(`div`,{ref:g,"aria-hidden":!0,"data-composer-context-backdrop":!0,className:`pointer-events-none absolute inset-0 select-none overflow-hidden whitespace-pre-wrap [overflow-wrap:break-word] px-3.5 ${u?`py-2.5 pb-3`:`py-2.5 ${fe?`pr-[6.6875rem]`:`pr-20`}`} text-[13px] leading-relaxed text-transparent`,children:A}),(0,L.jsx)(`textarea`,{id:a,ref:h,onScroll:A?j:void 0,"data-surface":r,value:S,autoFocus:c,disabled:l,onChange:e=>E(e.target.value),onKeyDown:pe,onPaste:e=>{let t=[...e.clipboardData.items].filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(Boolean);t.length&&(e.preventDefault(),O(t))},placeholder:i,rows:1,spellCheck:!1,style:{minHeight:o,maxHeight:s},className:`relative block w-full resize-none bg-transparent px-3.5 ${u?`py-2.5 pb-3`:`py-2.5 ${fe?GL:KL}`} text-[13px] leading-relaxed text-fg outline-none placeholder:text-muted scrollbar-none disabled:opacity-60`})]}),C.length>0&&(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-3 pb-2 ${fe?`pr-[6.6875rem]`:`pr-20`}`,children:C.map((e,t)=>(0,L.jsx)(ZL,{attachment:e,disabled:l,onRemove:()=>D(w.filter((e,n)=>n!==t))},`${e.path}-${t}`))}),u&&(0,L.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1 pl-1.5 pb-1.5 ${fe?`pr-[6.6875rem]`:`pr-20`}`,children:u}),fe&&(0,L.jsx)(`div`,{className:`absolute bottom-2 right-[43px] flex items-center`,children:fe}),(0,L.jsx)(`input`,{ref:_,type:`file`,multiple:!0,accept:Hc,className:`hidden`,onChange:e=>{O(e.target.files),e.target.value=``}}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>_.current?.click(),disabled:l||b,title:`Attach files`,"aria-label":`Attach files`,className:`absolute bottom-2 ${fe?UL:WL} flex h-7 w-7 items-center justify-center rounded-lg text-muted transition-[color,background-color] enabled:hover:bg-panel-2/70 enabled:hover:text-fg disabled:opacity-50`,children:b?(0,L.jsx)(Mm,{size:15,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(Bm,{size:15,strokeWidth:2})}),(0,L.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:n,disabled:!de||l||b,title:`Send (Enter · ⌘⏎ sends now)`,"aria-label":`Send`,className:`absolute bottom-2 ${HL} flex h-7 w-7 items-center justify-center rounded-lg transition-all ${de&&!l&&!b?`bg-fg text-bg hover:opacity-90 active:scale-95`:`bg-panel-2 text-muted`}`,children:l?(0,L.jsx)(Mm,{size:14,strokeWidth:2.5,className:`animate-spin`}):(0,L.jsx)(Jp,{size:14,strokeWidth:2.5})})]})}function ZL({attachment:e,disabled:t,onRemove:n}){let[r,i]=(0,I.useState)(!1),a=e.path.split(`/`).filter(Boolean).pop()||e.path,o=(a.includes(`.`)?a.split(`.`).pop():``).toUpperCase();return(0,L.jsxs)(`div`,{className:`group/att relative h-11 w-11`,title:a,children:[e.kind===`image`&&!r?(0,L.jsx)(`img`,{src:jS(e.path),alt:a,onError:()=>i(!0),className:`h-11 w-11 rounded-md border border-border object-cover`}):(0,L.jsxs)(`div`,{className:`flex h-11 w-11 flex-col items-center justify-center gap-0.5 rounded-md border border-border bg-panel-2 px-1`,children:[(0,L.jsx)(gm,{size:15,strokeWidth:2,className:`shrink-0 text-muted`}),o&&(0,L.jsx)(`span`,{className:`-mx-1 max-w-[calc(100%+0.5rem)] truncate text-[8px] font-medium leading-none text-muted/80`,children:o})]}),(0,L.jsx)(`button`,{type:`button`,onClick:n,disabled:t,title:`Remove ${a}`,"aria-label":`Remove ${a}`,className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full border border-border bg-bg text-muted opacity-0 transition-opacity hover:text-fg focus-visible:opacity-100 group-hover/att:opacity-100 disabled:hidden`,children:(0,L.jsx)(ah,{size:10,strokeWidth:2.5})})]})}function QL(){return nt({queryKey:[`githubStatus`],queryFn:()=>Y.githubStatus(),staleTime:3e4,refetchOnWindowFocus:!0,refetchInterval:e=>{let t=e.state.data;return t?.inRepo&&t.authed?!1:6e4}})}function $L(){let e=QL();return!!(e.data?.inRepo&&e.data.authed)}function eR({className:e=``}){return $L()?(0,L.jsx)(`button`,{type:`button`,onClick:Gf,onMouseDown:e=>e.preventDefault(),title:`Investigate this issue and make recommendations`,"aria-label":`Investigate this issue and make recommendations`,className:`flex h-7 w-7 items-center justify-center rounded-lg text-muted outline-none transition-[color,background-color,box-shadow] enabled:hover:bg-panel-2/70 enabled:hover:text-fg enabled:focus-visible:bg-panel-2/70 enabled:focus-visible:text-muted enabled:focus-visible:ring-1 enabled:focus-visible:ring-muted/80 enabled:focus-visible:ring-offset-1 enabled:focus-visible:ring-offset-bg enabled:active:bg-elevated enabled:active:text-muted disabled:bg-transparent disabled:text-muted/35 ${e}`,children:(0,L.jsx)(wm,{size:15,strokeWidth:2})}):null}var tR=`prompt-control-type petite-caps`,nR=tR,rR=tR,iR=`profile-grid-cell relative flex h-6 cursor-pointer select-none items-center justify-start rounded border border-transparent px-1 text-left text-muted outline-none transition-colors ${nR} data-[highlighted]:border-border data-[highlighted]:bg-panel-2 data-[highlighted]:text-fg data-[highlighted]:outline data-[highlighted]:outline-1 data-[highlighted]:outline-offset-1 data-[highlighted]:outline-fg/55 data-[state=checked]:border-accent/70 data-[state=checked]:bg-accent/10 data-[state=checked]:font-medium data-[state=checked]:text-fg data-[state=checked]:ring-1 data-[state=checked]:ring-inset data-[state=checked]:ring-accent/90`;function aR(e){return`minmax(6rem, 7rem) repeat(${Math.max(0,e)}, auto)`}var oR=[`ultra`,`ultracode`],sR=[`low`,`medium`,`high`,`xhigh`,`max`,...oR];function cR(e){return[...new Set(e.flatMap(e=>e.options.flatMap(e=>e.efforts)))].sort((e,t)=>{let n=sR.indexOf(e),r=sR.indexOf(t);return n===-1&&r===-1?e.localeCompare(t):n===-1?1:r===-1?-1:n-r})}function lR(e){let t=[];for(let n of cR(e)){let e=oR.includes(n)?t.find(e=>oR.includes(e[0])):void 0;e?e.push(n):t.push([n])}return t}function uR(e){return e.flatMap(e=>e.options.flatMap(t=>t.efforts.map(n=>({provider:e.id,model:t.model,effort:n}))))}function dR(e){return JSON.stringify([e.provider,e.model,e.effort])}function fR(e,t){return uR(e).find(e=>dR(e)===t)}function pR(e,t){return!t?.model||!t.effort?!1:e.some(e=>(!t.provider||e.id===t.provider)&&e.options.some(e=>e.model===t.model&&e.efforts.includes(t.effort)))}function mR(e,t,n=`Profile unknown`){if(!t?.model&&!t?.effort)return n;let r=e.flatMap(e=>e.options).find(e=>e.model===t.model)?.label??t.model??`Model unknown`;return t.effort?`${r} › ${t.effort}`:r}function hR(e,t,n){let r=lR(e),i=e=>r.findIndex(t=>t.includes(e)),a=e.flatMap(e=>e.options.map(t=>({provider:e.id,option:t}))),o=a.findIndex(e=>e.provider===t.provider&&e.option.model===t.model);if(o===-1)return null;let s=a[o],c=s.option.efforts.indexOf(t.effort);if(c===-1)return null;if(n===`Home`||n===`End`||n===`ArrowLeft`||n===`ArrowRight`){let e=n===`Home`?0:n===`End`?s.option.efforts.length-1:c+(n===`ArrowLeft`?-1:1),t=s.option.efforts[e];return t?{provider:s.provider,model:s.option.model,effort:t}:null}let l=a[o+(n===`ArrowUp`?-1:1)];if(!l)return null;let u=i(t.effort),d=l.option.efforts.reduce((e,t)=>e?Math.abs(i(t)-u)<Math.abs(i(e)-u)?t:e:t,void 0);return d?{provider:l.provider,model:l.option.model,effort:d}:null}var gR,_R=!1;function vR(){_R||typeof window>`u`||(_R=!0,window.addEventListener(`keydown`,e=>{e.key!==`Escape`||!gR||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),bR())},{capture:!0}))}function yR(e){vR();let t={dismiss:e};return gR=t,()=>{gR===t&&(gR=void 0)}}function bR(){let e=gR;return e?(gR=void 0,e.dismiss(),!0):!1}function xR(e){bR()&&e.preventDefault(),e.stopPropagation()}function SR(e){return e===`xhigh`?`X-high`:e.charAt(0).toUpperCase()+e.slice(1)}function CR({groups:e,value:t,pending:n,onValueChange:r,placeholder:i,ariaLabel:a,menuAriaLabel:o=`Choose model and effort`,title:s,disabled:c=!1,compact:l=!1,side:u=`bottom`,menuZClass:d=Nj,className:f=``}){let[p,m]=(0,I.useState)(!1),h=(0,I.useRef)(p),g=(0,I.useRef)(c),_=(0,I.useRef)(void 0),v=(0,I.useRef)(new Map),y=(0,I.useRef)(void 0),b=(0,I.useMemo)(()=>lR(e),[e]),x=(0,I.useMemo)(()=>e.flatMap(e=>e.options.flatMap(t=>t.efforts.map(n=>({provider:e.id,model:t.model,effort:n})))),[e]),S=l?rR:nR,C=c?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors hover:border-border hover:bg-panel-2 hover:text-fg`,w=pR(e,t),T=w&&t?.provider&&t.model&&t.effort?dR(t):void 0,E=n?.model||n?.effort?mR(e,n,`Pending profile`):void 0;h.current=p,g.current=c;function D(){h.current=!1,_.current=void 0,m(!1)}(0,I.useLayoutEffect)(()=>{let e=e=>{e.key!==`Escape`||!h.current||g.current||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),_.current?.(),D())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]),(0,I.useLayoutEffect)(()=>{!c||!p||(_.current?.(),D())},[c,p]),(0,I.useLayoutEffect)(()=>()=>_.current?.(),[]),(0,I.useLayoutEffect)(()=>{T===y.current&&(y.current=void 0)},[T]);function O(e){let t=dR(e);y.current!==t&&(y.current=t,r(e))}function k(t,n){if(![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(t.key))return;let r=hR(e,n,t.key);r&&(t.preventDefault(),t.stopPropagation(),v.current.get(dR(r))?.focus())}return(0,L.jsxs)(fI,{modal:!1,open:p,onOpenChange:e=>{_.current?.(),_.current=void 0,h.current=e,m(e),e&&(_.current=yR(D))},children:[(0,L.jsx)(pI,{asChild:!0,disabled:c,children:(0,L.jsxs)(`button`,{type:`button`,"aria-label":a,"aria-invalid":!w&&(t?.model||t?.effort)?!0:void 0,"aria-description":E?`Pending ${E}`:void 0,title:s,"data-profile-known":w?`true`:`false`,"data-profile-pending":E?`true`:void 0,className:`profile-grid-trigger group inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md border border-border/50 bg-transparent px-2 py-1 text-left text-muted outline-none data-[state=open]:border-border data-[state=open]:bg-panel-2 ${C} ${f} ${S}`,children:[(0,L.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 flex-1 truncate text-left ${S}`,children:mR(e,t,i)}),E&&(0,L.jsx)(Mm,{"aria-hidden":`true`,size:l?10:11,className:`shrink-0 animate-spin text-muted/65`}),(0,L.jsx)($p,{"aria-hidden":`true`,size:l?11:13,className:`shrink-0 text-fg/65 transition-transform group-data-[state=open]:rotate-180`})]})}),(0,L.jsx)(mI,{children:(0,L.jsxs)(hI,{"aria-label":o,align:`start`,side:u,sideOffset:5,collisionPadding:8,onEscapeKeyDown:e=>e.stopPropagation(),className:`profile-grid-menu ${d} ${Mj} max-h-[min(360px,var(--radix-dropdown-menu-content-available-height))] max-w-[calc(100vw-1rem)] overflow-auto rounded-lg p-1.5 ${S}`,children:[e.map(t=>(0,L.jsxs)(gI,{children:[t.label&&(0,L.jsx)(_I,{className:`px-1.5 pb-1 pt-1 text-left font-medium tracking-[0.07em] text-muted/55 first:pt-0.5`,children:t.label}),(0,L.jsx)(yI,{value:T,onValueChange:t=>{let n=fR(e,t);n&&O(n)},children:t.options.map(e=>(0,L.jsxs)(`div`,{"data-profile-grid-row":e.model,className:`grid w-max items-center gap-1 py-0.5`,style:{gridTemplateColumns:aR(b.length)},children:[(0,L.jsx)(`span`,{className:`profile-grid-model-label min-w-0 max-w-[9.5rem] truncate px-1.5 text-left text-muted ${S}`,title:e.label,children:e.label}),b.map(n=>{let r=n.find(t=>e.efforts.includes(t)),i=n.reduce((e,t)=>SR(t).length>SR(e).length?t:e);if(!r)return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`invisible cursor-default border border-transparent px-1 text-left font-medium ${S}`,children:SR(i)},i);let a={provider:t.id,model:e.model,effort:r},o=dR(a);return(0,L.jsx)(bI,{value:o,ref:e=>{e?v.current.set(o,e):v.current.delete(o)},onKeyDown:e=>k(e,a),onSelect:e=>{e.preventDefault(),O(a),_.current?.(),D()},"aria-label":`${e.label}, ${SR(r)} effort`,title:`${e.label} › ${SR(r)}`,className:iR,children:(0,L.jsxs)(`span`,{className:`grid`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`invisible col-start-1 row-start-1 font-medium`,children:SR(r)}),(0,L.jsx)(`span`,{className:`col-start-1 row-start-1`,children:SR(r)})]})},r)})]},e.model))}),t!==e.at(-1)&&(0,L.jsx)(SI,{className:`my-1 h-px bg-border`})]},t.id)),x.length===0&&(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-muted/60`,children:`No profiles available`})]})})]})}async function wR(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(!TR(e))throw Error(`the browser blocked clipboard access`)}function TR(e){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`0`,t.style.left=`0`,t.style.opacity=`0`,document.body.append(t);let n=document.getSelection(),r=n&&n.rangeCount>0?n.getRangeAt(0):null;t.select(),t.setSelectionRange(0,e.length);let i=!1;try{i=document.execCommand(`copy`)}catch{i=!1}return t.remove(),r&&n&&(n.removeAllRanges(),n.addRange(r)),i}var ER={claude:`claude auth login`,codex:`codex login`},DR={claude:`Claude`,codex:`Codex`};function OR(e){let t=e.trim();return t===`/login`?`login`:t===`/logout`?`logout`:null}var kR=(0,I.lazy)(()=>By(()=>import(`./TerminalPane-BLyRh8S1.js`).then(e=>({default:e.TerminalPane})),__vite__mapDeps([0,1])));function AR({backend:e,onClose:t,onAuthed:n}){let r=Ve(),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(null),c=(0,I.useRef)(!1),l=ER[e],u=DR[e],d=it({mutationFn:()=>Y.accountLoginStart({backend:e}),onSuccess:e=>{c.current=!1,s(e.attemptId)},onError:e=>Z(`Couldn't start the sign-in terminal: ${e.message.slice(0,80)} — use the command below instead`,{duration:7e3})}),f=nt({queryKey:[`accountLoginStatus`,o],queryFn:()=>Y.accountLoginStatus({attemptId:o}),enabled:!!o,refetchInterval:2e3});(0,I.useEffect)(()=>{if(!o||c.current)return;let t=f.data;if(!(!t||t.state===`running`||t.state===`unknown`)){if(c.current=!0,t.auth!==`signed-out`){r.setQueryData([`authStatus`],n=>n&&{...n,[e]:t.auth}),Z(`Signed in to ${u}`),n();return}Z(`${u} sign-in didn't complete — try again or use the command below`,{duration:7e3}),s(null)}},[o,f.data,e,u]);function p(){o&&!c.current&&Y.accountLoginCancel({attemptId:o}).catch(()=>{})}let m=(0,I.useRef)({attempt:null,settled:!1});m.current={attempt:o,settled:c.current},(0,I.useEffect)(()=>()=>{let{attempt:e,settled:t}=m.current;e&&!t&&Y.accountLoginCancel({attemptId:e}).catch(()=>{})},[]);async function h(){try{await wR(l),a(!0),window.setTimeout(()=>a(!1),1500)}catch{Z(`Couldn't copy — select the command and copy it manually`,{duration:6e3})}}let g=it({mutationFn:()=>Y.authStatus(),onSuccess:t=>{if(r.setQueryData([`authStatus`],t),t[e]===`signed-out`){Z(`Still signed out of ${u} — run the command, then retry`,{duration:6e3});return}n()},onError:()=>n()});return(0,L.jsx)(PI,{open:!0,onOpenChange:e=>{e||(p(),t())},children:(0,L.jsxs)(BI,{children:[(0,L.jsx)(HI,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(KI,{"aria-modal":`true`,"aria-describedby":void 0,className:`fixed left-1/2 top-1/2 z-[210] ${o?`w-[680px]`:`w-[440px]`} max-w-[92vw] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-panel p-5 shadow-2xl shadow-black/50 outline-none`,children:[(0,L.jsxs)(ZI,{className:`mb-1 text-[14px] font-medium`,children:[`Signed out of `,u]}),o?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`mb-3 text-[12.5px] leading-relaxed text-muted`,children:[`This terminal is running `,(0,L.jsx)(`code`,{className:`font-mono-keep text-fg/90`,children:l}),` — follow its prompts (it may open your browser). Frizz detects completion automatically.`]}),(0,L.jsx)(`div`,{className:`mb-4 h-[340px] overflow-hidden rounded-lg border border-border bg-[#0d0e10]`,children:(0,L.jsx)(I.Suspense,{fallback:(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center text-[12px] text-muted`,children:`Opening terminal…`}),children:(0,L.jsx)(kR,{slug:o})})}),(0,L.jsx)(`div`,{className:`flex items-center justify-end gap-2`,children:(0,L.jsx)(`button`,{type:`button`,onClick:()=>{p(),s(null)},className:`rounded-md px-3 py-1.5 text-[12.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg`,children:`Cancel sign-in`})})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`mb-4 text-[12.5px] leading-relaxed text-muted`,children:[`Frizz can't start a `,u,` thread until you're signed in. Sign in here, or run the command in your own terminal and retry:`]}),(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg border border-border bg-panel-2 px-3 py-2`,children:[(0,L.jsx)(`code`,{className:`flex-1 select-all font-mono-keep text-[12.5px] text-fg`,children:l}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,onClick:h,className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted outline-none transition-colors hover:bg-panel hover:text-fg`,children:i?(0,L.jsx)(Qp,{size:14,strokeWidth:2,className:`text-green-400`}):(0,L.jsx)(fm,{size:14,strokeWidth:1.8})})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md px-3 py-1.5 text-[12.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>g.mutate(),disabled:g.isPending,className:`flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-[12.5px] text-fg/90 outline-none transition-colors hover:bg-panel-2 disabled:opacity-60`,children:[g.isPending&&(0,L.jsx)(Mm,{size:13,className:`animate-spin`}),`Retry`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>d.mutate(),disabled:d.isPending,className:`flex items-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-[12.5px] font-medium text-white outline-none transition-opacity hover:opacity-90 disabled:opacity-60`,children:[d.isPending&&(0,L.jsx)(Mm,{size:13,className:`animate-spin`}),`Sign in here`]})]})]})]})]})})}function jR({backend:e,onClose:t}){let n=Ve(),r=DR[e],i=it({mutationFn:()=>Y.accountLogout({backend:e}),onSuccess:i=>{n.setQueryData([`authStatus`],t=>t&&{...t,[e]:i.auth}),i.status===`done`?Z(`Signed out of ${r}`):i.status===`blocked`?Z(`Not signed out — ${i.activeThreads} active ${r} thread${i.activeThreads===1?``:`s`}. Let them finish (or complete them) first.`,{duration:7e3}):Z(`${r} sign-out failed: ${i.detail??`unknown error`}`,{duration:7e3}),t()},onError:e=>{Z(`${r} sign-out failed: ${e.message.slice(0,80)}`,{duration:7e3}),t()}});return(0,L.jsx)(PI,{open:!0,onOpenChange:e=>{!e&&!i.isPending&&t()},children:(0,L.jsxs)(BI,{children:[(0,L.jsx)(HI,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(KI,{"aria-modal":`true`,"aria-describedby":void 0,className:`fixed left-1/2 top-1/2 z-[210] w-[420px] max-w-[86vw] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-panel p-5 shadow-2xl shadow-black/50 outline-none`,children:[(0,L.jsxs)(ZI,{className:`mb-1 text-[14px] font-medium`,children:[`Sign out of `,r,`?`]}),(0,L.jsxs)(`p`,{className:`mb-4 text-[12.5px] leading-relaxed text-muted`,children:[`New `,r,` threads will be blocked until you sign in again. Running `,r,` threads are left untouched — sign-out is refused while any are active.`]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:t,disabled:i.isPending,className:`rounded-md px-3 py-1.5 text-[12.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:opacity-60`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i.mutate(),disabled:i.isPending,className:`flex items-center gap-1.5 rounded-md bg-red-500/90 px-3 py-1.5 text-[12.5px] font-medium text-white outline-none transition-opacity hover:opacity-90 disabled:opacity-60`,children:[i.isPending&&(0,L.jsx)(Mm,{size:13,className:`animate-spin`}),`Sign out`]})]})]})]})})}var MR=mu.options,NR={auto:`Auto`,default:`Default`,acceptEdits:`Accept edits`,plan:`Plan`,bypassPermissions:`Bypass`},PR={auto:`auto — safe actions auto-approved, risky ones prompt`,default:`default — prompt for every permission`,acceptEdits:`accept edits — file edits auto-approved`,plan:`plan — read-only planning, approval before changes`,bypassPermissions:`bypass — never prompt (dangerous)`};MR.filter(e=>e!==`plan`).map(e=>({value:e,label:NR[e],title:PR[e]}));var FR=[`auto`,`bypassPermissions`].map(e=>({value:e,label:NR[e],title:PR[e]})),IR=[{value:`fable`,label:`Fable`},{value:`opus`,label:`Opus`},{value:`sonnet`,label:`Sonnet`},{value:`haiku`,label:`Haiku`}];new Set([{slug:`gpt-6-astra`,displayName:`GPT-6 Astra`,defaultEffort:`low`,efforts:[`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]},{slug:`gpt-5.6-sol`,displayName:`GPT-5.6 Sol`,defaultEffort:`medium`,efforts:[`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]},{slug:`gpt-5.6-terra`,displayName:`GPT-5.6 Terra`,defaultEffort:`medium`,efforts:[`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]},{slug:`gpt-5.6-luna`,displayName:`GPT-5.6 Luna`,defaultEffort:`medium`,efforts:[`low`,`medium`,`high`,`xhigh`,`max`]},{slug:`gpt-5.5`,displayName:`GPT-5.5`,defaultEffort:`medium`,efforts:[`low`,`medium`,`high`,`xhigh`]}].map(e=>e.slug));function LR(e){return e===`plan`?`auto`:e}var RR=[`low`,`medium`,`high`,`xhigh`,`max`],zR=`ultracode`,BR=new Set([`fable`,`opus`,`sonnet`]);function VR(e){return e&&BR.has(e)?[...RR,zR]:[...RR]}var HR={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-high`,max:`Max`,ultra:`Ultra`,ultracode:`Ultracode`};function UR(e){return HR[e]??e.charAt(0).toUpperCase()+e.slice(1)}function WR(e,t){let n=VR(e).map(e=>({value:e,label:UR(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function GR(e,t){let n=(e?.efforts??[]).map(e=>({value:e,label:UR(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function KR(e,t){return t.field===`backend`?{...e,backend:t.value}:t.field===`profile`?{...e,backend:t.backend,[t.backend]:{...e[t.backend],model:t.model,effort:t.effort}}:{...e,...t.field===`model`?{backend:t.backend}:{},[t.backend]:{...e[t.backend],[t.field]:t.value}}}function qR(e){return[{id:`claude`,label:`Claude Code`,options:IR.map(e=>({model:e.value,label:e.label,defaultEffort:`high`,efforts:VR(e.value)}))},{id:`codex`,label:`Codex`,options:e.map(e=>({model:e.slug,label:e.displayName,defaultEffort:e.defaultEffort,efforts:e.efforts}))}]}function JR(e,t){let n=e.backend,r=e[n],i=r.model??(n===`claude`?`opus`:t[0]?.slug??``),a=n===`codex`?t.find(e=>e.slug===i):void 0,o=n===`claude`?IR.some(e=>e.value===i):t.some(e=>e.slug===i),s=n===`claude`?`high`:a?.defaultEffort??``,c=r.effort??s,l=n===`claude`?WR(i,{withDefault:!1}):GR(a,{withDefault:!1}),u=l.some(e=>e.value===c);return{backend:n,model:i,effort:c,codexModel:a,modelAvailable:o,effortAvailable:u,effortOptions:c&&!u?[{value:c,label:`${c} (unavailable)`,title:`Saved reasoning level is not available for this model`},...l]:l}}function YR(){let e=Ve(),t=nt({queryKey:[`dispatchPreferencesGet`],queryFn:()=>Y.dispatchPreferencesGet()}),n=nt({queryKey:[`codexModels`],queryFn:()=>Y.codexModels()}),r=n.data??[],i=it({mutationFn:e=>Y.dispatchPreferenceSet(e),scope:{id:`dispatch-preferences`},onMutate:t=>{let n=e.getQueryData([`dispatchPreferencesGet`]);n&&e.setQueryData([`dispatchPreferencesGet`],KR(n,t))},onError:t=>{e.invalidateQueries({queryKey:[`dispatchPreferencesGet`]}),Z(`Could not save new-thread preference: ${t.message.slice(0,80)}`)}}),a=!!t.data&&!!n.data;return{resolved:(0,I.useMemo)(()=>a?JR(t.data,r):void 0,[a,t.data,r]),codexList:r,loadError:t.isError||n.isError,saveProfile:i.mutate}}var XR=`frizz-drafts:v1`,ZR=80,QR=512*1024,$R=2*1024*1024,ez=new TextEncoder;function tz(e){return ez.encode(e).byteLength}function nz(){return{version:1,entries:{}}}function rz(e){if(!e)return nz();try{let t=JSON.parse(e);if(!t||typeof t!=`object`||t.version!==1)return nz();let n=t.entries;if(!n||typeof n!=`object`||Array.isArray(n))return nz();let r={};for(let[e,t]of Object.entries(n))typeof t?.value!=`string`||typeof t?.touchedAt!=`number`||!Number.isFinite(t.touchedAt)||e.length>512||tz(t.value)>QR||(r[e]={value:t.value,touchedAt:t.touchedAt});return{version:1,entries:r}}catch{return nz()}}function iz(e){let t=Object.entries(e.entries).filter(([,e])=>e.value&&tz(e.value)<=QR).sort((e,t)=>t[1].touchedAt-e[1].touchedAt),n={};for(let[e,r]of t){if(Object.keys(n).length>=ZR)break;n[e]=r,tz(JSON.stringify({version:1,entries:n}))>$R&&delete n[e]}return{version:1,entries:n}}var az=new class{snapshot;listeners=new Set;storage;constructor(e=typeof sessionStorage>`u`?void 0:sessionStorage){this.storage=e;let t=null;try{t=e?.getItem(`frizz-drafts:v1`)??null}catch{}this.snapshot=iz(rz(t))}getSnapshot=()=>this.snapshot;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));get(e){return this.snapshot.entries[e]?.value??``}set(e,t){let n={...this.snapshot.entries};t?n[e]={value:t,touchedAt:Date.now()}:delete n[e],this.commit({version:1,entries:n})}clear(e){this.snapshot.entries[e]&&this.commit({version:1,entries:Object.fromEntries(Object.entries(this.snapshot.entries).filter(([t])=>t!==e))})}commit(e){this.snapshot=e;try{this.storage?.setItem(XR,JSON.stringify(iz(e)))}catch{}for(let e of this.listeners)e()}};function oz(e){return encodeURIComponent(e||`unresolved-project`)}var sz={dispatch:e=>`dispatch:${oz(e)}:new`,followUp:(e,t,n)=>`followup:${oz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}`,adopt:(e,t)=>`adopt:${oz(e)}:${encodeURIComponent(t)}`,answer:(e,t,n,r,i)=>`answer:${oz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}:${encodeURIComponent(r)}:${i}`,interaction:(e,t,n,r,i,a,o)=>`interaction:${oz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}:${i}:${encodeURIComponent(a)}:${encodeURIComponent(o)}`,question:(e,t,n,r)=>`question:${oz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}`};function cz(){return Zt(X).board?.projectDir}function lz(e){return Zt(X).board?.threads.find(t=>t.id===e)?.sessionId}function uz(e){let t=(0,I.useCallback)(()=>az.get(e),[e]);return[(0,I.useSyncExternalStore)(az.subscribe,t,t),(0,I.useCallback)(t=>az.set(e,t),[e]),(0,I.useCallback)(()=>az.clear(e),[e])]}function dz(e){let t=(0,I.useCallback)(()=>JSON.stringify(Object.fromEntries(e.map(e=>[e,az.get(e)]))),[e.join(`\0`)]),n=(0,I.useSyncExternalStore)(az.subscribe,t,t);return(0,I.useMemo)(()=>new Map(Object.entries(JSON.parse(n))),[n])}function fz({autoFocus:e,onDispatched:t}){let{resolved:n,codexList:r,loadError:i,saveProfile:a}=YR(),o=$L(),s=cz(),[c,l,u]=uz(sz.dispatch(s)),d=sz.dispatch(s),f=(0,I.useRef)(``),[p,m]=(0,I.useState)(null),h=nt({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4}),[g,_]=(0,I.useState)(null),[v,y]=(0,I.useState)(null),b=(0,I.useRef)(null),x=it({mutationFn:e=>Y.dispatch(e),onMutate:()=>Z(`Starting thread…`,{spinner:!0,sticky:!0}),onSuccess:e=>{m(null),t?.(),Z(`Thread started`,{link:{label:`Open thread`,slug:e.slug}})},onError:(e,t)=>{az.get(d)||l(f.current||t.prompt),m(null);let n=/^AUTH_REQUIRED:(claude|codex)$/.exec(e.message);if(n){b.current=t,_(n[1]),Z(`Signed out of ${n[1]===`claude`?`Claude`:`Codex`}`,{duration:3e3});return}Z(`Dispatch failed: ${e.message.slice(0,80)}`)}});function S(e){f.current=c,u(),m(e.prompt),x.mutate(e)}function C(){if(!c.trim()||!n)return;let e=OR(c);if(e){u(),e===`login`?(b.current=null,_(n.backend)):y(n.backend);return}if(!n.modelAvailable){Z(`Saved model is unavailable — choose a model before starting the thread`);return}if(!n.effortAvailable){Z(`Saved reasoning level is unavailable for this model — choose another level`);return}let t={prompt:c.trim(),model:n.model,backend:n.backend,effort:n.effort};if(h.data?.[n.backend]===`signed-out`){b.current=t,_(n.backend);return}S(t)}let w=(0,I.useMemo)(()=>n?(0,L.jsx)(CR,{groups:qR(r),value:{provider:n.backend,model:n.model,effort:n.effort},onValueChange:e=>a({field:`profile`,backend:e.provider,model:e.model,effort:e.effort}),ariaLabel:`Model and effort`,title:n.modelAvailable&&n.effortAvailable?`Model and reasoning effort`:`Saved model or reasoning effort unavailable — choose a supported pair`,className:`max-w-[min(21rem,72vw)]`}):(0,L.jsx)(CR,{groups:[],value:void 0,onValueChange:()=>{},placeholder:i?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort loading`,disabled:!0}),[n,r,i,a]);return(0,L.jsxs)(`div`,{className:`w-full flex flex-col gap-3`,children:[(0,L.jsx)(XL,{surface:`newComposer`,autoFocus:e,value:c,onChange:l,onSubmit:C,placeholder:`Describe the task…`,minHeight:96,maxHeight:340,busy:x.isPending,footer:w,leftAction:o?(0,L.jsx)(eR,{}):void 0}),x.isError&&(0,L.jsx)(`span`,{className:`px-0.5 text-[11px] text-red-400 truncate`,children:x.error.message}),p&&(0,L.jsxs)(`div`,{"data-pending-dispatch":!0,role:`status`,className:`rounded-lg border border-border bg-panel-2 px-3 py-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted`,children:[(0,L.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-accent`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{children:`Starting thread…`})]}),(0,L.jsx)(`p`,{className:`mt-1 line-clamp-2 whitespace-pre-wrap text-[12px] leading-relaxed text-fg`,children:p})]}),g&&(0,L.jsx)(AR,{backend:g,onClose:()=>_(null),onAuthed:()=>{let e=b.current;b.current=null,_(null),e&&S(e)}}),v&&(0,L.jsx)(jR,{backend:v,onClose:()=>y(null)})]})}function pz({onClose:e}){let t=(0,I.useRef)(null),n=(0,I.useRef)(typeof document<`u`&&document.activeElement instanceof HTMLElement?document.activeElement:null);return(0,I.useEffect)(()=>()=>{let e=n.current;window.setTimeout(()=>{e?.isConnected&&e.focus({preventScroll:!0})},0)},[]),(0,L.jsx)(PI,{open:!0,onOpenChange:t=>{t||e()},children:(0,L.jsxs)(BI,{children:[(0,L.jsx)(HI,{className:`fixed inset-0 z-50 bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(KI,{ref:t,"aria-modal":`true`,"aria-describedby":void 0,onEscapeKeyDown:xR,onCloseAutoFocus:e=>{e.preventDefault();let t=n.current;t?.isConnected&&t.focus({preventScroll:!0})},onOpenAutoFocus:e=>{e.preventDefault(),t.current?.querySelector(`textarea`)?.focus({preventScroll:!0})},className:`fixed left-1/2 top-1/2 z-50 w-[640px] max-w-[86vw] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-panel p-5 shadow-2xl shadow-black/50 outline-none max-[700px]:top-[calc(env(safe-area-inset-top)+56px)] max-[700px]:w-[calc(100vw-24px)] max-[700px]:max-w-none max-[700px]:translate-y-0`,children:[(0,L.jsx)(ZI,{className:`mb-1 text-[14px] font-medium`,children:`New thread`}),(0,L.jsx)(fz,{autoFocus:!0,onDispatched:e})]})]})})}function mz({children:e,onClose:t}){return(0,L.jsx)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center bg-black/30 backdrop-blur-md backdrop-saturate-150`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:e})}var hz=`-mx-1.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-fg/75 outline-none transition-colors hover:bg-elevated hover:text-fg focus-visible:ring-1 focus-visible:ring-border-strong disabled:opacity-55`,gz={claude:`size-[11px] translate-y-px`,codex:`size-[10px]`},_z={claude:{backend:`claude`,label:`Claude Code`},codex:{backend:`codex`,label:`OpenAI Codex`}};function vz(e){return e===`claude`||e===`codex`?_z[e]:void 0}function yz({backend:e,className:t}){let n=vz(e);return n?(0,L.jsx)(`span`,{role:`img`,"aria-label":n.label,className:`inline-flex shrink-0 text-muted/65 ${gz[n.backend]} ${t??``}`,children:n.backend===`codex`?(0,L.jsx)(bz,{}):(0,L.jsx)(xz,{})}):null}function bz(){return(0,L.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,L.jsx)(`path`,{d:`M22.282 9.821a6 6 0 0 0-.516-4.91a6.05 6.05 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a6 6 0 0 0-3.998 2.9a6.05 6.05 0 0 0 .743 7.097a5.98 5.98 0 0 0 .51 4.911a6.05 6.05 0 0 0 6.515 2.9A6 6 0 0 0 13.26 24a6.06 6.06 0 0 0 5.772-4.206a6 6 0 0 0 3.997-2.9a6.06 6.06 0 0 0-.747-7.073M13.26 22.43a4.48 4.48 0 0 1-2.876-1.04l.141-.081l4.779-2.758a.8.8 0 0 0 .392-.681v-6.737l2.02 1.168a.07.07 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494M3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085l4.783 2.759a.77.77 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646M2.34 7.896a4.5 4.5 0 0 1 2.366-1.973V11.6a.77.77 0 0 0 .388.677l5.815 3.354l-2.02 1.168a.08.08 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855l-5.833-3.387L15.119 7.2a.08.08 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667m2.01-3.023l-.141-.085l-4.774-2.782a.78.78 0 0 0-.785 0L9.409 9.23V6.897a.07.07 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135l-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.8.8 0 0 0-.393.681zm1.097-2.365l2.602-1.5l2.607 1.5v2.999l-2.597 1.5l-2.607-1.5Z`})})}function xz(){return(0,L.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,L.jsx)(`path`,{d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`})})}typeof window<`u`&&window.document&&window.document.createElement;function Sz(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)}}function Cz(e,t=[]){let n=[];function r(t,r){let i=I.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=I.useMemo(()=>o,Object.values(o));return(0,L.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=I.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>I.createContext(e));return function(n){let r=n?.[e]||t;return I.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,wz(i,...t)]}function wz(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return I.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var Tz=`DismissableLayer`,Ez=`dismissableLayer.update`,Dz=`dismissableLayer.pointerDownOutside`,Oz=`dismissableLayer.focusOutside`,kz,Az=I.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),jz=I.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=I.useContext(Az),[d,f]=I.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=I.useState({}),h=aD(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=_?g.indexOf(_):-1,y=d?g.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,S=I.useRef(!1),C=Fz(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:I.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return x&&!t},[u.branches,x])}),w=Iz(e=>{if(r&&S.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),T=d?y===g.length-1:!1,E=CD(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return I.useEffect(()=>{if(T)return p.addEventListener(`keydown`,E,{capture:!0}),()=>p.removeEventListener(`keydown`,E,{capture:!0})},[p,T,E]),I.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(kz=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Lz(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=kz))}},[d,p,n,u]),I.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Lz())},[d,u]),I.useEffect(()=>{let e=()=>m({});return document.addEventListener(Ez,e),()=>document.removeEventListener(Ez,e)},[]),(0,L.jsx)(xD.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:Sz(e.onFocusCapture,w.onFocusCapture),onBlurCapture:Sz(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:Sz(e.onPointerDownCapture,C.onPointerDownCapture)})});jz.displayName=Tz;var Mz=`DismissableLayerBranch`,Nz=I.forwardRef((e,t)=>{let n=I.useContext(Az),r=I.useRef(null),i=aD(t,r);return I.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,L.jsx)(xD.div,{...e,ref:i})});Nz.displayName=Mz;var Pz=()=>!0;function Fz(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Pz}=t,s=CD(e),c=I.useRef(!1),l=I.useRef(!1),u=I.useRef(new Map),d=I.useRef(()=>{});return I.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}function t(){return Array.from(u.current.values()).some(Boolean)}function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}function p(e){l.current&&u.current.set(e.type,!1)}let m=a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||Rz(Dz,s,p,{discrete:!0})};if(!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:()=>c.current=!0}}function Iz(e,t=globalThis?.document){let n=CD(e),r=I.useRef(!1);return I.useEffect(()=>{let e=e=>{e.target&&!r.current&&Rz(Oz,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Lz(){let e=new CustomEvent(Ez);document.dispatchEvent(e)}function Rz(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?SD(i,a):i.dispatchEvent(a)}var zz=`focusScope.autoFocusOnMount`,Bz=`focusScope.autoFocusOnUnmount`,Vz={bubbles:!1,cancelable:!0},Hz=`FocusScope`,Uz=I.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=I.useState(null),l=CD(i),u=CD(a),d=I.useRef(null),f=aD(t,c),p=I.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;I.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:Xz(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Xz(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Xz(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),I.useEffect(()=>{if(s){Zz.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(zz,Vz);s.addEventListener(zz,l),s.dispatchEvent(t),t.defaultPrevented||(Wz(eB(Kz(s)),{select:!0}),document.activeElement===e&&Xz(s))}return()=>{s.removeEventListener(zz,l),setTimeout(()=>{let t=new CustomEvent(Bz,Vz);s.addEventListener(Bz,u),s.dispatchEvent(t),t.defaultPrevented||Xz(e??document.body,{select:!0}),s.removeEventListener(Bz,u),Zz.remove(p)},0)}}},[s,l,u,p]);let m=I.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=Gz(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Xz(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Xz(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,L.jsx)(xD.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});Uz.displayName=Hz;function Wz(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Xz(r,{select:t}),document.activeElement!==n)return}function Gz(e){let t=Kz(e);return[qz(t,e),qz(t.reverse(),e)]}function Kz(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function qz(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Jz(r,{upTo:t})))return r}function Jz(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Yz(e){return e instanceof HTMLInputElement&&`select`in e}function Xz(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Yz(e)&&t&&e.select()}}var Zz=Qz();function Qz(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=$z(e,t),e.unshift(t)},remove(t){e=$z(e,t),e[0]?.resume()}}}function $z(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function eB(e){return e.filter(e=>e.tagName!==`A`)}var tB=`Popper`,[nB,rB]=Cz(tB),[iB,aB]=nB(tB),oB=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null),[a,o]=I.useState(void 0);return(0,L.jsx)(iB,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};oB.displayName=tB;var sB=`PopperAnchor`,cB=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=aB(sB,n),o=I.useRef(null),s=a.onAnchorChange,c=aD(t,I.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=I.useRef(null);I.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&vB(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,L.jsx)(xD.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})});cB.displayName=sB;var lB=`PopperContent`,[uB,dB]=nB(lB),fB=I.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=aB(lB,n),[_,v]=I.useState(null),y=aD(t,v),[b,x]=I.useState(null),S=oA(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(gB),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=Jk({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>Pk(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[Xk({mainAxis:i+w,alignmentAxis:o}),c&&Zk({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Qk():void 0,...k}),c&&$k({...k}),eA({...k,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&nA({element:b,padding:s}),_B({arrowWidth:C,arrowHeight:w}),f&&tA({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ee=g.setPlacementState;wD(()=>(ee(M),()=>{ee(void 0)}),[M,ee]);let[F,te]=vB(M),ne=CD(m);wD(()=>{N&&ne?.()},[N,ne]);let re=P.arrow?.x,ie=P.arrow?.y,ae=P.arrow?.centerOffset!==0,[oe,se]=I.useState();return wD(()=>{_&&se(window.getComputedStyle(_).zIndex)},[_]),(0,L.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:N?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,L.jsx)(uB,{scope:n,placedSide:F,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,L.jsx)(xD.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});fB.displayName=lB;var pB=`PopperArrow`,mB={top:`bottom`,right:`left`,bottom:`top`,left:`right`},hB=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=dB(pB,n),a=mB[i.placedSide];return(0,L.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,L.jsx)(aA,{...r,ref:t,style:{...r.style,display:`block`}})})});hB.displayName=pB;function gB(e){return e!==null}var _B=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=vB(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function vB(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var yB=oB,bB=cB,xB=fB,SB=hB;function CB(e,t){return I.useReducer((e,n)=>t[e][n]??e,e)}var wB=e=>{let{present:t,children:n}=e,r=TB(t),i=typeof n==`function`?n({present:r.isPresent}):I.Children.only(n),a=DB(r.ref,kB(i));return typeof n==`function`||r.isPresent?I.cloneElement(i,{ref:a}):null};wB.displayName=`Presence`;function TB(e){let[t,n]=I.useState(),r=I.useRef(null),i=I.useRef(e),a=I.useRef(`none`),o=I.useRef(void 0),[s,c]=CB(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return I.useEffect(()=>{s===`mounted`?(a.current=o.current??OB(r.current),o.current=void 0):a.current=`none`},[s]),wD(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=OB(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),wD(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=OB(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},s=e=>{e.target===t&&(a.current=OB(r.current))};return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:I.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=OB(t)}else r.current=null;n(e)},[])}}function EB(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function DB(...e){let t=I.useRef(e);return t.current=e,I.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=EB(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():EB(n[e],null)}}},[])}function OB(e){return e?.animationName||`none`}function kB(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var AB=`Popover`,[jB,MB]=Cz(AB,[rB]),NB=rB(),[PB,FB]=jB(AB),IB=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=NB(t),c=I.useRef(null),[l,u]=I.useState(!1),[d,f]=zA({prop:r,defaultProp:i??!1,onChange:a,caller:AB});return(0,L.jsx)(yB,{...s,children:(0,L.jsx)(PB,{scope:t,contentId:WD(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:I.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:I.useCallback(()=>u(!0),[]),onCustomAnchorRemove:I.useCallback(()=>u(!1),[]),modal:o,children:n})})};IB.displayName=AB;var LB=`PopoverAnchor`,RB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=FB(LB,n),a=NB(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return I.useEffect(()=>(o(),()=>s()),[o,s]),(0,L.jsx)(bB,{...a,...r,ref:t})});RB.displayName=LB;var zB=`PopoverTrigger`,BB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=FB(zB,n),a=NB(n),o=aD(t,i.triggerRef),s=(0,L.jsx)(xD.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":tV(i.open),...r,ref:o,onClick:Sz(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,L.jsx)(bB,{asChild:!0,...a,children:s})});BB.displayName=zB;var VB=`PopoverPortal`,[HB,UB]=jB(VB,{forceMount:void 0}),WB=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=FB(VB,t);return(0,L.jsx)(HB,{scope:t,forceMount:n,children:(0,L.jsx)(wB,{present:n||a.open,children:(0,L.jsx)(AA,{asChild:!0,container:i,children:r})})})};WB.displayName=VB;var GB=`PopoverContent`,KB=I.forwardRef((e,t)=>{let n=UB(GB,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=FB(GB,e.__scopePopover);return(0,L.jsx)(wB,{present:r||a.open,children:a.modal?(0,L.jsx)(JB,{...i,ref:t}):(0,L.jsx)(YB,{...i,ref:t})})});KB.displayName=GB;var qB=cD(`PopoverContent.RemoveScroll`),JB=I.forwardRef((e,t)=>{let n=FB(GB,e.__scopePopover),r=I.useRef(null),i=aD(t,r),a=I.useRef(!1);return I.useEffect(()=>{let e=r.current;if(e)return BM(e)},[]),(0,L.jsx)(YN,{as:qB,allowPinchZoom:!0,children:(0,L.jsx)(XB,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Sz(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Sz(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:Sz(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),YB=I.forwardRef((e,t)=>{let n=FB(GB,e.__scopePopover),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(XB,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),XB=I.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=FB(GB,n),p=NB(n);return qj(),(0,L.jsx)(Uz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(jz,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,L.jsx)(xB,{"data-state":tV(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),ZB=`PopoverClose`,QB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=FB(ZB,n);return(0,L.jsx)(xD.button,{type:`button`,...r,ref:t,onClick:Sz(e.onClick,()=>i.onOpenChange(!1))})});QB.displayName=ZB;var $B=`PopoverArrow`,eV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=NB(n);return(0,L.jsx)(SB,{...i,...r,ref:t})});eV.displayName=$B;function tV(e){return e?`open`:`closed`}var nV=IB,rV=RB,iV=BB,aV=WB,oV=KB;function sV({modal:e=!1,...t}){return(0,L.jsx)(nV,{modal:e,...t})}var cV=iV,lV=rV;function uV({children:e,side:t=`top`,align:n=`center`,sideOffset:r=6,className:i=``,...a}){return(0,L.jsx)(aV,{children:(0,L.jsx)(oV,{side:t,align:n,sideOffset:r,avoidCollisions:!0,collisionPadding:12,onEscapeKeyDown:e=>e.stopPropagation(),className:`${Mj} ${Ij} rounded-lg outline-none ${i}`,...a,children:e})})}var dV=3e4,fV=45e3;function pV(e,t){return t?AbortSignal.any([t,AbortSignal.timeout(e)]):AbortSignal.timeout(e)}var mV=`text-[9px]`,hV={claude:`text-fg/75! size-[14px]! translate-y-0!`,codex:`text-fg/75! size-[12.75px]! translate-y-0!`};function gV(){let e=nt({queryKey:[`quota`],queryFn:()=>Y.quota(),staleTime:1e4}),t=nt({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4});return[`claude`,`codex`].some(n=>_V(e.data?.[n],t.data?.[n],e.isLoading))}function _V(e,t,n){return t===`signed-out`||!e&&n?!1:!!e&&e.status===`ok`&&e.windows.length>0}function vV(){let e=Ve(),t=(0,I.useRef)(null),[n,r]=(0,I.useState)(!1),i=nt({queryKey:[`quota`],queryFn:({signal:e})=>Y.quota(void 0,{signal:pV(dV,e)}),refetchInterval:e=>{let t=e.state.data;return!t||t.claude.status!==`ok`||t.codex.status!==`ok`?15e3:3e4},staleTime:1e4,refetchOnWindowFocus:!0}),a=nt({queryKey:[`authStatus`],queryFn:({signal:e})=>Y.authStatus(void 0,{signal:pV(dV,e)}),refetchInterval:12e4,staleTime:3e4,refetchOnWindowFocus:!0}),o=n=>{if(t.current)return;r(!0);let i=Promise.all([Y.quota({force:n===`claude`},{signal:pV(fV)}).then(t=>e.setQueryData([`quota`],t)),e.refetchQueries({queryKey:[`authStatus`]})]).then(()=>{}).catch(()=>{}).finally(()=>{t.current=null,r(!1)});t.current=i};return(0,L.jsxs)(`div`,{"data-quota-bar":!0,className:`flex shrink-0 items-center gap-3 ${mV}`,children:[(0,L.jsx)(yV,{backend:`claude`,quota:i.data?.claude,auth:a.data?.claude,email:a.data?.emails?.claude,loading:i.isLoading,fetching:i.isFetching||n,onRecheck:()=>o(`claude`)}),(0,L.jsx)(yV,{backend:`codex`,quota:i.data?.codex,auth:a.data?.codex,email:a.data?.emails?.codex,loading:i.isLoading,fetching:i.isFetching||n,onRecheck:()=>o(`codex`)})]})}function yV({backend:e,quota:t,auth:n,email:r,loading:i,fetching:a,onRecheck:o}){let s=DR[e];if(!_V(t,n,i))return null;let c=bV(100-SV(t.windows).usedPercent);return(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(sV,{onOpenChange:e=>{e&&o()},children:[(0,L.jsx)(cV,{asChild:!0,children:(0,L.jsxs)(`button`,{type:`button`,"aria-label":`${s} quota: ${c}% remaining`,className:`flex items-center gap-1.5 min-w-0 rounded outline-none transition-opacity hover:opacity-80 focus-visible:ring-1 focus-visible:ring-border-strong`,children:[(0,L.jsx)(yz,{backend:e,className:hV[e]}),(0,L.jsxs)(`span`,{className:`tabular-nums ${CV(c)}`,children:[c,`%`]})]})}),(0,L.jsxs)(uV,{side:`bottom`,align:`start`,className:`w-[min(15rem,calc(100vw-1.5rem))] p-3 text-[11px] leading-relaxed text-fg`,children:[(0,L.jsxs)(`div`,{className:`mb-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,L.jsx)(yz,{backend:e}),(0,L.jsx)(`span`,{children:s}),t?.planType&&(0,L.jsxs)(`span`,{className:`text-muted/70`,children:[`· `,wV(t.planType),` plan`]}),a&&(0,L.jsx)(Mm,{size:11,className:`animate-spin text-muted/60`,"aria-label":`Rechecking`})]}),r&&(0,L.jsx)(`div`,{"data-quota-account":!0,className:`truncate text-muted/70 select-text`,title:r,children:r})]}),(0,L.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[t.windows.map(e=>{let t=bV(100-e.usedPercent),n=TV(e);return(0,L.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsx)(`span`,{className:`text-muted/80`,children:e.label}),(0,L.jsxs)(`span`,{className:`flex items-center gap-2 tabular-nums`,children:[(0,L.jsxs)(`span`,{className:CV(t),children:[t,`% left`]}),n&&(0,L.jsxs)(`span`,{className:`text-muted/55`,children:[`resets `,n]})]})]},e.key)}),t.detail&&(0,L.jsx)(`li`,{className:`pt-1 text-muted/55`,children:t.detail})]})]})]})})}function bV(e){return Math.max(0,Math.min(100,Math.round(e)))}var xV=25;function SV(e){return e.find(e=>e.key===`5h`)??e.reduce((e,t)=>t.usedPercent>e.usedPercent?t:e)}function CV(e){return e<=8?`text-red-400`:e<=xV?`text-accent`:`text-fg/70`}function wV(e){return e&&e[0].toUpperCase()+e.slice(1)}function TV(e){if(!e.resetsAt)return null;let t=e.resetsAt*1e3,n=new Date(t);if(Number.isNaN(n.getTime()))return null;let r=t-Date.now();if(r<=0)return null;if(r<24*36e5){let e=n.getHours(),t=n.getMinutes(),r=e>=12?`pm`:`am`;return e=e%12||12,t===0?`${e}${r}`:`${e}:${String(t).padStart(2,`0`)}${r}`}return n.toLocaleDateString(void 0,{weekday:`short`})}var EV=`frizz:supervisor-status-wake`;function DV(e){return e!==null}function OV(e){return e?.updateRestart===!0&&e.updateAvailable!==!1}function kV(e){return e?.dev===!0}async function AV(e=fetch){try{let t=await e(`/_frizz/control/status`,{headers:{"cache-control":`no-store`}});if(!t.ok||!t.headers.get(`content-type`)?.includes(`application/json`))return null;let n=await t.json();return n.protocol===1&&(n.state===`ready`||n.state===`restarting`||n.state===`failed`)?n:null}catch{return null}}async function jV(e,t){let n=await t(e,{method:`POST`,headers:{"cache-control":`no-store`}}),r;try{r=await n.json()}catch{}if(!n.headers.get(`content-type`)?.includes(`application/json`)||!r||r.protocol!==1||r.state!==`ready`&&r.state!==`restarting`&&r.state!==`failed`)throw Error(`Frizz restart controls are unavailable for this server`);if(!n.ok)throw Error(r.message??`Restart request failed (${n.status})`);if(r.state===`failed`)throw Error(r.message??`Frizz did not become ready`);return r}function MV(e=fetch){return jV(`/_frizz/control/restart`,e)}function NV(e=fetch){return jV(`/_frizz/control/update-restart`,e)}var PV=8e3,FV=500,IV=[`supervisorStatus`];function LV(e,t){return e===`restarting`||t?FV:PV}var RV=rt({queryKey:IV,queryFn:()=>AV(),refetchInterval:e=>LV(e.state.data?.state,X.controlPlaneRestartPending),staleTime:e=>LV(e.state.data?.state,X.controlPlaneRestartPending)});function zV(){return nt(RV)}var BV=null;function VV(e){BV||(BV=e,window.addEventListener(EV,()=>{e.refetchQueries({queryKey:IV,exact:!0})}))}var HV=`Install the latest version of Frizz. Your running threads will not be affected.`,UV=`A newer version of Frizz is available. Your running threads will not be affected.`,WV=`Restart Frizz. Your running threads will not be affected.`,GV=`fixed left-3 right-3 top-12 z-50 w-auto text-left font-sans sm:absolute sm:right-auto sm:-left-[17px] sm:top-[calc(100%+0.65rem)]`,KV=`absolute -top-[7px] left-4 h-3 w-3 rotate-45 border-l border-t bg-elevated`,qV=`sm:w-[min(23rem,calc(100vw-1.5rem))]`,JV=`sm:w-[min(34rem,calc(100vw-1.5rem))]`,YV=`rounded-xl bg-elevated p-3.5 shadow-xl shadow-black/45`;function XV({open:e,update:t,version:n,updateVersion:r}){if(!e)return null;let i=t?`Update Frizz`:`Restart Frizz`,a=t?r:void 0;return(0,L.jsxs)(`div`,{id:`update-restart-popover`,role:`tooltip`,"aria-label":i,className:`${GV} ${qV} ${YV} border border-border-strong`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${KV} border-border-strong`}),(0,L.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,L.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-fg/10 text-fg`,children:(0,L.jsx)(Gm,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,L.jsx)(`span`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:i}),n&&(0,L.jsx)(`span`,{className:`font-mono text-[11px] leading-snug text-muted`,children:a?`${n} → ${a}`:n})]})]}),(0,L.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:t?a?UV:HV:WV})]})}var ZV=`Frizz kept running the previous version, and your threads are unaffected.`;function QV({update:e,message:t,onDismiss:n}){return(0,L.jsxs)(`div`,{role:`alert`,className:`${GV} ${JV} ${YV} border border-red-500/45`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${KV} border-red-500/45`}),(0,L.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,L.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-red-500/15 text-red-300`,children:(0,L.jsx)(rh,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,L.jsx)(`span`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:e?`Update failed`:`Restart failed`}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,onClick:n,className:`-mr-1 ml-auto flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-border-strong`,children:(0,L.jsx)(ah,{"aria-hidden":`true`,size:14,strokeWidth:2.25})})]}),(0,L.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:ZV}),(0,L.jsx)(`pre`,{className:`relative mt-2.5 max-h-64 overflow-y-auto whitespace-pre-wrap break-words rounded-md border border-border bg-panel px-2.5 py-2 font-mono text-[11px] leading-relaxed text-fg/70`,children:t})]})}function $V({update:e,busy:t,updateVersion:n,onFocus:r,onBlur:i,onClick:a}){return(0,L.jsxs)(`button`,{type:`button`,"aria-describedby":`update-restart-popover`,"aria-label":e?`Update Frizz`:`Restart Frizz`,disabled:t,"aria-busy":t||void 0,className:`relative ${hz}`,onFocus:r,onBlur:i,onClick:a,children:[(0,L.jsx)(Gm,{size:14,"aria-hidden":`true`,className:t?`animate-spin`:void 0}),e&&!t&&n&&(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-[2px] top-[2px] h-[4px] w-[4px] rounded-full bg-accent`})]})}function eH(){let e=Zt(X),[t,n]=(0,I.useState)(!1),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(),[s,c]=(0,I.useState)(),l=(0,I.useRef)(!1),u=(0,I.useRef)(null),d=zV().data??null,f=OV(d),p={version:d?.version,updateVersion:d?.updateVersion};if(!DV(d))return null;let m=l.current&&e.controlPlaneState===`failed`?e.controlPlaneMessage??`Frizz did not become ready`:void 0,h=a??m,g=h&&h!==s?h:void 0,_=async()=>{if(r)return;l.current=!0,n(!1),i(!0),o(void 0),c(void 0);let e=`${window.location.pathname}${window.location.search}${window.location.hash}`;f&&(X.controlPlaneState=`restarting`,X.controlPlaneMessage=null,X.controlPlaneRestartPending=!0);try{f?await NV():await MV(),f?(sessionStorage.setItem(`frizz:reload-after-update-restart`,e),window.dispatchEvent(new Event(EV)),i(!1)):window.location.replace(e)}catch(e){f&&(X.controlPlaneRestartPending=!1,X.controlPlaneState=`ready`,X.controlPlaneMessage=null);let t=e.message.slice(0,140);i(!1),o(t),Z(`${f?`Update & Restart`:`Restart Frizz`} failed`)}};return(0,L.jsxs)(`div`,{ref:u,className:`relative`,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[(0,L.jsx)($V,{update:f,busy:r,updateVersion:p.updateVersion,onFocus:()=>n(!0),onBlur:()=>n(!1),onClick:()=>void _()}),g&&(0,L.jsx)(QV,{update:f,message:g,onDismiss:()=>c(g)}),(0,L.jsx)(XV,{open:t&&!g,update:f,version:p.version,updateVersion:p.updateVersion})]})}function tH(){return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px shrink-0 bg-border`})}function nH({text:e,title:t,className:n}){return(0,L.jsx)(`span`,{dir:`rtl`,className:`block min-w-0 overflow-hidden text-ellipsis whitespace-nowrap ${n??``}`,title:t,children:(0,L.jsx)(`span`,{dir:`ltr`,className:`[unicode-bidi:isolate]`,children:e})})}function rH(){let e=kC(),t=IU(e),n=gV(),r=e?.githubRepo??null,i=t.state===`verified`?t.label:t.state===`local`?t.name:null,a=t.state===`verified`?`Project: ${t.label}`:t.state===`local`?`Project: ${t.name}; local repository with no git remote`:t.state===`loading`?`Project identity loading`:`Project identity unavailable`;return(0,L.jsxs)(`div`,{"data-status-row":!0,className:`mb-2.5 flex min-w-0 items-center gap-3 text-[12px]`,children:[(0,L.jsx)(fb,{to:`/`,title:`All projects`,"aria-label":`All projects`,className:`${hz} -ml-px`,children:(0,L.jsx)(Em,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(tH,{}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Settings`,title:`Settings`,className:hz,onClick:()=>X.showSettings=!0,children:(0,L.jsx)(Ym,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(eH,{}),n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(tH,{}),(0,L.jsx)(vV,{})]}),(0,L.jsx)(`span`,{className:`ml-auto flex min-w-0 items-center`,"data-project-identity-state":t.state,"aria-label":a,"aria-busy":t.state===`loading`||void 0,children:i&&r?(0,L.jsx)(`a`,{href:`https://github.com/${r}`,target:`_blank`,rel:`noopener`,title:`Open ${i} on GitHub`,"aria-label":`Open ${i} on GitHub`,className:`block min-w-0 rounded-sm font-semibold text-fg/90 underline-offset-2 outline-none transition-colors hover:text-fg hover:underline focus-visible:ring-1 focus-visible:ring-border-strong`,children:(0,L.jsx)(nH,{text:i})}):i?(0,L.jsx)(nH,{text:i,title:i,className:`font-semibold text-fg/90`}):(0,L.jsx)(`span`,{className:`identity-placeholder w-24`,"aria-hidden":`true`})})]})}var iH=qt({at:{}}),aH=12e3,oH=new Map;function sH(e,t=Date.now()){iH.at[e]=t;let n=oH.get(e);n!==void 0&&clearTimeout(n),oH.set(e,setTimeout(()=>{oH.delete(e),delete iH.at[e]},aH))}function cH(e){let t=oH.get(e);t!==void 0&&(clearTimeout(t),oH.delete(e)),delete iH.at[e]}function lH(e,t,n=Date.now()){if(t===void 0||n-t>12e3)return!1;let r=e.lastActivityAt?Date.parse(e.lastActivityAt):NaN;return!(Number.isFinite(r)&&r>t)}function uH(){return Zt(iH).at}function dH(e,t,n=Date.now()){return t===void 0||!lH(e,t,n)?e:{...e,runtime:`running`,needsYou:!1,pendingAsk:void 0,pendingQuestion:!1,actionableInteraction:!1,lastUserAt:new Date(t).toISOString()}}function fH(e){let t=uH();return(0,I.useMemo)(()=>e.map(e=>dH(e,t[e.id])),[e,t])}var pH=0;function mH(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(pH+=1,`browser-${Date.now()}-${pH}`)}function hH({optimistic:e,request:t,success:n,failure:r}){e(),t().then(()=>n?.(),e=>r(e instanceof Error?e:Error(String(e))))}var gH=new Map;function _H(e,t){let n=(gH.get(e)??Promise.resolve()).then(t,t);return gH.set(e,n.then(()=>{},()=>{})),n}var vH=[300,800,1800,3500],yH=12e4,bH=e=>new Promise(t=>{setTimeout(t,e)});async function xH(e,t,n=bH){for(let r=0;;r++){try{await e()}catch(e){if(r>=vH.length||!lf(e))throw e;t(),await n(vH[r]);continue}t();return}}function SH(e,t,n,r,i,a=yH){let o=new AbortController,s=setTimeout(()=>o.abort(Error(`Frizz did not answer this send`)),a);return Y.followUp({slug:e,sessionId:Dp(X.board,e)?.sessionId??``,message:t,deliveryId:n,freshProcess:r,interrupt:i},{signal:o.signal}).finally(()=>clearTimeout(s))}function CH(e,t,n,r,i){return xH(()=>SH(e,t,n,r,i),()=>sH(e))}function wH(e,t,n,r={}){let i=n.trim();if(!i)return!1;let a=mH();return hH({optimistic:()=>{r.onOptimistic?.(),qC(e,t,i,{scrollToBottom:r.scrollToBottom,deliveryId:a}),sH(t),Y.markRead({slug:t}).catch(()=>{})},request:()=>_H(t,()=>CH(t,i,a,r.freshProcess,r.interrupt)),success:()=>r.onSuccess?.(),failure:n=>{JC(e,t,i,a),cH(t),r.onRollback?.(),Z(r.failureToast?.(n.message)??`Steer failed — ${n.message.slice(0,160)}`)}}),!0}function TH(e){let t=Ve(),[n,r]=(0,I.useState)(0);return{submit:(0,I.useCallback)((n,i={})=>wH(t,e,n,{...i,onOptimistic:()=>{r(e=>e+1),i.onOptimistic?.()},onSuccess:()=>{r(e=>Math.max(0,e-1)),i.onSuccess?.()},onRollback:()=>{r(e=>Math.max(0,e-1)),i.onRollback?.()}}),[t,e]),pending:n>0}}function EH(e,t){return new Promise(n=>{wH(e,t,`Continue exactly where you left off.`,{onSuccess:()=>{Z(`Retrying…`),n()},onRollback:()=>n(),failureToast:e=>`Retry failed: ${e.slice(0,80)}`})||n()})}function DH(e){let t=/^([A-Za-z0-9][\w.-]*)\/([A-Za-z0-9][\w.-]*)#(\d+)$/.exec(e.trim());return t?`https://github.com/${t[1]}/${t[2]}/pull/${t[3]}`:null}var OH=`Waiting for an external update.`;function kH(e){let t=new Set;return e.flatMap(e=>{if(e.kind!==`pr`)return[];let n=e.value.trim();return!n||t.has(n)?[]:(t.add(n),[{ref:n,url:DH(n)}])})}function AH(e){let t=(e.body??``).split(/\n\s*\n/).map(e=>e.trim()).find(Boolean);return t?NH(jH(t.replace(/\s*\n\s*/g,` `))):null}function jH(e){if(e.length<=MH)return e;let t=e.slice(0,MH),n=t.lastIndexOf(` `);return`${(n>MH/2?t.slice(0,n):t).replace(/[.,;:]$/,``)}…`}var MH=240;function NH(e){let t=(e.split(/\s/,1)[0]??``).replace(/[.,:;]+$/,``);return/[^a-zA-Z]/.test(t)||/[A-Z]/.test(t.slice(1))||PH.has(t)?e:e.charAt(0).toUpperCase()+e.slice(1)}var PH=new Set([`npm`,`npx`,`pnpm`,`nub`,`nubx`,`gh`,`git`,`node`,`bun`,`tsc`,`vite`,`curl`,`ssh`]);function FH(e){return e&&LH(e)||null}var IH=new Set([...rl,`shells`,`agents`,`timers`,`prs`,`for`,`title`]);function LH(e){return e.split(`
200
200
  `).filter(e=>{let t=/^\s*([a-z][a-z-]*):/i.exec(e)?.[1]?.toLowerCase();return!(t&&IH.has(t))}).join(`
201
201
  `).trim()}function RH(e){let t=t=>e.filter(e=>e.kind===t&&e.value.trim()).length,n=[...kH(e).map(e=>e.ref),zH(t(`shell`),`background shell`,`background shells`),zH(t(`agent`),`sub-agent`,`sub-agents`),zH(t(`timer`),`timer`,`timers`)].filter(e=>e!==null);return n.length>0?`waiting on ${BH(n)}`:null}function zH(e,t,n){return e<=0?null:e===1?`a ${t}`:`${e} ${n}`}function BH(e){return e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function VH(e){let t=e.find(e=>e.kind===`pr`);return t?`PR ${t.value}`:null}var HH=qt({at:{}}),UH=12e3,WH=new Map;function GH(e,t=Date.now()){HH.at[e]=t;let n=WH.get(e);n!==void 0&&clearTimeout(n),WH.set(e,setTimeout(()=>{WH.delete(e),delete HH.at[e]},UH))}function KH(e){let t=WH.get(e);t!==void 0&&(clearTimeout(t),WH.delete(e)),delete HH.at[e]}function qH(){return Zt(HH).at}function JH(e,t,n=Date.now()){return t===void 0||n-t>12e3||e.state===`archived`?e:{...e,state:`archived`,archived:!0,needsYou:!1,pendingAsk:void 0,pendingQuestion:!1,actionableInteraction:!1}}function YH(e){let t=qH();return(0,I.useMemo)(()=>e.map(e=>JH(e,t[e.id])),[e,t])}var XH=.5;function ZH(e,t,n=!1){let r=e.map(e=>({id:e.id,height:Math.max(0,e.bottom-e.top),visible:Math.min(e.bottom,t)-Math.max(e.top,0)})).filter(e=>e.visible>0);if(!r.length)return null;if(n)return r[r.length-1].id;let i=t*XH,a=r[0];for(let e of r)if(e.visible>a.visible&&(a=e),e.visible>=Math.min(i,e.height)&&e.visible>=a.visible)return e.id;return a.id}function QH(e,t,n,r){return!e||e.top<=r&&e.bottom>r?!0:Math.abs(t-n)>1}function $H(e,t,n,r,i=8){return n<e+i?n-e-i:r>t-i?r-t+i:0}var eU=`flex h-[19px] w-[19px] items-center justify-center rounded text-muted/70 outline-none transition-colors hover:bg-panel-2 hover:text-fg`,tU=`sticky top-0 self-start h-screen w-[clamp(272px,34vw,680px)] shrink-0 flex flex-col justify-center max-[800px]:static max-[800px]:h-auto max-[800px]:w-full max-[800px]:justify-start max-[800px]:pt-16`;function nU(){let e=Zt(X),t=YH(fH(jC(kC()?.threads??[]))),n=HT(t,Zt(tT).queueOrder),r=vT(xT(t)),i=e.sidebarCollapsed,a=n.active,o=n.snoozed,s=n.inactive,c=(0,I.useRef)(null),[l,u]=(0,I.useState)(null),d=(0,I.useRef)(null),f=(0,I.useCallback)(()=>{let e=[...document.querySelectorAll(`[data-queue-card][data-queue-leaving="false"]`)].map(e=>{let t=e.dataset.queueCard;if(!t)return null;let{top:n,bottom:r}=(e.querySelector(`[data-queue-card-root]`)??e).getBoundingClientRect();return{id:t,top:n,bottom:r}}).filter(e=>e!==null),t=d.current;if(t)if(QH(e.find(e=>e.id===t.id),window.scrollY,t.landedY,40))d.current=null;else{u(t.id);return}let n=Math.max(0,document.documentElement.scrollHeight-window.innerHeight),r=n>0&&window.scrollY>=n-1,i=ZH(e,window.innerHeight,r);u(e=>e===i?e:i)},[]);(0,I.useEffect)(()=>{let e=0,t=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(f)};t(),document.addEventListener(`scroll`,t,{capture:!0,passive:!0}),window.addEventListener(`resize`,t);let n=document.getElementById(`workpane`),r=n?new ResizeObserver(t):null,i=n?new MutationObserver(t):null;return n&&r?.observe(n),n&&i?.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-queue-card`,`data-queue-leaving`,`style`,`class`]}),()=>{cancelAnimationFrame(e),document.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t),r?.disconnect(),i?.disconnect()}},[f,e.view,e.drawers.length]),(0,I.useLayoutEffect)(()=>{let e=c.current;if(!e||!l||window.matchMedia(`(max-width: 800px)`).matches)return;let t=e.querySelector(`[data-sidebar-item="${CSS.escape(l)}"]`);if(!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=$H(n.top,n.bottom,r.top,r.bottom);Math.abs(i)>.5&&(e.scrollTop+=i)},[l]);let p=(0,I.useCallback)(e=>{d.current={id:e,landedY:Uf(e)??window.scrollY},u(e)},[]);return(0,L.jsx)(`aside`,{className:tU,children:(0,L.jsxs)(`div`,{className:`flex max-h-[calc(100vh-32px)] min-h-0 min-w-0 w-full flex-col max-[800px]:max-h-none`,children:[(0,L.jsxs)(`div`,{className:`mb-5 shrink-0 px-0.5`,children:[(0,L.jsx)(rH,{}),(0,L.jsx)(fz,{})]}),(0,L.jsxs)(`div`,{ref:c,"data-sidebar-rail":!0,className:`min-h-0 min-w-0 overflow-y-auto overflow-x-hidden max-[800px]:overflow-y-visible`,children:[n.pinned.length>0&&(0,L.jsxs)(`section`,{"aria-label":`Pinned`,children:[n.pinned.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(uU,{t:e,active:l===e.id,onQueueNavigate:p}),(0,L.jsx)(hU,{t:e})]},e.id)),a.length>0&&(0,L.jsx)(`hr`,{className:`my-3 border-border/50`})]}),a.length>0?(()=>{let{running:e,rested:t}=VT(a),n=e=>t=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(uU,{t,active:l===t.id,onQueueNavigate:p,restedAge:e}),(0,L.jsx)(hU,{t})]},t.id);return(0,L.jsxs)(L.Fragment,{children:[t.map(n(!0)),e.length>0&&t.length>0&&(0,L.jsx)(`hr`,{className:`my-3 border-border/50`}),e.map(n(!1))]})})():n.pinned.length===0?(0,L.jsx)(`div`,{className:`py-1 pl-5 pr-1.5 text-[11.5px] text-muted/50`,children:`No open threads`}):null,o.length>0&&(0,L.jsxs)(`section`,{"aria-label":`Snoozed`,children:[(0,L.jsx)(`hr`,{className:`my-3 border-border/50`}),(0,L.jsx)(rU,{label:`Snoozed`,count:o.length,collapsed:i.snoozed,onToggle:()=>X.sidebarCollapsed.snoozed=!X.sidebarCollapsed.snoozed}),!i.snoozed&&o.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(uU,{t:e,active:l===e.id,onQueueNavigate:p}),(0,L.jsx)(hU,{t:e})]},e.id))]}),s.length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`hr`,{className:`my-3 border-border/50`}),(0,L.jsx)(rU,{label:`Done`,count:s.length,collapsed:i.inactive,onToggle:()=>X.sidebarCollapsed.inactive=!X.sidebarCollapsed.inactive}),!i.inactive&&(0,L.jsx)(oU,{threads:s,railRef:c,activeId:l,onQueueNavigate:p})]}),r.length>0&&(0,L.jsxs)(`section`,{"aria-label":`External`,children:[(0,L.jsx)(`hr`,{className:`my-3 border-border/50`}),(0,L.jsx)(rU,{label:`External`,count:r.length,collapsed:i.external,onToggle:()=>X.sidebarCollapsed.external=!X.sidebarCollapsed.external}),!i.external&&r.map(e=>(0,L.jsx)(uU,{t:e,active:l===e.id,onQueueNavigate:p,restedAge:!0},e.id))]})]})]})})}function rU({label:e,count:t,collapsed:n,onToggle:r}){let i=(0,L.jsxs)(L.Fragment,{children:[r?(0,L.jsx)(tm,{size:11,className:`transition-transform ${n?``:`rotate-90`}`}):(0,L.jsx)(`span`,{className:`w-[11px] shrink-0`,"aria-hidden":!0}),(0,L.jsx)(`span`,{children:e}),(0,L.jsx)(`span`,{className:`ml-1.5 tabular-nums text-muted/60`,children:t})]}),a=`flex w-full items-center gap-1 px-1.5 py-1 text-[11px] uppercase tracking-wide text-muted/70`;return r?(0,L.jsx)(`button`,{onClick:r,className:`${a} transition-colors hover:text-fg`,children:i}):(0,L.jsx)(`div`,{className:a,children:i})}var iU=27,aU=8;function oU({threads:e,railRef:t,activeId:n,onQueueNavigate:r}){let i=(0,I.useRef)(null),[a,o]=(0,I.useState)(0),s=jw({count:e.length,getScrollElement:()=>t.current,getItemKey:t=>e[t]?.id??t,estimateSize:()=>iU,overscan:aU,scrollMargin:a});return(0,I.useLayoutEffect)(()=>{let e=t.current,n=i.current;if(!e||!n)return;let r=()=>{let t=n.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;o(e=>Math.abs(e-t)<.5?e:t)};r();let a=new ResizeObserver(r);return a.observe(e),()=>a.disconnect()}),(0,L.jsx)(`div`,{ref:i,"data-done-band":!0,className:`relative w-full`,style:{height:s.getTotalSize()},children:s.getVirtualItems().map(t=>{let i=e[t.index];return i?(0,L.jsxs)(`div`,{ref:s.measureElement,"data-index":t.index,className:`absolute left-0 top-0 w-full`,style:{transform:`translateY(${t.start-a}px)`},children:[(0,L.jsx)(uU,{t:i,active:n===i.id,onQueueNavigate:r}),(0,L.jsx)(hU,{t:i})]},i.id):null})})}var sU=16,cU=12;function lU({title:e,children:t}){let n=e.trimEnd(),r=n.lastIndexOf(` `)+1,i=n.length-r<=sU?r:n.length-cU;return i>=n.length?(0,L.jsxs)(L.Fragment,{children:[e,t]}):(0,L.jsxs)(L.Fragment,{children:[n.slice(0,i),(0,L.jsxs)(`span`,{className:`whitespace-nowrap`,children:[n.slice(i),t]})]})}var uU=(0,I.memo)(function({t:e,legacy:t,active:n=!1,onQueueNavigate:r,restedAge:i=!1}){let a=!t&&e.foreign===!0,o=!t&&OT(e),s=!t&&fT(e),c=!t&&LT(e),l=!t&&ST(e);return(0,L.jsxs)(`div`,{"data-sidebar-item":e.id,className:`group relative flex min-w-0 items-start rounded-md transition-[color,opacity] after:pointer-events-none after:absolute after:inset-0 after:rounded-md after:bg-white/[0.04] after:opacity-0 after:transition-opacity hover:after:opacity-100 ${t?`opacity-80`:o?`opacity-65 hover:opacity-90 focus-within:opacity-90`:``}`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,"data-sidebar-marker-rail":!0,className:`pointer-events-none absolute inset-y-0 left-0 w-5`,children:n&&(0,L.jsx)(`span`,{"data-sidebar-scroll-marker":!0,className:`absolute inset-y-0 left-1 w-[2px] rounded-full bg-accent`})}),(0,L.jsxs)(`button`,{onClick:()=>{if(e.needsYou&&sp(e.id)){r?.(e.id);return}np(e.id)},"aria-current":n?`location`:void 0,className:`min-w-0 flex-1 flex items-start gap-2 pb-1 pl-5 pr-1.5 pt-1 text-left`,children:[(0,L.jsx)(`span`,{className:`w-4 h-[19px] shrink-0 flex items-center justify-center`,children:(0,L.jsx)(bU,{t:e,legacy:t})}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 flex flex-col`,children:(0,L.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-3`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-[13px] leading-[19px] ${s?`text-fg/50`:o?`text-fg/75`:`text-fg/90`}`,children:(0,L.jsxs)(lU,{title:aT(e),children:[!t&&(0,L.jsx)(yz,{backend:e.backend,className:`ml-1`}),a&&(0,L.jsx)(`span`,{className:`petite-caps ml-1.5 inline-block rounded border border-border/60 px-1 align-[2px] text-[9.5px] leading-[14px] text-muted/55`,title:`Read-only — running in an external terminal`,children:`terminal`}),t&&(0,L.jsx)(gU,{status:e.archived?`archived`:e.status})]})}),i&&(0,L.jsx)(dU,{t:e,yieldsToRetry:!0}),l&&!i&&(0,L.jsx)(pU,{})]})})]}),t&&(0,L.jsx)(`div`,{className:`absolute right-1 top-1 hidden group-hover:flex items-stretch rounded-md bg-panel shadow-sm shadow-black/30`,children:(0,L.jsx)(OI,{slug:e.id,size:`sm`})}),!t&&(0,L.jsxs)(`div`,{className:`absolute right-1.5 top-1 hidden items-center gap-0.5 bg-bg group-hover:flex group-focus-within:flex before:pointer-events-none before:absolute before:inset-y-0 before:right-full before:w-3 before:bg-linear-to-r before:from-transparent before:to-bg`,children:[!a&&!l&&(0,L.jsx)(mU,{t:e,className:`-mr-0.5`}),(0,L.jsx)(zj,{slug:e.id,size:12,className:eU}),c&&(0,L.jsx)(fU,{slug:e.id}),!a&&l&&(0,L.jsx)(mU,{t:e})]})]})});function dU({t:e,yieldsToRetry:t}){let n=sE(),r=gT(e),i=JT(r,n);return!r||!i?null:(0,L.jsx)(`time`,{dateTime:r,"data-rail-rested-age":!0,title:GT(r,n)??void 0,"aria-label":`Rested ${GT(r,n)??i}`,className:`shrink-0 tabular-nums text-[10.5px] leading-[19px] text-muted/55 ${t?`transition-opacity group-hover:opacity-0 group-focus-within:opacity-0`:``}`,children:i})}function fU({slug:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return(0,L.jsx)(Rj,{label:`Retry — resume this session where it left off`,children:(0,L.jsx)(`button`,{"data-sidebar-retry":e,"aria-label":`Retry exited session`,disabled:n,onMouseDown:e=>e.preventDefault(),onClick:n=>{n.stopPropagation(),r(!0),EH(t,e).finally(()=>r(!1))},className:`${eU} disabled:opacity-50`,children:n?(0,L.jsx)(Mm,{size:13,className:`animate-spin`}):(0,L.jsx)(qm,{size:13})})})}function pU(){return(0,L.jsx)(`span`,{"aria-hidden":!0,"data-rail-pin-mark":!0,className:`-ml-1 flex h-[19px] w-[19px] shrink-0 items-center justify-center self-start text-muted/55 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0`,children:(0,L.jsx)(Hm,{size:12,fill:`currentColor`})})}function mU({t:e,className:t=``}){let n=ST(e),[r,i]=(0,I.useState)(!1);return(0,L.jsx)(Rj,{label:n?`Unpin — return this thread to the rail's bands`:`Pin — keep this thread at the very top`,children:(0,L.jsx)(`button`,{"data-sidebar-pin":e.id,"aria-label":n?`Unpin thread`:`Pin thread`,disabled:r,onMouseDown:e=>e.preventDefault(),onClick:t=>{t.stopPropagation(),i(!0),Y.setThreadPinned({slug:e.id,sessionId:e.sessionId??``,pinned:!n}).catch(e=>Z(`${n?`Unpin`:`Pin`} failed: ${String(e instanceof Error?e.message:e).slice(0,80)}`)).finally(()=>i(!1))},className:`${eU} disabled:opacity-50 ${t}`,children:n?(0,L.jsx)(Vm,{size:12,fill:`currentColor`}):(0,L.jsx)(Hm,{size:12})})})}function hU({t:e}){let t=VE(e.subAgents??[],`rail`);return t.length===0?null:(0,L.jsx)(`div`,{className:`flex flex-col`,children:t.map(t=>(0,L.jsx)(WE,{kind:`AGENT`,label:t.label,state:t.state,density:`rail`,depth:t.depth,startedAt:t.startedAt,parentSlug:e.id,onOpen:()=>ep(e.id,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}),onDismiss:Vj(e.id,t),title:t.subagentType?`[${t.subagentType}] ${t.label}`:t.label},t.id))})}function gU({status:e}){let t=e===`archived`?`Done`:e;return(0,L.jsx)(`span`,{className:`petite-caps ml-1.5 inline-block rounded border px-1 align-[2px] leading-[14px] text-[9.5px] ${iT[e]??`text-muted border-border`}`,children:t})}function _U(e,t,n=null){return[[t,RH(e.lastFence?.kind===`awaiting`?e.lastFence.hints:[]),n].filter(e=>!!e).join(` — `),vU(e)].filter(e=>!!e).join(`
202
202
 
@@ -305,12 +305,12 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
305
305
  `)}`:`${eu}\n${t.map((e,t)=>`${t+1}. “${e.question}” → ${e.answer}`).join(`
306
306
  `)}`}function yY(e,t,n,r={}){let i=TH(e),[a,o]=(0,I.useState)({}),s=(0,I.useMemo)(()=>gY(t),[t]),c=(0,I.useMemo)(()=>{for(let e=t.length-1;e>=0;e--)if(!(t[e].kind===`event`||t[e].kind===`reasoning`)&&t[e].role===`assistant`&&t[e].text.trim())return t[e]},[t]),l=(0,I.useMemo)(()=>_Y(t)!==-1,[t]),u=cz(),d=lz(e),f=(0,I.useCallback)((t,n)=>sz.answer(u,e,d,t,n),[u,e,d]),p=(0,I.useMemo)(()=>s.flatMap(e=>e.blocks.map((t,n)=>f(e.identity,n))),[s,f]),m=dz(p),h=(0,I.useRef)(n);h.current=n;let g=(0,I.useRef)(r.onSendFailed);g.current=r.onSendFailed;let _=(0,I.useCallback)((e,t)=>({...a[`${e}::${t}`]??{chosen:null,text:``},text:m.get(f(e,t))??``}),[a,m,f]),v=(0,I.useMemo)(()=>{let e=new Map;for(let t of s)e.set(t.identity,t);return e},[s]),y=(0,I.useCallback)((e,t,n)=>{let r=v.get(e)?.blocks[t],i=`${e}::${t}`;o(e=>{let t=e[i]??{chosen:null,text:``};if(r?.kind===`multi`){let r=new Set(t.chosenSet??[]);return r.has(n)?r.delete(n):r.add(n),{...e,[i]:{chosen:null,text:t.text,chosenSet:[...r].sort((e,t)=>e-t)}}}return{...e,[i]:{chosen:t.chosen===n?null:n,text:t.text}}})},[v]),b=(0,I.useCallback)((e,t,n)=>{let r=v.get(e)?.blocks[t];az.set(f(e,t),n),o(i=>{let a=`${e}::${t}`,o=i[a]??{chosen:null,text:``};return r?.kind===`multi`?{...i,[a]:{chosen:null,text:n,chosenSet:o.chosenSet??[]}}:{...i,[a]:{chosen:null,text:n}}})},[v,f]),x=s.some(e=>e.blocks.some((t,n)=>Uq(t,_(e.identity,n))!==``)),S=r.scrollToBottom!==!1,C=(0,I.useCallback)((e,t={})=>{i.submit(e,{...t,scrollToBottom:S,onRollback:()=>{t.onRollback?.(),g.current?.()}})&&h.current?.()},[i,S]),w=(0,I.useCallback)(e=>{let t=typeof e==`string`?e:void 0,n=t?s.filter(e=>e.identity===t):s,r=t?n.flatMap(e=>e.blocks.map((t,n)=>f(e.identity,n))):p,i=n.flatMap(e=>e.blocks.map((t,n)=>`${e.identity}::${n}`)),c=(e,t)=>Uq(e.blocks[t],_(e.identity,t)),l=n.flatMap(e=>e.blocks.map((t,n)=>({ask:e,bi:n,question:xY(t),answer:c(e,n)})).filter(e=>e.answer!==``));if(l.length===0)return;let u=n.find(e=>e.isLive),d=vY({answered:l.map(e=>({isLive:e.ask.isLive,question:e.question,answer:e.answer})),live:u&&{numbered:u.blocks.map((e,t)=>({n:t+1,a:c(u,t)})).filter(({a:e})=>e!==``)}}),m=a,h=r.map(e=>[e,az.get(e)]);C(d,{onOptimistic:()=>{r.forEach(e=>az.clear(e)),o(e=>{let t={...e};for(let e of i)delete t[e];return t})},onRollback:()=>{o(e=>{let t={...e};for(let e of i)m[e]?t[e]=m[e]:delete t[e];return t}),h.forEach(([e,t])=>{t&&!az.get(e)&&az.set(e,t)})}})},[a,s,_,C,p,f]),T=(0,I.useCallback)(e=>{let t=v.get(fY(e));if(t)return{answerFor:e=>_(t.identity,e),onChip:(e,n)=>y(t.identity,e,n),onText:(e,n)=>b(t.identity,e,n),onSubmit:()=>w(t.identity),anyAnswered:t.blocks.some((e,n)=>Uq(e,_(t.identity,n))!==``),sending:i.pending}},[v,_,y,b,w,i.pending]);return{liveMsg:c,answering:(0,I.useMemo)(()=>c?T(c):void 0,[c,T]),answeringForMessage:T,answerable:l,anyAnswered:x,sending:i.pending,sendAnswers:w,sendMessage:C}}function bY(e){let t=e.split(`
307
307
  `).map(e=>e.trim()).find(e=>e.length>0)??``;return t.length>120?`${t.slice(0,117)}…`:t}function xY(e){return bY(e.contextMd)||bY(e.options.join(` / `))||`earlier question`}function SY(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0).toString(36)}function CY({raw:e,question:t,questionKind:n,danger:r,interactive:i,wrap:a,aside:o,label:s,settled:c}){let l=(0,I.useMemo)(()=>t??zq(e??``,n??`question`,r),[t,e,n,r]),u=gK(l.contextMd),d=gK(l.trailingMd??``),f=l.recommendedIdx,p=vK(l.recommendation??``),m=l.kind===`multi`,h=l.danger,g=i?.answer.chosen??null,_=i?.answer.chosenSet??[],v=i?.answer.text??``,y=(0,I.useRef)(null),b=(0,I.useRef)(null);return(0,I.useLayoutEffect)(()=>{let e=y.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`)},[v]),(0,L.jsxs)(nJ,{tone:h?`risk`:`neutral`,icon:h?rh:void 0,label:s??(m?`Select multiple`:`Question`),aside:o,children:[u&&(0,L.jsx)(`div`,{className:`text-fg`,children:(0,L.jsx)(hq,{className:`md-body${a?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:u})}),(l.options.length>0||i)&&(0,L.jsxs)(`div`,{ref:b,tabIndex:-1,onKeyDown:e=>{!i||e.target!==e.currentTarget||IL({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),e.stopPropagation(),i.onSubmit())},className:`mt-2 grid grid-cols-1 gap-1.5 outline-none`,children:[l.options.map((e,t)=>(0,L.jsxs)(I.Fragment,{children:[l.optionHeadings?.[t]&&(0,L.jsx)(wY,{md:l.optionHeadings[t],wrap:a}),(0,L.jsx)(EY,{label:e,bodyMd:l.optionBodies?.[t],wrap:a,multi:m,recommended:f===t,recTitle:f===t?l.recommendedNote:void 0,selected:m?_.includes(t):g===t,settledPick:c?.chosenIdxs.includes(t)??!1,disabled:!i,onClick:()=>{i?.onChip(t,e),!(m&&y.current&&document.activeElement===y.current)&&b.current?.focus()}})]},t)),i&&(0,L.jsx)(`textarea`,{ref:y,rows:1,"data-surface":`questionAnswer`,value:v,onChange:e=>i.onText(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){e.preventDefault(),e.currentTarget.blur();return}IL({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),i.onSubmit())},onFocus:()=>{!m&&g!==null&&i.onText(v)},placeholder:m?`Add a note…`:l.options.length?`${TY(l.options)} Something else…`:`Type your answer…`,className:`col-span-full w-full resize-none overflow-hidden rounded-md border px-3 py-1.5 text-[12px] leading-snug text-fg/90 outline-none placeholder:text-muted/80 transition-colors ${v.trim()&&(m||g===null)?`border-accent bg-accent/10`:`border-border bg-transparent hover:bg-panel-2 focus:border-accent`}`})]}),c?.text&&(0,L.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap [overflow-wrap:anywhere] rounded-md border border-border-strong border-l-2 border-l-accent/40 bg-bg/50 py-1.5 pl-[11px] pr-3 text-[12px] leading-snug text-fg`,children:c.text}),c&&c.chosenIdxs.length===0&&!c.text&&(0,L.jsx)(`div`,{className:`mt-2 text-[11px] text-muted/70`,children:`Not answered`}),l.trailingMd&&(0,L.jsx)(hq,{className:`mt-2 md-body text-[12px] text-muted/70${a?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:d}),l.recommendation&&f===null&&(0,L.jsx)(hq,{className:`md-inline mt-1.5 text-[11px] text-muted/70`,html:p})]})}function wY({md:e,wrap:t}){let n=vK(e.split(`
308
- `).join(` `));return(0,L.jsx)(`div`,{className:`mt-1 text-fg`,children:(0,L.jsx)(hq,{className:`md-body${t?` ${Jq}`:``}`,html:n})})}function TY(e){let t=e[e.length-1]?.match(/^\s*([A-Za-z]|\d+)([.)])\s/);if(!t)return`${String.fromCharCode(65+e.length)}.`;let[,n,r]=t;return/\d/.test(n)?`${Number(n)+1}${r}`:`${String.fromCharCode(n.toUpperCase().charCodeAt(0)+1)}${r}`}function EY({label:e,bodyMd:t,wrap:n,selected:r,settledPick:i,disabled:a,multi:o,recommended:s,recTitle:c,onClick:l}){let u=vK(e),d=gK(t??``),f=(0,I.useId)();return(0,L.jsxs)(`div`,{"data-question-option":!0,title:c,onClick:e=>{a||e.target.closest(`a, button, .local-file-action, .local-file-code`)||window.getSelection()?.toString()||l()},className:`relative flex items-start gap-2 rounded-md border px-3 py-1.5 text-[12px] leading-snug transition-colors ${r?`border-accent bg-accent/10 text-fg`:i?`border-border-strong border-l-2 border-l-accent/40 bg-bg/50 pl-[11px] text-fg`:a?`border-border text-muted/80`:`border-border text-fg/90 hover:bg-elevated hover:border-border-strong`}`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:a,"aria-labelledby":f,onClick:l,onMouseDown:e=>e.preventDefault(),className:`absolute inset-0 rounded-md outline-none`}),o&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`mt-px flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-[3px] border ${r?`border-accent bg-accent text-bg`:i?`border-border-strong text-fg`:`border-border-strong`}`,children:(r||i)&&(0,L.jsx)(Qp,{size:10,strokeWidth:3})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{id:f,children:[s&&(0,L.jsx)(`span`,{className:`pointer-events-none float-right ml-2 mt-px -translate-y-[2px] rounded-full border border-border-strong px-1.5 py-px text-[9.5px] uppercase tracking-wide text-muted`,children:`Recommended`}),(0,L.jsx)(hq,{as:`span`,className:`md-inline`,html:u})]}),t!==void 0&&(0,L.jsx)(hq,{className:`md-body mt-1.5 text-[11.5px] opacity-90${n?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:d})]})]})}function DY({blocks:e,answering:t,onClose:n}){let[r,i]=(0,I.useState)(0),[a,o]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let e=requestAnimationFrame(()=>o(!0));return()=>cancelAnimationFrame(e)},[]),(0,I.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),n())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n]);let s=e[Math.min(r,e.length-1)];if(!s)return null;let c=r>=e.length-1;return(0,ot.createPortal)((0,L.jsxs)(`div`,{"data-mobile-answer-sheet":!0,className:`fixed inset-0 z-[80] flex flex-col justify-end`,children:[(0,L.jsx)(`button`,{"aria-label":`Close`,onClick:n,className:`absolute inset-0 bg-black/50 transition-opacity duration-200 ${a?`opacity-100`:`opacity-0`}`}),(0,L.jsxs)(`div`,{className:`relative flex max-h-[86%] flex-col overflow-hidden rounded-t-[14px] border-t border-border-strong bg-panel pb-[env(safe-area-inset-bottom)] shadow-[0_-20px_60px_-10px_rgba(0,0,0,0.8)] transition-transform duration-200 ease-out motion-reduce:transition-none ${a?`translate-y-0`:`translate-y-full`}`,children:[(0,L.jsx)(`div`,{className:`mx-auto mt-[6px] h-[5px] w-[36px] shrink-0 rounded-full bg-muted/35`}),(0,L.jsxs)(`div`,{className:`flex h-[48px] shrink-0 items-center gap-2 border-b border-border/70 px-3`,children:[(0,L.jsx)(`button`,{onClick:n,className:`flex h-[44px] items-center px-2 text-[16px] text-fg/85`,children:`Cancel`}),(0,L.jsx)(`span`,{className:`flex-1 text-center text-[15px] font-semibold tracking-[-0.01em] text-fg`,children:e.length>1?`Question ${r+1} of ${e.length}`:`Question`}),(0,L.jsx)(`span`,{className:`flex h-[44px] w-[44px] items-center justify-center`,children:(0,L.jsx)(ah,{size:19,className:`opacity-0`,"aria-hidden":!0})})]}),(0,L.jsx)(`div`,{"data-mobile-answer-body":!0,className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:(0,L.jsx)(CY,{raw:s.raw,questionKind:s.kind,danger:s.danger,interactive:{answer:t.answerFor(s.bi),onChip:(e,n)=>t.onChip(s.bi,e,n),onText:e=>t.onText(s.bi,e),onSubmit:()=>c?l():i(e=>e+1)}},s.bi)}),(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center gap-3 border-t border-border/70 px-4 pb-[30px] pt-3`,children:[e.length>1?(0,L.jsx)(`div`,{className:`flex items-center gap-1.5`,children:e.map((e,t)=>(0,L.jsx)(`span`,{className:`size-[6px] rounded-full ${t===r?`bg-accent`:`bg-muted/35`}`},e.bi))}):null,(0,L.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[r>0?(0,L.jsx)(`button`,{onClick:()=>i(e=>e-1),className:`flex h-[50px] shrink-0 items-center justify-center rounded-[14px] border border-border-strong bg-elevated px-5 text-[17px] text-fg active:bg-panel-2`,children:`Back`}):null,(0,L.jsx)(`button`,{onClick:()=>c?l():i(e=>e+1),disabled:c?!t.anyAnswered||t.sending:!1,className:`flex h-[50px] flex-1 items-center justify-center rounded-[14px] bg-accent px-5 text-[17px] font-semibold text-bg transition-[filter,opacity] active:brightness-90 disabled:opacity-40`,children:c?t.sending?`Sending…`:`Send answers`:`Continue`})]})]})]})]}),document.body);function l(){t.onSubmit(),n()}}function OY(e){return(0,I.useSyncExternalStore)(e=>Jt(X,e),()=>e?kY(e)!==`codex`:!1,()=>!1)}function kY(e){return Dp(X.board,e)?.backend}function AY(e,t,n,r){let i=sz.followUp(e,t,n),a=az.get(i),o=a?`${r}\n\n${a}`:r;return az.set(i,o),i}function jY(e){if(!(typeof document>`u`)){for(let t=e;t;t=t.parentElement){let e=t.querySelector(`[data-thread-composer-box] textarea`);if(e){e.focus(),e.setSelectionRange(e.value.length,e.value.length);return}}document.getElementById(`followup-input`)?.focus()}}function MY(e){let t=Ve(),n=cz(),[r,i]=(0,I.useState)(!1);return{unqueue:(0,I.useCallback)(a=>{if(!e||r)return;let o=Dp(X.board,e)?.sessionId;if(!o){Z(`This thread has no live session to unqueue from`);return}i(!0),Y.unqueueFollowUp({slug:e,sessionId:o,deliveryId:a.deliveryId}).then(r=>{if(i(!1),!r.unqueued){Z(r.reason??`That message could not be taken back`);return}JC(t,e,a.rawText,a.deliveryId),AY(n,e,o,a.text),jY(a.from)},e=>{i(!1),Z(`Couldn't unqueue — ${(e instanceof Error?e.message:String(e)).slice(0,90)}`)})},[r,n,t,e]),pending:r}}function NY(e){return(0,I.useSyncExternalStore)(e=>Jt(X,e),()=>{if(!e)return!1;let t=Dp(X.board,e);return t?.backend!==`codex`&&t?.runtime===`running`},()=>!1)}function PY(e){let[t,n]=(0,I.useState)(!1);return{deliverNow:(0,I.useCallback)(()=>{if(!e||t)return;let r=Dp(X.board,e)?.sessionId;if(!r){Z(`This thread has no live session to interrupt`);return}n(!0),Y.deliverQueuedNow({slug:e,sessionId:r}).then(e=>{n(!1),e.interrupted||Z(e.reason??`That message could not be pushed through`)},e=>{n(!1),Z(`Couldn't push it through — ${(e instanceof Error?e.message:String(e)).slice(0,90)}`)})},[t,e]),pending:t}}function FY(e){return e.displayText??e.text}function IY(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role===`user`&&!n.queued&&!n.peerFrom&&!n.agentInstruction)return t}return-1}function LY(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.role!==`user`||n.queued||n.peerFrom||n.agentInstruction)&&!(n.wake&&!yJ(n)))return t}return 0}function RY(e,t){if(e.kind===`event`||e.kind===`reasoning`||e.role!==`user`)return!1;let n=FY(e).replace(/\r\n?/g,`
308
+ `).join(` `));return(0,L.jsx)(`div`,{className:`mt-1 text-fg`,children:(0,L.jsx)(hq,{className:`md-body${t?` ${Jq}`:``}`,html:n})})}function TY(e){let t=e[e.length-1]?.match(/^\s*([A-Za-z]|\d+)([.)])\s/);if(!t)return`${String.fromCharCode(65+e.length)}.`;let[,n,r]=t;return/\d/.test(n)?`${Number(n)+1}${r}`:`${String.fromCharCode(n.toUpperCase().charCodeAt(0)+1)}${r}`}function EY({label:e,bodyMd:t,wrap:n,selected:r,settledPick:i,disabled:a,multi:o,recommended:s,recTitle:c,onClick:l}){let u=vK(e),d=gK(t??``),f=(0,I.useId)();return(0,L.jsxs)(`div`,{"data-question-option":!0,title:c,onClick:e=>{a||e.target.closest(`a, button, .local-file-action, .local-file-code`)||window.getSelection()?.toString()||l()},className:`relative flex items-start gap-2 rounded-md border px-3 py-1.5 text-[12px] leading-snug transition-colors ${r?`border-accent bg-accent/10 text-fg`:i?`border-border-strong border-l-2 border-l-accent/40 bg-bg/50 pl-[11px] text-fg`:a?`border-border text-muted/80`:`border-border text-fg/90 hover:bg-elevated hover:border-border-strong`}`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:a,"aria-labelledby":f,onClick:l,onMouseDown:e=>e.preventDefault(),className:`absolute inset-0 rounded-md outline-none`}),o&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`mt-px flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-[3px] border ${r?`border-accent bg-accent text-bg`:i?`border-border-strong text-fg`:`border-border-strong`}`,children:(r||i)&&(0,L.jsx)(Qp,{size:10,strokeWidth:3})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{id:f,children:[s&&(0,L.jsx)(`span`,{className:`pointer-events-none float-right ml-2 mt-px -translate-y-[2px] rounded-full border border-border-strong px-1.5 py-px text-[9.5px] uppercase tracking-wide text-muted`,children:`Recommended`}),(0,L.jsx)(hq,{as:`span`,className:`md-inline`,html:u})]}),t!==void 0&&(0,L.jsx)(hq,{className:`md-body mt-1.5 text-[11.5px] opacity-90${n?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:d})]})]})}function DY({blocks:e,answering:t,onClose:n}){let[r,i]=(0,I.useState)(0),[a,o]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let e=requestAnimationFrame(()=>o(!0));return()=>cancelAnimationFrame(e)},[]),(0,I.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),n())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n]);let s=e[Math.min(r,e.length-1)];if(!s)return null;let c=r>=e.length-1;return(0,ot.createPortal)((0,L.jsxs)(`div`,{"data-mobile-answer-sheet":!0,className:`fixed inset-0 z-[80] flex flex-col justify-end`,children:[(0,L.jsx)(`button`,{"aria-label":`Close`,onClick:n,className:`absolute inset-0 bg-black/50 transition-opacity duration-200 ${a?`opacity-100`:`opacity-0`}`}),(0,L.jsxs)(`div`,{className:`relative flex max-h-[86%] flex-col overflow-hidden rounded-t-[14px] border-t border-border-strong bg-panel pb-[env(safe-area-inset-bottom)] shadow-[0_-20px_60px_-10px_rgba(0,0,0,0.8)] transition-transform duration-200 ease-out motion-reduce:transition-none ${a?`translate-y-0`:`translate-y-full`}`,children:[(0,L.jsx)(`div`,{className:`mx-auto mt-[6px] h-[5px] w-[36px] shrink-0 rounded-full bg-muted/35`}),(0,L.jsxs)(`div`,{className:`flex h-[48px] shrink-0 items-center gap-2 border-b border-border/70 px-3`,children:[(0,L.jsx)(`button`,{onClick:n,className:`flex h-[44px] items-center px-2 text-[16px] text-fg/85`,children:`Cancel`}),(0,L.jsx)(`span`,{className:`flex-1 text-center text-[15px] font-semibold tracking-[-0.01em] text-fg`,children:e.length>1?`Question ${r+1} of ${e.length}`:`Question`}),(0,L.jsx)(`span`,{className:`flex h-[44px] w-[44px] items-center justify-center`,children:(0,L.jsx)(ah,{size:19,className:`opacity-0`,"aria-hidden":!0})})]}),(0,L.jsx)(`div`,{"data-mobile-answer-body":!0,className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:(0,L.jsx)(CY,{raw:s.raw,questionKind:s.kind,danger:s.danger,interactive:{answer:t.answerFor(s.bi),onChip:(e,n)=>t.onChip(s.bi,e,n),onText:e=>t.onText(s.bi,e),onSubmit:()=>c?l():i(e=>e+1)}},s.bi)}),(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center gap-3 border-t border-border/70 px-4 pb-[30px] pt-3`,children:[e.length>1?(0,L.jsx)(`div`,{className:`flex items-center gap-1.5`,children:e.map((e,t)=>(0,L.jsx)(`span`,{className:`size-[6px] rounded-full ${t===r?`bg-accent`:`bg-muted/35`}`},e.bi))}):null,(0,L.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[r>0?(0,L.jsx)(`button`,{onClick:()=>i(e=>e-1),className:`flex h-[50px] shrink-0 items-center justify-center rounded-[14px] border border-border-strong bg-elevated px-5 text-[17px] text-fg active:bg-panel-2`,children:`Back`}):null,(0,L.jsx)(`button`,{onClick:()=>c?l():i(e=>e+1),disabled:c?!t.anyAnswered||t.sending:!1,className:`flex h-[50px] flex-1 items-center justify-center rounded-[14px] bg-accent px-5 text-[17px] font-semibold text-bg transition-[filter,opacity] active:brightness-90 disabled:opacity-40`,children:c?t.sending?`Sending…`:`Send answers`:`Continue`})]})]})]})]}),document.body);function l(){t.onSubmit(),n()}}function OY(e){return(0,I.useSyncExternalStore)(e=>Jt(X,e),()=>e?kY(e)!==`codex`:!1,()=>!1)}function kY(e){return Dp(X.board,e)?.backend}function AY(e,t,n,r){let i=sz.followUp(e,t,n),a=az.get(i),o=a?`${r}\n\n${a}`:r;return az.set(i,o),i}function jY(e){if(!(typeof document>`u`)){for(let t=e;t;t=t.parentElement){let e=t.querySelector(`[data-thread-composer-box] textarea`);if(e){e.focus(),e.setSelectionRange(e.value.length,e.value.length);return}}document.getElementById(`followup-input`)?.focus()}}function MY(e){let t=Ve(),n=cz(),[r,i]=(0,I.useState)(!1);return{unqueue:(0,I.useCallback)(a=>{if(!e||r)return;let o=Dp(X.board,e)?.sessionId;if(!o){Z(`This thread has no live session to unqueue from`);return}i(!0),Y.unqueueFollowUp({slug:e,sessionId:o,deliveryId:a.deliveryId}).then(r=>{if(i(!1),!r.unqueued){Z(r.reason??`That message could not be taken back`);return}JC(t,e,a.rawText,a.deliveryId),AY(n,e,o,a.text),jY(a.from)},e=>{i(!1),Z(`Couldn't unqueue — ${(e instanceof Error?e.message:String(e)).slice(0,160)}`)})},[r,n,t,e]),pending:r}}function NY(e){return(0,I.useSyncExternalStore)(e=>Jt(X,e),()=>{if(!e)return!1;let t=Dp(X.board,e);return t?.backend!==`codex`&&t?.runtime===`running`},()=>!1)}function PY(e){let[t,n]=(0,I.useState)(!1);return{deliverNow:(0,I.useCallback)(()=>{if(!e||t)return;let r=Dp(X.board,e)?.sessionId;if(!r){Z(`This thread has no live session to interrupt`);return}n(!0),Y.deliverQueuedNow({slug:e,sessionId:r}).then(e=>{n(!1),e.interrupted||Z(e.reason??`That message could not be pushed through`)},e=>{n(!1),Z(`Couldn't push it through — ${(e instanceof Error?e.message:String(e)).slice(0,160)}`)})},[t,e]),pending:t}}function FY(e){return e.displayText??e.text}function IY(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role===`user`&&!n.queued&&!n.peerFrom&&!n.agentInstruction)return t}return-1}function LY(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.role!==`user`||n.queued||n.peerFrom||n.agentInstruction)&&!(n.wake&&!yJ(n)))return t}return 0}function RY(e,t){if(e.kind===`event`||e.kind===`reasoning`||e.role!==`user`)return!1;let n=FY(e).replace(/\r\n?/g,`
309
309
  `);return(t===void 0?_J(n):t)?!0:!(e.wake||e.peerFrom)}function zY(e,t){return RY(e,t)?`bubble`:`prose`}var BY=`icon-label-nudge`,VY=new Set([`planning`,`planned`,`active`,`needs-human`,`blocked`]);function HY(e){return!!(e&&e.kind===`legacy`&&!e.foreign&&e.runtime===`none`&&!e.sessionId&&!e.threadName&&!e.owner&&e.agents.length===0&&e.errors.length===0&&VY.has(e.status))}function UY(e,t){let n=e.trim();if(!(!n||n===t.trim()))return n}function WY(e,t){let n=e.trim();return!n||n===t||n===`Untitled thread`||n===`Spinning up a thread…`?``:n}function GY(e){return e.kind!==`session`||e.foreign||e.backend===`codex`||e.claudeRuntime!==void 0&&e.claudeRuntime!==`broker`?{show:!1,enabled:!1,label:``}:e.runtime===`exited`||e.runtime===`none`?{show:!0,enabled:!1,label:`Resume this Claude thread to rename it with Claude`}:e.runtime===`spawning`?{show:!0,enabled:!1,label:`Rename with Claude once this thread has started`}:{show:!0,enabled:!0,label:`Rename with Claude — a fresh title from the opening request`}}var KY=`sticky top-0 z-10 flex min-w-0 shrink-0 items-center gap-2.5 border-b border-border bg-panel px-3 ${oh} max-[640px]:h-auto max-[640px]:min-h-12 max-[640px]:flex-wrap max-[640px]:items-start max-[640px]:gap-y-2 max-[640px]:px-4 max-[640px]:py-2.5`,qY=`min-w-0 flex-1 pl-1 max-[640px]:basis-full`,JY=`flex shrink-0 items-center max-[640px]:w-full max-[640px]:justify-between`;function YY(e){return e?.trim()?{kind:`profile-error`,message:`Profile controls unavailable: ${e.trim().slice(0,160)}`}:null}function XY(e){if(e.foreign)return`Read-only external thread`;if(e.permissionChangePending||e.permissionPending)return`A permission change is already in progress`;if(e.profileChangePending)return`A model and effort change is already in progress`;if(e.runtimeControlPending)return`Another runtime control is already in progress`;if(e.pendingAsk||e.runtime===`perm-prompt`)return`Resolve the current terminal approval or question first`;if(e.backend===`codex`)return null;let t=[...e.subAgents??[],...e.bgShells??[]].filter(e=>e.state===`running`||e.state===`stale`).length;return t>0?`Wait for ${t} unresolved background operation${t===1?``:`s`}`:e.runtime===`running`||e.runtime===`spawning`?`Wait for the current turn to finish`:null}function ZY(e){return e.permissionChangePending===!0||e.permissionPending!==void 0||e.profileChangePending===!0||e.runtimeControlPending===!0}function QY(e,t){let n=t===`codex`?`Sandbox`:`Permissions`;return e===`applied`?`${n} applied to the live session`:e===`next-turn`?t===`codex`?`${n} applied — takes effect on the next turn`:`${n} saved — the worker restarts on the next turn`:`${n} saved for the next resume`}function $Y(e){return e===`right`?`pl-3 pr-7`:`pl-7 pr-3`}function eX(e,t,n,r){let i=(n?n.flatMap(e=>e.options):t??[]).find(t=>t.value===e);return i?{text:i.label,placeholder:!1}:e?{text:e,placeholder:!1}:{text:r??``,placeholder:!0}}var tX=`__frizz_empty_select_value__`,nX=e=>e===``?tX:e,rX=e=>e===tX?``:e,iX={ghost:`border-transparent bg-transparent hover:border-border hover:bg-panel-2 data-[state=open]:border-border data-[state=open]:bg-panel-2`,bordered:`w-full justify-between border-border bg-bg hover:bg-panel-2 data-[state=open]:bg-panel-2`,readout:`text-muted hover:text-fg border-border/50 bg-transparent hover:border-border hover:bg-panel-2 data-[state=open]:border-border data-[state=open]:bg-panel-2 [&_.select-caret]:text-fg/65 [&_.select-caret]:opacity-100`},aX={ghost:`border-transparent bg-transparent`,bordered:`w-full justify-between border-border bg-bg`,readout:`text-muted border-border/50 bg-transparent [&_.select-caret]:text-fg/65 [&_.select-caret]:opacity-100`};function oX({o:e,indicatorPosition:t,typography:n}){return(0,L.jsxs)(bI,{value:nX(e.value),title:e.title,className:`relative flex w-full min-w-0 cursor-pointer select-none items-center overflow-hidden rounded-md py-1.5 text-left text-[12px] text-muted outline-none data-[highlighted]:bg-panel-2 data-[highlighted]:text-fg data-[state=checked]:bg-panel-2 data-[state=checked]:font-medium data-[state=checked]:text-fg ${$Y(t)} ${n??``}`,children:[(0,L.jsx)(xI,{className:`pointer-events-none absolute top-1/2 inline-flex -translate-y-1/2 items-center text-accent ${t===`right`?`right-2`:`left-2`}`,children:(0,L.jsx)(Qp,{size:13})}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]})}function sX({value:e,onValueChange:t,options:n,groups:r,placeholder:i,ariaLabel:a,title:o,disabled:s=!1,variant:c=`ghost`,indicatorPosition:l=`left`,side:u=`bottom`,className:d=``}){let f=eX(e,n,r,i),p=s?aX[c]:iX[c],m=c===`readout`?tR:``,[h,g]=(0,I.useState)(!1),_=(0,I.useRef)(h),v=(0,I.useRef)(s),y=(0,I.useRef)(void 0);return _.current=h,v.current=s,(0,I.useLayoutEffect)(()=>{let e=e=>{e.key!==`Escape`||!_.current||v.current||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),_.current=!1,y.current?.(),y.current=void 0,g(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]),(0,I.useLayoutEffect)(()=>{!s||!h||(_.current=!1,y.current?.(),y.current=void 0,g(!1))},[s,h]),(0,I.useLayoutEffect)(()=>()=>y.current?.(),[]),(0,L.jsxs)(fI,{modal:!1,open:h,onOpenChange:e=>{y.current?.(),y.current=void 0,_.current=e,g(e),e&&(y.current=yR(()=>{_.current=!1,y.current=void 0,g(!1)}))},children:[(0,L.jsx)(pI,{asChild:!0,disabled:s,children:(0,L.jsxs)(`button`,{type:`button`,"aria-label":a,title:o,className:`group inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md border px-2 py-1 text-left text-[12px] text-fg outline-none data-[placeholder]:text-muted ${s?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors`} ${p} ${c===`readout`?`select-trigger-readout`:``} ${m} ${d}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left ${f.placeholder?`text-muted`:``}`,children:f.text}),(0,L.jsx)($p,{className:`select-caret shrink-0 text-muted ${s?``:`transition-transform group-data-[state=open]:rotate-180`}`,size:13})]})}),(0,L.jsx)(mI,{children:(0,L.jsx)(hI,{align:`start`,side:u,sideOffset:5,onEscapeKeyDown:e=>e.stopPropagation(),className:`${Pj} min-w-[var(--radix-dropdown-menu-trigger-width)] max-w-[calc(100vw-1rem)] overflow-hidden rounded-lg p-1 ${m}`,children:(0,L.jsx)(yI,{value:nX(e),onValueChange:e=>t(rX(e)),className:`max-h-[300px] min-w-0 overflow-y-auto`,children:r?r.map((e,t)=>(0,L.jsxs)(gI,{children:[e.label&&(0,L.jsx)(_I,{className:`${$Y(l)} min-w-0 truncate pb-1 pt-2 text-left text-[10px] font-medium uppercase tracking-wide text-muted/60 first:pt-1`,children:e.label}),e.options.map(e=>(0,L.jsx)(oX,{o:e,indicatorPosition:l,typography:m},e.value))]},e.label||`g${t}`)):(n??[]).map(e=>(0,L.jsx)(oX,{o:e,indicatorPosition:l,typography:m},e.value))})})})]})}function cX(e,t,n,r){let i=e.find(e=>e.model===t),a=!!i,o=!!(i&&n&&i.efforts.includes(n)),s=a&&o;return{selectedProfile:i,modelKnown:a,effortKnown:o,profileKnown:s,modelSelectable:r||a,effortSelectable:!!i&&(r||s)}}function lX(e){let t=Zt(X).board?.threads.find(t=>t.id===e),n=nt({queryKey:[`threadProfileOptions`,e],queryFn:()=>Y.threadProfileOptions({slug:e}),enabled:!!(t&&!t.foreign&&t.kind===`session`),staleTime:5e3}),r=it({mutationFn:t=>Y.setThreadProfile({slug:e,...t})}),i=it({mutationFn:t=>Y.setThreadPermission({slug:e,permissionMode:t})}),a=r.isPending||i.isPending;if(!t||t.foreign||t.kind!==`session`)return{busy:a,footer:null,status:null};let o=a||ZY(t),s=t.model?.trim(),c=t.effort?.trim(),l=t.backend===`codex`?`codex`:`claude`,u=r.isPending?r.variables:void 0,d=t.profilePendingModel??u?.model,f=t.profilePendingEffort??u?.effort,p=n.data?.options??[],{modelSelectable:m}=cX(p,s,c,t.runtime===`exited`),h=n.data!==void 0,g=[{id:l,label:l===`codex`?`Codex`:`Claude Code`,options:p}],_=YY(n.isError?n.error.message:void 0),v=t.permissionMode?LR(t.permissionMode):`auto`,y=FR.some(e=>e.value===v)?v:`auto`,b=i.isPending?i.variables:y,x=XY(t);function S(e){e!==y&&i.mutate(e,{onSuccess:e=>Z(QY(e.effect,`claude`)),onError:e=>Z(`Permission change failed: ${e.message.slice(0,120)}`)})}function C(e){r.mutate(e,{onSuccess:e=>Z(e.effect===`next-resume`?`Model and effort saved for the next resume`:`Model and effort applied`),onError:e=>Z(`Profile change failed: ${e.message.slice(0,120)}`)})}return{busy:o,footer:(0,L.jsxs)(`div`,{"data-thread-composer-controls":!0,className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-1.5 gap-y-0.5`,children:[(0,L.jsx)(CR,{groups:g,value:{provider:l,model:s,effort:c},pending:d||f?{provider:l,model:d,effort:f}:void 0,onValueChange:({model:e,effort:t})=>C({model:e,effort:t}),placeholder:n.isPending?`Profile loading…`:`Profile unknown`,ariaLabel:`Thread model and effort`,menuAriaLabel:`Choose ${l===`codex`?`Codex`:`Claude Code`} model and effort`,title:m?t.runtime===`exited`?`Saved per thread and applied when this conversation resumes`:`Change this idle conversation's model and reasoning effort`:`The current live backend profile is unavailable; controls fail closed`,disabled:o||!h||!m||n.isError,compact:!0,side:`top`,className:`min-w-0 max-w-[min(72%,20rem)] px-1.5 py-0.5`}),l===`claude`&&(0,L.jsx)(sX,{variant:`readout`,side:`top`,value:b,onValueChange:e=>S(e),options:FR,ariaLabel:`Thread permission mode`,title:x?`${x} — changing permissions restarts this thread's worker process`:b===`bypassPermissions`?`Bypass: the worker never asks for approval. Changing this restarts the worker process; the conversation resumes from disk on the next turn.`:`Auto: risky actions raise an approval card here. Changing this restarts the worker process; the conversation resumes from disk on the next turn.`,disabled:o||x!==null,className:`shrink-0`}),d&&f&&(0,L.jsxs)(`span`,{className:`min-w-0 truncate text-[9px] text-muted/50`,children:[`→ `,d,` · `,f,` pending`]})]}),status:_?(0,L.jsx)(`div`,{"data-thread-control-error":``,className:`px-1 pt-1 text-[9.5px] leading-tight text-muted/65`,children:_.message}):null}}var uX=new Map;function dX(e){let t=uX.get(e);if(t)return t;let n=Y.threadSkills({slug:e}).then(e=>e.skills,()=>(uX.delete(e),[]));return uX.set(e,n),n}function fX({slug:e,surface:t,placeholder:n,className:r,id:i,ops:a,submitOverride:o}){let s=Zt(X),c=s.board?.threads.find(t=>t.id===e),l=cz(),u=sz.followUp(l,e,c?.sessionId),[d,f,p]=uz(u),m=lX(e),h=TH(e),[g,_]=(0,I.useState)(null),v=(0,I.useMemo)(()=>()=>dX(e),[e]),[y,b]=(0,I.useState)(null),x=s.composerContext[e],S=(0,I.useMemo)(()=>x?.map(e=>e.token)??[],[x]);(0,I.useEffect)(()=>{let t=X.composerContext[e];if(!t?.length)return;let{prose:n}=hL(d),r=t.filter(e=>xL(n,e.token));r.length!==t.length&&(X.composerContext[e]=r)},[e,d,x]);let C=!o&&c?.runtime===`running`&&c.backend!==`codex`;function w(t=!1){let n=d.trim();if(!n)return;let r=OR(n);if(r){p();let e=c?.backend===`codex`?`codex`:`claude`;r===`login`?_(e):b(e);return}let i=gp(e),a=AL(n,i,l),s={onOptimistic:p,onRollback:()=>{az.get(u)||f(d),_p(e,i)}};o?o(a,s):h.submit(a,{...s,interrupt:t})}return(0,L.jsxs)(`div`,{"data-thread-composer-box":t,...t===`chatComposer`?{"data-thread-action-bar":``}:{},className:r,children:[(0,L.jsx)(XL,{contextTokens:S,id:i,surface:t,value:d,onChange:f,onSubmit:()=>w(),onInterruptSubmit:C?()=>w(!0):void 0,slashSuggest:v,placeholder:n,busy:m.busy,footer:m.footer}),m.status,(0,L.jsx)(`div`,{className:`ops-column-optical-inset empty:hidden`,children:a}),g&&(0,L.jsx)(AR,{backend:g,onClose:()=>_(null),onAuthed:()=>_(null)}),y&&(0,L.jsx)(jR,{backend:y,onClose:()=>b(null)})]})}function pX({slug:e,ops:t}){let n=Zt(X).board?.threads.find(t=>t.id===e);return n?(0,L.jsx)(fX,{slug:e,surface:`chatComposer`,id:`followup-input`,placeholder:n.foreign?`Send a message to take over this session…`:`Follow up…`,className:`shrink-0 px-3 py-3`,ops:t}):null}function mX({thread:e}){let[t,n]=(0,I.useState)(!1);if(e.kind!==`session`||e.foreign||e.claudeRuntime!==`broker`||e.runtime===`exited`)return null;async function r(){n(!0);try{let t=await Y.reloadThreadPlugins({slug:e.id,sessionId:e.sessionId??``}),n=[`${t.plugins} plugin${t.plugins===1?``:`s`}`,`${t.commands} skill${t.commands===1?``:`s`}`,`${t.agents} agent${t.agents===1?``:`s`}`],r=t.mcpServers.length?` · MCP: ${t.mcpServers.join(`, `)}`:``,i=t.errorCount?` · ${t.errorCount} load error${t.errorCount===1?``:`s`}`:``;Z(`Reloaded ${n.join(`, `)}${r}${i}`)}catch(e){Z((e instanceof Error?e.message:`Plugin reload failed`).slice(0,120))}finally{n(!1)}}return(0,L.jsx)(Rj,{label:`Reload plugins — hooks, skills, agents and MCP re-read from disk, same conversation`,side:`top`,children:(0,L.jsx)(`button`,{type:`button`,"data-reload-plugins":!0,disabled:t,"aria-label":`Reload plugins`,onMouseDown:e=>e.preventDefault(),onClick:()=>void r(),className:tD,children:(0,L.jsx)(Um,{size:14,strokeWidth:2})})})}function hX(e,t){return new Promise(n=>{wH(e,t,`Your worker process was restarted so it picks up frizz's current tooling (hooks and worker contract). Re-read whatever you left in your scratch directory, then continue exactly where you left off.`,{freshProcess:!0,onSuccess:()=>{Z(`Restarting worker…`),n()},onRollback:()=>n(),failureToast:e=>`Restart failed: ${e.slice(0,80)}`})||n()})}function gX(){return kV(zV().data??null)}function _X({thread:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return!gX()||e.kind!==`session`||e.foreign||e.backend===`codex`||e.runtime===`exited`?null:(0,L.jsx)(Rj,{label:`Restart worker — same conversation, fresh process on current tooling`,side:`top`,children:(0,L.jsx)(`button`,{type:`button`,disabled:n,"aria-label":`Restart worker`,onMouseDown:e=>e.preventDefault(),onClick:()=>{r(!0),hX(t,e.id).finally(()=>r(!1))},className:`${tD} mx-[2px]`,children:n?(0,L.jsx)(Mm,{size:14,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(Gm,{size:14,strokeWidth:2})})})}function vX({slug:e,label:t=`Exit fullscreen`}){let n=eD(e)??ZC(`/`);function r(e){Id(e)&&(e.preventDefault(),nw(n,{viewTransition:!Mp()}))}return(0,L.jsx)(Rj,{label:t,children:(0,L.jsx)(`a`,{href:n,"aria-label":t,"data-standalone-return":!0,onMouseDown:e=>e.preventDefault(),onClick:r,className:tD,children:(0,L.jsx)(Lm,{size:14})})})}function yX({thread:e,expand:t,collapse:n,onDoc:r,onDone:i,onCollapse:a,collapsed:o,doneBusy:s,onStatusMutate:c,onStatusApplied:l,onStatusFailed:u}){let d=e.kind===`session`;return(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[a&&(0,L.jsx)(xX,{label:o?`Expand`:`Collapse`,icon:o?rm:nm,size:13,onClick:a}),(0,L.jsx)(mX,{thread:e}),(0,L.jsx)(_X,{thread:e}),r&&(0,L.jsx)(xX,{label:`Frizz document`,icon:gm,size:14,onClick:r}),t&&(0,L.jsx)(zj,{slug:e.id}),n&&(0,L.jsx)(vX,{slug:e.id}),d?LT(e)?(0,L.jsx)(bX,{slug:e.id}):null:(0,L.jsx)(`div`,{className:`ml-1`,children:(0,L.jsx)(OI,{slug:e.id,onDone:i,doneBusy:s,onMutateStart:c,onApplied:l,onFailed:u})})]})}function bX({slug:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return(0,L.jsx)(Rj,{label:`Retry — resume this session where it left off`,children:(0,L.jsxs)(`button`,{onClick:()=>{r(!0),EH(t,e).finally(()=>r(!1))},disabled:n,"aria-label":`Retry exited session`,onMouseDown:e=>e.preventDefault(),className:`ml-1 flex items-center gap-1.5 rounded-md border border-accent/45 bg-accent/10 px-2.5 py-1 text-[12px] font-medium text-accent outline-none transition-colors hover:border-accent/70 hover:bg-accent/15 disabled:opacity-50`,children:[n?(0,L.jsx)(Mm,{size:12,className:`animate-spin`}):(0,L.jsx)(qm,{size:12}),`Retry`]})})}function xX({label:e,icon:t,size:n,busy:r,...i}){return(0,L.jsx)(Rj,{label:e,children:(0,L.jsx)(`button`,{...i,"aria-label":e,onMouseDown:e=>e.preventDefault(),className:tD,children:r?(0,L.jsx)(Mm,{size:n,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(t,{size:n,strokeWidth:2})})})}function SX(e){let t=e.kind===`session`&&e.foreign!==!0,n=t&&(e.state===`archived`||e.archived===!0),r=t,i=t&&!n;return{footer:r,done:n,snooze:i,archive:i}}function CX(e){if(e.runtime===`exited`&&e.crashed)return!1;if(e.runtime===`perm-prompt`||e.pendingAsk)return!0;if(e.runtime===`running`||e.runtime===`spawning`)return!1;let t=e=>e.state===`running`||e.state===`stale`;return!(e.subAgents?.some(e=>Xc(e)&&t(e))||e.bgShells?.some(t))}function wX(e){let t={lead:`This thread is still running.`,groups:[],trailer:`Marking it done will stop its agent session, then move it to Done.`};if(!e)return t;if(e.cutOff)return{lead:`This session was cut off mid-turn — its worker ended before the turn finished, so the thread isn’t done.`,groups:[],trailer:`Marking it done files it under Done as it is. Retry resumes it where it left off.`};let n=[TX(`agent`,`sub-agent`,e.subAgents,e.subAgentCount),TX(`shell`,`background shell`,e.bgShells,e.bgShellCount)].filter(e=>e!==null);return e.unobservable?{lead:`This session is live, but its transcript can’t be read right now — it may still be working.`,groups:n,trailer:`Marking it done will stop the session anyway, then move it to Done.`}:!e.turnInFlight&&n.length===0?t:{lead:e.turnInFlight?n.length>0?`The agent is mid-turn, and it still owns background work:`:`The agent is mid-turn — it’s executing right now.`:`The agent is resting, but the background work it launched is still running:`,groups:n,trailer:n.length>0?`Marking it done will stop the session and everything running under it, then move it to Done.`:`Marking it done will stop its agent session mid-turn, then move it to Done.`}}function TX(e,t,n,r){let i=Math.max(r,n.length);return i===0?null:{kind:e,heading:`${i} ${t}${i===1?``:`s`}`,items:n.map(e=>({label:e.label,stale:e.state===`stale`})),overflow:Math.max(0,i-n.length)}}function EX({open:e,onOpenChange:t,title:n,children:r,footer:i,className:a=`w-[640px] max-w-[92vw] max-h-[82vh]`}){return(0,L.jsx)(PI,{open:e,onOpenChange:t,children:(0,L.jsxs)(BI,{children:[(0,L.jsx)(HI,{className:`overlay-in fixed inset-0 z-[200] bg-black/55 backdrop-blur-[1px]`}),(0,L.jsxs)(KI,{"aria-modal":`true`,onEscapeKeyDown:xR,className:`pop-in fixed left-1/2 top-1/2 z-[200] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border bg-panel shadow-2xl shadow-black/50 outline-none ${a}`,children:[(0,L.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border px-4`,children:[(0,L.jsx)(ZI,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:n}),(0,L.jsx)(tL,{type:`button`,"aria-label":`Close`,className:`rounded-md p-1 text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg`,children:(0,L.jsx)(ah,{size:15})})]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:r}),i&&(0,L.jsx)(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3`,children:i})]})]})})}function DX({thread:e,onSnoozed:t}){let[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(``),f=(0,I.useId)(),p=(0,I.useId)(),m=(0,I.useId)(),h=DT(e),g=Zt(tT).snoozePreset,_=Lw(g),v=zw(g),y=(0,I.useMemo)(()=>Hw(new Date(Date.now()+6e4)),[i]);async function b(n,i=null){r(!0);try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:n,prompt:n?i:null}),n?(Z(`${i?`Bump scheduled`:`Snoozed`} · ${Ww(n)}`),t?.()):Z(`Snooze cleared`),a(!1),d(``)}catch(e){let t=e instanceof Error?e.message:`Snooze failed`;Z(t.slice(0,100)),d(t)}finally{r(!1)}}function x(e){tT.snoozePreset=e,b(Bw(e))}function S(){s(Hw(new Date(h??Bw(g)))),l(e.snoozePrompt??``),d(``),a(!0)}function C(){let e=Uw(o);if(!e.ok){d(e.message);return}let t=c.trim();if(t.length>4e3){d(`Prompt is too long (${t.length}/${fl})`);return}b(e.until,t||null)}return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`inline-flex items-stretch rounded-md border border-border-strong bg-panel-2/60`,children:[(0,L.jsxs)(`button`,{type:`button`,disabled:n,"aria-label":h?`Wake thread now`:v,title:h?`Wake now · ${Ww(h)}`:v,onClick:()=>void b(h?null:Bw(g)),className:`flex items-center gap-1.5 rounded-l-md px-2.5 py-1 text-[12px] font-medium text-fg/75 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60 disabled:cursor-not-allowed disabled:opacity-45`,children:[n&&(0,L.jsx)(Mm,{size:12,className:`animate-spin`}),h?`Wake now`:v]}),(0,L.jsx)(`span`,{"aria-hidden":!0,className:`my-1 w-px bg-border`}),(0,L.jsxs)(CI,{children:[(0,L.jsx)(wI,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,disabled:n,"aria-label":`Snooze options`,title:`Selected snooze: ${_}`,className:`flex min-w-0 items-center justify-center gap-1 rounded-r-md px-2 text-fg/75 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60 disabled:cursor-not-allowed disabled:opacity-45`,children:(0,L.jsx)($p,{size:12})})}),(0,L.jsxs)(TI,{align:`end`,children:[Pw.map(e=>(0,L.jsx)(EI,{onSelect:()=>x(e.value),icon:(0,L.jsx)(dm,{size:12}),children:(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-4`,children:[(0,L.jsx)(`span`,{children:e.label}),(0,L.jsx)(`span`,{className:`text-[10px] text-muted/55`,children:e.detail})]})},e.value)),(0,L.jsx)(DI,{}),(0,L.jsx)(EI,{onSelect:S,children:`Custom time & prompt…`}),h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(DI,{}),(0,L.jsx)(EI,{onSelect:()=>void b(null),children:`Wake now`})]})]})]})]}),(0,L.jsx)(EX,{open:i,onOpenChange:e=>{n||a(e)},title:`Snooze thread`,className:`w-[360px] max-w-[92vw]`,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>a(!1),className:`rounded-md px-3 py-1.5 text-[12px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:opacity-45`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`submit`,form:m,disabled:n,className:`flex items-center gap-1.5 rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-opacity hover:opacity-90 disabled:opacity-45`,children:[n&&(0,L.jsx)(Mm,{size:12,className:`animate-spin`}),c.trim()?`Snooze & bump`:`Snooze`]})]}),children:(0,L.jsxs)(`form`,{id:m,className:`flex flex-col gap-2.5 p-4`,onSubmit:e=>{e.preventDefault(),C()},children:[(0,L.jsx)(`label`,{htmlFor:f,className:`text-[11px] font-medium text-muted`,children:`Wake at this local time`}),(0,L.jsx)(`input`,{id:f,type:`datetime-local`,required:!0,min:y,value:o,onChange:e=>{s(e.target.value),d(``)},className:`w-full rounded-md border border-border bg-bg px-2.5 py-2 text-[13px] text-fg outline-none focus:border-accent`}),(0,L.jsx)(`p`,{className:`text-[10.5px] text-muted/65`,children:`Stored as an exact instant; shown here in your browser’s local time zone.`}),(0,L.jsxs)(`label`,{htmlFor:p,className:`mt-1 text-[11px] font-medium text-muted`,children:[`Then send this prompt `,(0,L.jsx)(`span`,{className:`font-normal text-muted/55`,children:`(optional)`})]}),(0,L.jsx)(`textarea`,{id:p,autoFocus:!0,rows:3,maxLength:fl,placeholder:`e.g. Check whether CI went green and land it if so.`,value:c,onChange:e=>{l(e.target.value),d(``)},onKeyDown:e=>{IL({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),C())},className:`w-full resize-y rounded-md border border-border bg-bg px-2.5 py-2 text-[13px] leading-5 text-fg outline-none placeholder:text-muted/40 focus:border-accent`}),(0,L.jsx)(`p`,{className:`min-h-4 text-[10.5px] text-muted/65`,children:c.trim()?`frizz will resume this thread with the prompt at the wake time.`:`Leave empty to just bring the card back to your queue.`}),u&&(0,L.jsx)(`p`,{role:`alert`,className:`text-[11px] text-red-400`,children:u})]})})]})}var OX=1.25,kX=7.5-OX/2,AX=2*Math.PI*kX;function jX(e,t){return Math.max(0,Math.min(100,Math.floor(e/t*100)))}function MX({thread:e}){let t=e.context;if(!t||t.window<=0)return null;let n=jX(t.tokens,t.window),r=Math.max(0,Math.min(1,t.tokens/t.window)),i=`Context ${n}% full\n${t.tokens.toLocaleString()} of ${t.window.toLocaleString()} tokens`;return(0,L.jsx)(Rj,{label:i,side:`top`,multiline:!0,children:(0,L.jsx)(`span`,{"data-context-meter":!0,"data-context-percent":n,"aria-label":i,className:`flex shrink-0 items-center text-muted/60`,children:(0,L.jsxs)(`svg`,{viewBox:`0 0 16 16`,className:`h-[1.05em] w-[1.05em]`,"aria-hidden":!0,style:{transform:`rotate(-90deg)`},children:[(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:kX,fill:`none`,stroke:`currentColor`,strokeOpacity:.3,strokeWidth:OX}),(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:kX,fill:`none`,stroke:`currentColor`,strokeWidth:OX,strokeDasharray:`${AX*r} ${AX}`})]})})})}var NX={sm:{track:`h-[16px] w-[28px]`,thumb:`size-[12px]`,travel:`translate-x-[12px]`,onCap:`translate-y-[calc(6px_-_0.5cap)]`},md:{track:`h-[20px] w-[34px]`,thumb:`size-[16px]`,travel:`translate-x-[14px]`,onCap:`translate-y-[calc(8px_-_0.5cap)]`}};function PX({checked:e,onChange:t,disabled:n,label:r,size:i=`sm`,testId:a}){let o=NX[i];return(0,L.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":r,disabled:n,"data-switch":a,"data-state":e?`checked`:`unchecked`,onMouseDown:e=>e.preventDefault(),onClick:()=>t(!e),className:`inline-flex shrink-0 cursor-pointer items-center self-baseline rounded-full p-[2px] outline-none transition-colors focus-visible:ring-1 focus-visible:ring-fg/60 disabled:cursor-default disabled:opacity-45 ${o.track} ${o.onCap} ${e?`bg-fg`:`bg-border hover:bg-border-strong`}`,children:(0,L.jsx)(`span`,{className:`pointer-events-none block rounded-full transition-transform duration-150 ease-out ${o.thumb} ${e?`bg-bg ${o.travel}`:`translate-x-0 bg-muted/70`}`})})}function FX({size:e=12,className:t=``}){return(0,L.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:t,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,L.jsx)(`path`,{d:`M12 7a5 5 0 1 0 5 5`}),(0,L.jsx)(`path`,{d:`M13 3.055a9 9 0 1 0 7.941 7.945`}),(0,L.jsx)(`path`,{d:`M15 6v3h3l3 -3h-3v-3l-3 3`}),(0,L.jsx)(`path`,{d:`M15 9l-3 3`})]})}function IX({thread:e}){let[t,n]=(0,I.useState)(`closed`),r=(0,I.useRef)(null),i=(0,I.useRef)(void 0);(0,I.useEffect)(()=>()=>clearTimeout(i.current),[]);let a=e.recurringPrompt,o=a?.stopHook===!0||a?.heartbeat===!0||a?.postCompaction===!0;function s(){clearTimeout(i.current),i.current=setTimeout(()=>n(e=>e===`closed`?`preview`:e),LX)}function c(){clearTimeout(i.current),n(e=>e===`preview`?`closed`:e)}let l=e=>{r.current?.contains(e.detail.originalEvent.target)&&e.preventDefault()};return(0,L.jsxs)(sV,{open:t!==`closed`,onOpenChange:e=>{e||(clearTimeout(i.current),n(`closed`))},children:[(0,L.jsx)(lV,{asChild:!0,children:(0,L.jsx)(`button`,{ref:r,type:`button`,"data-recurring-prompt":!0,"data-recurring-prompt-on":o?`true`:`false`,"aria-label":o?`Goal (on)`:`Goal`,"aria-haspopup":`dialog`,"aria-expanded":t===`full`,onClick:()=>{clearTimeout(i.current),n(e=>e===`full`?`closed`:`full`)},onPointerEnter:e=>{e.pointerType===`mouse`&&s()},onPointerLeave:e=>{e.pointerType===`mouse`&&c()},onFocus:()=>n(e=>e===`closed`?`preview`:e),onBlur:c,className:`flex items-center rounded-md px-0.5 py-0.5 outline-none ${VL}`,children:(0,L.jsx)(FX,{size:12,className:o?`text-amber-400/90`:`text-muted/60 hover:text-muted`})})}),t===`preview`?(0,L.jsx)(uV,{side:`top`,align:`start`,"data-recurring-preview":!0,onPointerDownOutside:l,className:`pointer-events-none max-w-[min(22rem,calc(100vw-1.5rem))] p-2.5 text-[11px] leading-snug text-fg`,onOpenAutoFocus:e=>e.preventDefault(),children:(0,L.jsx)(RX,{armed:a})}):(0,L.jsx)(uV,{side:`top`,align:`start`,className:`w-[min(46rem,calc(100vw-1.5rem))] p-3 text-[11px] leading-relaxed text-fg`,onPointerDownOutside:l,onOpenAutoFocus:e=>e.preventDefault(),children:(0,L.jsx)(JX,{thread:e,armed:a,close:()=>n(`closed`)})})]})}var LX=260;function RX({armed:e}){let t=e?.prompt?.trim(),n=e?qX({stopHook:e.stopHook===!0,heartbeat:e.heartbeat===!0,postCompaction:e.postCompaction===!0,seconds:e.intervalSeconds??VX}):[];return(0,L.jsxs)(`div`,{"data-recurring-preview-body":!0,children:[(0,L.jsxs)(`div`,{className:`mb-1 flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Goal`}),(0,L.jsx)(`span`,{className:`text-muted/70`,children:n.length>0?`sent ${n.join(`, `)}`:t?`no trigger is on`:`not set`})]}),(0,L.jsx)(`p`,{className:`line-clamp-4 whitespace-pre-wrap ${t?`text-fg/90`:`text-muted`}`,children:t||`Click to write what this thread is trying to achieve.`})]})}var zX=1,BX=1440,VX=600;function HX(e,t){if(e===String(Math.round(t/60)))return t;let n=Math.round(Number(e));return Number.isFinite(n)&&n>0?Math.min(BX,Math.max(zX,n))*60:t}var UX=null;function WX(e){return{prompt:e.text.trim(),stopHook:e.stopHook,heartbeat:e.heartbeat,postCompaction:e.postCompaction,seconds:e.seconds}}function GX(e,t){return(e.text.trim()||null)===(t.prompt||null)&&e.stopHook===t.stopHook&&e.heartbeat===t.heartbeat&&e.postCompaction===t.postCompaction&&e.seconds===t.seconds}function KX(e,t){return!e.archived&&!t}function qX(e){return[e.stopHook?`at every rest`:null,e.heartbeat?`every ${Math.round(e.seconds/60)}m`:null,e.postCompaction?`after every compaction`:null].filter(e=>e!==null)}function JX({thread:e,armed:t,close:n}){let r=KX(e,t)?_l:``,i=UX?.slug===e.id?UX.draft:null,[a,o]=(0,I.useState)(i?.text??t?.prompt??r),[s,c]=(0,I.useState)(i?.stopHook??t?.stopHook??!1),[l,u]=(0,I.useState)(i?.heartbeat??t?.heartbeat??!1),[d,f]=(0,I.useState)(i?.postCompaction??t?.postCompaction??!1),[p,m]=(0,I.useState)(i?.seconds??t?.intervalSeconds??VX),h=s||l||d,[g,_]=(0,I.useState)(String(Math.round((i?.seconds??t?.intervalSeconds??VX)/60))),v=(0,I.useRef)(null),y=(0,I.useRef)({prompt:t?.prompt??r,stopHook:t?.stopHook??!1,heartbeat:t?.heartbeat??!1,postCompaction:t?.postCompaction??!1,seconds:t?.intervalSeconds??VX}),b=e=>({text:a,stopHook:s,heartbeat:l,postCompaction:d,seconds:HX(g,p),...e}),x=(0,I.useRef)(b());x.current=b(),(0,I.useEffect)(()=>()=>{let n=x.current;if(GX(n,y.current)){UX?.slug===e.id&&(UX=null);return}if(n.text.trim()===``&&!t){UX={slug:e.id,draft:n};return}C(n)},[]);let S=(0,I.useRef)(Promise.resolve(!0));function C(t){let n=S.current.catch(()=>!1).then(async()=>{let n=await w(t);return n?UX?.slug===e.id&&(UX=null):UX={slug:e.id,draft:t},n});return S.current=n,n}async function w(t){let n=t.text.trim()||null;if(GX(t,y.current))return!0;try{await Y.setThreadRecurringPrompt({slug:e.id,sessionId:e.sessionId??``,prompt:n,stopHook:t.stopHook,heartbeat:t.heartbeat,postCompaction:t.postCompaction,...n===null?{}:{intervalSeconds:t.seconds}}),y.current={...WX(t),prompt:n??``};let r=qX(t);Z(n===null?`Goal cleared`:r.length===0?`Goal saved — no trigger is on, so nothing is sent`:`Goal: sent ${r.join(`, `)}`)}catch(e){return Z((e instanceof Error?e.message:`Could not save the recurring prompt`).slice(0,100)),!1}return!0}function T(){if(GX(b(),y.current)||a.trim()===``&&!t){n();return}C(b()).then(e=>{e&&n()})}function E(){let e=HX(g,p);_(String(Math.round(e/60))),m(e)}let D=[{at:t?.lastRestFiredAt,how:`at rest`},{at:t?.lastScheduleFiredAt,how:`on schedule`},{at:t?.lastCompactFiredAt,how:`after a compaction`}].filter(e=>e.at!==void 0),O=D.reduce((e,t)=>e&&Date.parse(e.at)>=Date.parse(t.at)?e:t,void 0),k=O===void 0?null:D.length>1?`Last sent ${wE(O.at)}`:`Last sent ${O.how} ${wE(O.at)}`;return(0,L.jsxs)(`section`,{"data-recurring-panel":!0,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Goal`}),k&&(0,L.jsx)(`span`,{className:`ml-auto truncate text-muted/55`,children:k})]}),(0,L.jsx)(`textarea`,{ref:v,"data-recurring-text":!0,value:a,maxLength:ml,onChange:e=>o(e.target.value),onKeyDown:e=>{IL({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),T())},placeholder:`What is this thread trying to achieve?`,className:`field-sizing-content max-h-[28vh] min-h-[4rem] w-full resize-none overflow-y-auto rounded-md border border-border bg-bg px-2 py-1.5 text-[12px] leading-snug outline-none placeholder:text-muted/50 focus:border-border-strong ${h?`text-fg`:`text-muted`}`}),(0,L.jsxs)(`div`,{className:`mt-3 grid grid-cols-[auto_auto_1fr] items-baseline gap-x-2.5 gap-y-2`,children:[(0,L.jsx)(PX,{testId:`stop-hook`,label:`Stop hook`,checked:s,onChange:e=>{c(e),e&&!a.trim()&&requestAnimationFrame(()=>v.current?.focus())}}),(0,L.jsx)(`span`,{className:`font-medium ${s?`text-fg`:`text-muted`}`,children:`Stop hook`}),(0,L.jsx)(`span`,{className:`text-muted`,children:`every rest — unless it signed off or parked on a wait`}),(0,L.jsx)(PX,{testId:`heartbeat`,label:`Heartbeat`,checked:l,onChange:e=>{u(e),e&&!a.trim()&&requestAnimationFrame(()=>v.current?.focus())}}),(0,L.jsx)(`span`,{className:`font-medium ${l?`text-fg`:`text-muted`}`,children:`Heartbeat`}),l?(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted`,children:[`every`,(0,L.jsx)(`input`,{type:`number`,"data-recurring-minutes":!0,inputMode:`numeric`,min:zX,max:BX,value:g,onChange:e=>_(e.target.value),onBlur:E,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),E())},"aria-label":`Heartbeat interval in minutes`,className:`w-[4.5ch] rounded-md border border-border bg-bg px-1 py-[3px] text-center text-[11px] leading-none tabular-nums text-fg outline-none focus:border-border-strong disabled:opacity-45 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none`}),`min, even mid-turn`]}):(0,L.jsx)(`span`,{className:`text-muted`,children:`on a clock, even mid-turn`}),(0,L.jsx)(PX,{testId:`post-compaction`,label:`Compaction`,checked:d,onChange:e=>{f(e),e&&!a.trim()&&requestAnimationFrame(()=>v.current?.focus())}}),(0,L.jsx)(`span`,{className:`font-medium ${d?`text-fg`:`text-muted`}`,children:`Compaction`}),(0,L.jsx)(`span`,{className:`text-muted`,children:`when the context is summarized away — link the doc to re-read`})]})]})}function YX({thread:e,sticky:t=!1,safeArea:n=!1,onArchived:r,onDismissCancel:i,onSnoozed:a}){let o=SX(e);return o.footer?(0,L.jsxs)(`footer`,{"aria-label":`Thread lifecycle actions`,"data-thread-lifecycle-footer":!0,className:`${t?`z-20`:Zq} flex min-h-10 shrink-0 flex-wrap items-center justify-end ${zL} border-t border-border/70 bg-panel/95 px-3 pt-2 text-[12px] ${n?`pb-[max(0.5rem,env(safe-area-inset-bottom))]`:`pb-2`} backdrop-blur-sm`,children:[(0,L.jsxs)(`span`,{className:`mr-auto flex items-center ${zL}`,children:[(0,L.jsx)(MX,{thread:e}),(0,L.jsx)(ZX,{thread:e}),(0,L.jsx)(IX,{thread:e})]}),o.done?(0,L.jsx)(XX,{}):(0,L.jsxs)(L.Fragment,{children:[o.snooze&&(0,L.jsx)(DX,{thread:e,onSnoozed:a}),(0,L.jsx)(QX,{thread:e,onArchived:r,onDismissCancel:i})]})]}):null}function XX(){let e=`Marked done — send a message to reopen it`;return(0,L.jsx)(Rj,{label:e,side:`top`,children:(0,L.jsxs)(`span`,{"data-thread-done":!0,"aria-label":e,className:`flex items-center gap-1 rounded-md border border-transparent px-2.5 py-1 font-medium text-muted`,children:[(0,L.jsx)(Qp,{size:12}),`Done`]})})}function ZX({thread:e}){let t=DT(e);if(!t)return null;let n=e.snoozePrompt?.trim(),r=n?`Bumps ${Ww(t)}\n${n}`:`Snoozed until ${Ww(t)}`;return(0,L.jsx)(Rj,{label:r,side:`top`,multiline:!!n,children:(0,L.jsx)(`span`,{"data-pending-snooze":!0,"aria-label":r,className:`flex items-center px-0.5 text-muted/60 ${BL}`,children:(0,L.jsx)(Tm,{size:12})})})}function QX({thread:e,onArchived:t,onDismissCancel:n,className:r=`rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] text-fg/80 hover:bg-panel-2 hover:text-fg`,iconClassName:i=``}){let[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(void 0),d=(r,i)=>{o(!0),i&&t?.(),(r||CX(e))&&GH(e.id),Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:r}).then(r=>{if(r.needsConfirmation){KH(e.id),i&&n?.(),u(r.hold),c(!0),o(!1);return}c(!1),Z(`Done`),i||t?.()}).catch(t=>{KH(e.id),i&&n?.(),Z(`Couldn’t finish: ${t.message.slice(0,80)}`),o(!1)})},f=!!t&&!!n&&CX(e);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>d(!1,f),disabled:a,"aria-label":`Mark as done`,title:`Mark as done`,onMouseDown:e=>e.preventDefault(),className:`flex items-center gap-1 font-medium outline-none transition-colors focus-visible:ring-1 focus-visible:ring-fg/60 disabled:opacity-45 ${r}`,children:[(0,L.jsx)(Qp,{size:12,className:i}),`Mark as done`]}),(0,L.jsx)(EX,{open:s,onOpenChange:e=>{a||c(e)},title:l?.cutOff?`Mark an unfinished thread done?`:`End this session?`,className:`w-[390px] max-w-[92vw]`,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>c(!1),className:`rounded-md px-3 py-1.5 text-[12px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:opacity-45`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>d(!0,!1),className:`flex items-center gap-1.5 rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-opacity hover:opacity-90 disabled:opacity-45`,children:[a&&(0,L.jsx)(Mm,{size:12,className:`animate-spin`}),l?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,L.jsx)($X,{hold:l})})]})}function $X({hold:e}){let t=wX(e);return(0,L.jsxs)(`div`,{"data-completion-hold":!0,className:`flex flex-col gap-2 p-4 text-[12px] leading-relaxed text-muted`,children:[(0,L.jsx)(`p`,{children:t.lead}),t.groups.map(e=>(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,L.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-fg/70`,children:e.heading}),(0,L.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[e.items.map((e,t)=>(0,L.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:EE,children:`⤷`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate text-fg/80`,children:e.label}),e.stale&&(0,L.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted/60`,children:`no recent output`})]},`${e.label}-${t}`)),e.overflow>0&&(0,L.jsxs)(`li`,{className:`pl-[15px] text-muted/60`,children:[`+`,e.overflow,` more`]})]})]},e.kind)),(0,L.jsx)(`p`,{children:t.trailer})]})}function eZ({thread:e,hidden:t=!1}){let n=it({mutationFn:()=>Y.aiRenameThread({slug:e.id}),onSuccess:({title:e})=>Z(`Renamed to “${e}”`),onError:e=>Z(e instanceof Error?e.message:`Could not rename with Claude`,{duration:7e3})}),r=GY(e);if(!r.show||t)return null;let i=n.isPending?`Claude is generating a title…`:n.error instanceof Error?n.error.message:r.label,a=n.isPending||!!n.error;return(0,L.jsx)(Rj,{label:i,children:(0,L.jsx)(`button`,{type:`button`,"data-ai-rename":!0,"aria-label":n.isPending?`Renaming with Claude`:r.label,"aria-busy":n.isPending,"aria-disabled":!r.enabled,onMouseDown:e=>e.preventDefault(),onClick:()=>{if(!n.isPending){if(!r.enabled){Z(r.label);return}n.reset(),n.mutate()}},className:`title-refresh-offset -mx-[7px] -my-3 flex h-6 w-6 shrink-0 items-center justify-center rounded-md outline-none transition-[color,background-color,opacity] focus-visible:opacity-100 group-hover/thread-title:opacity-100 ${a?`opacity-100`:`opacity-0`} ${n.error?`text-red-400 hover:bg-red-500/10`:r.enabled?`text-muted hover:bg-panel-2 hover:text-fg`:`cursor-not-allowed text-muted/50 hover:bg-panel-2`}`,children:n.isPending?(0,L.jsx)(Mm,{size:12,className:`animate-spin`}):(0,L.jsx)(Jm,{size:12})})})}var tZ=new Set([`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]);function nZ(e,t){let n=e.lastIndexOf(t);if(n<=0)return{model:e};let r=e.slice(n+1);return tZ.has(r)?{model:e.slice(0,n),effort:r}:{model:e}}function rZ(e){let t=e?.trim();if(!t)return`Profile unknown`;if(t.startsWith(`frizz:`)){let{model:e,effort:n}=nZ(t.slice(6).replace(/^frizz-/,``),`-`);return n?`${e} › ${n}`:e}let n=t.split(/\s+/),{model:r,effort:i}=nZ(n.at(-1)??t,`/`);if(!i)return t;let a=n.slice(0,-1).join(` `);return`${a?`${a} · `:``}${r} › ${i}`}function iZ(e){return e?.trim()?rZ(e):void 0}function aZ(e){if(e.kind!==void 0||e.role!==`assistant`||e.text.trim())return;let t=e.parts??[],n=t.length>0?t.length===1&&t[0].kind===`tools`?t[0].tools:[]:e.tools??[],r=n.length===1?n[0]:void 0;return r?.agentCompletion?r:void 0}var oZ={completed:`finished`,killed:`stopped`,failed:`failed`};function sZ(e){let t=oZ[e.agentStatus??`completed`],n=e.agentElapsedMs===void 0?void 0:xE(e.agentElapsedMs);return{outcome:t,tail:`${t}${n?` · ${n}`:``}`}}var cZ=e=>e===void 0?void 0:gE(e),lZ=e=>{if(e!==void 0)return xE(e)||void 0};function uZ(e){let{agentStatus:t,agentElapsedMs:n,liveState:r,liveElapsedMs:i,status:a,durationMs:o}=e;if(t){let e=t===`killed`,r=t===`failed`,i=cZ(n);return{label:t===`completed`?void 0:oZ[t],duration:lZ(n),tone:r?`failed`:`muted`,title:`${e?`Stopped`:r?`Failed`:`Ran for`}${e||r?` after`:``} ${i??`an unknown time`}`}}if(r){let e=cZ(i);return{label:void 0,duration:lZ(i),tone:`muted`,title:r===`running`?`Working for ${e??`an unknown time`}`:`Dispatched ${e??`an unknown time`} ago`}}if(a===`pending`||a!==`failed`&&a!==`cancelled`)return null;let s=a===`failed`,c=a===`cancelled`,l=cZ(o);return{label:c?oZ.killed:s?oZ.failed:void 0,duration:lZ(o),tone:s?`failed`:`muted`,title:`${c?`Stopped after`:s?`Failed after`:`Ran for`} ${l??`an unknown time`}`}}function dZ({at:e,host:t}){let n=YT(e);return!n||!e?null:(0,L.jsx)(`time`,{dateTime:e,"aria-hidden":`true`,className:`!pointer-events-none absolute right-6 top-full z-10 ${t===`bubble`?`mt-[2px]`:`-mt-[5px]`} select-none text-[11px] leading-4 [font-variant-numeric:tabular-nums] text-muted/70 opacity-0 transition-opacity group-hover/ts:opacity-100`,children:n})}function fZ({at:e,host:t,gap:n,children:r}){return(0,L.jsxs)(`div`,{className:`group/ts relative flex flex-col px-6`,style:{paddingTop:n},children:[r,(0,L.jsx)(dZ,{at:e,host:t})]})}var pZ=`text-[14px] leading-5 text-muted`,mZ=`size-[1em] shrink-0 self-baseline -mt-[calc(1em_-_1cap)] translate-y-[calc(0.5em_-_0.5cap)] text-muted/70 transition-transform group-hover:text-fg`;function hZ(e){return`${mZ} ${e?`-mx-[0.208em] rotate-90`:`-mx-[0.333em]`}`}var $=I.createElement;function gZ({payload:e}){return e.kind===`command-approval`?$(I.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},`Command`),$(`div`,{className:`mt-0.5 break-words text-[13px] font-medium text-fg`},e.command.summary),e.command.workingDirectoryLabel?$(`div`,{className:`mt-1 break-all text-[10.5px] text-muted/70`},`Working directory: `,e.command.workingDirectoryLabel):null,$(_Z,{label:`Redacted command preview`,text:e.command.preview}),e.command.actions?$(vZ,{actions:e.command.actions}):null,e.capabilities?$(bZ,{capabilities:e.capabilities}):null):e.kind===`file-approval`?$(I.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},wZ(e.operation)),$(`div`,{className:`mt-0.5 break-all font-mono-keep text-[12px] text-fg`},e.pathLabel),e.destinationLabel?$(`div`,{className:`mt-1 break-all font-mono-keep text-[11px] text-muted`},`→ `,e.destinationLabel):null,e.grantRootLabel?$(`section`,{"aria-label":`Requested session write root`,className:`mt-2.5 min-w-0 rounded-md border border-amber-400/35 bg-amber-500/[0.06] px-2.5 py-2`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-amber-100/80`},`Requested session write root`),$(`div`,{className:`mt-1 min-w-0 break-all font-mono-keep text-[10.5px] text-fg/85`},e.grantRootLabel),e.scopeLabel?$(`div`,{className:`mt-1.5 whitespace-pre-wrap break-words text-[10.5px] leading-snug text-amber-100/75`},e.scopeLabel):null):null,e.diffPreview?$(_Z,{label:`Plain-text diff preview`,text:e.diffPreview}):null,e.changes?$(yZ,{changes:e.changes}):null):$(I.Fragment,null,e.preview?$(`pre`,{className:`max-h-64 max-w-full min-w-0 overflow-auto rounded-md border border-border/70 bg-bg/40 px-2.5 py-2 whitespace-pre-wrap break-words font-mono-keep text-[11.5px] leading-relaxed text-fg/90`},e.promptLabel?$(`span`,{className:`text-shell/90`},e.promptLabel):null,e.promptLabel?$(`span`,{className:`text-accent`},` ❯ `):null,e.preview):null,e.resourceLabel?$(`div`,{className:`mt-1 break-all text-[11px] text-muted`},`Resource: `,e.resourceLabel):null,e.workingDirectoryLabel?$(`div`,{className:`mt-1.5 break-all text-[10.5px] text-muted/70`},`Working directory: `,e.workingDirectoryLabel):null,e.scopeLabel?$(`div`,{className:`mt-2 whitespace-pre-wrap break-words text-[11px] leading-snug text-muted`},e.scopeLabel):null,e.capabilities?$(bZ,{capabilities:e.capabilities}):null)}function _Z({label:e,text:t}){return $(`details`,{className:`mt-2.5 min-w-0 rounded-md border border-border/70 bg-bg/35`,open:t.length<1200},$(`summary`,{className:`cursor-pointer px-2.5 py-2 text-[10.5px] text-muted outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/50`},e),$(`pre`,{className:`max-h-64 max-w-full min-w-0 overflow-auto border-t border-border/60 px-2.5 py-2 whitespace-pre-wrap break-words font-mono-keep text-[11px] leading-relaxed text-fg/80`},t))}function vZ({actions:e}){return $(`section`,{"aria-label":`Parsed command actions`,className:`mt-3 min-w-0`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-muted/75`},`Parsed actions`),$(`ul`,{className:`mt-1.5 flex min-w-0 flex-col gap-2`},e.map((e,t)=>$(`li`,{key:t,className:`min-w-0 rounded-md border border-border/65 bg-bg/25 px-2.5 py-2`},$(`div`,{className:`text-[11px] font-medium text-fg/90`},CZ(e.kind)),e.resourceLabel?$(`div`,{className:`mt-0.5 break-all font-mono-keep text-[10.5px] text-muted`},e.resourceLabel):null,e.queryLabel?$(`div`,{className:`mt-0.5 break-all text-[10.5px] text-muted`},`Query: `,e.queryLabel):null,$(_Z,{label:`${CZ(e.kind)} command detail`,text:e.commandPreview})))))}function yZ({changes:e}){return $(`section`,{"aria-label":`Affected file changes`,className:`mt-3 min-w-0`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-muted/75`},`Affected changes`),$(`ol`,{className:`mt-1.5 flex min-w-0 flex-col gap-2`},e.map((e,t)=>$(`li`,{key:t,className:`min-w-0 rounded-md border border-border/65 bg-bg/25 px-2.5 py-2`},$(`div`,{className:`text-[11px] font-medium text-fg/90`},wZ(e.operation)),$(`div`,{className:`mt-0.5 break-all font-mono-keep text-[10.5px] text-fg/80`},e.pathLabel),e.destinationLabel?$(`div`,{className:`mt-0.5 min-w-0 break-all font-mono-keep text-[10.5px] text-muted`},`→ `,e.destinationLabel):null,e.diffPreview?$(_Z,{label:`${wZ(e.operation)} plain-text diff`,text:e.diffPreview}):null))))}function bZ({capabilities:e}){return $(`section`,{"aria-label":`Requested capabilities`,className:`mt-3 min-w-0`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-muted/75`},`Requested capabilities`),$(`ul`,{className:`mt-1.5 flex min-w-0 flex-col gap-2`},e.map((e,t)=>$(`li`,{key:t,className:`min-w-0 rounded-md border border-border/65 bg-bg/25 px-2.5 py-2`},$(xZ,{capability:e})))))}function xZ({capability:e}){if(e.kind===`network`){let t=e.enabled===!0?`Enable network access`:e.enabled===!1?`Disable network access`:`Network access request`;return $(I.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},t),e.hosts.length>0?$(SZ,{label:`Hosts and protocols`,values:e.hosts}):null)}if(e.kind===`filesystem`){let t=e.access===`read`?`Read filesystem paths`:e.access===`write`?`Write filesystem paths`:`Deny filesystem paths`;return $(I.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},t),$(SZ,{label:`Paths`,values:e.resources}))}return e.kind===`glob-scan`?$(I.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},`Filesystem glob scanning`),$(`div`,{className:`mt-0.5 text-[10.5px] text-muted`},`Maximum depth: `,String(e.depth))):e.kind===`exec-policy`?$(I.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},`Future command policy amendment`),$(SZ,{label:`Command prefix tokens`,values:e.prefixes})):$(I.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},e.access===`allow`?`Allow future network hosts`:`Deny future network hosts`),$(SZ,{label:`Hosts`,values:e.hosts}))}function SZ({label:e,values:t}){return $(`div`,{className:`mt-1 min-w-0`},$(`div`,{className:`sr-only`},e),$(`ul`,{"aria-label":e,className:`flex min-w-0 flex-col gap-0.5`},t.map((e,t)=>$(`li`,{key:t,className:`min-w-0 break-all font-mono-keep text-[10.5px] text-muted`},e))))}function CZ(e){switch(e){case`read`:return`Read a file`;case`list-files`:return`List files`;case`search`:return`Search files`;case`unknown`:return`Unclassified command`}}function wZ(e){switch(e){case`read`:return`Read file`;case`create`:return`Create file`;case`write`:return`Modify file`;case`move`:return`Move file`;case`delete`:return`Delete file`;case`execute`:return`Execute file`;case`other`:return`File operation`}}function TZ(e){return e===`sending`?{actionsEnabled:!1,status:`Sending to runtime…`}:e===`reconnect-required`?{actionsEnabled:!1,status:`Runtime reconnect required before this request can be answered.`}:{actionsEnabled:!0}}var EZ={semantic:`approve`,label:`Approve once`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`},DZ={semantic:`approve`,label:`Approve for session`,order:20,tone:`primary`,durable:!0,scope:`Persists for later matching requests in this thread session.`},OZ={semantic:`approve`,label:`Grant for turn`,order:10,tone:`primary`,durable:!1,scope:`Applies to this turn only.`},kZ={semantic:`approve`,label:`Grant for session`,order:20,tone:`primary`,durable:!0,scope:`Persists until this thread session ends.`},AZ={semantic:`deny`,label:`Deny`,order:70,tone:`danger`,durable:!1,scope:`Rejects this request.`},jZ={semantic:`decline`,label:`Decline`,order:70,tone:`danger`,durable:!1,scope:`Declines this request.`},MZ={semantic:`cancel`,label:`Cancel request`,order:80,tone:`neutral`,durable:!1,scope:`Cancels this pending request.`};function NZ(e,t){let{id:n,semantic:r}=t;if(e.kind===`command-approval`||e.kind===`file-approval`)return(n===`accept`||n===`approve-once`)&&r===`approve`?EZ:n===`acceptForSession`&&r===`approve`?DZ:(n===`decline`||n===`deny`)&&r===`deny`?AZ:n===`cancel`&&r===`cancel`?MZ:void 0;if(e.kind===`permission-approval`)return n===`grant-turn`&&r===`approve`?OZ:n===`grant-session`&&r===`approve`?kZ:(n===`deny`||n===`decline`)&&r===`deny`?AZ:n===`cancel`&&r===`cancel`?MZ:void 0;if(e.kind===`mcp-elicitation-form`||e.kind===`mcp-elicitation-url`)return n===`accept`&&r===`accept`?{semantic:`accept`,label:e.kind===`mcp-elicitation-form`?`Submit`:`Continue`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`}:n===`decline`&&r===`decline`?jZ:n===`cancel`&&r===`cancel`?MZ:void 0;if(n===`answer`&&r===`answer`)return{semantic:`answer`,label:`Send answer`,order:10,tone:`primary`,durable:!1,scope:`Sends these answers to this request only.`};if(n===`decline`&&r===`decline`)return jZ;if(n===`cancel`&&r===`cancel`)return MZ}function PZ(e){let t=t=>e.payload.kind===`mcp-elicitation-form`&&t===`accept`||e.payload.kind===`agent-question`&&t===`answer`;return e.allowedDecisions.flatMap(n=>{let r=NZ(e.payload,n);return r?[{...r,id:n.id,semantic:n.semantic,requiresValues:t(n.semantic)}]:[]}).sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id))}function FZ(e){switch(e){case`claude`:return`Claude`;case`codex`:return`Codex`;case`frizz`:return`Frizz`}}function IZ(e){switch(e){case`runtime`:return`Runtime`;case`agent`:return`Agent`;case`tool`:return`Tool`;case`mcp-server`:return`MCP server`;case`frizz`:return`Frizz`}}function LZ(e,t){let n=e.options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t));return n<0?``:String(n)}function RZ(e){let t=Object.create(null);for(let n of e)if(n.input===`text`||n.input===`multiline`)t[n.id]=n.default??``;else if(n.input===`number`||n.input===`integer`)t[n.id]=n.default===void 0?``:String(n.default);else if(n.input===`boolean`)t[n.id]=n.default??!1;else if(n.input===`select`)t[n.id]=n.default===void 0?``:LZ(n,n.default);else if(n.input===`multi-select`){let e=new Set(n.default??[]);t[n.id]=n.options.flatMap((t,n)=>e.has(t.value)?[String(n)]:[])}return t}function zZ(e,t,n){let r=Object.create(null);for(let t of Object.keys(e))r[t]=e[t];return r[t]=n,r}function BZ(e,t){if(e.some(e=>e.secret))return{errors:{},formError:`Secret responses cannot be sent through this Frizz connection.`};let n=Object.create(null),r={};for(let i of e){let e=t[i.id],a;if(i.input===`text`||i.input===`multiline`){let t=typeof e==`string`?e:``;if(!i.required&&t===``)continue;i.required&&t===``?r[i.id]=`This field is required.`:a=t}else if(i.input===`number`||i.input===`integer`){let t=typeof e==`string`?e.trim():``;if(!i.required&&t===``)continue;if(t===``)r[i.id]=`This field is required.`;else{let e=Number(t);Number.isFinite(e)?a=e:r[i.id]=`Enter a valid number.`}}else if(i.input===`boolean`)a=e===!0;else if(i.input===`select`){let t=typeof e==`string`&&/^\d+$/.test(e)?Number(e):-1;if(t<0||t>=i.options.length)if(i.required)r[i.id]=`Choose an option.`;else continue;else a=i.options[t].value}else if(i.input===`multi-select`){let t=(Array.isArray(e)?e:[]).flatMap(e=>/^\d+$/.test(e)?[Number(e)]:[]);if(t.some(e=>e<0||e>=i.options.length))r[i.id]=`Choose only advertised options.`;else if(i.required&&t.length===0)r[i.id]=`Choose at least one option.`;else if(t.length>0)a=t.map(e=>i.options[e].value);else continue}if(a!==void 0&&!r[i.id]){let e=ac(i,a);e?r[i.id]=`Value ${e}.`:n[i.id]=a}}if(Object.keys(r).length>0)return{errors:r};let i=yc.safeParse(n);return i.success?{errors:r,values:i.data}:{errors:r,formError:`The response is too large or contains invalid values.`}}function VZ(e,t){return JSON.stringify([e,t??null])}function HZ(e,t){try{let n=new URL(e,t);return n.protocol===`http:`||n.protocol===`https:`?n.toString():null}catch{return null}}function UZ(e,t){let n=e.getAttribute(`href`);if(!n)return!1;let r=HZ(n,t);if(!r)return!1;let i;try{i=new URL(t)}catch{return!1}if(new URL(r).origin===i.origin)return!1;e.setAttribute(`target`,`_blank`);let a=new Set((e.getAttribute(`rel`)??``).split(/\s+/u).filter(Boolean));return a.add(`noopener`),a.add(`noreferrer`),e.setAttribute(`rel`,[...a].join(` `)),!0}function WZ(e=()=>location.href){return t=>{if(t.defaultPrevented||t.button!==0)return;let n=KZ(t);n&&UZ(n,e())}}function GZ(){let e=WZ();return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)}function KZ(e){let t=typeof e.composedPath==`function`?e.composedPath():[];for(let e of t)if(qZ(e))return e;let n=e.target?.closest?.(`a[href]`);return qZ(n)?n:null}function qZ(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.tagName?.toLowerCase()===`a`&&typeof t.getAttribute==`function`&&typeof t.setAttribute==`function`&&typeof t.hasAttribute==`function`&&t.hasAttribute(`href`)}function JZ(e){let t=e,n=``;do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return`${n}.`}function YZ(e,t){let n=e??t;if(!n)return null;let r=e&&(e.input===`select`||e.input===`multi-select`)?e.options:[];return{question:{kind:e?.input===`multi-select`?`multi`:`question`,danger:!1,contextMd:n.description??n.label,options:r.map((e,t)=>`${JZ(t)} ${e.label}`),recommendedIdx:null},...e?{optionFieldId:e.id}:{},optionValues:r.map(e=>e.value),...t?{notesFieldId:t.id}:{}}}function XZ(e){if(e.payload.kind!==`agent-question`)return null;let t=e.payload.fields,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.secret)return null;if(r.id.endsWith(`_notes`))continue;let i=t[e+1],a=i&&i.id===`${r.id}_notes`?i:void 0;if(r.input===`select`||r.input===`multi-select`){let e=YZ(r,a);if(!e)return null;n.push(e)}else if(r.input===`text`||r.input===`multiline`){let e=YZ(void 0,r);if(!e)return null;n.push(e)}else return null}return n.length>0?n:null}function ZZ(e,t){let n=[],r;if(t){let i=e.multiSelect?t.split(`, `):[t];e.options.forEach((e,t)=>{i.includes(e.label)&&n.push(t)}),n.length===0&&(r=t)}return{question:{kind:e.multiSelect?`multi`:`question`,danger:!1,contextMd:e.question,options:e.options.map((e,t)=>`${JZ(t)} ${e.label}${e.description?` — ${e.description}`:``}`),recommendedIdx:null},chosenIdxs:n,text:r}}function QZ(e,t){let n={};return e.forEach((e,r)=>{let i=t[r];if(!i)return;let a=i.text.trim();if(e.question.kind===`multi`){let t=(i.chosenSet??[]).slice().sort((e,t)=>e-t).flatMap(t=>{let n=e.optionValues[t];return n===void 0?[]:[n]});e.optionFieldId&&t.length>0&&(n[e.optionFieldId]=t),e.notesFieldId&&a&&(n[e.notesFieldId]=a);return}let o=i.chosen;if(e.optionFieldId&&o!==null&&e.optionValues[o]!==void 0){n[e.optionFieldId]=e.optionValues[o];return}a&&e.notesFieldId&&(n[e.notesFieldId]=a)}),Object.keys(n).length>0?n:void 0}function $Z(e){let t=e instanceof Error?e.message:`The request could not be updated.`;return t.length>240?`${t.slice(0,239)}…`:t}function eQ(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`frizz-response-${Date.now()}-${Math.random().toString(36).slice(2)}`}function tQ({thread:e,className:t=``,autoFocusFirst:n=!1}){let r=PC(e),i=IC(e),a=(0,I.useMemo)(()=>[...i.data?.interactions??[]].sort((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.id.localeCompare(t.id)),[i.data?.interactions]);return r?i.isError&&a.length===0?(0,L.jsxs)(`div`,{"data-interactions-error":!0,role:`alert`,className:`${Yq} border border-amber-500/35 bg-amber-500/[0.07] p-4 text-[12px] text-amber-100 ${t}`,children:[(0,L.jsx)(`div`,{className:`font-medium`,children:`Pending requests could not be loaded.`}),(0,L.jsx)(`div`,{className:`mt-1 break-words text-amber-100/75`,children:$Z(i.error)}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>void i.refetch(),className:`mt-2 rounded-md border border-amber-400/40 px-2 py-1 text-[11px] hover:bg-amber-500/10`,children:`Try again`})]}):a.length===0?null:(0,L.jsx)(`section`,{"data-typed-interactions":!0,"aria-label":`${a.length} pending request${a.length===1?``:`s`}`,className:`flex min-w-0 flex-col gap-3 ${t}`,children:a.map((e,t)=>(0,L.jsx)(rQ,{record:e,autoFocus:n&&t===0},e.id))}):null}function nQ({record:e,questions:t,autoFocus:n}){let r=Ve(),i=(0,I.useRef)(null),a=(0,I.useRef)(new Map),o=cz(),s=TZ(e.delivery?.effect),c=(0,I.useMemo)(()=>PZ(e).find(e=>e.semantic===`answer`),[e]),l=dz(t.flatMap(t=>t.notesFieldId?[sz.interaction(o,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId)]:[])),[u,d]=(0,I.useState)(()=>t.map(()=>({chosen:null,chosenSet:[]}))),f=t.map((t,n)=>({chosen:u[n]?.chosen??null,chosenSet:u[n]?.chosenSet??[],text:t.notesFieldId?l.get(sz.interaction(o,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId))??``:``})),p=QZ(t,f),[m,h]=(0,I.useState)(),[g,_]=(0,I.useState)(!1);(0,I.useEffect)(()=>{if(!n)return;let e=document.activeElement;e&&e!==document.body||requestAnimationFrame(()=>i.current?.focus())},[n,e.id]);let v=it({mutationFn:async t=>Y.interactionResolve({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id,sessionEpoch:e.owner.sessionEpoch,capabilityRevision:e.owner.capabilityRevision,expectedRecordRevision:e.recordRevision,responseId:t.responseId,decisionId:t.decisionId,values:t.values}),onSuccess:t=>{_(!0),Pb(r,t.interaction),r.invalidateQueries({queryKey:Mb(e.owner.threadSlug,e.owner.sessionId)}),r.invalidateQueries({queryKey:Nb(e.owner.threadSlug,e.owner.sessionId,e.id)})},onError:t=>{Fb(r,e),h($Z(t))}}),y=()=>{if(!c||!p||v.isPending||g||!s.actionsEnabled)return;h(void 0);let e=VZ(c.id,p),t=a.current.get(e)??eQ();a.current.set(e,t),v.mutate({decisionId:c.id,values:p,responseId:t})},b=(t,n)=>{t.notesFieldId&&az.set(sz.interaction(o,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId),n)};return(0,L.jsxs)(`article`,{ref:i,tabIndex:-1,"data-interaction-id":e.id,"data-interaction-kind":e.payload.kind,"data-interaction-question":`native`,"data-delivery-effect":e.delivery?.effect,className:`flex min-w-0 flex-col gap-2 outline-none`,children:[t.map((e,t)=>(0,L.jsx)(CY,{question:e.question,interactive:s.actionsEnabled&&!g?{answer:f[t],onChip:n=>{d(r=>r.map((r,i)=>{if(i!==t)return r;if(e.question.kind===`multi`){let e=r.chosenSet.includes(n)?r.chosenSet.filter(e=>e!==n):[...r.chosenSet,n];return{...r,chosenSet:e}}return{...r,chosen:r.chosen===n?null:n}}))},onText:n=>{b(e,n),e.question.kind!==`multi`&&d(e=>e[t]?.chosen===null||e[t]===void 0?e:e.map((e,n)=>n===t?{...e,chosen:null}:e))},onSubmit:y}:void 0},e.optionFieldId??e.notesFieldId??t)),m&&(0,L.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-red-300`,children:m}),(s.status||v.isPending||g)&&(0,L.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[11px] leading-snug text-muted`,children:s.status??(g?`Answer sent.`:`Sending…`)}),s.actionsEnabled&&!g&&(0,L.jsx)(`div`,{className:`flex justify-start`,children:(0,L.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:!p||v.isPending,onClick:y,onMouseDown:e=>e.preventDefault(),className:`rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:`Send answers`})})]})}function rQ({record:e,autoFocus:t=!1}){let n=(0,I.useMemo)(()=>XZ(e),[e]);return n?(0,L.jsx)(nQ,{record:e,questions:n,autoFocus:t}):(0,L.jsx)(iQ,{record:e,autoFocus:t})}function iQ({record:e,autoFocus:t=!1}){let n=Ve(),r=(0,I.useId)(),i=(0,I.useRef)(null),a=(0,I.useRef)(new Map),o=e.payload.kind===`mcp-elicitation-form`||e.payload.kind===`agent-question`?e.payload.fields:[],s=o.some(e=>e.secret),c=cz(),l=o.filter(e=>!e.secret&&(e.input===`text`||e.input===`multiline`)).map(t=>sz.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.id)),u=dz(l),[d,f]=(0,I.useState)(()=>RZ(o)),p=(0,I.useMemo)(()=>{let t={...d};return o.forEach(n=>{if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=sz.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id);t[n.id]=u.get(r)??``}}),t},[o,d,u,c,e.id,e.owner]),[m,h]=(0,I.useState)({}),[g,_]=(0,I.useState)(),[v,y]=(0,I.useState)(),[b,x]=(0,I.useState)(!1),[S,C]=(0,I.useState)(),[w,T]=(0,I.useState)(!1),E=TZ(e.delivery?.effect),D=(0,I.useMemo)(()=>PZ(e),[e]).filter(e=>!(s&&e.requiresValues)),O=e.allowedDecisions.length-D.length,k=(0,I.useCallback)(t=>{for(let n of o)if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=t[n.id];typeof r==`string`&&az.set(sz.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id),r)}f(t)},[o,c,e.id,e.owner]);(0,I.useEffect)(()=>{if(!t)return;let e=document.activeElement;e&&e!==document.body||requestAnimationFrame(()=>i.current?.focus())},[t,e.id]),(0,I.useEffect)(()=>{E.actionsEnabled||(C(void 0),T(!1))},[E.actionsEnabled]);let A=it({mutationFn:async({decision:t,values:n,responseId:r})=>{if(t.semantic===`cancel`&&e.provider.kind===`frizz`){let t=await Y.interactionCancel({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id,sessionEpoch:e.owner.sessionEpoch,capabilityRevision:e.owner.capabilityRevision,expectedRecordRevision:e.recordRevision});return{effect:t.effect,interaction:t.interaction,waitingForProvider:!1}}let i=await Y.interactionResolve({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id,sessionEpoch:e.owner.sessionEpoch,capabilityRevision:e.owner.capabilityRevision,expectedRecordRevision:e.recordRevision,responseId:r,decisionId:t.id,...n===void 0?{}:{values:n}});return{effect:i.effect,interaction:i.interaction,waitingForProvider:i.interaction.delivery?.effect===`sending`||i.effect===`queued`||i.effect===`already-queued`}},onSuccess:(t,r)=>{t.waitingForProvider||a.current.delete(VZ(r.decision.id,r.values)),_(void 0),C(void 0),T(!1),x(!0),l.forEach(e=>az.clear(e)),y(t.waitingForProvider?`Response sent. Waiting for the provider to acknowledge it…`:`Request completed.`),Pb(n,t.interaction),n.setQueryData(Nb(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t.interaction}),n.invalidateQueries({queryKey:Mb(e.owner.threadSlug,e.owner.sessionId),exact:!0}),t.waitingForProvider&&window.setTimeout(()=>{n.invalidateQueries({queryKey:Mb(e.owner.threadSlug,e.owner.sessionId),exact:!0})},1e3)},onError:t=>{y(void 0),_($Z(t)),Fb(n,e),Y.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{Pb(n,t),n.setQueryData(Nb(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t}),t.delivery?.effect===`sending`?(_(void 0),y(void 0),x(!0)):t.delivery?.effect===`reconnect-required`?(_(void 0),y(void 0)):(t.lifecycle!==`pending`||t.recordRevision!==e.recordRevision)&&(_(void 0),y(t.lifecycle===`expired`?`This request expired.`:`This request changed in another client.`),n.invalidateQueries({queryKey:Mb(e.owner.threadSlug,e.owner.sessionId),exact:!0})),n.invalidateQueries({queryKey:Mb(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}});function j(e){if(!e.requiresValues){h({});return}let t=BZ(o,p);return h(t.errors),t.formError?(_(t.formError),null):t.values?t.values:null}function M(e,t=!1){if(!E.actionsEnabled||A.isPending||b)return;_(void 0);let n=j(e);if(n===null)return;if(e.durable&&!t){C(e),T(!1);return}let r=VZ(e.id,n),i=a.current.get(r)??eQ();a.current.set(r,i),A.mutate({decision:e,values:n,responseId:i})}let N=D.find(e=>e.requiresValues&&e.tone===`primary`);function P(e){e.preventDefault(),E.actionsEnabled&&N&&M(N)}return(0,L.jsxs)(`article`,{ref:i,tabIndex:-1,"aria-labelledby":r,"data-interaction-id":e.id,"data-interaction-kind":e.payload.kind,"data-delivery-effect":e.delivery?.effect,className:`min-w-0 ${Yq} border border-accent/45 bg-accent/[0.065] shadow-sm shadow-black/15 outline-none focus-visible:ring-2 focus-visible:ring-accent/60`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 border-b border-accent/20 px-4 py-3`,children:[(0,L.jsx)(Xm,{"aria-hidden":`true`,size:16,className:`shrink-0 text-accent`}),(0,L.jsx)(`h3`,{id:r,className:`min-w-0 flex-1 break-words text-[14px] font-semibold leading-snug text-fg`,children:e.payload.title})]}),(0,L.jsx)(`form`,{onSubmit:P,onKeyDown:e=>{e.target instanceof HTMLButtonElement||IL({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),E.actionsEnabled&&N&&M(N))},className:`min-w-0 px-4 py-3.5`,noValidate:!0,children:(0,L.jsxs)(`fieldset`,{disabled:!E.actionsEnabled,className:`min-w-0 border-0 p-0`,children:[(0,L.jsx)(`legend`,{className:`sr-only`,children:`Interaction request`}),(0,L.jsx)(oQ,{record:e,instanceId:r,draft:p,setDraft:k,errors:m,autoFocus:t}),s&&(0,L.jsxs)(`div`,{"data-secret-fallback":!0,className:`mt-3 rounded-md border border-amber-500/35 bg-amber-500/[0.07] p-3 text-[12px] leading-snug text-amber-100/90`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(km,{"aria-hidden":`true`,size:14,className:`mt-0.5 shrink-0`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`font-medium`,children:`Secret input is unavailable in this page.`}),(0,L.jsx)(`div`,{className:`mt-1 text-amber-100/70`,children:`Frizz will not persist or send secret values through the current RPC.`})]})]}),(0,L.jsx)(`div`,{className:`mt-2 font-medium`,children:`Use the provider's trusted secret-input flow. The thread terminal cannot answer this typed request.`})]}),O>0&&(0,L.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-md border border-amber-500/25 bg-amber-500/[0.05] px-3 py-2 text-[11px] leading-snug text-amber-100/75`,children:[(0,L.jsx)(rh,{"aria-hidden":`true`,size:13,className:`mt-0.5 shrink-0`}),(0,L.jsxs)(`span`,{children:[O===1?`One advertised choice`:`${O} advertised choices`,` cannot be safely labeled or delivered in Frizz and is not shown.`]})]}),S&&(0,L.jsxs)(`div`,{"data-durable-confirmation":!0,role:`group`,"aria-label":`Confirm ${S.label}`,className:`mt-3 rounded-md border border-amber-400/45 bg-amber-500/[0.08] p-3`,children:[(0,L.jsx)(`div`,{className:`text-[12px] font-semibold text-amber-100`,children:`This approval persists beyond the current request.`}),(0,L.jsx)(`div`,{className:`mt-1 text-[11px] leading-snug text-amber-100/75`,children:S.scope}),(0,L.jsxs)(`label`,{className:`mt-2.5 flex cursor-pointer items-start gap-2 text-[11px] leading-snug text-fg/85`,children:[(0,L.jsx)(`input`,{type:`checkbox`,autoFocus:!0,checked:w,onChange:e=>T(e.target.checked),className:`mt-0.5 accent-[var(--color-accent)]`}),(0,L.jsx)(`span`,{children:`I understand this may authorize later matching actions in this session.`})]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-start gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>{C(void 0),T(!1)},className:`rounded-md border border-border px-2.5 py-1.5 text-[11px] text-muted hover:bg-panel-2 hover:text-fg`,children:`Back`}),(0,L.jsxs)(`button`,{type:`button`,disabled:!w||A.isPending,onClick:()=>M(S,!0),className:`rounded-md border border-amber-400/50 bg-amber-500/15 px-2.5 py-1.5 text-[11px] font-semibold text-amber-50 hover:bg-amber-500/25 disabled:opacity-35`,children:[`Confirm `,S.label.toLowerCase()]})]})]}),g&&(0,L.jsx)(`div`,{role:`alert`,className:`mt-3 break-words text-[11px] leading-snug text-red-300`,children:g}),(E.status??v)&&(0,L.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`mt-3 text-[11px] leading-snug text-muted`,children:E.status??v}),E.actionsEnabled&&!S&&!b&&D.length>0&&(0,L.jsxs)(`div`,{className:`mt-4 flex flex-wrap justify-start gap-2`,children:[D.map(e=>(0,L.jsxs)(`button`,{type:e===N?`submit`:`button`,"data-interaction-decision":e.id,disabled:A.isPending,"aria-describedby":e.durable?`${r}-scope-${e.id}`:void 0,onClick:e===N?void 0:()=>M(e),className:aQ(e),children:[A.isPending?`Sending…`:e.label,e.durable&&(0,L.jsx)(`span`,{className:`sr-only`,children:`; persistent approval`})]},e.id)),D.filter(e=>e.durable).map(e=>(0,L.jsx)(`span`,{id:`${r}-scope-${e.id}`,className:`sr-only`,children:e.scope},`scope-${e.id}`))]}),!sQ.has(e.payload.kind)&&(0,L.jsx)(uQ,{record:e})]})})]})}function aQ(e){let t=`rounded-md border px-2.5 py-1.5 text-[11px] font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-fg/50 disabled:opacity-40`;return e.tone===`primary`?`${t} border-accent/55 bg-accent/15 text-fg hover:bg-accent/25`:e.tone===`danger`?`${t} border-red-400/35 bg-red-500/[0.07] text-red-200 hover:bg-red-500/15`:`${t} border-border bg-panel text-muted hover:bg-panel-2 hover:text-fg`}function oQ({record:e,instanceId:t,draft:n,setDraft:r,errors:i,autoFocus:a}){let o=e.payload,s=(e,t)=>r(zZ(n,e,t)),c;return c=o.kind===`command-approval`||o.kind===`file-approval`||o.kind===`permission-approval`?(0,L.jsx)(gZ,{payload:o}):o.kind===`mcp-elicitation-url`?(0,L.jsx)(lQ,{url:o.url}):(0,L.jsx)(dQ,{instanceId:t,fields:o.fields,draft:n,setValue:s,errors:i,autoFocus:a}),(0,L.jsxs)(L.Fragment,{children:[`message`in o&&o.message&&(0,L.jsx)(cQ,{text:o.message}),(0,L.jsx)(`div`,{className:`message`in o&&o.message?`mt-3`:``,children:c})]})}var sQ=new Set([`command-approval`,`file-approval`,`permission-approval`]);function cQ({text:e}){return e.length>600||e.split(`
310
310
  `).length>6?(0,L.jsxs)(`details`,{className:`rounded-md border border-border/70 bg-panel/60`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer px-2.5 py-2 text-[11px] text-muted outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/50`,children:`Request message`}),(0,L.jsx)(`div`,{className:`max-h-52 overflow-auto border-t border-border/60 px-2.5 py-2 whitespace-pre-wrap break-words text-[12px] leading-relaxed text-fg/80`,children:e})]}):(0,L.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-[12px] leading-relaxed text-fg/80`,children:e})}function lQ({url:e}){let t=HZ(e,location.href);return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[11px] font-medium text-fg`,children:`Open this page to continue`}),(0,L.jsx)(`code`,{className:`mt-1.5 block max-h-24 overflow-auto break-all rounded-md border border-border bg-bg/40 px-2.5 py-2 font-mono-keep text-[10.5px] text-fg/80`,children:e}),t?(0,L.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:`mt-2 inline-flex items-center gap-1.5 rounded-md border border-border bg-panel px-2.5 py-1.5 text-[11px] font-medium text-fg hover:bg-panel-2`,children:[(0,L.jsx)(mm,{"aria-hidden":`true`,size:12}),`Open page`]}):(0,L.jsx)(`div`,{role:`alert`,className:`mt-1.5 break-words text-[11px] text-red-300`,children:`This request did not provide a safe http(s) URL.`})]})}function uQ({record:e}){return(0,L.jsxs)(`details`,{className:`mt-3 border-t border-border/50 pt-2 text-[10.5px] text-muted/70`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer w-fit outline-none hover:text-muted focus-visible:ring-1 focus-visible:ring-fg/50`,children:`Request details`}),(0,L.jsxs)(`dl`,{className:`mt-2 grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1`,children:[(0,L.jsx)(`dt`,{children:`Provider`}),(0,L.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:FZ(e.provider.kind)}),e.provider.name&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Reported name`}),(0,L.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.provider.name})]}),e.provider.version&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Reported version`}),(0,L.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.provider.version})]}),(0,L.jsx)(`dt`,{children:`Source`}),(0,L.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:IZ(e.source.kind)}),e.source.label&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Reported source`}),(0,L.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.source.label})]}),(0,L.jsx)(`dt`,{children:`Scope`}),(0,L.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:`This thread · this request`}),e.expiresAt&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Expires`}),(0,L.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.expiresAt})]})]})]})}function dQ({instanceId:e,fields:t,draft:n,setValue:r,errors:i,autoFocus:a}){let o=t.findIndex(e=>!e.secret);return(0,L.jsxs)(`fieldset`,{className:`min-w-0`,children:[(0,L.jsx)(`legend`,{className:`sr-only`,children:`Requested information`}),(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:t.map((t,s)=>(0,L.jsx)(fQ,{instanceId:e,field:t,value:n[t.id],setValue:e=>r(t.id,e),error:i[t.id],autoFocus:a&&s===o},t.id))})]})}function fQ({instanceId:e,field:t,value:n,setValue:r,error:i,autoFocus:a}){let o=`${e}-${t.id}`,s=t.description?`${o}-description`:void 0,c=i?`${o}-error`:void 0,l=[s,c].filter(Boolean).join(` `)||void 0,u=(0,L.jsxs)(L.Fragment,{children:[t.label,t.required&&(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`ml-0.5 text-accent`,children:`*`})]}),d=`mt-1 w-full min-w-0 rounded-md border border-border bg-bg/45 px-2.5 py-2 text-[12px] text-fg outline-none focus:border-accent focus:ring-1 focus:ring-accent/40`,f;if(t.secret)f=(0,L.jsx)(`div`,{className:`mt-1 text-[11px] text-amber-100/70`,children:`Use the secure fallback below.`});else if(t.input===`multiline`)f=(0,L.jsx)(`textarea`,{id:o,name:t.id,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,minLength:t.minLength,maxLength:t.maxLength,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,rows:4,className:`${d} resize-y`});else if(t.input===`text`){let e=t.format===`email`?`email`:t.format===`uri`?`url`:t.format===`date`?`date`:`text`;f=(0,L.jsx)(`input`,{id:o,name:t.id,type:e,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,minLength:t.minLength,maxLength:t.maxLength,placeholder:t.format===`date-time`?`2026-07-13T12:00:00Z`:void 0,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,className:d})}else if(t.input===`number`||t.input===`integer`)f=(0,L.jsx)(`input`,{id:o,name:t.id,type:`number`,step:t.input===`integer`?1:`any`,min:t.minimum,max:t.maximum,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,className:d});else if(t.input===`boolean`)f=(0,L.jsxs)(`label`,{htmlFor:o,className:`mt-1 flex cursor-pointer items-center gap-2 rounded-md border border-border bg-bg/30 px-2.5 py-2 text-[12px] text-fg/85`,children:[(0,L.jsx)(`input`,{id:o,name:t.id,type:`checkbox`,checked:n===!0,onChange:e=>r(e.target.checked),"aria-describedby":l,autoFocus:a,className:`accent-[var(--color-accent)]`}),(0,L.jsx)(`span`,{children:u})]});else if(t.input===`select`)f=(0,L.jsxs)(`select`,{id:o,name:t.id,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,className:d,children:[(0,L.jsx)(`option`,{value:``,children:`Choose an option…`}),t.options.map((e,t)=>(0,L.jsx)(`option`,{value:String(t),children:e.label},t))]});else if(t.input===`multi-select`){let e=Array.isArray(n)?n:[];f=(0,L.jsxs)(`fieldset`,{id:o,"aria-describedby":l,className:`mt-1 rounded-md border border-border bg-bg/30 px-2.5 py-2`,children:[(0,L.jsx)(`legend`,{className:`px-1 text-[11px] font-medium text-fg/85`,children:u}),(0,L.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t.options.map((n,i)=>{let o=String(i);return(0,L.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-[12px] text-fg/85`,children:[(0,L.jsx)(`input`,{type:`checkbox`,name:t.id,value:o,checked:e.includes(o),onChange:t=>r(t.target.checked?[...e,o]:e.filter(e=>e!==o)),autoFocus:a&&i===0,className:`mt-0.5 accent-[var(--color-accent)]`}),(0,L.jsx)(`span`,{children:n.label})]},o)})})]})}return(0,L.jsxs)(`div`,{className:`min-w-0`,children:[t.secret?(0,L.jsx)(`div`,{className:`text-[11px] font-medium text-fg/85`,children:u}):t.input!==`boolean`&&t.input!==`multi-select`?(0,L.jsx)(`label`,{htmlFor:o,className:`block text-[11px] font-medium text-fg/85`,children:u}):null,t.description&&(0,L.jsx)(`div`,{id:s,className:`mt-0.5 whitespace-pre-wrap break-words text-[10.5px] leading-snug text-muted`,children:t.description}),f,i&&(0,L.jsx)(`div`,{id:c,role:`alert`,className:`mt-1 text-[10.5px] text-red-300`,children:i})]})}function pQ(e){let t=e,n=``;do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return`${n}.`}function mQ(e,t){let n=t.description?.trim(),r=n&&!n.includes(`
311
311
  `)?n:void 0,i=[r?void 0:n,t.preview?.trim()].filter(Boolean).join(`
312
312
 
313
- `)||void 0;return{line:`${pQ(e)} ${t.label}${r?` — ${r}`:``}`,...i?{body:i}:{}}}var hQ=`root`;function gQ(e,t,n){return`${e}/${t}.${n}`}function _Q(e){let t=e.options??[],n=t.findIndex(e=>e.recommended),r=t.map((e,t)=>mQ(t,e));return{question:{kind:e.kind,danger:e.danger===!0,contextMd:e.question,options:r.map(e=>e.line),recommendedIdx:n===-1?null:n,...r.some(e=>e.body)?{optionBodies:r.map(e=>e.body)}:{}},optionLabels:t.map(e=>e.label)}}function vQ(e,t){return!t||e.kind===`multi`?null:t.chosen}function yQ(e,t){let n=[],r=(e,i,a)=>{let{question:o,optionLabels:s}=_Q(e);n.push({path:i,spec:e,question:o,optionLabels:s,depth:a});let c=vQ(e,t.get(i));c!==null&&(e.options?.[c]?.followUps??[]).forEach((e,t)=>r(e,gQ(i,c,t),a+1))};return r(e,hQ,1),n}function bQ(e,t){return t?t.text.trim()?!0:e.kind===`multi`?(t.chosenSet??[]).length>0:t.chosen!==null:!1}function xQ(e,t){if(!bQ(e.spec,t.get(`root`)))return;let n=(r,i)=>{let a=t.get(i),o=(r.options??[]).map(e=>e.label),s=vQ(r,a),c=r.kind===`multi`?(a?.chosenSet??[]).slice().sort((e,t)=>e-t).flatMap(e=>o[e]===void 0?[]:[o[e]]):s===null?[]:[o[s]].filter(e=>e!==void 0),l=r.kind===`multi`||s===null?a?.text.trim():void 0,u=s===null?[]:(r.options?.[s]?.followUps??[]).map((e,t)=>n(e,gQ(i,s,t)));return{questionId:e.id,question:r.question,chosen:c,...l?{text:l}:{},...u.length>0?{followUps:u}:{}}};return n(e.spec,hQ)}function SQ(e){let t=e instanceof Error?e.message:`The answer could not be sent.`;return t.length>240?`${t.slice(0,239)}…`:t}var CQ=(e,t)=>`${e}|${t}`;function wQ({thread:e,questions:t,inFlight:n=null,className:r=``}){let i=e?.id,a=t??e?.questions??[],o=cz(),[s,c]=(0,I.useState)(()=>new Map),[l,u]=(0,I.useState)(),d=(0,I.useContext)(z1),f=dz((0,I.useMemo)(()=>i?a.flatMap(e=>TQ(e).map(t=>sz.question(o,i,e.id,t))):[],[o,i,a])),p=(e,t)=>{let n=s.get(CQ(e.id,t));return{chosen:n?.chosen??null,chosenSet:n?.chosenSet??[],text:(i?f.get(sz.question(o,i,e.id,t)):void 0)??``}},m=e=>new Map(TQ(e).map(t=>[t,p(e,t)])),h=a.flatMap(e=>{let t=xQ(e,m(e));return t?[t]:[]}),g=it({mutationFn:async e=>Y.answerQuestions({slug:i,answers:e}),onSuccess:e=>{for(let t of e.answered){c(e=>{let n=new Map(e);for(let e of[...n.keys()])e.startsWith(`${t}|`)&&n.delete(e);return n});let e=a.find(e=>e.id===t);if(e&&i)for(let t of TQ(e))az.set(sz.question(o,i,e.id,t),``)}},onError:e=>{d?.cancel(),u(SQ(e))}}),_=it({mutationFn:async e=>Y.dismissQuestions({slug:i,ids:[e]}),onError:e=>u(SQ(e))});if(!i||a.length===0)return!i||!n?.length?null:(0,L.jsx)(`section`,{"data-answers-in-flight":!0,"aria-label":`Your answer, on its way to the worker`,className:`flex min-w-0 flex-col items-end ${r}`,children:(0,L.jsx)(dY,{answers:n,queued:!0})});let v=()=>{h.length===0||g.isPending||(u(void 0),d?.dismiss(),g.mutate(h))};return(0,L.jsxs)(`section`,{"data-registered-questions":!0,"aria-label":`${a.length} question${a.length===1?``:`s`} waiting for an answer`,className:`flex min-w-0 flex-col gap-3 ${r}`,children:[a.map(e=>(0,L.jsx)(`article`,{"data-question-id":e.id,className:`flex min-w-0 flex-col gap-2`,children:(()=>{let t=yQ(e.spec,m(e)),n=t=>(0,L.jsx)(CY,{question:t.question,label:t.depth>1?`Follow-up`:void 0,aside:t.depth===1&&!e.spec.danger?(0,L.jsx)(`button`,{type:`button`,"data-dismiss-question":!0,"aria-label":`Dismiss this question`,title:`Dismiss — the worker decides it itself`,disabled:_.isPending,onClick:()=>_.mutate(e.id),className:`card-icon-offset -mx-2 -my-1 flex rounded-md p-1 text-muted/70 outline-none transition-colors hover:bg-elevated hover:text-fg disabled:opacity-40`,children:(0,L.jsx)(ah,{size:16})}):void 0,interactive:{answer:p(e,t.path),onChip:n=>{c(r=>{let i=new Map(r),a=CQ(e.id,t.path),o=i.get(a)??{chosen:null,chosenSet:[]};if(t.spec.kind===`multi`){let e=o.chosenSet.includes(n)?o.chosenSet.filter(e=>e!==n):[...o.chosenSet,n];i.set(a,{...o,chosenSet:e})}else i.set(a,{...o,chosen:o.chosen===n?null:n});return i})},onText:n=>{az.set(sz.question(o,i,e.id,t.path),n),t.spec.kind!==`multi`&&c(n=>{let r=CQ(e.id,t.path),i=n.get(r);return!i||i.chosen===null?n:new Map(n).set(r,{...i,chosen:null})})},onSubmit:v}},t.path),r=t.slice(1);return(0,L.jsxs)(L.Fragment,{children:[n(t[0]),r.length>0&&(0,L.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:r.map(e=>(0,L.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:n(e)},e.path))})]})})()},e.id)),l&&(0,L.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-red-300`,children:l}),g.isPending&&(0,L.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[11px] leading-snug text-muted`,children:`Sending…`}),(0,L.jsx)(`div`,{className:`flex justify-start`,children:(0,L.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:h.length===0||g.isPending,onClick:v,onMouseDown:e=>e.preventDefault(),className:`rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:`Send answers`})})]})}function TQ(e){let t=[],n=(e,r)=>{t.push(r),e.options?.forEach((e,t)=>{e.followUps?.forEach((e,i)=>n(e,`${r}/${t}.${i}`))})};return n(e.spec,hQ),t}function EQ(e){return(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).length}function DQ(e,t={}){let n=(e.subAgents??[]).filter(e=>Xc(e)&&e.state===`running`).length,r=(e.bgShells??[]).filter(e=>e.state===`running`).length,i=t.watchers===!1?0:EQ(e),a=[n>0?`${n} sub-agent${n===1?``:`s`}`:null,r>0?`${r} background shell${r===1?``:`s`}`:null,i>0?`${i} PR watcher${i===1?``:`s`}`:null].filter(e=>e!==null);return a.length===0?`0 background shells`:a.length===1?a[0]:`${a.slice(0,-1).join(`, `)} and ${a[a.length-1]}`}function OQ(e){return(e.subAgents??[]).some(e=>Xc(e)&&e.state===`running`)}function kQ(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length}function AQ(e){return OQ(e)||kQ(e)>0}function jQ(e,t){return ul(t)??(MQ(e)?`Background shells running`:`Awaiting`)}function MQ(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length>0&&!OQ(e)&&EQ(e)===0&&NQ(e).length===0}function NQ(e){return(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`)}var PQ={id:``,subAgents:[],bgShells:[],watches:[]},FQ=[];function IQ(e,t){let n=new Set((e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).map(e=>e.target));return kH(t).filter(e=>!n.has(e.ref))}function LQ({watch:e}){return(0,I.useEffect)(()=>{e.url&&Of([e.ref])},[e.url,e.ref]),e.url?(0,L.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-gh-ref":e.ref,className:`${oJ} text-[12px]`,children:e.ref}):(0,L.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.ref})}var RQ={mergeable:`no conflicts`,blocked:`merge blocked`,conflicting:`has conflicts`,unknown:null};function zQ(e){return e.state!==`open`||e.merge===`blocked`&&e.checks!==`passing`&&e.checks!==`none`?null:RQ[e.merge]}var BQ=`shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`;function VQ({tone:e}){return(0,L.jsx)(`span`,{"aria-hidden":!0,className:`inline-block size-3 rounded-full border ${e} border-t-transparent motion-safe:animate-spin ${BQ}`})}function HQ(){return(0,L.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 16 16`,width:12,height:12,fill:`none`,stroke:`currentColor`,overflow:`visible`,className:BQ,style:{color:TE.fgAttention},children:[(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:`4`,fill:`currentColor`,stroke:`none`}),(0,L.jsxs)(`g`,{strokeWidth:`2`,className:`origin-center motion-safe:animate-spin`,children:[(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:`7`,opacity:`0.25`}),(0,L.jsx)(`path`,{d:`M15 8A7 7 0 0 1 8 15`})]})]})}function UQ({status:e}){return e?e.state===`merged`?(0,L.jsx)(bm,{size:12,className:BQ,style:{color:TE.fgDone}}):e.state===`closed`?(0,L.jsx)(xm,{size:12,className:BQ,style:{color:TE.fgDanger}}):e.checks===`failing`?(0,L.jsx)(um,{size:12,className:BQ,style:{color:TE.fgDanger}}):e.checks===`passing`?(0,L.jsx)(am,{size:12,className:BQ,style:{color:TE.fgSuccess}}):e.gated>0&&e.running===0?(0,L.jsx)(im,{size:12,className:BQ,style:{color:TE.fgAttention}}):e.checks===`running`?(0,L.jsx)(HQ,{}):(0,L.jsx)(om,{size:12,className:`${BQ} text-muted/60`}):(0,L.jsx)(om,{size:12,className:`${BQ} text-muted/60`})}function WQ(e){return[e.failed>0?`${e.failed} failing`:null,e.gated>0?`${e.gated} awaiting approval`:null,e.running>0?`${e.running} in progress`:null,e.passed>0?`${e.passed} successful`:null,e.skipped>0?`${e.skipped} skipped`:null].filter(e=>e!==null).join(`, `)}function GQ(e){if(!e)return`Checking…`;if(e.state===`merged`)return`Merged`;if(e.state===`closed`)return`Closed`;let t=WQ(e),n=zQ(e);return[t||`No checks`,n].filter(e=>e!==null).join(` · `)}var KQ=`group relative col-span-4 grid grid-cols-subgrid items-baseline rounded-sm text-[12px] leading-5`,qQ=`group relative col-span-4 flex items-baseline rounded-sm text-[12px] leading-5`,JQ=`ml-1.5 min-w-0 truncate font-medium text-fg/90`,YQ=`ml-3 min-w-0 truncate text-right text-muted/70`,XQ=`outline-none after:absolute after:inset-0 after:rounded-sm focus-visible:after:ring-1 focus-visible:after:ring-fg/60`;function ZQ(){return(0,L.jsx)(tm,{size:13,"aria-hidden":!0,className:`${BQ} ml-[3px] -mr-[4px] text-muted/35 transition-colors group-hover:text-muted/70`})}function QQ({mark:e,name:t,status:n,onOpen:r,onPrewarm:i,href:a,ghRef:o,title:s,testKind:c,testId:l,indent:u}){let d=u!==void 0,f=d?`${JQ} flex-1`:JQ,p=a?(0,L.jsx)(`a`,{href:a,target:`_blank`,rel:`noreferrer noopener`,title:s,"data-gh-ref":o,onMouseDown:e=>e.stopPropagation(),className:`${f} ${XQ} group-hover:underline group-hover:decoration-fg/40 group-hover:underline-offset-2`,children:t}):r?(0,L.jsx)(`button`,{type:`button`,onClick:r,onMouseDown:e=>e.stopPropagation(),title:s,className:`${f} ${XQ} text-left group-hover:underline group-hover:decoration-fg/40 group-hover:underline-offset-2`,children:t}):(0,L.jsx)(`span`,{className:f,title:s,children:t}),m=!!(a||r);return(0,L.jsxs)(`div`,{"data-wait-row":l,"data-wait-kind":c,onMouseEnter:i,onFocus:i,style:d?{paddingLeft:u}:void 0,className:`${d?qQ:KQ} ${m?`cursor-pointer transition-colors hover:bg-fg/[0.045]`:``}`,children:[(0,L.jsx)(`span`,{className:`flex shrink-0`,children:e}),p,(0,L.jsx)(`span`,{"data-wait-status":!0,className:YQ,children:n}),m?(0,L.jsx)(ZQ,{}):(0,L.jsx)(`span`,{})]})}function $Q({watch:e}){let t=e.github,n=DH(e.target);return(0,I.useEffect)(()=>{n&&Of([e.target])},[n,e.target]),(0,L.jsx)(QQ,{testKind:`github`,testId:e.target,mark:(0,L.jsx)(UQ,{status:t}),name:e.target,href:n??void 0,ghRef:n?e.target:void 0,title:n?`Open ${e.target} on GitHub`:e.target,status:(0,L.jsxs)(L.Fragment,{children:[GQ(t),t&&t.failing.length>0&&n&&(0,L.jsxs)(L.Fragment,{children:[` · `,(0,L.jsx)(`a`,{href:`${n}/checks`,target:`_blank`,rel:`noreferrer noopener`,onMouseDown:e=>e.stopPropagation(),className:`relative underline underline-offset-2 text-[#f85149]/85 decoration-[#f85149]/30 hover:decoration-[#f85149]`,children:`view failures`})]})]})})}function e$(e,t){return(e.bgShells??[]).find(e=>e.id===t||e.taskId===t||e.label===t)}function t$(e){return(e.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`)}function n$({watch:e,thread:t,slug:n,now:r}){let i=e$(t,e.target);if(i)return(0,L.jsx)(r$,{shell:i,slug:n,now:r,testId:e.target});let a=bE(e.createdAt,r);return(0,L.jsx)(QQ,{testKind:`shell`,testId:e.target,mark:(0,L.jsx)(eh,{size:12,className:`${BQ} text-shell`}),name:e.target,title:e.target,status:a?`running · ${a}`:`running`})}function r$({shell:e,slug:t,now:n,testId:r}){let i=bE(e.startedAt,n),a=e.id&&!e.outputUnavailable;return(0,L.jsx)(QQ,{testKind:`shell`,testId:r??e.id??e.label,mark:(0,L.jsx)(eh,{size:12,className:`${BQ} text-shell`}),name:e.label,onOpen:a?()=>tp(t,e.id,{label:e.label,startedAt:e.startedAt}):void 0,title:a?`Read this shell's output — running for ${i}`:e.label,status:i?`running · ${i}`:`running`})}function i$({watch:e,now:t}){let n=Date.parse(e.timer?.fireAt??``),r=Number.isFinite(n)?n>t?`fires in ${vE(n-t)}`:`firing…`:`armed`;return(0,L.jsx)(QQ,{testKind:`timer`,testId:e.target,mark:(0,L.jsx)(dm,{size:12,className:`${BQ} text-muted/60`}),name:e.timer?.prompt||e.target,title:e.timer?.fireAt?`One-off timer, set for ${e.timer.fireAt}`:e.target,status:r})}function a$(e){return(e.subAgents??[]).filter(e=>Xc(e)&&e.state===`running`)}function o$({agent:e,slug:t,now:n}){let r=bE(e.startedAt,n),i=e.subagentType?.replace(/^frizz:/,``);return(0,L.jsx)(QQ,{testKind:`agent`,testId:e.id??e.label,mark:(0,L.jsx)(VQ,{tone:`border-accent`}),name:e.label,onOpen:e.id?()=>ep(t,e.id,{label:e.label,subagentType:e.subagentType,startedAt:e.startedAt}):void 0,title:e.id?`Open this sub-agent — working for ${r}`:e.label,status:[i,r].filter(Boolean).join(` · `)})}function s$(e,t,n){let r=new Set(n.map(e=>e.target)),i=[];for(let n of t){if(n.kind!==`shell`)continue;let t=n.value.trim();if(!t||r.has(t))continue;let a=e$(e,t);!a||a.state!==`running`||(r.add(t),i.push({id:`shell:${e.id}:${t}`,kind:`shell`,target:t,state:`armed`,createdAt:a.startedAt}))}return i}function c$(e,t={}){let n=Date.parse(t.notAfter??``),r=e=>!Number.isFinite(n)||!e||!(Date.parse(e)>n),i=(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`&&r(e.createdAt)),a=t$(e).filter(t=>r(e$(e,t.target)?.startedAt??t.createdAt));return{prs:i,shells:[...a,...s$(e,t.hints??[],a)],agents:a$(e).filter(e=>r(e.startedAt)),timers:NQ(e).filter(e=>r(e.createdAt))}}function l$(e,t={}){let n=c$(e,t);return n.prs.length+n.shells.length+n.agents.length+n.timers.length>0}function u$(e,t,n={}){let{prs:r,shells:i,agents:a,timers:o}=c$(e,n);return[{head:`Sub-agents`,rows:a.map(n=>(0,L.jsx)(o$,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:i.map(n=>(0,L.jsx)(n$,{watch:n,thread:e,slug:e.id,now:t},n.id))},{head:`Pull requests`,rows:r.map(e=>(0,L.jsx)($Q,{watch:e},e.id))},{head:`Timers`,rows:o.map(e=>(0,L.jsx)(i$,{watch:e,now:t},e.id))}].filter(e=>e.rows.length>0)}function d$({group:e,first:t}){let n=`col-span-4 text-[10.5px] uppercase tracking-wide text-muted/45 ${t?``:`mt-2.5`}`;return e.onToggle?(0,L.jsxs)(`button`,{type:`button`,onClick:e.onToggle,"aria-expanded":!e.collapsed,onMouseDown:e=>e.stopPropagation(),className:`${n} flex items-baseline rounded-sm text-left transition-colors hover:text-muted/80`,children:[(0,L.jsx)(`span`,{children:e.head}),e.count!==void 0&&(0,L.jsx)(`span`,{className:`ml-1.5 tabular-nums`,children:e.count}),(0,L.jsx)(tm,{size:10,"aria-hidden":!0,className:`${BQ} ml-[5px] transition-transform ${e.collapsed?``:`rotate-90`}`})]}):(0,L.jsx)(`div`,{className:n,children:e.head})}function f$({groups:e,divider:t}){return e.length===0?null:(0,L.jsxs)(L.Fragment,{children:[t&&(0,L.jsx)(`div`,{"aria-hidden":!0,className:`-mx-4 mt-3 border-t border-border`}),(0,L.jsx)(`div`,{className:`mt-3 grid grid-cols-[auto_1fr_fit-content(50%)_auto] gap-y-px`,children:e.map((e,t)=>(0,L.jsxs)(I.Fragment,{children:[(0,L.jsx)(d$,{group:e,first:t===0}),!e.collapsed&&e.rows]},e.head))})]})}function p$(e){return e?.awaitingBackground===!0&&e.runtime===`turn-idle`&&e.bgSnoozed!==!0}var m$=`Hides card until new activity is detected`;function h$({thread:e,onSnooze:t,onSnoozeFailed:n}){let[r,i]=(0,I.useState)(!1);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{i(!0),t?.(),Y.snoozeAwaitingBackground({slug:e.id,sessionId:e.sessionId??``}).then(()=>Z(`Snoozed until the background work returns`)).catch(e=>{n?.(),Z(`Couldn’t snooze: ${e.message.slice(0,80)}`),i(!1)})},disabled:r,onMouseDown:e=>e.preventDefault(),title:m$,className:`disabled:opacity-45 ${sJ}`,children:[(0,L.jsx)(Tm,{size:12,className:BY}),`Snooze`]}),(0,L.jsx)(`span`,{className:aJ,children:m$})]})}function g$({thread:e,fence:t,onSnooze:n,onSnoozeFailed:r,notAfter:i}){let a=e??PQ,o=t??(e?.lastFence?.kind===`awaiting`?e.lastFence:void 0),s=o?.hints??FQ,c=OQ(a),l=FH(o?.body),u=gK(l??``),d=u$(a,sE(),{hints:s,notAfter:i}),f=IQ(a,s),p=i===void 0&&e!==void 0&&p$(e)&&SX(e).snooze;return(0,L.jsxs)(nJ,{"data-awaiting-background":!0,icon:MQ(a)?eh:Tm,label:(0,L.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:jQ(a,s)}),aside:f.length===1?(0,L.jsx)(LQ,{watch:f[0]}):void 0,className:p?`pb-0`:``,children:[l?(0,L.jsx)(hq,{className:`md-body ${Jq}`,html:u}):d.length===0&&!AQ(a)?(0,L.jsx)(`p`,{className:rJ,children:OH}):null,f.length>1&&(0,L.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:f.map(e=>(0,L.jsx)(LQ,{watch:e},e.ref))}),d.length===0&&AQ(a)&&(0,L.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75`,children:c?(0,L.jsxs)(L.Fragment,{children:[`It’s awaiting the results from `,DQ(a,{watchers:!1}),` it dispatched. It returns to the queue on its own when the work comes back.`]}):(0,L.jsxs)(L.Fragment,{children:[DQ(a,{watchers:!1}),` `,kQ(a)===1?`is`:`are`,` still running. It resumes on its own when`,` `,kQ(a)===1?`it finishes`:`one of them finishes`,`.`]})}),(0,L.jsx)(f$,{groups:d,divider:!!l}),p?(0,L.jsx)(`div`,{"data-awaiting-snooze":!0,className:`-mx-4 mt-3 flex flex-wrap items-center gap-x-2.5 gap-y-2 border-t border-border bg-fg/[0.03] px-4 py-2.5 ${Zq}`,children:(0,L.jsx)(h$,{thread:e,onSnooze:n,onSnoozeFailed:r})}):null]})}function _$(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.kind!==`event`||n.boundary!==`rest`)){for(let r=t-1;r>=0;r--){let t=e[r];if(t.role===`assistant`&&t.kind!==`event`&&t.kind!==`reasoning`)return{index:r,at:n.at}}return{index:-1,at:n.at}}}}function v$(e,t=Date.now()){return e!==void 0&&DT(e,t)!==void 0}function y$(){let[e,t]=(0,I.useState)(()=>Date.now());return(0,I.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function b$({thread:e}){let t=y$(),[n,r]=(0,I.useState)(!1),i=DT(e,t);if(!i)return null;let a=Date.parse(i),o=Ww(i,t).replace(/^(Today|Tomorrow)/,e=>e.toLowerCase()),s=e.snoozePrompt?.trim();async function c(){r(!0);try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:null,prompt:null}),Z(`Snooze cleared`)}catch(e){Z((e instanceof Error?e.message:`Wake failed`).slice(0,100))}finally{r(!1)}}return(0,L.jsxs)(nJ,{"data-snooze-card":!0,icon:Tm,label:`Snoozed`,children:[(0,L.jsx)(`div`,{"data-snooze-countdown":!0,title:new Date(a).toLocaleString(),className:`text-[22px] font-semibold leading-8 tracking-tight text-fg tabular-nums`,children:SE(a-t)}),(0,L.jsx)(`p`,{className:rJ,children:s?(0,L.jsxs)(L.Fragment,{children:[`Resumes `,o,` and sends: “`,Jw(s),`”`]}):(0,L.jsxs)(L.Fragment,{children:[`Returns to the queue `,o,`.`]})}),e.foreign!==!0&&(0,L.jsx)(iJ,{children:(0,L.jsx)(`button`,{type:`button`,"data-snooze-wake-now":!0,disabled:n,onClick:()=>void c(),className:`${sJ} disabled:cursor-not-allowed disabled:opacity-45`,children:`Wake now`})})]})}function x$({at:e,fallbackAt:t,className:n=``}){let r=sE(),i=UT(e,t),a=WT(i,r);return!a||!i?null:(0,L.jsx)(`time`,{dateTime:i,className:n,children:a})}var S$=1500;function C$(e,t){let n=0,r;function i(){r!==void 0&&(t.clearTimeout(r),r=void 0)}return{begin(){let a=++n;return e(!0),i(),r=t.setTimeout(()=>{a===n&&e(!1),r=void 0},S$),a},fail(t){t===n&&(i(),e(!1))},dispose(){n++,i()}}}var w$=`Could not copy terminal command`,T$={attach:`Attach command copied`,resume:`Resume command copied`},E$={attach:`Copy command to attach to this thread's live terminal`,resume:`Copy command to resume this thread in a new terminal`},D$=e=>[`terminalCommand`,e];function O$(e){return Y.threadTerminalCommand({slug:e}).then(e=>{if(!e.command)throw Error(e.reason??`No verified provider session is available to resume`);return{command:e.command,mode:e.mode===`attach`?`attach`:`resume`}})}async function k$(e){let t=O$(e);if(typeof ClipboardItem<`u`&&navigator.clipboard?.write)return await navigator.clipboard.write([new ClipboardItem({"text/plain":t.then(({command:e})=>new Blob([e],{type:`text/plain`}))})]),(await t).mode;let{command:n,mode:r}=await t;return await wR(n),r}function A$(e){let t=it({mutationFn:()=>k$(e)});return e=>t.mutate(void 0,{onSuccess:t=>{e?.onSuccess?.(),Z(T$[t])},onError:t=>{e?.onError?.(),Z(t instanceof Error?`${w$}: ${t.message}`:w$,{duration:7e3})}})}function j$({slug:e}){let[t,n]=(0,I.useState)(!1),r=(0,I.useRef)(null);r.current||=C$(n,{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)});let i=Ve(),a=A$(e);(0,I.useEffect)(()=>()=>r.current?.dispose(),[]);function o(){i.prefetchQuery({queryKey:D$(e),queryFn:()=>O$(e),staleTime:15e3})}function s(){let t=i.getQueryData(D$(e));if(t){wR(t.command).then(()=>{r.current?.begin(),Z(T$[t.mode])},()=>Z(w$,{duration:7e3}));return}a({onSuccess:()=>r.current?.begin()})}let c=i.getQueryData(D$(e)),l=t?c?T$[c.mode]:`Terminal command copied`:c?E$[c.mode]:`Copy terminal command`;return(0,L.jsx)(Rj,{label:l,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":l,title:l,onClick:s,onPointerEnter:o,onFocus:o,className:tD,children:t?(0,L.jsx)(Qp,{size:14,strokeWidth:2.2,className:`text-fg`}):(0,L.jsx)(eh,{size:14,strokeWidth:1.8})})})}function M$(e){let t=Math.max(e.scrollHeight-e.clientHeight,0),n=t-e.scrollTop,r=e.scrollHeight!==e.previousScrollHeight,i=r&&!e.readerMoved?e.following||n<=1:n<=4;return!i||!r||t<=0||n<=1?{following:i,scrollTop:null}:{following:i,scrollTop:t}}function N$(e){let t=e.scrollTop>640?!0:e.armed,n=t&&e.readerMoved&&e.scrollTop<=480&&e.hasEarlier&&!e.loading;return{armed:n?!1:t,shouldLoad:n}}function P$(e){return`legacy:${e.role}:${e.kind??`message`}:${e.at??``}:${e.text}`}function F$(e,t,n){let r=[],i=new Map,a=null;return e.forEach((e,o)=>{if(e.queued||t(e))return;let s=e.sourceId??P$(e),c=i.get(s)??0;i.set(s,c+1),r.push({key:c===0?s:`${s}:${c}`,message:e,messageIndex:o,gap:a===null?0:n(a,e)}),a=e}),r}function I$(e,t,n){let r=e[t];if(!r||r.kind!==`event`||r.boundary!==`rest`)return!1;for(let r=t+1;r<e.length;r++){let t=e[r];if(!(t.queued||n(t)))return!!t.boundary||t.wake===!0}return!0}function L$(e,t){let n=e.map(e=>e.message);return e.filter((e,r)=>!I$(n,r,t))}var R$=new Set([`agent`,`follow up`,`interrupt`,`send message`,`spawn agent`,`wait for agents`]),z$=new Set([`poll process`,`wait`]);function B$(e){return(e.split(`__`).pop()||e).replaceAll(`_`,` `).trim()}function V$(e){return B$(e).toLowerCase()}function H$(e){return e.prompt!==void 0||e.agentId!==void 0||e.sendTo!==void 0||e.sendBody!==void 0||e.backgroundState!==void 0&&!G$(e)||W$(e)||U$(e)||R$.has(V$(e.name))}function U$(e){return e.ask!==void 0&&e.ask.length>0&&e.status!==void 0&&e.status!==`pending`}function W$(e){return e.outputImage!==void 0||e.sentImages!==void 0&&e.sentImages.length>0}function G$(e){return e.backgroundState===`unknown`&&z$.has(V$(e.name))}function K$(e){if(e.role!==`assistant`||e.kind||e.queued)return null;if(e.parts&&e.parts.length>0){let t=[];for(let n of e.parts)if(n.kind===`text`){if(n.text.trim())return null}else t.push(...n.tools);return t.length>0&&t.every(e=>!H$(e))?t:null}return e.text.trim()||e.tools.length===0?null:e.tools.every(e=>!H$(e))?e.tools:null}function q$(e){return e.role!==`assistant`||e.kind||e.queued||e.text.trim()||e.tools.length>0?!1:!e.parts?.some(e=>e.kind===`text`?e.text.trim().length>0:e.tools.length>0)}function J$(e){if(e.role!==`assistant`||e.kind||e.queued)return null;if(!e.parts?.length)return Y$(e.tools);for(let t=e.parts.length-1;t>=0;t--){let n=e.parts[t];if(n.kind===`text`){if(n.text.trim())return null;continue}if(n.tools.length!==0)return Y$(n.tools)}return null}function Y$(e){let t=[];for(let n=e.length-1;n>=0&&!H$(e[n]);n--)t.unshift(e[n]);return t.length>0?t:null}function X$(e){if(e.role!==`assistant`||e.kind||e.queued)return null;let t=[],n=e=>{for(let n of e){if(H$(n))return!0;t.push(n)}return!1};if(!e.parts?.length)return e.text.trim()?null:n(e.tools)&&t.length>0?t:null;for(let r of e.parts){if(r.kind===`text`){if(!r.text.trim())continue;return t.length>0?t:null}if(n(r.tools))return t.length>0?t:null}return null}function Z$(e,t){return Q$(e,new Set(t))}function Q$(e,t){if(!e.parts?.length)return{...e,tools:e.tools.filter(e=>!t.has(e))};let n=e.parts.map(e=>e.kind===`text`?e:{kind:`tools`,tools:e.tools.filter(e=>!t.has(e))}).filter(e=>e.kind===`text`||e.tools.length>0);return{...e,tools:n.flatMap(e=>e.kind===`tools`?e.tools:[]),parts:n}}function $$(e,t,n){let r=[...e.tools,...t],i=e.parts?.map(e=>e.kind===`text`?e:{...e,tools:[...e.tools]})??[],a=-1;for(let e=i.length-1;e>=0;e--){let t=i[e];if(t.kind===`text`){if(t.text.trim())break;continue}if(t.tools.length>0){a=e;break}}let o=i[a];return o?.kind===`tools`?i[a]={kind:`tools`,tools:[...o.tools,...t]}:i.push({kind:`tools`,tools:t}),{...e,at:n??e.at,tools:r,parts:i}}function e1(e){let t=[],n=null;return e.forEach((e,r)=>{if(q$(e))return;if(e.queued){t.push({message:e,messageIndex:r});return}let i=K$(e);if(i&&n){n.message=$$(n.message,i,e.at);return}let a=n?X$(e):null,o=a?Z$(e,a):e;a&&n&&(n.message=$$(n.message,a,e.at));let s={message:o,messageIndex:r};t.push(s),J$(o)?(s.runStartedAt=o.at,n=s):n=null}),t}function t1(e){return e.status===`completed`||e.status===`failed`||e.status===`cancelled`}function n1(e){let t=r1(e);return t?.tools.some(e=>!t1(e))?t.tools.at(-1):void 0}function r1(e){let t=i1(e);if(!t)return;let n=J$(t.message);return n?{tools:n,at:t.message.at}:void 0}function i1(e){for(let t=e.length-1;t>=0;t--)if(!e[t].message.queued)return e[t]}function a1(e){let t=i1(e);if(t)return J$(t.message)?t.runStartedAt??t.message.at:t.message.at}function o1(e){return e.runStartedAt??e.message.at}function s1(e){let t=J$(e);return t?Q$(e,new Set(t)):e}function c1(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].message;if(!r.queued){J$(r)&&(t=r);break}}if(!t)return[...e];let n=[];for(let r of e){let e=r.message===t?s1(r.message):r.message;q$(e)||n.push(e===r.message?r:{...r,message:e})}return n}function l1(e){return e.detail?.trim()||void 0}var u1={add:`Adding`,analyze:`Analyzing`,apply:`Applying`,audit:`Auditing`,benchmark:`Benchmarking`,build:`Building`,bump:`Bumping`,capture:`Capturing`,check:`Checking`,clean:`Cleaning`,collect:`Collecting`,commit:`Committing`,compare:`Comparing`,confirm:`Confirming`,copy:`Copying`,count:`Counting`,create:`Creating`,debug:`Debugging`,delete:`Deleting`,diff:`Diffing`,disable:`Disabling`,dispatch:`Dispatching`,drive:`Driving`,dump:`Dumping`,edit:`Editing`,enable:`Enabling`,extract:`Extracting`,fetch:`Fetching`,find:`Finding`,fix:`Fixing`,format:`Formatting`,generate:`Generating`,grep:`Grepping`,inspect:`Inspecting`,install:`Installing`,kill:`Killing`,launch:`Launching`,lint:`Linting`,list:`Listing`,load:`Loading`,measure:`Measuring`,merge:`Merging`,migrate:`Migrating`,move:`Moving`,open:`Opening`,parse:`Parsing`,patch:`Patching`,poll:`Polling`,print:`Printing`,probe:`Probing`,profile:`Profiling`,publish:`Publishing`,pull:`Pulling`,push:`Pushing`,query:`Querying`,read:`Reading`,rebase:`Rebasing`,refactor:`Refactoring`,regenerate:`Regenerating`,remove:`Removing`,rename:`Renaming`,render:`Rendering`,reproduce:`Reproducing`,restart:`Restarting`,revert:`Reverting`,review:`Reviewing`,run:`Running`,save:`Saving`,scan:`Scanning`,search:`Searching`,seed:`Seeding`,spawn:`Spawning`,start:`Starting`,stop:`Stopping`,summarize:`Summarizing`,sync:`Syncing`,tag:`Tagging`,test:`Testing`,trace:`Tracing`,typecheck:`Typechecking`,update:`Updating`,validate:`Validating`,verify:`Verifying`,wait:`Waiting`,watch:`Watching`,write:`Writing`};function d1(e,t){let n=e?.trim();if(!n)return t;let r=n.indexOf(` `),i=(r===-1?n:n.slice(0,r)).replace(/[.:]$/,``);if(/ing$/i.test(i))return i.charAt(0).toUpperCase()+i.slice(1)+(r===-1?``:n.slice(r));let a=u1[i.toLowerCase()];return a?a+(r===-1?``:n.slice(r)):n.charAt(0).toUpperCase()+n.slice(1)}function f1(e,t){let n=t?.trim().replace(/\/+$/,``);if(!n||n===`/`||!n.startsWith(`/`))return e;let r=e.replaceAll(`${n}/`,``),i=/^(\/(?:Users|home)\/[^/]+)(?:\/|$)/.exec(n)?.[1];return i?r.replaceAll(`${i}/`,`~/`):r}function p1(e,t){return f1(m1(e),t)}function m1(e){let t=V$(e.name),n=l1(e),r=n?` ${n}`:``;return t===`bash`||t===`exec`||t===`run command`?d1(e.desc,n?`Running ${n}`:`Running a command`):t===`read`||t===`view image`?`Reading${r||` a file`}`:t===`grep`||t===`search`||t===`search query`||t===`find`?n?`Searching for ${n}`:`Searching`:t===`glob`||t===`find files`?n?`Finding ${n}`:`Finding files`:t===`edit`||t===`write`||t===`apply patch`?n?`Editing ${n}`:`Editing files`:t===`todos`||t===`update plan`?`Updating the plan`:t===`screenshot`||t===`snapshot`?n?`Capturing ${n}`:`Capturing the page`:t===`navigate`?n?`Navigating to ${n}`:`Navigating`:t===`evaluate`?`Evaluating the page`:t===`pages`?`Listing pages`:t===`new page`?`Opening a new page`:t===`close page`?`Closing the page`:t===`select page`?`Selecting a page`:t===`console`||t===`console message`?`Reading the console`:t===`network`||t===`network request`?`Inspecting network traffic`:t===`press key`?n?`Pressing ${n}`:`Pressing a key`:t===`fill form`?`Filling the form`:t===`dialog`?`Handling a dialog`:t===`upload`?n?`Uploading ${n}`:`Uploading a file`:t===`wait for`||t===`wait`?n?`Waiting for ${n}`:`Waiting`:t===`resize`?`Resizing the page`:t===`ask`?`Preparing a question`:t===`web`||t===`web search`?n?`Searching for ${n}`:`Searching the web`:`Using ${B$(e.name)||`a tool`}`}var h1=new Set([`edit`,`multiedit`,`write`,`apply patch`]);function g1(e){let t=new Set;for(let n of e){for(let e of n.edits??(n.edit?[n.edit]:[]))e.file.trim()&&t.add(e.file.trim());if(n.edit||n.edits?.length)continue;let e=n.detail?.trim();e&&h1.has(V$(n.name))&&t.add(e)}return t.size}function _1(e,t=0){let n=`Ran ${e} tool ${e===1?`call`:`calls`}`;return t===0?n:`${n}, edited ${t} file${t===1?``:`s`}`}function v1(e){return e>0?`${_1(e)}. Thinking…`:`Thinking…`}function y1(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function b1(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function x1(e,t){let n=y1(e,t);if(n)try{let e=new URL(n);return e.protocol===`https:`||e.protocol===`http:`?e.href:void 0}catch{return}}function S1({directive:e,icon:t,title:n,meta:r,children:i}){return(0,L.jsxs)(`section`,{"data-codex-directive":e.name,className:`min-w-0 ${Yq} border border-border bg-panel-2/75 p-4`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center text-muted`,"aria-hidden":!0,children:t}),(0,L.jsx)(`div`,{className:`max-w-[calc(100%-1.5rem)] shrink-0 break-words text-[12px] font-medium leading-4 text-fg`,children:n}),r&&(0,L.jsx)(`div`,{className:`min-w-0 truncate text-[11px] font-normal leading-4 text-muted`,children:r})]}),i]})}function C1({children:e,mono:t=!1}){return(0,L.jsx)(`div`,{className:`ml-6 mt-1 break-words text-[11px] leading-4 text-muted${t?` font-mono-keep`:``}`,children:e})}function w1({directive:e}){let t=e.attrs,n=y1(t,`display_name`)??y1(t,`skill_name`)??`Artifact template`,r=y1(t,`artifact_kind`),i=y1(t,`skill_name`),a=y1(t,`skill_directory`),[o,s]=(0,I.useState)(!!a);return(0,L.jsxs)(S1,{directive:e,icon:(0,L.jsx)(Am,{size:15}),title:n,meta:r?`${r} template`:`Template`,children:[i&&(0,L.jsx)(C1,{mono:!0,children:i.startsWith(`$`)?i:`$${i}`}),o&&a&&(0,L.jsx)(`img`,{src:jS(`${a}/assets/preview.png`),alt:`${n} template preview`,loading:`lazy`,onError:()=>s(!1),className:`ml-6 mt-2 max-h-44 max-w-[calc(100%-1.5rem)] rounded-md border border-border object-contain`})]})}function T1({directive:e}){let t=e.attrs,n=y1(t,`file`),r=b1(t,`start`),i=b1(t,`end`)??r,a=b1(t,`priority`),o=n?`${n}${r?`:${r}${i&&i!==r?`-${i}`:``}`:``}`:`Code location unavailable`;return(0,L.jsxs)(S1,{directive:e,icon:(0,L.jsx)(Fm,{size:15}),title:y1(t,`title`)??`Review finding`,meta:a===void 0?void 0:`P${a}`,children:[y1(t,`body`)&&(0,L.jsx)(C1,{children:y1(t,`body`)}),n?(0,L.jsx)(`button`,{type:`button`,className:`local-file-action ml-6 mt-1 max-w-[calc(100%-1.5rem)] break-all text-left font-mono-keep text-[11px] leading-4 text-accent underline decoration-dotted underline-offset-2`,"data-local-path":n,title:o,children:o}):(0,L.jsx)(C1,{mono:!0,children:o})]})}var E1={"git-stage":[zm,`Changes staged`],"git-commit":[ym,`Commit created`],"git-create-branch":[vm,`Branch created`],"git-push":[ih,`Branch pushed`],"git-create-pr":[Cm,`Pull request created`]};function D1({directive:e}){let[t,n]=E1[e.name],r=y1(e.attrs,`branch`),i=x1(e.attrs,`url`),a=`${n}${e.attrs.isDraft===!0?` as draft`:``}`;return(0,L.jsx)(S1,{directive:e,icon:(0,L.jsx)(t,{size:15}),title:i?(0,L.jsx)(`a`,{className:`text-accent underline underline-offset-2`,href:i,target:`_blank`,rel:`noopener noreferrer`,children:a}):a,meta:r&&(0,L.jsx)(`span`,{className:`font-mono-keep`,children:r})})}function O1({directive:e}){let t=y1(e.attrs,`threadId`),n=y1(e.attrs,`pendingWorktreeId`);return(0,L.jsx)(S1,{directive:e,icon:(0,L.jsx)(Rm,{size:15}),title:n?`Thread setup queued`:`Thread created`,meta:(t||n)&&(0,L.jsx)(`span`,{className:`font-mono-keep`,children:t??n})})}function k1({directive:e}){let t=y1(e.attrs,`reason`);return(0,L.jsx)(S1,{directive:e,icon:(0,L.jsx)(Kp,{size:15}),title:`Archive suggested`,meta:t})}function A1(e){if(typeof e!=`string`||!e)return;let t=e.match(/(?:^|;)INTERVAL=(\d+)(?:;|$)/)?.[1];return/(?:^|;)FREQ=HOURLY(?:;|$)/.test(e)?`Every ${t??`1`} hour${t===`1`||t===void 0?``:`s`}`:/(?:^|;)FREQ=WEEKLY(?:;|$)/.test(e)?`Weekly schedule`:`Custom schedule`}function j1({directive:e}){let t=e.attrs,n=y1(t,`mode`),r=y1(t,`name`)??`Automation`,i=A1(t.rrule),a=[r,n,y1(t,`status`),i].filter(Boolean).join(` · `);return(0,L.jsx)(S1,{directive:e,icon:(0,L.jsx)(Zp,{size:15}),title:`Automation suggested`,meta:a,children:y1(t,`prompt`)&&(0,L.jsx)(C1,{children:y1(t,`prompt`)})})}function M1({directive:e}){return e.name===`artifact-template`?(0,L.jsx)(w1,{directive:e}):e.name===`code-comment`?(0,L.jsx)(T1,{directive:e}):e.name.startsWith(`git-`)?(0,L.jsx)(D1,{directive:e}):e.name===`created-thread`?(0,L.jsx)(O1,{directive:e}):e.name===`archive`||e.name===`archive-thread`?(0,L.jsx)(k1,{directive:e}):(0,L.jsx)(j1,{directive:e})}var N1;function P1(){return N1??=By(async()=>{let{default:e}=await import(`./mermaid.core-D5Mvu4fo.js`);return{default:e}},__vite__mapDeps([2,3,4,1,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])).then(({default:e})=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:`dark`,themeVariables:{background:`#181b20`,primaryColor:`#181b20`,primaryTextColor:`#e6e7e9`,primaryBorderColor:`#33363c`,lineColor:`#8b8f96`,secondaryColor:`#26282d`,tertiaryColor:`#0d0e10`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`}}),e)),N1}function F1({source:e}){let t=(0,I.useId)(),[n,r]=(0,I.useState)({}),i=nq(n.html??``);return(0,I.useEffect)(()=>{let n=!0;if(r({}),e.length>5e4)return r({error:`Diagram source exceeds the 50 KB rendering limit`}),()=>{n=!1};let i=`frizz-mermaid-${t.replace(/[^a-zA-Z0-9]/g,``)}`;return P1().then(t=>t.render(i,e)).then(({svg:e})=>{n&&r({html:e})}).catch(e=>{if(!n)return;let t=e instanceof Error?e.message.split(/\n| for text:/,1)[0]:`Unknown diagram error`;r({error:t.slice(0,240)})}).finally(()=>document.getElementById(`d${i}`)?.remove()),()=>{n=!1}},[t,e]),n.error?(0,L.jsxs)(`section`,{"data-mermaid-state":`error`,className:`${Yq} border border-border bg-panel-2/75 p-4`,children:[(0,L.jsx)(`div`,{className:`text-[12px] font-medium text-fg`,children:`Diagram unavailable`}),(0,L.jsx)(`div`,{className:`mt-1 text-[11px] text-muted`,children:n.error}),(0,L.jsx)(`pre`,{className:`mt-2 overflow-x-auto whitespace-pre-wrap rounded-md bg-bg p-2 font-mono-keep text-[11px] text-muted`,children:e})]}):n.html?(0,L.jsx)(`div`,{"data-mermaid-state":`ready`,className:`overflow-x-auto ${Yq} border border-border bg-panel-2/75 p-4 [&_svg]:mx-auto [&_svg]:h-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:i}):(0,L.jsx)(`div`,{"data-mermaid-state":`loading`,role:`status`,"aria-label":`Rendering diagram`,className:`h-24 animate-pulse ${Yq} bg-panel-2`})}var I1=(0,I.createContext)(null),L1=(0,I.createContext)(null);function R1(){let e=(0,I.useContext)(I1),t=(0,I.useContext)(L1);return e??t}var z1=(0,I.createContext)(null);function B1(e){return e.status===`pending`&&e.backgroundState===`background`}function V1(e){let t=[];for(let n of e)for(let e of n.tools)B1(e)&&n.at&&t.push({label:e.desc??e.detail??e.command??`Background command`,startedAt:n.at,state:`running`,...e.shellId?{launchId:e.shellId}:{},...e.command?{command:e.command}:{}});return t}function H1(e){return e.map(e=>{if(!e.tools.some(B1))return e;let t=e.tools.filter(e=>!B1(e)),n=e.parts?.map(e=>e.kind===`tools`?{...e,tools:e.tools.filter(e=>!B1(e))}:e).filter(e=>e.kind!==`tools`||e.tools.length>0);return{...e,tools:t,parts:n}})}function U1({slug:e,onStatusApplied:t,onClose:n,virtualized:r=!1,showReturnToQueue:i=!1}){let a=Dp(kC(),e);return(0,L.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,L.jsx)(t0,{slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:i}),(0,L.jsx)(W1,{slug:e,virtualized:r}),a&&(0,L.jsx)(YX,{thread:a,sticky:!0,safeArea:!0,onArchived:t})]})}function W1({slug:e,virtualized:t}){let n=kC(),r=Dp(n,e),i=r?.runtime===`running`||r?.runtime===`spawning`,a=A$(e),o=UC(e,{poll:i}),s=Ve(),c=(0,I.useRef)(!1),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(null),p=(0,I.useMemo)(()=>o.data?.messages??[],[o.data]),m=(0,I.useMemo)(()=>V1(p),[p]),h=(0,I.useMemo)(()=>H1(p),[p]),g=(0,I.useMemo)(()=>h0(h),[h]),_=(0,I.useMemo)(()=>i?_$(h):void 0,[i,h]),v=_&&_.index>=0?_.index:g,y=(0,I.useMemo)(()=>e1(h),[h]),b=i?r1(y):void 0,x=i?n1(y):void 0,S=x?p1(x,n?.projectDir):void 0,C=i?a1(y):void 0,w=p$(r),T=(0,I.useMemo)(()=>{let e=i?c1(y):y;return L$(e,g0(e,v,w))},[y,i,v,w]),E=i,D=(0,I.useMemo)(()=>EJ(p),[p]),O=(0,I.useMemo)(()=>xJ(p,r?.answersInFlight),[p,r?.answersInFlight]),k=(0,I.useMemo)(()=>IY(p),[p]),A={thread:r,showWorking:E,registeredDone:qq(r,g>=0?h[g]?.text:void 0),restedCard:cJ(r,g>=0?h[g]?.text:void 0),errorVisible:uJ(h,r?.providerError)},{answeringForMessage:j}=yY(e,p),M=(0,I.useMemo)(()=>NJ(p,r?.questions??[]),[p,r?.questions]),N=(0,I.useRef)(null),[P,ee]=(0,I.useState)(null),F=o.data?.messages.length??0,te=!o.isLoading;(0,I.useEffect)(()=>{if(t)return;let e=N.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<=4&&(e.scrollTop=e.scrollHeight)},[F,i,t]);let ne=(0,I.useCallback)(async()=>{if(c.current)return;let t=s.getQueryData([`transcript`,e]),n=t?.beforeCursor,r=t?.transcriptKey;if(!(!t?.hasEarlier||!n||!r)){c.current=!0,u(!0),f(null);try{let t=await Y.threadTranscriptEarlier({slug:e,cursor:n}),i=s.getQueryData([`transcript`,e]);if(!i?.transcriptKey||i.transcriptKey!==r||t.transcriptKey!==r){await o.refetch(),Z(`Transcript changed while loading history; refreshed the current session`);return}s.setQueryData([`transcript`,e],mx(i,t))}catch(e){let t=e instanceof Error?e.message:`Could not load earlier transcript history`;f(t)}finally{c.current=!1,u(!1)}}},[o,s,e]);return(0,L.jsx)(I1.Provider,{value:e,children:(0,L.jsxs)(`div`,{"data-drawer-scroll-ready":o.isPending?`false`:`true`,className:`flex-1 min-h-0 flex flex-col overflow-hidden outline-none`,children:[(0,L.jsxs)(`div`,{className:`relative min-h-0 flex-1 flex flex-col`,children:[(0,L.jsx)(`div`,{ref:N,"data-drawer-transcript-scroll":!0,"data-virtualized-transcript-scroll":t||void 0,tabIndex:t?0:void 0,role:t?`region`:void 0,"aria-label":t?`Thread conversation`:void 0,"aria-busy":t&&l?!0:void 0,className:`relative min-h-0 flex-1 overflow-y-auto pb-3 outline-none [overflow-anchor:none] focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/60`,children:t&&F>0?(0,L.jsx)($1,{slug:e,transcriptRef:N,transcriptKey:o.data?.transcriptKey,messages:h,paired:D,inFlightAnswers:O,answeringForMessage:j,thread:r,running:i,copyTerminalCommand:a,transportFallback:o.transportFallback,isFetching:o.isFetching,refresh:()=>void o.refetch(),retryLiveUpdates:o.retryLiveUpdates,hasEarlier:o.data?.hasEarlier===!0,beforeCursor:o.data?.beforeCursor,loadingEarlier:l,earlierError:d,loadEarlier:()=>void ne(),jumpOverlay:P}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(tQ,{thread:r,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(wQ,{thread:r,inFlight:O,className:`px-6 pt-5`}),o.transportFallback&&(0,L.jsxs)(`div`,{"data-transcript-sync-fallback":!0,className:`mx-6 mt-3 flex flex-wrap items-center gap-2.5 rounded-xl border border-border-strong bg-panel-2 px-4 py-2.5 text-[12px]`,title:o.transportFallback.kind===`payload-too-large`?`Live payload ${o.transportFallback.actualBytes} bytes; socket limit ${o.transportFallback.maxBytes} bytes`:`Transcript read budget reached (${o.transportFallback.scope}); retry after about ${o.transportFallback.retryAfterMs}ms`,children:[(0,L.jsx)(rh,{size:13,className:`shrink-0 text-muted`}),(0,L.jsxs)(`div`,{className:`min-w-[180px] flex-1 leading-snug text-fg/85`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Live transcript updates paused.`}),` `,o.transportFallback.kind===`payload-too-large`?`The transcript is too large for push; the last complete HTTP-loaded copy remains visible.`:`The live read budget was reached; the last complete copy remains visible. Retry in a moment.`]}),(0,L.jsx)(`button`,{type:`button`,disabled:o.isFetching,onClick:()=>void o.refetch(),className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel disabled:opacity-40`,children:o.isFetching?`Refreshing…`:`Refresh once`}),(0,L.jsx)(`button`,{type:`button`,onClick:o.retryLiveUpdates,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel`,children:`Retry live`})]}),(0,L.jsx)(`div`,{"data-transcript-column":!0,className:`flex min-h-full flex-col px-6 py-5`,children:F===0?(0,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted`,children:o.isPending?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(b2,{}),` Loading…`]}):i?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(b2,{}),` Session starting…`]}):HY(r)?(0,L.jsxs)(`div`,{className:`text-center`,children:[(0,L.jsx)(`p`,{className:`mb-3`,children:`No session is attached to this thread yet.`}),(0,L.jsx)(`button`,{className:`btn-ghost border border-border text-[12px]`,onClick:()=>Y.adoptThread({slug:e}).catch(()=>{}),children:`Start a session on this thread`})]}):`No conversation yet.`}):(0,L.jsxs)(L.Fragment,{children:[b0(T.map(e=>e.message),(e,t)=>{let n=T[t].messageIndex;return(0,L.jsx)(t2,{m:e,answering:j(e),showSendButton:!0,paired:D[n],staleAwaiting:v>=0&&n<v,restingCardShown:n===g&&w,restedAt:_&&n===_.index?_.at??``:void 0,shadowedBy:M.get(n),thread:r},t)},e=>!!e.queued),te&&X1(A)!==null&&(0,L.jsx)(BJ,{h:Z1(A,T.map(e=>e.message))}),te&&(0,L.jsx)(Q1,{state:A,slug:e,retryText:k>=0?p[k]?.text:void 0,onTerminal:a,liveRuntimeStart:C,liveActivityLabel:S,liveToolRun:b}),r?.permPolicy?(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(f2,{policy:r.permPolicy,denies:r.permDenies})}):null,p.some(e=>e.queued)&&(0,L.jsx)(BJ,{}),(0,L.jsx)(`div`,{className:`flex flex-col gap-3.5`,children:p.map((e,t)=>e.queued?(0,L.jsx)(t2,{m:e,paired:D[t]},`q${t}`):null)})]})})]})}),(0,L.jsx)(`div`,{ref:ee,"data-transcript-overlay":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-end p-4 [&>*]:pointer-events-auto`})]}),(0,L.jsx)(`div`,{"data-thread-chat-footer":!0,className:`z-10 shrink-0 border-t border-border/60 bg-panel`,children:(0,L.jsx)(pX,{slug:e,onTerminal:a,ops:(0,L.jsx)(p2,{slug:e,transcriptShells:m,className:`px-1 pt-1.5`})})})]})})}var G1=700,K1=250,q1=(()=>{try{return localStorage.getItem(`frizz.debugScroll`)===`1`}catch{return!1}})();function J1(e){return e?.pendingInteraction===!0}function Y1(e){return J1(e)?void 0:e?.pendingAsk}function X1({thread:e,showWorking:t,registeredDone:n,restedCard:r,errorVisible:i}){return e?.providerError?.retrying?`provider-error`:e?.providerFault&&!e.foreign?`provider-fault`:e?.limitPause&&!e.foreign?`limit-pause`:Y1(e)?`pending-ask`:e?.runtime===`perm-prompt`&&!J1(e)?`perm-prompt`:t?`working`:e?.providerError?i?null:`provider-error`:v$(e)?`snooze`:p$(e)?`resting`:n?`registered-done`:r?`rested`:null}function Z1(e,t){return X1(e)===`working`?y0(t):14}function Q1({state:e,slug:t,retryText:n,onTerminal:r,liveRuntimeStart:i,liveActivityLabel:a,liveToolRun:o}){let s=e.thread;switch(X1(e)){case`provider-fault`:return(0,L.jsx)(l2,{slug:t,sessionId:s.sessionId,fault:s.providerFault,retryText:n});case`provider-error`:return(0,L.jsx)(dJ,{error:s.providerError});case`limit-pause`:return(0,L.jsx)(u2,{slug:t,sessionId:s.sessionId,pause:s.limitPause});case`pending-ask`:return(0,L.jsx)(m2,{ask:Y1(s),onTerminal:r});case`perm-prompt`:return(0,L.jsx)(d2,{onTerminal:r});case`working`:return(0,L.jsx)(x2,{since:s?.lastUserAt,startedAt:i,activityLabel:a,run:o});case`snooze`:return(0,L.jsx)(b$,{thread:s});case`resting`:return(0,L.jsx)(g$,{thread:s});case`registered-done`:return(0,L.jsx)(c2,{fenceKind:`done`,body:s.lastFence.body,hints:[]});case`rested`:return(0,L.jsx)(lJ,{thread:s});default:return null}}function $1({slug:e,transcriptRef:t,transcriptKey:n,messages:r,paired:i,inFlightAnswers:a,answeringForMessage:o,thread:s,running:c,copyTerminalCommand:l,transportFallback:u,isFetching:d,refresh:f,retryLiveUpdates:p,hasEarlier:m,beforeCursor:h,loadingEarlier:g,earlierError:_,loadEarlier:v,jumpOverlay:y}){let b=AC(),x=(0,I.useMemo)(()=>e1(r),[r]),S=c?r1(x):void 0,C=c?n1(x):void 0,w=C?p1(C,b):void 0,T=c?a1(x):void 0,E=(0,I.useMemo)(()=>h0(r),[r]),D=(0,I.useMemo)(()=>c?_$(r):void 0,[c,r]),O=D&&D.index>=0?D.index:E,k=p$(s),A=(0,I.useMemo)(()=>{let e=c?c1(x):x;return L$(e,g0(e,O,k))},[x,c,O,k]),j=c,M=(0,I.useMemo)(()=>F$(A.map(e=>e.message),g0(A,O,k),p0).map(e=>{let t=A[e.messageIndex];return{...e,messageIndex:t.messageIndex,stampAt:o1(t)}}),[A,O,k]),N=(0,I.useMemo)(()=>IY(r),[r]),P=qq(s,E>=0?r[E]?.text:void 0),ee=cJ(s,E>=0?r[E]?.text:void 0),F=uJ(r,s?.providerError),te={thread:s,showWorking:j,registeredDone:P,restedCard:ee,errorVisible:F},ne=X1(te)!==null,re=(0,I.useMemo)(()=>Z1({thread:s,showWorking:j,registeredDone:P,restedCard:ee,errorVisible:F},A.map(e=>e.message)),[A,j,s,P,ee,F]),ie=(0,I.useMemo)(()=>{let e=[],t=new Map,n=r.length-1;for(let[i,a]of AJ(r,s?.questions??[],{atRest:!c})){if(i>=n){e.push(...a);continue}let r=-1;for(let e=0;e<M.length&&!(M[e].messageIndex>i);e++)r=e;let o=t.get(r);o?o.push(...a):t.set(r,[...a])}return{byRow:t,tail:e}},[M,r,c,s?.questions]),ae=(0,I.useMemo)(()=>NJ(r,s?.questions??[]),[r,s?.questions]),oe=(0,I.useMemo)(()=>{let e=[{key:`head-anchor`,kind:`head-anchor`}];u&&e.push({key:`transport-fallback`,kind:`transport-fallback`}),(m||g||_)&&e.push({key:`earlier-history:${h??`complete`}`,kind:`earlier-history`});let t=ie.byRow.get(-1);t&&e.push({key:`questions:head`,kind:`questions`,questions:t}),M.forEach((t,n)=>{e.push({...t,kind:`message`});let r=ie.byRow.get(n);r&&e.push({key:`questions:${t.key}`,kind:`questions`,questions:r})}),e.push({key:`interactions`,kind:`interactions`}),ne&&e.push({key:`runtime-status`,kind:`runtime-status`});let n=ne||M.length>0?14:0;return r.forEach((t,r)=>{if(!t.queued)return;let i=`queued:${t.deliveryId??t.sourceId??r}`;e.push({key:i,kind:`queued`,message:t,messageIndex:r,gap:n}),n=14}),e},[h,_,m,ne,g,M,r,ie,u]),se=jw({count:oe.length,getScrollElement:()=>t.current,getItemKey:e=>oe[e]?.key??e,estimateSize:e=>{let t=oe[e];return t?t.kind===`head-anchor`||t.kind===`interactions`?1:t.kind===`earlier-history`?42:t.kind===`transport-fallback`?76:t.kind===`runtime-status`?54:t.kind===`questions`?220:t.kind===`message`?108+t.gap:82+t.gap:80},overscan:8,paddingStart:20,paddingEnd:20,anchorTo:`end`,followOnAppend:!0,scrollEndThreshold:4,scrollToFn:(e,{adjustments:t,behavior:n},r)=>{let i=r.scrollElement;i&&i.scrollTo({top:t===void 0?e:i.scrollTop+t,behavior:n})}}),[ce,le]=(0,I.useState)(!0),ue=(0,I.useRef)(!0),de=(0,I.useRef)(-1),fe=(0,I.useRef)(0),pe=(0,I.useRef)(null),me=(0,I.useRef)(!1),he=(0,I.useRef)(!1),ge=(0,I.useRef)(!0),_e=(0,I.useRef)(null),ve=(0,I.useRef)(void 0),ye=(0,I.useRef)(null),be=(0,I.useRef)(void 0),xe=(0,I.useRef)(0),Se=(0,I.useCallback)(()=>{let e=t.current;if(e){let t=e.getBoundingClientRect().top,n=Array.from(e.querySelectorAll(`[data-transcript-source-id]`)).find(e=>e.getBoundingClientRect().bottom>t+1),r=n?.dataset.transcriptRowKey;n&&r&&(_e.current={rowKey:r,viewportTop:n.getBoundingClientRect().top-t})}v()},[v,t]),Ce=(0,I.useCallback)((e,n)=>{let r=t.current;if(!r)return;let i=Array.from(r.querySelectorAll(`[data-transcript-source-id]`)).find(t=>t.dataset.transcriptSourceId===e);i&&(r.scrollTop+=i.getBoundingClientRect().top-n)},[t]);(0,I.useLayoutEffect)(()=>{if(!n||oe.length===0||ve.current===n)return;ve.current=n,me.current=!1,he.current=!1,ge.current=!0;let t=ZE(e)?.candidates.map(e=>({candidate:e,index:oe.findIndex(t=>t.kind===`message`&&t.message.sourceId===e.sourceId)})).find(e=>e.index>=0),r=requestAnimationFrame(()=>{if(!t){se.scrollToEnd({behavior:`instant`}),le(!0),me.current=!0;return}se.scrollToIndex(t.index,{align:`start`,behavior:`instant`}),ue.current=!1,le(!1),me.current=!0;let e=performance.now()+K1;xe.current=e;let n=()=>{performance.now()>=e||performance.now()<fe.current||(Ce(t.candidate.sourceId,t.candidate.screenTop),r=requestAnimationFrame(n))};n()});return()=>cancelAnimationFrame(r)},[Ce,oe.length,e,n,se]),(0,I.useLayoutEffect)(()=>{let e=_e.current,n=t.current;if(!e||!n||g)return;let r=()=>{let t=Array.from(n.querySelectorAll(`[data-transcript-row-key]`)).find(t=>t.dataset.transcriptRowKey===e.rowKey);if(!t)return;let r=t.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTop+=r-e.viewportTop};r();let i=0,a=requestAnimationFrame(()=>{r(),i=requestAnimationFrame(()=>{r(),_e.current===e&&(_e.current=null)})});return()=>{cancelAnimationFrame(a),cancelAnimationFrame(i)}},[g,M.length,t]);let we=(0,I.useCallback)(()=>{let e=t.current;if(!e)return null;let n=e.getBoundingClientRect().top,r=Array.from(e.querySelectorAll(`[data-transcript-row-key]`)).find(e=>e.getBoundingClientRect().bottom>n+1),i=r?.dataset.transcriptRowKey;return!r||!i?null:{rowKey:i,viewportTop:r.getBoundingClientRect().top-n}},[t]),Te=(0,I.useCallback)(e=>{let n=t.current;if(!n)return;let r=Array.from(n.querySelectorAll(`[data-transcript-row-key]`)).find(t=>t.dataset.transcriptRowKey===e.rowKey);if(!r)return;let i=r.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTop+=i-e.viewportTop},[t]),Ee=M[0]?.key;(0,I.useLayoutEffect)(()=>{let e=be.current;if(be.current=Ee,e===void 0||e===Ee||!me.current||ue.current||_e.current)return;let t=ye.current;if(!t)return;Te(t);let n=()=>{if(performance.now()<fe.current)return;let e=ye.current;e&&Te(e)},r=0,i=requestAnimationFrame(()=>{n(),r=requestAnimationFrame(n)});return()=>{cancelAnimationFrame(i),cancelAnimationFrame(r)}},[Te,Ee]);let De=(0,I.useCallback)(()=>{let e=t.current;if(!e||_e.current||performance.now()<xe.current)return;let n=M$({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,previousScrollHeight:de.current,following:ue.current,readerMoved:performance.now()<fe.current});if(ue.current=n.following,n.scrollTop!==null&&(e.scrollTop=n.scrollTop),de.current=e.scrollHeight,le(e=>e===n.following?e:n.following),q1&&!n.following&&performance.now()>=fe.current){let t=ye.current,n=t&&Array.from(e.querySelectorAll(`[data-transcript-row-key]`)).find(e=>e.dataset.transcriptRowKey===t.rowKey);if(t&&n){let r=Math.round(n.getBoundingClientRect().top-e.getBoundingClientRect().top-t.viewportTop);Math.abs(r)>2&&console.warn(`[frizz] transcript moved ${r}px under a still reader — row=${t.rowKey}`)}}ye.current=we()??ye.current},[we,t]);(0,I.useLayoutEffect)(De),(0,I.useEffect)(()=>{let e=pe.current;if(!e)return;let t=new ResizeObserver(De);return t.observe(e),()=>t.disconnect()},[De]),(0,I.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{De();let t=N$({armed:ge.current,scrollTop:e.scrollTop,readerMoved:me.current&&he.current,hasEarlier:m,loading:g});ge.current=t.armed,t.shouldLoad&&Se()},r=()=>{he.current=!0,fe.current=performance.now()+G1,requestAnimationFrame(n)},i=t=>{[`ArrowUp`,`PageUp`,`Home`,` `].includes(t.key)&&(e.scrollTop<=480&&(ge.current=!0),r())},a=t=>{t.deltaY<0&&e.scrollTop<=480&&(ge.current=!0),r()},o=()=>{e.scrollTop<=480&&(ge.current=!0),r()};e.addEventListener(`scroll`,n,{passive:!0}),e.addEventListener(`wheel`,a,{passive:!0}),e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`pointerdown`,r,{passive:!0}),e.addEventListener(`keydown`,i);let s=requestAnimationFrame(n);return()=>{cancelAnimationFrame(s),e.removeEventListener(`scroll`,n),e.removeEventListener(`wheel`,a),e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,o),e.removeEventListener(`pointerdown`,r),e.removeEventListener(`keydown`,i)}},[m,g,Se,De,t]);let Oe=se.getVirtualItems(),ke=se.getTotalSize();return(0,L.jsxs)(`div`,{ref:pe,"data-virtualized-transcript":!0,"data-virtual-row-count":Oe.length,className:`relative w-full`,style:{height:ke},children:[Oe.map(t=>{let n=oe[t.index];return n?(0,L.jsx)(`div`,{ref:se.measureElement,"data-index":t.index,"data-transcript-row-key":n.key,"data-transcript-source-id":n.kind===`message`?n.message.sourceId:void 0,className:`absolute left-0 top-0 w-full hover:z-[1]`,style:{transform:`translateY(${t.start}px)`},children:n.kind===`head-anchor`?null:n.kind===`interactions`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(tQ,{thread:s,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(wQ,{thread:s,questions:ie.tail,inFlight:a,className:`px-6 pt-5`})]}):n.kind===`questions`?(0,L.jsx)(wQ,{thread:s,questions:n.questions,className:`px-6 pt-5`}):n.kind===`transport-fallback`?u?(0,L.jsx)(`div`,{className:`px-6 pt-3`,children:(0,L.jsxs)(`div`,{"data-transcript-sync-fallback":!0,className:`flex flex-wrap items-center gap-2.5 ${Yq} border border-border-strong bg-panel-2 px-4 py-2.5 text-[12px]`,title:u.kind===`payload-too-large`?`Live payload ${u.actualBytes} bytes; socket limit ${u.maxBytes} bytes`:`Transcript read budget reached (${u.scope}); retry after about ${u.retryAfterMs}ms`,children:[(0,L.jsx)(rh,{size:13,className:`shrink-0 text-muted`}),(0,L.jsxs)(`div`,{className:`min-w-[180px] flex-1 leading-snug text-fg/85`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Live transcript updates paused.`}),` `,u.kind===`payload-too-large`?`The transcript is too large for push; the last complete HTTP-loaded copy remains visible.`:`The live read budget was reached; the last complete copy remains visible. Retry in a moment.`]}),(0,L.jsx)(`button`,{type:`button`,disabled:d,onClick:f,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel disabled:opacity-40`,children:d?`Refreshing…`:`Refresh once`}),(0,L.jsx)(`button`,{type:`button`,onClick:p,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel`,children:`Retry live`})]})}):null:n.kind===`earlier-history`?(0,L.jsx)(`div`,{className:`flex min-h-10 items-center justify-center px-6 text-[11px] text-muted`,role:`status`,children:_?(0,L.jsxs)(`span`,{className:`flex flex-wrap items-center justify-center gap-2 text-center`,children:[(0,L.jsx)(`span`,{children:_}),(0,L.jsx)(`button`,{type:`button`,onClick:Se,className:`rounded-md border border-border px-2 py-1 text-fg/90 hover:bg-panel-2`,children:`Retry`})]}):g?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Mm,{size:12,className:`animate-spin`}),` Loading earlier messages…`]}):(0,L.jsx)(`button`,{type:`button`,onClick:Se,className:`rounded-md px-2 py-1 outline-none hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:`Load earlier messages`})}):n.kind===`message`?(0,L.jsx)(fZ,{at:n.stampAt,host:zY(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(t2,{m:n.message,answering:o(n.message),showSendButton:!0,paired:i[n.messageIndex],staleAwaiting:O>=0&&n.messageIndex<O,restingCardShown:n.messageIndex===E&&k,restedAt:D&&n.messageIndex===D.index?D.at??``:void 0,shadowedBy:ae.get(n.messageIndex),thread:s})}):n.kind===`runtime-status`?(0,L.jsxs)(`div`,{className:`px-6`,style:{paddingTop:re},children:[(0,L.jsx)(Q1,{state:te,slug:e,retryText:N>=0?r[N]?.text:void 0,onTerminal:l,liveRuntimeStart:T,liveActivityLabel:w,liveToolRun:S}),s?.permPolicy?(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(f2,{policy:s.permPolicy,denies:s.permDenies})}):null]}):(0,L.jsx)(fZ,{at:n.message.at,host:zY(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(t2,{m:n.message,paired:i[n.messageIndex]})})},n.key):null}),(0,L.jsx)(e0,{overlay:y,hidden:ce,onJump:()=>se.scrollToEnd({behavior:`smooth`})})]})}function e0({overlay:e,hidden:t,onJump:n}){return!e||t?null:(0,ot.createPortal)((0,L.jsxs)(`button`,{type:`button`,"data-jump-to-latest":!0,onClick:n,className:`flex items-center gap-1.5 rounded-full border border-border-strong bg-elevated px-3 py-1.5 text-[11px] font-medium text-fg shadow-lg shadow-black/30 hover:bg-panel-2`,children:[(0,L.jsx)(qp,{size:12}),`Jump to latest`]}),e)}function t0({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1}){let i=Dp(kC(),e),a=it({mutationFn:()=>Y.markComplete({slug:e})}),o=it({mutationFn:t=>Y.renameThread({slug:e,title:t})}),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(``),d=(0,I.useRef)(null);(0,I.useEffect)(()=>{if(!s)return;let e=requestAnimationFrame(()=>{d.current?.focus(),d.current?.select()});return()=>cancelAnimationFrame(e)},[s]),(0,I.useEffect)(()=>{c(!1),u(``)},[e]);let f=rK(nt({queryKey:[`threadBody`,e],queryFn:()=>Y.threadBody({slug:e})}).data?.markdown??``).trim().length>0;if(!i)return null;let p=i.kind===`session`&&i.foreign!==!0,m=i.foreign===!0,h=i.kind===`session`&&!m,g=aT(i);function _(){c(!1),u(``)}function v(){let e=UY(l,g);if(c(!1),!e){u(``);return}o.mutate(e,{onSuccess:()=>{u(``),Z(`Thread renamed`)},onError:t=>{u(e),c(!0),Z(t instanceof Error?t.message:`Could not rename thread`)}})}return(0,L.jsxs)(`header`,{"data-thread-header":!0,className:KY,children:[(0,L.jsx)(`div`,{className:qY,children:(0,L.jsxs)(`div`,{className:`min-w-0 leading-tight`,children:[(0,L.jsxs)(`div`,{className:`group/thread-title flex min-w-0 items-center gap-2`,children:[s?(0,L.jsx)(`input`,{ref:d,"aria-label":`Thread title`,value:l,maxLength:200,onChange:e=>u(e.target.value),onBlur:v,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),v()):e.key===`Escape`&&(e.preventDefault(),_())},className:`min-w-0 flex-1 rounded-md border border-border bg-elevated px-1.5 py-1 font-semibold text-[15px] text-fg outline-none focus:border-accent`}):h?(0,L.jsx)(`button`,{type:`button`,title:`Edit title`,"aria-label":`Edit thread title: ${g}`,disabled:o.isPending,onClick:()=>{u(WY(g,i.id)),c(!0)},className:`min-w-0 max-w-full shrink truncate rounded px-0.5 -mx-0.5 font-semibold text-[15px] text-left outline-none transition-colors hover:bg-panel-2 focus-visible:ring-1 focus-visible:ring-fg/60 disabled:cursor-not-allowed disabled:opacity-40`,children:g}):(0,L.jsx)(`div`,{className:`min-w-0 max-w-full shrink truncate px-0.5 -mx-0.5 font-semibold text-[15px]`,title:g,children:g}),(0,L.jsx)(eZ,{thread:i,hidden:s})]}),(0,L.jsx)(x$,{at:gT(i),fallbackAt:i.spawnedAt,className:`mt-0.5 block truncate text-[11px] leading-tight text-muted/75`})]})}),(0,L.jsxs)(`div`,{className:JY,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[p&&(0,L.jsx)(j$,{slug:e}),(0,L.jsx)(yX,{thread:i,collapse:r,onDoc:f?()=>$f(`doc`,i.id):void 0,onDone:()=>a.mutate(void 0,{onSuccess:t}),doneBusy:a.isPending,onStatusApplied:t}),n&&(0,L.jsx)(zj,{slug:e})]}),n&&(0,L.jsx)(`button`,{type:`button`,"aria-label":`Close`,"data-dialog-initial-focus":!0,onClick:n,className:`ml-0.5 shrink-0 rounded-md p-1.5 text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg`,children:(0,L.jsx)(ah,{size:15})})]})]})}function n0(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||aZ(e))return null;if(e.parts&&e.parts.length>0){for(let t=e.parts.length-1;t>=0;t--){let n=e.parts[t];if(n.kind===`tools`?n.tools.length>0:n.text.trim())return n.kind===`tools`?n.tools:null}return null}return(e.tools?.length??0)>0&&!e.text.trim()?e.tools:null}function r0(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||aZ(e))return null;if(e.parts&&e.parts.length>0){for(let t of e.parts)if(t.kind===`tools`?t.tools.length>0:t.text.trim())return t.kind===`tools`?t.tools:null;return null}return(e.tools?.length??0)>0?e.tools:null}function i0(e){return n0(e)!==null}function a0(e){return r0(e)!==null}function o0(e){return e.kind===`event`&&!e.boundary||e.kind===`reasoning`}function s0(e){return o0(e)||i0(e)}function c0(e){return o0(e)||a0(e)}function l0(e){if(o0(e))return!0;let t=n0(e);return t!==null&&!H$(t[t.length-1])}function u0(e){if(o0(e))return!0;let t=r0(e);return t!==null&&!H$(t[0])}function d0(e){let t=n0(e);return t!==null&&W$(t[t.length-1])}function f0(e){let t=r0(e);return t!==null&&W$(t[0])}function p0(e,t){let n=d0(e)||f0(t),r=!n&&s0(e)&&c0(t)&&!(l0(e)&&u0(t));return(n?22:r?6:14)+(e.role===`user`&&t.role!==`user`?3:0)}function m0(e,t){return e.kind===`event`||e.kind===`reasoning`||e.role===`user`?!1:e.parts&&e.parts.length>0?e.parts.every(n=>n.kind===`tools`?n.tools.length===0:_0(e,n.text,t)):(e.tools?.length??0)===0&&_0(e,e.text,t)}function h0(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`&&e[t].kind!==`event`)return t;return-1}function g0(e,t,n=!1){let r=new WeakSet;if(t>=0)for(let n of e)n.messageIndex<t&&r.add(n.message);if(t>=0&&n)for(let n of e)n.messageIndex===t&&r.add(n.message);return e=>m0(e,r.has(e))}function _0(e,t,n){return!e.fenceRefused&&!n?!t.trim():Kq(t).every(e=>e.kind===`fence`&&e.fenceKind===`awaiting`)}function v0(e,t){return e.kind===`event`||e.kind===`reasoning`||e.role===`user`?!1:e.parts&&e.parts.length>0?e.parts.some(n=>n.kind===`text`&&!_0(e,n.text,t)):typeof e.text==`string`&&!_0(e,e.text,t)}function y0(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.queued||m0(n)))return d0(n)?22:s0(n)&&!l0(n)?6:14+(n.role===`user`?3:0)}return 0}function b0(e,t,n){let r=[],i=null;return e.forEach((e,a)=>{n?.(e,a)||m0(e)||(i!==null&&r.push((0,L.jsx)(BJ,{h:p0(i,e)},`s${a}`)),r.push(t(e,a)),i=e)}),r}function x0(e){let t=[];for(let n of e){if(n.kind===`text`){if(!n.text.trim())continue;t.push(n);continue}if(n.tools.length===0)continue;let e=t[t.length-1];e&&e.kind===`tools`?t[t.length-1]={kind:`tools`,tools:[...e.tools,...n.tools]}:t.push(n)}return t}function S0(e,t=14){let n=e.filter(e=>e!=null&&e!==!1),r=[];return n.forEach((e,n)=>{n>0&&r.push((0,L.jsx)(BJ,{h:typeof t==`number`?t:t(n)},`vs${n}`)),r.push(e)}),r}var C0={head:!1,tail:!1};function w0(e,t){return n=>e[n-1]?.tail||e[n]?.head?22:t}function T0(e){return{head:W$(e[0]),tail:W$(e[e.length-1])}}function E0(e){let t=[];for(let n of e){let e=t[t.length-1];if(n.edit){let r=!!(n.input||n.output||n.status||n.exitCode!==void 0);e&&e.edits&&!r&&!e.input&&!e.output&&!e.status&&e.edits[0].file===n.edit.file?e.edits.push(n.edit):t.push({name:n.name,detail:n.detail,edits:[n.edit],input:n.input,output:n.output,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1})}else n.command?t.push({name:n.name,detail:n.detail,command:n.command,desc:n.desc,input:n.input,output:n.output,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1}):n.outputImage?t.push({name:n.name,detail:n.detail,outputImage:n.outputImage,output:n.output??n.read,status:n.status,durationMs:n.durationMs,count:1}):n.read?t.push({name:n.name,detail:n.detail,read:n.read,status:n.status,durationMs:n.durationMs,count:1}):n.prompt||n.agentId?t.push({name:n.name,detail:n.detail,prompt:n.prompt,input:n.input,subagentType:n.subagentType,agentId:n.agentId,agentStatus:n.agentStatus,agentElapsedMs:n.agentElapsedMs,output:n.output,status:n.status,durationMs:n.durationMs,count:1}):n.sendTo!==void 0||n.sendBody!==void 0?t.push({name:n.name,detail:n.detail,sendTo:n.sendTo,sendSummary:n.sendSummary,sendBody:n.sendBody,sendType:n.sendType,sendDispatchId:n.sendDispatchId,sendTargetLabel:n.sendTargetLabel,status:n.status,durationMs:n.durationMs,count:1}):n.todos?t.push({name:n.name,detail:n.detail,todos:n.todos,input:n.input,status:n.status,durationMs:n.durationMs,count:1}):U$(n)?t.push({name:n.name,detail:n.detail,ask:n.ask,askAnswers:n.askAnswers,status:n.status,durationMs:n.durationMs,count:1}):n.sentImages||n.sentFiles?t.push({name:n.name,detail:n.detail,sentImages:n.sentImages,sentFiles:n.sentFiles,caption:n.caption,status:n.status,durationMs:n.durationMs,count:1}):n.input||n.output?t.push({name:n.name,detail:n.detail,input:n.input,output:n.output,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1}):e&&!e.edits&&!e.command&&!e.input&&!e.output&&!e.read&&!e.prompt&&!e.outputImage&&!e.sentImages&&!e.sentFiles&&e.sendTo===void 0&&e.sendBody===void 0&&e.name===n.name&&e.detail===n.detail&&e.status===n.status&&e.backgroundState===n.backgroundState&&e.exitCode===n.exitCode&&e.cwd===n.cwd&&e.sessionId===n.sessionId&&e.durationMs===n.durationMs?e.count++:t.push({name:n.name,detail:n.detail,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1})}return t}function D0(e){return e.split(`__`).pop()||e}function O0(e){let t=X.board?.projectDir;return t&&e.startsWith(t+`/`)?e.slice(t.length+1):e}function k0({tools:e,at:t}){let[n,r]=(0,I.useState)(!1),i=(0,I.useId)(),a=e.reduce((e,t)=>e+t.count,0),o=_1(a,g1(e));return(0,L.jsxs)(`div`,{"data-tool-activity":!0,"data-tool-activity-state":`settled`,className:`flex min-w-0 flex-col`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":i,"aria-expanded":n,"aria-label":`${n?`Collapse`:`Expand`} ${a} tool ${a===1?`call`:`calls`}: ${o}`,className:`group flex w-full min-w-0 items-baseline gap-1.5 rounded py-0.5 text-left outline-none transition-colors hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60 ${pZ}`,children:[(0,L.jsx)(`span`,{"data-tool-activity-label":!0,title:o,className:`min-w-0 truncate text-muted`,children:o}),(0,L.jsx)(tm,{"data-tool-activity-chevron":!0,"aria-hidden":`true`,size:13,className:hZ(n)})]}),n&&(0,L.jsx)(`div`,{id:i,className:`mt-1.5 flex flex-col`,children:S0(e.map((e,n)=>(0,L.jsx)(j0,{t:e,startedAt:t},n)),6)}),!n&&(0,L.jsx)(`div`,{id:i,hidden:!0})]})}function A0({tools:e,at:t}){let n=[];for(let t of e){let e=H$(t),r=n[n.length-1];r?.exceptional===e?r.tools.push(t):n.push({exceptional:e,tools:[t]})}return(0,L.jsx)(`div`,{className:`flex flex-col`,children:S0(n.map((e,n)=>e.exceptional?(0,L.jsx)(`div`,{className:`flex flex-col`,children:S0(e.tools.map((e,n)=>(0,L.jsx)(j0,{t:e,startedAt:t},n)),w0(e.tools.map(e=>T0([e])),6))},`exceptions-${n}`):(0,L.jsx)(k0,{tools:e.tools,at:t},`activity-${n}`)),w0(n.map(e=>T0(e.tools)),6))})}function j0({t:e,startedAt:t}){let n=(0,I.useContext)(I1),r=kC(),i=hE(e,(n?Dp(r,n):void 0)?.bgShells??[]);return e.edits&&e.status!==`failed`&&e.status!==`cancelled`?(0,L.jsx)($K,{edits:e.edits,meta:(0,L.jsx)(I0,{status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,durationMs:e.durationMs})}):e.command?(0,L.jsx)(W0,{command:e.command,desc:e.desc??e.detail,output:e.output,status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,sessionId:e.sessionId,durationMs:e.durationMs,startedAt:t}):e.outputImage?(0,L.jsx)(V0,{name:e.name,detail:e.detail,outputImage:e.outputImage,output:e.output,status:e.status,durationMs:e.durationMs}):e.read?(0,L.jsx)(K0,{detail:e.detail,read:e.read,status:e.status,durationMs:e.durationMs}):e.prompt||e.agentId?(0,L.jsx)(J0,{detail:e.detail,prompt:e.prompt,input:e.input,subagentType:e.subagentType,agentId:e.agentId,agentStatus:e.agentStatus,agentElapsedMs:e.agentElapsedMs,status:e.status,durationMs:e.durationMs,output:e.output}):e.sendTo!==void 0||e.sendBody!==void 0?(0,L.jsx)(X0,{to:e.sendTo,summary:e.sendSummary,body:e.sendBody??``,type:e.sendType,dispatchId:e.sendDispatchId,targetLabel:e.sendTargetLabel,status:e.status,durationMs:e.durationMs,at:t}):e.sentImages||e.sentFiles?(0,L.jsx)(H0,{images:e.sentImages??[],files:e.sentFiles??[],caption:e.caption,status:e.status,durationMs:e.durationMs}):e.todos?(0,L.jsx)(Sq,{todos:e.todos,note:e.input,meta:(0,L.jsx)(I0,{status:e.status,durationMs:e.durationMs})}):U$(e)?(0,L.jsx)(M0,{ask:e.ask??[],askAnswers:e.askAnswers}):e.input||e.output?(0,L.jsx)(W0,{name:e.name,command:e.input??``,desc:e.detail,output:e.output,status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,sessionId:e.sessionId,durationMs:e.durationMs,inputLabel:`input`,startedAt:t}):(0,L.jsx)(B0,{name:e.name,detail:e.detail,count:e.count,status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,cwd:e.cwd,sessionId:e.sessionId,durationMs:e.durationMs,startedAt:t})}function M0({ask:e,askAnswers:t}){return(0,L.jsx)(`div`,{"data-settled-ask":!0,className:`flex flex-col gap-1.5`,children:e.map((e,n)=>{let r=ZZ(e,t?.[n]);return(0,L.jsx)(CY,{question:r.question,settled:{chosenIdxs:r.chosenIdxs,text:r.text}},n)})})}function N0({tone:e,indicator:t,label:n,duration:r,title:i}){return(0,L.jsxs)(`span`,{className:`petite-caps frizz-tool-header-caps flex shrink-0 items-center gap-1 whitespace-nowrap text-[11.5px] leading-none ${e}`,title:i,"aria-label":i,children:[t,(0,L.jsx)(`span`,{children:[n,r].filter(Boolean).join(` · `)})]})}function P0(e,t,n){let[r,i]=(0,I.useState)(()=>Date.now()),a=fE(e,t),o=pE(e,t,n,r);return(0,I.useEffect)(()=>{if(!a||o)return;let e=n?Date.parse(n):NaN;if(!Number.isFinite(e))return;let t=setTimeout(()=>i(Date.now()),Math.max(dE-(Date.now()-e),0));return()=>clearTimeout(t)},[a,o,n]),o}function F0({status:e,backgroundState:t,liveBackgroundState:n,startedAt:r}){let i=P0(e,t,r),a=n===`running`?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--shell`,"data-running-indicator":`tool-disclosure`}):n===`stale`?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot-quiet frizz-live-dot-quiet--shell`,"data-running-indicator":`tool-quiet`,title:jE}):uE(e,t)||i?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--shell`,"data-running-indicator":`tool-disclosure`}):null;return a?(0,L.jsx)(`span`,{className:`frizz-tool-mark -mr-1 flex w-[9px] shrink-0 justify-center`,children:a}):null}function I0({status:e,backgroundState:t,liveBackgroundState:n,exitCode:r,durationMs:i}){if(!e&&i===void 0)return null;let[a,o]=n===`running`?[`running`,`background running`]:n===`stale`?[`stale`,`background stale`]:e===`pending`?t===`unknown`?[`unknown`,`background / unknown`]:[`running`,t===`background`?`background running`:`running`]:e===`failed`?r===void 0?[`failed`,`failed`]:[`exit ${r}`,`exit ${r}`]:e===`cancelled`?[`cancelled`,`cancelled`]:e===`completed`?[`done`,`done`]:[void 0,void 0],s=i===void 0?void 0:gE(i),c=[o,s].filter(Boolean).join(` · `);return(0,L.jsx)(N0,{tone:e===`failed`?`frizz-tool-failed`:e===`cancelled`?`text-amber-400`:`text-muted/55`,title:c,label:a,duration:s})}function L0(e,t,n){let r=t?Date.parse(t):NaN,i=e===`pending`&&Number.isFinite(r),[a,o]=(0,I.useState)(()=>Date.now());return(0,I.useEffect)(()=>{if(!i)return;let e=()=>o(Date.now()),t,n=setTimeout(()=>{e(),t=setInterval(e,1e3)},1e3-Date.now()%1e3);return()=>{clearTimeout(n),t&&clearInterval(t)}},[i,t]),i?Math.max(a-r,0):n}function R0(e,t,n){let r=t&&t!==X.board?.projectDir?`in ${O0(t)}`:void 0;return[e,t?r:n!==void 0&&!e?.includes(String(n))?`session ${n}`:void 0].filter(Boolean).join(` · `)||void 0}function z0(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.includes(`…`)}function B0({name:e,detail:t,count:n,status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,cwd:s,sessionId:c,durationMs:l,startedAt:u}){let d=R0(t,s,c),f=d?O0(d):void 0,p=t&&z0(t)?t:void 0;return(0,L.jsx)(`div`,{className:`frizz-bash`,title:d,children:(0,L.jsxs)(`div`,{className:`frizz-bash-header`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(F0,{status:r,backgroundState:i,liveBackgroundState:a,startedAt:u}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:D0(e)}),f&&(p?(0,L.jsx)(`span`,{className:`min-w-0 truncate`,onClick:e=>e.stopPropagation(),children:(0,L.jsx)(ZK,{path:p,className:`text-[11.5px] text-muted`,children:f})}):(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:f}))]}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,L.jsx)(I0,{status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,durationMs:l}),n>1&&(0,L.jsxs)(`span`,{className:`tabular-nums text-[11px] text-muted/45`,children:[`×`,n]})]})]})})}function V0({name:e,detail:t,outputImage:n,output:r,status:i,durationMs:a}){let o=t?O0(t):void 0,s=(0,L.jsxs)(`div`,{className:`frizz-bash-header`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:D0(e)}),o&&(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,title:t,children:o})]}),(0,L.jsx)(`span`,{className:`flex shrink-0 items-center gap-2`,children:(0,L.jsx)(I0,{status:i,durationMs:a})})]});return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(r2,{path:n,hideCaption:!0,altText:o?`${D0(e)}: ${o}`:D0(e),header:s}),r&&(0,L.jsx)(`pre`,{className:`frizz-bash frizz-bash-body frizz-bash-output-body mt-1.5`,children:r})]})}function H0({images:e,files:t,caption:n,status:r,durationMs:i}){let[a,o]=(0,I.useState)(!0),s=(0,I.useId)(),c=[e.length?`${e.length} image${e.length===1?``:`s`}`:``,t.length?`${t.length} file${t.length===1?``:`s`}`:``].filter(Boolean).join(` · `);return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":s,"aria-expanded":a,"aria-label":`${a?`Collapse`:`Expand`} files sent to you${c?`: ${c}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/60`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Sent to you`}),c&&(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:c})]}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,L.jsx)(I0,{status:r,durationMs:i}),(0,L.jsx)(tm,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${a?`rotate-90`:``}`})]})]}),(0,L.jsx)(`div`,{id:s,hidden:!a,children:a&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-2.5 pb-2.5 pt-1.5`,children:[e.map((e,t)=>(0,L.jsx)(r2,{path:e,hideCaption:!0,altText:n??`delivered image`},`i${t}`)),t.length>0&&(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map((e,t)=>(0,L.jsx)(i2,{path:e},`f${t}`))}),n&&(0,L.jsx)(`div`,{className:`max-w-[65%] text-[12px] leading-snug text-muted`,children:n})]})})]})}var U0=16;function W0({command:e,desc:t,output:n,name:r=`Bash`,status:i,backgroundState:a,liveBackgroundState:o,exitCode:s,sessionId:c,durationMs:l,inputLabel:u,startedAt:d}){let[f,p]=(0,I.useState)(!1),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(!1),v=(0,I.useId)(),y=L0(i,d,l),b=(0,I.useMemo)(()=>e.split(`
313
+ `)||void 0;return{line:`${pQ(e)} ${t.label}${r?` — ${r}`:``}`,...i?{body:i}:{}}}var hQ=`root`;function gQ(e,t,n){return`${e}/${t}.${n}`}function _Q(e){let t=e.options??[],n=t.findIndex(e=>e.recommended),r=t.map((e,t)=>mQ(t,e));return{question:{kind:e.kind,danger:e.danger===!0,contextMd:e.question,options:r.map(e=>e.line),recommendedIdx:n===-1?null:n,...r.some(e=>e.body)?{optionBodies:r.map(e=>e.body)}:{}},optionLabels:t.map(e=>e.label)}}function vQ(e,t){return!t||e.kind===`multi`?null:t.chosen}function yQ(e,t){let n=[],r=(e,i,a)=>{let{question:o,optionLabels:s}=_Q(e);n.push({path:i,spec:e,question:o,optionLabels:s,depth:a});let c=vQ(e,t.get(i));c!==null&&(e.options?.[c]?.followUps??[]).forEach((e,t)=>r(e,gQ(i,c,t),a+1))};return r(e,hQ,1),n}function bQ(e,t){return t?t.text.trim()?!0:e.kind===`multi`?(t.chosenSet??[]).length>0:t.chosen!==null:!1}function xQ(e,t){if(!bQ(e.spec,t.get(`root`)))return;let n=(r,i)=>{let a=t.get(i),o=(r.options??[]).map(e=>e.label),s=vQ(r,a),c=r.kind===`multi`?(a?.chosenSet??[]).slice().sort((e,t)=>e-t).flatMap(e=>o[e]===void 0?[]:[o[e]]):s===null?[]:[o[s]].filter(e=>e!==void 0),l=r.kind===`multi`||s===null?a?.text.trim():void 0,u=s===null?[]:(r.options?.[s]?.followUps??[]).map((e,t)=>n(e,gQ(i,s,t)));return{questionId:e.id,question:r.question,chosen:c,...l?{text:l}:{},...u.length>0?{followUps:u}:{}}};return n(e.spec,hQ)}function SQ(e){let t=e instanceof Error?e.message:`The answer could not be sent.`;return t.length>240?`${t.slice(0,239)}…`:t}var CQ=(e,t)=>`${e}|${t}`;function wQ({thread:e,questions:t,inFlight:n=null,className:r=``}){let i=e?.id,a=t??e?.questions??[],o=cz(),[s,c]=(0,I.useState)(()=>new Map),[l,u]=(0,I.useState)(),d=(0,I.useContext)(z1),f=dz((0,I.useMemo)(()=>i?a.flatMap(e=>TQ(e).map(t=>sz.question(o,i,e.id,t))):[],[o,i,a])),p=(e,t)=>{let n=s.get(CQ(e.id,t));return{chosen:n?.chosen??null,chosenSet:n?.chosenSet??[],text:(i?f.get(sz.question(o,i,e.id,t)):void 0)??``}},m=e=>new Map(TQ(e).map(t=>[t,p(e,t)])),h=a.flatMap(e=>{let t=xQ(e,m(e));return t?[t]:[]}),g=it({mutationFn:async e=>Y.answerQuestions({slug:i,answers:e}),onSuccess:e=>{for(let t of e.answered){c(e=>{let n=new Map(e);for(let e of[...n.keys()])e.startsWith(`${t}|`)&&n.delete(e);return n});let e=a.find(e=>e.id===t);if(e&&i)for(let t of TQ(e))az.set(sz.question(o,i,e.id,t),``)}},onError:e=>{d?.cancel(),u(SQ(e))}}),_=it({mutationFn:async e=>Y.dismissQuestions({slug:i,ids:[e]}),onError:e=>u(SQ(e))});if(!i||a.length===0)return!i||!n?.length?null:(0,L.jsx)(`section`,{"data-answers-in-flight":!0,"aria-label":`Your answer, on its way to the worker`,className:`flex min-w-0 flex-col items-end ${r}`,children:(0,L.jsx)(dY,{answers:n,queued:!0})});let v=()=>{h.length===0||g.isPending||(u(void 0),d?.dismiss(),g.mutate(h))};return(0,L.jsxs)(`section`,{"data-registered-questions":!0,"aria-label":`${a.length} question${a.length===1?``:`s`} waiting for an answer`,className:`flex min-w-0 flex-col gap-3 ${r}`,children:[a.map(e=>(0,L.jsx)(`article`,{"data-question-id":e.id,className:`flex min-w-0 flex-col gap-2`,children:(()=>{let t=yQ(e.spec,m(e)),n=t=>(0,L.jsx)(CY,{question:t.question,label:t.depth>1?`Follow-up`:void 0,aside:t.depth===1&&!e.spec.danger?(0,L.jsx)(`button`,{type:`button`,"data-dismiss-question":!0,"aria-label":`Dismiss this question`,title:`Dismiss — the worker decides it itself`,disabled:_.isPending,onClick:()=>_.mutate(e.id),className:`card-icon-offset -mx-2 -my-1 flex rounded-md p-1 text-muted/70 outline-none transition-colors hover:bg-elevated hover:text-fg disabled:opacity-40`,children:(0,L.jsx)(ah,{size:16})}):void 0,interactive:{answer:p(e,t.path),onChip:n=>{c(r=>{let i=new Map(r),a=CQ(e.id,t.path),o=i.get(a)??{chosen:null,chosenSet:[]};if(t.spec.kind===`multi`){let e=o.chosenSet.includes(n)?o.chosenSet.filter(e=>e!==n):[...o.chosenSet,n];i.set(a,{...o,chosenSet:e})}else i.set(a,{...o,chosen:o.chosen===n?null:n});return i})},onText:n=>{az.set(sz.question(o,i,e.id,t.path),n),t.spec.kind!==`multi`&&c(n=>{let r=CQ(e.id,t.path),i=n.get(r);return!i||i.chosen===null?n:new Map(n).set(r,{...i,chosen:null})})},onSubmit:v}},t.path),r=t.slice(1);return(0,L.jsxs)(L.Fragment,{children:[n(t[0]),r.length>0&&(0,L.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:r.map(e=>(0,L.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:n(e)},e.path))})]})})()},e.id)),l&&(0,L.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-red-300`,children:l}),g.isPending&&(0,L.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[11px] leading-snug text-muted`,children:`Sending…`}),(0,L.jsx)(`div`,{className:`flex justify-start`,children:(0,L.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:h.length===0||g.isPending,onClick:v,onMouseDown:e=>e.preventDefault(),className:`rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:`Send answers`})})]})}function TQ(e){let t=[],n=(e,r)=>{t.push(r),e.options?.forEach((e,t)=>{e.followUps?.forEach((e,i)=>n(e,`${r}/${t}.${i}`))})};return n(e.spec,hQ),t}function EQ(e){return(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).length}function DQ(e,t={}){let n=(e.subAgents??[]).filter(e=>Xc(e)&&e.state===`running`).length,r=(e.bgShells??[]).filter(e=>e.state===`running`).length,i=t.watchers===!1?0:EQ(e),a=[n>0?`${n} sub-agent${n===1?``:`s`}`:null,r>0?`${r} background shell${r===1?``:`s`}`:null,i>0?`${i} PR watcher${i===1?``:`s`}`:null].filter(e=>e!==null);return a.length===0?`0 background shells`:a.length===1?a[0]:`${a.slice(0,-1).join(`, `)} and ${a[a.length-1]}`}function OQ(e){return(e.subAgents??[]).some(e=>Xc(e)&&e.state===`running`)}function kQ(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length}function AQ(e){return OQ(e)||kQ(e)>0}function jQ(e,t){return ul(t)??(MQ(e)?`Background shells running`:`Awaiting`)}function MQ(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length>0&&!OQ(e)&&EQ(e)===0&&NQ(e).length===0}function NQ(e){return(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`)}var PQ={id:``,subAgents:[],bgShells:[],watches:[]},FQ=[];function IQ(e,t){let n=new Set((e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).map(e=>e.target));return kH(t).filter(e=>!n.has(e.ref))}function LQ({watch:e}){return(0,I.useEffect)(()=>{e.url&&Of([e.ref])},[e.url,e.ref]),e.url?(0,L.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-gh-ref":e.ref,className:`${oJ} text-[12px]`,children:e.ref}):(0,L.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.ref})}var RQ={mergeable:`no conflicts`,blocked:`merge blocked`,conflicting:`has conflicts`,unknown:null};function zQ(e){return e.state!==`open`||e.merge===`blocked`&&e.checks!==`passing`&&e.checks!==`none`?null:RQ[e.merge]}var BQ=`shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`;function VQ({tone:e}){return(0,L.jsx)(`span`,{"aria-hidden":!0,className:`inline-block size-3 rounded-full border ${e} border-t-transparent motion-safe:animate-spin ${BQ}`})}function HQ(){return(0,L.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 16 16`,width:12,height:12,fill:`none`,stroke:`currentColor`,overflow:`visible`,className:BQ,style:{color:TE.fgAttention},children:[(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:`4`,fill:`currentColor`,stroke:`none`}),(0,L.jsxs)(`g`,{strokeWidth:`2`,className:`origin-center motion-safe:animate-spin`,children:[(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:`7`,opacity:`0.25`}),(0,L.jsx)(`path`,{d:`M15 8A7 7 0 0 1 8 15`})]})]})}function UQ({status:e}){return e?e.state===`merged`?(0,L.jsx)(bm,{size:12,className:BQ,style:{color:TE.fgDone}}):e.state===`closed`?(0,L.jsx)(xm,{size:12,className:BQ,style:{color:TE.fgDanger}}):e.checks===`failing`?(0,L.jsx)(um,{size:12,className:BQ,style:{color:TE.fgDanger}}):e.checks===`passing`?(0,L.jsx)(am,{size:12,className:BQ,style:{color:TE.fgSuccess}}):e.gated>0&&e.running===0?(0,L.jsx)(im,{size:12,className:BQ,style:{color:TE.fgAttention}}):e.checks===`running`?(0,L.jsx)(HQ,{}):(0,L.jsx)(om,{size:12,className:`${BQ} text-muted/60`}):(0,L.jsx)(om,{size:12,className:`${BQ} text-muted/60`})}function WQ(e){return[e.failed>0?`${e.failed} failing`:null,e.gated>0?`${e.gated} awaiting approval`:null,e.running>0?`${e.running} in progress`:null,e.passed>0?`${e.passed} successful`:null,e.skipped>0?`${e.skipped} skipped`:null].filter(e=>e!==null).join(`, `)}function GQ(e){if(!e)return`Checking…`;if(e.state===`merged`)return`Merged`;if(e.state===`closed`)return`Closed`;let t=WQ(e),n=zQ(e);return[t||`No checks`,n].filter(e=>e!==null).join(` · `)}var KQ=`group relative col-span-4 grid grid-cols-subgrid items-baseline rounded-sm text-[12px] leading-5`,qQ=`group relative col-span-4 flex items-baseline rounded-sm text-[12px] leading-5`,JQ=`ml-1.5 min-w-0 truncate font-medium text-fg/90`,YQ=`ml-3 min-w-0 truncate text-right text-muted/70`,XQ=`outline-none after:absolute after:inset-0 after:rounded-sm focus-visible:after:ring-1 focus-visible:after:ring-fg/60`;function ZQ(){return(0,L.jsx)(tm,{size:13,"aria-hidden":!0,className:`${BQ} ml-[3px] -mr-[4px] text-muted/35 transition-colors group-hover:text-muted/70`})}function QQ({mark:e,name:t,status:n,onOpen:r,onPrewarm:i,href:a,ghRef:o,title:s,testKind:c,testId:l,indent:u}){let d=u!==void 0,f=d?`${JQ} flex-1`:JQ,p=a?(0,L.jsx)(`a`,{href:a,target:`_blank`,rel:`noreferrer noopener`,title:s,"data-gh-ref":o,onMouseDown:e=>e.stopPropagation(),className:`${f} ${XQ} group-hover:underline group-hover:decoration-fg/40 group-hover:underline-offset-2`,children:t}):r?(0,L.jsx)(`button`,{type:`button`,onClick:r,onMouseDown:e=>e.stopPropagation(),title:s,className:`${f} ${XQ} text-left group-hover:underline group-hover:decoration-fg/40 group-hover:underline-offset-2`,children:t}):(0,L.jsx)(`span`,{className:f,title:s,children:t}),m=!!(a||r);return(0,L.jsxs)(`div`,{"data-wait-row":l,"data-wait-kind":c,onMouseEnter:i,onFocus:i,style:d?{paddingLeft:u}:void 0,className:`${d?qQ:KQ} ${m?`cursor-pointer transition-colors hover:bg-fg/[0.045]`:``}`,children:[(0,L.jsx)(`span`,{className:`flex shrink-0`,children:e}),p,(0,L.jsx)(`span`,{"data-wait-status":!0,className:YQ,children:n}),m?(0,L.jsx)(ZQ,{}):(0,L.jsx)(`span`,{})]})}function $Q({watch:e}){let t=e.github,n=DH(e.target);return(0,I.useEffect)(()=>{n&&Of([e.target])},[n,e.target]),(0,L.jsx)(QQ,{testKind:`github`,testId:e.target,mark:(0,L.jsx)(UQ,{status:t}),name:e.target,href:n??void 0,ghRef:n?e.target:void 0,title:n?`Open ${e.target} on GitHub`:e.target,status:(0,L.jsxs)(L.Fragment,{children:[GQ(t),t&&t.failing.length>0&&n&&(0,L.jsxs)(L.Fragment,{children:[` · `,(0,L.jsx)(`a`,{href:`${n}/checks`,target:`_blank`,rel:`noreferrer noopener`,onMouseDown:e=>e.stopPropagation(),className:`relative underline underline-offset-2 text-[#f85149]/85 decoration-[#f85149]/30 hover:decoration-[#f85149]`,children:`view failures`})]})]})})}function e$(e,t){return(e.bgShells??[]).find(e=>e.id===t||e.taskId===t||e.label===t)}function t$(e){return(e.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`)}function n$({watch:e,thread:t,slug:n,now:r}){let i=e$(t,e.target);if(i)return(0,L.jsx)(r$,{shell:i,slug:n,now:r,testId:e.target});let a=bE(e.createdAt,r);return(0,L.jsx)(QQ,{testKind:`shell`,testId:e.target,mark:(0,L.jsx)(eh,{size:12,className:`${BQ} text-shell`}),name:e.target,title:e.target,status:a?`running · ${a}`:`running`})}function r$({shell:e,slug:t,now:n,testId:r}){let i=bE(e.startedAt,n),a=e.id&&!e.outputUnavailable;return(0,L.jsx)(QQ,{testKind:`shell`,testId:r??e.id??e.label,mark:(0,L.jsx)(eh,{size:12,className:`${BQ} text-shell`}),name:e.label,onOpen:a?()=>tp(t,e.id,{label:e.label,startedAt:e.startedAt}):void 0,title:a?`Read this shell's output — running for ${i}`:e.label,status:i?`running · ${i}`:`running`})}function i$({watch:e,now:t}){let n=Date.parse(e.timer?.fireAt??``),r=Number.isFinite(n)?n>t?`fires in ${vE(n-t)}`:`firing…`:`armed`;return(0,L.jsx)(QQ,{testKind:`timer`,testId:e.target,mark:(0,L.jsx)(dm,{size:12,className:`${BQ} text-muted/60`}),name:e.timer?.prompt||e.target,title:e.timer?.fireAt?`One-off timer, set for ${e.timer.fireAt}`:e.target,status:r})}function a$(e){return(e.subAgents??[]).filter(e=>Xc(e)&&e.state===`running`)}function o$({agent:e,slug:t,now:n}){let r=bE(e.startedAt,n),i=e.subagentType?.replace(/^frizz:/,``);return(0,L.jsx)(QQ,{testKind:`agent`,testId:e.id??e.label,mark:(0,L.jsx)(VQ,{tone:`border-accent`}),name:e.label,onOpen:e.id?()=>ep(t,e.id,{label:e.label,subagentType:e.subagentType,startedAt:e.startedAt}):void 0,title:e.id?`Open this sub-agent — working for ${r}`:e.label,status:[i,r].filter(Boolean).join(` · `)})}function s$(e,t,n){let r=new Set(n.map(e=>e.target)),i=[];for(let n of t){if(n.kind!==`shell`)continue;let t=n.value.trim();if(!t||r.has(t))continue;let a=e$(e,t);!a||a.state!==`running`||(r.add(t),i.push({id:`shell:${e.id}:${t}`,kind:`shell`,target:t,state:`armed`,createdAt:a.startedAt}))}return i}function c$(e,t={}){let n=Date.parse(t.notAfter??``),r=e=>!Number.isFinite(n)||!e||!(Date.parse(e)>n),i=(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`&&r(e.createdAt)),a=t$(e).filter(t=>r(e$(e,t.target)?.startedAt??t.createdAt));return{prs:i,shells:[...a,...s$(e,t.hints??[],a)],agents:a$(e).filter(e=>r(e.startedAt)),timers:NQ(e).filter(e=>r(e.createdAt))}}function l$(e,t={}){let n=c$(e,t);return n.prs.length+n.shells.length+n.agents.length+n.timers.length>0}function u$(e,t,n={}){let{prs:r,shells:i,agents:a,timers:o}=c$(e,n);return[{head:`Sub-agents`,rows:a.map(n=>(0,L.jsx)(o$,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:i.map(n=>(0,L.jsx)(n$,{watch:n,thread:e,slug:e.id,now:t},n.id))},{head:`Pull requests`,rows:r.map(e=>(0,L.jsx)($Q,{watch:e},e.id))},{head:`Timers`,rows:o.map(e=>(0,L.jsx)(i$,{watch:e,now:t},e.id))}].filter(e=>e.rows.length>0)}function d$({group:e,first:t}){let n=`col-span-4 text-[10.5px] uppercase tracking-wide text-muted/45 ${t?``:`mt-2.5`}`;return e.onToggle?(0,L.jsxs)(`button`,{type:`button`,onClick:e.onToggle,"aria-expanded":!e.collapsed,onMouseDown:e=>e.stopPropagation(),className:`${n} flex items-baseline rounded-sm text-left transition-colors hover:text-muted/80`,children:[(0,L.jsx)(`span`,{children:e.head}),e.count!==void 0&&(0,L.jsx)(`span`,{className:`ml-1.5 tabular-nums`,children:e.count}),(0,L.jsx)(tm,{size:10,"aria-hidden":!0,className:`${BQ} ml-[5px] transition-transform ${e.collapsed?``:`rotate-90`}`})]}):(0,L.jsx)(`div`,{className:n,children:e.head})}function f$({groups:e,divider:t}){return e.length===0?null:(0,L.jsxs)(L.Fragment,{children:[t&&(0,L.jsx)(`div`,{"aria-hidden":!0,className:`-mx-4 mt-3 border-t border-border`}),(0,L.jsx)(`div`,{className:`mt-3 grid grid-cols-[auto_1fr_fit-content(50%)_auto] gap-y-px`,children:e.map((e,t)=>(0,L.jsxs)(I.Fragment,{children:[(0,L.jsx)(d$,{group:e,first:t===0}),!e.collapsed&&e.rows]},e.head))})]})}function p$(e){return e?.awaitingBackground===!0&&e.runtime===`turn-idle`&&e.bgSnoozed!==!0}var m$=`Hides card until new activity is detected`;function h$({thread:e,onSnooze:t,onSnoozeFailed:n}){let[r,i]=(0,I.useState)(!1);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{i(!0),t?.(),Y.snoozeAwaitingBackground({slug:e.id,sessionId:e.sessionId??``}).then(()=>Z(`Snoozed until the background work returns`)).catch(e=>{n?.(),Z(`Couldn’t snooze: ${e.message.slice(0,80)}`),i(!1)})},disabled:r,onMouseDown:e=>e.preventDefault(),title:m$,className:`disabled:opacity-45 ${sJ}`,children:[(0,L.jsx)(Tm,{size:12,className:BY}),`Snooze`]}),(0,L.jsx)(`span`,{className:aJ,children:m$})]})}function g$({thread:e,fence:t,onSnooze:n,onSnoozeFailed:r,notAfter:i}){let a=e??PQ,o=t??(e?.lastFence?.kind===`awaiting`?e.lastFence:void 0),s=o?.hints??FQ,c=OQ(a),l=FH(o?.body),u=gK(l??``),d=u$(a,sE(),{hints:s,notAfter:i}),f=IQ(a,s),p=i===void 0&&e!==void 0&&p$(e)&&SX(e).snooze;return(0,L.jsxs)(nJ,{"data-awaiting-background":!0,icon:MQ(a)?eh:Tm,label:(0,L.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:jQ(a,s)}),aside:f.length===1?(0,L.jsx)(LQ,{watch:f[0]}):void 0,className:p?`pb-0`:``,children:[l?(0,L.jsx)(hq,{className:`md-body ${Jq}`,html:u}):d.length===0&&!AQ(a)?(0,L.jsx)(`p`,{className:rJ,children:OH}):null,f.length>1&&(0,L.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:f.map(e=>(0,L.jsx)(LQ,{watch:e},e.ref))}),d.length===0&&AQ(a)&&(0,L.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75`,children:c?(0,L.jsxs)(L.Fragment,{children:[`It’s awaiting the results from `,DQ(a,{watchers:!1}),` it dispatched. It returns to the queue on its own when the work comes back.`]}):(0,L.jsxs)(L.Fragment,{children:[DQ(a,{watchers:!1}),` `,kQ(a)===1?`is`:`are`,` still running. It resumes on its own when`,` `,kQ(a)===1?`it finishes`:`one of them finishes`,`.`]})}),(0,L.jsx)(f$,{groups:d,divider:!!l}),p?(0,L.jsx)(`div`,{"data-awaiting-snooze":!0,className:`-mx-4 mt-3 flex flex-wrap items-center gap-x-2.5 gap-y-2 border-t border-border bg-fg/[0.03] px-4 py-2.5 ${Zq}`,children:(0,L.jsx)(h$,{thread:e,onSnooze:n,onSnoozeFailed:r})}):null]})}function _$(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.kind!==`event`||n.boundary!==`rest`)){for(let r=t-1;r>=0;r--){let t=e[r];if(t.role===`assistant`&&t.kind!==`event`&&t.kind!==`reasoning`)return{index:r,at:n.at}}return{index:-1,at:n.at}}}}function v$(e,t=Date.now()){return e!==void 0&&DT(e,t)!==void 0}function y$(){let[e,t]=(0,I.useState)(()=>Date.now());return(0,I.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function b$({thread:e}){let t=y$(),[n,r]=(0,I.useState)(!1),i=DT(e,t);if(!i)return null;let a=Date.parse(i),o=Ww(i,t).replace(/^(Today|Tomorrow)/,e=>e.toLowerCase()),s=e.snoozePrompt?.trim();async function c(){r(!0);try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:null,prompt:null}),Z(`Snooze cleared`)}catch(e){Z((e instanceof Error?e.message:`Wake failed`).slice(0,100))}finally{r(!1)}}return(0,L.jsxs)(nJ,{"data-snooze-card":!0,icon:Tm,label:`Snoozed`,children:[(0,L.jsx)(`div`,{"data-snooze-countdown":!0,title:new Date(a).toLocaleString(),className:`text-[22px] font-semibold leading-8 tracking-tight text-fg tabular-nums`,children:SE(a-t)}),(0,L.jsx)(`p`,{className:rJ,children:s?(0,L.jsxs)(L.Fragment,{children:[`Resumes `,o,` and sends: “`,Jw(s),`”`]}):(0,L.jsxs)(L.Fragment,{children:[`Returns to the queue `,o,`.`]})}),e.foreign!==!0&&(0,L.jsx)(iJ,{children:(0,L.jsx)(`button`,{type:`button`,"data-snooze-wake-now":!0,disabled:n,onClick:()=>void c(),className:`${sJ} disabled:cursor-not-allowed disabled:opacity-45`,children:`Wake now`})})]})}function x$({at:e,fallbackAt:t,className:n=``}){let r=sE(),i=UT(e,t),a=WT(i,r);return!a||!i?null:(0,L.jsx)(`time`,{dateTime:i,className:n,children:a})}var S$=1500;function C$(e,t){let n=0,r;function i(){r!==void 0&&(t.clearTimeout(r),r=void 0)}return{begin(){let a=++n;return e(!0),i(),r=t.setTimeout(()=>{a===n&&e(!1),r=void 0},S$),a},fail(t){t===n&&(i(),e(!1))},dispose(){n++,i()}}}var w$=`Could not copy terminal command`,T$={attach:`Attach command copied`,resume:`Resume command copied`},E$={attach:`Copy command to attach to this thread's live terminal`,resume:`Copy command to resume this thread in a new terminal`},D$=e=>[`terminalCommand`,e];function O$(e){return Y.threadTerminalCommand({slug:e}).then(e=>{if(!e.command)throw Error(e.reason??`No verified provider session is available to resume`);return{command:e.command,mode:e.mode===`attach`?`attach`:`resume`}})}async function k$(e){let t=O$(e);if(typeof ClipboardItem<`u`&&navigator.clipboard?.write)return await navigator.clipboard.write([new ClipboardItem({"text/plain":t.then(({command:e})=>new Blob([e],{type:`text/plain`}))})]),(await t).mode;let{command:n,mode:r}=await t;return await wR(n),r}function A$(e){let t=it({mutationFn:()=>k$(e)});return e=>t.mutate(void 0,{onSuccess:t=>{e?.onSuccess?.(),Z(T$[t])},onError:t=>{e?.onError?.(),Z(t instanceof Error?`${w$}: ${t.message}`:w$,{duration:7e3})}})}function j$({slug:e}){let[t,n]=(0,I.useState)(!1),r=(0,I.useRef)(null);r.current||=C$(n,{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)});let i=Ve(),a=A$(e);(0,I.useEffect)(()=>()=>r.current?.dispose(),[]);function o(){i.prefetchQuery({queryKey:D$(e),queryFn:()=>O$(e),staleTime:15e3})}function s(){let t=i.getQueryData(D$(e));if(t){wR(t.command).then(()=>{r.current?.begin(),Z(T$[t.mode])},()=>Z(w$,{duration:7e3}));return}a({onSuccess:()=>r.current?.begin()})}let c=i.getQueryData(D$(e)),l=t?c?T$[c.mode]:`Terminal command copied`:c?E$[c.mode]:`Copy terminal command`;return(0,L.jsx)(Rj,{label:l,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":l,title:l,onClick:s,onPointerEnter:o,onFocus:o,className:tD,children:t?(0,L.jsx)(Qp,{size:14,strokeWidth:2.2,className:`text-fg`}):(0,L.jsx)(eh,{size:14,strokeWidth:1.8})})})}function M$(e){let t=Math.max(e.scrollHeight-e.clientHeight,0),n=t-e.scrollTop,r=e.scrollHeight!==e.previousScrollHeight,i=r&&!e.readerMoved?e.following||n<=1:n<=4;return!i||!r||t<=0||n<=1?{following:i,scrollTop:null}:{following:i,scrollTop:t}}function N$(e){let t=e.scrollTop>640?!0:e.armed,n=t&&e.readerMoved&&e.scrollTop<=480&&e.hasEarlier&&!e.loading;return{armed:n?!1:t,shouldLoad:n}}function P$(e){return`legacy:${e.role}:${e.kind??`message`}:${e.at??``}:${e.text}`}function F$(e,t,n){let r=[],i=new Map,a=null;return e.forEach((e,o)=>{if(e.queued||t(e))return;let s=e.sourceId??P$(e),c=i.get(s)??0;i.set(s,c+1),r.push({key:c===0?s:`${s}:${c}`,message:e,messageIndex:o,gap:a===null?0:n(a,e)}),a=e}),r}function I$(e,t,n){let r=e[t];if(!r||r.kind!==`event`||r.boundary!==`rest`)return!1;for(let r=t+1;r<e.length;r++){let t=e[r];if(!(t.queued||n(t)))return!!t.boundary||t.wake===!0}return!0}function L$(e,t){let n=e.map(e=>e.message);return e.filter((e,r)=>!I$(n,r,t))}var R$=new Set([`agent`,`follow up`,`interrupt`,`send message`,`spawn agent`,`wait for agents`]),z$=new Set([`poll process`,`wait`]);function B$(e){return(e.split(`__`).pop()||e).replaceAll(`_`,` `).trim()}function V$(e){return B$(e).toLowerCase()}function H$(e){return e.prompt!==void 0||e.agentId!==void 0||e.sendTo!==void 0||e.sendBody!==void 0||e.backgroundState!==void 0&&!G$(e)||W$(e)||U$(e)||R$.has(V$(e.name))}function U$(e){return e.ask!==void 0&&e.ask.length>0&&e.status!==void 0&&e.status!==`pending`}function W$(e){return e.outputImage!==void 0||e.sentImages!==void 0&&e.sentImages.length>0}function G$(e){return e.backgroundState===`unknown`&&z$.has(V$(e.name))}function K$(e){if(e.role!==`assistant`||e.kind||e.queued)return null;if(e.parts&&e.parts.length>0){let t=[];for(let n of e.parts)if(n.kind===`text`){if(n.text.trim())return null}else t.push(...n.tools);return t.length>0&&t.every(e=>!H$(e))?t:null}return e.text.trim()||e.tools.length===0?null:e.tools.every(e=>!H$(e))?e.tools:null}function q$(e){return e.role!==`assistant`||e.kind||e.queued||e.text.trim()||e.tools.length>0?!1:!e.parts?.some(e=>e.kind===`text`?e.text.trim().length>0:e.tools.length>0)}function J$(e){if(e.role!==`assistant`||e.kind||e.queued)return null;if(!e.parts?.length)return Y$(e.tools);for(let t=e.parts.length-1;t>=0;t--){let n=e.parts[t];if(n.kind===`text`){if(n.text.trim())return null;continue}if(n.tools.length!==0)return Y$(n.tools)}return null}function Y$(e){let t=[];for(let n=e.length-1;n>=0&&!H$(e[n]);n--)t.unshift(e[n]);return t.length>0?t:null}function X$(e){if(e.role!==`assistant`||e.kind||e.queued)return null;let t=[],n=e=>{for(let n of e){if(H$(n))return!0;t.push(n)}return!1};if(!e.parts?.length)return e.text.trim()?null:n(e.tools)&&t.length>0?t:null;for(let r of e.parts){if(r.kind===`text`){if(!r.text.trim())continue;return t.length>0?t:null}if(n(r.tools))return t.length>0?t:null}return null}function Z$(e,t){return Q$(e,new Set(t))}function Q$(e,t){if(!e.parts?.length)return{...e,tools:e.tools.filter(e=>!t.has(e))};let n=e.parts.map(e=>e.kind===`text`?e:{kind:`tools`,tools:e.tools.filter(e=>!t.has(e))}).filter(e=>e.kind===`text`||e.tools.length>0);return{...e,tools:n.flatMap(e=>e.kind===`tools`?e.tools:[]),parts:n}}function $$(e,t,n){let r=[...e.tools,...t],i=e.parts?.map(e=>e.kind===`text`?e:{...e,tools:[...e.tools]})??[],a=-1;for(let e=i.length-1;e>=0;e--){let t=i[e];if(t.kind===`text`){if(t.text.trim())break;continue}if(t.tools.length>0){a=e;break}}let o=i[a];return o?.kind===`tools`?i[a]={kind:`tools`,tools:[...o.tools,...t]}:i.push({kind:`tools`,tools:t}),{...e,at:n??e.at,tools:r,parts:i}}function e1(e){let t=[],n=null;return e.forEach((e,r)=>{if(q$(e))return;if(e.queued){t.push({message:e,messageIndex:r});return}let i=K$(e);if(i&&n){n.message=$$(n.message,i,e.at);return}let a=n?X$(e):null,o=a?Z$(e,a):e;a&&n&&(n.message=$$(n.message,a,e.at));let s={message:o,messageIndex:r};t.push(s),J$(o)?(s.runStartedAt=o.at,n=s):n=null}),t}function t1(e){return e.status===`completed`||e.status===`failed`||e.status===`cancelled`}function n1(e){let t=r1(e);return t?.tools.some(e=>!t1(e))?t.tools.at(-1):void 0}function r1(e){let t=i1(e);if(!t)return;let n=J$(t.message);return n?{tools:n,at:t.message.at}:void 0}function i1(e){for(let t=e.length-1;t>=0;t--)if(!e[t].message.queued)return e[t]}function a1(e){let t=i1(e);if(t)return J$(t.message)?t.runStartedAt??t.message.at:t.message.at}function o1(e){return e.runStartedAt??e.message.at}function s1(e){let t=J$(e);return t?Q$(e,new Set(t)):e}function c1(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].message;if(!r.queued){J$(r)&&(t=r);break}}if(!t)return[...e];let n=[];for(let r of e){let e=r.message===t?s1(r.message):r.message;q$(e)||n.push(e===r.message?r:{...r,message:e})}return n}function l1(e){return e.detail?.trim()||void 0}var u1={add:`Adding`,analyze:`Analyzing`,apply:`Applying`,audit:`Auditing`,benchmark:`Benchmarking`,build:`Building`,bump:`Bumping`,capture:`Capturing`,check:`Checking`,clean:`Cleaning`,collect:`Collecting`,commit:`Committing`,compare:`Comparing`,confirm:`Confirming`,copy:`Copying`,count:`Counting`,create:`Creating`,debug:`Debugging`,delete:`Deleting`,diff:`Diffing`,disable:`Disabling`,dispatch:`Dispatching`,drive:`Driving`,dump:`Dumping`,edit:`Editing`,enable:`Enabling`,extract:`Extracting`,fetch:`Fetching`,find:`Finding`,fix:`Fixing`,format:`Formatting`,generate:`Generating`,grep:`Grepping`,inspect:`Inspecting`,install:`Installing`,kill:`Killing`,launch:`Launching`,lint:`Linting`,list:`Listing`,load:`Loading`,measure:`Measuring`,merge:`Merging`,migrate:`Migrating`,move:`Moving`,open:`Opening`,parse:`Parsing`,patch:`Patching`,poll:`Polling`,print:`Printing`,probe:`Probing`,profile:`Profiling`,publish:`Publishing`,pull:`Pulling`,push:`Pushing`,query:`Querying`,read:`Reading`,rebase:`Rebasing`,refactor:`Refactoring`,regenerate:`Regenerating`,remove:`Removing`,rename:`Renaming`,render:`Rendering`,reproduce:`Reproducing`,restart:`Restarting`,revert:`Reverting`,review:`Reviewing`,run:`Running`,save:`Saving`,scan:`Scanning`,search:`Searching`,seed:`Seeding`,spawn:`Spawning`,start:`Starting`,stop:`Stopping`,summarize:`Summarizing`,sync:`Syncing`,tag:`Tagging`,test:`Testing`,trace:`Tracing`,typecheck:`Typechecking`,update:`Updating`,validate:`Validating`,verify:`Verifying`,wait:`Waiting`,watch:`Watching`,write:`Writing`};function d1(e,t){let n=e?.trim();if(!n)return t;let r=n.indexOf(` `),i=(r===-1?n:n.slice(0,r)).replace(/[.:]$/,``);if(/ing$/i.test(i))return i.charAt(0).toUpperCase()+i.slice(1)+(r===-1?``:n.slice(r));let a=u1[i.toLowerCase()];return a?a+(r===-1?``:n.slice(r)):n.charAt(0).toUpperCase()+n.slice(1)}function f1(e,t){let n=t?.trim().replace(/\/+$/,``);if(!n||n===`/`||!n.startsWith(`/`))return e;let r=e.replaceAll(`${n}/`,``),i=/^(\/(?:Users|home)\/[^/]+)(?:\/|$)/.exec(n)?.[1];return i?r.replaceAll(`${i}/`,`~/`):r}function p1(e,t){return f1(m1(e),t)}function m1(e){let t=V$(e.name),n=l1(e),r=n?` ${n}`:``;return t===`bash`||t===`exec`||t===`run command`?d1(e.desc,n?`Running ${n}`:`Running a command`):t===`read`||t===`view image`?`Reading${r||` a file`}`:t===`grep`||t===`search`||t===`search query`||t===`find`?n?`Searching for ${n}`:`Searching`:t===`glob`||t===`find files`?n?`Finding ${n}`:`Finding files`:t===`edit`||t===`write`||t===`apply patch`?n?`Editing ${n}`:`Editing files`:t===`todos`||t===`update plan`?`Updating the plan`:t===`screenshot`||t===`snapshot`?n?`Capturing ${n}`:`Capturing the page`:t===`navigate`?n?`Navigating to ${n}`:`Navigating`:t===`evaluate`?`Evaluating the page`:t===`pages`?`Listing pages`:t===`new page`?`Opening a new page`:t===`close page`?`Closing the page`:t===`select page`?`Selecting a page`:t===`console`||t===`console message`?`Reading the console`:t===`network`||t===`network request`?`Inspecting network traffic`:t===`press key`?n?`Pressing ${n}`:`Pressing a key`:t===`fill form`?`Filling the form`:t===`dialog`?`Handling a dialog`:t===`upload`?n?`Uploading ${n}`:`Uploading a file`:t===`wait for`||t===`wait`?n?`Waiting for ${n}`:`Waiting`:t===`resize`?`Resizing the page`:t===`ask`?`Preparing a question`:t===`web`||t===`web search`?n?`Searching for ${n}`:`Searching the web`:`Using ${B$(e.name)||`a tool`}`}var h1=new Set([`edit`,`multiedit`,`write`,`apply patch`]);function g1(e){let t=new Set;for(let n of e){for(let e of n.edits??(n.edit?[n.edit]:[]))e.file.trim()&&t.add(e.file.trim());if(n.edit||n.edits?.length)continue;let e=n.detail?.trim();e&&h1.has(V$(n.name))&&t.add(e)}return t.size}function _1(e,t=0){let n=`Ran ${e} tool ${e===1?`call`:`calls`}`;return t===0?n:`${n}, edited ${t} file${t===1?``:`s`}`}function v1(e){return e>0?`${_1(e)}. Thinking…`:`Thinking…`}function y1(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function b1(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function x1(e,t){let n=y1(e,t);if(n)try{let e=new URL(n);return e.protocol===`https:`||e.protocol===`http:`?e.href:void 0}catch{return}}function S1({directive:e,icon:t,title:n,meta:r,children:i}){return(0,L.jsxs)(`section`,{"data-codex-directive":e.name,className:`min-w-0 ${Yq} border border-border bg-panel-2/75 p-4`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center text-muted`,"aria-hidden":!0,children:t}),(0,L.jsx)(`div`,{className:`max-w-[calc(100%-1.5rem)] shrink-0 break-words text-[12px] font-medium leading-4 text-fg`,children:n}),r&&(0,L.jsx)(`div`,{className:`min-w-0 truncate text-[11px] font-normal leading-4 text-muted`,children:r})]}),i]})}function C1({children:e,mono:t=!1}){return(0,L.jsx)(`div`,{className:`ml-6 mt-1 break-words text-[11px] leading-4 text-muted${t?` font-mono-keep`:``}`,children:e})}function w1({directive:e}){let t=e.attrs,n=y1(t,`display_name`)??y1(t,`skill_name`)??`Artifact template`,r=y1(t,`artifact_kind`),i=y1(t,`skill_name`),a=y1(t,`skill_directory`),[o,s]=(0,I.useState)(!!a);return(0,L.jsxs)(S1,{directive:e,icon:(0,L.jsx)(Am,{size:15}),title:n,meta:r?`${r} template`:`Template`,children:[i&&(0,L.jsx)(C1,{mono:!0,children:i.startsWith(`$`)?i:`$${i}`}),o&&a&&(0,L.jsx)(`img`,{src:jS(`${a}/assets/preview.png`),alt:`${n} template preview`,loading:`lazy`,onError:()=>s(!1),className:`ml-6 mt-2 max-h-44 max-w-[calc(100%-1.5rem)] rounded-md border border-border object-contain`})]})}function T1({directive:e}){let t=e.attrs,n=y1(t,`file`),r=b1(t,`start`),i=b1(t,`end`)??r,a=b1(t,`priority`),o=n?`${n}${r?`:${r}${i&&i!==r?`-${i}`:``}`:``}`:`Code location unavailable`;return(0,L.jsxs)(S1,{directive:e,icon:(0,L.jsx)(Fm,{size:15}),title:y1(t,`title`)??`Review finding`,meta:a===void 0?void 0:`P${a}`,children:[y1(t,`body`)&&(0,L.jsx)(C1,{children:y1(t,`body`)}),n?(0,L.jsx)(`button`,{type:`button`,className:`local-file-action ml-6 mt-1 max-w-[calc(100%-1.5rem)] break-all text-left font-mono-keep text-[11px] leading-4 text-accent underline decoration-dotted underline-offset-2`,"data-local-path":n,title:o,children:o}):(0,L.jsx)(C1,{mono:!0,children:o})]})}var E1={"git-stage":[zm,`Changes staged`],"git-commit":[ym,`Commit created`],"git-create-branch":[vm,`Branch created`],"git-push":[ih,`Branch pushed`],"git-create-pr":[Cm,`Pull request created`]};function D1({directive:e}){let[t,n]=E1[e.name],r=y1(e.attrs,`branch`),i=x1(e.attrs,`url`),a=`${n}${e.attrs.isDraft===!0?` as draft`:``}`;return(0,L.jsx)(S1,{directive:e,icon:(0,L.jsx)(t,{size:15}),title:i?(0,L.jsx)(`a`,{className:`text-accent underline underline-offset-2`,href:i,target:`_blank`,rel:`noopener noreferrer`,children:a}):a,meta:r&&(0,L.jsx)(`span`,{className:`font-mono-keep`,children:r})})}function O1({directive:e}){let t=y1(e.attrs,`threadId`),n=y1(e.attrs,`pendingWorktreeId`);return(0,L.jsx)(S1,{directive:e,icon:(0,L.jsx)(Rm,{size:15}),title:n?`Thread setup queued`:`Thread created`,meta:(t||n)&&(0,L.jsx)(`span`,{className:`font-mono-keep`,children:t??n})})}function k1({directive:e}){let t=y1(e.attrs,`reason`);return(0,L.jsx)(S1,{directive:e,icon:(0,L.jsx)(Kp,{size:15}),title:`Archive suggested`,meta:t})}function A1(e){if(typeof e!=`string`||!e)return;let t=e.match(/(?:^|;)INTERVAL=(\d+)(?:;|$)/)?.[1];return/(?:^|;)FREQ=HOURLY(?:;|$)/.test(e)?`Every ${t??`1`} hour${t===`1`||t===void 0?``:`s`}`:/(?:^|;)FREQ=WEEKLY(?:;|$)/.test(e)?`Weekly schedule`:`Custom schedule`}function j1({directive:e}){let t=e.attrs,n=y1(t,`mode`),r=y1(t,`name`)??`Automation`,i=A1(t.rrule),a=[r,n,y1(t,`status`),i].filter(Boolean).join(` · `);return(0,L.jsx)(S1,{directive:e,icon:(0,L.jsx)(Zp,{size:15}),title:`Automation suggested`,meta:a,children:y1(t,`prompt`)&&(0,L.jsx)(C1,{children:y1(t,`prompt`)})})}function M1({directive:e}){return e.name===`artifact-template`?(0,L.jsx)(w1,{directive:e}):e.name===`code-comment`?(0,L.jsx)(T1,{directive:e}):e.name.startsWith(`git-`)?(0,L.jsx)(D1,{directive:e}):e.name===`created-thread`?(0,L.jsx)(O1,{directive:e}):e.name===`archive`||e.name===`archive-thread`?(0,L.jsx)(k1,{directive:e}):(0,L.jsx)(j1,{directive:e})}var N1;function P1(){return N1??=By(async()=>{let{default:e}=await import(`./mermaid.core-DnlDGPhM.js`);return{default:e}},__vite__mapDeps([2,3,4,1,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])).then(({default:e})=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:`dark`,themeVariables:{background:`#181b20`,primaryColor:`#181b20`,primaryTextColor:`#e6e7e9`,primaryBorderColor:`#33363c`,lineColor:`#8b8f96`,secondaryColor:`#26282d`,tertiaryColor:`#0d0e10`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`}}),e)),N1}function F1({source:e}){let t=(0,I.useId)(),[n,r]=(0,I.useState)({}),i=nq(n.html??``);return(0,I.useEffect)(()=>{let n=!0;if(r({}),e.length>5e4)return r({error:`Diagram source exceeds the 50 KB rendering limit`}),()=>{n=!1};let i=`frizz-mermaid-${t.replace(/[^a-zA-Z0-9]/g,``)}`;return P1().then(t=>t.render(i,e)).then(({svg:e})=>{n&&r({html:e})}).catch(e=>{if(!n)return;let t=e instanceof Error?e.message.split(/\n| for text:/,1)[0]:`Unknown diagram error`;r({error:t.slice(0,240)})}).finally(()=>document.getElementById(`d${i}`)?.remove()),()=>{n=!1}},[t,e]),n.error?(0,L.jsxs)(`section`,{"data-mermaid-state":`error`,className:`${Yq} border border-border bg-panel-2/75 p-4`,children:[(0,L.jsx)(`div`,{className:`text-[12px] font-medium text-fg`,children:`Diagram unavailable`}),(0,L.jsx)(`div`,{className:`mt-1 text-[11px] text-muted`,children:n.error}),(0,L.jsx)(`pre`,{className:`mt-2 overflow-x-auto whitespace-pre-wrap rounded-md bg-bg p-2 font-mono-keep text-[11px] text-muted`,children:e})]}):n.html?(0,L.jsx)(`div`,{"data-mermaid-state":`ready`,className:`overflow-x-auto ${Yq} border border-border bg-panel-2/75 p-4 [&_svg]:mx-auto [&_svg]:h-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:i}):(0,L.jsx)(`div`,{"data-mermaid-state":`loading`,role:`status`,"aria-label":`Rendering diagram`,className:`h-24 animate-pulse ${Yq} bg-panel-2`})}var I1=(0,I.createContext)(null),L1=(0,I.createContext)(null);function R1(){let e=(0,I.useContext)(I1),t=(0,I.useContext)(L1);return e??t}var z1=(0,I.createContext)(null);function B1(e){return e.status===`pending`&&e.backgroundState===`background`}function V1(e){let t=[];for(let n of e)for(let e of n.tools)B1(e)&&n.at&&t.push({label:e.desc??e.detail??e.command??`Background command`,startedAt:n.at,state:`running`,...e.shellId?{launchId:e.shellId}:{},...e.command?{command:e.command}:{}});return t}function H1(e){return e.map(e=>{if(!e.tools.some(B1))return e;let t=e.tools.filter(e=>!B1(e)),n=e.parts?.map(e=>e.kind===`tools`?{...e,tools:e.tools.filter(e=>!B1(e))}:e).filter(e=>e.kind!==`tools`||e.tools.length>0);return{...e,tools:t,parts:n}})}function U1({slug:e,onStatusApplied:t,onClose:n,virtualized:r=!1,showReturnToQueue:i=!1}){let a=Dp(kC(),e);return(0,L.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,L.jsx)(t0,{slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:i}),(0,L.jsx)(W1,{slug:e,virtualized:r}),a&&(0,L.jsx)(YX,{thread:a,sticky:!0,safeArea:!0,onArchived:t})]})}function W1({slug:e,virtualized:t}){let n=kC(),r=Dp(n,e),i=r?.runtime===`running`||r?.runtime===`spawning`,a=A$(e),o=UC(e,{poll:i}),s=Ve(),c=(0,I.useRef)(!1),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(null),p=(0,I.useMemo)(()=>o.data?.messages??[],[o.data]),m=(0,I.useMemo)(()=>V1(p),[p]),h=(0,I.useMemo)(()=>H1(p),[p]),g=(0,I.useMemo)(()=>h0(h),[h]),_=(0,I.useMemo)(()=>i?_$(h):void 0,[i,h]),v=_&&_.index>=0?_.index:g,y=(0,I.useMemo)(()=>e1(h),[h]),b=i?r1(y):void 0,x=i?n1(y):void 0,S=x?p1(x,n?.projectDir):void 0,C=i?a1(y):void 0,w=p$(r),T=(0,I.useMemo)(()=>{let e=i?c1(y):y;return L$(e,g0(e,v,w))},[y,i,v,w]),E=i,D=(0,I.useMemo)(()=>EJ(p),[p]),O=(0,I.useMemo)(()=>xJ(p,r?.answersInFlight),[p,r?.answersInFlight]),k=(0,I.useMemo)(()=>IY(p),[p]),A={thread:r,showWorking:E,registeredDone:qq(r,g>=0?h[g]?.text:void 0),restedCard:cJ(r,g>=0?h[g]?.text:void 0),errorVisible:uJ(h,r?.providerError)},{answeringForMessage:j}=yY(e,p),M=(0,I.useMemo)(()=>NJ(p,r?.questions??[]),[p,r?.questions]),N=(0,I.useRef)(null),[P,ee]=(0,I.useState)(null),F=o.data?.messages.length??0,te=!o.isLoading;(0,I.useEffect)(()=>{if(t)return;let e=N.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<=4&&(e.scrollTop=e.scrollHeight)},[F,i,t]);let ne=(0,I.useCallback)(async()=>{if(c.current)return;let t=s.getQueryData([`transcript`,e]),n=t?.beforeCursor,r=t?.transcriptKey;if(!(!t?.hasEarlier||!n||!r)){c.current=!0,u(!0),f(null);try{let t=await Y.threadTranscriptEarlier({slug:e,cursor:n}),i=s.getQueryData([`transcript`,e]);if(!i?.transcriptKey||i.transcriptKey!==r||t.transcriptKey!==r){await o.refetch(),Z(`Transcript changed while loading history; refreshed the current session`);return}s.setQueryData([`transcript`,e],mx(i,t))}catch(e){let t=e instanceof Error?e.message:`Could not load earlier transcript history`;f(t)}finally{c.current=!1,u(!1)}}},[o,s,e]);return(0,L.jsx)(I1.Provider,{value:e,children:(0,L.jsxs)(`div`,{"data-drawer-scroll-ready":o.isPending?`false`:`true`,className:`flex-1 min-h-0 flex flex-col overflow-hidden outline-none`,children:[(0,L.jsxs)(`div`,{className:`relative min-h-0 flex-1 flex flex-col`,children:[(0,L.jsx)(`div`,{ref:N,"data-drawer-transcript-scroll":!0,"data-virtualized-transcript-scroll":t||void 0,tabIndex:t?0:void 0,role:t?`region`:void 0,"aria-label":t?`Thread conversation`:void 0,"aria-busy":t&&l?!0:void 0,className:`relative min-h-0 flex-1 overflow-y-auto pb-3 outline-none [overflow-anchor:none] focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/60`,children:t&&F>0?(0,L.jsx)($1,{slug:e,transcriptRef:N,transcriptKey:o.data?.transcriptKey,messages:h,paired:D,inFlightAnswers:O,answeringForMessage:j,thread:r,running:i,copyTerminalCommand:a,transportFallback:o.transportFallback,isFetching:o.isFetching,refresh:()=>void o.refetch(),retryLiveUpdates:o.retryLiveUpdates,hasEarlier:o.data?.hasEarlier===!0,beforeCursor:o.data?.beforeCursor,loadingEarlier:l,earlierError:d,loadEarlier:()=>void ne(),jumpOverlay:P}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(tQ,{thread:r,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(wQ,{thread:r,inFlight:O,className:`px-6 pt-5`}),o.transportFallback&&(0,L.jsxs)(`div`,{"data-transcript-sync-fallback":!0,className:`mx-6 mt-3 flex flex-wrap items-center gap-2.5 rounded-xl border border-border-strong bg-panel-2 px-4 py-2.5 text-[12px]`,title:o.transportFallback.kind===`payload-too-large`?`Live payload ${o.transportFallback.actualBytes} bytes; socket limit ${o.transportFallback.maxBytes} bytes`:`Transcript read budget reached (${o.transportFallback.scope}); retry after about ${o.transportFallback.retryAfterMs}ms`,children:[(0,L.jsx)(rh,{size:13,className:`shrink-0 text-muted`}),(0,L.jsxs)(`div`,{className:`min-w-[180px] flex-1 leading-snug text-fg/85`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Live transcript updates paused.`}),` `,o.transportFallback.kind===`payload-too-large`?`The transcript is too large for push; the last complete HTTP-loaded copy remains visible.`:`The live read budget was reached; the last complete copy remains visible. Retry in a moment.`]}),(0,L.jsx)(`button`,{type:`button`,disabled:o.isFetching,onClick:()=>void o.refetch(),className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel disabled:opacity-40`,children:o.isFetching?`Refreshing…`:`Refresh once`}),(0,L.jsx)(`button`,{type:`button`,onClick:o.retryLiveUpdates,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel`,children:`Retry live`})]}),(0,L.jsx)(`div`,{"data-transcript-column":!0,className:`flex min-h-full flex-col px-6 py-5`,children:F===0?(0,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted`,children:o.isPending?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(b2,{}),` Loading…`]}):i?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(b2,{}),` Session starting…`]}):HY(r)?(0,L.jsxs)(`div`,{className:`text-center`,children:[(0,L.jsx)(`p`,{className:`mb-3`,children:`No session is attached to this thread yet.`}),(0,L.jsx)(`button`,{className:`btn-ghost border border-border text-[12px]`,onClick:()=>Y.adoptThread({slug:e}).catch(()=>{}),children:`Start a session on this thread`})]}):`No conversation yet.`}):(0,L.jsxs)(L.Fragment,{children:[b0(T.map(e=>e.message),(e,t)=>{let n=T[t].messageIndex;return(0,L.jsx)(t2,{m:e,answering:j(e),showSendButton:!0,paired:D[n],staleAwaiting:v>=0&&n<v,restingCardShown:n===g&&w,restedAt:_&&n===_.index?_.at??``:void 0,shadowedBy:M.get(n),thread:r},t)},e=>!!e.queued),te&&X1(A)!==null&&(0,L.jsx)(BJ,{h:Z1(A,T.map(e=>e.message))}),te&&(0,L.jsx)(Q1,{state:A,slug:e,retryText:k>=0?p[k]?.text:void 0,onTerminal:a,liveRuntimeStart:C,liveActivityLabel:S,liveToolRun:b}),r?.permPolicy?(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(f2,{policy:r.permPolicy,denies:r.permDenies})}):null,p.some(e=>e.queued)&&(0,L.jsx)(BJ,{}),(0,L.jsx)(`div`,{className:`flex flex-col gap-3.5`,children:p.map((e,t)=>e.queued?(0,L.jsx)(t2,{m:e,paired:D[t]},`q${t}`):null)})]})})]})}),(0,L.jsx)(`div`,{ref:ee,"data-transcript-overlay":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-end p-4 [&>*]:pointer-events-auto`})]}),(0,L.jsx)(`div`,{"data-thread-chat-footer":!0,className:`z-10 shrink-0 border-t border-border/60 bg-panel`,children:(0,L.jsx)(pX,{slug:e,onTerminal:a,ops:(0,L.jsx)(p2,{slug:e,transcriptShells:m,className:`px-1 pt-1.5`})})})]})})}var G1=700,K1=250,q1=(()=>{try{return localStorage.getItem(`frizz.debugScroll`)===`1`}catch{return!1}})();function J1(e){return e?.pendingInteraction===!0}function Y1(e){return J1(e)?void 0:e?.pendingAsk}function X1({thread:e,showWorking:t,registeredDone:n,restedCard:r,errorVisible:i}){return e?.providerError?.retrying?`provider-error`:e?.providerFault&&!e.foreign?`provider-fault`:e?.limitPause&&!e.foreign?`limit-pause`:Y1(e)?`pending-ask`:e?.runtime===`perm-prompt`&&!J1(e)?`perm-prompt`:t?`working`:e?.providerError?i?null:`provider-error`:v$(e)?`snooze`:p$(e)?`resting`:n?`registered-done`:r?`rested`:null}function Z1(e,t){return X1(e)===`working`?y0(t):14}function Q1({state:e,slug:t,retryText:n,onTerminal:r,liveRuntimeStart:i,liveActivityLabel:a,liveToolRun:o}){let s=e.thread;switch(X1(e)){case`provider-fault`:return(0,L.jsx)(l2,{slug:t,sessionId:s.sessionId,fault:s.providerFault,retryText:n});case`provider-error`:return(0,L.jsx)(dJ,{error:s.providerError});case`limit-pause`:return(0,L.jsx)(u2,{slug:t,sessionId:s.sessionId,pause:s.limitPause});case`pending-ask`:return(0,L.jsx)(m2,{ask:Y1(s),onTerminal:r});case`perm-prompt`:return(0,L.jsx)(d2,{onTerminal:r});case`working`:return(0,L.jsx)(x2,{since:s?.lastUserAt,startedAt:i,activityLabel:a,run:o});case`snooze`:return(0,L.jsx)(b$,{thread:s});case`resting`:return(0,L.jsx)(g$,{thread:s});case`registered-done`:return(0,L.jsx)(c2,{fenceKind:`done`,body:s.lastFence.body,hints:[]});case`rested`:return(0,L.jsx)(lJ,{thread:s});default:return null}}function $1({slug:e,transcriptRef:t,transcriptKey:n,messages:r,paired:i,inFlightAnswers:a,answeringForMessage:o,thread:s,running:c,copyTerminalCommand:l,transportFallback:u,isFetching:d,refresh:f,retryLiveUpdates:p,hasEarlier:m,beforeCursor:h,loadingEarlier:g,earlierError:_,loadEarlier:v,jumpOverlay:y}){let b=AC(),x=(0,I.useMemo)(()=>e1(r),[r]),S=c?r1(x):void 0,C=c?n1(x):void 0,w=C?p1(C,b):void 0,T=c?a1(x):void 0,E=(0,I.useMemo)(()=>h0(r),[r]),D=(0,I.useMemo)(()=>c?_$(r):void 0,[c,r]),O=D&&D.index>=0?D.index:E,k=p$(s),A=(0,I.useMemo)(()=>{let e=c?c1(x):x;return L$(e,g0(e,O,k))},[x,c,O,k]),j=c,M=(0,I.useMemo)(()=>F$(A.map(e=>e.message),g0(A,O,k),p0).map(e=>{let t=A[e.messageIndex];return{...e,messageIndex:t.messageIndex,stampAt:o1(t)}}),[A,O,k]),N=(0,I.useMemo)(()=>IY(r),[r]),P=qq(s,E>=0?r[E]?.text:void 0),ee=cJ(s,E>=0?r[E]?.text:void 0),F=uJ(r,s?.providerError),te={thread:s,showWorking:j,registeredDone:P,restedCard:ee,errorVisible:F},ne=X1(te)!==null,re=(0,I.useMemo)(()=>Z1({thread:s,showWorking:j,registeredDone:P,restedCard:ee,errorVisible:F},A.map(e=>e.message)),[A,j,s,P,ee,F]),ie=(0,I.useMemo)(()=>{let e=[],t=new Map,n=r.length-1;for(let[i,a]of AJ(r,s?.questions??[],{atRest:!c})){if(i>=n){e.push(...a);continue}let r=-1;for(let e=0;e<M.length&&!(M[e].messageIndex>i);e++)r=e;let o=t.get(r);o?o.push(...a):t.set(r,[...a])}return{byRow:t,tail:e}},[M,r,c,s?.questions]),ae=(0,I.useMemo)(()=>NJ(r,s?.questions??[]),[r,s?.questions]),oe=(0,I.useMemo)(()=>{let e=[{key:`head-anchor`,kind:`head-anchor`}];u&&e.push({key:`transport-fallback`,kind:`transport-fallback`}),(m||g||_)&&e.push({key:`earlier-history:${h??`complete`}`,kind:`earlier-history`});let t=ie.byRow.get(-1);t&&e.push({key:`questions:head`,kind:`questions`,questions:t}),M.forEach((t,n)=>{e.push({...t,kind:`message`});let r=ie.byRow.get(n);r&&e.push({key:`questions:${t.key}`,kind:`questions`,questions:r})}),e.push({key:`interactions`,kind:`interactions`}),ne&&e.push({key:`runtime-status`,kind:`runtime-status`});let n=ne||M.length>0?14:0;return r.forEach((t,r)=>{if(!t.queued)return;let i=`queued:${t.deliveryId??t.sourceId??r}`;e.push({key:i,kind:`queued`,message:t,messageIndex:r,gap:n}),n=14}),e},[h,_,m,ne,g,M,r,ie,u]),se=jw({count:oe.length,getScrollElement:()=>t.current,getItemKey:e=>oe[e]?.key??e,estimateSize:e=>{let t=oe[e];return t?t.kind===`head-anchor`||t.kind===`interactions`?1:t.kind===`earlier-history`?42:t.kind===`transport-fallback`?76:t.kind===`runtime-status`?54:t.kind===`questions`?220:t.kind===`message`?108+t.gap:82+t.gap:80},overscan:8,paddingStart:20,paddingEnd:20,anchorTo:`end`,followOnAppend:!0,scrollEndThreshold:4,scrollToFn:(e,{adjustments:t,behavior:n},r)=>{let i=r.scrollElement;i&&i.scrollTo({top:t===void 0?e:i.scrollTop+t,behavior:n})}}),[ce,le]=(0,I.useState)(!0),ue=(0,I.useRef)(!0),de=(0,I.useRef)(-1),fe=(0,I.useRef)(0),pe=(0,I.useRef)(null),me=(0,I.useRef)(!1),he=(0,I.useRef)(!1),ge=(0,I.useRef)(!0),_e=(0,I.useRef)(null),ve=(0,I.useRef)(void 0),ye=(0,I.useRef)(null),be=(0,I.useRef)(void 0),xe=(0,I.useRef)(0),Se=(0,I.useCallback)(()=>{let e=t.current;if(e){let t=e.getBoundingClientRect().top,n=Array.from(e.querySelectorAll(`[data-transcript-source-id]`)).find(e=>e.getBoundingClientRect().bottom>t+1),r=n?.dataset.transcriptRowKey;n&&r&&(_e.current={rowKey:r,viewportTop:n.getBoundingClientRect().top-t})}v()},[v,t]),Ce=(0,I.useCallback)((e,n)=>{let r=t.current;if(!r)return;let i=Array.from(r.querySelectorAll(`[data-transcript-source-id]`)).find(t=>t.dataset.transcriptSourceId===e);i&&(r.scrollTop+=i.getBoundingClientRect().top-n)},[t]);(0,I.useLayoutEffect)(()=>{if(!n||oe.length===0||ve.current===n)return;ve.current=n,me.current=!1,he.current=!1,ge.current=!0;let t=ZE(e)?.candidates.map(e=>({candidate:e,index:oe.findIndex(t=>t.kind===`message`&&t.message.sourceId===e.sourceId)})).find(e=>e.index>=0),r=requestAnimationFrame(()=>{if(!t){se.scrollToEnd({behavior:`instant`}),le(!0),me.current=!0;return}se.scrollToIndex(t.index,{align:`start`,behavior:`instant`}),ue.current=!1,le(!1),me.current=!0;let e=performance.now()+K1;xe.current=e;let n=()=>{performance.now()>=e||performance.now()<fe.current||(Ce(t.candidate.sourceId,t.candidate.screenTop),r=requestAnimationFrame(n))};n()});return()=>cancelAnimationFrame(r)},[Ce,oe.length,e,n,se]),(0,I.useLayoutEffect)(()=>{let e=_e.current,n=t.current;if(!e||!n||g)return;let r=()=>{let t=Array.from(n.querySelectorAll(`[data-transcript-row-key]`)).find(t=>t.dataset.transcriptRowKey===e.rowKey);if(!t)return;let r=t.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTop+=r-e.viewportTop};r();let i=0,a=requestAnimationFrame(()=>{r(),i=requestAnimationFrame(()=>{r(),_e.current===e&&(_e.current=null)})});return()=>{cancelAnimationFrame(a),cancelAnimationFrame(i)}},[g,M.length,t]);let we=(0,I.useCallback)(()=>{let e=t.current;if(!e)return null;let n=e.getBoundingClientRect().top,r=Array.from(e.querySelectorAll(`[data-transcript-row-key]`)).find(e=>e.getBoundingClientRect().bottom>n+1),i=r?.dataset.transcriptRowKey;return!r||!i?null:{rowKey:i,viewportTop:r.getBoundingClientRect().top-n}},[t]),Te=(0,I.useCallback)(e=>{let n=t.current;if(!n)return;let r=Array.from(n.querySelectorAll(`[data-transcript-row-key]`)).find(t=>t.dataset.transcriptRowKey===e.rowKey);if(!r)return;let i=r.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTop+=i-e.viewportTop},[t]),Ee=M[0]?.key;(0,I.useLayoutEffect)(()=>{let e=be.current;if(be.current=Ee,e===void 0||e===Ee||!me.current||ue.current||_e.current)return;let t=ye.current;if(!t)return;Te(t);let n=()=>{if(performance.now()<fe.current)return;let e=ye.current;e&&Te(e)},r=0,i=requestAnimationFrame(()=>{n(),r=requestAnimationFrame(n)});return()=>{cancelAnimationFrame(i),cancelAnimationFrame(r)}},[Te,Ee]);let De=(0,I.useCallback)(()=>{let e=t.current;if(!e||_e.current||performance.now()<xe.current)return;let n=M$({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,previousScrollHeight:de.current,following:ue.current,readerMoved:performance.now()<fe.current});if(ue.current=n.following,n.scrollTop!==null&&(e.scrollTop=n.scrollTop),de.current=e.scrollHeight,le(e=>e===n.following?e:n.following),q1&&!n.following&&performance.now()>=fe.current){let t=ye.current,n=t&&Array.from(e.querySelectorAll(`[data-transcript-row-key]`)).find(e=>e.dataset.transcriptRowKey===t.rowKey);if(t&&n){let r=Math.round(n.getBoundingClientRect().top-e.getBoundingClientRect().top-t.viewportTop);Math.abs(r)>2&&console.warn(`[frizz] transcript moved ${r}px under a still reader — row=${t.rowKey}`)}}ye.current=we()??ye.current},[we,t]);(0,I.useLayoutEffect)(De),(0,I.useEffect)(()=>{let e=pe.current;if(!e)return;let t=new ResizeObserver(De);return t.observe(e),()=>t.disconnect()},[De]),(0,I.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{De();let t=N$({armed:ge.current,scrollTop:e.scrollTop,readerMoved:me.current&&he.current,hasEarlier:m,loading:g});ge.current=t.armed,t.shouldLoad&&Se()},r=()=>{he.current=!0,fe.current=performance.now()+G1,requestAnimationFrame(n)},i=t=>{[`ArrowUp`,`PageUp`,`Home`,` `].includes(t.key)&&(e.scrollTop<=480&&(ge.current=!0),r())},a=t=>{t.deltaY<0&&e.scrollTop<=480&&(ge.current=!0),r()},o=()=>{e.scrollTop<=480&&(ge.current=!0),r()};e.addEventListener(`scroll`,n,{passive:!0}),e.addEventListener(`wheel`,a,{passive:!0}),e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`pointerdown`,r,{passive:!0}),e.addEventListener(`keydown`,i);let s=requestAnimationFrame(n);return()=>{cancelAnimationFrame(s),e.removeEventListener(`scroll`,n),e.removeEventListener(`wheel`,a),e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,o),e.removeEventListener(`pointerdown`,r),e.removeEventListener(`keydown`,i)}},[m,g,Se,De,t]);let Oe=se.getVirtualItems(),ke=se.getTotalSize();return(0,L.jsxs)(`div`,{ref:pe,"data-virtualized-transcript":!0,"data-virtual-row-count":Oe.length,className:`relative w-full`,style:{height:ke},children:[Oe.map(t=>{let n=oe[t.index];return n?(0,L.jsx)(`div`,{ref:se.measureElement,"data-index":t.index,"data-transcript-row-key":n.key,"data-transcript-source-id":n.kind===`message`?n.message.sourceId:void 0,className:`absolute left-0 top-0 w-full hover:z-[1]`,style:{transform:`translateY(${t.start}px)`},children:n.kind===`head-anchor`?null:n.kind===`interactions`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(tQ,{thread:s,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(wQ,{thread:s,questions:ie.tail,inFlight:a,className:`px-6 pt-5`})]}):n.kind===`questions`?(0,L.jsx)(wQ,{thread:s,questions:n.questions,className:`px-6 pt-5`}):n.kind===`transport-fallback`?u?(0,L.jsx)(`div`,{className:`px-6 pt-3`,children:(0,L.jsxs)(`div`,{"data-transcript-sync-fallback":!0,className:`flex flex-wrap items-center gap-2.5 ${Yq} border border-border-strong bg-panel-2 px-4 py-2.5 text-[12px]`,title:u.kind===`payload-too-large`?`Live payload ${u.actualBytes} bytes; socket limit ${u.maxBytes} bytes`:`Transcript read budget reached (${u.scope}); retry after about ${u.retryAfterMs}ms`,children:[(0,L.jsx)(rh,{size:13,className:`shrink-0 text-muted`}),(0,L.jsxs)(`div`,{className:`min-w-[180px] flex-1 leading-snug text-fg/85`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Live transcript updates paused.`}),` `,u.kind===`payload-too-large`?`The transcript is too large for push; the last complete HTTP-loaded copy remains visible.`:`The live read budget was reached; the last complete copy remains visible. Retry in a moment.`]}),(0,L.jsx)(`button`,{type:`button`,disabled:d,onClick:f,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel disabled:opacity-40`,children:d?`Refreshing…`:`Refresh once`}),(0,L.jsx)(`button`,{type:`button`,onClick:p,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel`,children:`Retry live`})]})}):null:n.kind===`earlier-history`?(0,L.jsx)(`div`,{className:`flex min-h-10 items-center justify-center px-6 text-[11px] text-muted`,role:`status`,children:_?(0,L.jsxs)(`span`,{className:`flex flex-wrap items-center justify-center gap-2 text-center`,children:[(0,L.jsx)(`span`,{children:_}),(0,L.jsx)(`button`,{type:`button`,onClick:Se,className:`rounded-md border border-border px-2 py-1 text-fg/90 hover:bg-panel-2`,children:`Retry`})]}):g?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Mm,{size:12,className:`animate-spin`}),` Loading earlier messages…`]}):(0,L.jsx)(`button`,{type:`button`,onClick:Se,className:`rounded-md px-2 py-1 outline-none hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:`Load earlier messages`})}):n.kind===`message`?(0,L.jsx)(fZ,{at:n.stampAt,host:zY(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(t2,{m:n.message,answering:o(n.message),showSendButton:!0,paired:i[n.messageIndex],staleAwaiting:O>=0&&n.messageIndex<O,restingCardShown:n.messageIndex===E&&k,restedAt:D&&n.messageIndex===D.index?D.at??``:void 0,shadowedBy:ae.get(n.messageIndex),thread:s})}):n.kind===`runtime-status`?(0,L.jsxs)(`div`,{className:`px-6`,style:{paddingTop:re},children:[(0,L.jsx)(Q1,{state:te,slug:e,retryText:N>=0?r[N]?.text:void 0,onTerminal:l,liveRuntimeStart:T,liveActivityLabel:w,liveToolRun:S}),s?.permPolicy?(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(f2,{policy:s.permPolicy,denies:s.permDenies})}):null]}):(0,L.jsx)(fZ,{at:n.message.at,host:zY(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(t2,{m:n.message,paired:i[n.messageIndex]})})},n.key):null}),(0,L.jsx)(e0,{overlay:y,hidden:ce,onJump:()=>se.scrollToEnd({behavior:`smooth`})})]})}function e0({overlay:e,hidden:t,onJump:n}){return!e||t?null:(0,ot.createPortal)((0,L.jsxs)(`button`,{type:`button`,"data-jump-to-latest":!0,onClick:n,className:`flex items-center gap-1.5 rounded-full border border-border-strong bg-elevated px-3 py-1.5 text-[11px] font-medium text-fg shadow-lg shadow-black/30 hover:bg-panel-2`,children:[(0,L.jsx)(qp,{size:12}),`Jump to latest`]}),e)}function t0({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1}){let i=Dp(kC(),e),a=it({mutationFn:()=>Y.markComplete({slug:e})}),o=it({mutationFn:t=>Y.renameThread({slug:e,title:t})}),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(``),d=(0,I.useRef)(null);(0,I.useEffect)(()=>{if(!s)return;let e=requestAnimationFrame(()=>{d.current?.focus(),d.current?.select()});return()=>cancelAnimationFrame(e)},[s]),(0,I.useEffect)(()=>{c(!1),u(``)},[e]);let f=rK(nt({queryKey:[`threadBody`,e],queryFn:()=>Y.threadBody({slug:e})}).data?.markdown??``).trim().length>0;if(!i)return null;let p=i.kind===`session`&&i.foreign!==!0,m=i.foreign===!0,h=i.kind===`session`&&!m,g=aT(i);function _(){c(!1),u(``)}function v(){let e=UY(l,g);if(c(!1),!e){u(``);return}o.mutate(e,{onSuccess:()=>{u(``),Z(`Thread renamed`)},onError:t=>{u(e),c(!0),Z(t instanceof Error?t.message:`Could not rename thread`)}})}return(0,L.jsxs)(`header`,{"data-thread-header":!0,className:KY,children:[(0,L.jsx)(`div`,{className:qY,children:(0,L.jsxs)(`div`,{className:`min-w-0 leading-tight`,children:[(0,L.jsxs)(`div`,{className:`group/thread-title flex min-w-0 items-center gap-2`,children:[s?(0,L.jsx)(`input`,{ref:d,"aria-label":`Thread title`,value:l,maxLength:200,onChange:e=>u(e.target.value),onBlur:v,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),v()):e.key===`Escape`&&(e.preventDefault(),_())},className:`min-w-0 flex-1 rounded-md border border-border bg-elevated px-1.5 py-1 font-semibold text-[15px] text-fg outline-none focus:border-accent`}):h?(0,L.jsx)(`button`,{type:`button`,title:`Edit title`,"aria-label":`Edit thread title: ${g}`,disabled:o.isPending,onClick:()=>{u(WY(g,i.id)),c(!0)},className:`min-w-0 max-w-full shrink truncate rounded px-0.5 -mx-0.5 font-semibold text-[15px] text-left outline-none transition-colors hover:bg-panel-2 focus-visible:ring-1 focus-visible:ring-fg/60 disabled:cursor-not-allowed disabled:opacity-40`,children:g}):(0,L.jsx)(`div`,{className:`min-w-0 max-w-full shrink truncate px-0.5 -mx-0.5 font-semibold text-[15px]`,title:g,children:g}),(0,L.jsx)(eZ,{thread:i,hidden:s})]}),(0,L.jsx)(x$,{at:gT(i),fallbackAt:i.spawnedAt,className:`mt-0.5 block truncate text-[11px] leading-tight text-muted/75`})]})}),(0,L.jsxs)(`div`,{className:JY,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[p&&(0,L.jsx)(j$,{slug:e}),(0,L.jsx)(yX,{thread:i,collapse:r,onDoc:f?()=>$f(`doc`,i.id):void 0,onDone:()=>a.mutate(void 0,{onSuccess:t}),doneBusy:a.isPending,onStatusApplied:t}),n&&(0,L.jsx)(zj,{slug:e})]}),n&&(0,L.jsx)(`button`,{type:`button`,"aria-label":`Close`,"data-dialog-initial-focus":!0,onClick:n,className:`ml-0.5 shrink-0 rounded-md p-1.5 text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg`,children:(0,L.jsx)(ah,{size:15})})]})]})}function n0(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||aZ(e))return null;if(e.parts&&e.parts.length>0){for(let t=e.parts.length-1;t>=0;t--){let n=e.parts[t];if(n.kind===`tools`?n.tools.length>0:n.text.trim())return n.kind===`tools`?n.tools:null}return null}return(e.tools?.length??0)>0&&!e.text.trim()?e.tools:null}function r0(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||aZ(e))return null;if(e.parts&&e.parts.length>0){for(let t of e.parts)if(t.kind===`tools`?t.tools.length>0:t.text.trim())return t.kind===`tools`?t.tools:null;return null}return(e.tools?.length??0)>0?e.tools:null}function i0(e){return n0(e)!==null}function a0(e){return r0(e)!==null}function o0(e){return e.kind===`event`&&!e.boundary||e.kind===`reasoning`}function s0(e){return o0(e)||i0(e)}function c0(e){return o0(e)||a0(e)}function l0(e){if(o0(e))return!0;let t=n0(e);return t!==null&&!H$(t[t.length-1])}function u0(e){if(o0(e))return!0;let t=r0(e);return t!==null&&!H$(t[0])}function d0(e){let t=n0(e);return t!==null&&W$(t[t.length-1])}function f0(e){let t=r0(e);return t!==null&&W$(t[0])}function p0(e,t){let n=d0(e)||f0(t),r=!n&&s0(e)&&c0(t)&&!(l0(e)&&u0(t));return(n?22:r?6:14)+(e.role===`user`&&t.role!==`user`?3:0)}function m0(e,t){return e.kind===`event`||e.kind===`reasoning`||e.role===`user`?!1:e.parts&&e.parts.length>0?e.parts.every(n=>n.kind===`tools`?n.tools.length===0:_0(e,n.text,t)):(e.tools?.length??0)===0&&_0(e,e.text,t)}function h0(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`&&e[t].kind!==`event`)return t;return-1}function g0(e,t,n=!1){let r=new WeakSet;if(t>=0)for(let n of e)n.messageIndex<t&&r.add(n.message);if(t>=0&&n)for(let n of e)n.messageIndex===t&&r.add(n.message);return e=>m0(e,r.has(e))}function _0(e,t,n){return!e.fenceRefused&&!n?!t.trim():Kq(t).every(e=>e.kind===`fence`&&e.fenceKind===`awaiting`)}function v0(e,t){return e.kind===`event`||e.kind===`reasoning`||e.role===`user`?!1:e.parts&&e.parts.length>0?e.parts.some(n=>n.kind===`text`&&!_0(e,n.text,t)):typeof e.text==`string`&&!_0(e,e.text,t)}function y0(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.queued||m0(n)))return d0(n)?22:s0(n)&&!l0(n)?6:14+(n.role===`user`?3:0)}return 0}function b0(e,t,n){let r=[],i=null;return e.forEach((e,a)=>{n?.(e,a)||m0(e)||(i!==null&&r.push((0,L.jsx)(BJ,{h:p0(i,e)},`s${a}`)),r.push(t(e,a)),i=e)}),r}function x0(e){let t=[];for(let n of e){if(n.kind===`text`){if(!n.text.trim())continue;t.push(n);continue}if(n.tools.length===0)continue;let e=t[t.length-1];e&&e.kind===`tools`?t[t.length-1]={kind:`tools`,tools:[...e.tools,...n.tools]}:t.push(n)}return t}function S0(e,t=14){let n=e.filter(e=>e!=null&&e!==!1),r=[];return n.forEach((e,n)=>{n>0&&r.push((0,L.jsx)(BJ,{h:typeof t==`number`?t:t(n)},`vs${n}`)),r.push(e)}),r}var C0={head:!1,tail:!1};function w0(e,t){return n=>e[n-1]?.tail||e[n]?.head?22:t}function T0(e){return{head:W$(e[0]),tail:W$(e[e.length-1])}}function E0(e){let t=[];for(let n of e){let e=t[t.length-1];if(n.edit){let r=!!(n.input||n.output||n.status||n.exitCode!==void 0);e&&e.edits&&!r&&!e.input&&!e.output&&!e.status&&e.edits[0].file===n.edit.file?e.edits.push(n.edit):t.push({name:n.name,detail:n.detail,edits:[n.edit],input:n.input,output:n.output,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1})}else n.command?t.push({name:n.name,detail:n.detail,command:n.command,desc:n.desc,input:n.input,output:n.output,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1}):n.outputImage?t.push({name:n.name,detail:n.detail,outputImage:n.outputImage,output:n.output??n.read,status:n.status,durationMs:n.durationMs,count:1}):n.read?t.push({name:n.name,detail:n.detail,read:n.read,status:n.status,durationMs:n.durationMs,count:1}):n.prompt||n.agentId?t.push({name:n.name,detail:n.detail,prompt:n.prompt,input:n.input,subagentType:n.subagentType,agentId:n.agentId,agentStatus:n.agentStatus,agentElapsedMs:n.agentElapsedMs,output:n.output,status:n.status,durationMs:n.durationMs,count:1}):n.sendTo!==void 0||n.sendBody!==void 0?t.push({name:n.name,detail:n.detail,sendTo:n.sendTo,sendSummary:n.sendSummary,sendBody:n.sendBody,sendType:n.sendType,sendDispatchId:n.sendDispatchId,sendTargetLabel:n.sendTargetLabel,status:n.status,durationMs:n.durationMs,count:1}):n.todos?t.push({name:n.name,detail:n.detail,todos:n.todos,input:n.input,status:n.status,durationMs:n.durationMs,count:1}):U$(n)?t.push({name:n.name,detail:n.detail,ask:n.ask,askAnswers:n.askAnswers,status:n.status,durationMs:n.durationMs,count:1}):n.sentImages||n.sentFiles?t.push({name:n.name,detail:n.detail,sentImages:n.sentImages,sentFiles:n.sentFiles,caption:n.caption,status:n.status,durationMs:n.durationMs,count:1}):n.input||n.output?t.push({name:n.name,detail:n.detail,input:n.input,output:n.output,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1}):e&&!e.edits&&!e.command&&!e.input&&!e.output&&!e.read&&!e.prompt&&!e.outputImage&&!e.sentImages&&!e.sentFiles&&e.sendTo===void 0&&e.sendBody===void 0&&e.name===n.name&&e.detail===n.detail&&e.status===n.status&&e.backgroundState===n.backgroundState&&e.exitCode===n.exitCode&&e.cwd===n.cwd&&e.sessionId===n.sessionId&&e.durationMs===n.durationMs?e.count++:t.push({name:n.name,detail:n.detail,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1})}return t}function D0(e){return e.split(`__`).pop()||e}function O0(e){let t=X.board?.projectDir;return t&&e.startsWith(t+`/`)?e.slice(t.length+1):e}function k0({tools:e,at:t}){let[n,r]=(0,I.useState)(!1),i=(0,I.useId)(),a=e.reduce((e,t)=>e+t.count,0),o=_1(a,g1(e));return(0,L.jsxs)(`div`,{"data-tool-activity":!0,"data-tool-activity-state":`settled`,className:`flex min-w-0 flex-col`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":i,"aria-expanded":n,"aria-label":`${n?`Collapse`:`Expand`} ${a} tool ${a===1?`call`:`calls`}: ${o}`,className:`group flex w-full min-w-0 items-baseline gap-1.5 rounded py-0.5 text-left outline-none transition-colors hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60 ${pZ}`,children:[(0,L.jsx)(`span`,{"data-tool-activity-label":!0,title:o,className:`min-w-0 truncate text-muted`,children:o}),(0,L.jsx)(tm,{"data-tool-activity-chevron":!0,"aria-hidden":`true`,size:13,className:hZ(n)})]}),n&&(0,L.jsx)(`div`,{id:i,className:`mt-1.5 flex flex-col`,children:S0(e.map((e,n)=>(0,L.jsx)(j0,{t:e,startedAt:t},n)),6)}),!n&&(0,L.jsx)(`div`,{id:i,hidden:!0})]})}function A0({tools:e,at:t}){let n=[];for(let t of e){let e=H$(t),r=n[n.length-1];r?.exceptional===e?r.tools.push(t):n.push({exceptional:e,tools:[t]})}return(0,L.jsx)(`div`,{className:`flex flex-col`,children:S0(n.map((e,n)=>e.exceptional?(0,L.jsx)(`div`,{className:`flex flex-col`,children:S0(e.tools.map((e,n)=>(0,L.jsx)(j0,{t:e,startedAt:t},n)),w0(e.tools.map(e=>T0([e])),6))},`exceptions-${n}`):(0,L.jsx)(k0,{tools:e.tools,at:t},`activity-${n}`)),w0(n.map(e=>T0(e.tools)),6))})}function j0({t:e,startedAt:t}){let n=(0,I.useContext)(I1),r=kC(),i=hE(e,(n?Dp(r,n):void 0)?.bgShells??[]);return e.edits&&e.status!==`failed`&&e.status!==`cancelled`?(0,L.jsx)($K,{edits:e.edits,meta:(0,L.jsx)(I0,{status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,durationMs:e.durationMs})}):e.command?(0,L.jsx)(W0,{command:e.command,desc:e.desc??e.detail,output:e.output,status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,sessionId:e.sessionId,durationMs:e.durationMs,startedAt:t}):e.outputImage?(0,L.jsx)(V0,{name:e.name,detail:e.detail,outputImage:e.outputImage,output:e.output,status:e.status,durationMs:e.durationMs}):e.read?(0,L.jsx)(K0,{detail:e.detail,read:e.read,status:e.status,durationMs:e.durationMs}):e.prompt||e.agentId?(0,L.jsx)(J0,{detail:e.detail,prompt:e.prompt,input:e.input,subagentType:e.subagentType,agentId:e.agentId,agentStatus:e.agentStatus,agentElapsedMs:e.agentElapsedMs,status:e.status,durationMs:e.durationMs,output:e.output}):e.sendTo!==void 0||e.sendBody!==void 0?(0,L.jsx)(X0,{to:e.sendTo,summary:e.sendSummary,body:e.sendBody??``,type:e.sendType,dispatchId:e.sendDispatchId,targetLabel:e.sendTargetLabel,status:e.status,durationMs:e.durationMs,at:t}):e.sentImages||e.sentFiles?(0,L.jsx)(H0,{images:e.sentImages??[],files:e.sentFiles??[],caption:e.caption,status:e.status,durationMs:e.durationMs}):e.todos?(0,L.jsx)(Sq,{todos:e.todos,note:e.input,meta:(0,L.jsx)(I0,{status:e.status,durationMs:e.durationMs})}):U$(e)?(0,L.jsx)(M0,{ask:e.ask??[],askAnswers:e.askAnswers}):e.input||e.output?(0,L.jsx)(W0,{name:e.name,command:e.input??``,desc:e.detail,output:e.output,status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,sessionId:e.sessionId,durationMs:e.durationMs,inputLabel:`input`,startedAt:t}):(0,L.jsx)(B0,{name:e.name,detail:e.detail,count:e.count,status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,cwd:e.cwd,sessionId:e.sessionId,durationMs:e.durationMs,startedAt:t})}function M0({ask:e,askAnswers:t}){return(0,L.jsx)(`div`,{"data-settled-ask":!0,className:`flex flex-col gap-1.5`,children:e.map((e,n)=>{let r=ZZ(e,t?.[n]);return(0,L.jsx)(CY,{question:r.question,settled:{chosenIdxs:r.chosenIdxs,text:r.text}},n)})})}function N0({tone:e,indicator:t,label:n,duration:r,title:i}){return(0,L.jsxs)(`span`,{className:`petite-caps frizz-tool-header-caps flex shrink-0 items-center gap-1 whitespace-nowrap text-[11.5px] leading-none ${e}`,title:i,"aria-label":i,children:[t,(0,L.jsx)(`span`,{children:[n,r].filter(Boolean).join(` · `)})]})}function P0(e,t,n){let[r,i]=(0,I.useState)(()=>Date.now()),a=fE(e,t),o=pE(e,t,n,r);return(0,I.useEffect)(()=>{if(!a||o)return;let e=n?Date.parse(n):NaN;if(!Number.isFinite(e))return;let t=setTimeout(()=>i(Date.now()),Math.max(dE-(Date.now()-e),0));return()=>clearTimeout(t)},[a,o,n]),o}function F0({status:e,backgroundState:t,liveBackgroundState:n,startedAt:r}){let i=P0(e,t,r),a=n===`running`?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--shell`,"data-running-indicator":`tool-disclosure`}):n===`stale`?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot-quiet frizz-live-dot-quiet--shell`,"data-running-indicator":`tool-quiet`,title:jE}):uE(e,t)||i?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--shell`,"data-running-indicator":`tool-disclosure`}):null;return a?(0,L.jsx)(`span`,{className:`frizz-tool-mark -mr-1 flex w-[9px] shrink-0 justify-center`,children:a}):null}function I0({status:e,backgroundState:t,liveBackgroundState:n,exitCode:r,durationMs:i}){if(!e&&i===void 0)return null;let[a,o]=n===`running`?[`running`,`background running`]:n===`stale`?[`stale`,`background stale`]:e===`pending`?t===`unknown`?[`unknown`,`background / unknown`]:[`running`,t===`background`?`background running`:`running`]:e===`failed`?r===void 0?[`failed`,`failed`]:[`exit ${r}`,`exit ${r}`]:e===`cancelled`?[`cancelled`,`cancelled`]:e===`completed`?[`done`,`done`]:[void 0,void 0],s=i===void 0?void 0:gE(i),c=[o,s].filter(Boolean).join(` · `);return(0,L.jsx)(N0,{tone:e===`failed`?`frizz-tool-failed`:e===`cancelled`?`text-amber-400`:`text-muted/55`,title:c,label:a,duration:s})}function L0(e,t,n){let r=t?Date.parse(t):NaN,i=e===`pending`&&Number.isFinite(r),[a,o]=(0,I.useState)(()=>Date.now());return(0,I.useEffect)(()=>{if(!i)return;let e=()=>o(Date.now()),t,n=setTimeout(()=>{e(),t=setInterval(e,1e3)},1e3-Date.now()%1e3);return()=>{clearTimeout(n),t&&clearInterval(t)}},[i,t]),i?Math.max(a-r,0):n}function R0(e,t,n){let r=t&&t!==X.board?.projectDir?`in ${O0(t)}`:void 0;return[e,t?r:n!==void 0&&!e?.includes(String(n))?`session ${n}`:void 0].filter(Boolean).join(` · `)||void 0}function z0(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.includes(`…`)}function B0({name:e,detail:t,count:n,status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,cwd:s,sessionId:c,durationMs:l,startedAt:u}){let d=R0(t,s,c),f=d?O0(d):void 0,p=t&&z0(t)?t:void 0;return(0,L.jsx)(`div`,{className:`frizz-bash`,title:d,children:(0,L.jsxs)(`div`,{className:`frizz-bash-header`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(F0,{status:r,backgroundState:i,liveBackgroundState:a,startedAt:u}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:D0(e)}),f&&(p?(0,L.jsx)(`span`,{className:`min-w-0 truncate`,onClick:e=>e.stopPropagation(),children:(0,L.jsx)(ZK,{path:p,className:`text-[11.5px] text-muted`,children:f})}):(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:f}))]}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,L.jsx)(I0,{status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,durationMs:l}),n>1&&(0,L.jsxs)(`span`,{className:`tabular-nums text-[11px] text-muted/45`,children:[`×`,n]})]})]})})}function V0({name:e,detail:t,outputImage:n,output:r,status:i,durationMs:a}){let o=t?O0(t):void 0,s=(0,L.jsxs)(`div`,{className:`frizz-bash-header`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:D0(e)}),o&&(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,title:t,children:o})]}),(0,L.jsx)(`span`,{className:`flex shrink-0 items-center gap-2`,children:(0,L.jsx)(I0,{status:i,durationMs:a})})]});return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(r2,{path:n,hideCaption:!0,altText:o?`${D0(e)}: ${o}`:D0(e),header:s}),r&&(0,L.jsx)(`pre`,{className:`frizz-bash frizz-bash-body frizz-bash-output-body mt-1.5`,children:r})]})}function H0({images:e,files:t,caption:n,status:r,durationMs:i}){let[a,o]=(0,I.useState)(!0),s=(0,I.useId)(),c=[e.length?`${e.length} image${e.length===1?``:`s`}`:``,t.length?`${t.length} file${t.length===1?``:`s`}`:``].filter(Boolean).join(` · `);return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":s,"aria-expanded":a,"aria-label":`${a?`Collapse`:`Expand`} files sent to you${c?`: ${c}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/60`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Sent to you`}),c&&(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:c})]}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,L.jsx)(I0,{status:r,durationMs:i}),(0,L.jsx)(tm,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${a?`rotate-90`:``}`})]})]}),(0,L.jsx)(`div`,{id:s,hidden:!a,children:a&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-2.5 pb-2.5 pt-1.5`,children:[e.map((e,t)=>(0,L.jsx)(r2,{path:e,hideCaption:!0,altText:n??`delivered image`},`i${t}`)),t.length>0&&(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map((e,t)=>(0,L.jsx)(i2,{path:e},`f${t}`))}),n&&(0,L.jsx)(`div`,{className:`max-w-[65%] text-[12px] leading-snug text-muted`,children:n})]})})]})}var U0=16;function W0({command:e,desc:t,output:n,name:r=`Bash`,status:i,backgroundState:a,liveBackgroundState:o,exitCode:s,sessionId:c,durationMs:l,inputLabel:u,startedAt:d}){let[f,p]=(0,I.useState)(!1),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(!1),v=(0,I.useId)(),y=L0(i,d,l),b=(0,I.useMemo)(()=>e.split(`
314
314
  `).length,[e]),x=b>U0,S=(0,I.useMemo)(()=>n?n.split(`
315
315
  `).length:0,[n]),C=S>U0,w=R0(t,void 0,c),T=!!(e||n);return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>T&&p(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":T?v:void 0,"aria-expanded":T?f:void 0,"aria-label":`${T?`${f?`Collapse`:`Expand`} `:``}${D0(r)}${w?`: ${w}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/60`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(F0,{status:i,backgroundState:a,liveBackgroundState:o,startedAt:d}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:D0(r)}),(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,title:w,children:w??``})]}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,L.jsx)(I0,{status:i,backgroundState:a,liveBackgroundState:o,exitCode:s,durationMs:y}),T&&(0,L.jsx)(tm,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${f?`rotate-90`:``}`})]})]}),T&&(0,L.jsxs)(`div`,{id:v,hidden:!f,children:[f&&e&&(0,L.jsxs)(L.Fragment,{children:[u&&(0,L.jsx)(`div`,{className:`frizz-bash-output-label petite-caps`,children:u}),(0,L.jsx)(gq,{text:e,language:u?`plaintext`:`bash`,className:`frizz-bash-body${u?` frizz-bash-output-body`:``}${x&&!m?` frizz-bash-clamp`:``}`}),x&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>h(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:m?`Collapse`:`Show all ${b} lines`})]}),f&&n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`frizz-bash-output-label petite-caps`,children:`output`}),(0,L.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body${C&&!g?` frizz-bash-clamp`:``}`,children:n}),C&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>_(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:g?`Collapse`:`Show all ${S} lines`})]})]})]})}var G0=16;function K0({detail:e,read:t,status:n,durationMs:r}){let[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(!1),c=(0,I.useId)(),l=(0,I.useMemo)(()=>t.split(`
316
316
  `).length,[t]),u=l>G0,d=e?O0(e):void 0,f=e&&z0(e)?e:void 0;return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(XK,{className:`frizz-bash-header`,controls:c,expanded:i,label:`${i?`Collapse`:`Expand`} Read${e?`: ${e}`:``}`,onToggle:()=>a(e=>!e),meta:(0,L.jsx)(I0,{status:n,durationMs:r}),children:[(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Read`}),d&&(f?(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,L.jsx)(ZK,{path:f,className:`text-[11.5px] text-muted`,children:d})}):(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:d}))]}),(0,L.jsx)(`div`,{id:c,hidden:!i,children:i&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(gq,{text:t,language:lS(e),className:`frizz-bash-body${u&&!o?` frizz-bash-clamp`:``}`}),u&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:o?`Collapse`:`Show all ${l} lines`})]})})]})}var q0=16;function J0({detail:e,prompt:t,input:n,subagentType:r,agentId:i,agentStatus:a,agentElapsedMs:o,status:s,durationMs:c,output:l}){let[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(!1),m=(0,I.useId)(),h=t??n,g=(0,I.useMemo)(()=>h?h.split(`