frizz 0.12.12 → 0.12.13

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/package.json +1 -1
  2. package/web-dist/assets/{TerminalPane-CTuT1746.js → TerminalPane-Cv0c_SNS.js} +1 -1
  3. package/web-dist/assets/{abnfDiagram-VRR7QNED-C9lXEgoU.js → abnfDiagram-VRR7QNED-B-wED8ht.js} +1 -1
  4. package/web-dist/assets/architecture-TIHT7OUA-nsH-QfGr.js +1 -0
  5. package/web-dist/assets/{architectureDiagram-ZJ3FMSHR-BmJyQxby.js → architectureDiagram-ZJ3FMSHR-kHm_O2sR.js} +1 -1
  6. package/web-dist/assets/{blockDiagram-677ZJIJ3-DYTepy7i.js → blockDiagram-677ZJIJ3-CdazUaKU.js} +1 -1
  7. package/web-dist/assets/{c4Diagram-LMCZKHZV-CNaJlw58.js → c4Diagram-LMCZKHZV-rauLKZbJ.js} +1 -1
  8. package/web-dist/assets/channel-fvwjeUt3.js +1 -0
  9. package/web-dist/assets/{chunk-32BRIVSS-uAMm81q2.js → chunk-32BRIVSS-DjOqyEDX.js} +1 -1
  10. package/web-dist/assets/{chunk-52WLFC77-DjszZCE7.js → chunk-52WLFC77-f1SThegZ.js} +1 -1
  11. package/web-dist/assets/{chunk-C7G6YPKG-BuHoup14.js → chunk-C7G6YPKG-BfQsesjz.js} +1 -1
  12. package/web-dist/assets/{chunk-EX3LRPZG-Bg9UEQvR.js → chunk-EX3LRPZG-BIzZW7OQ.js} +1 -1
  13. package/web-dist/assets/{chunk-FWX5IMBZ-CHnQfTLw.js → chunk-FWX5IMBZ-CATINZFC.js} +2 -2
  14. package/web-dist/assets/{chunk-HOUHSVGY-ByjeQLq2.js → chunk-HOUHSVGY-DbMBRCCE.js} +1 -1
  15. package/web-dist/assets/{chunk-ICXQ74PX-DeM9b_DJ.js → chunk-ICXQ74PX-COcoSWx4.js} +1 -1
  16. package/web-dist/assets/{chunk-MOJQB5TN-DxLERy2q.js → chunk-MOJQB5TN-CVnI-o_4.js} +1 -1
  17. package/web-dist/assets/{chunk-OGEWGWER-sBPjsAxh.js → chunk-OGEWGWER-U0vdZqB6.js} +1 -1
  18. package/web-dist/assets/{chunk-PUDLZKDR-CarEdLd9.js → chunk-PUDLZKDR-Bukb7rem.js} +1 -1
  19. package/web-dist/assets/{chunk-Q4XR5HBZ-BfXpvkfr.js → chunk-Q4XR5HBZ-Bl019PHd.js} +1 -1
  20. package/web-dist/assets/{chunk-V7JOEXUC-B3FaJqr_.js → chunk-V7JOEXUC-YJR0vzI6.js} +1 -1
  21. package/web-dist/assets/{chunk-VAUOI2AC-DHsDLPEL.js → chunk-VAUOI2AC-CK6NU9kj.js} +1 -1
  22. package/web-dist/assets/{chunk-VR4S4FIN-ObNNjO-z.js → chunk-VR4S4FIN-B3LBv3C3.js} +1 -1
  23. package/web-dist/assets/{chunk-WYO6CB5R-JZxgPfBf.js → chunk-WYO6CB5R-DjRPyRuS.js} +1 -1
  24. package/web-dist/assets/{chunk-ZGVPDNZ5-rLSAye5U.js → chunk-ZGVPDNZ5-BUJCayKP.js} +1 -1
  25. package/web-dist/assets/classDiagram-OUVF2IWQ-BRZQ_xnN.js +1 -0
  26. package/web-dist/assets/classDiagram-v2-EOCWNBFH-BRZQ_xnN.js +1 -0
  27. package/web-dist/assets/{cynefin-VYW2F7L2-B0-Xy-xW.js → cynefin-VYW2F7L2-CE3ce51v.js} +1 -1
  28. package/web-dist/assets/{cynefinDiagram-TSTJHNR4-Dd3QCTMp.js → cynefinDiagram-TSTJHNR4-DSXSPZQV.js} +1 -1
  29. package/web-dist/assets/{dagre-VKFMJZFB-c_sDjRhh.js → dagre-VKFMJZFB-VwBQdjum.js} +1 -1
  30. package/web-dist/assets/{diagram-FQU43EPY-DlrOA7Q2.js → diagram-FQU43EPY-7Tf5_WDu.js} +1 -1
  31. package/web-dist/assets/{diagram-G47NLZAW-DNwGdtwN.js → diagram-G47NLZAW-mu4aclWA.js} +1 -1
  32. package/web-dist/assets/{diagram-NH7WQ7WH-CPNunIAd.js → diagram-NH7WQ7WH-B3kAVNwv.js} +1 -1
  33. package/web-dist/assets/{diagram-OA4YK3LP-BZVJWnon.js → diagram-OA4YK3LP-DAaV-2ou.js} +1 -1
  34. package/web-dist/assets/{diagram-WEI45ONY-B8UEevkd.js → diagram-WEI45ONY-DijPfgly.js} +1 -1
  35. package/web-dist/assets/{ebnfDiagram-CCIWWBDH-BGCxDQf1.js → ebnfDiagram-CCIWWBDH-B1o42Wp-.js} +1 -1
  36. package/web-dist/assets/{erDiagram-Q63AITRT-CKnUuelS.js → erDiagram-Q63AITRT-Dqej9Wi3.js} +1 -1
  37. package/web-dist/assets/eventmodeling-45OFAUF4-B8xeGcXU.js +1 -0
  38. package/web-dist/assets/flowDiagram-23GEKE2U-Cnyfcz6Z.js +1 -0
  39. package/web-dist/assets/{ganttDiagram-NO4QXBWP-2-k1ZZhN.js → ganttDiagram-NO4QXBWP-UoyrLPUT.js} +1 -1
  40. package/web-dist/assets/{gitGraph-TEB2WS4Q-Ci3lt5M_.js → gitGraph-TEB2WS4Q-CwjIwQ3T.js} +1 -1
  41. package/web-dist/assets/{gitGraphDiagram-IHSO6WYX-B_AQwuvk.js → gitGraphDiagram-IHSO6WYX-BxU758_g.js} +1 -1
  42. package/web-dist/assets/index-CT6k_A5y.css +1 -0
  43. package/web-dist/assets/{index-D5VGTEZg.js → index-k8HCkyvh.js} +4 -4
  44. package/web-dist/assets/{info-DKCQHKI2-m3mT757b.js → info-DKCQHKI2-CWtSI6aK.js} +1 -1
  45. package/web-dist/assets/{infoDiagram-FWYZ7A6U-CQw6f3Hj.js → infoDiagram-FWYZ7A6U-n5xRfy_d.js} +1 -1
  46. package/web-dist/assets/{ishikawaDiagram-FXEZZL3T-C-7JgXGg.js → ishikawaDiagram-FXEZZL3T-DU1LTQY-.js} +1 -1
  47. package/web-dist/assets/{journeyDiagram-5HDEW3XC-DhPxGm-x.js → journeyDiagram-5HDEW3XC-BzZWHoPv.js} +1 -1
  48. package/web-dist/assets/{kanban-definition-HUTT4EX6-pYAdpAN-.js → kanban-definition-HUTT4EX6-CeneyR7c.js} +1 -1
  49. package/web-dist/assets/{line-DtHJLrdk.js → line-DTfkLWnw.js} +1 -1
  50. package/web-dist/assets/{mermaid-parser.core-CiDWeD1W.js → mermaid-parser.core-CHzoJ5LT.js} +3 -3
  51. package/web-dist/assets/{mermaid.core-BIRnljFs.js → mermaid.core-Cl84DLN2.js} +3 -3
  52. package/web-dist/assets/{mindmap-definition-LN4V7U3C-AwCgXi_v.js → mindmap-definition-LN4V7U3C-C39sBNqB.js} +1 -1
  53. package/web-dist/assets/{packet-7NZHBO7P-CnOMRKg1.js → packet-7NZHBO7P-Bj73rlQn.js} +1 -1
  54. package/web-dist/assets/{pegDiagram-2B236MQR-KwEiKY6p.js → pegDiagram-2B236MQR-BEEM1vSv.js} +1 -1
  55. package/web-dist/assets/{pie-RZYD4A2V-BXVw5n_F.js → pie-RZYD4A2V-CJ-fEfdy.js} +1 -1
  56. package/web-dist/assets/{pieDiagram-ENE6RG2P-BKeGzq7n.js → pieDiagram-ENE6RG2P-Dcqj3oyh.js} +1 -1
  57. package/web-dist/assets/{quadrantDiagram-ABIIQ3AL-_B_KnoiC.js → quadrantDiagram-ABIIQ3AL-D5cljQ3D.js} +1 -1
  58. package/web-dist/assets/{radar-I7S5WNFK-BDV-2CJh.js → radar-I7S5WNFK-G8JqqGPf.js} +1 -1
  59. package/web-dist/assets/{railroad-3IZDKUUU-CJLCawbl.js → railroad-3IZDKUUU-CaGNL0iN.js} +1 -1
  60. package/web-dist/assets/railroad-abnf-AHOZXSZD-DWZmdy-r.js +1 -0
  61. package/web-dist/assets/railroad-ebnf-EBAXGLYW-C-XoPuo_.js +1 -0
  62. package/web-dist/assets/railroad-peg-LSFZ7HO6-BGpxqg46.js +1 -0
  63. package/web-dist/assets/{railroadDiagram-RFXS5EU6-BVV6ZmA7.js → railroadDiagram-RFXS5EU6-BZGZXMY4.js} +1 -1
  64. package/web-dist/assets/{requirementDiagram-TGXJPOKE-D3JoXNiN.js → requirementDiagram-TGXJPOKE-Dj5yn_9e.js} +1 -1
  65. package/web-dist/assets/{sankeyDiagram-HTMAVEWB-D7r0TcuX.js → sankeyDiagram-HTMAVEWB-7iJ_NDNf.js} +1 -1
  66. package/web-dist/assets/{sequenceDiagram-DBY2YBRQ-B35koHCj.js → sequenceDiagram-DBY2YBRQ-Bl54CknA.js} +1 -1
  67. package/web-dist/assets/{stateDiagram-2N3HPSRC-DrFIFrPb.js → stateDiagram-2N3HPSRC-DuvjeNgJ.js} +1 -1
  68. package/web-dist/assets/stateDiagram-v2-6OUMAXLB-BR-vrMgH.js +1 -0
  69. package/web-dist/assets/{swimlanes-5IMT3BWC-D14gjDvr.js → swimlanes-5IMT3BWC-B7-Jj4Sk.js} +1 -1
  70. package/web-dist/assets/swimlanesDiagram-G3AALYLV-C1HvMf2k.js +8 -0
  71. package/web-dist/assets/{timeline-definition-FHXFAJF6-DYuBi6LS.js → timeline-definition-FHXFAJF6-jsey2pEG.js} +1 -1
  72. package/web-dist/assets/{treeView-QDETBFTQ-DWCgtuaU.js → treeView-QDETBFTQ-DhPmOzHr.js} +1 -1
  73. package/web-dist/assets/{treemap-6X3UGDF4-QuJpQ-gt.js → treemap-6X3UGDF4-Dw2IaXqK.js} +1 -1
  74. package/web-dist/assets/{vennDiagram-L72KCM5P-BgtM82oJ.js → vennDiagram-L72KCM5P-CXKZkBab.js} +1 -1
  75. package/web-dist/assets/{wardley-OPB4EBWU-CWh_aioC.js → wardley-OPB4EBWU-CTCdDwyE.js} +1 -1
  76. package/web-dist/assets/{wardleyDiagram-EHGQE667-BNWSkBva.js → wardleyDiagram-EHGQE667-B1w0xIqB.js} +1 -1
  77. package/web-dist/assets/{xychartDiagram-FW5EYKEG-Bc6i6hg5.js → xychartDiagram-FW5EYKEG-gULk-uIl.js} +1 -1
  78. package/web-dist/index.html +2 -2
  79. package/web-dist/assets/architecture-TIHT7OUA-cPNCo9oK.js +0 -1
  80. package/web-dist/assets/channel-D5dgm6BA.js +0 -1
  81. package/web-dist/assets/classDiagram-OUVF2IWQ-Bj_Hjv7y.js +0 -1
  82. package/web-dist/assets/classDiagram-v2-EOCWNBFH-Bj_Hjv7y.js +0 -1
  83. package/web-dist/assets/eventmodeling-45OFAUF4-DvqeSNur.js +0 -1
  84. package/web-dist/assets/flowDiagram-23GEKE2U-DT_LFo10.js +0 -1
  85. package/web-dist/assets/index-CSVjp00Q.css +0 -1
  86. package/web-dist/assets/railroad-abnf-AHOZXSZD-BLgEAPud.js +0 -1
  87. package/web-dist/assets/railroad-ebnf-EBAXGLYW-Czt3Iqq1.js +0 -1
  88. package/web-dist/assets/railroad-peg-LSFZ7HO6-HPyLt5Zu.js +0 -1
  89. package/web-dist/assets/stateDiagram-v2-6OUMAXLB-D57MsDPe.js +0 -1
  90. package/web-dist/assets/swimlanesDiagram-G3AALYLV-DC2nRhL8.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPane-CTuT1746.js","assets/rolldown-runtime-Bh1tDfsg.js","assets/mermaid.core-BIRnljFs.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-C4XfhTaE.js","assets/chunk-WYO6CB5R-JZxgPfBf.js","assets/chunk-ICXQ74PX-DeM9b_DJ.js","assets/dist-DoH_9pyS.js","assets/chunk-VAUOI2AC-DHsDLPEL.js","assets/chunk-HOUHSVGY-ByjeQLq2.js","assets/chunk-Q4XR5HBZ-BfXpvkfr.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-sBPjsAxh.js","assets/chunk-C7G6YPKG-BuHoup14.js","assets/chunk-ZGVPDNZ5-rLSAye5U.js","assets/rough.esm-CSKSodPl.js","assets/chunk-52WLFC77-DjszZCE7.js","assets/line-DtHJLrdk.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-FWX5IMBZ-CHnQfTLw.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-Cv0c_SNS.js","assets/rolldown-runtime-Bh1tDfsg.js","assets/mermaid.core-Cl84DLN2.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-C4XfhTaE.js","assets/chunk-WYO6CB5R-DjRPyRuS.js","assets/chunk-ICXQ74PX-COcoSWx4.js","assets/dist-DoH_9pyS.js","assets/chunk-VAUOI2AC-CK6NU9kj.js","assets/chunk-HOUHSVGY-DbMBRCCE.js","assets/chunk-Q4XR5HBZ-Bl019PHd.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-U0vdZqB6.js","assets/chunk-C7G6YPKG-BfQsesjz.js","assets/chunk-ZGVPDNZ5-BUJCayKP.js","assets/rough.esm-CSKSodPl.js","assets/chunk-52WLFC77-f1SThegZ.js","assets/line-DTfkLWnw.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-FWX5IMBZ-CATINZFC.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),np._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(`
@@ -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=>zL(n,e.token))?null:{body:n,items:i}}function ZL(e){return e.key===`Enter`&&!e.altKey&&!e.shiftKey&&!e.isComposing&&e.keyCode!==229}function QL(e,t){return t&&ZL(e)&&!e.metaKey&&!e.ctrlKey}function $L(e,t){return t&&ZL(e)&&(e.metaKey||e.ctrlKey)}function eR(e){return ZL(e)}function tR(e){return e.key===`Enter`&&e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing}function nR(e,t,n){return e===`queueComposer`&&t===`Enter`&&n}var rR=`gap-3`,iR=`-mx-1`,aR=`-mx-[3px]`,oR=`right-2`,sR=`right-[71px]`,cR=`right-[44px]`,lR=`pr-[6.6875rem]`,uR=`pr-20`;async function dR(e,t){let n=Id(),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 fR={project:`project`,user:`global`,builtin:`built-in`,plugin:`plugin`};function pR(e,t){e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,t)}px`}function mR({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)(()=>NL(e),[e]),w=C.map(e=>e.path),T=(0,I.useRef)(e);T.current=e;let E=e=>t(PL(e,w)),D=e=>t(PL(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 dR(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=NL(T.current);t(PL(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||pR(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=UL(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(fR[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=UL(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(nR(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(QL(i,a)){e.preventDefault(),e.stopPropagation(),n();return}if($L(i,a)){e.preventDefault(),e.stopPropagation(),(m??n)();return}if(tR(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?fR[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?lR:uR}`} 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)(hR,{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?sR:cR} 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)(Xm,{size:15,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(ih,{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 ${oR} 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)(Xm,{size:14,strokeWidth:2.5,className:`animate-spin`}):(0,L.jsx)(fm,{size:14,strokeWidth:2.5})})]})}function hR({attachment:e,disabled:t,onRemove:n}){let[r,i]=(0,I.useState)(!1),a=Qf(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:YS(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)(Pm,{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)(Ch,{size:10,strokeWidth:2.5})})]})}function gR(){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 _R(){let e=gR();return!!(e.data?.inRepo&&e.data.authed)}function vR({className:e=``}){return _R()?(0,L.jsx)(`button`,{type:`button`,onClick:lp,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)(Hm,{size:15,strokeWidth:2})}):null}var yR=`prompt-control-type petite-caps`,bR=yR,xR=yR,SR=`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 ${bR} 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 CR(e){return`minmax(6rem, 7rem) repeat(${Math.max(0,e)}, auto)`}var wR=[`ultra`,`ultracode`],TR=[`low`,`medium`,`high`,`xhigh`,`max`,...wR];function ER(e){return[...new Set(e.flatMap(e=>e.options.flatMap(e=>e.efforts)))].sort((e,t)=>{let n=TR.indexOf(e),r=TR.indexOf(t);return n===-1&&r===-1?e.localeCompare(t):n===-1?1:r===-1?-1:n-r})}function DR(e){let t=[];for(let n of ER(e)){let e=wR.includes(n)?t.find(e=>wR.includes(e[0])):void 0;e?e.push(n):t.push([n])}return t}function OR(e){return e.flatMap(e=>e.options.flatMap(t=>t.efforts.map(n=>({provider:e.id,model:t.model,effort:n}))))}function kR(e){return JSON.stringify([e.provider,e.model,e.effort])}function AR(e,t){return OR(e).find(e=>kR(e)===t)}function jR(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 NR(e,t,n){let r=DR(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 PR,FR=!1;function IR(){FR||typeof window>`u`||(FR=!0,window.addEventListener(`keydown`,e=>{e.key!==`Escape`||!PR||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),RR())},{capture:!0}))}function LR(e){IR();let t={dismiss:e};return PR=t,()=>{PR===t&&(PR=void 0)}}function RR(){let e=PR;return e?(PR=void 0,e.dismiss(),!0):!1}function zR(e){RR()&&e.preventDefault(),e.stopPropagation()}function BR(e){return e===`xhigh`?`X-high`:e.charAt(0).toUpperCase()+e.slice(1)}function VR({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=Zj,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)(()=>DR(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?xR:bR,C=c?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors hover:border-border hover:bg-panel-2 hover:text-fg`,w=jR(e,t),T=w&&t?.provider&&t.model&&t.effort?kR(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=kR(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=NR(e,n,t.key);r&&(t.preventDefault(),t.stopPropagation(),v.current.get(kR(r))?.focus())}return(0,L.jsxs)(AI,{modal:!1,open:p,onOpenChange:e=>{_.current?.(),_.current=void 0,h.current=e,m(e),e&&(_.current=LR(D))},children:[(0,L.jsx)(jI,{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)(Xm,{"aria-hidden":`true`,size:l?10:11,className:`shrink-0 animate-spin text-muted/65`}),(0,L.jsx)(_m,{"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)(NI,{"aria-label":o,align:`start`,side:u,sideOffset:5,collisionPadding:8,onEscapeKeyDown:e=>e.stopPropagation(),className:`profile-grid-menu ${d} ${Xj} 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)(PI,{children:[t.label&&(0,L.jsx)(FI,{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)(LI,{value:T,onValueChange:t=>{let n=AR(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:CR(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)=>BR(t).length>BR(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:BR(i)},i);let a={provider:t.id,model:e.model,effort:r},o=kR(a);return(0,L.jsx)(RI,{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}, ${BR(r)} effort`,title:`${e.label} › ${BR(r)}`,className:SR,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:BR(r)}),(0,L.jsx)(`span`,{className:`col-start-1 row-start-1`,children:BR(r)})]})},r)})]},e.model))}),t!==e.at(-1)&&(0,L.jsx)(BI,{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 HR(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(!UR(e))throw Error(`the browser blocked clipboard access`)}function UR(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 WR={claude:`claude auth login`,codex:`codex login`},GR={claude:`Claude`,codex:`Codex`};function KR(e){let t=e.trim();return t===`/login`?`login`:t===`/logout`?`logout`:null}var qR=(0,I.lazy)(()=>ib(()=>import(`./TerminalPane-CTuT1746.js`).then(e=>({default:e.TerminalPane})),__vite__mapDeps([0,1])));function JR({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=WR[e],u=GR[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 HR(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)(QI,{open:!0,onOpenChange:e=>{e||(p(),t())},children:(0,L.jsxs)(iL,{children:[(0,L.jsx)(oL,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(uL,{"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)(hL,{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)(qR,{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)(gm,{size:14,strokeWidth:2,className:`text-green-400`}):(0,L.jsx)(Am,{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)(Xm,{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)(Xm,{size:13,className:`animate-spin`}),`Sign in here`]})]})]})]})]})})}function YR({backend:e,onClose:t}){let n=Ve(),r=GR[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)(QI,{open:!0,onOpenChange:e=>{!e&&!i.isPending&&t()},children:(0,L.jsxs)(iL,{children:[(0,L.jsx)(oL,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(uL,{"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)(hL,{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)(Xm,{size:13,className:`animate-spin`}),`Sign out`]})]})]})]})})}var XR=_u.options,ZR={auto:`Auto`,default:`Default`,acceptEdits:`Accept edits`,plan:`Plan`,bypassPermissions:`Bypass`},QR={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)`};XR.filter(e=>e!==`plan`).map(e=>({value:e,label:ZR[e],title:QR[e]}));var $R=[`auto`,`bypassPermissions`].map(e=>({value:e,label:ZR[e],title:QR[e]})),ez=[{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 tz(e){return e===`plan`?`auto`:e}var nz=[`low`,`medium`,`high`,`xhigh`,`max`],rz=`ultracode`,iz=new Set([`fable`,`opus`,`sonnet`]);function az(e){return e&&iz.has(e)?[...nz,rz]:[...nz]}var oz={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-high`,max:`Max`,ultra:`Ultra`,ultracode:`Ultracode`};function sz(e){return oz[e]??e.charAt(0).toUpperCase()+e.slice(1)}function cz(e,t){let n=az(e).map(e=>({value:e,label:sz(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function lz(e,t){let n=(e?.efforts??[]).map(e=>({value:e,label:sz(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function uz(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 dz(e){return[{id:`claude`,label:`Claude Code`,options:ez.map(e=>({model:e.value,label:e.label,defaultEffort:`high`,efforts:az(e.value)}))},{id:`codex`,label:`Codex`,options:e.map(e=>({model:e.slug,label:e.displayName,defaultEffort:e.defaultEffort,efforts:e.efforts}))}]}function fz(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`?ez.some(e=>e.value===i):t.some(e=>e.slug===i),s=n===`claude`?`high`:a?.defaultEffort??``,c=r.effort??s,l=n===`claude`?cz(i,{withDefault:!1}):lz(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 pz(){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`],uz(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?fz(t.data,r):void 0,[a,t.data,r]),codexList:r,loadError:t.isError||n.isError,saveProfile:i.mutate}}var mz=`frizz-drafts:v1`,hz=80,gz=512*1024,_z=2*1024*1024,vz=new TextEncoder;function yz(e){return vz.encode(e).byteLength}function bz(){return{version:1,entries:{}}}function xz(e){if(!e)return bz();try{let t=JSON.parse(e);if(!t||typeof t!=`object`||t.version!==1)return bz();let n=t.entries;if(!n||typeof n!=`object`||Array.isArray(n))return bz();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||yz(t.value)>gz||(r[e]={value:t.value,touchedAt:t.touchedAt});return{version:1,entries:r}}catch{return bz()}}function Sz(e){let t=Object.entries(e.entries).filter(([,e])=>e.value&&yz(e.value)<=gz).sort((e,t)=>t[1].touchedAt-e[1].touchedAt),n={};for(let[e,r]of t){if(Object.keys(n).length>=hz)break;n[e]=r,yz(JSON.stringify({version:1,entries:n}))>_z&&delete n[e]}return{version:1,entries:n}}var Cz=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=Sz(xz(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(mz,JSON.stringify(Sz(e)))}catch{}for(let e of this.listeners)e()}};function wz(e){return encodeURIComponent(e||`unresolved-project`)}var Tz={dispatch:e=>`dispatch:${wz(e)}:new`,followUp:(e,t,n)=>`followup:${wz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}`,adopt:(e,t)=>`adopt:${wz(e)}:${encodeURIComponent(t)}`,answer:(e,t,n,r,i)=>`answer:${wz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}:${encodeURIComponent(r)}:${i}`,interaction:(e,t,n,r,i,a,o)=>`interaction:${wz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}:${i}:${encodeURIComponent(a)}:${encodeURIComponent(o)}`,question:(e,t,n,r)=>`question:${wz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}`};function Ez(){return Zt(X).board?.projectDir}function Dz(e){return Zt(X).board?.threads.find(t=>t.id===e)?.sessionId}function Oz(e){let t=(0,I.useCallback)(()=>Cz.get(e),[e]);return[(0,I.useSyncExternalStore)(Cz.subscribe,t,t),(0,I.useCallback)(t=>Cz.set(e,t),[e]),(0,I.useCallback)(()=>Cz.clear(e),[e])]}function kz(e){let t=(0,I.useCallback)(()=>JSON.stringify(Object.fromEntries(e.map(e=>[e,Cz.get(e)]))),[e.join(`\0`)]),n=(0,I.useSyncExternalStore)(Cz.subscribe,t,t);return(0,I.useMemo)(()=>new Map(Object.entries(JSON.parse(n))),[n])}function Az({autoFocus:e,onDispatched:t}){let{resolved:n,codexList:r,loadError:i,saveProfile:a}=pz(),o=_R(),s=Ez(),[c,l,u]=Oz(Tz.dispatch(s)),d=Tz.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)=>{Cz.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=KR(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)(VR,{groups:dz(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)(VR,{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)(mR,{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)(vR,{}):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)(JR,{backend:g,onClose:()=>_(null),onAuthed:()=>{let e=b.current;b.current=null,_(null),e&&S(e)}}),v&&(0,L.jsx)(YR,{backend:v,onClose:()=>y(null)})]})}function jz({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)(QI,{open:!0,onOpenChange:t=>{t||e()},children:(0,L.jsxs)(iL,{children:[(0,L.jsx)(oL,{className:`fixed inset-0 z-50 bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(uL,{ref:t,"aria-modal":`true`,"aria-describedby":void 0,onEscapeKeyDown:zR,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)(hL,{className:`mb-1 text-[14px] font-medium`,children:`New thread`}),(0,L.jsx)(Az,{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 Nz=`-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`,Pz={claude:`size-[11px] translate-y-px`,codex:`size-[10px]`},Fz={claude:{backend:`claude`,label:`Claude Code`},codex:{backend:`codex`,label:`OpenAI Codex`}};function Iz(e){return e===`claude`||e===`codex`?Fz[e]:void 0}function Lz({backend:e,className:t}){let n=Iz(e);return n?(0,L.jsx)(`span`,{role:`img`,"aria-label":n.label,className:`inline-flex shrink-0 text-muted/65 ${Pz[n.backend]} ${t??``}`,children:n.backend===`codex`?(0,L.jsx)(Rz,{}):(0,L.jsx)(zz,{})}):null}function Rz(){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 zz(){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 Bz(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)}}function Vz(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,Hz(i,...t)]}function Hz(...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 Uz=`DismissableLayer`,Wz=`dismissableLayer.update`,Gz=`dismissableLayer.pointerDownOutside`,Kz=`dismissableLayer.focusOutside`,qz,Jz=I.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Yz=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(Jz),[d,f]=I.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=I.useState({}),h=CD(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=$z(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=eB(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=VD(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&&(qz=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),tB(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=qz))}},[d,p,n,u]),I.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),tB())},[d,u]),I.useEffect(()=>{let e=()=>m({});return document.addEventListener(Wz,e),()=>document.removeEventListener(Wz,e)},[]),(0,L.jsx)(zD.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:Bz(e.onFocusCapture,w.onFocusCapture),onBlurCapture:Bz(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:Bz(e.onPointerDownCapture,C.onPointerDownCapture)})});Yz.displayName=Uz;var Xz=`DismissableLayerBranch`,Zz=I.forwardRef((e,t)=>{let n=I.useContext(Jz),r=I.useRef(null),i=CD(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)(zD.div,{...e,ref:i})});Zz.displayName=Xz;var Qz=()=>!0;function $z(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Qz}=t,s=VD(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||nB(Gz,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 eB(e,t=globalThis?.document){let n=VD(e),r=I.useRef(!1);return I.useEffect(()=>{let e=e=>{e.target&&!r.current&&nB(Kz,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 tB(){let e=new CustomEvent(Wz);document.dispatchEvent(e)}function nB(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?BD(i,a):i.dispatchEvent(a)}var rB=`focusScope.autoFocusOnMount`,iB=`focusScope.autoFocusOnUnmount`,aB={bubbles:!1,cancelable:!0},oB=`FocusScope`,sB=I.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=I.useState(null),l=VD(i),u=VD(a),d=I.useRef(null),f=CD(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:mB(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||mB(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&mB(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){hB.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(rB,aB);s.addEventListener(rB,l),s.dispatchEvent(t),t.defaultPrevented||(cB(vB(uB(s)),{select:!0}),document.activeElement===e&&mB(s))}return()=>{s.removeEventListener(rB,l),setTimeout(()=>{let t=new CustomEvent(iB,aB);s.addEventListener(iB,u),s.dispatchEvent(t),t.defaultPrevented||mB(e??document.body,{select:!0}),s.removeEventListener(iB,u),hB.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]=lB(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&mB(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&mB(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,L.jsx)(zD.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});sB.displayName=oB;function cB(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(mB(r,{select:t}),document.activeElement!==n)return}function lB(e){let t=uB(e);return[dB(t,e),dB(t.reverse(),e)]}function uB(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 dB(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):fB(r,{upTo:t})))return r}function fB(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 pB(e){return e instanceof HTMLInputElement&&`select`in e}function mB(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&pB(e)&&t&&e.select()}}var hB=gB();function gB(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=_B(e,t),e.unshift(t)},remove(t){e=_B(e,t),e[0]?.resume()}}}function _B(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function vB(e){return e.filter(e=>e.tagName!==`A`)}var yB=`Popper`,[bB,xB]=Vz(yB),[SB,CB]=bB(yB),wB=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null),[a,o]=I.useState(void 0);return(0,L.jsx)(SB,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};wB.displayName=yB;var TB=`PopperAnchor`,EB=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=CB(TB,n),o=I.useRef(null),s=a.onAnchorChange,c=CD(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&&IB(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,L.jsx)(zD.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})});EB.displayName=TB;var DB=`PopperContent`,[OB,kB]=bB(DB),AB=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=CB(DB,n),[_,v]=I.useState(null),y=CD(t,v),[b,x]=I.useState(null),S=wA(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(PB),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=fA({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>Qk(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[mA({mainAxis:i+w,alignmentAxis:o}),c&&hA({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?gA():void 0,...k}),c&&_A({...k}),vA({...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&&bA({element:b,padding:s}),FB({arrowWidth:C,arrowHeight:w}),f&&yA({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ee=g.setPlacementState;HD(()=>(ee(M),()=>{ee(void 0)}),[M,ee]);let[F,te]=IB(M),ne=VD(m);HD(()=>{N&&ne?.()},[N,ne]);let re=P.arrow?.x,ie=P.arrow?.y,ae=P.arrow?.centerOffset!==0,[oe,se]=I.useState();return HD(()=>{_&&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)(OB,{scope:n,placedSide:F,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,L.jsx)(zD.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});AB.displayName=DB;var jB=`PopperArrow`,MB={top:`bottom`,right:`left`,bottom:`top`,left:`right`},NB=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=kB(jB,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)(CA,{...r,ref:t,style:{...r.style,display:`block`}})})});NB.displayName=jB;function PB(e){return e!==null}var FB=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]=IB(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 IB(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var LB=wB,RB=EB,zB=AB,BB=NB;function VB(e,t){return I.useReducer((e,n)=>t[e][n]??e,e)}var HB=e=>{let{present:t,children:n}=e,r=UB(t),i=typeof n==`function`?n({present:r.isPresent}):I.Children.only(n),a=GB(r.ref,qB(i));return typeof n==`function`||r.isPresent?I.cloneElement(i,{ref:a}):null};HB.displayName=`Presence`;function UB(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]=VB(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??KB(r.current),o.current=void 0):a.current=`none`},[s]),HD(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=KB(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]),HD(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=KB(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=KB(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=KB(t)}else r.current=null;n(e)},[])}}function WB(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function GB(...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=WB(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():WB(n[e],null)}}},[])}function KB(e){return e?.animationName||`none`}function qB(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 JB=`Popover`,[YB,XB]=Vz(JB,[xB]),ZB=xB(),[QB,$B]=YB(JB),eV=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=ZB(t),c=I.useRef(null),[l,u]=I.useState(!1),[d,f]=rj({prop:r,defaultProp:i??!1,onChange:a,caller:JB});return(0,L.jsx)(LB,{...s,children:(0,L.jsx)(QB,{scope:t,contentId:cO(),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})})};eV.displayName=JB;var tV=`PopoverAnchor`,nV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=$B(tV,n),a=ZB(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return I.useEffect(()=>(o(),()=>s()),[o,s]),(0,L.jsx)(RB,{...a,...r,ref:t})});nV.displayName=tV;var rV=`PopoverTrigger`,iV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=$B(rV,n),a=ZB(n),o=CD(t,i.triggerRef),s=(0,L.jsx)(zD.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":yV(i.open),...r,ref:o,onClick:Bz(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,L.jsx)(RB,{asChild:!0,...a,children:s})});iV.displayName=rV;var aV=`PopoverPortal`,[oV,sV]=YB(aV,{forceMount:void 0}),cV=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=$B(aV,t);return(0,L.jsx)(oV,{scope:t,forceMount:n,children:(0,L.jsx)(HB,{present:n||a.open,children:(0,L.jsx)(JA,{asChild:!0,container:i,children:r})})})};cV.displayName=aV;var lV=`PopoverContent`,uV=I.forwardRef((e,t)=>{let n=sV(lV,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=$B(lV,e.__scopePopover);return(0,L.jsx)(HB,{present:r||a.open,children:a.modal?(0,L.jsx)(fV,{...i,ref:t}):(0,L.jsx)(pV,{...i,ref:t})})});uV.displayName=lV;var dV=ED(`PopoverContent.RemoveScroll`),fV=I.forwardRef((e,t)=>{let n=$B(lV,e.__scopePopover),r=I.useRef(null),i=CD(t,r),a=I.useRef(!1);return I.useEffect(()=>{let e=r.current;if(e)return iN(e)},[]),(0,L.jsx)(pP,{as:dV,allowPinchZoom:!0,children:(0,L.jsx)(mV,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Bz(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Bz(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:Bz(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),pV=I.forwardRef((e,t)=>{let n=$B(lV,e.__scopePopover),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(mV,{...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()}})}),mV=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=$B(lV,n),p=ZB(n);return dM(),(0,L.jsx)(sB,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(Yz,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,L.jsx)(zB,{"data-state":yV(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)`}})})})}),hV=`PopoverClose`,gV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=$B(hV,n);return(0,L.jsx)(zD.button,{type:`button`,...r,ref:t,onClick:Bz(e.onClick,()=>i.onOpenChange(!1))})});gV.displayName=hV;var _V=`PopoverArrow`,vV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ZB(n);return(0,L.jsx)(BB,{...i,...r,ref:t})});vV.displayName=_V;function yV(e){return e?`open`:`closed`}var bV=eV,xV=nV,SV=iV,CV=cV,wV=uV;function TV({modal:e=!1,...t}){return(0,L.jsx)(bV,{modal:e,...t})}var EV=SV,DV=xV;function OV({children:e,side:t=`top`,align:n=`center`,sideOffset:r=6,className:i=``,...a}){return(0,L.jsx)(CV,{children:(0,L.jsx)(wV,{side:t,align:n,sideOffset:r,avoidCollisions:!0,collisionPadding:12,onEscapeKeyDown:e=>e.stopPropagation(),className:`${Xj} ${eM} rounded-lg outline-none ${i}`,...a,children:e})})}var kV=3e4,AV=45e3;function jV(e,t){return t?AbortSignal.any([t,AbortSignal.timeout(e)]):AbortSignal.timeout(e)}var MV=`text-[9px]`,NV={claude:`text-fg/75! size-[14px]! translate-y-0!`,codex:`text-fg/75! size-[12.75px]! translate-y-0!`};function PV(){let e=nt({queryKey:[`quota`],queryFn:()=>Y.quota(),staleTime:1e4}),t=nt({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4});return[`claude`,`codex`].some(n=>FV(e.data?.[n],t.data?.[n],e.isLoading))}function FV(e,t,n){return t===`signed-out`||!e&&n?!1:!!e&&e.status===`ok`&&e.windows.length>0}function IV(){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:jV(kV,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:jV(kV,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:jV(AV)}).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)(LV,{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)(LV,{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 LV({backend:e,quota:t,auth:n,email:r,loading:i,fetching:a,onRecheck:o}){let s=GR[e];if(!FV(t,n,i))return null;let c=RV(100-BV(t.windows).usedPercent);return(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(TV,{onOpenChange:e=>{e&&o()},children:[(0,L.jsx)(EV,{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)(Lz,{backend:e,className:NV[e]}),(0,L.jsxs)(`span`,{className:`tabular-nums ${VV(c)}`,children:[c,`%`]})]})}),(0,L.jsxs)(OV,{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)(Lz,{backend:e}),(0,L.jsx)(`span`,{children:s}),t?.planType&&(0,L.jsxs)(`span`,{className:`text-muted/70`,children:[`· `,HV(t.planType),` plan`]}),a&&(0,L.jsx)(Xm,{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=RV(100-e.usedPercent),n=UV(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:VV(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 RV(e){return Math.max(0,Math.min(100,Math.round(e)))}var zV=25;function BV(e){return e.find(e=>e.key===`5h`)??e.reduce((e,t)=>t.usedPercent>e.usedPercent?t:e)}function VV(e){return e<=8?`text-red-400`:e<=zV?`text-accent`:`text-fg/70`}function HV(e){return e&&e[0].toUpperCase()+e.slice(1)}function UV(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 WV=`frizz:supervisor-status-wake`,GV=`frizz:reload-after-update-restart`,KV=`frizz:update-restart-from-version`;function qV(e,t){return t.version===e?{kind:`previous-kept`}:{kind:`successor-failed`,version:t.version}}function JV(e){if(e.kind===`previous-kept`)return{summary:`Frizz kept running the previous version`,detail:`Frizz kept running the previous version, and your threads are unaffected.`};let t=e.version?`Frizz ${e.version}`:`The new version of Frizz`;return{summary:`${t} failed to start`,detail:`${t} came up but could not start its board, and the previous version is gone. Restart Frizz from the terminal (npx frizz) and check its log for the reason.`}}function YV(e){return e?.artifactDigest??e?.version??null}function XV(e,t){if(e===null||t?.state!==`ready`)return!1;let n=YV(t);return n!==null&&n!==e}var ZV=3*6e4,QV={silentSince:null,silentForMs:0,stalled:!1};function $V(e,t,n=ZV){if(!t.restarting||t.answered)return QV;let r=e.silentSince??t.at,i=Math.max(0,t.at-r);return{silentSince:r,silentForMs:i,stalled:i>=n}}function eH(e,t){return e.ackedAt!==null&&t.requestedAt>=e.ackedAt}function tH(e,t){return e.attempt&&!(eH(e.attempt,t)&&nH(e.attempt,t))?e:{state:t.state,message:t.message??null,attempt:null}}function nH(e,t){if(t.state!==`ready`)return!0;let n=t.artifactDigest??t.version??null;return e.build!=null&&n!==null&&n!==e.build}function rH(e,t){return t.state===`ready`&&e.attempt===null}function iH(e){return e!==null}function aH(e){return e?.updateRestart===!0&&e.updateAvailable!==!1}function oH(e){return e?.dev===!0}async function sH(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 cH(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 lH(e=fetch){return cH(`/_frizz/control/restart`,e)}function uH(e=fetch){return cH(`/_frizz/control/update-restart`,e)}var dH=8e3,fH=500,pH=[`supervisorStatus`];function mH(e,t){return e===`restarting`||t?fH:dH}var hH=rt({queryKey:pH,queryFn:async()=>{let e=Date.now(),t=await sH();return t?{...t,requestedAt:e}:null},refetchInterval:e=>mH(e.state.data?.state,X.controlPlaneRestartAttempt!==null),staleTime:e=>mH(e.state.data?.state,X.controlPlaneRestartAttempt!==null)});function gH(){return nt(hH)}var _H=null;function vH(e){_H||(_H=e,window.addEventListener(WV,()=>{e.refetchQueries({queryKey:pH,exact:!0})}))}function yH(e,t){let n=e=>{let t=e&&/^v?(\d+)\.(\d+)\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u.exec(e);return t?[Number(t[1]),Number(t[2])]:null},r=n(e),i=n(t);return r!==null&&i!==null&&(r[0]!==i[0]||r[1]!==i[1])}var bH=`Install the latest version of Frizz. Your running threads will not be affected.`,xH=`A newer version of Frizz is available. Your running threads will not be affected.`,SH=`Restart Frizz. Your running threads will not be affected.`,CH=`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)]`,wH=`absolute -top-[7px] left-4 h-3 w-3 rotate-45 border-l border-t bg-elevated`,TH=`sm:w-[min(23rem,calc(100vw-1.5rem))]`,EH=`sm:w-[min(34rem,calc(100vw-1.5rem))]`,DH=`rounded-xl bg-elevated p-3.5 shadow-xl shadow-black/45`;function OH({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:`${CH} ${TH} ${DH} border border-border-strong`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${wH} 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)(lh,{"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?xH:bH:SH})]})}var kH={kind:`previous-kept`};function AH({update:e,message:t,outcome:n=kH,onDismiss:r}){return(0,L.jsxs)(`div`,{role:`alert`,className:`${CH} ${EH} ${DH} border border-red-500/45`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${wH} 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)(xh,{"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:r,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)(Ch,{"aria-hidden":`true`,size:14,strokeWidth:2.25})})]}),(0,L.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:JV(n).detail}),(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 jH({update:e,busy:t,version:n,updateVersion:r,onFocus:i,onBlur:a,onClick:o}){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 ${Nz}`,onFocus:i,onBlur:a,onClick:o,children:[(0,L.jsx)(lh,{size:14,"aria-hidden":`true`,className:t?`animate-spin`:void 0}),e&&!t&&yH(n,r)&&(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-[2px] top-[2px] h-[4px] w-[4px] rounded-full bg-accent`})]})}function MH(){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)(null),u=(0,I.useRef)(null),d=gH().data??null,f=aH(d),p={version:d?.version,updateVersion:d?.updateVersion};if(!iH(d))return null;let m=l.current!==null&&e.controlPlaneState===`failed`,h=m?e.controlPlaneMessage??`Frizz did not become ready`:void 0,g=a??h,_=g&&g!==s?g:void 0,v=!a&&m&&l.current?qV(l.current.version,{version:d?.version}):kH,y=async()=>{if(r)return;l.current={version:d?.version},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.controlPlaneRestartAttempt={startedAt:Date.now(),ackedAt:null,build:YV(d)});try{if(f?await uH():await lH(),f){sessionStorage.setItem(GV,e),l.current.version?sessionStorage.setItem(KV,l.current.version):sessionStorage.removeItem(KV);let t=X.controlPlaneRestartAttempt;t&&(X.controlPlaneRestartAttempt={...t,ackedAt:Date.now()}),window.dispatchEvent(new Event(WV)),i(!1)}else window.location.replace(e)}catch(e){f&&(X.controlPlaneRestartAttempt=null,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)(jH,{update:f,busy:r,version:p.version,updateVersion:p.updateVersion,onFocus:()=>n(!0),onBlur:()=>n(!1),onClick:()=>void y()}),_&&(0,L.jsx)(AH,{update:f,message:_,outcome:v,onDismiss:()=>c(_)}),(0,L.jsx)(OH,{open:t&&!_,update:f,version:p.version,updateVersion:p.updateVersion})]})}function NH(){return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px shrink-0 bg-border`})}function PH({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 FH(){let e=qC(),t=mW(e),n=PV(),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)(Ab,{to:`/`,title:`All projects`,"aria-label":`All projects`,className:`${Nz} -ml-px`,children:(0,L.jsx)(Wm,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(NH,{}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Settings`,title:`Settings`,className:Nz,onClick:()=>X.showSettings=!0,children:(0,L.jsx)(ph,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(MH,{}),n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(NH,{}),(0,L.jsx)(IV,{})]}),(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)(PH,{text:i})}):i?(0,L.jsx)(PH,{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:{}}),LH=12e3,RH=new Map;function zH(e,t=Date.now()){IH.at[e]=t;let n=RH.get(e);n!==void 0&&clearTimeout(n),RH.set(e,setTimeout(()=>{RH.delete(e),delete IH.at[e]},LH))}function BH(e){let t=RH.get(e);t!==void 0&&(clearTimeout(t),RH.delete(e)),delete IH.at[e]}function VH(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 HH(){return Zt(IH).at}function UH(e,t,n=Date.now()){return t===void 0||!VH(e,t,n)?e:{...e,runtime:`running`,needsYou:!1,pendingAsk:void 0,pendingQuestion:!1,actionableInteraction:!1,lastUserAt:new Date(t).toISOString()}}function WH(e){let t=HH();return(0,I.useMemo)(()=>e.map(e=>UH(e,t[e.id])),[e,t])}var GH=0;function KH(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(GH+=1,`browser-${Date.now()}-${GH}`)}function qH({optimistic:e,request:t,success:n,failure:r}){e(),t().then(()=>n?.(),e=>r(e instanceof Error?e:Error(String(e))))}var JH=new Map;function YH(e,t){let n=(JH.get(e)??Promise.resolve()).then(t,t);return JH.set(e,n.then(()=>{},()=>{})),n}var XH=[300,800,1800,3500],ZH=12e4,QH=e=>new Promise(t=>{setTimeout(t,e)});async function $H(e,t,n=QH){for(let r=0;;r++){try{await e()}catch(e){if(r>=XH.length||!ff(e))throw e;t(),await n(XH[r]);continue}t();return}}function eU(e,t,n,r,i,a=ZH){let o=new AbortController,s=setTimeout(()=>o.abort(Error(`Frizz did not answer this send`)),a);return Y.followUp({slug:e,sessionId:Gp(X.board,e)?.sessionId??``,message:t,deliveryId:n,freshProcess:r,interrupt:i},{signal:o.signal}).finally(()=>clearTimeout(s))}function tU(e,t,n,r,i){return $H(()=>eU(e,t,n,r,i),()=>zH(e))}function nU(e,t,n,r={}){let i=n.trim();if(!i)return!1;let a=KH();return qH({optimistic:()=>{r.onOptimistic?.(),dw(e,t,i,{scrollToBottom:r.scrollToBottom,deliveryId:a}),zH(t),Y.markRead({slug:t}).catch(()=>{})},request:()=>YH(t,()=>tU(t,i,a,r.freshProcess,r.interrupt)),success:()=>r.onSuccess?.(),failure:n=>{fw(e,t,i,a),BH(t),r.onRollback?.(),Z(r.failureToast?.(n.message)??`Steer failed — ${n.message.slice(0,160)}`)}}),!0}function rU(e){let t=Ve(),[n,r]=(0,I.useState)(0);return{submit:(0,I.useCallback)((n,i={})=>nU(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 iU(e,t){return new Promise(n=>{nU(e,t,`Continue exactly where you left off.`,{onSuccess:()=>{Z(`Retrying…`),n()},onRollback:()=>n(),failureToast:e=>`Retry failed: ${e.slice(0,80)}`})||n()})}function aU(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 oU=`Waiting for an external update.`;function sU(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:aU(n)}])})}function cU(e){let t=(e.body??``).split(/\n\s*\n/).map(e=>e.trim()).find(Boolean);return t?dU(lU(t.replace(/\s*\n\s*/g,` `))):null}function lU(e){if(e.length<=uU)return e;let t=e.slice(0,uU),n=t.lastIndexOf(` `);return`${(n>uU/2?t.slice(0,n):t).replace(/[.,;:]$/,``)}…`}var uU=240;function dU(e){let t=(e.split(/\s/,1)[0]??``).replace(/[.,:;]+$/,``);return/[^a-zA-Z]/.test(t)||/[A-Z]/.test(t.slice(1))||fU.has(t)?e:e.charAt(0).toUpperCase()+e.slice(1)}var fU=new Set([`npm`,`npx`,`pnpm`,`nub`,`nubx`,`gh`,`git`,`node`,`bun`,`tsc`,`vite`,`curl`,`ssh`]);function pU(e){return e&&hU(e)||null}var mU=new Set([...rl,`shells`,`agents`,`timers`,`prs`,`for`,`title`]);function hU(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?fR[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?lR:uR}`} 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)(hR,{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?sR:cR} 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)(Xm,{size:15,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(ih,{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 ${oR} 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)(Xm,{size:14,strokeWidth:2.5,className:`animate-spin`}):(0,L.jsx)(fm,{size:14,strokeWidth:2.5})})]})}function hR({attachment:e,disabled:t,onRemove:n}){let[r,i]=(0,I.useState)(!1),a=Qf(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:YS(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)(Pm,{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)(Ch,{size:10,strokeWidth:2.5})})]})}function gR(){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 _R(){let e=gR();return!!(e.data?.inRepo&&e.data.authed)}function vR({className:e=``}){return _R()?(0,L.jsx)(`button`,{type:`button`,onClick:lp,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)(Hm,{size:15,strokeWidth:2})}):null}var yR=`prompt-control-type petite-caps`,bR=yR,xR=yR,SR=`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 ${bR} 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 CR(e){return`minmax(6rem, 7rem) repeat(${Math.max(0,e)}, auto)`}var wR=[`ultra`,`ultracode`],TR=[`low`,`medium`,`high`,`xhigh`,`max`,...wR];function ER(e){return[...new Set(e.flatMap(e=>e.options.flatMap(e=>e.efforts)))].sort((e,t)=>{let n=TR.indexOf(e),r=TR.indexOf(t);return n===-1&&r===-1?e.localeCompare(t):n===-1?1:r===-1?-1:n-r})}function DR(e){let t=[];for(let n of ER(e)){let e=wR.includes(n)?t.find(e=>wR.includes(e[0])):void 0;e?e.push(n):t.push([n])}return t}function OR(e){return e.flatMap(e=>e.options.flatMap(t=>t.efforts.map(n=>({provider:e.id,model:t.model,effort:n}))))}function kR(e){return JSON.stringify([e.provider,e.model,e.effort])}function AR(e,t){return OR(e).find(e=>kR(e)===t)}function jR(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 NR(e,t,n){let r=DR(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 PR,FR=!1;function IR(){FR||typeof window>`u`||(FR=!0,window.addEventListener(`keydown`,e=>{e.key!==`Escape`||!PR||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),RR())},{capture:!0}))}function LR(e){IR();let t={dismiss:e};return PR=t,()=>{PR===t&&(PR=void 0)}}function RR(){let e=PR;return e?(PR=void 0,e.dismiss(),!0):!1}function zR(e){RR()&&e.preventDefault(),e.stopPropagation()}function BR(e){return e===`xhigh`?`X-high`:e.charAt(0).toUpperCase()+e.slice(1)}function VR({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=Zj,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)(()=>DR(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?xR:bR,C=c?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors hover:border-border hover:bg-panel-2 hover:text-fg`,w=jR(e,t),T=w&&t?.provider&&t.model&&t.effort?kR(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=kR(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=NR(e,n,t.key);r&&(t.preventDefault(),t.stopPropagation(),v.current.get(kR(r))?.focus())}return(0,L.jsxs)(AI,{modal:!1,open:p,onOpenChange:e=>{_.current?.(),_.current=void 0,h.current=e,m(e),e&&(_.current=LR(D))},children:[(0,L.jsx)(jI,{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)(Xm,{"aria-hidden":`true`,size:l?10:11,className:`shrink-0 animate-spin text-muted/65`}),(0,L.jsx)(_m,{"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)(NI,{"aria-label":o,align:`start`,side:u,sideOffset:5,collisionPadding:8,onEscapeKeyDown:e=>e.stopPropagation(),className:`profile-grid-menu ${d} ${Xj} 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)(PI,{children:[t.label&&(0,L.jsx)(FI,{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)(LI,{value:T,onValueChange:t=>{let n=AR(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:CR(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)=>BR(t).length>BR(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:BR(i)},i);let a={provider:t.id,model:e.model,effort:r},o=kR(a);return(0,L.jsx)(RI,{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}, ${BR(r)} effort`,title:`${e.label} › ${BR(r)}`,className:SR,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:BR(r)}),(0,L.jsx)(`span`,{className:`col-start-1 row-start-1`,children:BR(r)})]})},r)})]},e.model))}),t!==e.at(-1)&&(0,L.jsx)(BI,{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 HR(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(!UR(e))throw Error(`the browser blocked clipboard access`)}function UR(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 WR={claude:`claude auth login`,codex:`codex login`},GR={claude:`Claude`,codex:`Codex`};function KR(e){let t=e.trim();return t===`/login`?`login`:t===`/logout`?`logout`:null}var qR=(0,I.lazy)(()=>ib(()=>import(`./TerminalPane-Cv0c_SNS.js`).then(e=>({default:e.TerminalPane})),__vite__mapDeps([0,1])));function JR({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=WR[e],u=GR[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 HR(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)(QI,{open:!0,onOpenChange:e=>{e||(p(),t())},children:(0,L.jsxs)(iL,{children:[(0,L.jsx)(oL,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(uL,{"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)(hL,{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)(qR,{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)(gm,{size:14,strokeWidth:2,className:`text-green-400`}):(0,L.jsx)(Am,{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)(Xm,{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)(Xm,{size:13,className:`animate-spin`}),`Sign in here`]})]})]})]})]})})}function YR({backend:e,onClose:t}){let n=Ve(),r=GR[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)(QI,{open:!0,onOpenChange:e=>{!e&&!i.isPending&&t()},children:(0,L.jsxs)(iL,{children:[(0,L.jsx)(oL,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(uL,{"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)(hL,{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)(Xm,{size:13,className:`animate-spin`}),`Sign out`]})]})]})]})})}var XR=_u.options,ZR={auto:`Auto`,default:`Default`,acceptEdits:`Accept edits`,plan:`Plan`,bypassPermissions:`Bypass`},QR={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)`};XR.filter(e=>e!==`plan`).map(e=>({value:e,label:ZR[e],title:QR[e]}));var $R=[`auto`,`bypassPermissions`].map(e=>({value:e,label:ZR[e],title:QR[e]})),ez=[{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 tz(e){return e===`plan`?`auto`:e}var nz=[`low`,`medium`,`high`,`xhigh`,`max`],rz=`ultracode`,iz=new Set([`fable`,`opus`,`sonnet`]);function az(e){return e&&iz.has(e)?[...nz,rz]:[...nz]}var oz={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-high`,max:`Max`,ultra:`Ultra`,ultracode:`Ultracode`};function sz(e){return oz[e]??e.charAt(0).toUpperCase()+e.slice(1)}function cz(e,t){let n=az(e).map(e=>({value:e,label:sz(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function lz(e,t){let n=(e?.efforts??[]).map(e=>({value:e,label:sz(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function uz(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 dz(e){return[{id:`claude`,label:`Claude Code`,options:ez.map(e=>({model:e.value,label:e.label,defaultEffort:`high`,efforts:az(e.value)}))},{id:`codex`,label:`Codex`,options:e.map(e=>({model:e.slug,label:e.displayName,defaultEffort:e.defaultEffort,efforts:e.efforts}))}]}function fz(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`?ez.some(e=>e.value===i):t.some(e=>e.slug===i),s=n===`claude`?`high`:a?.defaultEffort??``,c=r.effort??s,l=n===`claude`?cz(i,{withDefault:!1}):lz(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 pz(){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`],uz(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?fz(t.data,r):void 0,[a,t.data,r]),codexList:r,loadError:t.isError||n.isError,saveProfile:i.mutate}}var mz=`frizz-drafts:v1`,hz=80,gz=512*1024,_z=2*1024*1024,vz=new TextEncoder;function yz(e){return vz.encode(e).byteLength}function bz(){return{version:1,entries:{}}}function xz(e){if(!e)return bz();try{let t=JSON.parse(e);if(!t||typeof t!=`object`||t.version!==1)return bz();let n=t.entries;if(!n||typeof n!=`object`||Array.isArray(n))return bz();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||yz(t.value)>gz||(r[e]={value:t.value,touchedAt:t.touchedAt});return{version:1,entries:r}}catch{return bz()}}function Sz(e){let t=Object.entries(e.entries).filter(([,e])=>e.value&&yz(e.value)<=gz).sort((e,t)=>t[1].touchedAt-e[1].touchedAt),n={};for(let[e,r]of t){if(Object.keys(n).length>=hz)break;n[e]=r,yz(JSON.stringify({version:1,entries:n}))>_z&&delete n[e]}return{version:1,entries:n}}var Cz=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=Sz(xz(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(mz,JSON.stringify(Sz(e)))}catch{}for(let e of this.listeners)e()}};function wz(e){return encodeURIComponent(e||`unresolved-project`)}var Tz={dispatch:e=>`dispatch:${wz(e)}:new`,followUp:(e,t,n)=>`followup:${wz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}`,adopt:(e,t)=>`adopt:${wz(e)}:${encodeURIComponent(t)}`,answer:(e,t,n,r,i)=>`answer:${wz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}:${encodeURIComponent(r)}:${i}`,interaction:(e,t,n,r,i,a,o)=>`interaction:${wz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}:${i}:${encodeURIComponent(a)}:${encodeURIComponent(o)}`,question:(e,t,n,r)=>`question:${wz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}`};function Ez(){return Zt(X).board?.projectDir}function Dz(e){return Zt(X).board?.threads.find(t=>t.id===e)?.sessionId}function Oz(e){let t=(0,I.useCallback)(()=>Cz.get(e),[e]);return[(0,I.useSyncExternalStore)(Cz.subscribe,t,t),(0,I.useCallback)(t=>Cz.set(e,t),[e]),(0,I.useCallback)(()=>Cz.clear(e),[e])]}function kz(e){let t=(0,I.useCallback)(()=>JSON.stringify(Object.fromEntries(e.map(e=>[e,Cz.get(e)]))),[e.join(`\0`)]),n=(0,I.useSyncExternalStore)(Cz.subscribe,t,t);return(0,I.useMemo)(()=>new Map(Object.entries(JSON.parse(n))),[n])}function Az({autoFocus:e,onDispatched:t}){let{resolved:n,codexList:r,loadError:i,saveProfile:a}=pz(),o=_R(),s=Ez(),[c,l,u]=Oz(Tz.dispatch(s)),d=Tz.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)=>{Cz.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=KR(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)(VR,{groups:dz(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)(VR,{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)(mR,{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)(vR,{}):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)(JR,{backend:g,onClose:()=>_(null),onAuthed:()=>{let e=b.current;b.current=null,_(null),e&&S(e)}}),v&&(0,L.jsx)(YR,{backend:v,onClose:()=>y(null)})]})}function jz({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)(QI,{open:!0,onOpenChange:t=>{t||e()},children:(0,L.jsxs)(iL,{children:[(0,L.jsx)(oL,{className:`fixed inset-0 z-50 bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(uL,{ref:t,"aria-modal":`true`,"aria-describedby":void 0,onEscapeKeyDown:zR,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)(hL,{className:`mb-1 text-[14px] font-medium`,children:`New thread`}),(0,L.jsx)(Az,{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 Nz=`-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`,Pz={claude:`size-[11px] translate-y-px`,codex:`size-[10px]`},Fz={claude:{backend:`claude`,label:`Claude Code`},codex:{backend:`codex`,label:`OpenAI Codex`}};function Iz(e){return e===`claude`||e===`codex`?Fz[e]:void 0}function Lz({backend:e,className:t}){let n=Iz(e);return n?(0,L.jsx)(`span`,{role:`img`,"aria-label":n.label,className:`inline-flex shrink-0 text-muted/65 ${Pz[n.backend]} ${t??``}`,children:n.backend===`codex`?(0,L.jsx)(Rz,{}):(0,L.jsx)(zz,{})}):null}function Rz(){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 zz(){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 Bz(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)}}function Vz(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,Hz(i,...t)]}function Hz(...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 Uz=`DismissableLayer`,Wz=`dismissableLayer.update`,Gz=`dismissableLayer.pointerDownOutside`,Kz=`dismissableLayer.focusOutside`,qz,Jz=I.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Yz=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(Jz),[d,f]=I.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=I.useState({}),h=CD(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=$z(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=eB(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=VD(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&&(qz=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),tB(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=qz))}},[d,p,n,u]),I.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),tB())},[d,u]),I.useEffect(()=>{let e=()=>m({});return document.addEventListener(Wz,e),()=>document.removeEventListener(Wz,e)},[]),(0,L.jsx)(zD.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:Bz(e.onFocusCapture,w.onFocusCapture),onBlurCapture:Bz(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:Bz(e.onPointerDownCapture,C.onPointerDownCapture)})});Yz.displayName=Uz;var Xz=`DismissableLayerBranch`,Zz=I.forwardRef((e,t)=>{let n=I.useContext(Jz),r=I.useRef(null),i=CD(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)(zD.div,{...e,ref:i})});Zz.displayName=Xz;var Qz=()=>!0;function $z(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Qz}=t,s=VD(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||nB(Gz,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 eB(e,t=globalThis?.document){let n=VD(e),r=I.useRef(!1);return I.useEffect(()=>{let e=e=>{e.target&&!r.current&&nB(Kz,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 tB(){let e=new CustomEvent(Wz);document.dispatchEvent(e)}function nB(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?BD(i,a):i.dispatchEvent(a)}var rB=`focusScope.autoFocusOnMount`,iB=`focusScope.autoFocusOnUnmount`,aB={bubbles:!1,cancelable:!0},oB=`FocusScope`,sB=I.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=I.useState(null),l=VD(i),u=VD(a),d=I.useRef(null),f=CD(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:mB(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||mB(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&mB(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){hB.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(rB,aB);s.addEventListener(rB,l),s.dispatchEvent(t),t.defaultPrevented||(cB(vB(uB(s)),{select:!0}),document.activeElement===e&&mB(s))}return()=>{s.removeEventListener(rB,l),setTimeout(()=>{let t=new CustomEvent(iB,aB);s.addEventListener(iB,u),s.dispatchEvent(t),t.defaultPrevented||mB(e??document.body,{select:!0}),s.removeEventListener(iB,u),hB.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]=lB(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&mB(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&mB(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,L.jsx)(zD.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});sB.displayName=oB;function cB(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(mB(r,{select:t}),document.activeElement!==n)return}function lB(e){let t=uB(e);return[dB(t,e),dB(t.reverse(),e)]}function uB(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 dB(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):fB(r,{upTo:t})))return r}function fB(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 pB(e){return e instanceof HTMLInputElement&&`select`in e}function mB(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&pB(e)&&t&&e.select()}}var hB=gB();function gB(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=_B(e,t),e.unshift(t)},remove(t){e=_B(e,t),e[0]?.resume()}}}function _B(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function vB(e){return e.filter(e=>e.tagName!==`A`)}var yB=`Popper`,[bB,xB]=Vz(yB),[SB,CB]=bB(yB),wB=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null),[a,o]=I.useState(void 0);return(0,L.jsx)(SB,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};wB.displayName=yB;var TB=`PopperAnchor`,EB=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=CB(TB,n),o=I.useRef(null),s=a.onAnchorChange,c=CD(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&&IB(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,L.jsx)(zD.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})});EB.displayName=TB;var DB=`PopperContent`,[OB,kB]=bB(DB),AB=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=CB(DB,n),[_,v]=I.useState(null),y=CD(t,v),[b,x]=I.useState(null),S=wA(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(PB),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=fA({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>Qk(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[mA({mainAxis:i+w,alignmentAxis:o}),c&&hA({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?gA():void 0,...k}),c&&_A({...k}),vA({...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&&bA({element:b,padding:s}),FB({arrowWidth:C,arrowHeight:w}),f&&yA({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ee=g.setPlacementState;HD(()=>(ee(M),()=>{ee(void 0)}),[M,ee]);let[F,te]=IB(M),ne=VD(m);HD(()=>{N&&ne?.()},[N,ne]);let re=P.arrow?.x,ie=P.arrow?.y,ae=P.arrow?.centerOffset!==0,[oe,se]=I.useState();return HD(()=>{_&&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)(OB,{scope:n,placedSide:F,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,L.jsx)(zD.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});AB.displayName=DB;var jB=`PopperArrow`,MB={top:`bottom`,right:`left`,bottom:`top`,left:`right`},NB=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=kB(jB,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)(CA,{...r,ref:t,style:{...r.style,display:`block`}})})});NB.displayName=jB;function PB(e){return e!==null}var FB=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]=IB(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 IB(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var LB=wB,RB=EB,zB=AB,BB=NB;function VB(e,t){return I.useReducer((e,n)=>t[e][n]??e,e)}var HB=e=>{let{present:t,children:n}=e,r=UB(t),i=typeof n==`function`?n({present:r.isPresent}):I.Children.only(n),a=GB(r.ref,qB(i));return typeof n==`function`||r.isPresent?I.cloneElement(i,{ref:a}):null};HB.displayName=`Presence`;function UB(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]=VB(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??KB(r.current),o.current=void 0):a.current=`none`},[s]),HD(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=KB(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]),HD(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=KB(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=KB(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=KB(t)}else r.current=null;n(e)},[])}}function WB(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function GB(...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=WB(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():WB(n[e],null)}}},[])}function KB(e){return e?.animationName||`none`}function qB(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 JB=`Popover`,[YB,XB]=Vz(JB,[xB]),ZB=xB(),[QB,$B]=YB(JB),eV=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=ZB(t),c=I.useRef(null),[l,u]=I.useState(!1),[d,f]=rj({prop:r,defaultProp:i??!1,onChange:a,caller:JB});return(0,L.jsx)(LB,{...s,children:(0,L.jsx)(QB,{scope:t,contentId:cO(),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})})};eV.displayName=JB;var tV=`PopoverAnchor`,nV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=$B(tV,n),a=ZB(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return I.useEffect(()=>(o(),()=>s()),[o,s]),(0,L.jsx)(RB,{...a,...r,ref:t})});nV.displayName=tV;var rV=`PopoverTrigger`,iV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=$B(rV,n),a=ZB(n),o=CD(t,i.triggerRef),s=(0,L.jsx)(zD.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":yV(i.open),...r,ref:o,onClick:Bz(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,L.jsx)(RB,{asChild:!0,...a,children:s})});iV.displayName=rV;var aV=`PopoverPortal`,[oV,sV]=YB(aV,{forceMount:void 0}),cV=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=$B(aV,t);return(0,L.jsx)(oV,{scope:t,forceMount:n,children:(0,L.jsx)(HB,{present:n||a.open,children:(0,L.jsx)(JA,{asChild:!0,container:i,children:r})})})};cV.displayName=aV;var lV=`PopoverContent`,uV=I.forwardRef((e,t)=>{let n=sV(lV,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=$B(lV,e.__scopePopover);return(0,L.jsx)(HB,{present:r||a.open,children:a.modal?(0,L.jsx)(fV,{...i,ref:t}):(0,L.jsx)(pV,{...i,ref:t})})});uV.displayName=lV;var dV=ED(`PopoverContent.RemoveScroll`),fV=I.forwardRef((e,t)=>{let n=$B(lV,e.__scopePopover),r=I.useRef(null),i=CD(t,r),a=I.useRef(!1);return I.useEffect(()=>{let e=r.current;if(e)return iN(e)},[]),(0,L.jsx)(pP,{as:dV,allowPinchZoom:!0,children:(0,L.jsx)(mV,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Bz(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Bz(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:Bz(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),pV=I.forwardRef((e,t)=>{let n=$B(lV,e.__scopePopover),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(mV,{...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()}})}),mV=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=$B(lV,n),p=ZB(n);return dM(),(0,L.jsx)(sB,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(Yz,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,L.jsx)(zB,{"data-state":yV(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)`}})})})}),hV=`PopoverClose`,gV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=$B(hV,n);return(0,L.jsx)(zD.button,{type:`button`,...r,ref:t,onClick:Bz(e.onClick,()=>i.onOpenChange(!1))})});gV.displayName=hV;var _V=`PopoverArrow`,vV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=ZB(n);return(0,L.jsx)(BB,{...i,...r,ref:t})});vV.displayName=_V;function yV(e){return e?`open`:`closed`}var bV=eV,xV=nV,SV=iV,CV=cV,wV=uV;function TV({modal:e=!1,...t}){return(0,L.jsx)(bV,{modal:e,...t})}var EV=SV,DV=xV;function OV({children:e,side:t=`top`,align:n=`center`,sideOffset:r=6,className:i=``,...a}){return(0,L.jsx)(CV,{children:(0,L.jsx)(wV,{side:t,align:n,sideOffset:r,avoidCollisions:!0,collisionPadding:12,onEscapeKeyDown:e=>e.stopPropagation(),className:`${Xj} ${eM} rounded-lg outline-none ${i}`,...a,children:e})})}var kV=3e4,AV=45e3;function jV(e,t){return t?AbortSignal.any([t,AbortSignal.timeout(e)]):AbortSignal.timeout(e)}var MV=`text-[9px]`,NV={claude:`text-fg/75! size-[14px]! translate-y-0!`,codex:`text-fg/75! size-[12.75px]! translate-y-0!`};function PV(){let e=nt({queryKey:[`quota`],queryFn:()=>Y.quota(),staleTime:1e4}),t=nt({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4});return[`claude`,`codex`].some(n=>FV(e.data?.[n],t.data?.[n],e.isLoading))}function FV(e,t,n){return t===`signed-out`||!e&&n?!1:!!e&&e.status===`ok`&&e.windows.length>0}function IV(){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:jV(kV,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:jV(kV,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:jV(AV)}).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)(LV,{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)(LV,{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 LV({backend:e,quota:t,auth:n,email:r,loading:i,fetching:a,onRecheck:o}){let s=GR[e];if(!FV(t,n,i))return null;let c=RV(100-BV(t.windows).usedPercent);return(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(TV,{onOpenChange:e=>{e&&o()},children:[(0,L.jsx)(EV,{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)(Lz,{backend:e,className:NV[e]}),(0,L.jsxs)(`span`,{className:`tabular-nums ${VV(c)}`,children:[c,`%`]})]})}),(0,L.jsxs)(OV,{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)(Lz,{backend:e}),(0,L.jsx)(`span`,{children:s}),t?.planType&&(0,L.jsxs)(`span`,{className:`text-muted/70`,children:[`· `,HV(t.planType),` plan`]}),a&&(0,L.jsx)(Xm,{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=RV(100-e.usedPercent),n=UV(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:VV(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 RV(e){return Math.max(0,Math.min(100,Math.round(e)))}var zV=25;function BV(e){return e.find(e=>e.key===`5h`)??e.reduce((e,t)=>t.usedPercent>e.usedPercent?t:e)}function VV(e){return e<=8?`text-red-400`:e<=zV?`text-accent`:`text-fg/70`}function HV(e){return e&&e[0].toUpperCase()+e.slice(1)}function UV(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 WV=`frizz:supervisor-status-wake`,GV=`frizz:reload-after-update-restart`,KV=`frizz:update-restart-from-version`;function qV(e,t){return t.version===e?{kind:`previous-kept`}:{kind:`successor-failed`,version:t.version}}function JV(e){if(e.kind===`previous-kept`)return{summary:`Frizz kept running the previous version`,detail:`Frizz kept running the previous version, and your threads are unaffected.`};let t=e.version?`Frizz ${e.version}`:`The new version of Frizz`;return{summary:`${t} failed to start`,detail:`${t} came up but could not start its board, and the previous version is gone. Restart Frizz from the terminal (npx frizz) and check its log for the reason.`}}function YV(e){return e?.artifactDigest??e?.version??null}function XV(e,t){if(e===null||t?.state!==`ready`)return!1;let n=YV(t);return n!==null&&n!==e}var ZV=3*6e4,QV={silentSince:null,silentForMs:0,stalled:!1};function $V(e,t,n=ZV){if(!t.restarting||t.answered)return QV;let r=e.silentSince??t.at,i=Math.max(0,t.at-r);return{silentSince:r,silentForMs:i,stalled:i>=n}}function eH(e,t){return e.ackedAt!==null&&t.requestedAt>=e.ackedAt}function tH(e,t){return e.attempt&&!(eH(e.attempt,t)&&nH(e.attempt,t))?e:{state:t.state,message:t.message??null,attempt:null}}function nH(e,t){if(t.state!==`ready`)return!0;let n=t.artifactDigest??t.version??null;return e.build!=null&&n!==null&&n!==e.build}function rH(e,t){return t.state===`ready`&&e.attempt===null}function iH(e){return e!==null}function aH(e){return e?.updateRestart===!0&&e.updateAvailable!==!1}function oH(e){return e?.dev===!0}async function sH(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 cH(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 lH(e=fetch){return cH(`/_frizz/control/restart`,e)}function uH(e=fetch){return cH(`/_frizz/control/update-restart`,e)}var dH=8e3,fH=500,pH=[`supervisorStatus`];function mH(e,t){return e===`restarting`||t?fH:dH}var hH=rt({queryKey:pH,queryFn:async()=>{let e=Date.now(),t=await sH();return t?{...t,requestedAt:e}:null},refetchInterval:e=>mH(e.state.data?.state,X.controlPlaneRestartAttempt!==null),staleTime:e=>mH(e.state.data?.state,X.controlPlaneRestartAttempt!==null)});function gH(){return nt(hH)}var _H=null;function vH(e){_H||(_H=e,window.addEventListener(WV,()=>{e.refetchQueries({queryKey:pH,exact:!0})}))}function yH(e,t){let n=e=>{let t=e&&/^v?(\d+)\.(\d+)\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u.exec(e);return t?[Number(t[1]),Number(t[2])]:null},r=n(e),i=n(t);return r!==null&&i!==null&&(r[0]!==i[0]||r[1]!==i[1])}var bH=`Install the latest version of Frizz. Your running threads will not be affected.`,xH=`A newer version of Frizz is available. Your running threads will not be affected.`,SH=`Restart Frizz. Your running threads will not be affected.`,CH=`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)]`,wH=`absolute -top-[7px] left-4 h-3 w-3 rotate-45 border-l border-t bg-elevated`,TH=`sm:w-[min(23rem,calc(100vw-1.5rem))]`,EH=`sm:w-[min(34rem,calc(100vw-1.5rem))]`,DH=`rounded-xl bg-elevated p-3.5 shadow-xl shadow-black/45`;function OH({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:`${CH} ${TH} ${DH} border border-border-strong`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${wH} 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)(lh,{"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?xH:bH:SH})]})}var kH={kind:`previous-kept`};function AH({update:e,message:t,outcome:n=kH,onDismiss:r}){return(0,L.jsxs)(`div`,{role:`alert`,className:`${CH} ${EH} ${DH} border border-red-500/45`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${wH} 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)(xh,{"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:r,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)(Ch,{"aria-hidden":`true`,size:14,strokeWidth:2.25})})]}),(0,L.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:JV(n).detail}),(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 jH({update:e,busy:t,version:n,updateVersion:r,onFocus:i,onBlur:a,onClick:o}){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 ${Nz}`,onFocus:i,onBlur:a,onClick:o,children:[(0,L.jsx)(lh,{size:14,"aria-hidden":`true`,className:t?`animate-spin`:void 0}),e&&!t&&yH(n,r)&&(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-[2px] top-[2px] h-[4px] w-[4px] rounded-full bg-accent`})]})}function MH(){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)(null),u=(0,I.useRef)(null),d=gH().data??null,f=aH(d),p={version:d?.version,updateVersion:d?.updateVersion};if(!iH(d))return null;let m=l.current!==null&&e.controlPlaneState===`failed`,h=m?e.controlPlaneMessage??`Frizz did not become ready`:void 0,g=a??h,_=g&&g!==s?g:void 0,v=!a&&m&&l.current?qV(l.current.version,{version:d?.version}):kH,y=async()=>{if(r)return;l.current={version:d?.version},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.controlPlaneRestartAttempt={startedAt:Date.now(),ackedAt:null,build:YV(d)});try{if(f?await uH():await lH(),f){sessionStorage.setItem(GV,e),l.current.version?sessionStorage.setItem(KV,l.current.version):sessionStorage.removeItem(KV);let t=X.controlPlaneRestartAttempt;t&&(X.controlPlaneRestartAttempt={...t,ackedAt:Date.now()}),window.dispatchEvent(new Event(WV)),i(!1)}else window.location.replace(e)}catch(e){f&&(X.controlPlaneRestartAttempt=null,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)(jH,{update:f,busy:r,version:p.version,updateVersion:p.updateVersion,onFocus:()=>n(!0),onBlur:()=>n(!1),onClick:()=>void y()}),_&&(0,L.jsx)(AH,{update:f,message:_,outcome:v,onDismiss:()=>c(_)}),(0,L.jsx)(OH,{open:t&&!_,update:f,version:p.version,updateVersion:p.updateVersion})]})}function NH(){return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px shrink-0 bg-border`})}function PH({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 FH(){let e=qC(),t=mW(e),n=PV(),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)(Ab,{to:`/`,title:`All projects`,"aria-label":`All projects`,className:`${Nz} -ml-px`,children:(0,L.jsx)(Wm,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(NH,{}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Settings`,title:`Settings`,className:Nz,onClick:()=>X.showSettings=!0,children:(0,L.jsx)(ph,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(MH,{}),n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(NH,{}),(0,L.jsx)(IV,{})]}),(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)(PH,{text:i})}):i?(0,L.jsx)(PH,{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:{}}),LH=12e3,RH=new Map;function zH(e,t=Date.now()){IH.at[e]=t;let n=RH.get(e);n!==void 0&&clearTimeout(n),RH.set(e,setTimeout(()=>{RH.delete(e),delete IH.at[e]},LH))}function BH(e){let t=RH.get(e);t!==void 0&&(clearTimeout(t),RH.delete(e)),delete IH.at[e]}function VH(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 HH(){return Zt(IH).at}function UH(e,t,n=Date.now()){return t===void 0||!VH(e,t,n)?e:{...e,runtime:`running`,needsYou:!1,pendingAsk:void 0,pendingQuestion:!1,actionableInteraction:!1,lastUserAt:new Date(t).toISOString()}}function WH(e){let t=HH();return(0,I.useMemo)(()=>e.map(e=>UH(e,t[e.id])),[e,t])}var GH=0;function KH(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(GH+=1,`browser-${Date.now()}-${GH}`)}function qH({optimistic:e,request:t,success:n,failure:r}){e(),t().then(()=>n?.(),e=>r(e instanceof Error?e:Error(String(e))))}var JH=new Map;function YH(e,t){let n=(JH.get(e)??Promise.resolve()).then(t,t);return JH.set(e,n.then(()=>{},()=>{})),n}var XH=[300,800,1800,3500],ZH=12e4,QH=e=>new Promise(t=>{setTimeout(t,e)});async function $H(e,t,n=QH){for(let r=0;;r++){try{await e()}catch(e){if(r>=XH.length||!ff(e))throw e;t(),await n(XH[r]);continue}t();return}}function eU(e,t,n,r,i,a=ZH){let o=new AbortController,s=setTimeout(()=>o.abort(Error(`Frizz did not answer this send`)),a);return Y.followUp({slug:e,sessionId:Gp(X.board,e)?.sessionId??``,message:t,deliveryId:n,freshProcess:r,interrupt:i},{signal:o.signal}).finally(()=>clearTimeout(s))}function tU(e,t,n,r,i){return $H(()=>eU(e,t,n,r,i),()=>zH(e))}function nU(e,t,n,r={}){let i=n.trim();if(!i)return!1;let a=KH();return qH({optimistic:()=>{r.onOptimistic?.(),dw(e,t,i,{scrollToBottom:r.scrollToBottom,deliveryId:a}),zH(t),Y.markRead({slug:t}).catch(()=>{})},request:()=>YH(t,()=>tU(t,i,a,r.freshProcess,r.interrupt)),success:()=>r.onSuccess?.(),failure:n=>{fw(e,t,i,a),BH(t),r.onRollback?.(),Z(r.failureToast?.(n.message)??`Steer failed — ${n.message.slice(0,160)}`)}}),!0}function rU(e){let t=Ve(),[n,r]=(0,I.useState)(0);return{submit:(0,I.useCallback)((n,i={})=>nU(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 iU(e,t){return new Promise(n=>{nU(e,t,`Continue exactly where you left off.`,{onSuccess:()=>{Z(`Retrying…`),n()},onRollback:()=>n(),failureToast:e=>`Retry failed: ${e.slice(0,80)}`})||n()})}function aU(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 oU=`Waiting for an external update.`;function sU(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:aU(n)}])})}function cU(e){let t=(e.body??``).split(/\n\s*\n/).map(e=>e.trim()).find(Boolean);return t?dU(lU(t.replace(/\s*\n\s*/g,` `))):null}function lU(e){if(e.length<=uU)return e;let t=e.slice(0,uU),n=t.lastIndexOf(` `);return`${(n>uU/2?t.slice(0,n):t).replace(/[.,;:]$/,``)}…`}var uU=240;function dU(e){let t=(e.split(/\s/,1)[0]??``).replace(/[.,:;]+$/,``);return/[^a-zA-Z]/.test(t)||/[A-Z]/.test(t.slice(1))||fU.has(t)?e:e.charAt(0).toUpperCase()+e.slice(1)}var fU=new Set([`npm`,`npx`,`pnpm`,`nub`,`nubx`,`gh`,`git`,`node`,`bun`,`tsc`,`vite`,`curl`,`ssh`]);function pU(e){return e&&hU(e)||null}var mU=new Set([...rl,`shells`,`agents`,`timers`,`prs`,`for`,`title`]);function hU(e){return e.split(`
200
200
  `).filter(e=>{let t=/^\s*([a-z][a-z-]*):/i.exec(e)?.[1]?.toLowerCase();return!(t&&mU.has(t))}).join(`
201
201
  `).trim()}function gU(e){let t=t=>e.filter(e=>e.kind===t&&e.value.trim()).length,n=[...sU(e).map(e=>e.ref),_U(t(`shell`),`background shell`,`background shells`),_U(t(`agent`),`sub-agent`,`sub-agents`),_U(t(`timer`),`timer`,`timers`)].filter(e=>e!==null);return n.length>0?`waiting on ${vU(n)}`:null}function _U(e,t,n){return e<=0?null:e===1?`a ${t}`:`${e} ${n}`}function vU(e){return e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function yU(e){let t=e.find(e=>e.kind===`pr`);return t?`PR ${t.value}`:null}var bU=qt({at:{}}),xU=12e3,SU=new Map;function CU(e,t=Date.now()){bU.at[e]=t;let n=SU.get(e);n!==void 0&&clearTimeout(n),SU.set(e,setTimeout(()=>{SU.delete(e),delete bU.at[e]},xU))}function wU(e){let t=SU.get(e);t!==void 0&&(clearTimeout(t),SU.delete(e)),delete bU.at[e]}function TU(){return Zt(bU).at}function EU(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 DU(e){let t=TU();return(0,I.useMemo)(()=>e.map(e=>EU(e,t[e.id])),[e,t])}var OU=.5;function kU(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*OU,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 AU(e,t,n,r){return!e||e.top<=r&&e.bottom>r?!0:Math.abs(t-n)>1}function jU(e,t,n,r,i=8){return n<e+i?n-e-i:r>t-i?r-t+i:0}var MU=`flex h-[19px] w-[19px] items-center justify-center rounded text-muted opacity-70 outline-none transition-[color,opacity] hover:bg-panel-2 hover:text-fg hover:opacity-100`,NU=`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 PU(){let e=Zt(X),t=DU(WH(YC(qC()?.threads??[]))),n=oE(t,Zt(yT).queueOrder),r=IT(zT(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(AU(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=kU(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=jU(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:sp(e)??window.scrollY},u(e)},[]);return(0,L.jsx)(`aside`,{className:NU,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)(FH,{}),(0,L.jsx)(Az,{})]}),(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)(HU,{t:e,active:l===e.id,onQueueNavigate:p}),(0,L.jsx)(qU,{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}=aE(a),n=e=>t=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(HU,{t,active:l===t.id,onQueueNavigate:p,restedAge:e}),(0,L.jsx)(qU,{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)(FU,{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)(HU,{t:e,active:l===e.id,onQueueNavigate:p}),(0,L.jsx)(qU,{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)(FU,{label:`Done`,count:s.length,collapsed:i.inactive,onToggle:()=>X.sidebarCollapsed.inactive=!X.sidebarCollapsed.inactive}),!i.inactive&&(0,L.jsx)(RU,{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)(FU,{label:`External`,count:r.length,collapsed:i.external,onToggle:()=>X.sidebarCollapsed.external=!X.sidebarCollapsed.external}),!i.external&&r.map(e=>(0,L.jsx)(HU,{t:e,active:l===e.id,onQueueNavigate:p,restedAge:!0},e.id))]})]})]})})}function FU({label:e,count:t,collapsed:n,onToggle:r}){let i=(0,L.jsxs)(L.Fragment,{children:[r?(0,L.jsx)(ym,{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,LU=8;function RU({threads:e,railRef:t,activeId:n,onQueueNavigate:r}){let i=(0,I.useRef)(null),[a,o]=(0,I.useState)(0),s=Yw({count:e.length,getScrollElement:()=>t.current,getItemKey:t=>e[t]?.id??t,estimateSize:()=>IU,overscan:LU,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)(HU,{t:i,active:n===i.id,onQueueNavigate:r}),(0,L.jsx)(qU,{t:i})]},i.id):null})})}var zU=16,BU=12;function VU({title:e,children:t}){let n=e.trimEnd(),r=n.lastIndexOf(` `)+1,i=n.length-r<=zU?r:n.length-BU;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 HU=(0,I.memo)(function({t:e,legacy:t,active:n=!1,onQueueNavigate:r,restedAge:i=!1}){let a=!t&&e.foreign===!0,o=!t&&KT(e),s=!t&&eE(e)===`archived`,c=o||s,l=!t&&AT(e),u=!t&&tE(e),d=!t&&BT(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`:c?`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&&Tp(e.id)){r?.(e.id);return}bp(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)(QU,{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] ${l?`text-fg/50`:c?`text-fg/75`:`text-fg/90`}`,children:(0,L.jsxs)(VU,{title:CT(e),children:[!t&&(0,L.jsx)(Lz,{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)(JU,{status:e.archived?`archived`:e.status})]})}),i&&(0,L.jsx)(UU,{t:e,yieldsToRetry:!0}),d&&!i&&(0,L.jsx)(GU,{})]})})]}),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)(KI,{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&&!d&&(0,L.jsx)(KU,{t:e,className:`-mr-0.5`}),(0,L.jsx)(rM,{slug:e.id,size:12,className:MU}),u&&(0,L.jsx)(WU,{slug:e.id}),!a&&d&&(0,L.jsx)(KU,{t:e})]})]})});function UU({t:e,yieldsToRetry:t}){let n=TE(),r=PT(e),i=fE(r,n);return!r||!i?null:(0,L.jsx)(`time`,{dateTime:r,"data-rail-rested-age":!0,title:lE(r,n)??void 0,"aria-label":`Rested ${lE(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 WU({slug:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return(0,L.jsx)(nM,{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),iU(t,e).finally(()=>r(!1))},className:`${MU} disabled:opacity-50`,children:n?(0,L.jsx)(Xm,{size:13,className:`animate-spin`}):(0,L.jsx)(dh,{size:13})})})}function GU(){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 opacity-55 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0`,children:(0,L.jsx)(oh,{size:12,fill:`currentColor`})})}function KU({t:e,className:t=``}){let n=BT(e),[r,i]=(0,I.useState)(!1);return(0,L.jsx)(nM,{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:`${MU} disabled:opacity-50 ${t}`,children:n?(0,L.jsx)(ah,{size:12,fill:`currentColor`}):(0,L.jsx)(oh,{size:12})})})}function qU({t:e}){let t=aD(e.subAgents??[],`rail`);return t.length===0?null:(0,L.jsx)(`div`,{className:`flex flex-col`,children:t.map(t=>(0,L.jsx)(cD,{kind:`AGENT`,label:t.label,state:t.state,density:`rail`,depth:t.depth,startedAt:t.startedAt,parentSlug:e.id,onOpen:()=>vp(e.id,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}),onDismiss:aM(e.id,t),title:t.subagentType?`[${t.subagentType}] ${t.label}`:t.label},t.id))})}function JU({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] ${ST[e]??`text-muted border-border`}`,children:t})}function YU(e,t,n=null){return[[t,gU(e.lastFence?.kind===`awaiting`?e.lastFence.hints:[]),n].filter(e=>!!e).join(` — `),XU(e)].filter(e=>!!e).join(`
202
202
 
@@ -306,11 +306,11 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
306
306
  `)}`}function eX(e,t,n,r={}){let i=rU(e),[a,o]=(0,I.useState)({}),s=(0,I.useMemo)(()=>ZY(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)(()=>QY(t)!==-1,[t]),u=Ez(),d=Dz(e),f=(0,I.useCallback)((t,n)=>Tz.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=kz(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];Cz.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)=>xJ(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)=>xJ(e.blocks[t],_(e.identity,t)),l=n.flatMap(e=>e.blocks.map((t,n)=>({ask:e,bi:n,question:nX(t),answer:c(e,n)})).filter(e=>e.answer!==``));if(l.length===0)return;let u=n.find(e=>e.isLive),d=$Y({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,Cz.get(e)]);C(d,{onOptimistic:()=>{r.forEach(e=>Cz.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&&!Cz.get(e)&&Cz.set(e,t)})}})},[a,s,_,C,p,f]),T=(0,I.useCallback)(e=>{let t=v.get(qY(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)=>xJ(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 tX(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 nX(e){return tX(e.contextMd)||tX(e.options.join(` / `))||`earlier question`}function rX(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 iX({raw:e,question:t,questionKind:n,danger:r,interactive:i,wrap:a,aside:o,label:s,settled:c}){let l=(0,I.useMemo)(()=>t??_J(e??``,n??`question`,r),[t,e,n,r]),u=JK(l.contextMd),d=JK(l.trailingMd??``),f=l.recommendedIdx,p=XK(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)(PJ,{tone:h?`risk`:`neutral`,icon:h?xh:void 0,label:s??(m?`Select multiple`:`Question`),aside:o,children:[u&&(0,L.jsx)(`div`,{className:`text-fg`,children:(0,L.jsx)(qq,{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||eR({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)(aX,{md:l.optionHeadings[t],wrap:a}),(0,L.jsx)(sX,{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}eR({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?`${oX(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)(qq,{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)(qq,{className:`md-inline mt-1.5 text-[11px] text-muted/70`,html:p})]})}function aX({md:e,wrap:t}){let n=XK(e.split(`
308
308
  `).join(` `));return(0,L.jsx)(`div`,{className:`mt-1 text-fg`,children:(0,L.jsx)(qq,{className:`md-body${t?` ${EJ}`:``}`,html:n})})}function oX(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 sX({label:e,bodyMd:t,wrap:n,selected:r,settledPick:i,disabled:a,multi:o,recommended:s,recTitle:c,onClick:l}){let u=XK(e),d=JK(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)(gm,{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)(qq,{as:`span`,className:`md-inline`,html:u})]}),t!==void 0&&(0,L.jsx)(qq,{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 cX({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)(Ch,{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)(iX,{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 lX(e){return(0,I.useSyncExternalStore)(e=>Jt(X,e),()=>e?uX(e)!==`codex`:!1,()=>!1)}function uX(e){return Gp(X.board,e)?.backend}function dX(e,t,n,r){let i=Tz.followUp(e,t,n),a=Cz.get(i),o=a?`${r}\n\n${a}`:r;return Cz.set(i,o),i}function fX(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 pX(e){let t=Ve(),n=Ez(),[r,i]=(0,I.useState)(!1);return{unqueue:(0,I.useCallback)(a=>{if(!e||r)return;let o=Gp(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}fw(t,e,a.rawText,a.deliveryId),dX(n,e,o,a.text),fX(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 mX(e){return(0,I.useSyncExternalStore)(e=>Jt(X,e),()=>{if(!e)return!1;let t=Gp(X.board,e);return t?.backend!==`codex`&&t?.runtime===`running`},()=>!1)}function hX(e){let[t,n]=(0,I.useState)(!1);return{deliverNow:(0,I.useCallback)(()=>{if(!e||t)return;let r=Gp(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 gX(e){return e.displayText??e.text}function _X(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 vX(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&&!ZJ(n)))return t}return 0}function yX(e,t){if(e.kind===`event`||e.kind===`reasoning`||e.role!==`user`)return!1;let n=gX(e).replace(/\r\n?/g,`
309
- `);return(t===void 0?YJ(n):t)?!0:!(e.wake||e.peerFrom)}function bX(e,t){return yX(e,t)?`bubble`:`prose`}var xX=`icon-label-nudge`,SX=new Set([`planning`,`planned`,`active`,`needs-human`,`blocked`]);function CX(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&&SX.has(e.status))}function wX(e,t){let n=e.trim();if(!(!n||n===t.trim()))return n}function TX(e,t){let n=e.trim();return!n||n===t||n===`Untitled thread`||n===`Spinning up a thread…`?``:n}function EX(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 DX=`sticky top-0 z-10 flex min-w-0 shrink-0 items-center gap-2.5 border-b border-border bg-panel px-3 ${wh} 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`,OX=`min-w-0 flex-1 pl-1 max-[640px]:basis-full`,kX=`flex shrink-0 items-center max-[640px]:w-full max-[640px]:justify-between`;function AX(e){return e?.trim()?{kind:`profile-error`,message:`Profile controls unavailable: ${e.trim().slice(0,160)}`}:null}function jX(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 MX(e){return e.permissionChangePending===!0||e.permissionPending!==void 0||e.profileChangePending===!0||e.runtimeControlPending===!0}function NX(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 PX(e){return e===`right`?`pl-3 pr-7`:`pl-7 pr-3`}function FX(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 IX=`__frizz_empty_select_value__`,LX=e=>e===``?IX:e,RX=e=>e===IX?``:e,zX={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`},BX={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 VX({o:e,indicatorPosition:t,typography:n}){return(0,L.jsxs)(RI,{value:LX(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 ${PX(t)} ${n??``}`,children:[(0,L.jsx)(zI,{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)(gm,{size:13})}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]})}function HX({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=FX(e,n,r,i),p=s?BX[c]:zX[c],m=c===`readout`?yR:``,[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)(AI,{modal:!1,open:h,onOpenChange:e=>{y.current?.(),y.current=void 0,_.current=e,g(e),e&&(y.current=LR(()=>{_.current=!1,y.current=void 0,g(!1)}))},children:[(0,L.jsx)(jI,{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)(_m,{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)(NI,{align:`start`,side:u,sideOffset:5,onEscapeKeyDown:e=>e.stopPropagation(),className:`${Qj} min-w-[var(--radix-dropdown-menu-trigger-width)] max-w-[calc(100vw-1rem)] overflow-hidden rounded-lg p-1 ${m}`,children:(0,L.jsx)(LI,{value:LX(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)(PI,{children:[e.label&&(0,L.jsx)(FI,{className:`${PX(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)(VX,{o:e,indicatorPosition:l,typography:m},e.value))]},e.label||`g${t}`)):(n??[]).map(e=>(0,L.jsx)(VX,{o:e,indicatorPosition:l,typography:m},e.value))})})})]})}function UX(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 WX(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||MX(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}=UX(p,s,c,t.runtime===`exited`),h=n.data!==void 0,g=[{id:l,label:l===`codex`?`Codex`:`Claude Code`,options:p}],_=AX(n.isError?n.error.message:void 0),v=t.permissionMode?tz(t.permissionMode):`auto`,y=$R.some(e=>e.value===v)?v:`auto`,b=i.isPending?i.variables:y,x=jX(t);function S(e){e!==y&&i.mutate(e,{onSuccess:e=>Z(NX(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)(VR,{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)(HX,{variant:`readout`,side:`top`,value:b,onValueChange:e=>S(e),options:$R,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 GX=new Map;function KX(e){let t=GX.get(e);if(t)return t;let n=Y.threadSkills({slug:e}).then(e=>e.skills,()=>(GX.delete(e),[]));return GX.set(e,n),n}function qX({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=Ez(),u=Tz.followUp(l,e,c?.sessionId),[d,f,p]=Oz(u),m=WX(e),h=rU(e),[g,_]=(0,I.useState)(null),v=(0,I.useMemo)(()=>()=>KX(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}=NL(d),r=t.filter(e=>zL(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=KR(n);if(r){p();let e=c?.backend===`codex`?`codex`:`claude`;r===`login`?_(e):b(e);return}let i=Pp(e),a=JL(n,i,l),s={onOptimistic:p,onRollback:()=>{Cz.get(u)||f(d),Fp(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)(mR,{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)(JR,{backend:g,onClose:()=>_(null),onAuthed:()=>_(null)}),y&&(0,L.jsx)(YR,{backend:y,onClose:()=>b(null)})]})}function JX({slug:e,ops:t}){let n=Zt(X).board?.threads.find(t=>t.id===e);return n?(0,L.jsx)(qX,{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 YX({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)(nM,{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:yD,children:(0,L.jsx)(sh,{size:14,strokeWidth:2})})})}function XX(e,t){return new Promise(n=>{nU(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 ZX(){return oH(gH().data??null)}function QX({thread:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return!ZX()||e.kind!==`session`||e.foreign||e.backend===`codex`||e.runtime===`exited`?null:(0,L.jsx)(nM,{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),XX(t,e.id).finally(()=>r(!1))},className:`${yD} mx-[2px]`,children:n?(0,L.jsx)(Xm,{size:14,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(lh,{size:14,strokeWidth:2})})})}function $X({slug:e,label:t=`Exit fullscreen`}){let n=vD(e)??hw(`/`);function r(e){zd(e)&&(e.preventDefault(),bw(n,{viewTransition:!Xp()}))}return(0,L.jsx)(nM,{label:t,children:(0,L.jsx)(`a`,{href:n,"aria-label":t,"data-standalone-return":!0,onMouseDown:e=>e.preventDefault(),onClick:r,className:yD,children:(0,L.jsx)(th,{size:14})})})}function eZ({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)(nZ,{label:o?`Expand`:`Collapse`,icon:o?xm:bm,size:13,onClick:a}),(0,L.jsx)(YX,{thread:e}),(0,L.jsx)(QX,{thread:e}),r&&(0,L.jsx)(nZ,{label:`Frizz document`,icon:Pm,size:14,onClick:r}),t&&(0,L.jsx)(rM,{slug:e.id}),n&&(0,L.jsx)($X,{slug:e.id}),d?tE(e)?(0,L.jsx)(tZ,{slug:e.id}):null:(0,L.jsx)(`div`,{className:`ml-1`,children:(0,L.jsx)(KI,{slug:e.id,onDone:i,doneBusy:s,onMutateStart:c,onApplied:l,onFailed:u})})]})}function tZ({slug:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return(0,L.jsx)(nM,{label:`Retry — resume this session where it left off`,children:(0,L.jsxs)(`button`,{onClick:()=>{r(!0),iU(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)(Xm,{size:12,className:`animate-spin`}):(0,L.jsx)(dh,{size:12}),`Retry`]})})}function nZ({label:e,icon:t,size:n,busy:r,...i}){return(0,L.jsx)(nM,{label:e,children:(0,L.jsx)(`button`,{...i,"aria-label":e,onMouseDown:e=>e.preventDefault(),className:yD,children:r?(0,L.jsx)(Xm,{size:n,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(t,{size:n,strokeWidth:2})})})}function rZ(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 iZ(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 aZ(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=[oZ(`agent`,`sub-agent`,e.subAgents,e.subAgentCount),oZ(`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 oZ(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 sZ({open:e,onOpenChange:t,title:n,children:r,footer:i,className:a=`w-[640px] max-w-[92vw] max-h-[82vh]`}){return(0,L.jsx)(QI,{open:e,onOpenChange:t,children:(0,L.jsxs)(iL,{children:[(0,L.jsx)(oL,{className:`overlay-in fixed inset-0 z-[200] bg-black/55 backdrop-blur-[1px]`}),(0,L.jsxs)(uL,{"aria-modal":`true`,onEscapeKeyDown:zR,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)(hL,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:n}),(0,L.jsx)(yL,{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)(Ch,{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 cZ({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=GT(e),g=Zt(yT).snoozePreset,_=tT(g),v=rT(g),y=(0,I.useMemo)(()=>oT(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`} · ${cT(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){yT.snoozePreset=e,b(iT(e))}function S(){s(oT(new Date(h??iT(g)))),l(e.snoozePrompt??``),d(``),a(!0)}function C(){let e=sT(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 · ${cT(h)}`:v,onClick:()=>void b(h?null:iT(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)(Xm,{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)(VI,{children:[(0,L.jsx)(HI,{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)(_m,{size:12})})}),(0,L.jsxs)(UI,{align:`end`,children:[Qw.map(e=>(0,L.jsx)(WI,{onSelect:()=>x(e.value),icon:(0,L.jsx)(km,{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)(GI,{}),(0,L.jsx)(WI,{onSelect:S,children:`Custom time & prompt…`}),h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(GI,{}),(0,L.jsx)(WI,{onSelect:()=>void b(null),children:`Wake now`})]})]})]})]}),(0,L.jsx)(sZ,{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)(Xm,{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=>{eR({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 lZ=1.25,uZ=7.5-lZ/2,dZ=2*Math.PI*uZ;function fZ(e,t){return Math.max(0,Math.min(100,Math.floor(e/t*100)))}function pZ({thread:e}){let t=e.context;if(!t||t.window<=0)return null;let n=fZ(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)(nM,{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:uZ,fill:`none`,stroke:`currentColor`,strokeOpacity:.3,strokeWidth:lZ}),(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:uZ,fill:`none`,stroke:`currentColor`,strokeWidth:lZ,strokeDasharray:`${dZ*r} ${dZ}`})]})})})}var mZ={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 hZ({checked:e,onChange:t,disabled:n,label:r,size:i=`sm`,testId:a}){let o=mZ[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 gZ({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 _Z({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),vZ)}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)(TV,{open:t!==`closed`,onOpenChange:e=>{e||(clearTimeout(i.current),n(`closed`))},children:[(0,L.jsx)(DV,{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 ${aR}`,children:(0,L.jsx)(gZ,{size:12,className:o?`text-amber-400/90`:`text-muted/60 hover:text-muted`})})}),t===`preview`?(0,L.jsx)(OV,{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)(yZ,{armed:a})}):(0,L.jsx)(OV,{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)(kZ,{thread:e,armed:a,close:()=>n(`closed`)})})]})}var vZ=260;function yZ({armed:e}){let t=e?.prompt?.trim(),n=e?OZ({stopHook:e.stopHook===!0,heartbeat:e.heartbeat===!0,postCompaction:e.postCompaction===!0,seconds:e.intervalSeconds??SZ}):[];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 bZ=1,xZ=1440,SZ=600;function CZ(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(xZ,Math.max(bZ,n))*60:t}var wZ=null;function TZ(e){return{prompt:e.text.trim(),stopHook:e.stopHook,heartbeat:e.heartbeat,postCompaction:e.postCompaction,seconds:e.seconds}}function EZ(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 DZ(e,t){return!e.archived&&!t}function OZ(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 kZ({thread:e,armed:t,close:n}){let r=DZ(e,t)?_l:``,i=wZ?.slug===e.id?wZ.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??SZ),h=s||l||d,[g,_]=(0,I.useState)(String(Math.round((i?.seconds??t?.intervalSeconds??SZ)/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??SZ}),b=e=>({text:a,stopHook:s,heartbeat:l,postCompaction:d,seconds:CZ(g,p),...e}),x=(0,I.useRef)(b());x.current=b(),(0,I.useEffect)(()=>()=>{let n=x.current;if(EZ(n,y.current)){wZ?.slug===e.id&&(wZ=null);return}if(n.text.trim()===``&&!t){wZ={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?wZ?.slug===e.id&&(wZ=null):wZ={slug:e.id,draft:t},n});return S.current=n,n}async function w(t){let n=t.text.trim()||null;if(EZ(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={...TZ(t),prompt:n??``};let r=OZ(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(EZ(b(),y.current)||a.trim()===``&&!t){n();return}C(b()).then(e=>{e&&n()})}function E(){let e=CZ(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 ${HE(O.at)}`:`Last sent ${O.how} ${HE(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=>{eR({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)(hZ,{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)(hZ,{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:bZ,max:xZ,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)(hZ,{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 AZ({thread:e,sticky:t=!1,safeArea:n=!1,onArchived:r,onDismissCancel:i,onSnoozed:a}){let o=rZ(e);return o.footer?(0,L.jsxs)(`footer`,{"aria-label":`Thread lifecycle actions`,"data-thread-lifecycle-footer":!0,className:`${t?`z-20`:kJ} flex min-h-10 shrink-0 flex-wrap items-center justify-end ${rR} 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 ${rR}`,children:[(0,L.jsx)(pZ,{thread:e}),(0,L.jsx)(MZ,{thread:e}),(0,L.jsx)(_Z,{thread:e})]}),o.done?(0,L.jsx)(jZ,{}):(0,L.jsxs)(L.Fragment,{children:[o.snooze&&(0,L.jsx)(cZ,{thread:e,onSnoozed:a}),(0,L.jsx)(NZ,{thread:e,onArchived:r,onDismissCancel:i})]})]}):null}function jZ(){let e=`Marked done — send a message to reopen it`;return(0,L.jsx)(nM,{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)(gm,{size:12}),`Done`]})})}function MZ({thread:e}){let t=GT(e);if(!t)return null;let n=e.snoozePrompt?.trim(),r=n?`Bumps ${cT(t)}\n${n}`:`Snoozed until ${cT(t)}`;return(0,L.jsx)(nM,{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 ${iR}`,children:(0,L.jsx)(Um,{size:12})})})}function NZ({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||iZ(e))&&CU(e.id),Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:r}).then(r=>{if(r.needsConfirmation){wU(e.id),i&&n?.(),u(r.hold),c(!0),o(!1);return}c(!1),Z(`Done`),i||t?.()}).catch(t=>{wU(e.id),i&&n?.(),Z(`Couldn’t finish: ${t.message.slice(0,80)}`),o(!1)})},f=!!t&&!!n&&iZ(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)(gm,{size:12,className:i}),`Mark as done`]}),(0,L.jsx)(sZ,{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)(Xm,{size:12,className:`animate-spin`}),l?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,L.jsx)(PZ,{hold:l})})]})}function PZ({hold:e}){let t=aZ(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:WE,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 FZ({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=EX(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)(nM,{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)(Xm,{size:12,className:`animate-spin`}):(0,L.jsx)(fh,{size:12})})})}var IZ=new Set([`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]);function LZ(e,t){let n=e.lastIndexOf(t);if(n<=0)return{model:e};let r=e.slice(n+1);return IZ.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}=LZ(t.slice(6).replace(/^frizz-/,``),`-`);return n?`${e} › ${n}`:e}let n=t.split(/\s+/),{model:r,effort:i}=LZ(n.at(-1)??t,`/`);if(!i)return t;let a=n.slice(0,-1).join(` `);return`${a?`${a} · `:``}${r} › ${i}`}function zZ(e){return e?.trim()?RZ(e):void 0}function BZ(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 VZ={completed:`finished`,killed:`stopped`,failed:`failed`};function HZ(e){let t=VZ[e.agentStatus??`completed`],n=e.agentElapsedMs===void 0?void 0:zE(e.agentElapsedMs);return{outcome:t,tail:`${t}${n?` · ${n}`:``}`}}var UZ=e=>e===void 0?void 0:PE(e),WZ=e=>{if(e!==void 0)return zE(e)||void 0};function GZ(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=UZ(n);return{label:t===`completed`?void 0:VZ[t],duration:WZ(n),tone:r?`failed`:`muted`,title:`${e?`Stopped`:r?`Failed`:`Ran for`}${e||r?` after`:``} ${i??`an unknown time`}`}}if(r){let e=UZ(i);return{label:void 0,duration:WZ(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=UZ(o);return{label:c?VZ.killed:s?VZ.failed:void 0,duration:WZ(o),tone:s?`failed`:`muted`,title:`${c?`Stopped after`:s?`Failed after`:`Ran for`} ${l??`an unknown time`}`}}var KZ=`group flex min-w-0 items-baseline gap-1.5 rounded-sm py-0.5 text-left text-[11.5px] leading-5 outline-none focus-visible:ring-1 focus-visible:ring-fg/60`,qZ=`h-[1em] w-[1em] shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)] text-muted/45`;function JZ({links:e}){return e.length?(0,L.jsx)(`div`,{"data-thread-links":!0,"aria-label":`Registered links`,className:`mt-2 flex min-w-0 flex-col gap-0.5 border-t border-border pt-1.5`,children:e.map(e=>{let t=e.kind===`link`,n=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:WE,children:`⤷`}),(0,L.jsx)(t?Mm:Pm,{"aria-hidden":!0,className:qZ}),(0,L.jsx)(`span`,{"data-link-kind":!0,className:`petite-caps w-[33px] shrink-0 text-[9px] text-muted/45`,children:t?`Link`:`File`}),(0,L.jsx)(`span`,{"data-link-label":!0,className:`min-w-0 flex-1 truncate text-muted/70 group-hover:text-fg/80 group-hover:underline`,children:e.label}),t&&(0,L.jsx)(`span`,{"data-link-destination":!0,className:`font-mono-keep ml-auto max-w-[45%] min-w-0 truncate text-right text-[10px] text-muted/45`,children:e.target})]});return t?(0,L.jsx)(`a`,{"data-thread-link":e.id,href:e.target,target:`_blank`,rel:`noopener noreferrer`,title:e.target,className:KZ,onClick:e=>e.stopPropagation(),children:n},e.id):(0,L.jsx)(`button`,{"data-thread-link":e.id,type:`button`,title:e.target,className:`${KZ} cursor-pointer`,onClick:t=>{t.stopPropagation(),wq(e.target)},children:n},e.id)})}):null}function YZ({at:e,host:t}){let n=pE(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 XZ({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)(YZ,{at:e,host:t})]})}var ZZ=`text-[14px] leading-5 text-muted`,QZ=`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 $Z(e){return`${QZ} ${e?`-mx-[0.208em] rotate-90`:`-mx-[0.333em]`}`}var $=I.createElement;function eQ({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,$(tQ,{label:`Redacted command preview`,text:e.command.preview}),e.command.actions?$(nQ,{actions:e.command.actions}):null,e.capabilities?$(iQ,{capabilities:e.capabilities}):null):e.kind===`file-approval`?$(I.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},cQ(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?$(tQ,{label:`Plain-text diff preview`,text:e.diffPreview}):null,e.changes?$(rQ,{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?$(iQ,{capabilities:e.capabilities}):null)}function tQ({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 nQ({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`},sQ(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,$(tQ,{label:`${sQ(e.kind)} command detail`,text:e.commandPreview})))))}function rQ({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`},cQ(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?$(tQ,{label:`${cQ(e.operation)} plain-text diff`,text:e.diffPreview}):null))))}function iQ({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`},$(aQ,{capability:e})))))}function aQ({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?$(oQ,{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),$(oQ,{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`),$(oQ,{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`),$(oQ,{label:`Hosts`,values:e.hosts}))}function oQ({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 sQ(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 cQ(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 lQ(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 uQ={semantic:`approve`,label:`Approve once`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`},dQ={semantic:`approve`,label:`Approve for session`,order:20,tone:`primary`,durable:!0,scope:`Persists for later matching requests in this thread session.`},fQ={semantic:`approve`,label:`Grant for turn`,order:10,tone:`primary`,durable:!1,scope:`Applies to this turn only.`},pQ={semantic:`approve`,label:`Grant for session`,order:20,tone:`primary`,durable:!0,scope:`Persists until this thread session ends.`},mQ={semantic:`deny`,label:`Deny`,order:70,tone:`danger`,durable:!1,scope:`Rejects this request.`},hQ={semantic:`decline`,label:`Decline`,order:70,tone:`danger`,durable:!1,scope:`Declines this request.`},gQ={semantic:`cancel`,label:`Cancel request`,order:80,tone:`neutral`,durable:!1,scope:`Cancels this pending request.`};function _Q(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`?uQ:n===`acceptForSession`&&r===`approve`?dQ:(n===`decline`||n===`deny`)&&r===`deny`?mQ:n===`cancel`&&r===`cancel`?gQ:void 0;if(e.kind===`permission-approval`)return n===`grant-turn`&&r===`approve`?fQ:n===`grant-session`&&r===`approve`?pQ:(n===`deny`||n===`decline`)&&r===`deny`?mQ:n===`cancel`&&r===`cancel`?gQ: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`?hQ:n===`cancel`&&r===`cancel`?gQ: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 hQ;if(n===`cancel`&&r===`cancel`)return gQ}function vQ(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=_Q(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 yQ(e){switch(e){case`claude`:return`Claude`;case`codex`:return`Codex`;case`frizz`:return`Frizz`}}function bQ(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 xQ(e,t){let n=e.options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t));return n<0?``:String(n)}function SQ(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?``:xQ(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 CQ(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 wQ(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 TQ(e,t){return JSON.stringify([e,t??null])}function EQ(e,t){try{let n=new URL(e,t);return n.protocol===`http:`||n.protocol===`https:`?n.toString():null}catch{return null}}function DQ(e,t){let n=e.getAttribute(`href`);if(!n)return!1;let r=EQ(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 OQ(e=()=>location.href){return t=>{if(t.defaultPrevented||t.button!==0)return;let n=AQ(t);n&&DQ(n,e())}}function kQ(){let e=OQ();return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)}function AQ(e){let t=typeof e.composedPath==`function`?e.composedPath():[];for(let e of t)if(jQ(e))return e;let n=e.target?.closest?.(`a[href]`);return jQ(n)?n:null}function jQ(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 MQ(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 NQ(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)=>`${MQ(t)} ${e.label}`),recommendedIdx:null},...e?{optionFieldId:e.id}:{},optionValues:r.map(e=>e.value),...t?{notesFieldId:t.id}:{}}}function PQ(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=NQ(r,a);if(!e)return null;n.push(e)}else if(r.input===`text`||r.input===`multiline`){let e=NQ(void 0,r);if(!e)return null;n.push(e)}else return null}return n.length>0?n:null}function FQ(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)=>`${MQ(t)} ${e.label}${e.description?` — ${e.description}`:``}`),recommendedIdx:null},chosenIdxs:n,text:r}}function IQ(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 LQ(e){let t=e instanceof Error?e.message:`The request could not be updated.`;return t.length>240?`${t.slice(0,239)}…`:t}function RQ(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`frizz-response-${Date.now()}-${Math.random().toString(36).slice(2)}`}function zQ({thread:e,className:t=``,autoFocusFirst:n=!1}){let r=QC(e),i=ew(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:`${DJ} 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:LQ(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)(VQ,{record:e,autoFocus:n&&t===0},e.id))}):null}function BQ({record:e,questions:t,autoFocus:n}){let r=Ve(),i=(0,I.useRef)(null),a=(0,I.useRef)(new Map),o=Ez(),s=lQ(e.delivery?.effect),c=(0,I.useMemo)(()=>vQ(e).find(e=>e.semantic===`answer`),[e]),l=kz(t.flatMap(t=>t.notesFieldId?[Tz.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(Tz.interaction(o,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId))??``:``})),p=IQ(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),Qb(r,t.interaction),r.invalidateQueries({queryKey:Xb(e.owner.threadSlug,e.owner.sessionId)}),r.invalidateQueries({queryKey:Zb(e.owner.threadSlug,e.owner.sessionId,e.id)})},onError:t=>{$b(r,e),h(LQ(t))}}),y=()=>{if(!c||!p||v.isPending||g||!s.actionsEnabled)return;h(void 0);let e=TQ(c.id,p),t=a.current.get(e)??RQ();a.current.set(e,t),v.mutate({decisionId:c.id,values:p,responseId:t})},b=(t,n)=>{t.notesFieldId&&Cz.set(Tz.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)(iX,{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 VQ({record:e,autoFocus:t=!1}){let n=(0,I.useMemo)(()=>PQ(e),[e]);return n?(0,L.jsx)(BQ,{record:e,questions:n,autoFocus:t}):(0,L.jsx)(HQ,{record:e,autoFocus:t})}function HQ({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=Ez(),l=o.filter(e=>!e.secret&&(e.input===`text`||e.input===`multiline`)).map(t=>Tz.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.id)),u=kz(l),[d,f]=(0,I.useState)(()=>SQ(o)),p=(0,I.useMemo)(()=>{let t={...d};return o.forEach(n=>{if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=Tz.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=lQ(e.delivery?.effect),D=(0,I.useMemo)(()=>vQ(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`&&Cz.set(Tz.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(TQ(r.decision.id,r.values)),_(void 0),C(void 0),T(!1),x(!0),l.forEach(e=>Cz.clear(e)),y(t.waitingForProvider?`Response sent. Waiting for the provider to acknowledge it…`:`Request completed.`),Qb(n,t.interaction),n.setQueryData(Zb(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t.interaction}),n.invalidateQueries({queryKey:Xb(e.owner.threadSlug,e.owner.sessionId),exact:!0}),t.waitingForProvider&&window.setTimeout(()=>{n.invalidateQueries({queryKey:Xb(e.owner.threadSlug,e.owner.sessionId),exact:!0})},1e3)},onError:t=>{y(void 0),_(LQ(t)),$b(n,e),Y.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{Qb(n,t),n.setQueryData(Zb(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:Xb(e.owner.threadSlug,e.owner.sessionId),exact:!0})),n.invalidateQueries({queryKey:Xb(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}});function j(e){if(!e.requiresValues){h({});return}let t=wQ(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=TQ(e.id,n),i=a.current.get(r)??RQ();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 ${DJ} 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)(mh,{"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||eR({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)(WQ,{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)(qm,{"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)(xh,{"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:UQ(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}`))]}),!GQ.has(e.payload.kind)&&(0,L.jsx)(JQ,{record:e})]})})]})}function UQ(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 WQ({record:e,instanceId:t,draft:n,setDraft:r,errors:i,autoFocus:a}){let o=e.payload,s=(e,t)=>r(CQ(n,e,t)),c;return c=o.kind===`command-approval`||o.kind===`file-approval`||o.kind===`permission-approval`?(0,L.jsx)(eQ,{payload:o}):o.kind===`mcp-elicitation-url`?(0,L.jsx)(qQ,{url:o.url}):(0,L.jsx)(YQ,{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)(KQ,{text:o.message}),(0,L.jsx)(`div`,{className:`message`in o&&o.message?`mt-3`:``,children:c})]})}var GQ=new Set([`command-approval`,`file-approval`,`permission-approval`]);function KQ({text:e}){return e.length>600||e.split(`
309
+ `);return(t===void 0?YJ(n):t)?!0:!(e.wake||e.peerFrom)}function bX(e,t){return yX(e,t)?`bubble`:`prose`}var xX=`icon-label-nudge`,SX=new Set([`planning`,`planned`,`active`,`needs-human`,`blocked`]);function CX(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&&SX.has(e.status))}function wX(e,t){let n=e.trim();if(!(!n||n===t.trim()))return n}function TX(e,t){let n=e.trim();return!n||n===t||n===`Untitled thread`||n===`Spinning up a thread…`?``:n}function EX(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 DX=`sticky top-0 z-10 flex min-w-0 shrink-0 items-center gap-2.5 border-b border-border bg-panel px-3 ${wh} 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`,OX=`min-w-0 flex-1 pl-1 max-[640px]:basis-full`,kX=`flex shrink-0 items-center max-[640px]:w-full max-[640px]:justify-between`;function AX(e){return e?.trim()?{kind:`profile-error`,message:`Profile controls unavailable: ${e.trim().slice(0,160)}`}:null}function jX(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 MX(e){return e.permissionChangePending===!0||e.permissionPending!==void 0||e.profileChangePending===!0||e.runtimeControlPending===!0}function NX(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 PX(e){return e===`right`?`pl-3 pr-7`:`pl-7 pr-3`}function FX(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 IX=`__frizz_empty_select_value__`,LX=e=>e===``?IX:e,RX=e=>e===IX?``:e,zX={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`},BX={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 VX({o:e,indicatorPosition:t,typography:n}){return(0,L.jsxs)(RI,{value:LX(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 ${PX(t)} ${n??``}`,children:[(0,L.jsx)(zI,{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)(gm,{size:13})}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]})}function HX({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=FX(e,n,r,i),p=s?BX[c]:zX[c],m=c===`readout`?yR:``,[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)(AI,{modal:!1,open:h,onOpenChange:e=>{y.current?.(),y.current=void 0,_.current=e,g(e),e&&(y.current=LR(()=>{_.current=!1,y.current=void 0,g(!1)}))},children:[(0,L.jsx)(jI,{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)(_m,{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)(NI,{align:`start`,side:u,sideOffset:5,onEscapeKeyDown:e=>e.stopPropagation(),className:`${Qj} min-w-[var(--radix-dropdown-menu-trigger-width)] max-w-[calc(100vw-1rem)] overflow-hidden rounded-lg p-1 ${m}`,children:(0,L.jsx)(LI,{value:LX(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)(PI,{children:[e.label&&(0,L.jsx)(FI,{className:`${PX(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)(VX,{o:e,indicatorPosition:l,typography:m},e.value))]},e.label||`g${t}`)):(n??[]).map(e=>(0,L.jsx)(VX,{o:e,indicatorPosition:l,typography:m},e.value))})})})]})}function UX(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 WX(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||MX(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}=UX(p,s,c,t.runtime===`exited`),h=n.data!==void 0,g=[{id:l,label:l===`codex`?`Codex`:`Claude Code`,options:p}],_=AX(n.isError?n.error.message:void 0),v=t.permissionMode?tz(t.permissionMode):`auto`,y=$R.some(e=>e.value===v)?v:`auto`,b=i.isPending?i.variables:y,x=jX(t);function S(e){e!==y&&i.mutate(e,{onSuccess:e=>Z(NX(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)(VR,{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)(HX,{variant:`readout`,side:`top`,value:b,onValueChange:e=>S(e),options:$R,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 GX=new Map;function KX(e){let t=GX.get(e);if(t)return t;let n=Y.threadSkills({slug:e}).then(e=>e.skills,()=>(GX.delete(e),[]));return GX.set(e,n),n}function qX({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=Ez(),u=Tz.followUp(l,e,c?.sessionId),[d,f,p]=Oz(u),m=WX(e),h=rU(e),[g,_]=(0,I.useState)(null),v=(0,I.useMemo)(()=>()=>KX(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}=NL(d),r=t.filter(e=>zL(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=KR(n);if(r){p();let e=c?.backend===`codex`?`codex`:`claude`;r===`login`?_(e):b(e);return}let i=Pp(e),a=JL(n,i,l),s={onOptimistic:p,onRollback:()=>{Cz.get(u)||f(d),Fp(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)(mR,{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)(JR,{backend:g,onClose:()=>_(null),onAuthed:()=>_(null)}),y&&(0,L.jsx)(YR,{backend:y,onClose:()=>b(null)})]})}function JX({slug:e,ops:t}){let n=Zt(X).board?.threads.find(t=>t.id===e);return n?(0,L.jsx)(qX,{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 YX({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)(nM,{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:yD,children:(0,L.jsx)(sh,{size:14,strokeWidth:2})})})}function XX(e,t){return new Promise(n=>{nU(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 ZX(){return oH(gH().data??null)}function QX({thread:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return!ZX()||e.kind!==`session`||e.foreign||e.backend===`codex`||e.runtime===`exited`?null:(0,L.jsx)(nM,{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),XX(t,e.id).finally(()=>r(!1))},className:`${yD} mx-[2px]`,children:n?(0,L.jsx)(Xm,{size:14,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(lh,{size:14,strokeWidth:2})})})}function $X({slug:e,label:t=`Exit fullscreen`}){let n=vD(e)??hw(`/`);function r(e){zd(e)&&(e.preventDefault(),bw(n,{viewTransition:!Xp()}))}return(0,L.jsx)(nM,{label:t,children:(0,L.jsx)(`a`,{href:n,"aria-label":t,"data-standalone-return":!0,onMouseDown:e=>e.preventDefault(),onClick:r,className:yD,children:(0,L.jsx)(th,{size:14})})})}function eZ({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)(nZ,{label:o?`Expand`:`Collapse`,icon:o?xm:bm,size:13,onClick:a}),(0,L.jsx)(YX,{thread:e}),(0,L.jsx)(QX,{thread:e}),r&&(0,L.jsx)(nZ,{label:`Frizz document`,icon:Pm,size:14,onClick:r}),t&&(0,L.jsx)(rM,{slug:e.id}),n&&(0,L.jsx)($X,{slug:e.id}),d?tE(e)?(0,L.jsx)(tZ,{slug:e.id}):null:(0,L.jsx)(`div`,{className:`ml-1`,children:(0,L.jsx)(KI,{slug:e.id,onDone:i,doneBusy:s,onMutateStart:c,onApplied:l,onFailed:u})})]})}function tZ({slug:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return(0,L.jsx)(nM,{label:`Retry — resume this session where it left off`,children:(0,L.jsxs)(`button`,{onClick:()=>{r(!0),iU(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)(Xm,{size:12,className:`animate-spin`}):(0,L.jsx)(dh,{size:12}),`Retry`]})})}function nZ({label:e,icon:t,size:n,busy:r,...i}){return(0,L.jsx)(nM,{label:e,children:(0,L.jsx)(`button`,{...i,"aria-label":e,onMouseDown:e=>e.preventDefault(),className:yD,children:r?(0,L.jsx)(Xm,{size:n,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(t,{size:n,strokeWidth:2})})})}function rZ(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 iZ(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 aZ(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=[oZ(`agent`,`sub-agent`,e.subAgents,e.subAgentCount),oZ(`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 oZ(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 sZ({open:e,onOpenChange:t,title:n,children:r,footer:i,className:a=`w-[640px] max-w-[92vw] max-h-[82vh]`}){return(0,L.jsx)(QI,{open:e,onOpenChange:t,children:(0,L.jsxs)(iL,{children:[(0,L.jsx)(oL,{className:`overlay-in fixed inset-0 z-[200] bg-black/55 backdrop-blur-[1px]`}),(0,L.jsxs)(uL,{"aria-modal":`true`,onEscapeKeyDown:zR,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)(hL,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:n}),(0,L.jsx)(yL,{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)(Ch,{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 cZ({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=GT(e),g=Zt(yT).snoozePreset,_=tT(g),v=rT(g),y=(0,I.useMemo)(()=>oT(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`} · ${cT(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){yT.snoozePreset=e,b(iT(e))}function S(){s(oT(new Date(h??iT(g)))),l(e.snoozePrompt??``),d(``),a(!0)}function C(){let e=sT(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 · ${cT(h)}`:v,onClick:()=>void b(h?null:iT(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)(Xm,{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)(VI,{children:[(0,L.jsx)(HI,{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)(_m,{size:12})})}),(0,L.jsxs)(UI,{align:`end`,children:[Qw.map(e=>(0,L.jsx)(WI,{onSelect:()=>x(e.value),icon:(0,L.jsx)(km,{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)(GI,{}),(0,L.jsx)(WI,{onSelect:S,children:`Custom time & prompt…`}),h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(GI,{}),(0,L.jsx)(WI,{onSelect:()=>void b(null),children:`Wake now`})]})]})]})]}),(0,L.jsx)(sZ,{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)(Xm,{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=>{eR({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 lZ=1.25,uZ=7.5-lZ/2,dZ=2*Math.PI*uZ;function fZ(e,t){return Math.max(0,Math.min(100,Math.floor(e/t*100)))}function pZ({thread:e}){let t=e.context;if(!t||t.window<=0)return null;let n=fZ(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)(nM,{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:uZ,fill:`none`,stroke:`currentColor`,strokeOpacity:.3,strokeWidth:lZ}),(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:uZ,fill:`none`,stroke:`currentColor`,strokeWidth:lZ,strokeDasharray:`${dZ*r} ${dZ}`})]})})})}var mZ={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 hZ({checked:e,onChange:t,disabled:n,label:r,size:i=`sm`,testId:a}){let o=mZ[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 gZ({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 _Z({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),vZ)}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)(TV,{open:t!==`closed`,onOpenChange:e=>{e||(clearTimeout(i.current),n(`closed`))},children:[(0,L.jsx)(DV,{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 ${aR}`,children:(0,L.jsx)(gZ,{size:12,className:o?`text-amber-400/90`:`text-muted/60 hover:text-muted`})})}),t===`preview`?(0,L.jsx)(OV,{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)(yZ,{armed:a})}):(0,L.jsx)(OV,{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)(kZ,{thread:e,armed:a,close:()=>n(`closed`)})})]})}var vZ=260;function yZ({armed:e}){let t=e?.prompt?.trim(),n=e?OZ({stopHook:e.stopHook===!0,heartbeat:e.heartbeat===!0,postCompaction:e.postCompaction===!0,seconds:e.intervalSeconds??SZ}):[];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 bZ=1,xZ=1440,SZ=600;function CZ(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(xZ,Math.max(bZ,n))*60:t}var wZ=null;function TZ(e){return{prompt:e.text.trim(),stopHook:e.stopHook,heartbeat:e.heartbeat,postCompaction:e.postCompaction,seconds:e.seconds}}function EZ(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 DZ(e,t){return!e.archived&&!t}function OZ(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 kZ({thread:e,armed:t,close:n}){let r=DZ(e,t)?_l:``,i=wZ?.slug===e.id?wZ.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??SZ),h=s||l||d,[g,_]=(0,I.useState)(String(Math.round((i?.seconds??t?.intervalSeconds??SZ)/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??SZ}),b=e=>({text:a,stopHook:s,heartbeat:l,postCompaction:d,seconds:CZ(g,p),...e}),x=(0,I.useRef)(b());x.current=b(),(0,I.useEffect)(()=>()=>{let n=x.current;if(EZ(n,y.current)){wZ?.slug===e.id&&(wZ=null);return}if(n.text.trim()===``&&!t){wZ={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?wZ?.slug===e.id&&(wZ=null):wZ={slug:e.id,draft:t},n});return S.current=n,n}async function w(t){let n=t.text.trim()||null;if(EZ(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={...TZ(t),prompt:n??``};let r=OZ(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(EZ(b(),y.current)||a.trim()===``&&!t){n();return}C(b()).then(e=>{e&&n()})}function E(){let e=CZ(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 ${HE(O.at)}`:`Last sent ${O.how} ${HE(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=>{eR({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)(hZ,{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)(hZ,{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:bZ,max:xZ,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)(hZ,{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 AZ({thread:e,sticky:t=!1,safeArea:n=!1,onArchived:r,onDismissCancel:i,onSnoozed:a}){let o=rZ(e);return o.footer?(0,L.jsxs)(`footer`,{"aria-label":`Thread lifecycle actions`,"data-thread-lifecycle-footer":!0,className:`${t?`z-20`:kJ} flex min-h-10 shrink-0 flex-wrap items-center justify-end ${rR} 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 ${rR}`,children:[(0,L.jsx)(pZ,{thread:e}),(0,L.jsx)(MZ,{thread:e}),(0,L.jsx)(_Z,{thread:e})]}),o.done?(0,L.jsx)(jZ,{}):(0,L.jsxs)(L.Fragment,{children:[o.snooze&&(0,L.jsx)(cZ,{thread:e,onSnoozed:a}),(0,L.jsx)(NZ,{thread:e,onArchived:r,onDismissCancel:i})]})]}):null}function jZ(){let e=`Marked done — send a message to reopen it`;return(0,L.jsx)(nM,{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)(gm,{size:12}),`Done`]})})}function MZ({thread:e}){let t=GT(e);if(!t)return null;let n=e.snoozePrompt?.trim(),r=n?`Bumps ${cT(t)}\n${n}`:`Snoozed until ${cT(t)}`;return(0,L.jsx)(nM,{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 ${iR}`,children:(0,L.jsx)(Um,{size:12})})})}function NZ({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||iZ(e))&&CU(e.id),Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:r}).then(r=>{if(r.needsConfirmation){wU(e.id),i&&n?.(),u(r.hold),c(!0),o(!1);return}c(!1),Z(`Done`),i||t?.()}).catch(t=>{wU(e.id),i&&n?.(),Z(`Couldn’t finish: ${t.message.slice(0,80)}`),o(!1)})},f=!!t&&!!n&&iZ(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)(gm,{size:12,className:i}),`Mark as done`]}),(0,L.jsx)(sZ,{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)(Xm,{size:12,className:`animate-spin`}),l?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,L.jsx)(PZ,{hold:l})})]})}function PZ({hold:e}){let t=aZ(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:WE,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 FZ({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=EX(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)(nM,{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)(Xm,{size:12,className:`animate-spin`}):(0,L.jsx)(fh,{size:12})})})}var IZ=new Set([`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]);function LZ(e,t){let n=e.lastIndexOf(t);if(n<=0)return{model:e};let r=e.slice(n+1);return IZ.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}=LZ(t.slice(6).replace(/^frizz-/,``),`-`);return n?`${e} › ${n}`:e}let n=t.split(/\s+/),{model:r,effort:i}=LZ(n.at(-1)??t,`/`);if(!i)return t;let a=n.slice(0,-1).join(` `);return`${a?`${a} · `:``}${r} › ${i}`}function zZ(e){return e?.trim()?RZ(e):void 0}function BZ(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 VZ={completed:`finished`,killed:`stopped`,failed:`failed`};function HZ(e){let t=VZ[e.agentStatus??`completed`],n=e.agentElapsedMs===void 0?void 0:zE(e.agentElapsedMs);return{outcome:t,tail:`${t}${n?` · ${n}`:``}`}}var UZ=e=>e===void 0?void 0:PE(e),WZ=e=>{if(e!==void 0)return zE(e)||void 0};function GZ(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=UZ(n);return{label:t===`completed`?void 0:VZ[t],duration:WZ(n),tone:r?`failed`:`muted`,title:`${e?`Stopped`:r?`Failed`:`Ran for`}${e||r?` after`:``} ${i??`an unknown time`}`}}if(r){let e=UZ(i);return{label:void 0,duration:WZ(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=UZ(o);return{label:c?VZ.killed:s?VZ.failed:void 0,duration:WZ(o),tone:s?`failed`:`muted`,title:`${c?`Stopped after`:s?`Failed after`:`Ran for`} ${l??`an unknown time`}`}}var KZ=`group flex min-w-0 items-baseline gap-1.5 rounded-sm text-left text-[11.5px] outline-none focus-visible:ring-1 focus-visible:ring-fg/60`,qZ=`h-[1em] w-[1em] -mt-[1em] shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)] text-muted/45`;function JZ({links:e}){return e.length?(0,L.jsx)(`div`,{"data-thread-links":!0,"aria-label":`Registered links`,className:`mt-2 flex min-w-0 flex-col gap-0.5 border-t border-border pt-1.5`,children:e.map(e=>{let t=e.kind===`link`,n=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:WE,children:`⤷`}),(0,L.jsx)(t?Mm:Pm,{"aria-hidden":!0,className:qZ}),(0,L.jsx)(`span`,{"data-link-kind":!0,className:`petite-caps w-[33px] shrink-0 text-[9px] text-muted/45`,children:t?`Link`:`File`}),(0,L.jsx)(`span`,{"data-link-label":!0,className:`min-w-0 flex-1 truncate text-muted/70 group-hover:text-fg/80 group-hover:underline`,children:e.label}),t&&(0,L.jsx)(`span`,{"data-link-destination":!0,className:`font-mono-keep ml-auto -mb-[0.5em] max-w-[45%] min-w-0 truncate text-right text-[10px] text-muted/45`,children:e.target})]});return t?(0,L.jsx)(`a`,{"data-thread-link":e.id,href:e.target,target:`_blank`,rel:`noopener noreferrer`,title:e.target,className:KZ,onClick:e=>e.stopPropagation(),children:n},e.id):(0,L.jsx)(`button`,{"data-thread-link":e.id,type:`button`,title:e.target,className:`${KZ} cursor-pointer`,onClick:t=>{t.stopPropagation(),wq(e.target)},children:n},e.id)})}):null}function YZ({at:e,host:t}){let n=pE(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 XZ({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)(YZ,{at:e,host:t})]})}var ZZ=`text-[14px] leading-5 text-muted`,QZ=`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 $Z(e){return`${QZ} ${e?`-mx-[0.208em] rotate-90`:`-mx-[0.333em]`}`}var $=I.createElement;function eQ({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,$(tQ,{label:`Redacted command preview`,text:e.command.preview}),e.command.actions?$(nQ,{actions:e.command.actions}):null,e.capabilities?$(iQ,{capabilities:e.capabilities}):null):e.kind===`file-approval`?$(I.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},cQ(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?$(tQ,{label:`Plain-text diff preview`,text:e.diffPreview}):null,e.changes?$(rQ,{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?$(iQ,{capabilities:e.capabilities}):null)}function tQ({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 nQ({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`},sQ(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,$(tQ,{label:`${sQ(e.kind)} command detail`,text:e.commandPreview})))))}function rQ({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`},cQ(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?$(tQ,{label:`${cQ(e.operation)} plain-text diff`,text:e.diffPreview}):null))))}function iQ({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`},$(aQ,{capability:e})))))}function aQ({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?$(oQ,{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),$(oQ,{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`),$(oQ,{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`),$(oQ,{label:`Hosts`,values:e.hosts}))}function oQ({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 sQ(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 cQ(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 lQ(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 uQ={semantic:`approve`,label:`Approve once`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`},dQ={semantic:`approve`,label:`Approve for session`,order:20,tone:`primary`,durable:!0,scope:`Persists for later matching requests in this thread session.`},fQ={semantic:`approve`,label:`Grant for turn`,order:10,tone:`primary`,durable:!1,scope:`Applies to this turn only.`},pQ={semantic:`approve`,label:`Grant for session`,order:20,tone:`primary`,durable:!0,scope:`Persists until this thread session ends.`},mQ={semantic:`deny`,label:`Deny`,order:70,tone:`danger`,durable:!1,scope:`Rejects this request.`},hQ={semantic:`decline`,label:`Decline`,order:70,tone:`danger`,durable:!1,scope:`Declines this request.`},gQ={semantic:`cancel`,label:`Cancel request`,order:80,tone:`neutral`,durable:!1,scope:`Cancels this pending request.`};function _Q(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`?uQ:n===`acceptForSession`&&r===`approve`?dQ:(n===`decline`||n===`deny`)&&r===`deny`?mQ:n===`cancel`&&r===`cancel`?gQ:void 0;if(e.kind===`permission-approval`)return n===`grant-turn`&&r===`approve`?fQ:n===`grant-session`&&r===`approve`?pQ:(n===`deny`||n===`decline`)&&r===`deny`?mQ:n===`cancel`&&r===`cancel`?gQ: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`?hQ:n===`cancel`&&r===`cancel`?gQ: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 hQ;if(n===`cancel`&&r===`cancel`)return gQ}function vQ(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=_Q(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 yQ(e){switch(e){case`claude`:return`Claude`;case`codex`:return`Codex`;case`frizz`:return`Frizz`}}function bQ(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 xQ(e,t){let n=e.options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t));return n<0?``:String(n)}function SQ(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?``:xQ(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 CQ(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 wQ(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 TQ(e,t){return JSON.stringify([e,t??null])}function EQ(e,t){try{let n=new URL(e,t);return n.protocol===`http:`||n.protocol===`https:`?n.toString():null}catch{return null}}function DQ(e,t){let n=e.getAttribute(`href`);if(!n)return!1;let r=EQ(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 OQ(e=()=>location.href){return t=>{if(t.defaultPrevented||t.button!==0)return;let n=AQ(t);n&&DQ(n,e())}}function kQ(){let e=OQ();return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)}function AQ(e){let t=typeof e.composedPath==`function`?e.composedPath():[];for(let e of t)if(jQ(e))return e;let n=e.target?.closest?.(`a[href]`);return jQ(n)?n:null}function jQ(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 MQ(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 NQ(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)=>`${MQ(t)} ${e.label}`),recommendedIdx:null},...e?{optionFieldId:e.id}:{},optionValues:r.map(e=>e.value),...t?{notesFieldId:t.id}:{}}}function PQ(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=NQ(r,a);if(!e)return null;n.push(e)}else if(r.input===`text`||r.input===`multiline`){let e=NQ(void 0,r);if(!e)return null;n.push(e)}else return null}return n.length>0?n:null}function FQ(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)=>`${MQ(t)} ${e.label}${e.description?` — ${e.description}`:``}`),recommendedIdx:null},chosenIdxs:n,text:r}}function IQ(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 LQ(e){let t=e instanceof Error?e.message:`The request could not be updated.`;return t.length>240?`${t.slice(0,239)}…`:t}function RQ(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`frizz-response-${Date.now()}-${Math.random().toString(36).slice(2)}`}function zQ({thread:e,className:t=``,autoFocusFirst:n=!1}){let r=QC(e),i=ew(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:`${DJ} 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:LQ(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)(VQ,{record:e,autoFocus:n&&t===0},e.id))}):null}function BQ({record:e,questions:t,autoFocus:n}){let r=Ve(),i=(0,I.useRef)(null),a=(0,I.useRef)(new Map),o=Ez(),s=lQ(e.delivery?.effect),c=(0,I.useMemo)(()=>vQ(e).find(e=>e.semantic===`answer`),[e]),l=kz(t.flatMap(t=>t.notesFieldId?[Tz.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(Tz.interaction(o,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId))??``:``})),p=IQ(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),Qb(r,t.interaction),r.invalidateQueries({queryKey:Xb(e.owner.threadSlug,e.owner.sessionId)}),r.invalidateQueries({queryKey:Zb(e.owner.threadSlug,e.owner.sessionId,e.id)})},onError:t=>{$b(r,e),h(LQ(t))}}),y=()=>{if(!c||!p||v.isPending||g||!s.actionsEnabled)return;h(void 0);let e=TQ(c.id,p),t=a.current.get(e)??RQ();a.current.set(e,t),v.mutate({decisionId:c.id,values:p,responseId:t})},b=(t,n)=>{t.notesFieldId&&Cz.set(Tz.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)(iX,{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 VQ({record:e,autoFocus:t=!1}){let n=(0,I.useMemo)(()=>PQ(e),[e]);return n?(0,L.jsx)(BQ,{record:e,questions:n,autoFocus:t}):(0,L.jsx)(HQ,{record:e,autoFocus:t})}function HQ({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=Ez(),l=o.filter(e=>!e.secret&&(e.input===`text`||e.input===`multiline`)).map(t=>Tz.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.id)),u=kz(l),[d,f]=(0,I.useState)(()=>SQ(o)),p=(0,I.useMemo)(()=>{let t={...d};return o.forEach(n=>{if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=Tz.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=lQ(e.delivery?.effect),D=(0,I.useMemo)(()=>vQ(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`&&Cz.set(Tz.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(TQ(r.decision.id,r.values)),_(void 0),C(void 0),T(!1),x(!0),l.forEach(e=>Cz.clear(e)),y(t.waitingForProvider?`Response sent. Waiting for the provider to acknowledge it…`:`Request completed.`),Qb(n,t.interaction),n.setQueryData(Zb(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t.interaction}),n.invalidateQueries({queryKey:Xb(e.owner.threadSlug,e.owner.sessionId),exact:!0}),t.waitingForProvider&&window.setTimeout(()=>{n.invalidateQueries({queryKey:Xb(e.owner.threadSlug,e.owner.sessionId),exact:!0})},1e3)},onError:t=>{y(void 0),_(LQ(t)),$b(n,e),Y.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{Qb(n,t),n.setQueryData(Zb(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:Xb(e.owner.threadSlug,e.owner.sessionId),exact:!0})),n.invalidateQueries({queryKey:Xb(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}});function j(e){if(!e.requiresValues){h({});return}let t=wQ(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=TQ(e.id,n),i=a.current.get(r)??RQ();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 ${DJ} 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)(mh,{"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||eR({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)(WQ,{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)(qm,{"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)(xh,{"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:UQ(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}`))]}),!GQ.has(e.payload.kind)&&(0,L.jsx)(JQ,{record:e})]})})]})}function UQ(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 WQ({record:e,instanceId:t,draft:n,setDraft:r,errors:i,autoFocus:a}){let o=e.payload,s=(e,t)=>r(CQ(n,e,t)),c;return c=o.kind===`command-approval`||o.kind===`file-approval`||o.kind===`permission-approval`?(0,L.jsx)(eQ,{payload:o}):o.kind===`mcp-elicitation-url`?(0,L.jsx)(qQ,{url:o.url}):(0,L.jsx)(YQ,{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)(KQ,{text:o.message}),(0,L.jsx)(`div`,{className:`message`in o&&o.message?`mt-3`:``,children:c})]})}var GQ=new Set([`command-approval`,`file-approval`,`permission-approval`]);function KQ({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 qQ({url:e}){let t=EQ(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 JQ({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:yQ(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:bQ(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 YQ({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)(XQ,{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 XQ({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 ZQ(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 QQ(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:`${ZQ(e)} ${t.label}${r?` — ${r}`:``}`,...i?{body:i}:{}}}var $Q=`root`;function e$(e,t,n){return`${e}/${t}.${n}`}function t$(e){let t=e.options??[],n=t.findIndex(e=>e.recommended),r=t.map((e,t)=>QQ(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 n$(e,t){return!t||e.kind===`multi`?null:t.chosen}function r$(e,t){let n=[],r=(e,i,a)=>{let{question:o,optionLabels:s}=t$(e);n.push({path:i,spec:e,question:o,optionLabels:s,depth:a});let c=n$(e,t.get(i));c!==null&&(e.options?.[c]?.followUps??[]).forEach((e,t)=>r(e,e$(i,c,t),a+1))};return r(e,$Q,1),n}function i$(e,t){return t?t.text.trim()?!0:e.kind===`multi`?(t.chosenSet??[]).length>0:t.chosen!==null:!1}function a$(e,t){if(!i$(e.spec,t.get(`root`)))return;let n=(r,i)=>{let a=t.get(i),o=(r.options??[]).map(e=>e.label),s=n$(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,e$(i,s,t)));return{questionId:e.id,question:r.question,chosen:c,...l?{text:l}:{},...u.length>0?{followUps:u}:{}}};return n(e.spec,$Q)}function o$(e){let t=e instanceof Error?e.message:`The answer could not be sent.`;return t.length>240?`${t.slice(0,239)}…`:t}var s$=(e,t)=>`${e}|${t}`,c$=(0,I.createContext)(null);function l$(e){let t=e?.id,n=e?.questions??[],r=Ez(),[i,a]=(0,I.useState)(()=>new Map),[o,s]=(0,I.useState)(),c=(0,I.useContext)(D0),l=kz((0,I.useMemo)(()=>t?n.flatMap(e=>p$(e).map(n=>Tz.question(r,t,e.id,n))):[],[r,t,n])),u=(e,n)=>{let a=i.get(s$(e.id,n));return{chosen:a?.chosen??null,chosenSet:a?.chosenSet??[],text:(t?l.get(Tz.question(r,t,e.id,n)):void 0)??``}},d=e=>new Map(p$(e).map(t=>[t,u(e,t)])),f=n.flatMap(e=>{let t=a$(e,d(e));return t?[t]:[]}),p=it({mutationFn:async e=>Y.answerQuestions({slug:t,answers:e}),onSuccess:e=>{for(let i of e.answered){a(e=>{let t=new Map(e);for(let e of[...t.keys()])e.startsWith(`${i}|`)&&t.delete(e);return t});let e=n.find(e=>e.id===i);if(e&&t)for(let n of p$(e))Cz.set(Tz.question(r,t,e.id,n),``)}},onError:e=>{c?.cancel(),s(o$(e))}}),m=it({mutationFn:async e=>Y.dismissQuestions({slug:t,ids:[e]}),onError:e=>s(o$(e))});return{slug:t,answerFor:u,answersOf:d,onChip:(e,t,n,r)=>{a(i=>{let a=new Map(i),o=s$(e.id,t),s=a.get(o)??{chosen:null,chosenSet:[]};if(n){let e=s.chosenSet.includes(r)?s.chosenSet.filter(e=>e!==r):[...s.chosenSet,r];a.set(o,{...s,chosenSet:e})}else a.set(o,{...s,chosen:s.chosen===r?null:r});return a})},onText:(e,n,i,o)=>{t&&(Cz.set(Tz.question(r,t,e.id,n),o),i||a(t=>{let r=s$(e.id,n),i=t.get(r);return!i||i.chosen===null?t:new Map(t).set(r,{...i,chosen:null})}))},dismiss:e=>m.mutate(e),dismissing:m.isPending,submit:()=>{!t||f.length===0||p.isPending||(s(void 0),c?.dismiss(),p.mutate(f))},staged:f.length,sending:p.isPending,error:o}}function u$({thread:e,children:t}){let n=l$(e);return(0,L.jsx)(c$.Provider,{value:n,children:t})}function d$({q:e,answering:t}){let n=(0,I.useContext)(c$),r=t??n;if(!r||!r.slug)return null;let i=r$(e.spec,r.answersOf(e)),a=t=>(0,L.jsx)(iX,{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:r.dismissing,onClick:()=>r.dismiss(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)(Ch,{size:16})}):void 0,interactive:{answer:r.answerFor(e,t.path),onChip:n=>r.onChip(e,t.path,t.spec.kind===`multi`,n),onText:n=>r.onText(e,t.path,t.spec.kind===`multi`,n),onSubmit:r.submit}},t.path),o=i.slice(1);return(0,L.jsxs)(`article`,{"data-question-id":e.id,className:`flex min-w-0 flex-col gap-2`,children:[a(i[0]),o.length>0&&(0,L.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:o.map(e=>(0,L.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:a(e)},e.path))})]})}function f$({thread:e,questions:t,inFlight:n=null,showSend:r=!1,className:i=``}){let a=e?.id,o=t??e?.questions??[],s=(0,I.useContext)(c$),c=l$(s?void 0:e),l=s??c;return!a||o.length===0&&!r?!a||!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 ${i}`,children:(0,L.jsx)(KY,{answers:n,queued:!0})}):(0,L.jsxs)(`section`,{"data-registered-questions":!0,"aria-label":o.length>0?`${o.length} question${o.length===1?``:`s`} waiting for an answer`:`Send the answers above`,className:`flex min-w-0 flex-col gap-3 ${i}`,children:[o.map(e=>(0,L.jsx)(d$,{q:e,answering:l},e.id)),l.error&&(0,L.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-red-300`,children:l.error}),l.sending&&(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:l.staged===0||l.sending,onClick:l.submit,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 p$(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,$Q),t}function m$(e){return(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).length}function h$(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:m$(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 g$(e){return(e.subAgents??[]).some(e=>Xc(e)&&e.state===`running`)}function _$(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length}function v$(e){return g$(e)||_$(e)>0}function y$(e,t){return ul(t)??(b$(e)?`Background shells running`:`Awaiting`)}function b$(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length>0&&!g$(e)&&m$(e)===0&&x$(e).length===0}function x$(e){return(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`)}var S$={id:``,subAgents:[],bgShells:[],watches:[]},C$=[];function w$(e,t){let n=new Set((e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).map(e=>e.target));return sU(t).filter(e=>!n.has(e.ref))}function T$({watch:e}){return(0,I.useEffect)(()=>{e.url&&jf([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:`${RJ} text-[12px]`,children:e.ref}):(0,L.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.ref})}var E$={mergeable:`no conflicts`,blocked:`merge blocked`,conflicting:`has conflicts`,unknown:null};function D$(e){return e.state!==`open`||e.merge===`blocked`&&e.checks!==`passing`&&e.checks!==`none`?null:E$[e.merge]}var O$=`shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`;function k$({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 ${O$}`})}function A$(){return(0,L.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 16 16`,width:12,height:12,fill:`none`,stroke:`currentColor`,overflow:`visible`,className:O$,style:{color:UE.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 j$({status:e}){return e?e.state===`merged`?(0,L.jsx)(Rm,{size:12,className:O$,style:{color:UE.fgDone}}):e.state===`closed`?(0,L.jsx)(zm,{size:12,className:O$,style:{color:UE.fgDanger}}):e.checks===`failing`?(0,L.jsx)(Om,{size:12,className:O$,style:{color:UE.fgDanger}}):e.checks===`passing`?(0,L.jsx)(Cm,{size:12,className:O$,style:{color:UE.fgSuccess}}):e.gated>0&&e.running===0?(0,L.jsx)(Sm,{size:12,className:O$,style:{color:UE.fgAttention}}):e.checks===`running`?(0,L.jsx)(A$,{}):(0,L.jsx)(wm,{size:12,className:`${O$} text-muted/60`}):(0,L.jsx)(wm,{size:12,className:`${O$} text-muted/60`})}function M$(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 N$(e){if(!e)return`Checking…`;if(e.state===`merged`)return`Merged`;if(e.state===`closed`)return`Closed`;let t=M$(e),n=D$(e);return[t||`No checks`,n].filter(e=>e!==null).join(` · `)}var P$=`group relative col-span-4 grid grid-cols-subgrid items-baseline rounded-sm text-[12px] leading-5`,F$=`group relative col-span-4 flex items-baseline rounded-sm text-[12px] leading-5`,I$=`ml-1.5 min-w-0 truncate font-medium text-fg/90`,L$=`ml-3 min-w-0 truncate text-right text-muted/70`,R$=`outline-none after:absolute after:inset-0 after:rounded-sm focus-visible:after:ring-1 focus-visible:after:ring-fg/60`;function z$(){return(0,L.jsx)(ym,{size:13,"aria-hidden":!0,className:`${O$} ml-[3px] -mr-[4px] text-muted/35 transition-colors group-hover:text-muted/70`})}function B$({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?`${I$} flex-1`:I$,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} ${R$} 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} ${R$} 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?F$:P$} ${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:L$,children:n}),m?(0,L.jsx)(z$,{}):(0,L.jsx)(`span`,{})]})}function V$({watch:e}){let t=e.github,n=aU(e.target);return(0,I.useEffect)(()=>{n&&jf([e.target])},[n,e.target]),(0,L.jsx)(B$,{testKind:`github`,testId:e.target,mark:(0,L.jsx)(j$,{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:[N$(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 H$(e,t){return(e.bgShells??[]).find(e=>e.id===t||e.taskId===t||e.label===t)}function U$(e){return(e.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`)}function W$({watch:e,thread:t,slug:n,now:r}){let i=H$(t,e.target);if(i)return(0,L.jsx)(G$,{shell:i,slug:n,now:r,testId:e.target});let a=RE(e.createdAt,r);return(0,L.jsx)(B$,{testKind:`shell`,testId:e.target,mark:(0,L.jsx)(vh,{size:12,className:`${O$} text-shell`}),name:e.target,title:e.target,status:a?`running · ${a}`:`running`})}function G$({shell:e,slug:t,now:n,testId:r}){let i=RE(e.startedAt,n),a=e.id&&!e.outputUnavailable;return(0,L.jsx)(B$,{testKind:`shell`,testId:r??e.id??e.label,mark:(0,L.jsx)(vh,{size:12,className:`${O$} text-shell`}),name:e.label,onOpen:a?()=>yp(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 K$({watch:e,now:t}){let n=Date.parse(e.timer?.fireAt??``),r=Number.isFinite(n)?n>t?`fires in ${IE(n-t)}`:`firing…`:`armed`;return(0,L.jsx)(B$,{testKind:`timer`,testId:e.target,mark:(0,L.jsx)(km,{size:12,className:`${O$} 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 q$(e){return(e.subAgents??[]).filter(e=>Xc(e)&&e.state===`running`)}function J$({agent:e,slug:t,now:n}){let r=RE(e.startedAt,n),i=e.subagentType?.replace(/^frizz:/,``);return(0,L.jsx)(B$,{testKind:`agent`,testId:e.id??e.label,mark:(0,L.jsx)(k$,{tone:`border-accent`}),name:e.label,onOpen:e.id?()=>vp(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 Y$(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=H$(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 X$(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=U$(e).filter(t=>r(H$(e,t.target)?.startedAt??t.createdAt));return{prs:i,shells:[...a,...Y$(e,t.hints??[],a)],agents:q$(e).filter(e=>r(e.startedAt)),timers:x$(e).filter(e=>r(e.createdAt))}}function Z$(e,t={}){let n=X$(e,t);return n.prs.length+n.shells.length+n.agents.length+n.timers.length>0}function Q$(e,t,n={}){let{prs:r,shells:i,agents:a,timers:o}=X$(e,n);return[{head:`Sub-agents`,rows:a.map(n=>(0,L.jsx)(J$,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:i.map(n=>(0,L.jsx)(W$,{watch:n,thread:e,slug:e.id,now:t},n.id))},{head:`Pull requests`,rows:r.map(e=>(0,L.jsx)(V$,{watch:e},e.id))},{head:`Timers`,rows:o.map(e=>(0,L.jsx)(K$,{watch:e,now:t},e.id))}].filter(e=>e.rows.length>0)}function $$({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)(ym,{size:10,"aria-hidden":!0,className:`${O$} ml-[5px] transition-transform ${e.collapsed?``:`rotate-90`}`})]}):(0,L.jsx)(`div`,{className:n,children:e.head})}function e1({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)($$,{group:e,first:t===0}),!e.collapsed&&e.rows]},e.head))})]})}function t1(e){return e?.awaitingBackground===!0&&e.runtime===`turn-idle`&&e.bgSnoozed!==!0}var n1=`Hides card until new activity is detected`;function r1({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:n1,className:`disabled:opacity-45 ${zJ}`,children:[(0,L.jsx)(Um,{size:12,className:xX}),`Snooze`]}),(0,L.jsx)(`span`,{className:LJ,children:n1})]})}function i1({thread:e,fence:t,onSnooze:n,onSnoozeFailed:r,notAfter:i}){let a=e??S$,o=t??(e?.lastFence?.kind===`awaiting`?e.lastFence:void 0),s=o?.hints??C$,c=g$(a),l=pU(o?.body),u=JK(l??``),d=Q$(a,TE(),{hints:s,notAfter:i}),f=w$(a,s),p=i===void 0&&e!==void 0&&t1(e)&&rZ(e).snooze;return(0,L.jsxs)(PJ,{"data-awaiting-background":!0,icon:b$(a)?vh:Um,label:(0,L.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:y$(a,s)}),aside:f.length===1?(0,L.jsx)(T$,{watch:f[0]}):void 0,className:p?`pb-0`:``,children:[l?(0,L.jsx)(qq,{className:`md-body ${EJ}`,html:u}):d.length===0&&!v$(a)?(0,L.jsx)(`p`,{className:FJ,children:oU}):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)(T$,{watch:e},e.ref))}),d.length===0&&v$(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 `,h$(a,{watchers:!1}),` it dispatched. It returns to the queue on its own when the work comes back.`]}):(0,L.jsxs)(L.Fragment,{children:[h$(a,{watchers:!1}),` `,_$(a)===1?`is`:`are`,` still running. It resumes on its own when`,` `,_$(a)===1?`it finishes`:`one of them finishes`,`.`]})}),(0,L.jsx)(e1,{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 ${kJ}`,children:(0,L.jsx)(r1,{thread:e,onSnooze:n,onSnoozeFailed:r})}):null]})}function a1(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 o1(e,t=Date.now()){return e!==void 0&&GT(e,t)!==void 0}function s1(){let[e,t]=(0,I.useState)(()=>Date.now());return(0,I.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function c1({thread:e}){let t=s1(),[n,r]=(0,I.useState)(!1),i=GT(e,t);if(!i)return null;let a=Date.parse(i),o=cT(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)(PJ,{"data-snooze-card":!0,icon:Um,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:BE(a-t)}),(0,L.jsx)(`p`,{className:FJ,children:s?(0,L.jsxs)(L.Fragment,{children:[`Resumes `,o,` and sends: “`,fT(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:`${zJ} disabled:cursor-not-allowed disabled:opacity-45`,children:`Wake now`})})]})}function l1({at:e,fallbackAt:t,className:n=``}){let r=TE(),i=sE(e,t),a=cE(i,r);return!a||!i?null:(0,L.jsx)(`time`,{dateTime:i,className:n,children:a})}var u1=1500;function d1(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},u1),a},fail(t){t===n&&(i(),e(!1))},dispose(){n++,i()}}}var f1=`Could not copy terminal command`,p1={attach:`Attach command copied`,resume:`Resume command copied`},m1={attach:`Copy command to attach to this thread's live terminal`,resume:`Copy command to resume this thread in a new terminal`},h1=e=>[`terminalCommand`,e];function g1(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 _1(e){let t=g1(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 HR(n),r}function v1(e){let t=it({mutationFn:()=>_1(e)});return e=>t.mutate(void 0,{onSuccess:t=>{e?.onSuccess?.(),Z(p1[t])},onError:t=>{e?.onError?.(),Z(t instanceof Error?`${f1}: ${t.message}`:f1,{duration:7e3})}})}function y1({slug:e}){let[t,n]=(0,I.useState)(!1),r=(0,I.useRef)(null);r.current||=d1(n,{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)});let i=Ve(),a=v1(e);(0,I.useEffect)(()=>()=>r.current?.dispose(),[]);function o(){i.prefetchQuery({queryKey:h1(e),queryFn:()=>g1(e),staleTime:15e3})}function s(){let t=i.getQueryData(h1(e));if(t){HR(t.command).then(()=>{r.current?.begin(),Z(p1[t.mode])},()=>Z(f1,{duration:7e3}));return}a({onSuccess:()=>r.current?.begin()})}let c=i.getQueryData(h1(e)),l=t?c?p1[c.mode]:`Terminal command copied`:c?m1[c.mode]:`Copy terminal command`;return(0,L.jsx)(nM,{label:l,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":l,title:l,onClick:s,onPointerEnter:o,onFocus:o,className:yD,children:t?(0,L.jsx)(gm,{size:14,strokeWidth:2.2,className:`text-fg`}):(0,L.jsx)(vh,{size:14,strokeWidth:1.8})})})}function b1(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 x1(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 S1(e){return`legacy:${e.role}:${e.kind??`message`}:${e.at??``}:${e.text}`}function C1(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??S1(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 w1(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 T1(e,t){let n=e.map(e=>e.message);return e.filter((e,r)=>!w1(n,r,t))}var E1=new Set([`agent`,`follow up`,`interrupt`,`send message`,`spawn agent`,`wait for agents`]),D1=new Set([`poll process`,`wait`]);function O1(e){return(e.split(`__`).pop()||e).replaceAll(`_`,` `).trim()}function k1(e){return O1(e).toLowerCase()}function A1(e){return e.prompt!==void 0||e.agentId!==void 0||e.sendTo!==void 0||e.sendBody!==void 0||e.backgroundState!==void 0&&!N1(e)||M1(e)||j1(e)||E1.has(k1(e.name))}function j1(e){return e.ask!==void 0&&e.ask.length>0&&e.status!==void 0&&e.status!==`pending`}function M1(e){return e.outputImage!==void 0||e.sentImages!==void 0&&e.sentImages.length>0}function N1(e){return e.backgroundState===`unknown`&&D1.has(k1(e.name))}function P1(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=>!A1(e))?t:null}return e.text.trim()||e.tools.length===0?null:e.tools.every(e=>!A1(e))?e.tools:null}function F1(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 I1(e){if(e.role!==`assistant`||e.kind||e.queued)return null;if(!e.parts?.length)return L1(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 L1(n.tools)}return null}function L1(e){let t=[];for(let n=e.length-1;n>=0&&!A1(e[n]);n--)t.unshift(e[n]);return t.length>0?t:null}function R1(e){if(e.role!==`assistant`||e.kind||e.queued)return null;let t=[],n=e=>{for(let n of e){if(A1(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 z1(e,t){return B1(e,new Set(t))}function B1(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 V1(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 H1(e){let t=[],n=null;return e.forEach((e,r)=>{if(F1(e))return;if(e.queued){t.push({message:e,messageIndex:r});return}let i=P1(e);if(i&&n){n.message=V1(n.message,i,e.at);return}let a=n?R1(e):null,o=a?z1(e,a):e;a&&n&&(n.message=V1(n.message,a,e.at));let s={message:o,messageIndex:r};t.push(s),I1(o)?(s.runStartedAt=o.at,n=s):n=null}),t}function U1(e){return e.status===`completed`||e.status===`failed`||e.status===`cancelled`}function W1(e){let t=G1(e);return t?.tools.some(e=>!U1(e))?t.tools.at(-1):void 0}function G1(e){let t=K1(e);if(!t)return;let n=I1(t.message);return n?{tools:n,at:t.message.at}:void 0}function K1(e){for(let t=e.length-1;t>=0;t--)if(!e[t].message.queued)return e[t]}function q1(e){let t=K1(e);if(t)return I1(t.message)?t.runStartedAt??t.message.at:t.message.at}function J1(e){return e.runStartedAt??e.message.at}function Y1(e){let t=I1(e);return t?B1(e,new Set(t)):e}function X1(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].message;if(!r.queued){I1(r)&&(t=r);break}}if(!t)return[...e];let n=[];for(let r of e){let e=r.message===t?Y1(r.message):r.message;F1(e)||n.push(e===r.message?r:{...r,message:e})}return n}function Z1(e){return e.detail?.trim()||void 0}var Q1={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 $1(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=Q1[i.toLowerCase()];return a?a+(r===-1?``:n.slice(r)):n.charAt(0).toUpperCase()+n.slice(1)}function e0(e,t,n){let r=t?.trim().replace(/[\\/]+$/,``);if(!r||!qf(r))return e;let i=tp(r);return i?rp(e.replace(i,``),n?.trim().replace(/[\\/]+$/,``)||/^([A-Za-z]:[\\/]Users[\\/][^\\/]+|\/(?:Users|home)\/[^/]+)(?=[\\/]|$)/.exec(r)?.[1]):e}function t0(e,t,n=Vf().home){return e0(n0(e),t,n)}function n0(e){let t=k1(e.name),n=Z1(e),r=n?` ${n}`:``;return t===`bash`||t===`exec`||t===`run command`?$1(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 ${O1(e.name)||`a tool`}`}var r0=new Set([`edit`,`multiedit`,`write`,`apply patch`]);function i0(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&&r0.has(k1(n.name))&&t.add(e)}return t.size}function a0(e,t=0){let n=`Ran ${e} tool ${e===1?`call`:`calls`}`;return t===0?n:`${n}, edited ${t} file${t===1?``:`s`}`}function o0(e){return e>0?`${a0(e)}. Thinking…`:`Thinking…`}function s0(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function c0(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function l0(e,t){let n=s0(e,t);if(n)try{let e=new URL(n);return e.protocol===`https:`||e.protocol===`http:`?e.href:void 0}catch{return}}function u0({directive:e,icon:t,title:n,meta:r,children:i}){return(0,L.jsxs)(`section`,{"data-codex-directive":e.name,className:`min-w-0 ${DJ} 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 d0({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 f0({directive:e}){let t=e.attrs,n=s0(t,`display_name`)??s0(t,`skill_name`)??`Artifact template`,r=s0(t,`artifact_kind`),i=s0(t,`skill_name`),a=s0(t,`skill_directory`),[o,s]=(0,I.useState)(!!a);return(0,L.jsxs)(u0,{directive:e,icon:(0,L.jsx)(Jm,{size:15}),title:n,meta:r?`${r} template`:`Template`,children:[i&&(0,L.jsx)(d0,{mono:!0,children:i.startsWith(`$`)?i:`$${i}`}),o&&a&&(0,L.jsx)(`img`,{src:YS(`${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 p0({directive:e}){let t=e.attrs,n=s0(t,`file`),r=c0(t,`start`),i=c0(t,`end`)??r,a=c0(t,`priority`),o=n?`${n}${r?`:${r}${i&&i!==r?`-${i}`:``}`:``}`:`Code location unavailable`;return(0,L.jsxs)(u0,{directive:e,icon:(0,L.jsx)($m,{size:15}),title:s0(t,`title`)??`Review finding`,meta:a===void 0?void 0:`P${a}`,children:[s0(t,`body`)&&(0,L.jsx)(d0,{children:s0(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)(d0,{mono:!0,children:o})]})}var m0={"git-stage":[rh,`Changes staged`],"git-commit":[Lm,`Commit created`],"git-create-branch":[Im,`Branch created`],"git-push":[Sh,`Branch pushed`],"git-create-pr":[Vm,`Pull request created`]};function h0({directive:e}){let[t,n]=m0[e.name],r=s0(e.attrs,`branch`),i=l0(e.attrs,`url`),a=`${n}${e.attrs.isDraft===!0?` as draft`:``}`;return(0,L.jsx)(u0,{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 g0({directive:e}){let t=s0(e.attrs,`threadId`),n=s0(e.attrs,`pendingWorktreeId`);return(0,L.jsx)(u0,{directive:e,icon:(0,L.jsx)(nh,{size:15}),title:n?`Thread setup queued`:`Thread created`,meta:(t||n)&&(0,L.jsx)(`span`,{className:`font-mono-keep`,children:t??n})})}function _0({directive:e}){let t=s0(e.attrs,`reason`);return(0,L.jsx)(u0,{directive:e,icon:(0,L.jsx)(um,{size:15}),title:`Archive suggested`,meta:t})}function v0(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 y0({directive:e}){let t=e.attrs,n=s0(t,`mode`),r=s0(t,`name`)??`Automation`,i=v0(t.rrule),a=[r,n,s0(t,`status`),i].filter(Boolean).join(` · `);return(0,L.jsx)(u0,{directive:e,icon:(0,L.jsx)(hm,{size:15}),title:`Automation suggested`,meta:a,children:s0(t,`prompt`)&&(0,L.jsx)(d0,{children:s0(t,`prompt`)})})}function b0({directive:e}){return e.name===`artifact-template`?(0,L.jsx)(f0,{directive:e}):e.name===`code-comment`?(0,L.jsx)(p0,{directive:e}):e.name.startsWith(`git-`)?(0,L.jsx)(h0,{directive:e}):e.name===`created-thread`?(0,L.jsx)(g0,{directive:e}):e.name===`archive`||e.name===`archive-thread`?(0,L.jsx)(_0,{directive:e}):(0,L.jsx)(y0,{directive:e})}var x0;function S0(){return x0??=ib(async()=>{let{default:e}=await import(`./mermaid.core-BIRnljFs.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)),x0}function C0({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 S0().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:`${DJ} 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 ${DJ} 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 ${DJ} bg-panel-2`})}var w0=(0,I.createContext)(null),T0=(0,I.createContext)(null);function E0(){let e=(0,I.useContext)(w0),t=(0,I.useContext)(T0);return e??t}var D0=(0,I.createContext)(null);function O0(e){return e.status===`pending`&&e.backgroundState===`background`}function k0(e){let t=[];for(let n of e)for(let e of n.tools)O0(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 A0(e){return e.map(e=>{if(!e.tools.some(O0))return e;let t=e.tools.filter(e=>!O0(e)),n=e.parts?.map(e=>e.kind===`tools`?{...e,tools:e.tools.filter(e=>!O0(e))}:e).filter(e=>e.kind!==`tools`||e.tools.length>0);return{...e,tools:t,parts:n}})}function j0({slug:e,onStatusApplied:t,onClose:n,virtualized:r=!1,showReturnToQueue:i=!1}){let a=Gp(qC(),e);return(0,L.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,L.jsx)(U0,{slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:i}),(0,L.jsx)(M0,{slug:e,virtualized:r}),a&&(0,L.jsx)(AZ,{thread:a,sticky:!0,safeArea:!0,onArchived:t})]})}function M0({slug:e,virtualized:t}){let n=qC(),r=Gp(n,e),i=r?.runtime===`running`||r?.runtime===`spawning`,a=v1(e),o=sw(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)(()=>k0(p),[p]),h=(0,I.useMemo)(()=>A0(p),[p]),g=(0,I.useMemo)(()=>r2(h),[h]),_=(0,I.useMemo)(()=>i?a1(h):void 0,[i,h]),v=_&&_.index>=0?_.index:g,y=(0,I.useMemo)(()=>H1(h),[h]),b=i?G1(y):void 0,x=i?W1(y):void 0,S=x?t0(x,n?.projectDir):void 0,C=i?q1(y):void 0,w=t1(r),T=(0,I.useMemo)(()=>{let e=i?X1(y):y;return T1(e,i2(e,v,w))},[y,i,v,w]),E=i,D=(0,I.useMemo)(()=>iY(p),[p]),O=(0,I.useMemo)(()=>$J(p,r?.answersInFlight),[p,r?.answersInFlight]),k=(0,I.useMemo)(()=>_X(p),[p]),A={thread:r,showWorking:E,registeredDone:TJ(r,g>=0?h[g]?.text:void 0),restedCard:BJ(r,g>=0?h[g]?.text:void 0),errorVisible:HJ(h,r?.providerError)},{answeringForMessage:j}=eX(e,p),M=(0,I.useMemo)(()=>dY(p,r?.questions??[]),[p,r?.questions]),N=(0,I.useMemo)(()=>yY(p,r?.questions??[]),[p,r?.questions]),P=Xl(r?.spawnedAt),ee=(0,I.useRef)(null),[F,te]=(0,I.useState)(null),ne=o.data?.messages.length??0,re=!o.isLoading;(0,I.useEffect)(()=>{if(t)return;let e=ee.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<=4&&(e.scrollTop=e.scrollHeight)},[ne,i,t]);let ie=(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)(w0.Provider,{value:e,children:(0,L.jsx)(u$,{thread:r,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:ee,"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&&ne>0?(0,L.jsx)(V0,{slug:e,transcriptRef:ee,transcriptKey:o.data?.transcriptKey,messages:h,paired:D,inFlightAnswers:O,answeringForMessage:j,placement:N,fencesLive:P,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 ie(),jumpOverlay:F}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(zQ,{thread:r,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(f$,{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)(xh,{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:ne===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)(c4,{}),` Loading…`]}):i?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(c4,{}),` Session starting…`]}):CX(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:[c2(T.map(e=>e.message),(e,t)=>{let n=T[t].messageIndex;return(0,L.jsx)(U2,{m:e,answering:P?j(e):void 0,showSendButton:!0,paired:D[n],staleAwaiting:v>=0&&n<v,restingCardShown:n===g&&w,restedAt:_&&n===_.index?_.at??``:void 0,shadowedBy:M.get(n),placed:N.placed.get(n),thread:r},t)},e=>!!e.queued),re&&R0(A)!==null&&(0,L.jsx)(bY,{h:z0(A,T.map(e=>e.message))}),re&&(0,L.jsx)(B0,{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)(e4,{policy:r.permPolicy,denies:r.permDenies})}):null,p.some(e=>e.queued)&&(0,L.jsx)(bY,{}),(0,L.jsx)(`div`,{className:`flex flex-col gap-3.5`,children:p.map((e,t)=>e.queued?(0,L.jsx)(U2,{m:e,paired:D[t]},`q${t}`):null)})]})})]})}),(0,L.jsx)(`div`,{ref:te,"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)(JX,{slug:e,onTerminal:a,ops:(0,L.jsx)(t4,{slug:e,transcriptShells:m,className:`px-1 pt-1.5`})})})]})})})}var N0=700,P0=250,F0=(()=>{try{return localStorage.getItem(`frizz.debugScroll`)===`1`}catch{return!1}})();function I0(e){return e?.pendingInteraction===!0}function L0(e){return I0(e)?void 0:e?.pendingAsk}function R0({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`:L0(e)?`pending-ask`:e?.runtime===`perm-prompt`&&!I0(e)?`perm-prompt`:t?`working`:e?.providerError?i?null:`provider-error`:o1(e)?`snooze`:t1(e)?`resting`:n?`registered-done`:r?`rested`:null}function z0(e,t){return R0(e)===`working`?s2(t):14}function B0({state:e,slug:t,retryText:n,onTerminal:r,liveRuntimeStart:i,liveActivityLabel:a,liveToolRun:o}){let s=e.thread;switch(R0(e)){case`provider-fault`:return(0,L.jsx)(Z2,{slug:t,sessionId:s.sessionId,fault:s.providerFault,retryText:n});case`provider-error`:return(0,L.jsx)(UJ,{error:s.providerError});case`limit-pause`:return(0,L.jsx)(Q2,{slug:t,sessionId:s.sessionId,pause:s.limitPause});case`pending-ask`:return(0,L.jsx)(n4,{ask:L0(s),onTerminal:r});case`perm-prompt`:return(0,L.jsx)($2,{onTerminal:r});case`working`:return(0,L.jsx)(l4,{since:s?.lastUserAt,startedAt:i,activityLabel:a,run:o});case`snooze`:return(0,L.jsx)(c1,{thread:s});case`resting`:return(0,L.jsx)(i1,{thread:s});case`registered-done`:return(0,L.jsx)(X2,{fenceKind:`done`,body:s.lastFence.body,hints:[]});case`rested`:return(0,L.jsx)(VJ,{thread:s});default:return null}}function V0({slug:e,transcriptRef:t,transcriptKey:n,messages:r,paired:i,inFlightAnswers:a,answeringForMessage:o,placement:s,fencesLive:c,thread:l,running:u,copyTerminalCommand:d,transportFallback:f,isFetching:p,refresh:m,retryLiveUpdates:h,hasEarlier:g,beforeCursor:_,loadingEarlier:v,earlierError:y,loadEarlier:b,jumpOverlay:x}){let S=JC(),C=(0,I.useMemo)(()=>H1(r),[r]),w=u?G1(C):void 0,T=u?W1(C):void 0,E=T?t0(T,S):void 0,D=u?q1(C):void 0,O=(0,I.useMemo)(()=>r2(r),[r]),k=(0,I.useMemo)(()=>u?a1(r):void 0,[u,r]),A=k&&k.index>=0?k.index:O,j=t1(l),M=(0,I.useMemo)(()=>{let e=u?X1(C):C;return T1(e,i2(e,A,j))},[C,u,A,j]),N=u,P=(0,I.useMemo)(()=>C1(M.map(e=>e.message),i2(M,A,j),t2).map(e=>{let t=M[e.messageIndex];return{...e,messageIndex:t.messageIndex,stampAt:J1(t)}}),[M,A,j]),ee=(0,I.useMemo)(()=>_X(r),[r]),F=TJ(l,O>=0?r[O]?.text:void 0),te=BJ(l,O>=0?r[O]?.text:void 0),ne=HJ(r,l?.providerError),re={thread:l,showWorking:N,registeredDone:F,restedCard:te,errorVisible:ne},ie=R0(re)!==null,ae=(0,I.useMemo)(()=>z0({thread:l,showWorking:N,registeredDone:F,restedCard:te,errorVisible:ne},M.map(e=>e.message)),[M,N,l,F,te,ne]),oe=(0,I.useMemo)(()=>{let e=[],t=new Map,n=r.length-1,i=(l?.questions??[]).filter(e=>!s.placedIds.has(e.id));for(let[a,o]of cY(r,i,{atRest:!u})){if(a>=n){e.push(...o);continue}let r=-1;for(let e=0;e<P.length&&!(P[e].messageIndex>a);e++)r=e;let i=t.get(r);i?i.push(...o):t.set(r,[...o])}return{byRow:t,tail:e}},[P,r,s.placedIds,u,l?.questions]),se=(0,I.useMemo)(()=>dY(r,l?.questions??[]),[r,l?.questions]),ce=(0,I.useMemo)(()=>{let e=[{key:`head-anchor`,kind:`head-anchor`}];f&&e.push({key:`transport-fallback`,kind:`transport-fallback`}),(g||v||y)&&e.push({key:`earlier-history:${_??`complete`}`,kind:`earlier-history`});let t=oe.byRow.get(-1);t&&e.push({key:`questions:head`,kind:`questions`,questions:t}),P.forEach((t,n)=>{e.push({...t,kind:`message`});let r=oe.byRow.get(n);r&&e.push({key:`questions:${t.key}`,kind:`questions`,questions:r})}),e.push({key:`interactions`,kind:`interactions`}),ie&&e.push({key:`runtime-status`,kind:`runtime-status`});let n=ie||P.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},[_,y,g,ie,v,P,r,oe,f]),le=Yw({count:ce.length,getScrollElement:()=>t.current,getItemKey:e=>ce[e]?.key??e,estimateSize:e=>{let t=ce[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})}}),[ue,de]=(0,I.useState)(!0),fe=(0,I.useRef)(!0),pe=(0,I.useRef)(-1),me=(0,I.useRef)(0),he=(0,I.useRef)(null),ge=(0,I.useRef)(!1),_e=(0,I.useRef)(!1),ve=(0,I.useRef)(!0),ye=(0,I.useRef)(null),be=(0,I.useRef)(void 0),xe=(0,I.useRef)(null),Se=(0,I.useRef)(void 0),Ce=(0,I.useRef)(0),we=(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&&(ye.current={rowKey:r,viewportTop:n.getBoundingClientRect().top-t})}b()},[b,t]),Te=(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||ce.length===0||be.current===n)return;be.current=n,ge.current=!1,_e.current=!1,ve.current=!0;let t=hD(e)?.candidates.map(e=>({candidate:e,index:ce.findIndex(t=>t.kind===`message`&&t.message.sourceId===e.sourceId)})).find(e=>e.index>=0),r=requestAnimationFrame(()=>{if(!t){le.scrollToEnd({behavior:`instant`}),de(!0),ge.current=!0;return}le.scrollToIndex(t.index,{align:`start`,behavior:`instant`}),fe.current=!1,de(!1),ge.current=!0;let e=performance.now()+P0;Ce.current=e;let n=()=>{performance.now()>=e||performance.now()<me.current||(Te(t.candidate.sourceId,t.candidate.screenTop),r=requestAnimationFrame(n))};n()});return()=>cancelAnimationFrame(r)},[Te,ce.length,e,n,le]),(0,I.useLayoutEffect)(()=>{let e=ye.current,n=t.current;if(!e||!n||v)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(),ye.current===e&&(ye.current=null)})});return()=>{cancelAnimationFrame(a),cancelAnimationFrame(i)}},[v,P.length,t]);let Ee=(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]),De=(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]),Oe=P[0]?.key;(0,I.useLayoutEffect)(()=>{let e=Se.current;if(Se.current=Oe,e===void 0||e===Oe||!ge.current||fe.current||ye.current)return;let t=xe.current;if(!t)return;De(t);let n=()=>{if(performance.now()<me.current)return;let e=xe.current;e&&De(e)},r=0,i=requestAnimationFrame(()=>{n(),r=requestAnimationFrame(n)});return()=>{cancelAnimationFrame(i),cancelAnimationFrame(r)}},[De,Oe]);let ke=(0,I.useCallback)(()=>{let e=t.current;if(!e||ye.current||performance.now()<Ce.current)return;let n=b1({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,previousScrollHeight:pe.current,following:fe.current,readerMoved:performance.now()<me.current});if(fe.current=n.following,n.scrollTop!==null&&(e.scrollTop=n.scrollTop),pe.current=e.scrollHeight,de(e=>e===n.following?e:n.following),F0&&!n.following&&performance.now()>=me.current){let t=xe.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}`)}}xe.current=Ee()??xe.current},[Ee,t]);(0,I.useLayoutEffect)(ke),(0,I.useEffect)(()=>{let e=he.current;if(!e)return;let t=new ResizeObserver(ke);return t.observe(e),()=>t.disconnect()},[ke]),(0,I.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{ke();let t=x1({armed:ve.current,scrollTop:e.scrollTop,readerMoved:ge.current&&_e.current,hasEarlier:g,loading:v});ve.current=t.armed,t.shouldLoad&&we()},r=()=>{_e.current=!0,me.current=performance.now()+N0,requestAnimationFrame(n)},i=t=>{[`ArrowUp`,`PageUp`,`Home`,` `].includes(t.key)&&(e.scrollTop<=480&&(ve.current=!0),r())},a=t=>{t.deltaY<0&&e.scrollTop<=480&&(ve.current=!0),r()},o=()=>{e.scrollTop<=480&&(ve.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)}},[g,v,we,ke,t]);let Ae=le.getVirtualItems(),je=le.getTotalSize();return(0,L.jsxs)(`div`,{ref:he,"data-virtualized-transcript":!0,"data-virtual-row-count":Ae.length,className:`relative w-full`,style:{height:je},children:[Ae.map(t=>{let n=ce[t.index];return n?(0,L.jsx)(`div`,{ref:le.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)(zQ,{thread:l,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(f$,{thread:l,questions:oe.tail,inFlight:a,showSend:s.placedIds.size>0,className:`px-6 pt-5`})]}):n.kind===`questions`?(0,L.jsx)(f$,{thread:l,questions:n.questions,className:`px-6 pt-5`}):n.kind===`transport-fallback`?f?(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 ${DJ} border border-border-strong bg-panel-2 px-4 py-2.5 text-[12px]`,title:f.kind===`payload-too-large`?`Live payload ${f.actualBytes} bytes; socket limit ${f.maxBytes} bytes`:`Transcript read budget reached (${f.scope}); retry after about ${f.retryAfterMs}ms`,children:[(0,L.jsx)(xh,{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.`}),` `,f.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:p,onClick:m,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:p?`Refreshing…`:`Refresh once`}),(0,L.jsx)(`button`,{type:`button`,onClick:h,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:y?(0,L.jsxs)(`span`,{className:`flex flex-wrap items-center justify-center gap-2 text-center`,children:[(0,L.jsx)(`span`,{children:y}),(0,L.jsx)(`button`,{type:`button`,onClick:we,className:`rounded-md border border-border px-2 py-1 text-fg/90 hover:bg-panel-2`,children:`Retry`})]}):v?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Xm,{size:12,className:`animate-spin`}),` Loading earlier messages…`]}):(0,L.jsx)(`button`,{type:`button`,onClick:we,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)(XZ,{at:n.stampAt,host:bX(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(U2,{m:n.message,answering:c?o(n.message):void 0,showSendButton:!0,paired:i[n.messageIndex],staleAwaiting:A>=0&&n.messageIndex<A,restingCardShown:n.messageIndex===O&&j,restedAt:k&&n.messageIndex===k.index?k.at??``:void 0,shadowedBy:se.get(n.messageIndex),placed:s.placed.get(n.messageIndex),thread:l})}):n.kind===`runtime-status`?(0,L.jsxs)(`div`,{className:`px-6`,style:{paddingTop:ae},children:[(0,L.jsx)(B0,{state:re,slug:e,retryText:ee>=0?r[ee]?.text:void 0,onTerminal:d,liveRuntimeStart:D,liveActivityLabel:E,liveToolRun:w}),l?.permPolicy?(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(e4,{policy:l.permPolicy,denies:l.permDenies})}):null]}):(0,L.jsx)(XZ,{at:n.message.at,host:bX(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(U2,{m:n.message,paired:i[n.messageIndex]})})},n.key):null}),(0,L.jsx)(H0,{overlay:x,hidden:ue,onJump:()=>le.scrollToEnd({behavior:`smooth`})})]})}function H0({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)(dm,{size:12}),`Jump to latest`]}),e)}function U0({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1}){let i=Gp(qC(),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=FK(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=CT(i);function _(){c(!1),u(``)}function v(){let e=wX(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:DX,children:[(0,L.jsx)(`div`,{className:OX,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(TX(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)(FZ,{thread:i,hidden:s})]}),(0,L.jsx)(l1,{at:PT(i),fallbackAt:i.spawnedAt,className:`mt-0.5 block truncate text-[11px] leading-tight text-muted/75`})]})}),(0,L.jsxs)(`div`,{className:kX,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[p&&(0,L.jsx)(y1,{slug:e}),(0,L.jsx)(eZ,{thread:i,collapse:r,onDoc:f?()=>_p(`doc`,i.id):void 0,onDone:()=>a.mutate(void 0,{onSuccess:t}),doneBusy:a.isPending,onStatusApplied:t}),n&&(0,L.jsx)(rM,{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)(Ch,{size:15})})]})]})}function W0(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||BZ(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 G0(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||BZ(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 K0(e){return W0(e)!==null}function q0(e){return G0(e)!==null}function J0(e){return e.kind===`event`&&!e.boundary||e.kind===`reasoning`}function Y0(e){return J0(e)||K0(e)}function X0(e){return J0(e)||q0(e)}function Z0(e){if(J0(e))return!0;let t=W0(e);return t!==null&&!A1(t[t.length-1])}function Q0(e){if(J0(e))return!0;let t=G0(e);return t!==null&&!A1(t[0])}function $0(e){let t=W0(e);return t!==null&&M1(t[t.length-1])}function e2(e){let t=G0(e);return t!==null&&M1(t[0])}function t2(e,t){let n=$0(e)||e2(t),r=!n&&Y0(e)&&X0(t)&&!(Z0(e)&&Q0(t));return(n?22:r?6:14)+(e.role===`user`&&t.role!==`user`?3:0)}function n2(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:a2(e,n.text,t)):(e.tools?.length??0)===0&&a2(e,e.text,t)}function r2(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`&&e[t].kind!==`event`)return t;return-1}function i2(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=>n2(e,r.has(e))}function a2(e,t,n){return!e.fenceRefused&&!n?!t.trim():wJ(t).every(e=>e.kind===`fence`&&e.fenceKind===`awaiting`)}function o2(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`&&!a2(e,n.text,t)):typeof e.text==`string`&&!a2(e,e.text,t)}function s2(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.queued||n2(n)))return $0(n)?22:Y0(n)&&!Z0(n)?6:14+(n.role===`user`?3:0)}return 0}function c2(e,t,n){let r=[],i=null;return e.forEach((e,a)=>{n?.(e,a)||n2(e)||(i!==null&&r.push((0,L.jsx)(bY,{h:t2(i,e)},`s${a}`)),r.push(t(e,a)),i=e)}),r}function l2(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 u2(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)(bY,{h:typeof t==`number`?t:t(n)},`vs${n}`)),r.push(e)}),r}var d2={head:!1,tail:!1};function f2(e,t){return n=>e[n-1]?.tail||e[n]?.head?22:t}function p2(e){return{head:M1(e[0]),tail:M1(e[e.length-1])}}function m2(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}):j1(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 h2(e){return e.split(`__`).pop()||e}function g2(e){let t=X.board?.projectDir;return t&&e.startsWith(t+`/`)?e.slice(t.length+1):e}function _2({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=a0(a,i0(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 ${ZZ}`,children:[(0,L.jsx)(`span`,{"data-tool-activity-label":!0,title:o,className:`min-w-0 truncate text-muted`,children:o}),(0,L.jsx)(ym,{"data-tool-activity-chevron":!0,"aria-hidden":`true`,size:13,className:$Z(n)})]}),n&&(0,L.jsx)(`div`,{id:i,className:`mt-1.5 flex flex-col`,children:u2(e.map((e,n)=>(0,L.jsx)(y2,{t:e,startedAt:t},n)),6)}),!n&&(0,L.jsx)(`div`,{id:i,hidden:!0})]})}function v2({tools:e,at:t}){let n=[];for(let t of e){let e=A1(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:u2(n.map((e,n)=>e.exceptional?(0,L.jsx)(`div`,{className:`flex flex-col`,children:u2(e.tools.map((e,n)=>(0,L.jsx)(y2,{t:e,startedAt:t},n)),f2(e.tools.map(e=>p2([e])),6))},`exceptions-${n}`):(0,L.jsx)(_2,{tools:e.tools,at:t},`activity-${n}`)),f2(n.map(e=>p2(e.tools)),6))})}function y2({t:e,startedAt:t}){let n=(0,I.useContext)(w0),r=qC(),i=NE(e,(n?Gp(r,n):void 0)?.bgShells??[]);return e.edits&&e.status!==`failed`&&e.status!==`cancelled`?(0,L.jsx)(Aq,{edits:e.edits,meta:(0,L.jsx)(w2,{status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,durationMs:e.durationMs})}):e.command?(0,L.jsx)(M2,{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)(k2,{name:e.name,detail:e.detail,outputImage:e.outputImage,output:e.output,status:e.status,durationMs:e.durationMs}):e.read?(0,L.jsx)(P2,{detail:e.detail,read:e.read,status:e.status,durationMs:e.durationMs}):e.prompt||e.agentId?(0,L.jsx)(I2,{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)(R2,{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)(A2,{images:e.sentImages??[],files:e.sentFiles??[],caption:e.caption,status:e.status,durationMs:e.durationMs}):e.todos?(0,L.jsx)(eJ,{todos:e.todos,note:e.input,meta:(0,L.jsx)(w2,{status:e.status,durationMs:e.durationMs})}):j1(e)?(0,L.jsx)(b2,{ask:e.ask??[],askAnswers:e.askAnswers}):e.input||e.output?(0,L.jsx)(M2,{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)(O2,{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 b2({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=FQ(e,t?.[n]);return(0,L.jsx)(iX,{question:r.question,settled:{chosenIdxs:r.chosenIdxs,text:r.text}},n)})})}function x2({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 S2(e,t,n){let[r,i]=(0,I.useState)(()=>Date.now()),a=AE(e,t),o=jE(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(kE-(Date.now()-e),0));return()=>clearTimeout(t)},[a,o,n]),o}function C2({status:e,backgroundState:t,liveBackgroundState:n,startedAt:r}){let i=S2(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:YE}):OE(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 w2({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:PE(i),c=[o,s].filter(Boolean).join(` · `);return(0,L.jsx)(x2,{tone:e===`failed`?`frizz-tool-failed`:e===`cancelled`?`text-amber-400`:`text-muted/55`,title:c,label:a,duration:s})}function T2(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 E2(e,t,n){let r=t&&t!==X.board?.projectDir?`in ${g2(t)}`:void 0;return[e,t?r:n!==void 0&&!e?.includes(String(n))?`session ${n}`:void 0].filter(Boolean).join(` · `)||void 0}function D2(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.includes(`…`)}function O2({name:e,detail:t,count:n,status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,cwd:s,sessionId:c,durationMs:l,startedAt:u}){let d=E2(t,s,c),f=d?g2(d):void 0,p=t&&D2(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)(C2,{status:r,backgroundState:i,liveBackgroundState:a,startedAt:u}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:h2(e)}),f&&(p?(0,L.jsx)(`span`,{className:`min-w-0 truncate`,onClick:e=>e.stopPropagation(),children:(0,L.jsx)(kq,{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)(w2,{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 k2({name:e,detail:t,outputImage:n,output:r,status:i,durationMs:a}){let o=t?g2(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:h2(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)(w2,{status:i,durationMs:a})})]});return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(G2,{path:n,hideCaption:!0,altText:o?`${h2(e)}: ${o}`:h2(e),header:s}),r&&(0,L.jsx)(`pre`,{className:`frizz-bash frizz-bash-body frizz-bash-output-body mt-1.5`,children:r})]})}function A2({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)(w2,{status:r,durationMs:i}),(0,L.jsx)(ym,{"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)(G2,{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)(K2,{path:e},`f${t}`))}),n&&(0,L.jsx)(`div`,{className:`max-w-[65%] text-[12px] leading-snug text-muted`,children:n})]})})]})}var j2=16;function M2({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=T2(i,d,l),b=(0,I.useMemo)(()=>e.split(`
313
+ `)||void 0;return{line:`${ZQ(e)} ${t.label}${r?` — ${r}`:``}`,...i?{body:i}:{}}}var $Q=`root`;function e$(e,t,n){return`${e}/${t}.${n}`}function t$(e){let t=e.options??[],n=t.findIndex(e=>e.recommended),r=t.map((e,t)=>QQ(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 n$(e,t){return!t||e.kind===`multi`?null:t.chosen}function r$(e,t){let n=[],r=(e,i,a)=>{let{question:o,optionLabels:s}=t$(e);n.push({path:i,spec:e,question:o,optionLabels:s,depth:a});let c=n$(e,t.get(i));c!==null&&(e.options?.[c]?.followUps??[]).forEach((e,t)=>r(e,e$(i,c,t),a+1))};return r(e,$Q,1),n}function i$(e,t){return t?t.text.trim()?!0:e.kind===`multi`?(t.chosenSet??[]).length>0:t.chosen!==null:!1}function a$(e,t){if(!i$(e.spec,t.get(`root`)))return;let n=(r,i)=>{let a=t.get(i),o=(r.options??[]).map(e=>e.label),s=n$(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,e$(i,s,t)));return{questionId:e.id,question:r.question,chosen:c,...l?{text:l}:{},...u.length>0?{followUps:u}:{}}};return n(e.spec,$Q)}function o$(e){let t=e instanceof Error?e.message:`The answer could not be sent.`;return t.length>240?`${t.slice(0,239)}…`:t}var s$=(e,t)=>`${e}|${t}`,c$=(0,I.createContext)(null);function l$(e){let t=e?.id,n=e?.questions??[],r=Ez(),[i,a]=(0,I.useState)(()=>new Map),[o,s]=(0,I.useState)(),c=(0,I.useContext)(D0),l=kz((0,I.useMemo)(()=>t?n.flatMap(e=>p$(e).map(n=>Tz.question(r,t,e.id,n))):[],[r,t,n])),u=(e,n)=>{let a=i.get(s$(e.id,n));return{chosen:a?.chosen??null,chosenSet:a?.chosenSet??[],text:(t?l.get(Tz.question(r,t,e.id,n)):void 0)??``}},d=e=>new Map(p$(e).map(t=>[t,u(e,t)])),f=n.flatMap(e=>{let t=a$(e,d(e));return t?[t]:[]}),p=it({mutationFn:async e=>Y.answerQuestions({slug:t,answers:e}),onSuccess:e=>{for(let i of e.answered){a(e=>{let t=new Map(e);for(let e of[...t.keys()])e.startsWith(`${i}|`)&&t.delete(e);return t});let e=n.find(e=>e.id===i);if(e&&t)for(let n of p$(e))Cz.set(Tz.question(r,t,e.id,n),``)}},onError:e=>{c?.cancel(),s(o$(e))}}),m=it({mutationFn:async e=>Y.dismissQuestions({slug:t,ids:[e]}),onError:e=>s(o$(e))});return{slug:t,answerFor:u,answersOf:d,onChip:(e,t,n,r)=>{a(i=>{let a=new Map(i),o=s$(e.id,t),s=a.get(o)??{chosen:null,chosenSet:[]};if(n){let e=s.chosenSet.includes(r)?s.chosenSet.filter(e=>e!==r):[...s.chosenSet,r];a.set(o,{...s,chosenSet:e})}else a.set(o,{...s,chosen:s.chosen===r?null:r});return a})},onText:(e,n,i,o)=>{t&&(Cz.set(Tz.question(r,t,e.id,n),o),i||a(t=>{let r=s$(e.id,n),i=t.get(r);return!i||i.chosen===null?t:new Map(t).set(r,{...i,chosen:null})}))},dismiss:e=>m.mutate(e),dismissing:m.isPending,submit:()=>{!t||f.length===0||p.isPending||(s(void 0),c?.dismiss(),p.mutate(f))},staged:f.length,sending:p.isPending,error:o}}function u$({thread:e,children:t}){let n=l$(e);return(0,L.jsx)(c$.Provider,{value:n,children:t})}function d$({q:e,answering:t}){let n=(0,I.useContext)(c$),r=t??n;if(!r||!r.slug)return null;let i=r$(e.spec,r.answersOf(e)),a=t=>(0,L.jsx)(iX,{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:r.dismissing,onClick:()=>r.dismiss(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)(Ch,{size:16})}):void 0,interactive:{answer:r.answerFor(e,t.path),onChip:n=>r.onChip(e,t.path,t.spec.kind===`multi`,n),onText:n=>r.onText(e,t.path,t.spec.kind===`multi`,n),onSubmit:r.submit}},t.path),o=i.slice(1);return(0,L.jsxs)(`article`,{"data-question-id":e.id,className:`flex min-w-0 flex-col gap-2`,children:[a(i[0]),o.length>0&&(0,L.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:o.map(e=>(0,L.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:a(e)},e.path))})]})}function f$({thread:e,questions:t,inFlight:n=null,showSend:r=!1,className:i=``}){let a=e?.id,o=t??e?.questions??[],s=(0,I.useContext)(c$),c=l$(s?void 0:e),l=s??c;return!a||o.length===0&&!r?!a||!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 ${i}`,children:(0,L.jsx)(KY,{answers:n,queued:!0})}):(0,L.jsxs)(`section`,{"data-registered-questions":!0,"aria-label":o.length>0?`${o.length} question${o.length===1?``:`s`} waiting for an answer`:`Send the answers above`,className:`flex min-w-0 flex-col gap-3 ${i}`,children:[o.map(e=>(0,L.jsx)(d$,{q:e,answering:l},e.id)),l.error&&(0,L.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-red-300`,children:l.error}),l.sending&&(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:l.staged===0||l.sending,onClick:l.submit,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 p$(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,$Q),t}function m$(e){return(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).length}function h$(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:m$(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 g$(e){return(e.subAgents??[]).some(e=>Xc(e)&&e.state===`running`)}function _$(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length}function v$(e){return g$(e)||_$(e)>0}function y$(e,t){return ul(t)??(b$(e)?`Background shells running`:`Awaiting`)}function b$(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length>0&&!g$(e)&&m$(e)===0&&x$(e).length===0}function x$(e){return(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`)}var S$={id:``,subAgents:[],bgShells:[],watches:[]},C$=[];function w$(e,t){let n=new Set((e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).map(e=>e.target));return sU(t).filter(e=>!n.has(e.ref))}function T$({watch:e}){return(0,I.useEffect)(()=>{e.url&&jf([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:`${RJ} text-[12px]`,children:e.ref}):(0,L.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.ref})}var E$={mergeable:`no conflicts`,blocked:`merge blocked`,conflicting:`has conflicts`,unknown:null};function D$(e){return e.state!==`open`||e.merge===`blocked`&&e.checks!==`passing`&&e.checks!==`none`?null:E$[e.merge]}var O$=`shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`;function k$({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 ${O$}`})}function A$(){return(0,L.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 16 16`,width:12,height:12,fill:`none`,stroke:`currentColor`,overflow:`visible`,className:O$,style:{color:UE.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 j$({status:e}){return e?e.state===`merged`?(0,L.jsx)(Rm,{size:12,className:O$,style:{color:UE.fgDone}}):e.state===`closed`?(0,L.jsx)(zm,{size:12,className:O$,style:{color:UE.fgDanger}}):e.checks===`failing`?(0,L.jsx)(Om,{size:12,className:O$,style:{color:UE.fgDanger}}):e.checks===`passing`?(0,L.jsx)(Cm,{size:12,className:O$,style:{color:UE.fgSuccess}}):e.gated>0&&e.running===0?(0,L.jsx)(Sm,{size:12,className:O$,style:{color:UE.fgAttention}}):e.checks===`running`?(0,L.jsx)(A$,{}):(0,L.jsx)(wm,{size:12,className:`${O$} text-muted/60`}):(0,L.jsx)(wm,{size:12,className:`${O$} text-muted/60`})}function M$(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 N$(e){if(!e)return`Checking…`;if(e.state===`merged`)return`Merged`;if(e.state===`closed`)return`Closed`;let t=M$(e),n=D$(e);return[t||`No checks`,n].filter(e=>e!==null).join(` · `)}var P$=`group relative col-span-4 grid grid-cols-subgrid items-baseline rounded-sm text-[12px] leading-5`,F$=`group relative col-span-4 flex items-baseline rounded-sm text-[12px] leading-5`,I$=`ml-1.5 min-w-0 truncate font-medium text-fg/90`,L$=`ml-3 min-w-0 truncate text-right text-muted/70`,R$=`outline-none after:absolute after:inset-0 after:rounded-sm focus-visible:after:ring-1 focus-visible:after:ring-fg/60`;function z$(){return(0,L.jsx)(ym,{size:13,"aria-hidden":!0,className:`${O$} ml-[3px] -mr-[4px] text-muted/35 transition-colors group-hover:text-muted/70`})}function B$({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?`${I$} flex-1`:I$,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} ${R$} 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} ${R$} 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?F$:P$} ${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:L$,children:n}),m?(0,L.jsx)(z$,{}):(0,L.jsx)(`span`,{})]})}function V$({watch:e}){let t=e.github,n=aU(e.target);return(0,I.useEffect)(()=>{n&&jf([e.target])},[n,e.target]),(0,L.jsx)(B$,{testKind:`github`,testId:e.target,mark:(0,L.jsx)(j$,{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:[N$(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 H$(e,t){return(e.bgShells??[]).find(e=>e.id===t||e.taskId===t||e.label===t)}function U$(e){return(e.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`)}function W$({watch:e,thread:t,slug:n,now:r}){let i=H$(t,e.target);if(i)return(0,L.jsx)(G$,{shell:i,slug:n,now:r,testId:e.target});let a=RE(e.createdAt,r);return(0,L.jsx)(B$,{testKind:`shell`,testId:e.target,mark:(0,L.jsx)(vh,{size:12,className:`${O$} text-shell`}),name:e.target,title:e.target,status:a?`running · ${a}`:`running`})}function G$({shell:e,slug:t,now:n,testId:r}){let i=RE(e.startedAt,n),a=e.id&&!e.outputUnavailable;return(0,L.jsx)(B$,{testKind:`shell`,testId:r??e.id??e.label,mark:(0,L.jsx)(vh,{size:12,className:`${O$} text-shell`}),name:e.label,onOpen:a?()=>yp(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 K$({watch:e,now:t}){let n=Date.parse(e.timer?.fireAt??``),r=Number.isFinite(n)?n>t?`fires in ${IE(n-t)}`:`firing…`:`armed`;return(0,L.jsx)(B$,{testKind:`timer`,testId:e.target,mark:(0,L.jsx)(km,{size:12,className:`${O$} 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 q$(e){return(e.subAgents??[]).filter(e=>Xc(e)&&e.state===`running`)}function J$({agent:e,slug:t,now:n}){let r=RE(e.startedAt,n),i=e.subagentType?.replace(/^frizz:/,``);return(0,L.jsx)(B$,{testKind:`agent`,testId:e.id??e.label,mark:(0,L.jsx)(k$,{tone:`border-accent`}),name:e.label,onOpen:e.id?()=>vp(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 Y$(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=H$(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 X$(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=U$(e).filter(t=>r(H$(e,t.target)?.startedAt??t.createdAt));return{prs:i,shells:[...a,...Y$(e,t.hints??[],a)],agents:q$(e).filter(e=>r(e.startedAt)),timers:x$(e).filter(e=>r(e.createdAt))}}function Z$(e,t={}){let n=X$(e,t);return n.prs.length+n.shells.length+n.agents.length+n.timers.length>0}function Q$(e,t,n={}){let{prs:r,shells:i,agents:a,timers:o}=X$(e,n);return[{head:`Sub-agents`,rows:a.map(n=>(0,L.jsx)(J$,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:i.map(n=>(0,L.jsx)(W$,{watch:n,thread:e,slug:e.id,now:t},n.id))},{head:`Pull requests`,rows:r.map(e=>(0,L.jsx)(V$,{watch:e},e.id))},{head:`Timers`,rows:o.map(e=>(0,L.jsx)(K$,{watch:e,now:t},e.id))}].filter(e=>e.rows.length>0)}function $$({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)(ym,{size:10,"aria-hidden":!0,className:`${O$} ml-[5px] transition-transform ${e.collapsed?``:`rotate-90`}`})]}):(0,L.jsx)(`div`,{className:n,children:e.head})}function e1({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)($$,{group:e,first:t===0}),!e.collapsed&&e.rows]},e.head))})]})}function t1(e){return e?.awaitingBackground===!0&&e.runtime===`turn-idle`&&e.bgSnoozed!==!0}var n1=`Hides card until new activity is detected`;function r1({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:n1,className:`disabled:opacity-45 ${zJ}`,children:[(0,L.jsx)(Um,{size:12,className:xX}),`Snooze`]}),(0,L.jsx)(`span`,{className:LJ,children:n1})]})}function i1({thread:e,fence:t,onSnooze:n,onSnoozeFailed:r,notAfter:i}){let a=e??S$,o=t??(e?.lastFence?.kind===`awaiting`?e.lastFence:void 0),s=o?.hints??C$,c=g$(a),l=pU(o?.body),u=JK(l??``),d=Q$(a,TE(),{hints:s,notAfter:i}),f=w$(a,s),p=i===void 0&&e!==void 0&&t1(e)&&rZ(e).snooze;return(0,L.jsxs)(PJ,{"data-awaiting-background":!0,icon:b$(a)?vh:Um,label:(0,L.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:y$(a,s)}),aside:f.length===1?(0,L.jsx)(T$,{watch:f[0]}):void 0,className:p?`pb-0`:``,children:[l?(0,L.jsx)(qq,{className:`md-body ${EJ}`,html:u}):d.length===0&&!v$(a)?(0,L.jsx)(`p`,{className:FJ,children:oU}):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)(T$,{watch:e},e.ref))}),d.length===0&&v$(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 `,h$(a,{watchers:!1}),` it dispatched. It returns to the queue on its own when the work comes back.`]}):(0,L.jsxs)(L.Fragment,{children:[h$(a,{watchers:!1}),` `,_$(a)===1?`is`:`are`,` still running. It resumes on its own when`,` `,_$(a)===1?`it finishes`:`one of them finishes`,`.`]})}),(0,L.jsx)(e1,{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 ${kJ}`,children:(0,L.jsx)(r1,{thread:e,onSnooze:n,onSnoozeFailed:r})}):null]})}function a1(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 o1(e,t=Date.now()){return e!==void 0&&GT(e,t)!==void 0}function s1(){let[e,t]=(0,I.useState)(()=>Date.now());return(0,I.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function c1({thread:e}){let t=s1(),[n,r]=(0,I.useState)(!1),i=GT(e,t);if(!i)return null;let a=Date.parse(i),o=cT(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)(PJ,{"data-snooze-card":!0,icon:Um,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:BE(a-t)}),(0,L.jsx)(`p`,{className:FJ,children:s?(0,L.jsxs)(L.Fragment,{children:[`Resumes `,o,` and sends: “`,fT(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:`${zJ} disabled:cursor-not-allowed disabled:opacity-45`,children:`Wake now`})})]})}function l1({at:e,fallbackAt:t,className:n=``}){let r=TE(),i=sE(e,t),a=cE(i,r);return!a||!i?null:(0,L.jsx)(`time`,{dateTime:i,className:n,children:a})}var u1=1500;function d1(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},u1),a},fail(t){t===n&&(i(),e(!1))},dispose(){n++,i()}}}var f1=`Could not copy terminal command`,p1={attach:`Attach command copied`,resume:`Resume command copied`},m1={attach:`Copy command to attach to this thread's live terminal`,resume:`Copy command to resume this thread in a new terminal`},h1=e=>[`terminalCommand`,e];function g1(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 _1(e){let t=g1(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 HR(n),r}function v1(e){let t=it({mutationFn:()=>_1(e)});return e=>t.mutate(void 0,{onSuccess:t=>{e?.onSuccess?.(),Z(p1[t])},onError:t=>{e?.onError?.(),Z(t instanceof Error?`${f1}: ${t.message}`:f1,{duration:7e3})}})}function y1({slug:e}){let[t,n]=(0,I.useState)(!1),r=(0,I.useRef)(null);r.current||=d1(n,{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)});let i=Ve(),a=v1(e);(0,I.useEffect)(()=>()=>r.current?.dispose(),[]);function o(){i.prefetchQuery({queryKey:h1(e),queryFn:()=>g1(e),staleTime:15e3})}function s(){let t=i.getQueryData(h1(e));if(t){HR(t.command).then(()=>{r.current?.begin(),Z(p1[t.mode])},()=>Z(f1,{duration:7e3}));return}a({onSuccess:()=>r.current?.begin()})}let c=i.getQueryData(h1(e)),l=t?c?p1[c.mode]:`Terminal command copied`:c?m1[c.mode]:`Copy terminal command`;return(0,L.jsx)(nM,{label:l,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":l,title:l,onClick:s,onPointerEnter:o,onFocus:o,className:yD,children:t?(0,L.jsx)(gm,{size:14,strokeWidth:2.2,className:`text-fg`}):(0,L.jsx)(vh,{size:14,strokeWidth:1.8})})})}function b1(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 x1(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 S1(e){return`legacy:${e.role}:${e.kind??`message`}:${e.at??``}:${e.text}`}function C1(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??S1(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 w1(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 T1(e,t){let n=e.map(e=>e.message);return e.filter((e,r)=>!w1(n,r,t))}var E1=new Set([`agent`,`follow up`,`interrupt`,`send message`,`spawn agent`,`wait for agents`]),D1=new Set([`poll process`,`wait`]);function O1(e){return(e.split(`__`).pop()||e).replaceAll(`_`,` `).trim()}function k1(e){return O1(e).toLowerCase()}function A1(e){return e.prompt!==void 0||e.agentId!==void 0||e.sendTo!==void 0||e.sendBody!==void 0||e.backgroundState!==void 0&&!N1(e)||M1(e)||j1(e)||E1.has(k1(e.name))}function j1(e){return e.ask!==void 0&&e.ask.length>0&&e.status!==void 0&&e.status!==`pending`}function M1(e){return e.outputImage!==void 0||e.sentImages!==void 0&&e.sentImages.length>0}function N1(e){return e.backgroundState===`unknown`&&D1.has(k1(e.name))}function P1(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=>!A1(e))?t:null}return e.text.trim()||e.tools.length===0?null:e.tools.every(e=>!A1(e))?e.tools:null}function F1(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 I1(e){if(e.role!==`assistant`||e.kind||e.queued)return null;if(!e.parts?.length)return L1(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 L1(n.tools)}return null}function L1(e){let t=[];for(let n=e.length-1;n>=0&&!A1(e[n]);n--)t.unshift(e[n]);return t.length>0?t:null}function R1(e){if(e.role!==`assistant`||e.kind||e.queued)return null;let t=[],n=e=>{for(let n of e){if(A1(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 z1(e,t){return B1(e,new Set(t))}function B1(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 V1(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 H1(e){let t=[],n=null;return e.forEach((e,r)=>{if(F1(e))return;if(e.queued){t.push({message:e,messageIndex:r});return}let i=P1(e);if(i&&n){n.message=V1(n.message,i,e.at);return}let a=n?R1(e):null,o=a?z1(e,a):e;a&&n&&(n.message=V1(n.message,a,e.at));let s={message:o,messageIndex:r};t.push(s),I1(o)?(s.runStartedAt=o.at,n=s):n=null}),t}function U1(e){return e.status===`completed`||e.status===`failed`||e.status===`cancelled`}function W1(e){let t=G1(e);return t?.tools.some(e=>!U1(e))?t.tools.at(-1):void 0}function G1(e){let t=K1(e);if(!t)return;let n=I1(t.message);return n?{tools:n,at:t.message.at}:void 0}function K1(e){for(let t=e.length-1;t>=0;t--)if(!e[t].message.queued)return e[t]}function q1(e){let t=K1(e);if(t)return I1(t.message)?t.runStartedAt??t.message.at:t.message.at}function J1(e){return e.runStartedAt??e.message.at}function Y1(e){let t=I1(e);return t?B1(e,new Set(t)):e}function X1(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].message;if(!r.queued){I1(r)&&(t=r);break}}if(!t)return[...e];let n=[];for(let r of e){let e=r.message===t?Y1(r.message):r.message;F1(e)||n.push(e===r.message?r:{...r,message:e})}return n}function Z1(e){return e.detail?.trim()||void 0}var Q1={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 $1(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=Q1[i.toLowerCase()];return a?a+(r===-1?``:n.slice(r)):n.charAt(0).toUpperCase()+n.slice(1)}function e0(e,t,n){let r=t?.trim().replace(/[\\/]+$/,``);if(!r||!qf(r))return e;let i=tp(r);return i?rp(e.replace(i,``),n?.trim().replace(/[\\/]+$/,``)||/^([A-Za-z]:[\\/]Users[\\/][^\\/]+|\/(?:Users|home)\/[^/]+)(?=[\\/]|$)/.exec(r)?.[1]):e}function t0(e,t,n=Vf().home){return e0(n0(e),t,n)}function n0(e){let t=k1(e.name),n=Z1(e),r=n?` ${n}`:``;return t===`bash`||t===`exec`||t===`run command`?$1(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 ${O1(e.name)||`a tool`}`}var r0=new Set([`edit`,`multiedit`,`write`,`apply patch`]);function i0(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&&r0.has(k1(n.name))&&t.add(e)}return t.size}function a0(e,t=0){let n=`Ran ${e} tool ${e===1?`call`:`calls`}`;return t===0?n:`${n}, edited ${t} file${t===1?``:`s`}`}function o0(e){return e>0?`${a0(e)}. Thinking…`:`Thinking…`}function s0(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function c0(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function l0(e,t){let n=s0(e,t);if(n)try{let e=new URL(n);return e.protocol===`https:`||e.protocol===`http:`?e.href:void 0}catch{return}}function u0({directive:e,icon:t,title:n,meta:r,children:i}){return(0,L.jsxs)(`section`,{"data-codex-directive":e.name,className:`min-w-0 ${DJ} 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 d0({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 f0({directive:e}){let t=e.attrs,n=s0(t,`display_name`)??s0(t,`skill_name`)??`Artifact template`,r=s0(t,`artifact_kind`),i=s0(t,`skill_name`),a=s0(t,`skill_directory`),[o,s]=(0,I.useState)(!!a);return(0,L.jsxs)(u0,{directive:e,icon:(0,L.jsx)(Jm,{size:15}),title:n,meta:r?`${r} template`:`Template`,children:[i&&(0,L.jsx)(d0,{mono:!0,children:i.startsWith(`$`)?i:`$${i}`}),o&&a&&(0,L.jsx)(`img`,{src:YS(`${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 p0({directive:e}){let t=e.attrs,n=s0(t,`file`),r=c0(t,`start`),i=c0(t,`end`)??r,a=c0(t,`priority`),o=n?`${n}${r?`:${r}${i&&i!==r?`-${i}`:``}`:``}`:`Code location unavailable`;return(0,L.jsxs)(u0,{directive:e,icon:(0,L.jsx)($m,{size:15}),title:s0(t,`title`)??`Review finding`,meta:a===void 0?void 0:`P${a}`,children:[s0(t,`body`)&&(0,L.jsx)(d0,{children:s0(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)(d0,{mono:!0,children:o})]})}var m0={"git-stage":[rh,`Changes staged`],"git-commit":[Lm,`Commit created`],"git-create-branch":[Im,`Branch created`],"git-push":[Sh,`Branch pushed`],"git-create-pr":[Vm,`Pull request created`]};function h0({directive:e}){let[t,n]=m0[e.name],r=s0(e.attrs,`branch`),i=l0(e.attrs,`url`),a=`${n}${e.attrs.isDraft===!0?` as draft`:``}`;return(0,L.jsx)(u0,{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 g0({directive:e}){let t=s0(e.attrs,`threadId`),n=s0(e.attrs,`pendingWorktreeId`);return(0,L.jsx)(u0,{directive:e,icon:(0,L.jsx)(nh,{size:15}),title:n?`Thread setup queued`:`Thread created`,meta:(t||n)&&(0,L.jsx)(`span`,{className:`font-mono-keep`,children:t??n})})}function _0({directive:e}){let t=s0(e.attrs,`reason`);return(0,L.jsx)(u0,{directive:e,icon:(0,L.jsx)(um,{size:15}),title:`Archive suggested`,meta:t})}function v0(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 y0({directive:e}){let t=e.attrs,n=s0(t,`mode`),r=s0(t,`name`)??`Automation`,i=v0(t.rrule),a=[r,n,s0(t,`status`),i].filter(Boolean).join(` · `);return(0,L.jsx)(u0,{directive:e,icon:(0,L.jsx)(hm,{size:15}),title:`Automation suggested`,meta:a,children:s0(t,`prompt`)&&(0,L.jsx)(d0,{children:s0(t,`prompt`)})})}function b0({directive:e}){return e.name===`artifact-template`?(0,L.jsx)(f0,{directive:e}):e.name===`code-comment`?(0,L.jsx)(p0,{directive:e}):e.name.startsWith(`git-`)?(0,L.jsx)(h0,{directive:e}):e.name===`created-thread`?(0,L.jsx)(g0,{directive:e}):e.name===`archive`||e.name===`archive-thread`?(0,L.jsx)(_0,{directive:e}):(0,L.jsx)(y0,{directive:e})}var x0;function S0(){return x0??=ib(async()=>{let{default:e}=await import(`./mermaid.core-Cl84DLN2.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)),x0}function C0({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 S0().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:`${DJ} 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 ${DJ} 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 ${DJ} bg-panel-2`})}var w0=(0,I.createContext)(null),T0=(0,I.createContext)(null);function E0(){let e=(0,I.useContext)(w0),t=(0,I.useContext)(T0);return e??t}var D0=(0,I.createContext)(null);function O0(e){return e.status===`pending`&&e.backgroundState===`background`}function k0(e){let t=[];for(let n of e)for(let e of n.tools)O0(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 A0(e){return e.map(e=>{if(!e.tools.some(O0))return e;let t=e.tools.filter(e=>!O0(e)),n=e.parts?.map(e=>e.kind===`tools`?{...e,tools:e.tools.filter(e=>!O0(e))}:e).filter(e=>e.kind!==`tools`||e.tools.length>0);return{...e,tools:t,parts:n}})}function j0({slug:e,onStatusApplied:t,onClose:n,virtualized:r=!1,showReturnToQueue:i=!1}){let a=Gp(qC(),e);return(0,L.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,L.jsx)(U0,{slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:i}),(0,L.jsx)(M0,{slug:e,virtualized:r}),a&&(0,L.jsx)(AZ,{thread:a,sticky:!0,safeArea:!0,onArchived:t})]})}function M0({slug:e,virtualized:t}){let n=qC(),r=Gp(n,e),i=r?.runtime===`running`||r?.runtime===`spawning`,a=v1(e),o=sw(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)(()=>k0(p),[p]),h=(0,I.useMemo)(()=>A0(p),[p]),g=(0,I.useMemo)(()=>r2(h),[h]),_=(0,I.useMemo)(()=>i?a1(h):void 0,[i,h]),v=_&&_.index>=0?_.index:g,y=(0,I.useMemo)(()=>H1(h),[h]),b=i?G1(y):void 0,x=i?W1(y):void 0,S=x?t0(x,n?.projectDir):void 0,C=i?q1(y):void 0,w=t1(r),T=(0,I.useMemo)(()=>{let e=i?X1(y):y;return T1(e,i2(e,v,w))},[y,i,v,w]),E=i,D=(0,I.useMemo)(()=>iY(p),[p]),O=(0,I.useMemo)(()=>$J(p,r?.answersInFlight),[p,r?.answersInFlight]),k=(0,I.useMemo)(()=>_X(p),[p]),A={thread:r,showWorking:E,registeredDone:TJ(r,g>=0?h[g]?.text:void 0),restedCard:BJ(r,g>=0?h[g]?.text:void 0),errorVisible:HJ(h,r?.providerError)},{answeringForMessage:j}=eX(e,p),M=(0,I.useMemo)(()=>dY(p,r?.questions??[]),[p,r?.questions]),N=(0,I.useMemo)(()=>yY(p,r?.questions??[]),[p,r?.questions]),P=Xl(r?.spawnedAt),ee=(0,I.useRef)(null),[F,te]=(0,I.useState)(null),ne=o.data?.messages.length??0,re=!o.isLoading;(0,I.useEffect)(()=>{if(t)return;let e=ee.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<=4&&(e.scrollTop=e.scrollHeight)},[ne,i,t]);let ie=(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)(w0.Provider,{value:e,children:(0,L.jsx)(u$,{thread:r,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:ee,"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&&ne>0?(0,L.jsx)(V0,{slug:e,transcriptRef:ee,transcriptKey:o.data?.transcriptKey,messages:h,paired:D,inFlightAnswers:O,answeringForMessage:j,placement:N,fencesLive:P,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 ie(),jumpOverlay:F}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(zQ,{thread:r,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(f$,{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)(xh,{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:ne===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)(c4,{}),` Loading…`]}):i?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(c4,{}),` Session starting…`]}):CX(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:[c2(T.map(e=>e.message),(e,t)=>{let n=T[t].messageIndex;return(0,L.jsx)(U2,{m:e,answering:P?j(e):void 0,showSendButton:!0,paired:D[n],staleAwaiting:v>=0&&n<v,restingCardShown:n===g&&w,restedAt:_&&n===_.index?_.at??``:void 0,shadowedBy:M.get(n),placed:N.placed.get(n),thread:r},t)},e=>!!e.queued),re&&R0(A)!==null&&(0,L.jsx)(bY,{h:z0(A,T.map(e=>e.message))}),re&&(0,L.jsx)(B0,{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)(e4,{policy:r.permPolicy,denies:r.permDenies})}):null,p.some(e=>e.queued)&&(0,L.jsx)(bY,{}),(0,L.jsx)(`div`,{className:`flex flex-col gap-3.5`,children:p.map((e,t)=>e.queued?(0,L.jsx)(U2,{m:e,paired:D[t]},`q${t}`):null)})]})})]})}),(0,L.jsx)(`div`,{ref:te,"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)(JX,{slug:e,onTerminal:a,ops:(0,L.jsx)(t4,{slug:e,transcriptShells:m,className:`px-1 pt-1.5`})})})]})})})}var N0=700,P0=250,F0=(()=>{try{return localStorage.getItem(`frizz.debugScroll`)===`1`}catch{return!1}})();function I0(e){return e?.pendingInteraction===!0}function L0(e){return I0(e)?void 0:e?.pendingAsk}function R0({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`:L0(e)?`pending-ask`:e?.runtime===`perm-prompt`&&!I0(e)?`perm-prompt`:t?`working`:e?.providerError?i?null:`provider-error`:o1(e)?`snooze`:t1(e)?`resting`:n?`registered-done`:r?`rested`:null}function z0(e,t){return R0(e)===`working`?s2(t):14}function B0({state:e,slug:t,retryText:n,onTerminal:r,liveRuntimeStart:i,liveActivityLabel:a,liveToolRun:o}){let s=e.thread;switch(R0(e)){case`provider-fault`:return(0,L.jsx)(Z2,{slug:t,sessionId:s.sessionId,fault:s.providerFault,retryText:n});case`provider-error`:return(0,L.jsx)(UJ,{error:s.providerError});case`limit-pause`:return(0,L.jsx)(Q2,{slug:t,sessionId:s.sessionId,pause:s.limitPause});case`pending-ask`:return(0,L.jsx)(n4,{ask:L0(s),onTerminal:r});case`perm-prompt`:return(0,L.jsx)($2,{onTerminal:r});case`working`:return(0,L.jsx)(l4,{since:s?.lastUserAt,startedAt:i,activityLabel:a,run:o});case`snooze`:return(0,L.jsx)(c1,{thread:s});case`resting`:return(0,L.jsx)(i1,{thread:s});case`registered-done`:return(0,L.jsx)(X2,{fenceKind:`done`,body:s.lastFence.body,hints:[]});case`rested`:return(0,L.jsx)(VJ,{thread:s});default:return null}}function V0({slug:e,transcriptRef:t,transcriptKey:n,messages:r,paired:i,inFlightAnswers:a,answeringForMessage:o,placement:s,fencesLive:c,thread:l,running:u,copyTerminalCommand:d,transportFallback:f,isFetching:p,refresh:m,retryLiveUpdates:h,hasEarlier:g,beforeCursor:_,loadingEarlier:v,earlierError:y,loadEarlier:b,jumpOverlay:x}){let S=JC(),C=(0,I.useMemo)(()=>H1(r),[r]),w=u?G1(C):void 0,T=u?W1(C):void 0,E=T?t0(T,S):void 0,D=u?q1(C):void 0,O=(0,I.useMemo)(()=>r2(r),[r]),k=(0,I.useMemo)(()=>u?a1(r):void 0,[u,r]),A=k&&k.index>=0?k.index:O,j=t1(l),M=(0,I.useMemo)(()=>{let e=u?X1(C):C;return T1(e,i2(e,A,j))},[C,u,A,j]),N=u,P=(0,I.useMemo)(()=>C1(M.map(e=>e.message),i2(M,A,j),t2).map(e=>{let t=M[e.messageIndex];return{...e,messageIndex:t.messageIndex,stampAt:J1(t)}}),[M,A,j]),ee=(0,I.useMemo)(()=>_X(r),[r]),F=TJ(l,O>=0?r[O]?.text:void 0),te=BJ(l,O>=0?r[O]?.text:void 0),ne=HJ(r,l?.providerError),re={thread:l,showWorking:N,registeredDone:F,restedCard:te,errorVisible:ne},ie=R0(re)!==null,ae=(0,I.useMemo)(()=>z0({thread:l,showWorking:N,registeredDone:F,restedCard:te,errorVisible:ne},M.map(e=>e.message)),[M,N,l,F,te,ne]),oe=(0,I.useMemo)(()=>{let e=[],t=new Map,n=r.length-1,i=(l?.questions??[]).filter(e=>!s.placedIds.has(e.id));for(let[a,o]of cY(r,i,{atRest:!u})){if(a>=n){e.push(...o);continue}let r=-1;for(let e=0;e<P.length&&!(P[e].messageIndex>a);e++)r=e;let i=t.get(r);i?i.push(...o):t.set(r,[...o])}return{byRow:t,tail:e}},[P,r,s.placedIds,u,l?.questions]),se=(0,I.useMemo)(()=>dY(r,l?.questions??[]),[r,l?.questions]),ce=(0,I.useMemo)(()=>{let e=[{key:`head-anchor`,kind:`head-anchor`}];f&&e.push({key:`transport-fallback`,kind:`transport-fallback`}),(g||v||y)&&e.push({key:`earlier-history:${_??`complete`}`,kind:`earlier-history`});let t=oe.byRow.get(-1);t&&e.push({key:`questions:head`,kind:`questions`,questions:t}),P.forEach((t,n)=>{e.push({...t,kind:`message`});let r=oe.byRow.get(n);r&&e.push({key:`questions:${t.key}`,kind:`questions`,questions:r})}),e.push({key:`interactions`,kind:`interactions`}),ie&&e.push({key:`runtime-status`,kind:`runtime-status`});let n=ie||P.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},[_,y,g,ie,v,P,r,oe,f]),le=Yw({count:ce.length,getScrollElement:()=>t.current,getItemKey:e=>ce[e]?.key??e,estimateSize:e=>{let t=ce[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})}}),[ue,de]=(0,I.useState)(!0),fe=(0,I.useRef)(!0),pe=(0,I.useRef)(-1),me=(0,I.useRef)(0),he=(0,I.useRef)(null),ge=(0,I.useRef)(!1),_e=(0,I.useRef)(!1),ve=(0,I.useRef)(!0),ye=(0,I.useRef)(null),be=(0,I.useRef)(void 0),xe=(0,I.useRef)(null),Se=(0,I.useRef)(void 0),Ce=(0,I.useRef)(0),we=(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&&(ye.current={rowKey:r,viewportTop:n.getBoundingClientRect().top-t})}b()},[b,t]),Te=(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||ce.length===0||be.current===n)return;be.current=n,ge.current=!1,_e.current=!1,ve.current=!0;let t=hD(e)?.candidates.map(e=>({candidate:e,index:ce.findIndex(t=>t.kind===`message`&&t.message.sourceId===e.sourceId)})).find(e=>e.index>=0),r=requestAnimationFrame(()=>{if(!t){le.scrollToEnd({behavior:`instant`}),de(!0),ge.current=!0;return}le.scrollToIndex(t.index,{align:`start`,behavior:`instant`}),fe.current=!1,de(!1),ge.current=!0;let e=performance.now()+P0;Ce.current=e;let n=()=>{performance.now()>=e||performance.now()<me.current||(Te(t.candidate.sourceId,t.candidate.screenTop),r=requestAnimationFrame(n))};n()});return()=>cancelAnimationFrame(r)},[Te,ce.length,e,n,le]),(0,I.useLayoutEffect)(()=>{let e=ye.current,n=t.current;if(!e||!n||v)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(),ye.current===e&&(ye.current=null)})});return()=>{cancelAnimationFrame(a),cancelAnimationFrame(i)}},[v,P.length,t]);let Ee=(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]),De=(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]),Oe=P[0]?.key;(0,I.useLayoutEffect)(()=>{let e=Se.current;if(Se.current=Oe,e===void 0||e===Oe||!ge.current||fe.current||ye.current)return;let t=xe.current;if(!t)return;De(t);let n=()=>{if(performance.now()<me.current)return;let e=xe.current;e&&De(e)},r=0,i=requestAnimationFrame(()=>{n(),r=requestAnimationFrame(n)});return()=>{cancelAnimationFrame(i),cancelAnimationFrame(r)}},[De,Oe]);let ke=(0,I.useCallback)(()=>{let e=t.current;if(!e||ye.current||performance.now()<Ce.current)return;let n=b1({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,previousScrollHeight:pe.current,following:fe.current,readerMoved:performance.now()<me.current});if(fe.current=n.following,n.scrollTop!==null&&(e.scrollTop=n.scrollTop),pe.current=e.scrollHeight,de(e=>e===n.following?e:n.following),F0&&!n.following&&performance.now()>=me.current){let t=xe.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}`)}}xe.current=Ee()??xe.current},[Ee,t]);(0,I.useLayoutEffect)(ke),(0,I.useEffect)(()=>{let e=he.current;if(!e)return;let t=new ResizeObserver(ke);return t.observe(e),()=>t.disconnect()},[ke]),(0,I.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{ke();let t=x1({armed:ve.current,scrollTop:e.scrollTop,readerMoved:ge.current&&_e.current,hasEarlier:g,loading:v});ve.current=t.armed,t.shouldLoad&&we()},r=()=>{_e.current=!0,me.current=performance.now()+N0,requestAnimationFrame(n)},i=t=>{[`ArrowUp`,`PageUp`,`Home`,` `].includes(t.key)&&(e.scrollTop<=480&&(ve.current=!0),r())},a=t=>{t.deltaY<0&&e.scrollTop<=480&&(ve.current=!0),r()},o=()=>{e.scrollTop<=480&&(ve.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)}},[g,v,we,ke,t]);let Ae=le.getVirtualItems(),je=le.getTotalSize();return(0,L.jsxs)(`div`,{ref:he,"data-virtualized-transcript":!0,"data-virtual-row-count":Ae.length,className:`relative w-full`,style:{height:je},children:[Ae.map(t=>{let n=ce[t.index];return n?(0,L.jsx)(`div`,{ref:le.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)(zQ,{thread:l,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(f$,{thread:l,questions:oe.tail,inFlight:a,showSend:s.placedIds.size>0,className:`px-6 pt-5`})]}):n.kind===`questions`?(0,L.jsx)(f$,{thread:l,questions:n.questions,className:`px-6 pt-5`}):n.kind===`transport-fallback`?f?(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 ${DJ} border border-border-strong bg-panel-2 px-4 py-2.5 text-[12px]`,title:f.kind===`payload-too-large`?`Live payload ${f.actualBytes} bytes; socket limit ${f.maxBytes} bytes`:`Transcript read budget reached (${f.scope}); retry after about ${f.retryAfterMs}ms`,children:[(0,L.jsx)(xh,{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.`}),` `,f.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:p,onClick:m,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:p?`Refreshing…`:`Refresh once`}),(0,L.jsx)(`button`,{type:`button`,onClick:h,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:y?(0,L.jsxs)(`span`,{className:`flex flex-wrap items-center justify-center gap-2 text-center`,children:[(0,L.jsx)(`span`,{children:y}),(0,L.jsx)(`button`,{type:`button`,onClick:we,className:`rounded-md border border-border px-2 py-1 text-fg/90 hover:bg-panel-2`,children:`Retry`})]}):v?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Xm,{size:12,className:`animate-spin`}),` Loading earlier messages…`]}):(0,L.jsx)(`button`,{type:`button`,onClick:we,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)(XZ,{at:n.stampAt,host:bX(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(U2,{m:n.message,answering:c?o(n.message):void 0,showSendButton:!0,paired:i[n.messageIndex],staleAwaiting:A>=0&&n.messageIndex<A,restingCardShown:n.messageIndex===O&&j,restedAt:k&&n.messageIndex===k.index?k.at??``:void 0,shadowedBy:se.get(n.messageIndex),placed:s.placed.get(n.messageIndex),thread:l})}):n.kind===`runtime-status`?(0,L.jsxs)(`div`,{className:`px-6`,style:{paddingTop:ae},children:[(0,L.jsx)(B0,{state:re,slug:e,retryText:ee>=0?r[ee]?.text:void 0,onTerminal:d,liveRuntimeStart:D,liveActivityLabel:E,liveToolRun:w}),l?.permPolicy?(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(e4,{policy:l.permPolicy,denies:l.permDenies})}):null]}):(0,L.jsx)(XZ,{at:n.message.at,host:bX(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(U2,{m:n.message,paired:i[n.messageIndex]})})},n.key):null}),(0,L.jsx)(H0,{overlay:x,hidden:ue,onJump:()=>le.scrollToEnd({behavior:`smooth`})})]})}function H0({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)(dm,{size:12}),`Jump to latest`]}),e)}function U0({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1}){let i=Gp(qC(),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=FK(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=CT(i);function _(){c(!1),u(``)}function v(){let e=wX(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:DX,children:[(0,L.jsx)(`div`,{className:OX,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(TX(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)(FZ,{thread:i,hidden:s})]}),(0,L.jsx)(l1,{at:PT(i),fallbackAt:i.spawnedAt,className:`mt-0.5 block truncate text-[11px] leading-tight text-muted/75`})]})}),(0,L.jsxs)(`div`,{className:kX,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[p&&(0,L.jsx)(y1,{slug:e}),(0,L.jsx)(eZ,{thread:i,collapse:r,onDoc:f?()=>_p(`doc`,i.id):void 0,onDone:()=>a.mutate(void 0,{onSuccess:t}),doneBusy:a.isPending,onStatusApplied:t}),n&&(0,L.jsx)(rM,{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)(Ch,{size:15})})]})]})}function W0(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||BZ(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 G0(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||BZ(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 K0(e){return W0(e)!==null}function q0(e){return G0(e)!==null}function J0(e){return e.kind===`event`&&!e.boundary||e.kind===`reasoning`}function Y0(e){return J0(e)||K0(e)}function X0(e){return J0(e)||q0(e)}function Z0(e){if(J0(e))return!0;let t=W0(e);return t!==null&&!A1(t[t.length-1])}function Q0(e){if(J0(e))return!0;let t=G0(e);return t!==null&&!A1(t[0])}function $0(e){let t=W0(e);return t!==null&&M1(t[t.length-1])}function e2(e){let t=G0(e);return t!==null&&M1(t[0])}function t2(e,t){let n=$0(e)||e2(t),r=!n&&Y0(e)&&X0(t)&&!(Z0(e)&&Q0(t));return(n?22:r?6:14)+(e.role===`user`&&t.role!==`user`?3:0)}function n2(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:a2(e,n.text,t)):(e.tools?.length??0)===0&&a2(e,e.text,t)}function r2(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`&&e[t].kind!==`event`)return t;return-1}function i2(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=>n2(e,r.has(e))}function a2(e,t,n){return!e.fenceRefused&&!n?!t.trim():wJ(t).every(e=>e.kind===`fence`&&e.fenceKind===`awaiting`)}function o2(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`&&!a2(e,n.text,t)):typeof e.text==`string`&&!a2(e,e.text,t)}function s2(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.queued||n2(n)))return $0(n)?22:Y0(n)&&!Z0(n)?6:14+(n.role===`user`?3:0)}return 0}function c2(e,t,n){let r=[],i=null;return e.forEach((e,a)=>{n?.(e,a)||n2(e)||(i!==null&&r.push((0,L.jsx)(bY,{h:t2(i,e)},`s${a}`)),r.push(t(e,a)),i=e)}),r}function l2(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 u2(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)(bY,{h:typeof t==`number`?t:t(n)},`vs${n}`)),r.push(e)}),r}var d2={head:!1,tail:!1};function f2(e,t){return n=>e[n-1]?.tail||e[n]?.head?22:t}function p2(e){return{head:M1(e[0]),tail:M1(e[e.length-1])}}function m2(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}):j1(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 h2(e){return e.split(`__`).pop()||e}function g2(e){let t=X.board?.projectDir;return t&&e.startsWith(t+`/`)?e.slice(t.length+1):e}function _2({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=a0(a,i0(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 ${ZZ}`,children:[(0,L.jsx)(`span`,{"data-tool-activity-label":!0,title:o,className:`min-w-0 truncate text-muted`,children:o}),(0,L.jsx)(ym,{"data-tool-activity-chevron":!0,"aria-hidden":`true`,size:13,className:$Z(n)})]}),n&&(0,L.jsx)(`div`,{id:i,className:`mt-1.5 flex flex-col`,children:u2(e.map((e,n)=>(0,L.jsx)(y2,{t:e,startedAt:t},n)),6)}),!n&&(0,L.jsx)(`div`,{id:i,hidden:!0})]})}function v2({tools:e,at:t}){let n=[];for(let t of e){let e=A1(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:u2(n.map((e,n)=>e.exceptional?(0,L.jsx)(`div`,{className:`flex flex-col`,children:u2(e.tools.map((e,n)=>(0,L.jsx)(y2,{t:e,startedAt:t},n)),f2(e.tools.map(e=>p2([e])),6))},`exceptions-${n}`):(0,L.jsx)(_2,{tools:e.tools,at:t},`activity-${n}`)),f2(n.map(e=>p2(e.tools)),6))})}function y2({t:e,startedAt:t}){let n=(0,I.useContext)(w0),r=qC(),i=NE(e,(n?Gp(r,n):void 0)?.bgShells??[]);return e.edits&&e.status!==`failed`&&e.status!==`cancelled`?(0,L.jsx)(Aq,{edits:e.edits,meta:(0,L.jsx)(w2,{status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,durationMs:e.durationMs})}):e.command?(0,L.jsx)(M2,{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)(k2,{name:e.name,detail:e.detail,outputImage:e.outputImage,output:e.output,status:e.status,durationMs:e.durationMs}):e.read?(0,L.jsx)(P2,{detail:e.detail,read:e.read,status:e.status,durationMs:e.durationMs}):e.prompt||e.agentId?(0,L.jsx)(I2,{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)(R2,{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)(A2,{images:e.sentImages??[],files:e.sentFiles??[],caption:e.caption,status:e.status,durationMs:e.durationMs}):e.todos?(0,L.jsx)(eJ,{todos:e.todos,note:e.input,meta:(0,L.jsx)(w2,{status:e.status,durationMs:e.durationMs})}):j1(e)?(0,L.jsx)(b2,{ask:e.ask??[],askAnswers:e.askAnswers}):e.input||e.output?(0,L.jsx)(M2,{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)(O2,{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 b2({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=FQ(e,t?.[n]);return(0,L.jsx)(iX,{question:r.question,settled:{chosenIdxs:r.chosenIdxs,text:r.text}},n)})})}function x2({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 S2(e,t,n){let[r,i]=(0,I.useState)(()=>Date.now()),a=AE(e,t),o=jE(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(kE-(Date.now()-e),0));return()=>clearTimeout(t)},[a,o,n]),o}function C2({status:e,backgroundState:t,liveBackgroundState:n,startedAt:r}){let i=S2(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:YE}):OE(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 w2({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:PE(i),c=[o,s].filter(Boolean).join(` · `);return(0,L.jsx)(x2,{tone:e===`failed`?`frizz-tool-failed`:e===`cancelled`?`text-amber-400`:`text-muted/55`,title:c,label:a,duration:s})}function T2(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 E2(e,t,n){let r=t&&t!==X.board?.projectDir?`in ${g2(t)}`:void 0;return[e,t?r:n!==void 0&&!e?.includes(String(n))?`session ${n}`:void 0].filter(Boolean).join(` · `)||void 0}function D2(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.includes(`…`)}function O2({name:e,detail:t,count:n,status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,cwd:s,sessionId:c,durationMs:l,startedAt:u}){let d=E2(t,s,c),f=d?g2(d):void 0,p=t&&D2(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)(C2,{status:r,backgroundState:i,liveBackgroundState:a,startedAt:u}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:h2(e)}),f&&(p?(0,L.jsx)(`span`,{className:`min-w-0 truncate`,onClick:e=>e.stopPropagation(),children:(0,L.jsx)(kq,{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)(w2,{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 k2({name:e,detail:t,outputImage:n,output:r,status:i,durationMs:a}){let o=t?g2(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:h2(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)(w2,{status:i,durationMs:a})})]});return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(G2,{path:n,hideCaption:!0,altText:o?`${h2(e)}: ${o}`:h2(e),header:s}),r&&(0,L.jsx)(`pre`,{className:`frizz-bash frizz-bash-body frizz-bash-output-body mt-1.5`,children:r})]})}function A2({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)(w2,{status:r,durationMs:i}),(0,L.jsx)(ym,{"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)(G2,{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)(K2,{path:e},`f${t}`))}),n&&(0,L.jsx)(`div`,{className:`max-w-[65%] text-[12px] leading-snug text-muted`,children:n})]})})]})}var j2=16;function M2({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=T2(i,d,l),b=(0,I.useMemo)(()=>e.split(`
314
314
  `).length,[e]),x=b>j2,S=(0,I.useMemo)(()=>n?n.split(`
315
315
  `).length:0,[n]),C=S>j2,w=E2(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`} `:``}${h2(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)(C2,{status:i,backgroundState:a,liveBackgroundState:o,startedAt:d}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:h2(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)(w2,{status:i,backgroundState:a,liveBackgroundState:o,exitCode:s,durationMs:y}),T&&(0,L.jsx)(ym,{"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)(Jq,{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 N2=16;function P2({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>N2,d=e?g2(e):void 0,f=e&&D2(e)?e:void 0;return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(Oq,{className:`frizz-bash-header`,controls:c,expanded:i,label:`${i?`Collapse`:`Expand`} Read${e?`: ${e}`:``}`,onToggle:()=>a(e=>!e),meta:(0,L.jsx)(w2,{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)(kq,{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)(Jq,{text:t,language:DS(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 F2=16;function I2({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(`