frizz-server 0.13.0 → 0.13.2

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-DyLvW_rQ.js → TerminalPane-DuP4bhhj.js} +1 -1
  3. package/web-dist/assets/{abnfDiagram-VRR7QNED-DIPgkiM8.js → abnfDiagram-VRR7QNED-CEh3P4ec.js} +1 -1
  4. package/web-dist/assets/architecture-TIHT7OUA-DljbXMGA.js +1 -0
  5. package/web-dist/assets/{architectureDiagram-ZJ3FMSHR-DBAKToiy.js → architectureDiagram-ZJ3FMSHR-hB8r_8GD.js} +1 -1
  6. package/web-dist/assets/{blockDiagram-677ZJIJ3-Ba0xt8st.js → blockDiagram-677ZJIJ3-B_EjnCzl.js} +1 -1
  7. package/web-dist/assets/{c4Diagram-LMCZKHZV-DFham1h_.js → c4Diagram-LMCZKHZV-CE2lnwzC.js} +1 -1
  8. package/web-dist/assets/channel-DDJsvUil.js +1 -0
  9. package/web-dist/assets/{chunk-32BRIVSS-Bl-817K-.js → chunk-32BRIVSS-ClStiHFP.js} +1 -1
  10. package/web-dist/assets/{chunk-52WLFC77-DBLTDz2W.js → chunk-52WLFC77-BwoEvnjI.js} +1 -1
  11. package/web-dist/assets/{chunk-C7G6YPKG-ClL6Ebv8.js → chunk-C7G6YPKG-Sml7hEgL.js} +1 -1
  12. package/web-dist/assets/{chunk-EX3LRPZG--3vJLCZP.js → chunk-EX3LRPZG-C5qtRylf.js} +1 -1
  13. package/web-dist/assets/{chunk-FWX5IMBZ-DMOdhcCP.js → chunk-FWX5IMBZ-3V8_Ch9U.js} +2 -2
  14. package/web-dist/assets/{chunk-HOUHSVGY-DkgTGLCa.js → chunk-HOUHSVGY-Jgabn4KJ.js} +1 -1
  15. package/web-dist/assets/{chunk-ICXQ74PX-7X6iir1H.js → chunk-ICXQ74PX-DPC_6w3e.js} +1 -1
  16. package/web-dist/assets/{chunk-MOJQB5TN-OpO5flE4.js → chunk-MOJQB5TN-C2R2l4fd.js} +1 -1
  17. package/web-dist/assets/{chunk-OGEWGWER-BbAMAzTZ.js → chunk-OGEWGWER-snbL2tzP.js} +1 -1
  18. package/web-dist/assets/{chunk-PUDLZKDR-avcvDgZl.js → chunk-PUDLZKDR-BH0YK-aj.js} +1 -1
  19. package/web-dist/assets/{chunk-Q4XR5HBZ-BaiGN1cd.js → chunk-Q4XR5HBZ-yS4RCJUS.js} +1 -1
  20. package/web-dist/assets/{chunk-V7JOEXUC-CKVakdOJ.js → chunk-V7JOEXUC-pTkkxySk.js} +1 -1
  21. package/web-dist/assets/{chunk-VAUOI2AC-DzG-rM3_.js → chunk-VAUOI2AC-ByfRcoJm.js} +1 -1
  22. package/web-dist/assets/{chunk-VR4S4FIN-t3j3HHQF.js → chunk-VR4S4FIN-D0ZL-X9t.js} +1 -1
  23. package/web-dist/assets/{chunk-WYO6CB5R-SnP0NDTw.js → chunk-WYO6CB5R-DR4Z32Vt.js} +1 -1
  24. package/web-dist/assets/{chunk-ZGVPDNZ5-pXn3giwS.js → chunk-ZGVPDNZ5-BSInEZ5j.js} +1 -1
  25. package/web-dist/assets/classDiagram-OUVF2IWQ-D7o_xZN-.js +1 -0
  26. package/web-dist/assets/classDiagram-v2-EOCWNBFH-D7o_xZN-.js +1 -0
  27. package/web-dist/assets/{cynefin-VYW2F7L2-C4qNLMkm.js → cynefin-VYW2F7L2-5_kg3VC3.js} +1 -1
  28. package/web-dist/assets/{cynefinDiagram-TSTJHNR4-2vzWUUfl.js → cynefinDiagram-TSTJHNR4-I2p0qywZ.js} +1 -1
  29. package/web-dist/assets/{dagre-VKFMJZFB-DUdNHEM9.js → dagre-VKFMJZFB-CqsSUWqR.js} +1 -1
  30. package/web-dist/assets/{diagram-FQU43EPY-C_EHNL09.js → diagram-FQU43EPY-LzYRcSp1.js} +1 -1
  31. package/web-dist/assets/{diagram-G47NLZAW-DOt98NB-.js → diagram-G47NLZAW-j7KoGkdO.js} +1 -1
  32. package/web-dist/assets/{diagram-NH7WQ7WH-uIgVP9iZ.js → diagram-NH7WQ7WH-CkKj7Le-.js} +1 -1
  33. package/web-dist/assets/{diagram-OA4YK3LP-CGWe4oxq.js → diagram-OA4YK3LP-BbYnMMQ4.js} +1 -1
  34. package/web-dist/assets/{diagram-WEI45ONY-C-5f7o9T.js → diagram-WEI45ONY-ZnaXdrM2.js} +1 -1
  35. package/web-dist/assets/{ebnfDiagram-CCIWWBDH-DoSFLtL-.js → ebnfDiagram-CCIWWBDH-DlMJ525N.js} +1 -1
  36. package/web-dist/assets/{erDiagram-Q63AITRT-DsCLMzEE.js → erDiagram-Q63AITRT-BNqaRFOq.js} +1 -1
  37. package/web-dist/assets/eventmodeling-45OFAUF4-C7Co2sdQ.js +1 -0
  38. package/web-dist/assets/flowDiagram-23GEKE2U-CU4XpHpz.js +1 -0
  39. package/web-dist/assets/{ganttDiagram-NO4QXBWP-D8UNGcBR.js → ganttDiagram-NO4QXBWP-LA2zj1xa.js} +1 -1
  40. package/web-dist/assets/{gitGraph-TEB2WS4Q-mC-XQzTE.js → gitGraph-TEB2WS4Q-CyxExxvY.js} +1 -1
  41. package/web-dist/assets/{gitGraphDiagram-IHSO6WYX-CkpPggS7.js → gitGraphDiagram-IHSO6WYX-DViEDxai.js} +1 -1
  42. package/web-dist/assets/{index-Dmo0zJc8.js → index-C7G9HRfv.js} +78 -78
  43. package/web-dist/assets/index-CiTqRvSi.css +1 -0
  44. package/web-dist/assets/{info-DKCQHKI2-Drg-xVbr.js → info-DKCQHKI2-CjwMBNAx.js} +1 -1
  45. package/web-dist/assets/{infoDiagram-FWYZ7A6U-CsGMTGpl.js → infoDiagram-FWYZ7A6U-CH1w5jOF.js} +1 -1
  46. package/web-dist/assets/{ishikawaDiagram-FXEZZL3T-DNgGBlL6.js → ishikawaDiagram-FXEZZL3T-D6E4RsM0.js} +1 -1
  47. package/web-dist/assets/{journeyDiagram-5HDEW3XC-BFN2bObi.js → journeyDiagram-5HDEW3XC-BqKaYGHB.js} +1 -1
  48. package/web-dist/assets/{kanban-definition-HUTT4EX6-BnDPclXf.js → kanban-definition-HUTT4EX6-BtqDatnY.js} +1 -1
  49. package/web-dist/assets/{line-DmLw74JM.js → line-CxNuqMwk.js} +1 -1
  50. package/web-dist/assets/{mermaid-parser.core-DGJk39E-.js → mermaid-parser.core-iyBzku_i.js} +3 -3
  51. package/web-dist/assets/{mermaid.core-8aee8nsf.js → mermaid.core-Bo-3lWY-.js} +3 -3
  52. package/web-dist/assets/{mindmap-definition-LN4V7U3C-CGWK_Qbm.js → mindmap-definition-LN4V7U3C-B6hABfKD.js} +1 -1
  53. package/web-dist/assets/{packet-7NZHBO7P-C5HYQyS5.js → packet-7NZHBO7P-CucMCZHl.js} +1 -1
  54. package/web-dist/assets/{pegDiagram-2B236MQR-WiQm887Q.js → pegDiagram-2B236MQR-otFk7wnm.js} +1 -1
  55. package/web-dist/assets/{pie-RZYD4A2V-DKBNMtMn.js → pie-RZYD4A2V-Cry4tbtA.js} +1 -1
  56. package/web-dist/assets/{pieDiagram-ENE6RG2P-F1A8_3DO.js → pieDiagram-ENE6RG2P-D55Qzck8.js} +1 -1
  57. package/web-dist/assets/{quadrantDiagram-ABIIQ3AL-bf6a3f_f.js → quadrantDiagram-ABIIQ3AL-CExholO3.js} +1 -1
  58. package/web-dist/assets/{radar-I7S5WNFK-AOKDUn-C.js → radar-I7S5WNFK-DTEZSaKV.js} +1 -1
  59. package/web-dist/assets/{railroad-3IZDKUUU-DNHhkFAC.js → railroad-3IZDKUUU-wcxq1ncG.js} +1 -1
  60. package/web-dist/assets/railroad-abnf-AHOZXSZD-D37eg4Bf.js +1 -0
  61. package/web-dist/assets/railroad-ebnf-EBAXGLYW-BUsJxSuz.js +1 -0
  62. package/web-dist/assets/railroad-peg-LSFZ7HO6-CqLrwvjX.js +1 -0
  63. package/web-dist/assets/{railroadDiagram-RFXS5EU6-Be52T90z.js → railroadDiagram-RFXS5EU6-fZ4i7gmj.js} +1 -1
  64. package/web-dist/assets/{requirementDiagram-TGXJPOKE-BqdMvEGK.js → requirementDiagram-TGXJPOKE-D_ImY4sL.js} +1 -1
  65. package/web-dist/assets/{sankeyDiagram-HTMAVEWB-BP3X6Ofp.js → sankeyDiagram-HTMAVEWB-owSPfb7d.js} +1 -1
  66. package/web-dist/assets/{sequenceDiagram-DBY2YBRQ-yDHhaUzc.js → sequenceDiagram-DBY2YBRQ-DcJPd0hW.js} +1 -1
  67. package/web-dist/assets/{stateDiagram-2N3HPSRC-xvctsgCU.js → stateDiagram-2N3HPSRC-Ds82k2nu.js} +1 -1
  68. package/web-dist/assets/stateDiagram-v2-6OUMAXLB-DgtweSx_.js +1 -0
  69. package/web-dist/assets/{swimlanes-5IMT3BWC-DZMLgrjk.js → swimlanes-5IMT3BWC-CdObiiEk.js} +1 -1
  70. package/web-dist/assets/swimlanesDiagram-G3AALYLV-JzJpN1D7.js +8 -0
  71. package/web-dist/assets/{timeline-definition-FHXFAJF6-n8sU0qlT.js → timeline-definition-FHXFAJF6-CyG43nBw.js} +1 -1
  72. package/web-dist/assets/{treeView-QDETBFTQ-Su8KloaY.js → treeView-QDETBFTQ-Csu3pDsD.js} +1 -1
  73. package/web-dist/assets/{treemap-6X3UGDF4-CNgRuVWf.js → treemap-6X3UGDF4-Cz38SD4Z.js} +1 -1
  74. package/web-dist/assets/{vennDiagram-L72KCM5P-B5I9YxaY.js → vennDiagram-L72KCM5P-CInmXHU6.js} +1 -1
  75. package/web-dist/assets/{wardley-OPB4EBWU-khMe_Wbq.js → wardley-OPB4EBWU-RlUfW1zQ.js} +1 -1
  76. package/web-dist/assets/{wardleyDiagram-EHGQE667-d8LsqhTO.js → wardleyDiagram-EHGQE667-pt9lws9S.js} +1 -1
  77. package/web-dist/assets/{xychartDiagram-FW5EYKEG-b0CH_-wy.js → xychartDiagram-FW5EYKEG-Q6zyjSv0.js} +1 -1
  78. package/web-dist/index.html +2 -2
  79. package/web-dist/assets/architecture-TIHT7OUA-B8qUD5-C.js +0 -1
  80. package/web-dist/assets/channel-5l10tOPT.js +0 -1
  81. package/web-dist/assets/classDiagram-OUVF2IWQ-vIfzHupB.js +0 -1
  82. package/web-dist/assets/classDiagram-v2-EOCWNBFH-vIfzHupB.js +0 -1
  83. package/web-dist/assets/eventmodeling-45OFAUF4-D7GQYhiK.js +0 -1
  84. package/web-dist/assets/flowDiagram-23GEKE2U-CR371xZs.js +0 -1
  85. package/web-dist/assets/index-CT6k_A5y.css +0 -1
  86. package/web-dist/assets/railroad-abnf-AHOZXSZD-DOXbu4iv.js +0 -1
  87. package/web-dist/assets/railroad-ebnf-EBAXGLYW-C1oE2RHD.js +0 -1
  88. package/web-dist/assets/railroad-peg-LSFZ7HO6-B4GD-bq-.js +0 -1
  89. package/web-dist/assets/stateDiagram-v2-6OUMAXLB-xFk0N3Cq.js +0 -1
  90. package/web-dist/assets/swimlanesDiagram-G3AALYLV-BoWrxkxy.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPane-DyLvW_rQ.js","assets/rolldown-runtime-Bh1tDfsg.js","assets/mermaid.core-8aee8nsf.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-C4XfhTaE.js","assets/chunk-WYO6CB5R-SnP0NDTw.js","assets/chunk-ICXQ74PX-7X6iir1H.js","assets/dist-DoH_9pyS.js","assets/chunk-VAUOI2AC-DzG-rM3_.js","assets/chunk-HOUHSVGY-DkgTGLCa.js","assets/chunk-Q4XR5HBZ-BaiGN1cd.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-BbAMAzTZ.js","assets/chunk-C7G6YPKG-ClL6Ebv8.js","assets/chunk-ZGVPDNZ5-pXn3giwS.js","assets/rough.esm-CSKSodPl.js","assets/chunk-52WLFC77-DBLTDz2W.js","assets/line-DmLw74JM.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-FWX5IMBZ-DMOdhcCP.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-DuP4bhhj.js","assets/rolldown-runtime-Bh1tDfsg.js","assets/mermaid.core-Bo-3lWY-.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-C4XfhTaE.js","assets/chunk-WYO6CB5R-DR4Z32Vt.js","assets/chunk-ICXQ74PX-DPC_6w3e.js","assets/dist-DoH_9pyS.js","assets/chunk-VAUOI2AC-ByfRcoJm.js","assets/chunk-HOUHSVGY-Jgabn4KJ.js","assets/chunk-Q4XR5HBZ-yS4RCJUS.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-snbL2tzP.js","assets/chunk-C7G6YPKG-Sml7hEgL.js","assets/chunk-ZGVPDNZ5-BSInEZ5j.js","assets/rough.esm-CSKSodPl.js","assets/chunk-52WLFC77-BwoEvnjI.js","assets/line-CxNuqMwk.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-FWX5IMBZ-3V8_Ch9U.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(`
@@ -136,12 +136,12 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
136
136
  `);if(!BS(n))return PS(e,t);let r=[],i=[];for(let e of n){let t=RS.exec(e);t?(r.push(t[1]),i.push(t[2])):e.trim()&&zS.test(e)?(r.push(e),i.push(``)):(r.push(``),i.push(e))}let a=LS(PS(i.join(`
137
137
  `),t));return r.map((e,t)=>(e?`<span class="${HS}">${VS(e)}</span>`:``)+(a[t]??``)).join(`
138
138
  `)}var WS=/^[a-zA-Z]:[\\/]/,GS=/^(?:cursor|vscode|vscode-insiders|windsurf):\/\/file\/(.*)$/i;function KS(e){try{return decodeURIComponent(e)}catch{return e}}function qS(e){if(e===`/`||e.startsWith(`/?`)||e.startsWith(`/#`))return!0;let t=e.replace(/[?#].*$/u,``);if(Ad(t))return!0;let n=Nd(t).split(`/`)[1]??``;return Ed.has(n)}function JS(e){let t=e?.trim();if(!t)return null;let n=KS(t);if(WS.test(n))return{display:n};if(n.startsWith(`/`)&&!n.startsWith(`//`)&&!qS(n)){let e=n;return{display:e,posixPath:e}}let r=GS.exec(t);if(r){let e=KS(r[1].replace(/[?#].*$/u,``)).replace(/^\/+/,``);if(!e)return null;if(WS.test(e))return{display:e};let t=`/${e}`;return{display:t,posixPath:t}}if(!/^file:/i.test(t))return null;try{let e=new URL(t);if(e.protocol!==`file:`)return null;if(e.hostname&&e.hostname!==`localhost`)return{display:t};let n=KS(e.pathname);return{display:n,posixPath:n}}catch{return{display:t}}}function YS(e){return`${Id()}/local-image?path=${encodeURIComponent(e)}`}var XS=/\.(?:png|jpe?g|gif|webp)$/i;function ZS(e){return e.posixPath&&XS.test(e.posixPath)?YS(e.posixPath):null}var QS=/\.(?:md|mdx|markdown)$/i;function $S(e){return QS.test(e.trim().replace(/:\d+(?::\d+)?$/,``))}function eC(e,t,n){let r=e?.trim();if(!r||/^[a-z][a-z0-9+.-]*:/i.test(r)||/^[\\/#?]/.test(r))return null;let i=KS(r.replace(/[?#].*$/u,``));if(!i)return null;let a=i===`~`||/^~[\\/]/.test(i);if(a&&!(n&&qf(n)))return null;let o=a?n:t;return qf(o)?Zf(o,a?i.slice(2):i):null}function tC(e){return $f(e)||`/`}function nC(e){return[$S(e)?`localMarkdown`:`localFile`,e]}function rC(e){let t=$S(e);return{queryKey:nC(e),queryFn:async()=>{if(t)return Y.localMarkdown({path:e});let n=await Y.localFile({path:e});return{path:n.path,markdown:n.text,truncated:n.truncated}},staleTime:5e3}}var iC=2e3,aC=new Map,oC=12;function sC(e,t){let n=aC.get(e);if(n&&n.raw===t)return n.html;let r=US(t,DS(e));if(aC.set(e,{raw:t,html:r}),aC.size>oC){let e=aC.keys().next();e.done||aC.delete(e.value)}return r}function cC(e){let t=globalThis.requestIdleCallback;t?t(e,{timeout:500}):setTimeout(e,0)}function lC(e,t){e.prefetchQuery(rC(t)).then(()=>{let n=e.getQueryData(rC(t).queryKey);!n?.markdown||$S(t)||cC(()=>sC(n.path,n.markdown))}).catch(()=>{})}var uC=null,dC=null,fC=null,pC=null,mC=0,hC=0,gC=!1,_C=!1,vC=!1,yC=new Map,bC=new Map,xC=0,SC=new Jb(()=>NC(),e=>{dC&&ex(dC,e)}),CC=35e3;function wC(){return`${location.origin.replace(/^http/,`ws`)}${Id()}/ws`}var TC,EC=!1;function DC(){TC=Ad(),EC=!0}function OC(e){return EC&&TC===e}function kC(){if(uC||vC)return;X.connection!==`open`&&(X.connection=`connecting`),DC();let e=new WebSocket(wC()),t=Ad();uC=e,gC=!1,hC=Date.now(),e.onopen=()=>{_C=!0,hC=Date.now(),X.connection=`open`,X.socketTranscripts=!0,fC&&=(clearTimeout(fC),null)},e.onmessage=n=>{if(!(uC!==e||t!==Ad())){hC=Date.now();try{let e=JSON.parse(n.data),t=LC(e);t&&(mC=0),t&&e.t===`event`&&e.event.type===`board`&&(gC=!0,xC++,zC())}catch(e){console.error(`bad /ws message`,e)}}},e.onerror=()=>{},e.onclose=()=>{uC===e&&(uC=null,jC())},PC()}function AC(){let e=uC;if(uC=null,gC=!1,e){e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close()}catch{}}}function jC(){if(SC.reset(),!_C){IC();return}mC++,X.connection=mC>3?`closed`:`connecting`,MC()}function MC(e=!1){if(fC){if(!e)return;clearTimeout(fC),fC=null}let t=e?0:Math.min(1e3*2**Math.min(mC-1,4),15e3);fC=setTimeout(()=>{fC=null,kC()},t)}function NC(){SC.reset(),AC(),kC()}function PC(){if(pC)return;pC=setInterval(()=>{uC&&Date.now()-hC>CC&&FC()},1e4);let e=()=>{vC||(!uC||Date.now()-hC>CC)&&FC(!0)};window.addEventListener(`focus`,e),window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,()=>{document.hidden||e()})}function FC(e=!1){if(!vC){if(AC(),SC.reset(),!_C){IC();return}mC++,X.connection=mC>3?`closed`:`connecting`,MC(e)}}function IC(e){vC||(vC=!0,e&&(X.socketBoardFallback=e,X.socketTranscriptFallbacks={}),AC(),X.socketTranscripts=!1,px(dC??void 0))}function LC(e){switch(e.t){case`event`:return SC.handle(e.event),e.event.type===`board`&&(X.socketBoardFallback=null),!0;case`transcript`:return dC?.setQueryData([`transcript`,e.slug],t=>{let n=jx(t,e.messages);return{...n,messages:wx(t?.messages,_x(t?.messages,n.messages))}}),delete X.socketTranscriptFallbacks[e.slug],!0;case`file-changed`:return dC?.invalidateQueries({queryKey:nC(e.path)}),!0;case`payload-too-large`:return e.channel===`board`?(X.socketBoardFallback||console.warn(`[frizz] live board payload exceeded the socket limit; using SSE`,{actualBytes:e.actualBytes,maxBytes:e.maxBytes}),IC({actualBytes:e.actualBytes,maxBytes:e.maxBytes})):(X.socketTranscriptFallbacks[e.slug]||console.warn(`[frizz] live transcript payload exceeded the socket limit; updates paused`,{slug:e.slug,actualBytes:e.actualBytes,maxBytes:e.maxBytes}),X.socketTranscriptFallbacks[e.slug]={kind:`payload-too-large`,actualBytes:e.actualBytes,maxBytes:e.maxBytes}),!1;case`resource-limited`:return X.socketTranscriptFallbacks[e.slug]||console.warn(`[frizz] live transcript read budget reached; updates paused`,{slug:e.slug,scope:e.scope,retryAfterMs:e.retryAfterMs}),X.socketTranscriptFallbacks[e.slug]={kind:`read-budget`,scope:e.scope,retryAfterMs:e.retryAfterMs},!1;case`hb`:return!0}}function RC(e){gC&&uC&&uC.readyState===WebSocket.OPEN&&uC.send(JSON.stringify(e))}function zC(){for(let e of yC.keys())X.socketTranscriptFallbacks[e]||RC({t:`sub`,topic:`transcript`,slug:e});for(let e of bC.keys())RC({t:`sub`,topic:`file`,path:e}),xC>1&&dC?.invalidateQueries({queryKey:nC(e)})}function BC(e){let t=(yC.get(e)??0)+1;yC.set(e,t),t===1&&!X.socketTranscriptFallbacks[e]&&RC({t:`sub`,topic:`transcript`,slug:e})}function VC(e){let t=(yC.get(e)??0)-1;t<=0?(yC.delete(e),RC({t:`unsub`,topic:`transcript`,slug:e})):yC.set(e,t)}function HC(e){let t=(bC.get(e)??0)+1;bC.set(e,t),t===1&&RC({t:`sub`,topic:`file`,path:e})}function UC(e){let t=(bC.get(e)??0)-1;t<=0?(bC.delete(e),RC({t:`unsub`,topic:`file`,path:e})):bC.set(e,t)}function WC(e){X.socketTranscriptFallbacks[e]&&(delete X.socketTranscriptFallbacks[e],yC.has(e)&&RC({t:`sub`,topic:`transcript`,slug:e}))}function GC(){yC.clear(),bC.clear(),SC.reset(),AC(),X.connection=`connecting`,DC(),vC?fx():kC()}function KC(e){dC=e,DC();let t=()=>kC();document.readyState===`complete`?t():window.addEventListener(`load`,t,{once:!0})}function qC(){return Zt(X).board}function JC(){return Zt(X).board?.projectDir}function YC(e){return e}function XC(e){let t=Zt(X).socketTranscripts;return(0,I.useEffect)(()=>(HC(e),()=>UC(e)),[e]),t}function ZC(e){if(!(!e||e.kind!==`session`||e.foreign||!e.sessionId))return{slug:e.id,sessionId:e.sessionId}}function QC(e){let t=ZC(e);if(!(!t||e?.pendingInteraction===!1))return t}function $C(e,t=Date.now()){let n=1/0;for(let t of e){if(!t.expiresAt)continue;let e=Date.parse(t.expiresAt);Number.isFinite(e)&&(n=Math.min(n,e))}return Number.isFinite(n)?Math.max(250,n-t+50):!1}function ew(e){let t=QC(e);return nt({queryKey:t?Xb(t.slug,t.sessionId):[`interactions`,`pending`,`unowned`],queryFn:()=>Y.pendingInteractions(t),enabled:t!==void 0,refetchInterval:e=>$C(e.state.data?.interactions??[]),refetchOnReconnect:!0,refetchOnWindowFocus:!0})}var tw=7e3,nw=5e3,rw=3,iw=15e3,aw=30*6e4;function ow(e,t,n){let r=Gp(e,t)?.lastActivityAt;if(!r)return 0;let i=Date.parse(r);return Number.isFinite(i)?i>n?0:iw:0}function sw(e,t){let n=Ve(),r=Zt(X),i=r.socketTranscripts,a=r.socketTranscriptFallbacks[e],o=nt({queryKey:[`transcript`,e],queryFn:async()=>{let t=await Y.threadTranscript({slug:e}),r=n.getQueryData([`transcript`,e]),i=Ax(r,t);return{...i,messages:wx(r?.messages,_x(r?.messages,i.messages))}},refetchInterval:t.poll&&!i&&!a?1500:!1,refetchOnWindowFocus:!a,staleTime:t=>ow(X.board,e,t.state.dataUpdatedAt),gcTime:aw});return(0,I.useEffect)(()=>{if(!t.poll&&!i||a)return;let r=!1,s=0,c,l=setInterval(()=>{if(r)return;let t=Gp(X.board,e)?.lastActivityAt,a=Ex(n.getQueryData([`transcript`,e])?.messages);if(!Tx(t,a,nw)){s=0;return}if(a!==c&&(s=0),s>=rw)return;s++,c=a;let l=t?Date.parse(t)-(a?Date.parse(a):0):0;console.warn(`[frizz] transcript watchdog: stale view — self-healing`,{slug:e,lagMs:l,transport:i?`socket`:`poll`,attempt:s}),i&&(VC(e),BC(e)),r=!0,o.refetch().finally(()=>{r=!1})},tw);return()=>clearInterval(l)},[e,t.poll,i,a]),{...o,transportFallback:a?a.kind===`payload-too-large`?{kind:`payload-too-large`,actualBytes:a.actualBytes,maxBytes:a.maxBytes}:{kind:`read-budget`,scope:a.scope,retryAfterMs:a.retryAfterMs}:null,retryLiveUpdates:()=>WC(e)}}function cw(e,t){return nt({queryKey:[`subAgentTranscript`,e,t],queryFn:()=>Y.subAgentTranscript({slug:e,id:t}),refetchInterval:e=>e.state.data?.state===`running`?2500:!1})}function lw(e,t){return nt({queryKey:[`backgroundShellOutput`,e,t],queryFn:()=>Y.backgroundShellOutput({slug:e,id:t}),refetchInterval:e=>e.state.data?.state===`running`?1500:!1})}function uw(e,t){let n=[...t].sort(),r=nt({queryKey:[`backgroundShellActivity`,e,n],queryFn:()=>Y.backgroundShellActivity({slug:e,ids:n}),enabled:n.length>0,refetchInterval:e=>e.state.data&&!e.state.data.shells.some(e=>e.running)?!1:1500});return(0,I.useMemo)(()=>new Map((r.data?.shells??[]).flatMap(e=>e.lines===null?[]:[[e.id,e.lines]])),[r.data])}function dw(e,t,n,r={}){e.setQueryData([`transcript`,t],e=>{let t=e?.messages??[];return{...e,messages:[...t,{role:`user`,text:n,tools:[],parts:[],queued:!0,deliveryId:r.deliveryId}]}}),r.scrollToBottom!==!1&&typeof window<`u`&&requestAnimationFrame(()=>window.scrollTo({top:document.documentElement.scrollHeight,behavior:`smooth`}))}function fw(e,t,n,r){e.setQueryData([`transcript`,t],e=>{if(!e?.messages?.length)return e;let t=e.messages.findLastIndex(e=>e.queued&&e.role===`user`&&e.text===n&&(r===void 0||e.deliveryId===r));return t===-1?e:{...e,messages:e.messages.filter((e,n)=>n!==t)}})}function pw(){let e=Bp();return e?`/thread/${encodeURIComponent(e)}`:X.routeThreadSlug?`/thread/${encodeURIComponent(X.routeThreadSlug)}`:X.view.startsWith(`status:`)?`/status/${encodeURIComponent(X.view.slice(7))}`:`/`}function mw(e){try{return decodeURIComponent(e)}catch{return null}}function hw(e,t=X.board?.projectSlug){let n=Pd(e);return n===`/`&&t?jd(t):n}function gw(e){let t=e.match(/^\/thread\/([^/]+)$/);if(t){let e=mw(t[1]);if(e===null){X.routeThreadSlug=null,zp(X.drawers.map(e=>e.id)),X.view=`todos`;return}X.view=`todos`;let n=X.drawers.findIndex(t=>t.kind===`thread`&&t.slug===e&&!t.closing);if(n!==-1){X.routeThreadSlug=null,zp(X.drawers.slice(n+1).map(e=>e.id));return}X.routeThreadSlug=e;return}let n=e.match(/^\/status\/([^/]+)$/);if(n){X.routeThreadSlug=null,zp(X.drawers.map(e=>e.id));let e=mw(n[1]);X.view=e===null?`todos`:`status:${e}`;return}X.routeThreadSlug=null,zp(X.drawers.map(e=>e.id)),X.view=`todos`}function _w(e=location.pathname){gw(Nd(e))}var vw=null;function yw(e){vw=e}function bw(e,t){vw?vw(e,t):typeof location<`u`&&location.assign(e)}function xw(e){return _w(),Jt(X,()=>{if(Rd(Nd())!==null)return;let t=hw(pw());t!==location.pathname&&e(t,{replace:!pw().startsWith(`/thread/`)})})}function Sw(e,t){if(!t)return e;let n=e.projectDir!==t.projectDir,r=t.threads.length>0;return{projectDir:t.projectDir,hasBeenVisible:n?r:e.hasBeenVisible||r}}var Cw=`frizz-sidebar-seen:`;function ww(e){try{return localStorage.getItem(Cw+(e??``))===`1`}catch{return!1}}function Tw(e,t){try{localStorage.setItem(Cw+(e??``),t?`1`:`0`)}catch{}}function Ew(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function Dw(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function Ow(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var kw=(e,t)=>Math.abs(e-t)<1.01,Aw=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},jw,Mw=()=>{if(jw!==void 0)return jw;if(typeof navigator>`u`)return jw=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return jw=!0;let e=navigator.maxTouchPoints;return jw=navigator.platform===`MacIntel`&&e!==void 0&&e>0},Nw=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},Pw=e=>e,Fw=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},Iw=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(Nw(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(Nw(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},Lw={passive:!0},Rw=typeof window>`u`?!0:`onscrollend`in window,zw=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&Rw,o=0,s=a?null:Aw(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,Lw),a&&r.addEventListener(`scrollend`,u,Lw),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},Bw=(e,t)=>zw(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),Vw=(e,t,n)=>{if(n.options.useCachedMeasurements){let t=n.indexFromElement(e),r=n.options.getItemKey(t);return n.itemSizeCache.get(r)??n.options.estimateSize(t)}if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}if(!t){let t=n.indexFromElement(e),r=n.options.getItemKey(t),i=n.itemSizeCache.get(r);if(i!==void 0)return i}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},Hw=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},Uw=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.pendingScrollAnchor=null,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Pw,rangeExtractor:Fw,onChange:()=>{},measureElement:Vw,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,anchorTo:`start`,followOnAppend:!1,scrollEndThreshold:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`,useCachedMeasurements:!1};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}let n=this.options,r=null,i=null,a=!1;if(n!==void 0&&n.enabled&&t.enabled&&t.anchorTo===`end`&&this.scrollElement!==null){let e=n.count,o=t.count,s=this.getMeasurements(),c=e>0?s[0]?.key??n.getItemKey(0):null,l=e>0?s[e-1]?.key??n.getItemKey(e-1):null;if(o!==e||e>0&&o>0&&(t.getItemKey(0)!==c||t.getItemKey(o-1)!==l)){a=!0;let c=e>0?this.getVirtualItemForOffset(this.getScrollOffset())??s[0]:null;c&&(r=[c.key,this.getScrollOffset()-c.start]);let u=t.followOnAppend===!0?`auto`:t.followOnAppend||null;u&&o>e&&this.isAtEnd(n.scrollEndThreshold)&&(e===0||t.getItemKey(o-1)!==l)&&(i=u)}}this.options=t,a&&(this.pendingMin=0,this.itemSizeCacheVersion++);let o=!1,s=0;if(r&&this.scrollOffset!==null){let[e,t]=r,n=this.getMeasurements(),{count:i,getItemKey:a}=this.options,c=0;for(;c<i&&a(c)!==e;)c++;if(c<i){let e=n[c];if(e){let n=Math.max(0,e.start+t);n!==this.scrollOffset&&(s=n-this.scrollOffset,this.scrollOffset=n,o=!0)}}}(o||i)&&(this.pendingScrollAnchor=[o?r[0]:null,o?r[1]:0,i,s])},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=Dw(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!Mw()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,Lw),e.addEventListener(`touchend`,n,Lw),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(Mw()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=Dw(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode,this.options.gap],(e,t,n,r,i,a,o,s)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s}),{key:!1}),this.getMeasurements=Dw(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o,gap:s},c)=>{let l=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let u=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=e*2,a=this._flatMeasurements;if(!a||a.length<i){let e=new Float64Array(i);a&&u>0&&e.set(a.subarray(0,u*2)),a=e,this._flatMeasurements=a}let o;if(u===0)o=t+n;else{let e=u-1;o=a[e*2]+a[e*2+1]+s}for(let t=u;t<e;t++){let e=r(t),n=l.get(e),i=typeof n==`number`?n:this.options.estimateSize(t);a[t*2]=o,a[t*2+1]=i,o+=i+s}let c=Ew(e,a,r);return this.measurementsCache=c,c}let d=this.measurementsCache.slice(0,u),f=Array(a).fill(void 0),p=new Float64Array(a),m=0;for(let e=0;e<u;e++){let t=d[e];t&&(f[t.lane]===void 0&&m++,f[t.lane]=e,p[t.lane]=t.end)}for(let i=u;i<e;i++){let e=r(i),c=this.laneAssignments.get(i),u,h,g=o===`estimate`||l.has(e);if(c!==void 0&&this.options.lanes>1){u=c;let e=f[u],r=e===void 0?void 0:d[e];h=r?r.end+s:t+n}else if(m===a){let e=0,t=p[0],n=f[0];for(let r=1;r<a;r++){let i=p[r];(i<t||i===t&&f[r]<n)&&(e=r,t=i,n=f[r])}u=e,h=t+s,g&&this.laneAssignments.set(i,u)}else u=i%this.options.lanes,h=t+n,g&&this.laneAssignments.set(i,u);let _=l.get(e),v=typeof _==`number`?_:this.options.estimateSize(i),y=h+v;d[i]={index:i,start:h,size:v,end:y,key:e,lane:u},f[u]===void 0&&m++,f[u]=i,p[u]=y}return this.measurementsCache=d,d},{key:!1,debug:()=>this.options.debug}),this.calculateRange=Dw(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=Kw(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Dw(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);if(o!==0){let a=this.options.anchorTo===`end`&&this.scrollState?.behavior!==`smooth`&&this.getVirtualDistanceFromEnd()<=this.options.scrollEndThreshold,s=a?this.getTotalSize():0,c=this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&(!this.itemSizeCache.has(i)||this.scrollDirection!==`backward`):this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this));(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,a?this.applyScrollAdjustment(this.getTotalSize()-s):c&&this.applyScrollAdjustment(o),this.notify(!1)}},this.getVirtualItems=Dw(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return Ow(t[Ww(0,t.length-1,r?e=>n[e*2]:e=>Ow(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){e!==0&&(Mw()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&kw(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},Ww=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function Gw(e,t,n){let r=0;for(;r<=t;){let i=(r+t)/2|0,a=e[i*2];if(a<n)r=i+1;else if(a>n)t=i-1;else return i}return r>0?r-1:0}function Kw(e,t,n,r,i){let a=e.length-1;if(e.length<=r)return{startIndex:0,endIndex:a};if(r===1&&i!==null){let e=Gw(i,a,n),r=e,o=n+t;for(;r<a&&i[r*2]+i[r*2+1]<o;)r++;return{startIndex:e,endIndex:r}}let o=Ww(0,a,t=>e[t].start,n),s=o;if(r===1)for(;s<a&&e[s].end<n+t;)s++;else if(r>1){let i=Array(r).fill(0);for(;s<a&&i.some(e=>e<n+t);){let t=e[s];i[t.lane]=t.end,s++}let c=Array(r).fill(n+t);for(;o>=0&&c.some(e=>e>=n);){let t=e[o];c[t.lane]=t.start,o--}o=Math.max(0,o-o%r),s=Math.min(a,s+(r-1-s%r))}return{startIndex:o,endIndex:s}}var qw=typeof document<`u`?I.useLayoutEffect:I.useEffect;function Jw({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=I.useReducer(e=>e+1,0)[1],a=I.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}let r=!!e.options.horizontal,i=t.mode===`transform`,o=r?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let n of c){let a=n.start-s,c=e.elementsCache.get(n.key);c&&t.lastPositions.get(c)!==a&&(t.lastPositions.set(c,a),i?c.style.transform=r?`translate3d(${a}px, 0, 0)`:`translate3d(0, ${a}px, 0)`:c.style[o]=`${a}px`)}},s={...r,onChange:(t,n)=>{var s;let c=a.current,l=!0;if(c.enabled){o(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,ot.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[c]=I.useState(()=>{let e=new Uw(s);return Object.assign(e,{containerRef:t=>{let n=a.current;if(n.container=t,n.lastSize=null,t&&n.enabled){let r=e.getTotalSize();n.lastSize=r;let i=e.options.horizontal?`width`:`height`;t.style[i]=`${r}px`}}})});return c.setOptions(s),qw(()=>c._didMount(),[]),qw(()=>c._willUpdate()),qw(()=>{o(c)}),c}function Yw(e){return Jw({observeElementRect:Iw,observeElementOffset:Bw,scrollToFn:Hw,...e})}var Xw=3600*1e3,Zw=24*Xw,Qw=[{value:`1h`,label:`1h`,detail:`60m`,kind:`duration`},{value:`tomorrow`,label:`tomorrow`,detail:`9am`,kind:`calendar`},{value:`1d`,label:`1d`,detail:`24h`,kind:`duration`},{value:`3d`,label:`3d`,detail:`72h`,kind:`duration`},{value:`1w`,label:`1w`,detail:`7d`,kind:`duration`}],$w=new Set(Qw.map(e=>e.value));function eT(e){return typeof e==`string`&&$w.has(e)}function tT(e){return nT(e).label}function nT(e){return Qw.find(t=>t.value===e)??Qw[2]}function rT(e){let t=nT(e);return t.kind===`calendar`?`Snooze until ${t.label}`:`Snooze ${t.label}`}function iT(e,t=Date.now()){if(e===`tomorrow`){let e=new Date(t);return new Date(e.getFullYear(),e.getMonth(),e.getDate()+1,9,0,0,0).toISOString()}return new Date(t+(e===`1h`?Xw:e===`1d`?Zw:e===`3d`?3*Zw:7*Zw)).toISOString()}function aT(e){return String(e).padStart(2,`0`)}function oT(e){return`${e.getFullYear()}-${aT(e.getMonth()+1)}-${aT(e.getDate())}T${aT(e.getHours())}:${aT(e.getMinutes())}`}function sT(e,t=Date.now()){let n=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/.exec(e);if(!n)return{ok:!1,message:`Choose a local date and time`};let[,r,i,a,o,s]=n,c=[r,i,a,o,s].map(Number),l=new Date(c[0],c[1]-1,c[2],c[3],c[4],0,0);return!Number.isFinite(l.getTime())||l.getFullYear()!==c[0]||l.getMonth()!==c[1]-1||l.getDate()!==c[2]||l.getHours()!==c[3]||l.getMinutes()!==c[4]?{ok:!1,message:`That local time does not exist`}:l.getTime()<=t?{ok:!1,message:`Choose a time in the future`}:{ok:!0,until:l.toISOString()}}function cT(e,t=Date.now()){let n=new Date(e);if(!Number.isFinite(n.getTime()))return``;let r=new Date(t),i=new Date(r.getFullYear(),r.getMonth(),r.getDate()).getTime(),a=new Date(n.getFullYear(),n.getMonth(),n.getDate()).getTime(),o=Math.round((a-i)/Zw),s=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(n);if(o===0)return`Today at ${s}`;if(o===1)return`Tomorrow at ${s}`;if(o>1&&o<7)return`${new Intl.DateTimeFormat(void 0,{weekday:`long`}).format(n)} at ${s}`;let c={month:`short`,day:`numeric`};return n.getFullYear()!==r.getFullYear()&&(c.year=`numeric`),`${new Intl.DateTimeFormat(void 0,c).format(n)} at ${s}`}function lT(e,t){if(!Number.isFinite(Date.parse(e)))return null;let n=cT(e,t);return n?n.replace(/^(Today|Tomorrow)/,e=>e.toLowerCase()):null}function uT(e,t=Date.now()){let n=lT(e,t);return n?`Snoozed until ${n}`:null}var dT=120;function fT(e,t=dT){let n=e.trim().replace(/\s+/g,` `);return n.length>t?`${n.slice(0,t-1)}…`:n}function pT(e,t,n=Date.now()){let r=t?.trim();if(!r)return uT(e,n);let i=mT(e,n);return i?`${i} — then: ${fT(r)}`:null}function mT(e,t=Date.now()){let n=lT(e,t);return n?`Auto-snoozed until ${n}`:null}var hT=`frizz.prefs.v1`;function gT(e,t){return e===`fifo`||e===`lifo`?e:t}function _T(e){let t={compactDiffs:!0,snoozePreset:`1d`,queueOrder:`fifo`,railFilesCollapsed:!1,diffsRedefaulted:!0};try{if(!e)return t;let n=JSON.parse(e);return n.diffsRedefaulted||=(n.compactDiffs=!0,!0),{...t,...n,snoozePreset:eT(n.snoozePreset)?n.snoozePreset:t.snoozePreset,queueOrder:gT(n.queueOrder,t.queueOrder),railFilesCollapsed:typeof n.railFilesCollapsed==`boolean`?n.railFilesCollapsed:t.railFilesCollapsed}}catch{return t}}function vT(){try{return _T(typeof localStorage>`u`?null:localStorage.getItem(hT))}catch{return _T(null)}}var yT=qt(vT());Jt(yT,()=>{try{typeof localStorage<`u`&&localStorage.setItem(hT,JSON.stringify(yT))}catch{}});function bT(e){return e.kind===`session`&&e.foreign!==!0&&e.runtime===`exited`}var xT=Uc.options,ST={planning:`text-sky-400 border-sky-400/40`,planned:`text-violet-400 border-violet-400/40`,active:`text-emerald-400 border-emerald-400/40`,"needs-human":`text-yellow-400 border-yellow-400/40`,blocked:`text-orange-400 border-orange-400/40`,done:`text-zinc-400 border-zinc-400/40`,dismissed:`text-rose-400 border-rose-400/40`,archived:`text-slate-500 border-slate-500/40`};function CT(e){return e.foreign===!0&&e.title.trim()?e.title.trim():AT(e)?ET:e.aiTitle?.trim()&&!wT(e)?TT(e.aiTitle):e.backend===`codex`&&e.titleAuto===!0&&!e.aiTitle?.trim()?DT:e.titleAuto===!1&&e.title.trim()?e.title:e.title.trim()&&!(e.titleAuto===!0&&e.title.trim()===e.id)?e.titleAuto===!0?TT(e.title):e.title.trim():e.titleAuto===!0?DT:e.id}function wT(e){return e.titleLocked??e.titleAuto===!1}function TT(e){let t=e.trim();if(!/^[a-z0-9]+(?:[-_][a-z0-9]+)*$/i.test(t))return t;let n=t.split(/[-_]+/).filter(Boolean);if(n.length===0)return t;let r=n.join(` `).toLowerCase();return r.charAt(0).toUpperCase()+r.slice(1)}var ET=`Spinning up a thread…`,DT=`Untitled thread`,OT=6e4,kT=15e3;function AT(e){if(!e.titleAuto||e.aiTitle)return!1;if(e.backend===`codex`){if(e.runtime===`spawning`)return!0;let t=Date.parse(e.spawnedAt??``);return Number.isFinite(t)&&Date.now()-t<kT}let t=Date.parse(e.spawnedAt??``);return Number.isFinite(t)&&Date.now()-t<OT}function jT(e){return e.status===`done`||e.status===`dismissed`||GT(e)!==void 0&&KT(e)?!1:!!(e.runtime===`perm-prompt`||e.pendingAsk||e.humanBlocked&&e.runtime!==`none`&&e.runtime!==`running`&&e.runtime!==`spawning`||e.pendingQuestion&&e.runtime!==`running`&&e.runtime!==`spawning`||(e.questions?.length??0)>0&&e.runtime!==`running`&&e.runtime!==`spawning`||(e.status===`active`||e.status===`planning`)&&(e.runtime===`exited`||e.runtime===`none`)&&e.spawnedAt&&!e.archived)}function MT(e){let t=Date.parse(e.lastUserAt??``),n=Date.parse(e.spawnedAt??``),r=Math.max(Number.isFinite(t)?t:-1/0,Number.isFinite(n)?n:-1/0);return Number.isFinite(r)?r:0}function NT(e){if(qT(e))return MT(e);let t=Date.parse(e.lastAssistantAt??``);return Number.isFinite(t)?t:MT(e)}function PT(e){return qT(e)?e.lastActivityAt??e.spawnedAt:e.lastAssistantAt??e.lastActivityAt??e.spawnedAt}function FT(e){return[...e].sort((e,t)=>{let n=jT(e);if(n!==jT(t))return n?-1:1;let r=NT(t)-NT(e);return r===0?e.id.localeCompare(t.id):r})}function IT(e){return[...e].sort((e,t)=>{let n=NT(t)-NT(e);return n===0?e.id.localeCompare(t.id):n})}function LT(e,t=`fifo`){let n=t===`lifo`?-1:1;return[...e].sort((e,t)=>{let r=(NT(e)-NT(t))*n;return r===0?e.id.localeCompare(t.id):r})}function RT(e){return du(e)}function zT(e){return e.filter(e=>e.kind===`session`&&e.foreign===!0)}function BT(e){return e.kind===`session`&&e.foreign!==!0&&typeof e.pinnedAt==`string`}function VT(e){return e.runtime===`turn-idle`||e.runtime===`exited`}function HT(e){return(e.subAgents??[]).some(e=>Xc(e)&&e.state===`running`)}function UT(e){return HT(e)?!0:e.awaitingBackground===!0&&!WT(e)}function WT(e){if(e.awaitingBackground!==!0)return!1;let t=e.watches??[];return!t.some(e=>e.kind===`timer`&&e.state===`armed`)||HT(e)||(e.bgShells??[]).some(e=>e.state===`running`)?!1:!t.some(e=>e.kind===`github`&&e.state===`armed`)}function GT(e,t=Date.now()){let n=Date.parse(e.snoozedUntil??``);return Number.isFinite(n)&&n>t?e.snoozedUntil:void 0}function KT(e,t=Date.now()){let n=GT(e,t)!==void 0;if(e.state===`archived`)return!1;let r=e.bgSnoozed===!0&&e.runtime===`turn-idle`;if(HT(e)||UT(e)&&!r)return!1;if(n)return e.runtime!==`running`&&e.runtime!==`spawning`;if(e.limitPause&&e.foreign!==!0||e.needsYou||e.pendingAsk||e.runtime===`perm-prompt`||!VT(e))return!1;if(r)return!0;let i=e.lastFence?.kind===`awaiting`;return n||i}function qT(e){return e.runtime===`running`||e.runtime===`spawning`?!0:e.runtime===`turn-idle`&&UT(e)}function JT(e){return e.needsYou===!0&&VT(e)}function YT(e){return e.runtime===`turn-idle`&&e.awaitingBackground===!0&&!HT(e)}function XT(e){return YT(e)?(e.bgShells??[]).some(e=>e.state===`running`)?!0:(e.watches??[]).some(e=>e.kind===`github`&&e.state===`armed`&&e.github?.checks===`running`&&e.github.state===`open`):!1}function ZT(e){return e.runtime===`turn-idle`?QT(e):!1}function QT(e){return(e.watches??[]).some(e=>e.kind===`github`&&e.state===`armed`)?!0:e.lastFence?.kind===`awaiting`&&e.lastFence.hints.some(e=>e.kind===`pr`&&e.value.trim()!==``)}function $T(e){return e.runtime===`turn-idle`?(e.watches??[]).some(e=>e.kind===`timer`&&e.state===`armed`):!1}function eE(e){let t=qT(e);return e.state===`archived`&&!t?`archived`:GT(e)!==void 0&&KT(e)?`snoozed`:e.actionableInteraction||e.pendingAsk||e.pendingQuestion||e.runtime===`perm-prompt`||e.humanBlocked||e.status===`needs-human`?`needs-input`:t&&!JT(e)&&!YT(e)?`working`:(e.questions?.length??0)>0?`needs-input`:KT(e)?`snoozed`:e.limitPause&&e.foreign!==!0?`limit`:e.lastFence?.kind===`done`&&VT(e)?`done`:ZT(e)?`pr`:$T(e)?`timer`:XT(e)?`background`:bT(e)?`stalled`:`rest`}function tE(e){let t=eE(e);return t===`stalled`||t===`limit`}function nE(e){return e.kind===`session`?e.state===`archived`&&!qT(e)?`inactive`:KT(e)?`snoozed`:`active`:null}function rE(e,t=`fifo`){let n=e.filter(iE);return[...LT(e.filter(e=>!iE(e)),t),...IT(n)]}function iE(e){return e.needsYou!==!0}function aE(e){return{running:e.filter(iE),rested:e.filter(e=>!iE(e))}}function oE(e,t=`fifo`){let n={pinned:[],active:[],snoozed:[],inactive:[]};for(let t of e){if(t.kind===`session`&&t.foreign===!0)continue;if(BT(t)){n.pinned.push(t);continue}let e=nE(t);e&&n[e].push(t)}return n.pinned.sort((e,t)=>(e.pinnedAt??``).localeCompare(t.pinnedAt??``)||e.id.localeCompare(t.id)),n.active=rE(n.active,t),n.snoozed=IT(n.snoozed),n.inactive=IT(n.inactive),n}function sE(e,t){for(let n of[e,t])if(n&&Number.isFinite(Date.parse(n)))return n}function cE(e,t=Date.now()){let n=lE(e,t);return n&&`Last active ${n}`}function lE(e,t=Date.now()){let n=fE(e,t);return n===null||n===uE?n:`${n} ago`}var uE=`just now`;function dE(e){if(e<60)return`${e}s`;let t=Math.floor(e/60);if(t<60)return`${t}m`;let n=Math.floor(t/60);if(n<24)return`${n}h`;let r=Math.floor(n/24);if(r<7)return`${r}d`;let i=Math.floor(r/7);if(i<5)return`${i}w`;let a=Math.floor(r/30);return a<12?`${a}mo`:`${Math.max(1,Math.floor(r/365))}y`}function fE(e,t=Date.now()){let n=e?Date.parse(e):NaN;if(!Number.isFinite(n)||!Number.isFinite(t))return null;let r=Math.max(0,Math.floor((t-n)/1e3));return r===0?uE:dE(r)}function pE(e,t=new Date){let n=e?Date.parse(e):NaN;if(!Number.isFinite(n))return null;let r=new Date(n);return`${r.toLocaleDateString([],r.getFullYear()===t.getFullYear()?{month:`short`,day:`numeric`}:{year:`numeric`,month:`short`,day:`numeric`})}, ${r.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}`}function mE(e,t=Date.now()){let n=e?Date.parse(e):NaN;if(!Number.isFinite(n)||!Number.isFinite(t))return null;let r=Math.max(0,Math.floor((t-n)/1e3));return r<60?uE:`${dE(r)} ago`}function hE(e,t={}){let n=e?Date.parse(e):NaN;return Number.isFinite(n)?new Intl.DateTimeFormat(t.locale,{day:`numeric`,month:`short`,year:`numeric`,hour:`numeric`,minute:`2-digit`,timeZoneName:`short`,timeZone:t.timeZone}).format(n):null}function gE(e){let t=new Date(e*1e3),n=t.toDateString()===new Date().toDateString(),r=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});return n?r:`${t.toLocaleDateString([],{weekday:`short`})} ${r}`}var _E=3e4,vE=new Set,yE=Date.now(),bE;function xE(){yE=Date.now();for(let e of vE)e();SE()}function SE(){if(vE.size===0)return;let e=_E-yE%_E;bE=setTimeout(xE,e||_E)}function CE(e){return vE.add(e),vE.size===1&&(yE=Date.now(),SE()),()=>{vE.delete(e),vE.size===0&&bE&&(clearTimeout(bE),bE=void 0)}}function wE(){return yE}function TE(){return(0,I.useSyncExternalStore)(CE,wE,wE)}function EE({size:e=15}){return(0,L.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 15 15`,"aria-hidden":!0,className:`text-muted/85`,children:[(0,L.jsx)(`rect`,{x:`0.5`,y:`0.5`,width:`14`,height:`14`,rx:`3.5`,fill:`none`,stroke:`currentColor`,strokeOpacity:`0.5`,strokeWidth:`1`}),(0,L.jsx)(`rect`,{x:`0.5`,y:`0.5`,width:`14`,height:`14`,rx:`3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1`,strokeLinecap:`round`,strokeDasharray:`11 39`,children:(0,L.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:`50`,to:`0`,dur:`1.1s`,repeatCount:`indefinite`})})]})}function DE(e){return e===`running`}function OE(e,t){return e===`pending`&&t===`background`}var kE=2e3;function AE(e,t){return e===`pending`&&t===void 0}function jE(e,t,n,r){if(!AE(e,t))return!1;let i=n?Date.parse(n):NaN;return Number.isFinite(i)?r-i>=kE:!0}function ME(e){return e?.split(`
139
- `).find(e=>e.trim())?.trim().replace(/\s+/g,` `)||void 0}function NE(e,t){if(e.name===`Interrupt process`||e.status===`cancelled`||e.backgroundState!==`background`)return;let n=new Set([ME(e.desc),ME(e.detail),ME(e.command)].filter(e=>!!e));if(n.size===0)return;let r=t.filter(e=>n.has(ME(e.label)??``));return r.some(e=>e.state===`running`)?`running`:r.some(e=>e.state===`stale`)?`stale`:void 0}function PE(e){if(e<1)return`<1ms`;if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${e<1e4?(e/1e3).toFixed(1):Math.round(e/1e3)}s`;let t=Math.floor(e/6e4);if(t>=60)return t%60?`${Math.floor(t/60)}h ${t%60}m`:`${Math.floor(t/60)}h`;let n=Math.round(e%6e4/1e3);return n?`${t}m ${n}s`:`${t}m`}function FE(e){if(e<1)return`just now`;if(e<60)return`${e}m`;let t=Math.floor(e/60);if(t<24)return e%60?`${t}h ${e%60}m`:`${t}h`;let n=Math.floor(t/24);return t%24?`${n}d ${t%24}h`:`${n}d`}function IE(e){if(!Number.isFinite(e)||e<0)return``;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60),i=n%60;return i?`${r}h ${i}m`:`${r}h`}function LE(e){if(!Number.isFinite(e)||e<0)return``;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return n%60?`${r}h ${n%60}m`:`${r}h`;let i=Math.floor(r/24);if(i<7)return r%24?`${i}d ${r%24}h`:`${i}d`;let a=Math.floor(i/7);return i%7?`${a}w ${i%7}d`:`${a}w`}function RE(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?IE(t-n):``}function zE(e){if(!Number.isFinite(e)||e<0)return``;let t=Math.floor(e/6e4);return t<1?`<1m`:FE(t)}function BE(e){if(!Number.isFinite(e)||e<=0)return`0s`;let t=e=>String(e).padStart(2,`0`),n=Math.ceil(e/1e3);if(n<60)return`${n}s`;let r=Math.floor(n/60);if(r<60)return`${r}m ${t(n%60)}s`;let i=Math.floor(r/60);if(i<24)return`${i}h ${t(r%60)}m`;let a=Math.floor(i/24);if(a<7)return i%24?`${a}d ${i%24}h`:`${a}d`;let o=Math.floor(a/7);return a%7?`${o}w ${a%7}d`:`${o}w`}function VE(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?FE(Math.floor((t-n)/6e4)):``}function HE(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);if(!Number.isFinite(n))return``;let r=Math.floor((t-n)/6e4);return r<1?`just now`:`${FE(r)} ago`}var UE={fgSuccess:`#3fb950`,bgSuccessEmphasis:`#238636`,fgDanger:`#f85149`,bgDangerEmphasis:`#da3633`,fgDone:`#ab7df8`,bgDoneEmphasis:`#8957e5`,fgAttention:`#d29922`,fgNeutral:`#9198a1`,bgNeutralEmphasis:`#656c76`},WE=`shrink-0 text-[11px] leading-none text-muted/45`,GE=`block h-1.5 w-1.5 rounded-full bg-muted/30`,KE=`stale — no recent output`,qE=`block h-1.5 w-1.5 rounded-full border border-muted/45`,JE=`rested — it stopped, but the work it launched is still running`,YE=`running — no recent output`,XE={AGENT:`Open sub-agent transcript`,SHELL:`Open background shell output`,GITHUB:`Open this pull request on GitHub`};function ZE(e){if(!(typeof e!=`number`||!Number.isFinite(e)||e<0))return e===1?`1 line`:`${$E(e)??`0`} lines`}function QE(e){if(e){if(e.state!==`open`)return e.state;if(e.failed>0)return`${e.failed} failed`;if(e.gated>0)return`${e.gated} held`;if(e.running>0)return`${e.running} running`;if(e.passed>0)return`${e.passed} green`}}function $E(e){if(typeof e!=`number`||!Number.isFinite(e)||e<=0)return;let t=(e,t)=>`${e<100?e.toFixed(1).replace(/\.0$/,``):Math.round(e)}${t}`;return e<1e3?String(Math.round(e)):e<1e6?t(e/1e3,`k`):t(e/1e6,`M`)}var eD={running:`Stop — end this operation and everything it spawned, then clear the row`,settled:`Clear — stop tracking this finished operation`},tD={running:`Stop`,settled:`Clear`},nD={AGENT:`sub-agent`,SHELL:`background shell`,GITHUB:`PR watcher`};function rD(e,t){let n=new Map;for(let t of e){if(!t.parentId)continue;let e=n.get(t.parentId);e?e.push(t):n.set(t.parentId,[t])}let r=[],i=new Set([t]),a=(e,t)=>{for(let o of n.get(e)??[])o.id&&i.has(o.id)||(o.id&&i.add(o.id),r.push({...o,displayDepth:t}),o.id&&a(o.id,t+1))};return a(t,1),r}var iD=e=>e.state===`running`||e.state===`stale`||e.state===`rested`;function aD(e,t){return t===`card`?e.filter(iD):t===`rail`?e.filter(e=>!!e.id&&iD(e)):e}var oD=e=>{let t=e.launchId??e.id;return[...t?[`id:${t}`]:[],...e.command?[`cmd:${e.command}`]:[],`launch:${e.label}\u0000${e.startedAt??``}`]};function sD(e,t){let n=[...e],r=new Set(n.flatMap(oD));for(let e of t)oD(e).some(e=>r.has(e))||n.push(e);return n}function cD({kind:e,label:t,state:n,density:r,depth:i,startedAt:a,counter:o,counterTitle:s,counterTone:c,parentSlug:l,onOpen:u,onDismiss:d,title:f}){let p=DE(n),m={AGENT:`frizz-live-dot--agent`,SHELL:`frizz-live-dot--shell`,GITHUB:`frizz-live-dot--github`},h={AGENT:`AGENT`,SHELL:`SHELL`,GITHUB:`WATCH`},g=!!u,_=r===`rail`,v=r===`sheet`,y=RE(a,TE()),b=Math.min(Math.max((i??1)-1,0),4)*13,x=p?`running`:`settled`,S=XE[e],C=f??(g?S:void 0),w=n===`rested`?(0,L.jsx)(`span`,{className:qE,title:JE}):(0,L.jsx)(`span`,{className:GE,title:KE}),T=_?(0,L.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:p?(0,L.jsx)(EE,{size:12}):w}):(0,L.jsx)(`span`,{className:`frizz-op-dot-slot flex w-[9px] shrink-0 justify-center`,children:p?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot ${m[e]}`,"data-running-indicator":r===`card`?`queue-subagent`:`operation`}):e===`SHELL`?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot-quiet frizz-live-dot-quiet--shell`,"data-running-indicator":`operation-quiet`,title:YE}):w}),E=o||y?(0,L.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 pl-1.5 text-muted/40`,children:[o&&(0,L.jsx)(`span`,{"data-child-op-counter":!0,title:s,style:c===`danger`?{color:UE.fgDanger}:void 0,children:o}),o&&y&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`text-muted/25`,children:`·`}),y&&(0,L.jsx)(`span`,{title:`Working for ${y}`,children:y})]}):null,D=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:WE,children:`⤷`}),T,v&&(0,L.jsx)(`span`,{className:`petite-caps shrink-0 text-[9.5px] text-muted/45`,children:h[e]}),(0,L.jsx)(`span`,{className:`min-w-0 truncate text-muted/70 ${_?`leading-[16px]`:g?`group-hover:text-fg/80 group-hover:underline`:``}`,children:t})]}),O=_?`group flex min-w-0 items-center gap-2 pl-[26px] text-left outline-none`:`group flex min-w-0 max-w-[60%] items-center gap-1.5 overflow-hidden text-left text-[11.5px] ${g?`cursor-pointer rounded-sm outline-none transition-colors focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/60`:``}`,k=_&&b>0?{paddingLeft:26+b}:void 0,A=g?(0,L.jsx)(`button`,{type:`button`,style:k,onClick:u,onMouseDown:v?e=>e.stopPropagation():void 0,title:C,"aria-label":`${S}: ${t}`,className:O,children:D}):(0,L.jsx)(`div`,{style:k,title:C,className:O,children:D});return(0,L.jsxs)(`div`,{className:_?`flex w-full min-w-0 items-center gap-1.5 rounded-md py-0.5 pr-1.5 text-[11.5px] transition-colors hover:bg-white/[0.04]`:`flex min-w-0 items-center gap-1.5 text-[11.5px]`,style:!_&&b>0?{marginLeft:b}:void 0,"data-op-row":d?``:void 0,"data-subagent-depth":i&&i>1?i:void 0,"data-subagent-parent":l,children:[A,d&&(0,L.jsx)(`button`,{type:`button`,onClick:d,onMouseDown:e=>e.stopPropagation(),title:eD[x],"aria-label":`${tD[x]} ${nD[e]}: ${t}`,className:`shrink-0 rounded-sm p-0.5 text-muted/45 outline-none transition-colors hover:text-fg focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:(0,L.jsx)(Ch,{size:11})}),E]})}var lD=null,uD=5e3,dD=6;function fD(e,t){for(let n=e.parentElement;n&&n!==t.parentElement;n=n.parentElement){let e=getComputedStyle(n).overflowY;if(e===`auto`||e===`scroll`){let e=n.getBoundingClientRect();return{top:e.top,bottom:e.bottom}}}return{top:0,bottom:window.innerHeight}}function pD(e,t){if(e.length===0||e[e.length-1].bottom<=t.bottom)return[];let n=[];for(let r of e)if(!(r.bottom<=t.top+1)&&(r.top>=t.bottom||(r.sourceId&&n.push({sourceId:r.sourceId,screenTop:r.top}),n.length>=dD)))break;return n}function mD(e,t){if(lD=null,!e||typeof window>`u`)return;let n=[...e.querySelectorAll(`[data-transcript-source-id]`)];if(n.length===0)return;let r=fD(n[0],e),i=pD(n.map(e=>{let t=e.getBoundingClientRect();return{sourceId:e.dataset.transcriptSourceId,top:t.top,bottom:t.bottom}}),r);i.length!==0&&(lD={slug:t,candidates:i,at:performance.now()})}function hD(e){let t=lD;return!t||(lD=null,t.slug!==e||performance.now()-t.at>uD)?null:t}var gD=null;function _D(e,t){/\/full\/?$/.test(t)||(gD={slug:e,path:t})}function vD(e){return gD&&gD.slug===e?gD.path:null}var yD=`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:hover:bg-transparent disabled:hover:text-muted disabled:opacity-40`;typeof window<`u`&&window.document&&window.document.createElement;function bD(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function xD(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function SD(...e){return t=>{let n=!1,r=e.map(e=>{let r=xD(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():xD(e[t],null)}}}}function CD(...e){return I.useCallback(SD(...e),e)}function wD(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){let s=o?.[e]?.[a]||i,c=I.useContext(s);if(c)return c;if(r!==void 0)return r;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,TD(i,...t)]}function TD(...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}function ED(e){let t=I.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];PD(r)&&typeof RD==`function`&&(r=RD(r._payload)),I.Children.forEach(r,e=>{if(MD(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;PD(n)&&typeof RD==`function`&&(n=RD(n._payload)),a=kD(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=I.cloneElement(a,void 0,s):!o&&I.Children.count(r)===1&&I.isValidElement(r)&&(a=r);let c=a?jD(a):void 0,l=CD(n,c);if(!a){if(r||r===0)throw Error(o?LD(e):ID(e));return r}let u=AD(i,a.props??{});return a.type!==I.Fragment&&(u.ref=n?l:c),I.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}var DD=Symbol.for(`radix.slottable`);function OD(e){let t=e=>`child`in e?e.children(e.child):e.children;return t.displayName=`${e}.Slottable`,t.__radixId=DD,t}var kD=(e,t)=>{if(`child`in e.props){let t=e.props.child;return I.isValidElement(t)?I.cloneElement(t,void 0,e.props.children(t.props.children)):null}return I.isValidElement(t)?t:null};function AD(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function jD(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)}function MD(e){return I.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===DD}var ND=Symbol.for(`react.lazy`);function PD(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===ND&&`_payload`in e&&FD(e._payload)}function FD(e){return typeof e==`object`&&!!e&&`then`in e}var ID=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,LD=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,RD=I.use,zD=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=ED(`Primitive.${t}`),r=I.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,L.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function BD(e,t){e&&ot.flushSync(()=>e.dispatchEvent(t))}function VD(e){let t=I.useRef(e);return I.useEffect(()=>{t.current=e}),I.useMemo(()=>((...e)=>t.current?.(...e)),[])}var HD=globalThis?.document?I.useLayoutEffect:()=>{},UD=I.useEffectEvent,WD=I.useInsertionEffect;function GD(e){if(typeof UD==`function`)return UD(e);let t=I.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof WD==`function`?WD(()=>{t.current=e}):HD(()=>{t.current=e}),I.useMemo(()=>((...e)=>t.current?.(...e)),[])}var KD=`DismissableLayer`,qD=`dismissableLayer.update`,JD=`dismissableLayer.pointerDownOutside`,YD=`dismissableLayer.focusOutside`,XD,ZD=I.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),QD=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(ZD),[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(_),y=d?g.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,S=I.useRef(!1),C=nO(e=>{let t=e.target;if(!(t instanceof Node))return;let n=[...u.branches].some(e=>e.contains(t));!x||n||(a?.(e),s?.(e),e.defaultPrevented||c?.())},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:u.dismissableSurfaces}),w=rO(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=GD(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]),I.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(XD=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),iO(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=XD))}},[d,p,n,u]),I.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),iO())},[d,u]),I.useEffect(()=>{let e=()=>m({});return document.addEventListener(qD,e),()=>document.removeEventListener(qD,e)},[]),(0,L.jsx)(zD.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:bD(e.onFocusCapture,w.onFocusCapture),onBlurCapture:bD(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:bD(e.onPointerDownCapture,C.onPointerDownCapture)})});QD.displayName=KD;var $D=`DismissableLayerBranch`,eO=I.forwardRef((e,t)=>{let n=I.useContext(ZD),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})});eO.displayName=$D;function tO(){let e=I.useContext(ZD),[t,n]=I.useState(null);return I.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}function nO(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a}=t,o=VD(e),s=I.useRef(!1),c=I.useRef(!1),l=I.useRef(new Map),u=I.useRef(()=>{});return I.useEffect(()=>{function e(){c.current=!1,i.current=!1,l.current.clear()}function t(){return Array.from(l.current.values()).some(Boolean)}function d(e){if(!c.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||l.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{c.current&&u.current()},0)}function f(e){c.current&&l.current.set(e.type,!1)}let p=a=>{if(a.target&&!s.current){let s=function(){n.removeEventListener(`click`,u.current);let r=t();e(),r||aO(JD,o,d,{discrete:!0})},d={originalEvent:a};c.current=!0,i.current=r&&a.button===0,l.current.clear(),!r||a.button!==0?s():(n.removeEventListener(`click`,u.current),u.current=s,n.addEventListener(`click`,u.current,{once:!0}))}else n.removeEventListener(`click`,u.current),e();s.current=!1},m=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of m)n.addEventListener(e,d,!0),n.addEventListener(e,f);let h=window.setTimeout(()=>{n.addEventListener(`pointerdown`,p)},0);return()=>{window.clearTimeout(h),n.removeEventListener(`pointerdown`,p),n.removeEventListener(`click`,u.current);for(let e of m)n.removeEventListener(e,d,!0),n.removeEventListener(e,f)}},[n,o,r,i,a]),{onPointerDownCapture:()=>s.current=!0}}function rO(e,t=globalThis?.document){let n=VD(e),r=I.useRef(!1);return I.useEffect(()=>{let e=e=>{e.target&&!r.current&&aO(YD,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 iO(){let e=new CustomEvent(qD);document.dispatchEvent(e)}function aO(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 oO=I.useId||(()=>void 0),sO=0;function cO(e){let[t,n]=I.useState(oO());return HD(()=>{e||n(e=>e??String(sO++))},[e]),e||(t?`radix-${t}`:``)}var lO=[`top`,`right`,`bottom`,`left`],uO=Math.min,dO=Math.max,fO=Math.round,pO=Math.floor,mO=e=>({x:e,y:e}),hO={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function gO(e,t,n){return dO(e,uO(t,n))}function _O(e,t){return typeof e==`function`?e(t):e}function vO(e){return e.split(`-`)[0]}function yO(e){return e.split(`-`)[1]}function bO(e){return e===`x`?`y`:`x`}function xO(e){return e===`y`?`height`:`width`}function SO(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function CO(e){return bO(SO(e))}function wO(e,t,n){n===void 0&&(n=!1);let r=yO(e),i=CO(e),a=xO(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=NO(o)),[o,NO(o)]}function TO(e){let t=NO(e);return[EO(e),t,EO(t)]}function EO(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var DO=[`left`,`right`],OO=[`right`,`left`],kO=[`top`,`bottom`],AO=[`bottom`,`top`];function jO(e,t,n){switch(e){case`top`:case`bottom`:return n?t?OO:DO:t?DO:OO;case`left`:case`right`:return t?kO:AO;default:return[]}}function MO(e,t,n,r){let i=yO(e),a=jO(vO(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(EO)))),a}function NO(e){let t=vO(e);return hO[t]+e.slice(t.length)}function PO(e){return{top:0,right:0,bottom:0,left:0,...e}}function FO(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:PO(e)}function IO(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function LO(e,t,n){let{reference:r,floating:i}=e,a=SO(t),o=CO(t),s=xO(o),c=vO(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(yO(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function RO(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=_O(t,e),p=FO(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=IO(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=IO(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var zO=50,BO=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:RO},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=LO(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<zO&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=LO(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},VO=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=_O(e,t)||{};if(l==null)return{};let d=FO(u),f={x:n,y:r},p=CO(i),m=xO(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=uO(d[_],T),D=uO(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=gO(O,A,k),M=!c.arrow&&yO(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),HO=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=_O(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=vO(r),_=SO(o),v=vO(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[NO(o)]:TO(o)),x=p!==`none`;!d&&x&&b.push(...MO(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=wO(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==SO(t))||T.every(e=>SO(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=SO(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function UO(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function WO(e){return lO.some(t=>e[t]>=0)}var GO=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=_O(e,t);switch(i){case`referenceHidden`:{let e=UO(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:WO(e)}}}case`escaped`:{let e=UO(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:WO(e)}}}default:return{}}}}},KO=new Set([`left`,`top`]);async function qO(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=vO(n),s=yO(n),c=SO(n)===`y`,l=KO.has(o)?-1:1,u=a&&c?-1:1,d=_O(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var JO=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await qO(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},YO=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=_O(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=SO(vO(i)),p=bO(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=gO(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=gO(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},XO=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=_O(e,t),u={x:n,y:r},d=SO(i),f=bO(d),p=u[f],m=u[d],h=_O(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=KO.has(vO(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},ZO=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=_O(e,t),u=await o.detectOverflow(t,l),d=vO(i),f=yO(i),p=SO(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=uO(h-u[g],v),x=uO(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=dO(u.left,0),t=dO(u.right,0),n=dO(u.top,0),r=dO(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:dO(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:dO(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function QO(){return typeof window<`u`}function $O(e){return nk(e)?(e.nodeName||``).toLowerCase():`#document`}function ek(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function tk(e){return((nk(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function nk(e){return QO()?e instanceof Node||e instanceof ek(e).Node:!1}function rk(e){return QO()?e instanceof Element||e instanceof ek(e).Element:!1}function ik(e){return QO()?e instanceof HTMLElement||e instanceof ek(e).HTMLElement:!1}function ak(e){return!QO()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof ek(e).ShadowRoot}function ok(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=_k(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function sk(e){return/^(table|td|th)$/.test($O(e))}function ck(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var lk=/transform|translate|scale|rotate|perspective|filter/,uk=/paint|layout|strict|content/,dk=e=>!!e&&e!==`none`,fk;function pk(e){let t=rk(e)?_k(e):e;return dk(t.transform)||dk(t.translate)||dk(t.scale)||dk(t.rotate)||dk(t.perspective)||!hk()&&(dk(t.backdropFilter)||dk(t.filter))||lk.test(t.willChange||``)||uk.test(t.contain||``)}function mk(e){let t=yk(e);for(;ik(t)&&!gk(t);){if(pk(t))return t;if(ck(t))return null;t=yk(t)}return null}function hk(){return fk??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),fk}function gk(e){return/^(html|body|#document)$/.test($O(e))}function _k(e){return ek(e).getComputedStyle(e)}function vk(e){return rk(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function yk(e){if($O(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||ak(e)&&e.host||tk(e);return ak(t)?t.host:t}function bk(e){let t=yk(e);return gk(t)?e.ownerDocument?e.ownerDocument.body:e.body:ik(t)&&ok(t)?t:bk(t)}function xk(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=bk(e),i=r===e.ownerDocument?.body,a=ek(r);if(i){let e=Sk(a);return t.concat(a,a.visualViewport||[],ok(r)?r:[],e&&n?xk(e):[])}else return t.concat(r,xk(r,[],n))}function Sk(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Ck(e){let t=_k(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ik(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=fO(n)!==a||fO(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function wk(e){return rk(e)?e:e.contextElement}function Tk(e){let t=wk(e);if(!ik(t))return mO(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Ck(t),o=(a?fO(n.width):n.width)/r,s=(a?fO(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Ek=mO(0);function Dk(e){let t=ek(e);return!hk()||!t.visualViewport?Ek:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ok(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ek(e)?!1:t}function kk(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=wk(e),o=mO(1);t&&(r?rk(r)&&(o=Tk(r)):o=Tk(e));let s=Ok(a,n,r)?Dk(a):mO(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=ek(a),t=r&&rk(r)?ek(r):r,n=e,i=Sk(n);for(;i&&r&&t!==n;){let e=Tk(i),t=i.getBoundingClientRect(),r=_k(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=ek(i),i=Sk(n)}}return IO({width:u,height:d,x:c,y:l})}function Ak(e,t){let n=vk(e).scrollLeft;return t?t.left+n:kk(tk(e)).left+n}function jk(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Ak(e,n),y:n.top+t.scrollTop}}function Mk(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=tk(r),s=t?ck(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=mO(1),u=mO(0),d=ik(r);if((d||!d&&!a)&&(($O(r)!==`body`||ok(o))&&(c=vk(r)),d)){let e=kk(r);l=Tk(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?jk(o,c):mO(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Nk(e){return Array.from(e.getClientRects())}function Pk(e){let t=tk(e),n=vk(e),r=e.ownerDocument.body,i=dO(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=dO(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Ak(e),s=-n.scrollTop;return _k(r).direction===`rtl`&&(o+=dO(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Fk=25;function Ik(e,t){let n=ek(e),r=tk(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=hk();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Ak(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Fk&&(a-=o)}else l<=Fk&&(a+=l);return{width:a,height:o,x:s,y:c}}function Lk(e,t){let n=kk(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=ik(e)?Tk(e):mO(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Rk(e,t,n){let r;if(t===`viewport`)r=Ik(e,n);else if(t===`document`)r=Pk(tk(e));else if(rk(t))r=Lk(t,n);else{let n=Dk(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return IO(r)}function zk(e,t){let n=yk(e);return n===t||!rk(n)||gk(n)?!1:_k(n).position===`fixed`||zk(n,t)}function Bk(e,t){let n=t.get(e);if(n)return n;let r=xk(e,[],!1).filter(e=>rk(e)&&$O(e)!==`body`),i=null,a=_k(e).position===`fixed`,o=a?yk(e):e;for(;rk(o)&&!gk(o);){let t=_k(o),n=pk(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||ok(o)&&!n&&zk(e,o))?r=r.filter(e=>e!==o):i=t,o=yk(o)}return t.set(e,r),r}function Vk(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?ck(t)?[]:Bk(t,this._c):[].concat(n),r],o=Rk(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Rk(t,a[e],i);s=dO(n.top,s),c=uO(n.right,c),l=uO(n.bottom,l),u=dO(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Hk(e){let{width:t,height:n}=Ck(e);return{width:t,height:n}}function Uk(e,t,n){let r=ik(t),i=tk(t),a=n===`fixed`,o=kk(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=mO(0);function l(){c.x=Ak(i)}if(r||!r&&!a)if(($O(t)!==`body`||ok(i))&&(s=vk(t)),r){let e=kk(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?jk(i,s):mO(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Wk(e){return _k(e).position===`static`}function Gk(e,t){if(!ik(e)||_k(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return tk(e)===n&&(n=n.ownerDocument.body),n}function Kk(e,t){let n=ek(e);if(ck(e))return n;if(!ik(e)){let t=yk(e);for(;t&&!gk(t);){if(rk(t)&&!Wk(t))return t;t=yk(t)}return n}let r=Gk(e,t);for(;r&&sk(r)&&Wk(r);)r=Gk(r,t);return r&&gk(r)&&Wk(r)&&!pk(r)?n:r||mk(e)||n}var qk=async function(e){let t=this.getOffsetParent||Kk,n=this.getDimensions,r=await n(e.floating);return{reference:Uk(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Jk(e){return _k(e).direction===`rtl`}var Yk={convertOffsetParentRelativeRectToViewportRelativeRect:Mk,getDocumentElement:tk,getClippingRect:Vk,getOffsetParent:Kk,getElementRects:qk,getClientRects:Nk,getDimensions:Hk,getScale:Tk,isElement:rk,isRTL:Jk};function Xk(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Zk(e,t){let n=null,r,i=tk(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=pO(d),h=pO(i.clientWidth-(u+f)),g=pO(i.clientHeight-(d+p)),_=pO(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:dO(0,uO(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Xk(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function Qk(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=wk(e),u=i||a?[...l?xk(l):[],...t?xk(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Zk(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?kk(e):null;c&&g();function g(){let t=kk(e);h&&!Xk(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var $k=JO,eA=YO,tA=HO,nA=ZO,rA=GO,iA=VO,aA=XO,oA=(e,t,n)=>{let r=new Map,i={platform:Yk,...n},a={...i.platform,_c:r};return BO(e,t,{...i,platform:a})},sA=typeof document<`u`?I.useLayoutEffect:function(){};function cA(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!cA(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!cA(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function lA(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function uA(e,t){let n=lA(e);return Math.round(t*n)/n}function dA(e){let t=I.useRef(e);return sA(()=>{t.current=e}),t}function fA(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=I.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=I.useState(r);cA(f,r)||p(r);let[m,h]=I.useState(null),[g,_]=I.useState(null),v=I.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=I.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=I.useRef(null),C=I.useRef(null),w=I.useRef(u),T=c!=null,E=dA(c),D=dA(i),O=dA(l),k=I.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),oA(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!cA(w.current,t)&&(w.current=t,ot.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);sA(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=I.useRef(!1);sA(()=>(A.current=!0,()=>{A.current=!1}),[]),sA(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=I.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=I.useMemo(()=>({reference:b,floating:x}),[b,x]),N=I.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=uA(M.floating,u.x),r=uA(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...lA(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return I.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var pA=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:iA({element:r.current,padding:i}).fn(n):r?iA({element:r,padding:i}).fn(n):{}}}},mA=(e,t)=>{let n=$k(e);return{name:n.name,fn:n.fn,options:[e,t]}},hA=(e,t)=>{let n=eA(e);return{name:n.name,fn:n.fn,options:[e,t]}},gA=(e,t)=>({fn:aA(e).fn,options:[e,t]}),_A=(e,t)=>{let n=tA(e);return{name:n.name,fn:n.fn,options:[e,t]}},vA=(e,t)=>{let n=nA(e);return{name:n.name,fn:n.fn,options:[e,t]}},yA=(e,t)=>{let n=rA(e);return{name:n.name,fn:n.fn,options:[e,t]}},bA=(e,t)=>{let n=pA(e);return{name:n.name,fn:n.fn,options:[e,t]}},xA=`Arrow`,SA=I.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,L.jsx)(zD.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,L.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});SA.displayName=xA;var CA=SA;function wA(e){let[t,n]=I.useState(void 0);return HD(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var TA=`Popper`,[EA,DA]=wD(TA),[OA,kA]=EA(TA),AA=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null),[a,o]=I.useState(void 0);return(0,L.jsx)(OA,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};AA.displayName=TA;var jA=`PopperAnchor`,MA=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=kA(jA,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&&HA(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})});MA.displayName=jA;var NA=`PopperContent`,[PA,FA]=EA(NA),IA=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=kA(NA,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(BA),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}),VA({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]=HA(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)(PA,{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`}})})})});IA.displayName=NA;var LA=`PopperArrow`,RA={top:`bottom`,right:`left`,bottom:`top`,left:`right`},zA=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=FA(LA,n),a=RA[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`}})})});zA.displayName=LA;function BA(e){return e!==null}var VA=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]=HA(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 HA(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var UA=AA,WA=MA,GA=IA,KA=zA,qA=`Portal`,JA=I.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=I.useState(!1);HD(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?ot.createPortal((0,L.jsx)(zD.div,{...r,ref:t}),o):null});JA.displayName=qA;function YA(e,t){return I.useReducer((e,n)=>t[e][n]??e,e)}var XA=e=>{let{present:t,children:n}=e,r=ZA(t),i=typeof n==`function`?n({present:r.isPresent}):I.Children.only(n),a=$A(r.ref,tj(i));return typeof n==`function`||r.isPresent?I.cloneElement(i,{ref:a}):null};XA.displayName=`Presence`;function ZA(e){let[t,n]=I.useState(),r=I.useRef(null),i=I.useRef(e),a=I.useRef(`none`),[o,s]=YA(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return I.useEffect(()=>{let e=ej(r.current);a.current=o===`mounted`?e:`none`},[o]),HD(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=ej(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),HD(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=ej(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=ej(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:I.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function QA(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function $A(...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=QA(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():QA(n[e],null)}}},[])}function ej(e){return e?.animationName||`none`}function tj(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 nj=I.useInsertionEffect||HD;function rj({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=ij({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=I.useRef(e!==void 0);I.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,I.useCallback(t=>{if(s){let n=aj(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function ij({defaultProp:e,onChange:t}){let[n,r]=I.useState(e),i=I.useRef(n),a=I.useRef(t);return nj(()=>{a.current=t},[t]),I.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function aj(e){return typeof e==`function`}var oj=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),sj=`VisuallyHidden`,cj=I.forwardRef((e,t)=>(0,L.jsx)(zD.span,{...e,ref:t,style:{...oj,...e.style}}));cj.displayName=sj;var lj=cj,[uj,dj]=wD(`Tooltip`,[DA]),fj=DA(),pj=`TooltipProvider`,mj=700,hj=`tooltip.open`,[gj,_j]=uj(pj),vj=e=>{let{__scopeTooltip:t,delayDuration:n=mj,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=I.useRef(!0),s=I.useRef(!1),c=I.useRef(0);return I.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,L.jsx)(gj,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:I.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:I.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:I.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};vj.displayName=pj;var yj=`Tooltip`,[bj,xj]=uj(yj),Sj=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=_j(yj,e.__scopeTooltip),l=fj(t),[u,d]=I.useState(null),f=cO(),p=I.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=I.useRef(!1),[_,v]=rj({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(hj))):c.onClose(),a?.(e)},caller:yj}),y=I.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=I.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=I.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=I.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return I.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,L.jsx)(UA,{...l,children:(0,L.jsx)(bj,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:I.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:I.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};Sj.displayName=yj;var Cj=`TooltipTrigger`,wj=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=xj(Cj,n),a=_j(Cj,n),o=fj(n),s=CD(t,I.useRef(null),i.onTriggerChange),c=I.useRef(!1),l=I.useRef(!1),u=I.useCallback(()=>c.current=!1,[]);return I.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,L.jsx)(WA,{asChild:!0,...o,children:(0,L.jsx)(zD.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:bD(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:bD(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:bD(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:bD(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:bD(e.onBlur,i.onClose),onClick:bD(e.onClick,i.onClose)})})});wj.displayName=Cj;var Tj=`TooltipPortal`,[Ej,Dj]=uj(Tj,{forceMount:void 0}),Oj=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=xj(Tj,t);return(0,L.jsx)(Ej,{scope:t,forceMount:n,children:(0,L.jsx)(XA,{present:n||a.open,children:(0,L.jsx)(JA,{asChild:!0,container:i,children:r})})})};Oj.displayName=Tj;var kj=`TooltipContent`,Aj=I.forwardRef((e,t)=>{let n=Dj(kj,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=xj(kj,e.__scopeTooltip);return(0,L.jsx)(XA,{present:r||o.open,children:o.disableHoverableContent?(0,L.jsx)(Fj,{side:i,...a,ref:t}):(0,L.jsx)(jj,{side:i,...a,ref:t})})}),jj=I.forwardRef((e,t)=>{let n=xj(kj,e.__scopeTooltip),r=_j(kj,e.__scopeTooltip),i=I.useRef(null),a=CD(t,i),[o,s]=I.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=I.useCallback(()=>{s(null),d(!1)},[d]),p=I.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=zj(r,Rj(r,n.getBoundingClientRect())),a=Bj(t.getBoundingClientRect()),o=Hj([...i,...a]);s(o),d(!0)},[d]);return I.useEffect(()=>()=>f(),[f]),I.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),I.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Vj(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,L.jsx)(Fj,{...e,ref:a})}),[Mj,Nj]=uj(yj,{isInside:!1}),Pj=OD(`TooltipContent`),Fj=I.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=xj(kj,n),l=fj(n),{onClose:u}=c;return I.useEffect(()=>(document.addEventListener(hj,u),()=>document.removeEventListener(hj,u)),[u]),I.useEffect(()=>{if(c.trigger){let e=e=>{e.target instanceof Node&&e.target.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,L.jsx)(QD,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,L.jsxs)(GA,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,L.jsx)(Pj,{children:r}),(0,L.jsx)(Mj,{scope:n,isInside:!0,children:(0,L.jsx)(lj,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Aj.displayName=kj;var Ij=`TooltipArrow`,Lj=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=fj(n);return Nj(Ij,n).isInside?null:(0,L.jsx)(KA,{...i,...r,ref:t})});Lj.displayName=Ij;function Rj(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function zj(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Bj(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Vj(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Hj(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Uj(t)}function Uj(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Wj=vj,Gj=Sj,Kj=wj,qj=Oj,Jj=Aj,Yj=Lj,Xj=`isolate bg-elevated opacity-100 border border-border shadow-2xl shadow-black/40`,Zj=`z-[110]`,Qj=`${Zj} ${Xj}`,$j=`z-[250]`,eM=`z-[250]`;function tM({children:e}){return(0,L.jsx)(Wj,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!0,children:e})}function nM({label:e,children:t,side:n=`top`,clickable:r=!1,multiline:i=!1,disabled:a=!1}){let o=i?`whitespace-pre-line`:`whitespace-normal`,[s,c]=(0,I.useState)(!1),l=(0,I.useId)(),u=r&&(0,I.isValidElement)(t)?t:null,d=u?(0,I.cloneElement)(u,{"aria-describedby":l}):t,f=(0,I.useRef)(null);if(u){let t=f.current?.getBoundingClientRect(),n=t?Math.min(Math.max(12,t.right+8),window.innerWidth-364):12,r=t?Math.min(Math.max(12,t.top-6),window.innerHeight-96):12;return(0,L.jsxs)(`span`,{ref:f,className:`inline-flex`,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocus:()=>c(!0),onBlur:()=>c(!1),onClick:()=>c(e=>!e),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),c(!1))},children:[d,s&&(0,ot.createPortal)((0,L.jsx)(`span`,{id:l,role:`tooltip`,className:`z-[250] max-w-[min(22rem,calc(100vw-1.5rem))] rounded-md border border-border bg-elevated px-3 py-2 text-[11px] leading-relaxed text-fg shadow-md shadow-black/40 break-words ${o}`,style:{position:`fixed`,left:n,top:r},children:e}),document.body)]})}return(0,L.jsxs)(Gj,{open:s&&!a,onOpenChange:c,children:[(0,L.jsx)(Kj,{asChild:!0,children:d}),(0,L.jsx)(qj,{children:(0,L.jsxs)(Jj,{id:l,side:n,sideOffset:5,collisionPadding:12,className:`${eM} max-w-[min(22rem,calc(100vw-1.5rem))] select-none rounded-md border border-border bg-elevated px-3 py-2 text-[11px] leading-relaxed text-fg shadow-md shadow-black/40 break-words ${o}`,children:[e,(0,L.jsx)(Yj,{className:`fill-elevated`})]})})]})}function rM({slug:e,size:t=14,className:n,label:r=`Open fullscreen`}){let i=Ld(e);function a(t){if(t.stopPropagation(),!zd(t))return;t.preventDefault();let n=!Xp(),r=t.currentTarget.closest(`[data-vt-chat]`);mD(r,e),typeof location<`u`&&_D(e,location.pathname),n&&r&&(r.style.viewTransitionName=`thread-chat`),bw(i,{viewTransition:n})}return(0,L.jsx)(nM,{label:r,children:(0,L.jsx)(`a`,{href:i,"aria-label":r,"data-expand-thread":e,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:a,className:n??`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:hover:bg-transparent disabled:hover:text-muted disabled:opacity-40`,children:(0,L.jsx)(Zm,{size:t})})})}function iM(e,t,n=`AGENT`){let r=n===`SHELL`?`Background shell`:`Sub-agent`;Y.stopBackgroundOp({slug:e,id:t}).then(({stopped:e,note:t,descendantsStopped:i})=>{if(e){if(t)return Z(`${r} stopped. ${t}`,{duration:7e3});if(n===`SHELL`)return Z(`Background shell stopped — the worker was told`);Z(i>0?`Sub-agent and ${i} descendant${i===1?``:`s`} stopped`:`Sub-agent stopped`)}}).catch(e=>{Z(`Couldn’t stop: ${(e instanceof Error?e.message:String(e)).slice(0,100)}`,{duration:7e3})})}function aM(e,t,n=`AGENT`){if(!t.id||!Xc(t)||t.state===`running`&&!t.stoppable)return;let r=t.id;return()=>iM(e,r,n)}function oM(e){let t=e+`CollectionProvider`,[n,r]=wD(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=I.useRef(null),a=I.useRef(new Map).current;return(0,L.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=ED(s),l=I.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=CD(t,a(s,n).collectionRef);return(0,L.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=ED(u),p=I.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=I.useRef(null),s=CD(t,o),c=a(u,n);return I.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,L.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return I.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var sM=I.createContext(void 0);function cM(e){let t=I.useContext(sM);return e||t||`ltr`}var lM=0,uM=null;function dM(){I.useEffect(()=>{uM||={start:fM(),end:fM()};let{start:e,end:t}=uM;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),lM++,()=>{lM===1&&(uM?.start.remove(),uM?.end.remove(),uM=null),lM=Math.max(0,lM-1)}},[])}function fM(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var pM=`focusScope.autoFocusOnMount`,mM=`focusScope.autoFocusOnUnmount`,hM={bubbles:!1,cancelable:!0},gM=`FocusScope`,_M=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:wM(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||wM(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&wM(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){TM.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(pM,hM);s.addEventListener(pM,l),s.dispatchEvent(t),t.defaultPrevented||(vM(OM(bM(s)),{select:!0}),document.activeElement===e&&wM(s))}return()=>{s.removeEventListener(pM,l),setTimeout(()=>{let t=new CustomEvent(mM,hM);s.addEventListener(mM,u),s.dispatchEvent(t),t.defaultPrevented||wM(e??document.body,{select:!0}),s.removeEventListener(mM,u),TM.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]=yM(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&wM(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&wM(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,L.jsx)(zD.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});_M.displayName=gM;function vM(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(wM(r,{select:t}),document.activeElement!==n)return}function yM(e){let t=bM(e);return[xM(t,e),xM(t.reverse(),e)]}function bM(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 xM(e,t){for(let n of e)if(!SM(n,{upTo:t}))return n}function SM(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 CM(e){return e instanceof HTMLInputElement&&`select`in e}function wM(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&CM(e)&&t&&e.select()}}var TM=EM();function EM(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=DM(e,t),e.unshift(t)},remove(t){e=DM(e,t),e[0]?.resume()}}}function DM(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function OM(e){return e.filter(e=>e.tagName!==`A`)}var kM=`rovingFocusGroup.onEntryFocus`,AM={bubbles:!1,cancelable:!0},jM=`RovingFocusGroup`,[MM,NM,PM]=oM(jM),[FM,IM]=wD(jM,[PM]),[LM,RM]=FM(jM),zM=I.forwardRef((e,t)=>(0,L.jsx)(MM.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,L.jsx)(MM.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,L.jsx)(BM,{...e,ref:t})})}));zM.displayName=jM;var BM=I.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=I.useRef(null),p=CD(t,f),m=cM(a),[h,g]=rj({prop:o,defaultProp:s??null,onChange:c,caller:jM}),[_,v]=I.useState(!1),y=VD(l),b=NM(n),x=I.useRef(!1),[S,C]=I.useState(0);return I.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(kM,y),()=>e.removeEventListener(kM,y)},[y]),(0,L.jsx)(LM,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:I.useCallback(e=>g(e),[g]),onItemShiftTab:I.useCallback(()=>v(!0),[]),onFocusableItemAdd:I.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:I.useCallback(()=>C(e=>e-1),[]),children:(0,L.jsx)(zD.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:bD(e.onMouseDown,()=>{x.current=!0}),onFocus:bD(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(kM,AM);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);KM([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:bD(e.onBlur,()=>v(!1))})})}),VM=`RovingFocusGroupItem`,HM=I.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=cO(),l=a||c,u=RM(VM,n),d=u.currentTabStopId===l,f=NM(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return I.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,L.jsx)(MM.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,L.jsx)(zD.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:bD(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:bD(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:bD(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=GM(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?qM(n,r+1):n.slice(r+1)}setTimeout(()=>KM(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});HM.displayName=VM;var UM={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function WM(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function GM(e,t,n){let r=WM(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return UM[r]}function KM(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function qM(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var JM=zM,YM=HM,XM=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},ZM=new WeakMap,QM=new WeakMap,$M={},eN=0,tN=function(e){return e&&(e.host||tN(e.parentNode))},nN=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=tN(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},rN=function(e,t,n,r){var i=nN(t,Array.isArray(e)?e:[e]);$M[n]||($M[n]=new WeakMap);var a=$M[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=(ZM.get(e)||0)+1,l=(a.get(e)||0)+1;ZM.set(e,c),a.set(e,l),o.push(e),c===1&&i&&QM.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),eN++,function(){o.forEach(function(e){var t=ZM.get(e)-1,i=a.get(e)-1;ZM.set(e,t),a.set(e,i),t||(QM.has(e)||e.removeAttribute(r),QM.delete(e)),i||e.removeAttribute(n)}),eN--,eN||(ZM=new WeakMap,ZM=new WeakMap,QM=new WeakMap,$M={})}},iN=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||XM(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),rN(r,i,n,`aria-hidden`)):function(){return null}},aN=function(){return aN=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},aN.apply(this,arguments)};function oN(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function sN(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var cN=`right-scroll-bar-position`,lN=`width-before-scroll-bar`,uN=`with-scroll-bars-hidden`,dN=`--removed-body-scroll-bar-size`;function fN(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function pN(e,t){var n=(0,I.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var mN=typeof window<`u`?I.useLayoutEffect:I.useEffect,hN=new WeakMap;function gN(e,t){var n=pN(t||null,function(t){return e.forEach(function(e){return fN(e,t)})});return mN(function(){var t=hN.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||fN(e,null)}),i.forEach(function(e){r.has(e)||fN(e,a)})}hN.set(n,e)},[e]),n}function _N(e){return e}function vN(e,t){t===void 0&&(t=_N);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function yN(e){e===void 0&&(e={});var t=vN(null);return t.options=aN({async:!0,ssr:!1},e),t}var bN=function(e){var t=e.sideCar,n=oN(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return I.createElement(r,aN({},n))};bN.isSideCarExport=!0;function xN(e,t){return e.useMedium(t),bN}var SN=yN(),CN=function(){},wN=I.forwardRef(function(e,t){var n=I.useRef(null),r=I.useState({onScrollCapture:CN,onWheelCapture:CN,onTouchMoveCapture:CN}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=oN(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=gN([n,t]),C=aN(aN({},b),i);return I.createElement(I.Fragment,null,u&&I.createElement(x,{sideCar:SN,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?I.cloneElement(I.Children.only(s),aN(aN({},C),{ref:S})):I.createElement(v,aN({},C,{className:c,ref:S}),s))});wN.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},wN.classNames={fullWidth:lN,zeroRight:cN};var TN,EN=function(){if(TN)return TN;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function DN(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=EN();return t&&e.setAttribute(`nonce`,t),e}function ON(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function kN(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var AN=function(){var e=0,t=null;return{add:function(n){e==0&&(t=DN())&&(ON(t,n),kN(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},jN=function(){var e=AN();return function(t,n){I.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},MN=function(){var e=jN();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},NN={left:0,top:0,right:0,gap:0},PN=function(e){return parseInt(e||``,10)||0},FN=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[PN(n),PN(r),PN(i)]},IN=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return NN;var t=FN(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},LN=MN(),RN=`data-scroll-locked`,zN=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
140
- .${uN} {
139
+ `).find(e=>e.trim())?.trim().replace(/\s+/g,` `)||void 0}function NE(e,t){if(e.name===`Interrupt process`||e.status===`cancelled`||e.backgroundState!==`background`)return;let n=new Set([ME(e.desc),ME(e.detail),ME(e.command)].filter(e=>!!e));if(n.size===0)return;let r=t.filter(e=>n.has(ME(e.label)??``));return r.some(e=>e.state===`running`)?`running`:r.some(e=>e.state===`stale`)?`stale`:void 0}function PE(e){if(e<1)return`<1ms`;if(e<1e3)return`${Math.round(e)}ms`;if(e<6e4)return`${e<1e4?(e/1e3).toFixed(1):Math.round(e/1e3)}s`;let t=Math.floor(e/6e4);if(t>=60)return t%60?`${Math.floor(t/60)}h ${t%60}m`:`${Math.floor(t/60)}h`;let n=Math.round(e%6e4/1e3);return n?`${t}m ${n}s`:`${t}m`}function FE(e){if(e<1)return`just now`;if(e<60)return`${e}m`;let t=Math.floor(e/60);if(t<24)return e%60?`${t}h ${e%60}m`:`${t}h`;let n=Math.floor(t/24);return t%24?`${n}d ${t%24}h`:`${n}d`}function IE(e){if(!Number.isFinite(e)||e<0)return``;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60),i=n%60;return i?`${r}h ${i}m`:`${r}h`}function LE(e){if(!Number.isFinite(e)||e<0)return``;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);if(r<24)return n%60?`${r}h ${n%60}m`:`${r}h`;let i=Math.floor(r/24);if(i<7)return r%24?`${i}d ${r%24}h`:`${i}d`;let a=Math.floor(i/7);return i%7?`${a}w ${i%7}d`:`${a}w`}function RE(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?IE(t-n):``}function zE(e){if(!Number.isFinite(e)||e<0)return``;let t=Math.floor(e/6e4);return t<1?`<1m`:FE(t)}function BE(e){if(!Number.isFinite(e)||e<=0)return`0s`;let t=e=>String(e).padStart(2,`0`),n=Math.ceil(e/1e3);if(n<60)return`${n}s`;let r=Math.floor(n/60);if(r<60)return`${r}m ${t(n%60)}s`;let i=Math.floor(r/60);if(i<24)return`${i}h ${t(r%60)}m`;let a=Math.floor(i/24);if(a<7)return i%24?`${a}d ${i%24}h`:`${a}d`;let o=Math.floor(a/7);return a%7?`${o}w ${a%7}d`:`${o}w`}function VE(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?FE(Math.floor((t-n)/6e4)):``}function HE(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);if(!Number.isFinite(n))return``;let r=Math.floor((t-n)/6e4);return r<1?`just now`:`${FE(r)} ago`}var UE={fgSuccess:`#3fb950`,bgSuccessEmphasis:`#238636`,fgDanger:`#f85149`,bgDangerEmphasis:`#da3633`,fgDone:`#ab7df8`,bgDoneEmphasis:`#8957e5`,fgAttention:`#d29922`,fgNeutral:`#9198a1`,bgNeutralEmphasis:`#656c76`},WE=`shrink-0 text-[11px] leading-none text-muted/45`,GE=`frizz-kind-tag petite-caps shrink-0 text-[9.5px] text-muted/45`,KE=`flex w-[9px] shrink-0 justify-center`,qE=`block h-1.5 w-1.5 rounded-full bg-muted/30`,JE=`stale — no recent output`,YE=`block h-1.5 w-1.5 rounded-full border border-muted/45`,XE=`rested — it stopped, but the work it launched is still running`,ZE=`running — no recent output`,QE={AGENT:`Open sub-agent transcript`,SHELL:`Open background shell output`,GITHUB:`Open this pull request on GitHub`};function $E(e){if(!(typeof e!=`number`||!Number.isFinite(e)||e<0))return e===1?`1 line`:`${tD(e)??`0`} lines`}function eD(e){if(e){if(e.state!==`open`)return e.state;if(e.failed>0)return`${e.failed} failed`;if(e.gated>0)return`${e.gated} held`;if(e.running>0)return`${e.running} running`;if(e.passed>0)return`${e.passed} green`}}function tD(e){if(typeof e!=`number`||!Number.isFinite(e)||e<=0)return;let t=(e,t)=>`${e<100?e.toFixed(1).replace(/\.0$/,``):Math.round(e)}${t}`;return e<1e3?String(Math.round(e)):e<1e6?t(e/1e3,`k`):t(e/1e6,`M`)}var nD={running:`Stop — end this operation and everything it spawned, then clear the row`,settled:`Clear — stop tracking this finished operation`},rD={running:`Stop`,settled:`Clear`},iD={AGENT:`sub-agent`,SHELL:`background shell`,GITHUB:`PR watcher`};function aD(e,t){let n=new Map;for(let t of e){if(!t.parentId)continue;let e=n.get(t.parentId);e?e.push(t):n.set(t.parentId,[t])}let r=[],i=new Set([t]),a=(e,t)=>{for(let o of n.get(e)??[])o.id&&i.has(o.id)||(o.id&&i.add(o.id),r.push({...o,displayDepth:t}),o.id&&a(o.id,t+1))};return a(t,1),r}var oD=e=>e.state===`running`||e.state===`stale`||e.state===`rested`;function sD(e,t){return t===`card`?e.filter(oD):t===`rail`?e.filter(e=>!!e.id&&oD(e)):e}var cD=e=>{let t=e.launchId??e.id;return[...t?[`id:${t}`]:[],...e.command?[`cmd:${e.command}`]:[],`launch:${e.label}\u0000${e.startedAt??``}`]};function lD(e,t){let n=[...e],r=new Set(n.flatMap(cD));for(let e of t)cD(e).some(e=>r.has(e))||n.push(e);return n}function uD({kind:e,label:t,state:n,density:r,depth:i,startedAt:a,counter:o,counterTitle:s,counterTone:c,parentSlug:l,onOpen:u,onDismiss:d,title:f}){let p=DE(n),m={AGENT:`frizz-live-dot--agent`,SHELL:`frizz-live-dot--shell`,GITHUB:`frizz-live-dot--github`},h={AGENT:`AGENT`,SHELL:`SHELL`,GITHUB:`WATCH`},g=!!u,_=r===`rail`,v=r===`sheet`,y=RE(a,TE()),b=Math.min(Math.max((i??1)-1,0),4)*13,x=p?`running`:`settled`,S=QE[e],C=f??(g?S:void 0),w=n===`rested`?(0,L.jsx)(`span`,{className:YE,title:XE}):(0,L.jsx)(`span`,{className:qE,title:JE}),T=_?(0,L.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:p?(0,L.jsx)(EE,{size:12}):w}):(0,L.jsx)(`span`,{className:`frizz-op-dot-slot ${KE}`,children:p?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot ${m[e]}`,"data-running-indicator":r===`card`?`queue-subagent`:`operation`}):e===`SHELL`?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot-quiet frizz-live-dot-quiet--shell`,"data-running-indicator":`operation-quiet`,title:ZE}):w}),E=o||y?(0,L.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 pl-1.5 text-muted/40`,children:[o&&(0,L.jsx)(`span`,{"data-child-op-counter":!0,title:s,style:c===`danger`?{color:UE.fgDanger}:void 0,children:o}),o&&y&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`text-muted/25`,children:`·`}),y&&(0,L.jsx)(`span`,{title:`Working for ${y}`,children:y})]}):null,D=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:WE,children:`⤷`}),T,v&&(0,L.jsx)(`span`,{className:`frizz-kind-tag petite-caps shrink-0 text-[9.5px] text-muted/45`,children:h[e]}),(0,L.jsx)(`span`,{className:`min-w-0 truncate text-muted/70 ${_?`leading-[16px]`:g?`group-hover:text-fg/80 group-hover:underline`:``}`,children:t})]}),O=_?`group flex min-w-0 items-center gap-2 pl-[26px] text-left outline-none`:`group flex min-w-0 max-w-[60%] items-center gap-1.5 overflow-hidden text-left text-[11.5px] ${g?`cursor-pointer rounded-sm outline-none transition-colors focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/60`:``}`,k=_&&b>0?{paddingLeft:26+b}:void 0,A=g?(0,L.jsx)(`button`,{type:`button`,style:k,onClick:u,onMouseDown:v?e=>e.stopPropagation():void 0,title:C,"aria-label":`${S}: ${t}`,className:O,children:D}):(0,L.jsx)(`div`,{style:k,title:C,className:O,children:D});return(0,L.jsxs)(`div`,{className:_?`flex w-full min-w-0 items-center gap-1.5 rounded-md py-0.5 pr-1.5 text-[11.5px] transition-colors hover:bg-white/[0.04]`:`flex min-w-0 items-center gap-1.5 text-[11.5px]`,style:!_&&b>0?{marginLeft:b}:void 0,"data-op-row":d?``:void 0,"data-subagent-depth":i&&i>1?i:void 0,"data-subagent-parent":l,children:[A,d&&(0,L.jsx)(`button`,{type:`button`,onClick:d,onMouseDown:e=>e.stopPropagation(),title:nD[x],"aria-label":`${rD[x]} ${iD[e]}: ${t}`,className:`shrink-0 rounded-sm p-0.5 text-muted/45 outline-none transition-colors hover:text-fg focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:(0,L.jsx)(Ch,{size:11})}),E]})}var dD=null,fD=5e3,pD=6;function mD(e,t){for(let n=e.parentElement;n&&n!==t.parentElement;n=n.parentElement){let e=getComputedStyle(n).overflowY;if(e===`auto`||e===`scroll`){let e=n.getBoundingClientRect();return{top:e.top,bottom:e.bottom}}}return{top:0,bottom:window.innerHeight}}function hD(e,t){if(e.length===0||e[e.length-1].bottom<=t.bottom)return[];let n=[];for(let r of e)if(!(r.bottom<=t.top+1)&&(r.top>=t.bottom||(r.sourceId&&n.push({sourceId:r.sourceId,screenTop:r.top}),n.length>=pD)))break;return n}function gD(e,t){if(dD=null,!e||typeof window>`u`)return;let n=[...e.querySelectorAll(`[data-transcript-source-id]`)];if(n.length===0)return;let r=mD(n[0],e),i=hD(n.map(e=>{let t=e.getBoundingClientRect();return{sourceId:e.dataset.transcriptSourceId,top:t.top,bottom:t.bottom}}),r);i.length!==0&&(dD={slug:t,candidates:i,at:performance.now()})}function _D(e){let t=dD;return!t||(dD=null,t.slug!==e||performance.now()-t.at>fD)?null:t}var vD=null;function yD(e,t){/\/full\/?$/.test(t)||(vD={slug:e,path:t})}function bD(e){return vD&&vD.slug===e?vD.path:null}var xD=`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:hover:bg-transparent disabled:hover:text-muted disabled:opacity-40`;typeof window<`u`&&window.document&&window.document.createElement;function SD(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function CD(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function wD(...e){return t=>{let n=!1,r=e.map(e=>{let r=CD(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():CD(e[t],null)}}}}function TD(...e){return I.useCallback(wD(...e),e)}function ED(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){let s=o?.[e]?.[a]||i,c=I.useContext(s);if(c)return c;if(r!==void 0)return r;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,DD(i,...t)]}function DD(...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}function OD(e){let t=I.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];ID(r)&&typeof BD==`function`&&(r=BD(r._payload)),I.Children.forEach(r,e=>{if(PD(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;ID(n)&&typeof BD==`function`&&(n=BD(n._payload)),a=jD(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=I.cloneElement(a,void 0,s):!o&&I.Children.count(r)===1&&I.isValidElement(r)&&(a=r);let c=a?ND(a):void 0,l=TD(n,c);if(!a){if(r||r===0)throw Error(o?zD(e):RD(e));return r}let u=MD(i,a.props??{});return a.type!==I.Fragment&&(u.ref=n?l:c),I.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}var kD=Symbol.for(`radix.slottable`);function AD(e){let t=e=>`child`in e?e.children(e.child):e.children;return t.displayName=`${e}.Slottable`,t.__radixId=kD,t}var jD=(e,t)=>{if(`child`in e.props){let t=e.props.child;return I.isValidElement(t)?I.cloneElement(t,void 0,e.props.children(t.props.children)):null}return I.isValidElement(t)?t:null};function MD(e,t){let n={...t};for(let r in t){let i=e[r],a=t[r];/^on[A-Z]/.test(r)?i&&a?n[r]=(...e)=>{let t=a(...e);return i(...e),t}:i&&(n[r]=i):r===`style`?n[r]={...i,...a}:r===`className`&&(n[r]=[i,a].filter(Boolean).join(` `))}return{...e,...n}}function ND(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)}function PD(e){return I.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===kD}var FD=Symbol.for(`react.lazy`);function ID(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===FD&&`_payload`in e&&LD(e._payload)}function LD(e){return typeof e==`object`&&!!e&&`then`in e}var RD=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,zD=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,BD=I.use,VD=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=OD(`Primitive.${t}`),r=I.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,L.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function HD(e,t){e&&ot.flushSync(()=>e.dispatchEvent(t))}function UD(e){let t=I.useRef(e);return I.useEffect(()=>{t.current=e}),I.useMemo(()=>((...e)=>t.current?.(...e)),[])}var WD=globalThis?.document?I.useLayoutEffect:()=>{},GD=I.useEffectEvent,KD=I.useInsertionEffect;function qD(e){if(typeof GD==`function`)return GD(e);let t=I.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof KD==`function`?KD(()=>{t.current=e}):WD(()=>{t.current=e}),I.useMemo(()=>((...e)=>t.current?.(...e)),[])}var JD=`DismissableLayer`,YD=`dismissableLayer.update`,XD=`dismissableLayer.pointerDownOutside`,ZD=`dismissableLayer.focusOutside`,QD,$D=I.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),eO=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($D),[d,f]=I.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=I.useState({}),h=TD(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=g.indexOf(_),y=d?g.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,S=I.useRef(!1),C=iO(e=>{let t=e.target;if(!(t instanceof Node))return;let n=[...u.branches].some(e=>e.contains(t));!x||n||(a?.(e),s?.(e),e.defaultPrevented||c?.())},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:u.dismissableSurfaces}),w=aO(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=qD(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]),I.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(QD=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),oO(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=QD))}},[d,p,n,u]),I.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),oO())},[d,u]),I.useEffect(()=>{let e=()=>m({});return document.addEventListener(YD,e),()=>document.removeEventListener(YD,e)},[]),(0,L.jsx)(VD.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:SD(e.onFocusCapture,w.onFocusCapture),onBlurCapture:SD(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:SD(e.onPointerDownCapture,C.onPointerDownCapture)})});eO.displayName=JD;var tO=`DismissableLayerBranch`,nO=I.forwardRef((e,t)=>{let n=I.useContext($D),r=I.useRef(null),i=TD(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)(VD.div,{...e,ref:i})});nO.displayName=tO;function rO(){let e=I.useContext($D),[t,n]=I.useState(null);return I.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}function iO(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a}=t,o=UD(e),s=I.useRef(!1),c=I.useRef(!1),l=I.useRef(new Map),u=I.useRef(()=>{});return I.useEffect(()=>{function e(){c.current=!1,i.current=!1,l.current.clear()}function t(){return Array.from(l.current.values()).some(Boolean)}function d(e){if(!c.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||l.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{c.current&&u.current()},0)}function f(e){c.current&&l.current.set(e.type,!1)}let p=a=>{if(a.target&&!s.current){let s=function(){n.removeEventListener(`click`,u.current);let r=t();e(),r||sO(XD,o,d,{discrete:!0})},d={originalEvent:a};c.current=!0,i.current=r&&a.button===0,l.current.clear(),!r||a.button!==0?s():(n.removeEventListener(`click`,u.current),u.current=s,n.addEventListener(`click`,u.current,{once:!0}))}else n.removeEventListener(`click`,u.current),e();s.current=!1},m=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of m)n.addEventListener(e,d,!0),n.addEventListener(e,f);let h=window.setTimeout(()=>{n.addEventListener(`pointerdown`,p)},0);return()=>{window.clearTimeout(h),n.removeEventListener(`pointerdown`,p),n.removeEventListener(`click`,u.current);for(let e of m)n.removeEventListener(e,d,!0),n.removeEventListener(e,f)}},[n,o,r,i,a]),{onPointerDownCapture:()=>s.current=!0}}function aO(e,t=globalThis?.document){let n=UD(e),r=I.useRef(!1);return I.useEffect(()=>{let e=e=>{e.target&&!r.current&&sO(ZD,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 oO(){let e=new CustomEvent(YD);document.dispatchEvent(e)}function sO(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?HD(i,a):i.dispatchEvent(a)}var cO=I.useId||(()=>void 0),lO=0;function uO(e){let[t,n]=I.useState(cO());return WD(()=>{e||n(e=>e??String(lO++))},[e]),e||(t?`radix-${t}`:``)}var dO=[`top`,`right`,`bottom`,`left`],fO=Math.min,pO=Math.max,mO=Math.round,hO=Math.floor,gO=e=>({x:e,y:e}),_O={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function vO(e,t,n){return pO(e,fO(t,n))}function yO(e,t){return typeof e==`function`?e(t):e}function bO(e){return e.split(`-`)[0]}function xO(e){return e.split(`-`)[1]}function SO(e){return e===`x`?`y`:`x`}function CO(e){return e===`y`?`height`:`width`}function wO(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function TO(e){return SO(wO(e))}function EO(e,t,n){n===void 0&&(n=!1);let r=xO(e),i=TO(e),a=CO(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=FO(o)),[o,FO(o)]}function DO(e){let t=FO(e);return[OO(e),t,OO(t)]}function OO(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var kO=[`left`,`right`],AO=[`right`,`left`],jO=[`top`,`bottom`],MO=[`bottom`,`top`];function NO(e,t,n){switch(e){case`top`:case`bottom`:return n?t?AO:kO:t?kO:AO;case`left`:case`right`:return t?jO:MO;default:return[]}}function PO(e,t,n,r){let i=xO(e),a=NO(bO(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(OO)))),a}function FO(e){let t=bO(e);return _O[t]+e.slice(t.length)}function IO(e){return{top:0,right:0,bottom:0,left:0,...e}}function LO(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:IO(e)}function RO(e){let{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function zO(e,t,n){let{reference:r,floating:i}=e,a=wO(t),o=TO(t),s=CO(o),c=bO(t),l=a===`y`,u=r.x+r.width/2-i.width/2,d=r.y+r.height/2-i.height/2,f=r[s]/2-i[s]/2,p;switch(c){case`top`:p={x:u,y:r.y-i.height};break;case`bottom`:p={x:u,y:r.y+r.height};break;case`right`:p={x:r.x+r.width,y:d};break;case`left`:p={x:r.x-i.width,y:d};break;default:p={x:r.x,y:r.y}}switch(xO(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function BO(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=yO(t,e),p=LO(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=RO(await i.getClippingRect({element:await(i.isElement==null?void 0:i.isElement(m))??!0?m:m.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(o.floating)),boundary:c,rootBoundary:l,strategy:s})),g=u===`floating`?{x:n,y:r,width:a.floating.width,height:a.floating.height}:a.reference,_=await(i.getOffsetParent==null?void 0:i.getOffsetParent(o.floating)),v=await(i.isElement==null?void 0:i.isElement(_))&&await(i.getScale==null?void 0:i.getScale(_))||{x:1,y:1},y=RO(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:o,rect:g,offsetParent:_,strategy:s}):g);return{top:(h.top-y.top+p.top)/v.y,bottom:(y.bottom-h.bottom+p.bottom)/v.y,left:(h.left-y.left+p.left)/v.x,right:(y.right-h.right+p.right)/v.x}}var VO=50,HO=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:BO},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=zO(l,r,c),f=r,p=0,m={};for(let n=0;n<a.length;n++){let h=a[n];if(!h)continue;let{name:g,fn:_}=h,{x:v,y,data:b,reset:x}=await _({x:u,y:d,initialPlacement:r,placement:f,strategy:i,middlewareData:m,rects:l,platform:s,elements:{reference:e,floating:t}});u=v??u,d=y??d,m[g]={...m[g],...b},x&&p<VO&&(p++,typeof x==`object`&&(x.placement&&(f=x.placement),x.rects&&(l=x.rects===!0?await o.getElementRects({reference:e,floating:t,strategy:i}):x.rects),{x:u,y:d}=zO(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},UO=e=>({name:`arrow`,options:e,async fn(t){let{x:n,y:r,placement:i,rects:a,platform:o,elements:s,middlewareData:c}=t,{element:l,padding:u=0}=yO(e,t)||{};if(l==null)return{};let d=LO(u),f={x:n,y:r},p=TO(i),m=CO(p),h=await o.getDimensions(l),g=p===`y`,_=g?`top`:`left`,v=g?`bottom`:`right`,y=g?`clientHeight`:`clientWidth`,b=a.reference[m]+a.reference[p]-f[p]-a.floating[m],x=f[p]-a.reference[p],S=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l)),C=S?S[y]:0;(!C||!await(o.isElement==null?void 0:o.isElement(S)))&&(C=s.floating[y]||a.floating[m]);let w=b/2-x/2,T=C/2-h[m]/2-1,E=fO(d[_],T),D=fO(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=vO(O,A,k),M=!c.arrow&&xO(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),WO=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=yO(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=bO(r),_=wO(o),v=bO(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[FO(o)]:DO(o)),x=p!==`none`;!d&&x&&b.push(...PO(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=EO(r,a,y);w.push(C[e[0]],C[e[1]])}if(T=[...T,{placement:r,overflows:w}],!w.every(e=>e<=0)){let e=(i.flip?.index||0)+1,t=S[e];if(t&&(!(u===`alignment`&&_!==wO(t))||T.every(e=>wO(e.placement)===_?e.overflows[0]>0:!0)))return{data:{index:e,overflows:T},reset:{placement:t}};let n=T.filter(e=>e.overflows[0]<=0).sort((e,t)=>e.overflows[1]-t.overflows[1])[0]?.placement;if(!n)switch(f){case`bestFit`:{let e=T.filter(e=>{if(x){let t=wO(e.placement);return t===_||t===`y`}return!0}).map(e=>[e.placement,e.overflows.filter(e=>e>0).reduce((e,t)=>e+t,0)]).sort((e,t)=>e[1]-t[1])[0]?.[0];e&&(n=e);break}case`initialPlacement`:n=o;break}if(r!==n)return{reset:{placement:n}}}return{}}}};function GO(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function KO(e){return dO.some(t=>e[t]>=0)}var qO=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=yO(e,t);switch(i){case`referenceHidden`:{let e=GO(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:KO(e)}}}case`escaped`:{let e=GO(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:KO(e)}}}default:return{}}}}},JO=new Set([`left`,`top`]);async function YO(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=bO(n),s=xO(n),c=wO(n)===`y`,l=JO.has(o)?-1:1,u=a&&c?-1:1,d=yO(t,e),{mainAxis:f,crossAxis:p,alignmentAxis:m}=typeof d==`number`?{mainAxis:d,crossAxis:0,alignmentAxis:null}:{mainAxis:d.mainAxis||0,crossAxis:d.crossAxis||0,alignmentAxis:d.alignmentAxis};return s&&typeof m==`number`&&(p=s===`end`?m*-1:m),c?{x:p*u,y:f*l}:{x:f*l,y:p*u}}var XO=function(e){return e===void 0&&(e=0),{name:`offset`,options:e,async fn(t){var n;let{x:r,y:i,placement:a,middlewareData:o}=t,s=await YO(t,e);return a===o.offset?.placement&&(n=o.arrow)!=null&&n.alignmentOffset?{}:{x:r+s.x,y:i+s.y,data:{...s,placement:a}}}}},ZO=function(e){return e===void 0&&(e={}),{name:`shift`,options:e,async fn(t){let{x:n,y:r,placement:i,platform:a}=t,{mainAxis:o=!0,crossAxis:s=!1,limiter:c={fn:e=>{let{x:t,y:n}=e;return{x:t,y:n}}},...l}=yO(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=wO(bO(i)),p=SO(f),m=u[p],h=u[f];if(o){let e=p===`y`?`top`:`left`,t=p===`y`?`bottom`:`right`,n=m+d[e],r=m-d[t];m=vO(n,m,r)}if(s){let e=f===`y`?`top`:`left`,t=f===`y`?`bottom`:`right`,n=h+d[e],r=h-d[t];h=vO(n,h,r)}let g=c.fn({...t,[p]:m,[f]:h});return{...g,data:{x:g.x-n,y:g.y-r,enabled:{[p]:o,[f]:s}}}}}},QO=function(e){return e===void 0&&(e={}),{options:e,fn(t){let{x:n,y:r,placement:i,rects:a,middlewareData:o}=t,{offset:s=0,mainAxis:c=!0,crossAxis:l=!0}=yO(e,t),u={x:n,y:r},d=wO(i),f=SO(d),p=u[f],m=u[d],h=yO(s,t),g=typeof h==`number`?{mainAxis:h,crossAxis:0}:{mainAxis:0,crossAxis:0,...h};if(c){let e=f===`y`?`height`:`width`,t=a.reference[f]-a.floating[e]+g.mainAxis,n=a.reference[f]+a.reference[e]-g.mainAxis;p<t?p=t:p>n&&(p=n)}if(l){let e=f===`y`?`width`:`height`,t=JO.has(bO(i)),n=a.reference[d]-a.floating[e]+(t&&o.offset?.[d]||0)+(t?0:g.crossAxis),r=a.reference[d]+a.reference[e]+(t?0:o.offset?.[d]||0)-(t?g.crossAxis:0);m<n?m=n:m>r&&(m=r)}return{[f]:p,[d]:m}}}},$O=function(e){return e===void 0&&(e={}),{name:`size`,options:e,async fn(t){var n,r;let{placement:i,rects:a,platform:o,elements:s}=t,{apply:c=()=>{},...l}=yO(e,t),u=await o.detectOverflow(t,l),d=bO(i),f=xO(i),p=wO(i)===`y`,{width:m,height:h}=a.floating,g,_;d===`top`||d===`bottom`?(g=d,_=f===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?`start`:`end`)?`left`:`right`):(_=d,g=f===`end`?`top`:`bottom`);let v=h-u.top-u.bottom,y=m-u.left-u.right,b=fO(h-u[g],v),x=fO(m-u[_],y),S=!t.middlewareData.shift,C=b,w=x;if((n=t.middlewareData.shift)!=null&&n.enabled.x&&(w=y),(r=t.middlewareData.shift)!=null&&r.enabled.y&&(C=v),S&&!f){let e=pO(u.left,0),t=pO(u.right,0),n=pO(u.top,0),r=pO(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:pO(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:pO(u.top,u.bottom))}await c({...t,availableWidth:w,availableHeight:C});let T=await o.getDimensions(s.floating);return m!==T.width||h!==T.height?{reset:{rects:!0}}:{}}}};function ek(){return typeof window<`u`}function tk(e){return ik(e)?(e.nodeName||``).toLowerCase():`#document`}function nk(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function rk(e){return((ik(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function ik(e){return ek()?e instanceof Node||e instanceof nk(e).Node:!1}function ak(e){return ek()?e instanceof Element||e instanceof nk(e).Element:!1}function ok(e){return ek()?e instanceof HTMLElement||e instanceof nk(e).HTMLElement:!1}function sk(e){return!ek()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof nk(e).ShadowRoot}function ck(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=yk(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function lk(e){return/^(table|td|th)$/.test(tk(e))}function uk(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var dk=/transform|translate|scale|rotate|perspective|filter/,fk=/paint|layout|strict|content/,pk=e=>!!e&&e!==`none`,mk;function hk(e){let t=ak(e)?yk(e):e;return pk(t.transform)||pk(t.translate)||pk(t.scale)||pk(t.rotate)||pk(t.perspective)||!_k()&&(pk(t.backdropFilter)||pk(t.filter))||dk.test(t.willChange||``)||fk.test(t.contain||``)}function gk(e){let t=xk(e);for(;ok(t)&&!vk(t);){if(hk(t))return t;if(uk(t))return null;t=xk(t)}return null}function _k(){return mk??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),mk}function vk(e){return/^(html|body|#document)$/.test(tk(e))}function yk(e){return nk(e).getComputedStyle(e)}function bk(e){return ak(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function xk(e){if(tk(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||sk(e)&&e.host||rk(e);return sk(t)?t.host:t}function Sk(e){let t=xk(e);return vk(t)?e.ownerDocument?e.ownerDocument.body:e.body:ok(t)&&ck(t)?t:Sk(t)}function Ck(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Sk(e),i=r===e.ownerDocument?.body,a=nk(r);if(i){let e=wk(a);return t.concat(a,a.visualViewport||[],ck(r)?r:[],e&&n?Ck(e):[])}else return t.concat(r,Ck(r,[],n))}function wk(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Tk(e){let t=yk(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=ok(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=mO(n)!==a||mO(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Ek(e){return ak(e)?e:e.contextElement}function Dk(e){let t=Ek(e);if(!ok(t))return gO(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Tk(t),o=(a?mO(n.width):n.width)/r,s=(a?mO(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Ok=gO(0);function kk(e){let t=nk(e);return!_k()||!t.visualViewport?Ok:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ak(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==nk(e)?!1:t}function jk(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Ek(e),o=gO(1);t&&(r?ak(r)&&(o=Dk(r)):o=Dk(e));let s=Ak(a,n,r)?kk(a):gO(0),c=(i.left+s.x)/o.x,l=(i.top+s.y)/o.y,u=i.width/o.x,d=i.height/o.y;if(a){let e=nk(a),t=r&&ak(r)?nk(r):r,n=e,i=wk(n);for(;i&&r&&t!==n;){let e=Dk(i),t=i.getBoundingClientRect(),r=yk(i),a=t.left+(i.clientLeft+parseFloat(r.paddingLeft))*e.x,o=t.top+(i.clientTop+parseFloat(r.paddingTop))*e.y;c*=e.x,l*=e.y,u*=e.x,d*=e.y,c+=a,l+=o,n=nk(i),i=wk(n)}}return RO({width:u,height:d,x:c,y:l})}function Mk(e,t){let n=bk(e).scrollLeft;return t?t.left+n:jk(rk(e)).left+n}function Nk(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Mk(e,n),y:n.top+t.scrollTop}}function Pk(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=rk(r),s=t?uk(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=gO(1),u=gO(0),d=ok(r);if((d||!d&&!a)&&((tk(r)!==`body`||ck(o))&&(c=bk(r)),d)){let e=jk(r);l=Dk(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?Nk(o,c):gO(0);return{width:n.width*l.x,height:n.height*l.y,x:n.x*l.x-c.scrollLeft*l.x+u.x+f.x,y:n.y*l.y-c.scrollTop*l.y+u.y+f.y}}function Fk(e){return Array.from(e.getClientRects())}function Ik(e){let t=rk(e),n=bk(e),r=e.ownerDocument.body,i=pO(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=pO(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Mk(e),s=-n.scrollTop;return yk(r).direction===`rtl`&&(o+=pO(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var Lk=25;function Rk(e,t){let n=nk(e),r=rk(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=_k();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Mk(r);if(l<=0){let e=r.ownerDocument,t=e.body,n=getComputedStyle(t),i=e.compatMode===`CSS1Compat`&&parseFloat(n.marginLeft)+parseFloat(n.marginRight)||0,o=Math.abs(r.clientWidth-t.clientWidth-i);o<=Lk&&(a-=o)}else l<=Lk&&(a+=l);return{width:a,height:o,x:s,y:c}}function zk(e,t){let n=jk(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=ok(e)?Dk(e):gO(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function Bk(e,t,n){let r;if(t===`viewport`)r=Rk(e,n);else if(t===`document`)r=Ik(rk(e));else if(ak(t))r=zk(t,n);else{let n=kk(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return RO(r)}function Vk(e,t){let n=xk(e);return n===t||!ak(n)||vk(n)?!1:yk(n).position===`fixed`||Vk(n,t)}function Hk(e,t){let n=t.get(e);if(n)return n;let r=Ck(e,[],!1).filter(e=>ak(e)&&tk(e)!==`body`),i=null,a=yk(e).position===`fixed`,o=a?xk(e):e;for(;ak(o)&&!vk(o);){let t=yk(o),n=hk(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||ck(o)&&!n&&Vk(e,o))?r=r.filter(e=>e!==o):i=t,o=xk(o)}return t.set(e,r),r}function Uk(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?uk(t)?[]:Hk(t,this._c):[].concat(n),r],o=Bk(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=Bk(t,a[e],i);s=pO(n.top,s),c=fO(n.right,c),l=fO(n.bottom,l),u=pO(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Wk(e){let{width:t,height:n}=Tk(e);return{width:t,height:n}}function Gk(e,t,n){let r=ok(t),i=rk(t),a=n===`fixed`,o=jk(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=gO(0);function l(){c.x=Mk(i)}if(r||!r&&!a)if((tk(t)!==`body`||ck(i))&&(s=bk(t)),r){let e=jk(t,!0,a,t);c.x=e.x+t.clientLeft,c.y=e.y+t.clientTop}else i&&l();a&&!r&&i&&l();let u=i&&!r&&!a?Nk(i,s):gO(0);return{x:o.left+s.scrollLeft-c.x-u.x,y:o.top+s.scrollTop-c.y-u.y,width:o.width,height:o.height}}function Kk(e){return yk(e).position===`static`}function qk(e,t){if(!ok(e)||yk(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return rk(e)===n&&(n=n.ownerDocument.body),n}function Jk(e,t){let n=nk(e);if(uk(e))return n;if(!ok(e)){let t=xk(e);for(;t&&!vk(t);){if(ak(t)&&!Kk(t))return t;t=xk(t)}return n}let r=qk(e,t);for(;r&&lk(r)&&Kk(r);)r=qk(r,t);return r&&vk(r)&&Kk(r)&&!hk(r)?n:r||gk(e)||n}var Yk=async function(e){let t=this.getOffsetParent||Jk,n=this.getDimensions,r=await n(e.floating);return{reference:Gk(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Xk(e){return yk(e).direction===`rtl`}var Zk={convertOffsetParentRelativeRectToViewportRelativeRect:Pk,getDocumentElement:rk,getClippingRect:Uk,getOffsetParent:Jk,getElementRects:Yk,getClientRects:Fk,getDimensions:Wk,getScale:Dk,isElement:ak,isRTL:Xk};function Qk(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function $k(e,t){let n=null,r,i=rk(e);function a(){var e;clearTimeout(r),(e=n)==null||e.disconnect(),n=null}function o(s,c){s===void 0&&(s=!1),c===void 0&&(c=1),a();let l=e.getBoundingClientRect(),{left:u,top:d,width:f,height:p}=l;if(s||t(),!f||!p)return;let m=hO(d),h=hO(i.clientWidth-(u+f)),g=hO(i.clientHeight-(d+p)),_=hO(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:pO(0,fO(1,c))||1},y=!0;function b(t){let n=t[0].intersectionRatio;if(n!==c){if(!y)return o();n?o(!1,n):r=setTimeout(()=>{o(!1,1e-7)},1e3)}n===1&&!Qk(l,e.getBoundingClientRect())&&o(),y=!1}try{n=new IntersectionObserver(b,{...v,root:i.ownerDocument})}catch{n=new IntersectionObserver(b,v)}n.observe(e)}return o(!0),a}function eA(e,t,n,r){r===void 0&&(r={});let{ancestorScroll:i=!0,ancestorResize:a=!0,elementResize:o=typeof ResizeObserver==`function`,layoutShift:s=typeof IntersectionObserver==`function`,animationFrame:c=!1}=r,l=Ek(e),u=i||a?[...l?Ck(l):[],...t?Ck(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?$k(l,n):null,f=-1,p=null;o&&(p=new ResizeObserver(e=>{let[r]=e;r&&r.target===l&&p&&t&&(p.unobserve(t),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var e;(e=p)==null||e.observe(t)})),n()}),l&&!c&&p.observe(l),t&&p.observe(t));let m,h=c?jk(e):null;c&&g();function g(){let t=jk(e);h&&!Qk(h,t)&&n(),h=t,m=requestAnimationFrame(g)}return n(),()=>{var e;u.forEach(e=>{i&&e.removeEventListener(`scroll`,n),a&&e.removeEventListener(`resize`,n)}),d?.(),(e=p)==null||e.disconnect(),p=null,c&&cancelAnimationFrame(m)}}var tA=XO,nA=ZO,rA=WO,iA=$O,aA=qO,oA=UO,sA=QO,cA=(e,t,n)=>{let r=new Map,i={platform:Zk,...n},a={...i.platform,_c:r};return HO(e,t,{...i,platform:a})},lA=typeof document<`u`?I.useLayoutEffect:function(){};function uA(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e==`function`&&e.toString()===t.toString())return!0;let n,r,i;if(e&&t&&typeof e==`object`){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!uA(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){let n=i[r];if(!(n===`_owner`&&e.$$typeof)&&!uA(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function dA(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function fA(e,t){let n=dA(e);return Math.round(t*n)/n}function pA(e){let t=I.useRef(e);return lA(()=>{t.current=e}),t}function mA(e){e===void 0&&(e={});let{placement:t=`bottom`,strategy:n=`absolute`,middleware:r=[],platform:i,elements:{reference:a,floating:o}={},transform:s=!0,whileElementsMounted:c,open:l}=e,[u,d]=I.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=I.useState(r);uA(f,r)||p(r);let[m,h]=I.useState(null),[g,_]=I.useState(null),v=I.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=I.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=I.useRef(null),C=I.useRef(null),w=I.useRef(u),T=c!=null,E=pA(c),D=pA(i),O=pA(l),k=I.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),cA(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!uA(w.current,t)&&(w.current=t,ot.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);lA(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=I.useRef(!1);lA(()=>(A.current=!0,()=>{A.current=!1}),[]),lA(()=>{if(b&&(S.current=b),x&&(C.current=x),b&&x){if(E.current)return E.current(b,x,k);k()}},[b,x,k,E,T]);let j=I.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=I.useMemo(()=>({reference:b,floating:x}),[b,x]),N=I.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=fA(M.floating,u.x),r=fA(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...dA(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return I.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var hA=e=>{function t(e){return{}.hasOwnProperty.call(e,`current`)}return{name:`arrow`,options:e,fn(n){let{element:r,padding:i}=typeof e==`function`?e(n):e;return r&&t(r)?r.current==null?{}:oA({element:r.current,padding:i}).fn(n):r?oA({element:r,padding:i}).fn(n):{}}}},gA=(e,t)=>{let n=tA(e);return{name:n.name,fn:n.fn,options:[e,t]}},_A=(e,t)=>{let n=nA(e);return{name:n.name,fn:n.fn,options:[e,t]}},vA=(e,t)=>({fn:sA(e).fn,options:[e,t]}),yA=(e,t)=>{let n=rA(e);return{name:n.name,fn:n.fn,options:[e,t]}},bA=(e,t)=>{let n=iA(e);return{name:n.name,fn:n.fn,options:[e,t]}},xA=(e,t)=>{let n=aA(e);return{name:n.name,fn:n.fn,options:[e,t]}},SA=(e,t)=>{let n=hA(e);return{name:n.name,fn:n.fn,options:[e,t]}},CA=`Arrow`,wA=I.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,L.jsx)(VD.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,L.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})});wA.displayName=CA;var TA=wA;function EA(e){let[t,n]=I.useState(void 0);return WD(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var DA=`Popper`,[OA,kA]=ED(DA),[AA,jA]=OA(DA),MA=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null),[a,o]=I.useState(void 0);return(0,L.jsx)(AA,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};MA.displayName=DA;var NA=`PopperAnchor`,PA=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=jA(NA,n),o=I.useRef(null),s=a.onAnchorChange,c=TD(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&&WA(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,L.jsx)(VD.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})});PA.displayName=NA;var FA=`PopperContent`,[IA,LA]=OA(FA),RA=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=jA(FA,n),[_,v]=I.useState(null),y=TD(t,v),[b,x]=I.useState(null),S=EA(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(HA),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=mA({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>eA(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[gA({mainAxis:i+w,alignmentAxis:o}),c&&_A({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?vA():void 0,...k}),c&&yA({...k}),bA({...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&&SA({element:b,padding:s}),UA({arrowWidth:C,arrowHeight:w}),f&&xA({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ee=g.setPlacementState;WD(()=>(ee(M),()=>{ee(void 0)}),[M,ee]);let[F,te]=WA(M),ne=UD(m);WD(()=>{N&&ne?.()},[N,ne]);let re=P.arrow?.x,ie=P.arrow?.y,ae=P.arrow?.centerOffset!==0,[oe,se]=I.useState();return WD(()=>{_&&se(window.getComputedStyle(_).zIndex)},[_]),(0,L.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:N?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,L.jsx)(IA,{scope:n,placedSide:F,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,L.jsx)(VD.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});RA.displayName=FA;var zA=`PopperArrow`,BA={top:`bottom`,right:`left`,bottom:`top`,left:`right`},VA=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=LA(zA,n),a=BA[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)(TA,{...r,ref:t,style:{...r.style,display:`block`}})})});VA.displayName=zA;function HA(e){return e!==null}var UA=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]=WA(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 WA(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var GA=MA,KA=PA,qA=RA,JA=VA,YA=`Portal`,XA=I.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=I.useState(!1);WD(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?ot.createPortal((0,L.jsx)(VD.div,{...r,ref:t}),o):null});XA.displayName=YA;function ZA(e,t){return I.useReducer((e,n)=>t[e][n]??e,e)}var QA=e=>{let{present:t,children:n}=e,r=$A(t),i=typeof n==`function`?n({present:r.isPresent}):I.Children.only(n),a=tj(r.ref,rj(i));return typeof n==`function`||r.isPresent?I.cloneElement(i,{ref:a}):null};QA.displayName=`Presence`;function $A(e){let[t,n]=I.useState(),r=I.useRef(null),i=I.useRef(e),a=I.useRef(`none`),[o,s]=ZA(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return I.useEffect(()=>{let e=nj(r.current);a.current=o===`mounted`?e:`none`},[o]),WD(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=nj(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),WD(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=nj(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(s(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},c=e=>{e.target===t&&(a.current=nj(r.current))};return t.addEventListener(`animationstart`,c),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,c),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else s(`ANIMATION_END`)},[t,s]),{isPresent:[`mounted`,`unmountSuspended`].includes(o),ref:I.useCallback(e=>{r.current=e?getComputedStyle(e):null,n(e)},[])}}function ej(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function tj(...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=ej(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():ej(n[e],null)}}},[])}function nj(e){return e?.animationName||`none`}function rj(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 ij=I.useInsertionEffect||WD;function aj({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=oj({defaultProp:t,onChange:n}),s=e!==void 0,c=s?e:i;{let t=I.useRef(e!==void 0);I.useEffect(()=>{let e=t.current;e!==s&&console.warn(`${r} is changing from ${e?`controlled`:`uncontrolled`} to ${s?`controlled`:`uncontrolled`}. Components should not switch from controlled to uncontrolled (or vice versa). Decide between using a controlled or uncontrolled value for the lifetime of the component.`),t.current=s},[s,r])}return[c,I.useCallback(t=>{if(s){let n=sj(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function oj({defaultProp:e,onChange:t}){let[n,r]=I.useState(e),i=I.useRef(n),a=I.useRef(t);return ij(()=>{a.current=t},[t]),I.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function sj(e){return typeof e==`function`}var cj=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),lj=`VisuallyHidden`,uj=I.forwardRef((e,t)=>(0,L.jsx)(VD.span,{...e,ref:t,style:{...cj,...e.style}}));uj.displayName=lj;var dj=uj,[fj,pj]=ED(`Tooltip`,[kA]),mj=kA(),hj=`TooltipProvider`,gj=700,_j=`tooltip.open`,[vj,yj]=fj(hj),bj=e=>{let{__scopeTooltip:t,delayDuration:n=gj,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=I.useRef(!0),s=I.useRef(!1),c=I.useRef(0);return I.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,L.jsx)(vj,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:I.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:I.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:I.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};bj.displayName=hj;var xj=`Tooltip`,[Sj,Cj]=fj(xj),wj=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=yj(xj,e.__scopeTooltip),l=mj(t),[u,d]=I.useState(null),f=uO(),p=I.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=I.useRef(!1),[_,v]=aj({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(_j))):c.onClose(),a?.(e)},caller:xj}),y=I.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=I.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=I.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=I.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return I.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,L.jsx)(GA,{...l,children:(0,L.jsx)(Sj,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:I.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:I.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};wj.displayName=xj;var Tj=`TooltipTrigger`,Ej=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Cj(Tj,n),a=yj(Tj,n),o=mj(n),s=TD(t,I.useRef(null),i.onTriggerChange),c=I.useRef(!1),l=I.useRef(!1),u=I.useCallback(()=>c.current=!1,[]);return I.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,L.jsx)(KA,{asChild:!0,...o,children:(0,L.jsx)(VD.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:SD(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:SD(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:SD(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:SD(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:SD(e.onBlur,i.onClose),onClick:SD(e.onClick,i.onClose)})})});Ej.displayName=Tj;var Dj=`TooltipPortal`,[Oj,kj]=fj(Dj,{forceMount:void 0}),Aj=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Cj(Dj,t);return(0,L.jsx)(Oj,{scope:t,forceMount:n,children:(0,L.jsx)(QA,{present:n||a.open,children:(0,L.jsx)(XA,{asChild:!0,container:i,children:r})})})};Aj.displayName=Dj;var jj=`TooltipContent`,Mj=I.forwardRef((e,t)=>{let n=kj(jj,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Cj(jj,e.__scopeTooltip);return(0,L.jsx)(QA,{present:r||o.open,children:o.disableHoverableContent?(0,L.jsx)(Lj,{side:i,...a,ref:t}):(0,L.jsx)(Nj,{side:i,...a,ref:t})})}),Nj=I.forwardRef((e,t)=>{let n=Cj(jj,e.__scopeTooltip),r=yj(jj,e.__scopeTooltip),i=I.useRef(null),a=TD(t,i),[o,s]=I.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=I.useCallback(()=>{s(null),d(!1)},[d]),p=I.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=Vj(r,Bj(r,n.getBoundingClientRect())),a=Hj(t.getBoundingClientRect()),o=Wj([...i,...a]);s(o),d(!0)},[d]);return I.useEffect(()=>()=>f(),[f]),I.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),I.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Uj(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,L.jsx)(Lj,{...e,ref:a})}),[Pj,Fj]=fj(xj,{isInside:!1}),Ij=AD(`TooltipContent`),Lj=I.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Cj(jj,n),l=mj(n),{onClose:u}=c;return I.useEffect(()=>(document.addEventListener(_j,u),()=>document.removeEventListener(_j,u)),[u]),I.useEffect(()=>{if(c.trigger){let e=e=>{e.target instanceof Node&&e.target.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,L.jsx)(eO,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,L.jsxs)(qA,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,L.jsx)(Ij,{children:r}),(0,L.jsx)(Pj,{scope:n,isInside:!0,children:(0,L.jsx)(dj,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Mj.displayName=jj;var Rj=`TooltipArrow`,zj=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=mj(n);return Fj(Rj,n).isInside?null:(0,L.jsx)(JA,{...i,...r,ref:t})});zj.displayName=Rj;function Bj(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function Vj(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Hj(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Uj(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function Wj(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Gj(t)}function Gj(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Kj=bj,qj=wj,Jj=Ej,Yj=Aj,Xj=Mj,Zj=zj,Qj=`isolate bg-elevated opacity-100 border border-border shadow-2xl shadow-black/40`,$j=`z-[110]`,eM=`${$j} ${Qj}`,tM=`z-[250]`,nM=`z-[250]`;function rM({children:e}){return(0,L.jsx)(Kj,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!0,children:e})}function iM({label:e,children:t,side:n=`top`,clickable:r=!1,multiline:i=!1,disabled:a=!1}){let o=i?`whitespace-pre-line`:`whitespace-normal`,[s,c]=(0,I.useState)(!1),l=(0,I.useId)(),u=r&&(0,I.isValidElement)(t)?t:null,d=u?(0,I.cloneElement)(u,{"aria-describedby":l}):t,f=(0,I.useRef)(null);if(u){let t=f.current?.getBoundingClientRect(),n=t?Math.min(Math.max(12,t.right+8),window.innerWidth-364):12,r=t?Math.min(Math.max(12,t.top-6),window.innerHeight-96):12;return(0,L.jsxs)(`span`,{ref:f,className:`inline-flex`,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocus:()=>c(!0),onBlur:()=>c(!1),onClick:()=>c(e=>!e),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),c(!1))},children:[d,s&&(0,ot.createPortal)((0,L.jsx)(`span`,{id:l,role:`tooltip`,className:`z-[250] max-w-[min(22rem,calc(100vw-1.5rem))] rounded-md border border-border bg-elevated px-3 py-2 text-[11px] leading-relaxed text-fg shadow-md shadow-black/40 break-words ${o}`,style:{position:`fixed`,left:n,top:r},children:e}),document.body)]})}return(0,L.jsxs)(qj,{open:s&&!a,onOpenChange:c,children:[(0,L.jsx)(Jj,{asChild:!0,children:d}),(0,L.jsx)(Yj,{children:(0,L.jsxs)(Xj,{id:l,side:n,sideOffset:5,collisionPadding:12,className:`${nM} max-w-[min(22rem,calc(100vw-1.5rem))] select-none rounded-md border border-border bg-elevated px-3 py-2 text-[11px] leading-relaxed text-fg shadow-md shadow-black/40 break-words ${o}`,children:[e,(0,L.jsx)(Zj,{className:`fill-elevated`})]})})]})}function aM({slug:e,size:t=14,className:n,label:r=`Open fullscreen`}){let i=Ld(e);function a(t){if(t.stopPropagation(),!zd(t))return;t.preventDefault();let n=!Xp(),r=t.currentTarget.closest(`[data-vt-chat]`);gD(r,e),typeof location<`u`&&yD(e,location.pathname),n&&r&&(r.style.viewTransitionName=`thread-chat`),bw(i,{viewTransition:n})}return(0,L.jsx)(iM,{label:r,children:(0,L.jsx)(`a`,{href:i,"aria-label":r,"data-expand-thread":e,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:a,className:n??`flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:hover:bg-transparent disabled:hover:text-muted disabled:opacity-40`,children:(0,L.jsx)(Zm,{size:t})})})}function oM(e,t,n=`AGENT`){let r=n===`SHELL`?`Background shell`:`Sub-agent`;Y.stopBackgroundOp({slug:e,id:t}).then(({stopped:e,note:t,descendantsStopped:i})=>{if(e){if(t)return Z(`${r} stopped. ${t}`,{duration:7e3});if(n===`SHELL`)return Z(`Background shell stopped — the worker was told`);Z(i>0?`Sub-agent and ${i} descendant${i===1?``:`s`} stopped`:`Sub-agent stopped`)}}).catch(e=>{Z(`Couldn’t stop: ${(e instanceof Error?e.message:String(e)).slice(0,100)}`,{duration:7e3})})}function sM(e,t,n=`AGENT`){if(!t.id||!Xc(t)||t.state===`running`&&!t.stoppable)return;let r=t.id;return()=>oM(e,r,n)}function cM(e){let t=e+`CollectionProvider`,[n,r]=ED(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=e=>{let{scope:t,children:n}=e,r=I.useRef(null),a=I.useRef(new Map).current;return(0,L.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})};o.displayName=t;let s=e+`CollectionSlot`,c=OD(s),l=I.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=TD(t,a(s,n).collectionRef);return(0,L.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=OD(u),p=I.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=I.useRef(null),s=TD(t,o),c=a(u,n);return I.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,L.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return I.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${d}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:o,Slot:l,ItemSlot:p},m,r]}var lM=I.createContext(void 0);function uM(e){let t=I.useContext(lM);return e||t||`ltr`}var dM=0,fM=null;function pM(){I.useEffect(()=>{fM||={start:mM(),end:mM()};let{start:e,end:t}=fM;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),dM++,()=>{dM===1&&(fM?.start.remove(),fM?.end.remove(),fM=null),dM=Math.max(0,dM-1)}},[])}function mM(){let e=document.createElement(`span`);return e.setAttribute(`data-radix-focus-guard`,``),e.tabIndex=0,e.style.outline=`none`,e.style.opacity=`0`,e.style.position=`fixed`,e.style.pointerEvents=`none`,e}var hM=`focusScope.autoFocusOnMount`,gM=`focusScope.autoFocusOnUnmount`,_M={bubbles:!1,cancelable:!0},vM=`FocusScope`,yM=I.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=I.useState(null),l=UD(i),u=UD(a),d=I.useRef(null),f=TD(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:EM(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||EM(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&EM(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){DM.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(hM,_M);s.addEventListener(hM,l),s.dispatchEvent(t),t.defaultPrevented||(bM(AM(SM(s)),{select:!0}),document.activeElement===e&&EM(s))}return()=>{s.removeEventListener(hM,l),setTimeout(()=>{let t=new CustomEvent(gM,_M);s.addEventListener(gM,u),s.dispatchEvent(t),t.defaultPrevented||EM(e??document.body,{select:!0}),s.removeEventListener(gM,u),DM.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]=xM(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&EM(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&EM(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,L.jsx)(VD.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});yM.displayName=vM;function bM(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(EM(r,{select:t}),document.activeElement!==n)return}function xM(e){let t=SM(e);return[CM(t,e),CM(t.reverse(),e)]}function SM(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 CM(e,t){for(let n of e)if(!wM(n,{upTo:t}))return n}function wM(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 TM(e){return e instanceof HTMLInputElement&&`select`in e}function EM(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&TM(e)&&t&&e.select()}}var DM=OM();function OM(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=kM(e,t),e.unshift(t)},remove(t){e=kM(e,t),e[0]?.resume()}}}function kM(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function AM(e){return e.filter(e=>e.tagName!==`A`)}var jM=`rovingFocusGroup.onEntryFocus`,MM={bubbles:!1,cancelable:!0},NM=`RovingFocusGroup`,[PM,FM,IM]=cM(NM),[LM,RM]=ED(NM,[IM]),[zM,BM]=LM(NM),VM=I.forwardRef((e,t)=>(0,L.jsx)(PM.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,L.jsx)(PM.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,L.jsx)(HM,{...e,ref:t})})}));VM.displayName=NM;var HM=I.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:i=!1,dir:a,currentTabStopId:o,defaultCurrentTabStopId:s,onCurrentTabStopIdChange:c,onEntryFocus:l,preventScrollOnEntryFocus:u=!1,...d}=e,f=I.useRef(null),p=TD(t,f),m=uM(a),[h,g]=aj({prop:o,defaultProp:s??null,onChange:c,caller:NM}),[_,v]=I.useState(!1),y=UD(l),b=FM(n),x=I.useRef(!1),[S,C]=I.useState(0);return I.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(jM,y),()=>e.removeEventListener(jM,y)},[y]),(0,L.jsx)(zM,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:I.useCallback(e=>g(e),[g]),onItemShiftTab:I.useCallback(()=>v(!0),[]),onFocusableItemAdd:I.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:I.useCallback(()=>C(e=>e-1),[]),children:(0,L.jsx)(VD.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:SD(e.onMouseDown,()=>{x.current=!0}),onFocus:SD(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(jM,MM);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);JM([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:SD(e.onBlur,()=>v(!1))})})}),UM=`RovingFocusGroupItem`,WM=I.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=uO(),l=a||c,u=BM(UM,n),d=u.currentTabStopId===l,f=FM(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return I.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,L.jsx)(PM.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,L.jsx)(VD.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:SD(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:SD(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:SD(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=qM(e,u.orientation,u.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=f().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=u.loop?YM(n,r+1):n.slice(r+1)}setTimeout(()=>JM(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});WM.displayName=UM;var GM={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function KM(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function qM(e,t,n){let r=KM(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return GM[r]}function JM(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function YM(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var XM=VM,ZM=WM,QM=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},$M=new WeakMap,eN=new WeakMap,tN={},nN=0,rN=function(e){return e&&(e.host||rN(e.parentNode))},iN=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=rN(t);return n&&e.contains(n)?n:(console.error(`aria-hidden`,t,`in not contained inside`,e,`. Doing nothing`),null)}).filter(function(e){return!!e})},aN=function(e,t,n,r){var i=iN(t,Array.isArray(e)?e:[e]);tN[n]||(tN[n]=new WeakMap);var a=tN[n],o=[],s=new Set,c=new Set(i),l=function(e){!e||s.has(e)||(s.add(e),l(e.parentNode))};i.forEach(l);var u=function(e){!e||c.has(e)||Array.prototype.forEach.call(e.children,function(e){if(s.has(e))u(e);else try{var t=e.getAttribute(r),i=t!==null&&t!==`false`,c=($M.get(e)||0)+1,l=(a.get(e)||0)+1;$M.set(e,c),a.set(e,l),o.push(e),c===1&&i&&eN.set(e,!0),l===1&&e.setAttribute(n,`true`),i||e.setAttribute(r,`true`)}catch(t){console.error(`aria-hidden: cannot operate on `,e,t)}})};return u(t),s.clear(),nN++,function(){o.forEach(function(e){var t=$M.get(e)-1,i=a.get(e)-1;$M.set(e,t),a.set(e,i),t||(eN.has(e)||e.removeAttribute(r),eN.delete(e)),i||e.removeAttribute(n)}),nN--,nN||($M=new WeakMap,$M=new WeakMap,eN=new WeakMap,tN={})}},oN=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||QM(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),aN(r,i,n,`aria-hidden`)):function(){return null}},sN=function(){return sN=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n],t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},sN.apply(this,arguments)};function cN(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n}function lN(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))}var uN=`right-scroll-bar-position`,dN=`width-before-scroll-bar`,fN=`with-scroll-bars-hidden`,pN=`--removed-body-scroll-bar-size`;function mN(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function hN(e,t){var n=(0,I.useState)(function(){return{value:e,callback:t,facade:{get current(){return n.value},set current(e){var t=n.value;t!==e&&(n.value=e,n.callback(e,t))}}}})[0];return n.callback=t,n.facade}var gN=typeof window<`u`?I.useLayoutEffect:I.useEffect,_N=new WeakMap;function vN(e,t){var n=hN(t||null,function(t){return e.forEach(function(e){return mN(e,t)})});return gN(function(){var t=_N.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||mN(e,null)}),i.forEach(function(e){r.has(e)||mN(e,a)})}_N.set(n,e)},[e]),n}function yN(e){return e}function bN(e,t){t===void 0&&(t=yN);var n=[],r=!1;return{read:function(){if(r)throw Error("Sidecar: could not `read` from an `assigned` medium. `read` could be used only with `useMedium`.");return n.length?n[n.length-1]:e},useMedium:function(e){var i=t(e,r);return n.push(i),function(){n=n.filter(function(e){return e!==i})}},assignSyncMedium:function(e){for(r=!0;n.length;){var t=n;n=[],t.forEach(e)}n={push:function(t){return e(t)},filter:function(){return n}}},assignMedium:function(e){r=!0;var t=[];if(n.length){var i=n;n=[],i.forEach(e),t=n}var a=function(){var n=t;t=[],n.forEach(e)},o=function(){return Promise.resolve().then(a)};o(),n={push:function(e){t.push(e),o()},filter:function(e){return t=t.filter(e),n}}}}}function xN(e){e===void 0&&(e={});var t=bN(null);return t.options=sN({async:!0,ssr:!1},e),t}var SN=function(e){var t=e.sideCar,n=cN(e,[`sideCar`]);if(!t)throw Error("Sidecar: please provide `sideCar` property to import the right car");var r=t.read();if(!r)throw Error(`Sidecar medium not found`);return I.createElement(r,sN({},n))};SN.isSideCarExport=!0;function CN(e,t){return e.useMedium(t),SN}var wN=xN(),TN=function(){},EN=I.forwardRef(function(e,t){var n=I.useRef(null),r=I.useState({onScrollCapture:TN,onWheelCapture:TN,onTouchMoveCapture:TN}),i=r[0],a=r[1],o=e.forwardProps,s=e.children,c=e.className,l=e.removeScrollBar,u=e.enabled,d=e.shards,f=e.sideCar,p=e.noRelative,m=e.noIsolation,h=e.inert,g=e.allowPinchZoom,_=e.as,v=_===void 0?`div`:_,y=e.gapMode,b=cN(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=vN([n,t]),C=sN(sN({},b),i);return I.createElement(I.Fragment,null,u&&I.createElement(x,{sideCar:wN,removeScrollBar:l,shards:d,noRelative:p,noIsolation:m,inert:h,setCallbacks:a,allowPinchZoom:!!g,lockRef:n,gapMode:y}),o?I.cloneElement(I.Children.only(s),sN(sN({},C),{ref:S})):I.createElement(v,sN({},C,{className:c,ref:S}),s))});EN.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},EN.classNames={fullWidth:dN,zeroRight:uN};var DN,ON=function(){if(DN)return DN;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function kN(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=ON();return t&&e.setAttribute(`nonce`,t),e}function AN(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function jN(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var MN=function(){var e=0,t=null;return{add:function(n){e==0&&(t=kN())&&(AN(t,n),jN(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},NN=function(){var e=MN();return function(t,n){I.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},PN=function(){var e=NN();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},FN={left:0,top:0,right:0,gap:0},IN=function(e){return parseInt(e||``,10)||0},LN=function(e){var t=window.getComputedStyle(document.body),n=t[e===`padding`?`paddingLeft`:`marginLeft`],r=t[e===`padding`?`paddingTop`:`marginTop`],i=t[e===`padding`?`paddingRight`:`marginRight`];return[IN(n),IN(r),IN(i)]},RN=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return FN;var t=LN(e),n=document.documentElement.clientWidth,r=window.innerWidth;return{left:t[0],top:t[1],right:t[2],gap:Math.max(0,r-n+t[2]-t[0])}},zN=PN(),BN=`data-scroll-locked`,VN=function(e,t,n,r){var i=e.left,a=e.top,o=e.right,s=e.gap;return n===void 0&&(n=`margin`),`
140
+ .${fN} {
141
141
  overflow: hidden ${r};
142
142
  padding-right: ${s}px ${r};
143
143
  }
144
- body[${RN}] {
144
+ body[${BN}] {
145
145
  overflow: hidden ${r};
146
146
  overscroll-behavior: contain;
147
147
  ${[t&&`position: relative ${r};`,n===`margin`&&`
@@ -154,63 +154,63 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
154
154
  `,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
155
155
  }
156
156
 
157
- .${cN} {
157
+ .${uN} {
158
158
  right: ${s}px ${r};
159
159
  }
160
160
 
161
- .${lN} {
161
+ .${dN} {
162
162
  margin-right: ${s}px ${r};
163
163
  }
164
164
 
165
- .${cN} .${cN} {
165
+ .${uN} .${uN} {
166
166
  right: 0 ${r};
167
167
  }
168
168
 
169
- .${lN} .${lN} {
169
+ .${dN} .${dN} {
170
170
  margin-right: 0 ${r};
171
171
  }
172
172
 
173
- body[${RN}] {
174
- ${dN}: ${s}px;
173
+ body[${BN}] {
174
+ ${pN}: ${s}px;
175
175
  }
176
- `},BN=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},VN=function(){I.useEffect(function(){return document.body.setAttribute(RN,(BN()+1).toString()),function(){var e=BN()-1;e<=0?document.body.removeAttribute(RN):document.body.setAttribute(RN,e.toString())}},[])},HN=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;VN();var a=I.useMemo(function(){return IN(i)},[i]);return I.createElement(LN,{styles:zN(a,!t,i,n?``:`!important`)})},UN=!1;if(typeof window<`u`)try{var WN=Object.defineProperty({},"passive",{get:function(){return UN=!0,!0}});window.addEventListener(`test`,WN,WN),window.removeEventListener(`test`,WN,WN)}catch{UN=!1}var GN=UN?{passive:!1}:!1,KN=function(e){return e.tagName===`TEXTAREA`},qN=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!KN(e)&&n[t]===`visible`)},JN=function(e){return qN(e,`overflowY`)},YN=function(e){return qN(e,`overflowX`)},XN=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),$N(e,r)){var i=eP(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},ZN=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},QN=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},$N=function(e,t){return e===`v`?JN(t):YN(t)},eP=function(e,t){return e===`v`?ZN(t):QN(t)},tP=function(e,t){return e===`h`&&t===`rtl`?-1:1},nP=function(e,t,n,r,i){var a=tP(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=eP(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&$N(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},rP=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},iP=function(e){return[e.deltaX,e.deltaY]},aP=function(e){return e&&`current`in e?e.current:e},oP=function(e,t){return e[0]===t[0]&&e[1]===t[1]},sP=function(e){return`
176
+ `},HN=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},UN=function(){I.useEffect(function(){return document.body.setAttribute(BN,(HN()+1).toString()),function(){var e=HN()-1;e<=0?document.body.removeAttribute(BN):document.body.setAttribute(BN,e.toString())}},[])},WN=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;UN();var a=I.useMemo(function(){return RN(i)},[i]);return I.createElement(zN,{styles:VN(a,!t,i,n?``:`!important`)})},GN=!1;if(typeof window<`u`)try{var KN=Object.defineProperty({},"passive",{get:function(){return GN=!0,!0}});window.addEventListener(`test`,KN,KN),window.removeEventListener(`test`,KN,KN)}catch{GN=!1}var qN=GN?{passive:!1}:!1,JN=function(e){return e.tagName===`TEXTAREA`},YN=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!JN(e)&&n[t]===`visible`)},XN=function(e){return YN(e,`overflowY`)},ZN=function(e){return YN(e,`overflowX`)},QN=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),tP(e,r)){var i=nP(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},$N=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},eP=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},tP=function(e,t){return e===`v`?XN(t):ZN(t)},nP=function(e,t){return e===`v`?$N(t):eP(t)},rP=function(e,t){return e===`h`&&t===`rtl`?-1:1},iP=function(e,t,n,r,i){var a=rP(e,window.getComputedStyle(t).direction),o=a*r,s=n.target,c=t.contains(s),l=!1,u=o>0,d=0,f=0;do{if(!s)break;var p=nP(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&tP(e,s)&&(d+=h,f+=m);var g=s.parentNode;s=g&&g.nodeType===Node.DOCUMENT_FRAGMENT_NODE?g.host:g}while(!c&&s!==document.body||c&&(t.contains(s)||t===s));return(u&&(i&&Math.abs(d)<1||!i&&o>d)||!u&&(i&&Math.abs(f)<1||!i&&-o>f))&&(l=!0),l},aP=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},oP=function(e){return[e.deltaX,e.deltaY]},sP=function(e){return e&&`current`in e?e.current:e},cP=function(e,t){return e[0]===t[0]&&e[1]===t[1]},lP=function(e){return`
177
177
  .block-interactivity-${e} {pointer-events: none;}
178
178
  .allow-interactivity-${e} {pointer-events: all;}
179
- `},cP=0,lP=[];function uP(e){var t=I.useRef([]),n=I.useRef([0,0]),r=I.useRef(),i=I.useState(cP++)[0],a=I.useState(MN)[0],o=I.useRef(e);I.useEffect(function(){o.current=e},[e]),I.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=sN([e.lockRef.current],(e.shards||[]).map(aP),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=I.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=rP(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=XN(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=XN(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return nP(h,t,e,h===`h`?s:c,!0)},[]),c=I.useCallback(function(e){var n=e;if(!(!lP.length||lP[lP.length-1]!==a)){var r=`deltaY`in n?iP(n):rP(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&oP(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(aP).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=I.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:dP(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=I.useCallback(function(e){n.current=rP(e),r.current=void 0},[]),d=I.useCallback(function(t){l(t.type,iP(t),t.target,s(t,e.lockRef.current))},[]),f=I.useCallback(function(t){l(t.type,rP(t),t.target,s(t,e.lockRef.current))},[]);I.useEffect(function(){return lP.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,GN),document.addEventListener(`touchmove`,c,GN),document.addEventListener(`touchstart`,u,GN),function(){lP=lP.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,GN),document.removeEventListener(`touchmove`,c,GN),document.removeEventListener(`touchstart`,u,GN)}},[]);var p=e.removeScrollBar,m=e.inert;return I.createElement(I.Fragment,null,m?I.createElement(a,{styles:sP(i)}):null,p?I.createElement(HN,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function dP(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var fP=xN(SN,uP),pP=I.forwardRef(function(e,t){return I.createElement(wN,aN({},e,{ref:t,sideCar:fP}))});pP.classNames=wN.classNames;var mP=[`Enter`,` `],hP=[`ArrowDown`,`PageUp`,`Home`],gP=[`ArrowUp`,`PageDown`,`End`],_P=[...hP,...gP],vP={ltr:[...mP,`ArrowRight`],rtl:[...mP,`ArrowLeft`]},yP={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},bP=`Menu`,[xP,SP,CP]=oM(bP),[wP,TP]=wD(bP,[CP,DA,IM]),EP=DA(),DP=IM(),[OP,kP]=wP(bP),[AP,jP]=wP(bP),MP=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=EP(t),[c,l]=I.useState(null),u=I.useRef(!1),d=VD(a),f=cM(i);return I.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),I.useEffect(()=>{if(!n)return;let e=()=>d(!1);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,L.jsx)(UA,{...s,children:(0,L.jsx)(OP,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,L.jsx)(AP,{scope:t,onClose:I.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};MP.displayName=bP;var NP=`MenuAnchor`,PP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=EP(n);return(0,L.jsx)(WA,{...i,...r,ref:t})});PP.displayName=NP;var FP=`MenuPortal`,[IP,LP]=wP(FP,{forceMount:void 0}),RP=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=kP(FP,t);return(0,L.jsx)(IP,{scope:t,forceMount:n,children:(0,L.jsx)(XA,{present:n||a.open,children:(0,L.jsx)(JA,{asChild:!0,container:i,children:r})})})};RP.displayName=FP;var zP=`MenuContent`,[BP,VP]=wP(zP),HP=I.forwardRef((e,t)=>{let n=LP(zP,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=kP(zP,e.__scopeMenu),o=jP(zP,e.__scopeMenu);return(0,L.jsx)(xP.Provider,{scope:e.__scopeMenu,children:(0,L.jsx)(XA,{present:r||a.open,children:(0,L.jsx)(xP.Slot,{scope:e.__scopeMenu,children:o.modal?(0,L.jsx)(UP,{...i,ref:t}):(0,L.jsx)(WP,{...i,ref:t})})})})}),UP=I.forwardRef((e,t)=>{let n=kP(zP,e.__scopeMenu),r=I.useRef(null),i=CD(t,r);return I.useEffect(()=>{let e=r.current;if(e)return iN(e)},[]),(0,L.jsx)(KP,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:bD(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),WP=I.forwardRef((e,t)=>{let n=kP(zP,e.__scopeMenu);return(0,L.jsx)(KP,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),GP=ED(`MenuContent.ScrollLock`),KP=I.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=kP(zP,n),_=jP(zP,n),v=EP(n),y=DP(n),b=SP(n),[x,S]=I.useState(null),C=I.useRef(null),w=CD(t,C,g.onContentChange),T=I.useRef(0),E=I.useRef(``),D=I.useRef(0),O=I.useRef(null),k=I.useRef(`right`),A=I.useRef(0),j=m?pP:I.Fragment,M=m?{as:GP,allowPinchZoom:!0}:void 0,N=e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=AF(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};I.useEffect(()=>()=>window.clearTimeout(T.current),[]),dM();let P=I.useCallback(e=>k.current===O.current?.side&&MF(e,O.current?.area),[]);return(0,L.jsx)(BP,{scope:n,searchRef:E,onItemEnter:I.useCallback(e=>{P(e)&&e.preventDefault()},[P]),onItemLeave:I.useCallback(e=>{P(e)||(C.current?.focus(),S(null))},[P]),onTriggerLeave:I.useCallback(e=>{P(e)&&e.preventDefault()},[P]),pointerGraceTimerRef:D,onPointerGraceIntentChange:I.useCallback(e=>{O.current=e},[]),children:(0,L.jsx)(j,{...M,children:(0,L.jsx)(_M,{asChild:!0,trapped:i,onMountAutoFocus:bD(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,L.jsx)(QD,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,L.jsx)(JM,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:bD(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,L.jsx)(GA,{role:`menu`,"aria-orientation":`vertical`,"data-state":TF(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:bD(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&N(e.key));let i=C.current;if(e.target!==i||!_P.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);gP.includes(e.key)&&a.reverse(),OF(a)}),onBlur:bD(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:bD(e.onPointerMove,NF(e=>{let t=e.target,n=A.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>A.current?`right`:`left`;k.current=t,A.current=e.clientX}}))})})})})})})});HP.displayName=zP;var qP=`MenuGroup`,JP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(zD.div,{role:`group`,...r,ref:t})});JP.displayName=qP;var YP=`MenuLabel`,XP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(zD.div,{...r,ref:t})});XP.displayName=YP;var ZP=`MenuItem`,QP=`menu.itemSelect`,$P=I.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=I.useRef(null),o=jP(ZP,e.__scopeMenu),s=VP(ZP,e.__scopeMenu),c=CD(t,a),l=I.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(QP,{bubbles:!0,cancelable:!0});e.addEventListener(QP,e=>r?.(e),{once:!0}),BD(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,L.jsx)(eF,{...i,ref:c,disabled:n,onClick:bD(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:bD(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:bD(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||mP.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});$P.displayName=ZP;var eF=I.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=VP(ZP,n),s=DP(n),c=I.useRef(null),l=CD(t,c),[u,d]=I.useState(!1),[f,p]=I.useState(``);return I.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,L.jsx)(xP.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,L.jsx)(YM,{asChild:!0,...s,focusable:!r,children:(0,L.jsx)(zD.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:bD(e.onPointerMove,NF(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:bD(e.onPointerLeave,NF(e=>o.onItemLeave(e))),onFocus:bD(e.onFocus,()=>d(!0)),onBlur:bD(e.onBlur,()=>d(!1))})})})}),tF=`MenuCheckboxItem`,nF=I.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,L.jsx)(uF,{scope:e.__scopeMenu,checked:n,children:(0,L.jsx)($P,{role:`menuitemcheckbox`,"aria-checked":EF(n)?`mixed`:n,...i,ref:t,"data-state":DF(n),onSelect:bD(i.onSelect,()=>r?.(EF(n)?!0:!n),{checkForDefaultPrevented:!1})})})});nF.displayName=tF;var rF=`MenuRadioGroup`,[iF,aF]=wP(rF,{value:void 0,onValueChange:()=>{}}),oF=I.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=VD(r);return(0,L.jsx)(iF,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,L.jsx)(JP,{...i,ref:t})})});oF.displayName=rF;var sF=`MenuRadioItem`,cF=I.forwardRef((e,t)=>{let{value:n,...r}=e,i=aF(sF,e.__scopeMenu),a=n===i.value;return(0,L.jsx)(uF,{scope:e.__scopeMenu,checked:a,children:(0,L.jsx)($P,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":DF(a),onSelect:bD(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});cF.displayName=sF;var lF=`MenuItemIndicator`,[uF,dF]=wP(lF,{checked:!1}),fF=I.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=dF(lF,n);return(0,L.jsx)(XA,{present:r||EF(a.checked)||a.checked===!0,children:(0,L.jsx)(zD.span,{...i,ref:t,"data-state":DF(a.checked)})})});fF.displayName=lF;var pF=`MenuSeparator`,mF=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(zD.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});mF.displayName=pF;var hF=`MenuArrow`,gF=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=EP(n);return(0,L.jsx)(KA,{...i,...r,ref:t})});gF.displayName=hF;var _F=`MenuSub`,[vF,yF]=wP(_F),bF=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=kP(_F,t),o=EP(t),[s,c]=I.useState(null),[l,u]=I.useState(null),d=VD(i);return I.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,L.jsx)(UA,{...o,children:(0,L.jsx)(OP,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,L.jsx)(vF,{scope:t,contentId:cO(),triggerId:cO(),trigger:s,onTriggerChange:c,children:n})})})};bF.displayName=_F;var xF=`MenuSubTrigger`,SF=I.forwardRef((e,t)=>{let n=kP(xF,e.__scopeMenu),r=jP(xF,e.__scopeMenu),i=yF(xF,e.__scopeMenu),a=VP(xF,e.__scopeMenu),o=I.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=I.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);I.useEffect(()=>u,[u]),I.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]);let d=CD(t,i.onTriggerChange);return(0,L.jsx)(PP,{asChild:!0,...l,children:(0,L.jsx)(eF,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":TF(n.open),...e,ref:d,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:bD(e.onPointerMove,NF(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:bD(e.onPointerLeave,NF(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:bD(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||vP[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});SF.displayName=xF;var CF=`MenuSubContent`,wF=I.forwardRef((e,t)=>{let n=LP(zP,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=kP(zP,e.__scopeMenu),s=jP(zP,e.__scopeMenu),c=yF(CF,e.__scopeMenu),l=I.useRef(null),u=CD(t,l);return(0,L.jsx)(xP.Provider,{scope:e.__scopeMenu,children:(0,L.jsx)(XA,{present:r||o.open,children:(0,L.jsx)(xP.Slot,{scope:e.__scopeMenu,children:(0,L.jsx)(KP,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:u,align:i,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:bD(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:bD(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:bD(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=yP[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})});wF.displayName=CF;function TF(e){return e?`open`:`closed`}function EF(e){return e===`indeterminate`}function DF(e){return EF(e)?`indeterminate`:e?`checked`:`unchecked`}function OF(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function kF(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function AF(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=kF(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function jF(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function MF(e,t){return t?jF({x:e.clientX,y:e.clientY},t):!1}function NF(e){return t=>t.pointerType===`mouse`?e(t):void 0}var PF=MP,FF=PP,IF=RP,LF=HP,RF=JP,zF=XP,BF=$P,VF=nF,HF=oF,UF=cF,WF=fF,GF=mF,KF=gF,qF=SF,JF=wF,YF=`DropdownMenu`,[XF,ZF]=wD(YF,[TP]),QF=TP(),[$F,eI]=XF(YF),tI=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=QF(t),l=I.useRef(null),[u,d]=rj({prop:i,defaultProp:a??!1,onChange:o,caller:YF});return(0,L.jsx)($F,{scope:t,triggerId:cO(),triggerRef:l,contentId:cO(),open:u,onOpenChange:d,onOpenToggle:I.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,L.jsx)(PF,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};tI.displayName=YF;var nI=`DropdownMenuTrigger`,rI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=eI(nI,n),o=QF(n),s=CD(t,a.triggerRef);return(0,L.jsx)(FF,{asChild:!0,...o,children:(0,L.jsx)(zD.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:bD(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:bD(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});rI.displayName=nI;var iI=`DropdownMenuPortal`,aI=e=>{let{__scopeDropdownMenu:t,...n}=e,r=QF(t);return(0,L.jsx)(IF,{...r,...n})};aI.displayName=iI;var oI=`DropdownMenuContent`,sI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=eI(oI,n),a=QF(n),o=I.useRef(!1);return(0,L.jsx)(LF,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:bD(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:bD(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});sI.displayName=oI;var cI=`DropdownMenuGroup`,lI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=QF(n);return(0,L.jsx)(RF,{...i,...r,ref:t})});lI.displayName=cI;var uI=`DropdownMenuLabel`,dI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=QF(n);return(0,L.jsx)(zF,{...i,...r,ref:t})});dI.displayName=uI;var fI=`DropdownMenuItem`,pI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=QF(n);return(0,L.jsx)(BF,{...i,...r,ref:t})});pI.displayName=fI;var mI=`DropdownMenuCheckboxItem`,hI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=QF(n);return(0,L.jsx)(VF,{...i,...r,ref:t})});hI.displayName=mI;var gI=`DropdownMenuRadioGroup`,_I=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=QF(n);return(0,L.jsx)(HF,{...i,...r,ref:t})});_I.displayName=gI;var vI=`DropdownMenuRadioItem`,yI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=QF(n);return(0,L.jsx)(UF,{...i,...r,ref:t})});yI.displayName=vI;var bI=`DropdownMenuItemIndicator`,xI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=QF(n);return(0,L.jsx)(WF,{...i,...r,ref:t})});xI.displayName=bI;var SI=`DropdownMenuSeparator`,CI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=QF(n);return(0,L.jsx)(GF,{...i,...r,ref:t})});CI.displayName=SI;var wI=`DropdownMenuArrow`,TI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=QF(n);return(0,L.jsx)(KF,{...i,...r,ref:t})});TI.displayName=wI;var EI=`DropdownMenuSubTrigger`,DI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=QF(n);return(0,L.jsx)(qF,{...i,...r,ref:t})});DI.displayName=EI;var OI=`DropdownMenuSubContent`,kI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=QF(n);return(0,L.jsx)(JF,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});kI.displayName=OI;var AI=tI,jI=rI,MI=aI,NI=sI,PI=lI,FI=dI,II=pI,LI=_I,RI=yI,zI=xI,BI=CI;function VI({modal:e=!1,...t}){return(0,L.jsx)(AI,{modal:e,...t})}var HI=jI;function UI({children:e,align:t=`end`,sideOffset:n=6}){return(0,L.jsx)(MI,{children:(0,L.jsx)(NI,{align:t,sideOffset:n,className:`${Qj} min-w-[184px] overflow-hidden rounded-lg p-1`,children:e})})}function WI({children:e,onSelect:t,icon:n,danger:r}){return(0,L.jsxs)(II,{onSelect:t,className:`flex cursor-pointer select-none items-center gap-2 rounded-md px-2.5 py-1.5 text-[12px] outline-none transition-colors data-[highlighted]:bg-panel-2 ${r?`text-red-400 data-[highlighted]:text-red-300`:`text-muted data-[highlighted]:text-fg`}`,children:[n&&(0,L.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:n}),e]})}function GI(){return(0,L.jsx)(BI,{className:`my-1 h-px bg-border`})}var KI=(0,I.memo)(function({slug:e,size:t=`md`,onDone:n,doneBusy:r,onMutateStart:i,onApplied:a,onFailed:o}){let[s,c]=(0,I.useState)(`done`),[l,u]=(0,I.useState)(!1),d=(s===`done`&&n?r:l)??!1,f=()=>{if(i?.(),s===`done`&&n)return n();u(!0),Y.setThreadStatus({slug:e,status:s}).then(()=>{Z(`Status → ${s}`),a?.()}).catch(()=>o?.()).finally(()=>u(!1))},p=t===`sm`;return(0,L.jsxs)(`div`,{className:`flex items-stretch overflow-hidden rounded-md border border-border-strong`,children:[(0,L.jsxs)(`button`,{onClick:f,disabled:d,onMouseDown:e=>e.preventDefault(),className:`flex items-center bg-panel-2 font-medium text-fg transition-colors hover:bg-elevated disabled:opacity-50 ${p?`gap-1 px-1.5 text-[11px]`:`gap-1.5 px-2.5 py-1 text-[12px]`}`,children:[d&&(0,L.jsx)(Xm,{size:p?11:12,className:`animate-spin`}),`Mark as `,s]}),(0,L.jsxs)(VI,{children:[(0,L.jsx)(HI,{"aria-label":`Set status…`,className:`flex items-center border-l border-border-strong bg-panel-2 text-muted outline-none transition-colors hover:bg-elevated hover:text-fg data-[state=open]:bg-elevated data-[state=open]:text-fg ${p?`px-1`:`px-1.5`}`,children:(0,L.jsx)(_m,{size:p?11:12})}),(0,L.jsx)(UI,{children:xT.map(e=>(0,L.jsxs)(WI,{onSelect:()=>c(e),children:[`Mark as `,e]},e))})]})]})}),qI=`Dialog`,[JI,YI]=wD(qI),[XI,ZI]=JI(qI),QI=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=I.useRef(null),c=I.useRef(null),[l,u]=rj({prop:r,defaultProp:i??!1,onChange:a,caller:qI});return(0,L.jsx)(XI,{scope:t,triggerRef:s,contentRef:c,contentId:cO(),titleId:cO(),descriptionId:cO(),open:l,onOpenChange:u,onOpenToggle:I.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};QI.displayName=qI;var $I=`DialogTrigger`,eL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ZI($I,n),a=CD(t,i.triggerRef);return(0,L.jsx)(zD.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":bL(i.open),...r,ref:a,onClick:bD(e.onClick,i.onOpenToggle)})});eL.displayName=$I;var tL=`DialogPortal`,[nL,rL]=JI(tL,{forceMount:void 0}),iL=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=ZI(tL,t);return(0,L.jsx)(nL,{scope:t,forceMount:n,children:I.Children.map(r,e=>(0,L.jsx)(XA,{present:n||a.open,children:(0,L.jsx)(JA,{asChild:!0,container:i,children:e})}))})};iL.displayName=tL;var aL=`DialogOverlay`,oL=I.forwardRef((e,t)=>{let n=rL(aL,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ZI(aL,e.__scopeDialog);return a.modal?(0,L.jsx)(XA,{present:r||a.open,children:(0,L.jsx)(cL,{...i,ref:t})}):null});oL.displayName=aL;var sL=ED(`DialogOverlay.RemoveScroll`),cL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ZI(aL,n),a=CD(t,tO());return(0,L.jsx)(pP,{as:sL,allowPinchZoom:!0,shards:[i.contentRef],children:(0,L.jsx)(zD.div,{"data-state":bL(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})}),lL=`DialogContent`,uL=I.forwardRef((e,t)=>{let n=rL(lL,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=ZI(lL,e.__scopeDialog);return(0,L.jsx)(XA,{present:r||a.open,children:a.modal?(0,L.jsx)(dL,{...i,ref:t}):(0,L.jsx)(fL,{...i,ref:t})})});uL.displayName=lL;var dL=I.forwardRef((e,t)=>{let n=ZI(lL,e.__scopeDialog),r=I.useRef(null),i=CD(t,n.contentRef,r);return I.useEffect(()=>{let e=r.current;if(e)return iN(e)},[]),(0,L.jsx)(pL,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:bD(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:bD(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:bD(e.onFocusOutside,e=>e.preventDefault())})}),fL=I.forwardRef((e,t)=>{let n=ZI(lL,e.__scopeDialog),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(pL,{...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()}})}),pL=I.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=ZI(lL,n);return dM(),(0,L.jsx)(L.Fragment,{children:(0,L.jsx)(_M,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(QD,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":bL(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),mL=`DialogTitle`,hL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ZI(mL,n);return(0,L.jsx)(zD.h2,{id:i.titleId,...r,ref:t})});hL.displayName=mL;var gL=`DialogDescription`,_L=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ZI(gL,n);return(0,L.jsx)(zD.p,{id:i.descriptionId,...r,ref:t})});_L.displayName=gL;var vL=`DialogClose`,yL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=ZI(vL,n);return(0,L.jsx)(zD.button,{type:`button`,...r,ref:t,onClick:bD(e.onClick,()=>i.onOpenChange(!1))})});yL.displayName=vL;function bL(e){return e?`open`:`closed`}var xL=new Set([`artifact-template`,`code-comment`,`created-thread`,`git-stage`,`git-commit`,`git-create-branch`,`git-push`,`git-create-pr`,`archive`,`archive-thread`,`automation-update`]),SL=/[a-zA-Z_][a-zA-Z0-9_-]*/y,CL=/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/;function wL(e){let t={},n=0;for(;n<e.length;){for(;/\s/.test(e[n]??``);)n++;if(n>=e.length)break;SL.lastIndex=n;let r=SL.exec(e);if(!r||Object.hasOwn(t,r[0]))return null;let i=r[0];if(n=SL.lastIndex,e[n]!==`=`)return null;if(n++,e[n]===`"`){let r=n;n++;let a=!1;for(;n<e.length;){let t=e[n++];if(a)a=!1;else if(t===`\\`)a=!0;else if(t===`"`)break}if(e[n-1]!==`"`)return null;try{t[i]=JSON.parse(e.slice(r,n))}catch{return null}}else{let r=n;for(;n<e.length&&!/\s/.test(e[n]);)n++;let a=e.slice(r,n);if(a===`true`||a===`false`)t[i]=a===`true`;else if(CL.test(a))t[i]=Number(a);else return null}if(n<e.length&&!/\s/.test(e[n]))return null}return t}function TL(e){let t=e.match(/^\s*::([a-z][a-z0-9-]*)\{([^\n]*)\}\s*$/);if(!t||!xL.has(t[1]))return null;let n=wL(t[2]);return n?{name:t[1],attrs:n}:null}var EL=String.raw`(?:[^\s\`]|[ ](?!/))+`,DL=new RegExp(String.raw`^\s*\`?(/${EL}\.(?:png|jpe?g|gif|webp))\`?\s*$`,`i`),OL=new RegExp(String.raw`^\s*\`?(/${EL}\.(?:${Ic.join(`|`)}))\`?\s*$`,`i`),kL=/^\s{0,3}(?:```|~~~)/,AL=/^\s{0,3}(`{3,}|~{3,})\s*mermaid\s*$/i,jL=/^\s*::codex-inline-vis\{file="([a-z0-9][a-z0-9-]{0,127}\.html)"\}\s*$/;function ML(e){let t=e.split(`
179
+ `},uP=0,dP=[];function fP(e){var t=I.useRef([]),n=I.useRef([0,0]),r=I.useRef(),i=I.useState(uP++)[0],a=I.useState(PN)[0],o=I.useRef(e);I.useEffect(function(){o.current=e},[e]),I.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=lN([e.lockRef.current],(e.shards||[]).map(sP),!0).filter(Boolean);return t.forEach(function(e){return e.classList.add(`allow-interactivity-${i}`)}),function(){document.body.classList.remove(`block-interactivity-${i}`),t.forEach(function(e){return e.classList.remove(`allow-interactivity-${i}`)})}}},[e.inert,e.lockRef.current,e.shards]);var s=I.useCallback(function(e,t){if(`touches`in e&&e.touches.length===2||e.type===`wheel`&&e.ctrlKey)return!o.current.allowPinchZoom;var i=aP(e),a=n.current,s=`deltaX`in e?e.deltaX:a[0]-i[0],c=`deltaY`in e?e.deltaY:a[1]-i[1],l,u=e.target,d=Math.abs(s)>Math.abs(c)?`h`:`v`;if(`touches`in e&&d===`h`&&u.type===`range`)return!1;var f=window.getSelection(),p=f&&f.anchorNode;if(p&&(p===u||p.contains(u)))return!1;var m=QN(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=QN(d,u)),!m)return!1;if(!r.current&&`changedTouches`in e&&(s||c)&&(r.current=l),!l)return!0;var h=r.current||l;return iP(h,t,e,h===`h`?s:c,!0)},[]),c=I.useCallback(function(e){var n=e;if(!(!dP.length||dP[dP.length-1]!==a)){var r=`deltaY`in n?oP(n):aP(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&cP(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(sP).filter(Boolean).filter(function(e){return e.contains(n.target)});(c.length>0?s(n,c[0]):!o.current.noIsolation)&&n.cancelable&&n.preventDefault()}}},[]),l=I.useCallback(function(e,n,r,i){var a={name:e,delta:n,target:r,should:i,shadowParent:pP(r)};t.current.push(a),setTimeout(function(){t.current=t.current.filter(function(e){return e!==a})},1)},[]),u=I.useCallback(function(e){n.current=aP(e),r.current=void 0},[]),d=I.useCallback(function(t){l(t.type,oP(t),t.target,s(t,e.lockRef.current))},[]),f=I.useCallback(function(t){l(t.type,aP(t),t.target,s(t,e.lockRef.current))},[]);I.useEffect(function(){return dP.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,qN),document.addEventListener(`touchmove`,c,qN),document.addEventListener(`touchstart`,u,qN),function(){dP=dP.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,qN),document.removeEventListener(`touchmove`,c,qN),document.removeEventListener(`touchstart`,u,qN)}},[]);var p=e.removeScrollBar,m=e.inert;return I.createElement(I.Fragment,null,m?I.createElement(a,{styles:lP(i)}):null,p?I.createElement(WN,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function pP(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var mP=CN(wN,fP),hP=I.forwardRef(function(e,t){return I.createElement(EN,sN({},e,{ref:t,sideCar:mP}))});hP.classNames=EN.classNames;var gP=[`Enter`,` `],_P=[`ArrowDown`,`PageUp`,`Home`],vP=[`ArrowUp`,`PageDown`,`End`],yP=[..._P,...vP],bP={ltr:[...gP,`ArrowRight`],rtl:[...gP,`ArrowLeft`]},xP={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},SP=`Menu`,[CP,wP,TP]=cM(SP),[EP,DP]=ED(SP,[TP,kA,RM]),OP=kA(),kP=RM(),[AP,jP]=EP(SP),[MP,NP]=EP(SP),PP=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=OP(t),[c,l]=I.useState(null),u=I.useRef(!1),d=UD(a),f=uM(i);return I.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),I.useEffect(()=>{if(!n)return;let e=()=>d(!1);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,L.jsx)(GA,{...s,children:(0,L.jsx)(AP,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,L.jsx)(MP,{scope:t,onClose:I.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};PP.displayName=SP;var FP=`MenuAnchor`,IP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=OP(n);return(0,L.jsx)(KA,{...i,...r,ref:t})});IP.displayName=FP;var LP=`MenuPortal`,[RP,zP]=EP(LP,{forceMount:void 0}),BP=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=jP(LP,t);return(0,L.jsx)(RP,{scope:t,forceMount:n,children:(0,L.jsx)(QA,{present:n||a.open,children:(0,L.jsx)(XA,{asChild:!0,container:i,children:r})})})};BP.displayName=LP;var VP=`MenuContent`,[HP,UP]=EP(VP),WP=I.forwardRef((e,t)=>{let n=zP(VP,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=jP(VP,e.__scopeMenu),o=NP(VP,e.__scopeMenu);return(0,L.jsx)(CP.Provider,{scope:e.__scopeMenu,children:(0,L.jsx)(QA,{present:r||a.open,children:(0,L.jsx)(CP.Slot,{scope:e.__scopeMenu,children:o.modal?(0,L.jsx)(GP,{...i,ref:t}):(0,L.jsx)(KP,{...i,ref:t})})})})}),GP=I.forwardRef((e,t)=>{let n=jP(VP,e.__scopeMenu),r=I.useRef(null),i=TD(t,r);return I.useEffect(()=>{let e=r.current;if(e)return oN(e)},[]),(0,L.jsx)(JP,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:SD(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),KP=I.forwardRef((e,t)=>{let n=jP(VP,e.__scopeMenu);return(0,L.jsx)(JP,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),qP=OD(`MenuContent.ScrollLock`),JP=I.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:c,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,disableOutsideScroll:m,...h}=e,g=jP(VP,n),_=NP(VP,n),v=OP(n),y=kP(n),b=wP(n),[x,S]=I.useState(null),C=I.useRef(null),w=TD(t,C,g.onContentChange),T=I.useRef(0),E=I.useRef(``),D=I.useRef(0),O=I.useRef(null),k=I.useRef(`right`),A=I.useRef(0),j=m?hP:I.Fragment,M=m?{as:qP,allowPinchZoom:!0}:void 0,N=e=>{let t=E.current+e,n=b().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=MF(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};I.useEffect(()=>()=>window.clearTimeout(T.current),[]),pM();let P=I.useCallback(e=>k.current===O.current?.side&&PF(e,O.current?.area),[]);return(0,L.jsx)(HP,{scope:n,searchRef:E,onItemEnter:I.useCallback(e=>{P(e)&&e.preventDefault()},[P]),onItemLeave:I.useCallback(e=>{P(e)||(C.current?.focus(),S(null))},[P]),onTriggerLeave:I.useCallback(e=>{P(e)&&e.preventDefault()},[P]),pointerGraceTimerRef:D,onPointerGraceIntentChange:I.useCallback(e=>{O.current=e},[]),children:(0,L.jsx)(j,{...M,children:(0,L.jsx)(yM,{asChild:!0,trapped:i,onMountAutoFocus:SD(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,L.jsx)(eO,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,L.jsx)(XM,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:SD(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,L.jsx)(qA,{role:`menu`,"aria-orientation":`vertical`,"data-state":DF(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:SD(h.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&N(e.key));let i=C.current;if(e.target!==i||!yP.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);vP.includes(e.key)&&a.reverse(),AF(a)}),onBlur:SD(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:SD(e.onPointerMove,FF(e=>{let t=e.target,n=A.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>A.current?`right`:`left`;k.current=t,A.current=e.clientX}}))})})})})})})});WP.displayName=VP;var YP=`MenuGroup`,XP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(VD.div,{role:`group`,...r,ref:t})});XP.displayName=YP;var ZP=`MenuLabel`,QP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(VD.div,{...r,ref:t})});QP.displayName=ZP;var $P=`MenuItem`,eF=`menu.itemSelect`,tF=I.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=I.useRef(null),o=NP($P,e.__scopeMenu),s=UP($P,e.__scopeMenu),c=TD(t,a),l=I.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(eF,{bubbles:!0,cancelable:!0});e.addEventListener(eF,e=>r?.(e),{once:!0}),HD(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,L.jsx)(nF,{...i,ref:c,disabled:n,onClick:SD(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:SD(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:SD(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||gP.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});tF.displayName=$P;var nF=I.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=UP($P,n),s=kP(n),c=I.useRef(null),l=TD(t,c),[u,d]=I.useState(!1),[f,p]=I.useState(``);return I.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,L.jsx)(CP.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,L.jsx)(ZM,{asChild:!0,...s,focusable:!r,children:(0,L.jsx)(VD.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:SD(e.onPointerMove,FF(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:SD(e.onPointerLeave,FF(e=>o.onItemLeave(e))),onFocus:SD(e.onFocus,()=>d(!0)),onBlur:SD(e.onBlur,()=>d(!1))})})})}),rF=`MenuCheckboxItem`,iF=I.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,L.jsx)(fF,{scope:e.__scopeMenu,checked:n,children:(0,L.jsx)(tF,{role:`menuitemcheckbox`,"aria-checked":OF(n)?`mixed`:n,...i,ref:t,"data-state":kF(n),onSelect:SD(i.onSelect,()=>r?.(OF(n)?!0:!n),{checkForDefaultPrevented:!1})})})});iF.displayName=rF;var aF=`MenuRadioGroup`,[oF,sF]=EP(aF,{value:void 0,onValueChange:()=>{}}),cF=I.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=UD(r);return(0,L.jsx)(oF,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,L.jsx)(XP,{...i,ref:t})})});cF.displayName=aF;var lF=`MenuRadioItem`,uF=I.forwardRef((e,t)=>{let{value:n,...r}=e,i=sF(lF,e.__scopeMenu),a=n===i.value;return(0,L.jsx)(fF,{scope:e.__scopeMenu,checked:a,children:(0,L.jsx)(tF,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":kF(a),onSelect:SD(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});uF.displayName=lF;var dF=`MenuItemIndicator`,[fF,pF]=EP(dF,{checked:!1}),mF=I.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=pF(dF,n);return(0,L.jsx)(QA,{present:r||OF(a.checked)||a.checked===!0,children:(0,L.jsx)(VD.span,{...i,ref:t,"data-state":kF(a.checked)})})});mF.displayName=dF;var hF=`MenuSeparator`,gF=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(VD.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});gF.displayName=hF;var _F=`MenuArrow`,vF=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=OP(n);return(0,L.jsx)(JA,{...i,...r,ref:t})});vF.displayName=_F;var yF=`MenuSub`,[bF,xF]=EP(yF),SF=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=jP(yF,t),o=OP(t),[s,c]=I.useState(null),[l,u]=I.useState(null),d=UD(i);return I.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,L.jsx)(GA,{...o,children:(0,L.jsx)(AP,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,L.jsx)(bF,{scope:t,contentId:uO(),triggerId:uO(),trigger:s,onTriggerChange:c,children:n})})})};SF.displayName=yF;var CF=`MenuSubTrigger`,wF=I.forwardRef((e,t)=>{let n=jP(CF,e.__scopeMenu),r=NP(CF,e.__scopeMenu),i=xF(CF,e.__scopeMenu),a=UP(CF,e.__scopeMenu),o=I.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:c}=a,l={__scopeMenu:e.__scopeMenu},u=I.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);I.useEffect(()=>u,[u]),I.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),c(null)}},[s,c]);let d=TD(t,i.onTriggerChange);return(0,L.jsx)(IP,{asChild:!0,...l,children:(0,L.jsx)(nF,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":DF(n.open),...e,ref:d,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:SD(e.onPointerMove,FF(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),u()},100))})),onPointerLeave:SD(e.onPointerLeave,FF(e=>{u();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:SD(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||bP[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});wF.displayName=CF;var TF=`MenuSubContent`,EF=I.forwardRef((e,t)=>{let n=zP(VP,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=jP(VP,e.__scopeMenu),s=NP(VP,e.__scopeMenu),c=xF(TF,e.__scopeMenu),l=I.useRef(null),u=TD(t,l);return(0,L.jsx)(CP.Provider,{scope:e.__scopeMenu,children:(0,L.jsx)(QA,{present:r||o.open,children:(0,L.jsx)(CP.Slot,{scope:e.__scopeMenu,children:(0,L.jsx)(JP,{id:c.contentId,"aria-labelledby":c.triggerId,...a,ref:u,align:i,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&l.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:SD(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:SD(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:SD(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=xP[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})});EF.displayName=TF;function DF(e){return e?`open`:`closed`}function OF(e){return e===`indeterminate`}function kF(e){return OF(e)?`indeterminate`:e?`checked`:`unchecked`}function AF(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function jF(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function MF(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=jF(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function NF(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function PF(e,t){return t?NF({x:e.clientX,y:e.clientY},t):!1}function FF(e){return t=>t.pointerType===`mouse`?e(t):void 0}var IF=PP,LF=IP,RF=BP,zF=WP,BF=XP,VF=QP,HF=tF,UF=iF,WF=cF,GF=uF,KF=mF,qF=gF,JF=vF,YF=wF,XF=EF,ZF=`DropdownMenu`,[QF,$F]=ED(ZF,[DP]),eI=DP(),[tI,nI]=QF(ZF),rI=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=eI(t),l=I.useRef(null),[u,d]=aj({prop:i,defaultProp:a??!1,onChange:o,caller:ZF});return(0,L.jsx)(tI,{scope:t,triggerId:uO(),triggerRef:l,contentId:uO(),open:u,onOpenChange:d,onOpenToggle:I.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,L.jsx)(IF,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};rI.displayName=ZF;var iI=`DropdownMenuTrigger`,aI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=nI(iI,n),o=eI(n),s=TD(t,a.triggerRef);return(0,L.jsx)(LF,{asChild:!0,...o,children:(0,L.jsx)(VD.button,{type:`button`,id:a.triggerId,"aria-haspopup":`menu`,"aria-expanded":a.open,"aria-controls":a.open?a.contentId:void 0,"data-state":a.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:s,onPointerDown:SD(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:SD(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});aI.displayName=iI;var oI=`DropdownMenuPortal`,sI=e=>{let{__scopeDropdownMenu:t,...n}=e,r=eI(t);return(0,L.jsx)(RF,{...r,...n})};sI.displayName=oI;var cI=`DropdownMenuContent`,lI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=nI(cI,n),a=eI(n),o=I.useRef(!1);return(0,L.jsx)(zF,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:SD(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:SD(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});lI.displayName=cI;var uI=`DropdownMenuGroup`,dI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=eI(n);return(0,L.jsx)(BF,{...i,...r,ref:t})});dI.displayName=uI;var fI=`DropdownMenuLabel`,pI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=eI(n);return(0,L.jsx)(VF,{...i,...r,ref:t})});pI.displayName=fI;var mI=`DropdownMenuItem`,hI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=eI(n);return(0,L.jsx)(HF,{...i,...r,ref:t})});hI.displayName=mI;var gI=`DropdownMenuCheckboxItem`,_I=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=eI(n);return(0,L.jsx)(UF,{...i,...r,ref:t})});_I.displayName=gI;var vI=`DropdownMenuRadioGroup`,yI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=eI(n);return(0,L.jsx)(WF,{...i,...r,ref:t})});yI.displayName=vI;var bI=`DropdownMenuRadioItem`,xI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=eI(n);return(0,L.jsx)(GF,{...i,...r,ref:t})});xI.displayName=bI;var SI=`DropdownMenuItemIndicator`,CI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=eI(n);return(0,L.jsx)(KF,{...i,...r,ref:t})});CI.displayName=SI;var wI=`DropdownMenuSeparator`,TI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=eI(n);return(0,L.jsx)(qF,{...i,...r,ref:t})});TI.displayName=wI;var EI=`DropdownMenuArrow`,DI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=eI(n);return(0,L.jsx)(JF,{...i,...r,ref:t})});DI.displayName=EI;var OI=`DropdownMenuSubTrigger`,kI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=eI(n);return(0,L.jsx)(YF,{...i,...r,ref:t})});kI.displayName=OI;var AI=`DropdownMenuSubContent`,jI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=eI(n);return(0,L.jsx)(XF,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});jI.displayName=AI;var MI=rI,NI=aI,PI=sI,FI=lI,II=dI,LI=pI,RI=hI,zI=yI,BI=xI,VI=CI,HI=TI;function UI({modal:e=!1,...t}){return(0,L.jsx)(MI,{modal:e,...t})}var WI=NI;function GI({children:e,align:t=`end`,sideOffset:n=6}){return(0,L.jsx)(PI,{children:(0,L.jsx)(FI,{align:t,sideOffset:n,className:`${eM} min-w-[184px] overflow-hidden rounded-lg p-1`,children:e})})}function KI({children:e,onSelect:t,icon:n,danger:r}){return(0,L.jsxs)(RI,{onSelect:t,className:`flex cursor-pointer select-none items-center gap-2 rounded-md px-2.5 py-1.5 text-[12px] outline-none transition-colors data-[highlighted]:bg-panel-2 ${r?`text-red-400 data-[highlighted]:text-red-300`:`text-muted data-[highlighted]:text-fg`}`,children:[n&&(0,L.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:n}),e]})}function qI(){return(0,L.jsx)(HI,{className:`my-1 h-px bg-border`})}var JI=(0,I.memo)(function({slug:e,size:t=`md`,onDone:n,doneBusy:r,onMutateStart:i,onApplied:a,onFailed:o}){let[s,c]=(0,I.useState)(`done`),[l,u]=(0,I.useState)(!1),d=(s===`done`&&n?r:l)??!1,f=()=>{if(i?.(),s===`done`&&n)return n();u(!0),Y.setThreadStatus({slug:e,status:s}).then(()=>{Z(`Status → ${s}`),a?.()}).catch(()=>o?.()).finally(()=>u(!1))},p=t===`sm`;return(0,L.jsxs)(`div`,{className:`flex items-stretch overflow-hidden rounded-md border border-border-strong`,children:[(0,L.jsxs)(`button`,{onClick:f,disabled:d,onMouseDown:e=>e.preventDefault(),className:`flex items-center bg-panel-2 font-medium text-fg transition-colors hover:bg-elevated disabled:opacity-50 ${p?`gap-1 px-1.5 text-[11px]`:`gap-1.5 px-2.5 py-1 text-[12px]`}`,children:[d&&(0,L.jsx)(Xm,{size:p?11:12,className:`animate-spin`}),`Mark as `,s]}),(0,L.jsxs)(UI,{children:[(0,L.jsx)(WI,{"aria-label":`Set status…`,className:`flex items-center border-l border-border-strong bg-panel-2 text-muted outline-none transition-colors hover:bg-elevated hover:text-fg data-[state=open]:bg-elevated data-[state=open]:text-fg ${p?`px-1`:`px-1.5`}`,children:(0,L.jsx)(_m,{size:p?11:12})}),(0,L.jsx)(GI,{children:xT.map(e=>(0,L.jsxs)(KI,{onSelect:()=>c(e),children:[`Mark as `,e]},e))})]})]})}),YI=`Dialog`,[XI,ZI]=ED(YI),[QI,$I]=XI(YI),eL=e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=I.useRef(null),c=I.useRef(null),[l,u]=aj({prop:r,defaultProp:i??!1,onChange:a,caller:YI});return(0,L.jsx)(QI,{scope:t,triggerRef:s,contentRef:c,contentId:uO(),titleId:uO(),descriptionId:uO(),open:l,onOpenChange:u,onOpenToggle:I.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};eL.displayName=YI;var tL=`DialogTrigger`,nL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=$I(tL,n),a=TD(t,i.triggerRef);return(0,L.jsx)(VD.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":SL(i.open),...r,ref:a,onClick:SD(e.onClick,i.onOpenToggle)})});nL.displayName=tL;var rL=`DialogPortal`,[iL,aL]=XI(rL,{forceMount:void 0}),oL=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=$I(rL,t);return(0,L.jsx)(iL,{scope:t,forceMount:n,children:I.Children.map(r,e=>(0,L.jsx)(QA,{present:n||a.open,children:(0,L.jsx)(XA,{asChild:!0,container:i,children:e})}))})};oL.displayName=rL;var sL=`DialogOverlay`,cL=I.forwardRef((e,t)=>{let n=aL(sL,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=$I(sL,e.__scopeDialog);return a.modal?(0,L.jsx)(QA,{present:r||a.open,children:(0,L.jsx)(uL,{...i,ref:t})}):null});cL.displayName=sL;var lL=OD(`DialogOverlay.RemoveScroll`),uL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=$I(sL,n),a=TD(t,rO());return(0,L.jsx)(hP,{as:lL,allowPinchZoom:!0,shards:[i.contentRef],children:(0,L.jsx)(VD.div,{"data-state":SL(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})}),dL=`DialogContent`,fL=I.forwardRef((e,t)=>{let n=aL(dL,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=$I(dL,e.__scopeDialog);return(0,L.jsx)(QA,{present:r||a.open,children:a.modal?(0,L.jsx)(pL,{...i,ref:t}):(0,L.jsx)(mL,{...i,ref:t})})});fL.displayName=dL;var pL=I.forwardRef((e,t)=>{let n=$I(dL,e.__scopeDialog),r=I.useRef(null),i=TD(t,n.contentRef,r);return I.useEffect(()=>{let e=r.current;if(e)return oN(e)},[]),(0,L.jsx)(hL,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:SD(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:SD(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:SD(e.onFocusOutside,e=>e.preventDefault())})}),mL=I.forwardRef((e,t)=>{let n=$I(dL,e.__scopeDialog),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(hL,{...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()}})}),hL=I.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=$I(dL,n);return pM(),(0,L.jsx)(L.Fragment,{children:(0,L.jsx)(yM,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(eO,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":SL(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),gL=`DialogTitle`,_L=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=$I(gL,n);return(0,L.jsx)(VD.h2,{id:i.titleId,...r,ref:t})});_L.displayName=gL;var vL=`DialogDescription`,yL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=$I(vL,n);return(0,L.jsx)(VD.p,{id:i.descriptionId,...r,ref:t})});yL.displayName=vL;var bL=`DialogClose`,xL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=$I(bL,n);return(0,L.jsx)(VD.button,{type:`button`,...r,ref:t,onClick:SD(e.onClick,()=>i.onOpenChange(!1))})});xL.displayName=bL;function SL(e){return e?`open`:`closed`}var CL=new Set([`artifact-template`,`code-comment`,`created-thread`,`git-stage`,`git-commit`,`git-create-branch`,`git-push`,`git-create-pr`,`archive`,`archive-thread`,`automation-update`]),wL=/[a-zA-Z_][a-zA-Z0-9_-]*/y,TL=/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/;function EL(e){let t={},n=0;for(;n<e.length;){for(;/\s/.test(e[n]??``);)n++;if(n>=e.length)break;wL.lastIndex=n;let r=wL.exec(e);if(!r||Object.hasOwn(t,r[0]))return null;let i=r[0];if(n=wL.lastIndex,e[n]!==`=`)return null;if(n++,e[n]===`"`){let r=n;n++;let a=!1;for(;n<e.length;){let t=e[n++];if(a)a=!1;else if(t===`\\`)a=!0;else if(t===`"`)break}if(e[n-1]!==`"`)return null;try{t[i]=JSON.parse(e.slice(r,n))}catch{return null}}else{let r=n;for(;n<e.length&&!/\s/.test(e[n]);)n++;let a=e.slice(r,n);if(a===`true`||a===`false`)t[i]=a===`true`;else if(TL.test(a))t[i]=Number(a);else return null}if(n<e.length&&!/\s/.test(e[n]))return null}return t}function DL(e){let t=e.match(/^\s*::([a-z][a-z0-9-]*)\{([^\n]*)\}\s*$/);if(!t||!CL.has(t[1]))return null;let n=EL(t[2]);return n?{name:t[1],attrs:n}:null}var OL=String.raw`(?:[^\s\`]|[ ](?!/))+`,kL=new RegExp(String.raw`^\s*\`?(/${OL}\.(?:png|jpe?g|gif|webp))\`?\s*$`,`i`),AL=new RegExp(String.raw`^\s*\`?(/${OL}\.(?:${Ic.join(`|`)}))\`?\s*$`,`i`),jL=/^\s{0,3}(?:```|~~~)/,ML=/^\s{0,3}(`{3,}|~{3,})\s*mermaid\s*$/i,NL=/^\s*::codex-inline-vis\{file="([a-z0-9][a-z0-9-]{0,127}\.html)"\}\s*$/;function PL(e){let t=e.split(`
180
180
  `),n=[],r=[],i=!1,a=()=>{if(r.length){let e=r.join(`
181
- `);e.trim()&&n.push({kind:`md`,text:e}),r=[]}};for(let e=0;e<t.length;e++){let o=t[e];if(!i){let r=o.match(AL)?.[1];if(r){let i=RegExp(`^\\s{0,3}${r[0]==="`"?"`":`~`}{${r.length},}\\s*$`),o=e+1;for(;o<t.length&&!i.test(t[o]);)o++;if(o<t.length){a(),n.push({kind:`mermaid`,source:t.slice(e+1,o).join(`
182
- `)}),e=o;continue}}}if(kL.test(o)){i=!i,r.push(o);continue}if(i){r.push(o);continue}let s=o.match(jL);if(s){a(),n.push({kind:`visualization`,file:s[1]});continue}let c=TL(o);if(c){a(),n.push({kind:`directive`,directive:c});continue}let l=o.match(DL);if(l){a(),n.push({kind:`image`,path:l[1]});continue}let u=o.match(OL);if(u){a(),n.push({kind:`file`,path:u[1]});continue}r.push(o)}return a(),n}function NL(e){let t=e.split(`
183
- `),n=Array(t.length),r=!1;for(let e=0;e<t.length;e++)kL.test(t[e])?(r=!r,n[e]=!0):n[e]=r;let i=[],a=t.length;for(;a>0&&!n[a-1];){let e=t[a-1],n=e.match(DL),r=n?null:e.match(OL);if(n)i.unshift({path:n[1],kind:`image`});else if(r)i.unshift({path:r[1],kind:`file`});else break;a--}return{prose:t.slice(0,a).join(`
184
- `),attachments:i}}function PL(e,t){return t.length?`${e}${e?`
181
+ `);e.trim()&&n.push({kind:`md`,text:e}),r=[]}};for(let e=0;e<t.length;e++){let o=t[e];if(!i){let r=o.match(ML)?.[1];if(r){let i=RegExp(`^\\s{0,3}${r[0]==="`"?"`":`~`}{${r.length},}\\s*$`),o=e+1;for(;o<t.length&&!i.test(t[o]);)o++;if(o<t.length){a(),n.push({kind:`mermaid`,source:t.slice(e+1,o).join(`
182
+ `)}),e=o;continue}}}if(jL.test(o)){i=!i,r.push(o);continue}if(i){r.push(o);continue}let s=o.match(NL);if(s){a(),n.push({kind:`visualization`,file:s[1]});continue}let c=DL(o);if(c){a(),n.push({kind:`directive`,directive:c});continue}let l=o.match(kL);if(l){a(),n.push({kind:`image`,path:l[1]});continue}let u=o.match(AL);if(u){a(),n.push({kind:`file`,path:u[1]});continue}r.push(o)}return a(),n}function FL(e){let t=e.split(`
183
+ `),n=Array(t.length),r=!1;for(let e=0;e<t.length;e++)jL.test(t[e])?(r=!r,n[e]=!0):n[e]=r;let i=[],a=t.length;for(;a>0&&!n[a-1];){let e=t[a-1],n=e.match(kL),r=n?null:e.match(AL);if(n)i.unshift({path:n[1],kind:`image`});else if(r)i.unshift({path:r[1],kind:`file`});else break;a--}return{prose:t.slice(0,a).join(`
184
+ `),attachments:i}}function IL(e,t){return t.length?`${e}${e?`
185
185
  `:``}${t.join(`
186
- `)}`:e}function FL(e){let t=Qf(e.display??e.path??``);return e.startLine===void 0||e.endLine===void 0?t:e.startLine===e.endLine?`${t}:${e.startLine}`:`${t}:${e.startLine}-${e.endLine}`}function IL(e){return e.startsWith(`@`)?e.slice(1):e}function LL(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var RL=`(?![0-9#]|-\\d)`;function zL(e,t){return new RegExp(LL(t)+RL).test(e)}function BL(e,t){let n=new RegExp(LL(t)+RL).exec(e);return n?n.index:-1}function VL(e,t,n){let r=`@${e}`,i=e=>t.some(t=>t.token===e)||zL(n,e);if(!i(r))return r;for(let e=2;;e++)if(!i(`${r}#${e}`))return`${r}#${e}`}function HL(e,t,n){let r=Math.max(0,Math.min(t,e.length)),i=e.slice(0,r),a=e.slice(r),o=i&&!/\s$/.test(i)?` `:``;return{prose:`${i}${o}${n}${a&&!/^\s/.test(a)?` `:``}${a}`,caret:r+o.length+n.length}}function UL(e,t){if(!t.length||!e)return e?[{text:e}]:[];let n=[...new Set(t)].sort((e,t)=>t.length-e.length).map(LL).join(`|`),r=RegExp(`(${n})${RL}`,`g`),i=[],a=0;for(let t of e.matchAll(r))t.index>a&&i.push({text:e.slice(a,t.index)}),i.push({text:t[0],token:t[0]}),a=t.index+t[0].length;return a<e.length&&i.push({text:e.slice(a)}),i}function WL(e,t){let n=[],r=``,i=1,a=!1;for(let t of e){if(t===`
187
- `){i++,a=!0;continue}if(/\s/.test(t)){a=!0;continue}a&&r.length>0&&(r+=` `,n.push(i)),a=!1,r+=t,n.push(i)}let o=t.replace(/\s+/g,` `).trim();if(!o)return null;let s=r.indexOf(o);return s===-1||r.indexOf(o,s+1)!==-1?null:{startLine:n[s],endLine:n[s+o.length-1]}}function GL(e,t){return t&&np(t,e)||e}function KL(e){return e.startLine===void 0||e.endLine===void 0?``:e.startLine===e.endLine?`, line ${e.startLine}`:`, lines ${e.startLine}-${e.endLine}`}function qL(e,t){return e.length?`Selected context:\n\n${e.map(e=>{let n=e.text.replace(/\s+$/,``).split(`
186
+ `)}`:e}function LL(e){let t=Qf(e.display??e.path??``);return e.startLine===void 0||e.endLine===void 0?t:e.startLine===e.endLine?`${t}:${e.startLine}`:`${t}:${e.startLine}-${e.endLine}`}function RL(e){return e.startsWith(`@`)?e.slice(1):e}function zL(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var BL=`(?![0-9#]|-\\d)`;function VL(e,t){return new RegExp(zL(t)+BL).test(e)}function HL(e,t){let n=new RegExp(zL(t)+BL).exec(e);return n?n.index:-1}function UL(e,t,n){let r=`@${e}`,i=e=>t.some(t=>t.token===e)||VL(n,e);if(!i(r))return r;for(let e=2;;e++)if(!i(`${r}#${e}`))return`${r}#${e}`}function WL(e,t,n){let r=Math.max(0,Math.min(t,e.length)),i=e.slice(0,r),a=e.slice(r),o=i&&!/\s$/.test(i)?` `:``;return{prose:`${i}${o}${n}${a&&!/^\s/.test(a)?` `:``}${a}`,caret:r+o.length+n.length}}function GL(e,t){if(!t.length||!e)return e?[{text:e}]:[];let n=[...new Set(t)].sort((e,t)=>t.length-e.length).map(zL).join(`|`),r=RegExp(`(${n})${BL}`,`g`),i=[],a=0;for(let t of e.matchAll(r))t.index>a&&i.push({text:e.slice(a,t.index)}),i.push({text:t[0],token:t[0]}),a=t.index+t[0].length;return a<e.length&&i.push({text:e.slice(a)}),i}function KL(e,t){let n=[],r=``,i=1,a=!1;for(let t of e){if(t===`
187
+ `){i++,a=!0;continue}if(/\s/.test(t)){a=!0;continue}a&&r.length>0&&(r+=` `,n.push(i)),a=!1,r+=t,n.push(i)}let o=t.replace(/\s+/g,` `).trim();if(!o)return null;let s=r.indexOf(o);return s===-1||r.indexOf(o,s+1)!==-1?null:{startLine:n[s],endLine:n[s+o.length-1]}}function qL(e,t){return t&&np(t,e)||e}function JL(e){return e.startLine===void 0||e.endLine===void 0?``:e.startLine===e.endLine?`, line ${e.startLine}`:`, lines ${e.startLine}-${e.endLine}`}function YL(e,t){return e.length?`Selected context:\n\n${e.map(e=>{let n=e.text.replace(/\s+$/,``).split(`
188
188
  `).map(e=>`> ${e}`).join(`
189
- `);return`${e.token} (${GL(e.path,t)}${KL(e)}):\n${n}`}).join(`
189
+ `);return`${e.token} (${qL(e.path,t)}${JL(e)}):\n${n}`}).join(`
190
190
 
191
- `)}`:``}function JL(e,t,n){let{prose:r,attachments:i}=NL(e),a=qL(t.filter(e=>zL(r,e.token)).sort((e,t)=>BL(r,e.token)-BL(r,t.token)),n);return a?PL(r.trimEnd()?`${r.trimEnd()}\n\n${a}`:a,i.map(e=>e.path)):e}var YL=`Selected context:
191
+ `)}`:``}function XL(e,t,n){let{prose:r,attachments:i}=FL(e),a=YL(t.filter(e=>VL(r,e.token)).sort((e,t)=>HL(r,e.token)-HL(r,t.token)),n);return a?IL(r.trimEnd()?`${r.trimEnd()}\n\n${a}`:a,i.map(e=>e.path)):e}var ZL=`Selected context:
192
192
 
193
- `;function XL(e){let t=e.lastIndexOf(YL);if(t===-1||t!==0&&e.slice(t-2,t)!==`
193
+ `;function QL(e){let t=e.lastIndexOf(ZL);if(t===-1||t!==0&&e.slice(t-2,t)!==`
194
194
 
195
195
  `)return null;let n=e.slice(0,Math.max(0,t-2)),r=e.slice(t+19).split(/\n\n(?=@\S+ \()/),i=[];for(let e of r){let t=e.split(`
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
- `)})}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
- `+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-DyLvW_rQ.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,launcherVersion:r,updateVersion:i}){if(!e)return null;let a=t?`Update Frizz`:`Restart Frizz`,o=t?i:void 0;return(0,L.jsxs)(`div`,{id:`update-restart-popover`,role:`tooltip`,"aria-label":a,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:a}),n&&(0,L.jsx)(`span`,{className:`font-mono text-[11px] leading-snug text-muted`,children:r?`Server ${o?`${n} → ${o}`:n}`:o?`${n} → ${o}`:n}),r&&(0,L.jsx)(`span`,{className:`font-mono text-[11px] leading-snug text-muted`,children:`Launcher ${r}`})]})]}),(0,L.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:t?o?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,launcherVersion:d?.launcherVersion,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,launcherVersion:p.launcherVersion,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
- `).filter(e=>{let t=/^\s*([a-z][a-z-]*):/i.exec(e)?.[1]?.toLowerCase();return!(t&&mU.has(t))}).join(`
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(`
197
+ `)})}return!i.length||!i.every(e=>VL(n,e.token))?null:{body:n,items:i}}function $L(e){return e.key===`Enter`&&!e.altKey&&!e.shiftKey&&!e.isComposing&&e.keyCode!==229}function eR(e,t){return t&&$L(e)&&!e.metaKey&&!e.ctrlKey}function tR(e,t){return t&&$L(e)&&(e.metaKey||e.ctrlKey)}function nR(e){return $L(e)}function rR(e){return e.key===`Enter`&&e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing}function iR(e,t,n){return e===`queueComposer`&&t===`Enter`&&n}var aR=`gap-3`,oR=`-mx-1`,sR=`-mx-[3px]`,cR=`right-2`,lR=`right-[71px]`,uR=`right-[44px]`,dR=`pr-[6.6875rem]`,fR=`pr-20`;async function pR(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 mR={project:`project`,user:`global`,builtin:`built-in`,plugin:`plugin`};function hR(e,t){e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,t)}px`}function gR({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)(()=>FL(e),[e]),w=C.map(e=>e.path),T=(0,I.useRef)(e);T.current=e;let E=e=>t(IL(e,w)),D=e=>t(IL(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 pR(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=FL(T.current);t(IL(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||hR(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=GL(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(mR[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=GL(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(iR(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
+ `+t.value.slice(r)),requestAnimationFrame(()=>t.setSelectionRange(n+1,n+1));return}let a=de&&!l&&!b;if(eR(i,a)){e.preventDefault(),e.stopPropagation(),n();return}if(tR(i,a)){e.preventDefault(),e.stopPropagation(),(m??n)();return}if(rR(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?mR[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?dR:fR}`} 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)(_R,{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?lR:uR} 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 ${cR} 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 _R({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 vR(){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 yR(){let e=vR();return!!(e.data?.inRepo&&e.data.authed)}function bR({className:e=``}){return yR()?(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 xR=`prompt-control-type petite-caps`,SR=xR,CR=xR,wR=`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 ${SR} 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 TR(e){return`minmax(6rem, 7rem) repeat(${Math.max(0,e)}, auto)`}var ER=[`ultra`,`ultracode`],DR=[`low`,`medium`,`high`,`xhigh`,`max`,...ER];function OR(e){return[...new Set(e.flatMap(e=>e.options.flatMap(e=>e.efforts)))].sort((e,t)=>{let n=DR.indexOf(e),r=DR.indexOf(t);return n===-1&&r===-1?e.localeCompare(t):n===-1?1:r===-1?-1:n-r})}function kR(e){let t=[];for(let n of OR(e)){let e=ER.includes(n)?t.find(e=>ER.includes(e[0])):void 0;e?e.push(n):t.push([n])}return t}function AR(e){return e.flatMap(e=>e.options.flatMap(t=>t.efforts.map(n=>({provider:e.id,model:t.model,effort:n}))))}function jR(e){return JSON.stringify([e.provider,e.model,e.effort])}function MR(e,t){return AR(e).find(e=>jR(e)===t)}function NR(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 PR(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 FR(e,t,n){let r=kR(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 IR,LR=!1;function RR(){LR||typeof window>`u`||(LR=!0,window.addEventListener(`keydown`,e=>{e.key!==`Escape`||!IR||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),BR())},{capture:!0}))}function zR(e){RR();let t={dismiss:e};return IR=t,()=>{IR===t&&(IR=void 0)}}function BR(){let e=IR;return e?(IR=void 0,e.dismiss(),!0):!1}function VR(e){BR()&&e.preventDefault(),e.stopPropagation()}function HR(e){return e===`xhigh`?`X-high`:e.charAt(0).toUpperCase()+e.slice(1)}function UR({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=$j,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)(()=>kR(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?CR:SR,C=c?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors hover:border-border hover:bg-panel-2 hover:text-fg`,w=NR(e,t),T=w&&t?.provider&&t.model&&t.effort?jR(t):void 0,E=n?.model||n?.effort?PR(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=jR(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=FR(e,n,t.key);r&&(t.preventDefault(),t.stopPropagation(),v.current.get(jR(r))?.focus())}return(0,L.jsxs)(MI,{modal:!1,open:p,onOpenChange:e=>{_.current?.(),_.current=void 0,h.current=e,m(e),e&&(_.current=zR(D))},children:[(0,L.jsx)(NI,{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:PR(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)(PI,{children:(0,L.jsxs)(FI,{"aria-label":o,align:`start`,side:u,sideOffset:5,collisionPadding:8,onEscapeKeyDown:e=>e.stopPropagation(),className:`profile-grid-menu ${d} ${Qj} 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)(II,{children:[t.label&&(0,L.jsx)(LI,{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)(zI,{value:T,onValueChange:t=>{let n=MR(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:TR(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)=>HR(t).length>HR(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:HR(i)},i);let a={provider:t.id,model:e.model,effort:r},o=jR(a);return(0,L.jsx)(BI,{value:o,ref:e=>{e?v.current.set(o,e):v.current.delete(o)},onKeyDown:e=>k(e,a),onSelect:e=>{e.preventDefault(),O(a),_.current?.(),D()},"aria-label":`${e.label}, ${HR(r)} effort`,title:`${e.label} › ${HR(r)}`,className:wR,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:HR(r)}),(0,L.jsx)(`span`,{className:`col-start-1 row-start-1`,children:HR(r)})]})},r)})]},e.model))}),t!==e.at(-1)&&(0,L.jsx)(HI,{className:`my-1 h-px bg-border`})]},t.id)),x.length===0&&(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-muted/60`,children:`No profiles available`})]})})]})}async function WR(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(!GR(e))throw Error(`the browser blocked clipboard access`)}function GR(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 KR={claude:`claude auth login`,codex:`codex login`},qR={claude:`Claude`,codex:`Codex`};function JR(e){let t=e.trim();return t===`/login`?`login`:t===`/logout`?`logout`:null}var YR=(0,I.lazy)(()=>ib(()=>import(`./TerminalPane-DuP4bhhj.js`).then(e=>({default:e.TerminalPane})),__vite__mapDeps([0,1])));function XR({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=KR[e],u=qR[e],d=it({mutationFn:()=>Y.accountLoginStart({backend:e}),onSuccess:e=>{c.current=!1,s(e.attemptId)},onError:e=>Z(`Couldn't start the sign-in terminal: ${e.message.slice(0,80)} — use the command below instead`,{duration:7e3})}),f=nt({queryKey:[`accountLoginStatus`,o],queryFn:()=>Y.accountLoginStatus({attemptId:o}),enabled:!!o,refetchInterval:2e3});(0,I.useEffect)(()=>{if(!o||c.current)return;let t=f.data;if(!(!t||t.state===`running`||t.state===`unknown`)){if(c.current=!0,t.auth!==`signed-out`){r.setQueryData([`authStatus`],n=>n&&{...n,[e]:t.auth}),Z(`Signed in to ${u}`),n();return}Z(`${u} sign-in didn't complete — try again or use the command below`,{duration:7e3}),s(null)}},[o,f.data,e,u]);function p(){o&&!c.current&&Y.accountLoginCancel({attemptId:o}).catch(()=>{})}let m=(0,I.useRef)({attempt:null,settled:!1});m.current={attempt:o,settled:c.current},(0,I.useEffect)(()=>()=>{let{attempt:e,settled:t}=m.current;e&&!t&&Y.accountLoginCancel({attemptId:e}).catch(()=>{})},[]);async function h(){try{await WR(l),a(!0),window.setTimeout(()=>a(!1),1500)}catch{Z(`Couldn't copy — select the command and copy it manually`,{duration:6e3})}}let g=it({mutationFn:()=>Y.authStatus(),onSuccess:t=>{if(r.setQueryData([`authStatus`],t),t[e]===`signed-out`){Z(`Still signed out of ${u} — run the command, then retry`,{duration:6e3});return}n()},onError:()=>n()});return(0,L.jsx)(eL,{open:!0,onOpenChange:e=>{e||(p(),t())},children:(0,L.jsxs)(oL,{children:[(0,L.jsx)(cL,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(fL,{"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)(_L,{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)(YR,{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 ZR({backend:e,onClose:t}){let n=Ve(),r=qR[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)(eL,{open:!0,onOpenChange:e=>{!e&&!i.isPending&&t()},children:(0,L.jsxs)(oL,{children:[(0,L.jsx)(cL,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(fL,{"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)(_L,{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 QR=_u.options,$R={auto:`Auto`,default:`Default`,acceptEdits:`Accept edits`,plan:`Plan`,bypassPermissions:`Bypass`},ez={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)`};QR.filter(e=>e!==`plan`).map(e=>({value:e,label:$R[e],title:ez[e]}));var tz=[`auto`,`bypassPermissions`].map(e=>({value:e,label:$R[e],title:ez[e]})),nz=[{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 rz(e){return e===`plan`?`auto`:e}var iz=[`low`,`medium`,`high`,`xhigh`,`max`],az=`ultracode`,oz=new Set([`fable`,`opus`,`sonnet`]);function sz(e){return e&&oz.has(e)?[...iz,az]:[...iz]}var cz={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-high`,max:`Max`,ultra:`Ultra`,ultracode:`Ultracode`};function lz(e){return cz[e]??e.charAt(0).toUpperCase()+e.slice(1)}function uz(e,t){let n=sz(e).map(e=>({value:e,label:lz(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function dz(e,t){let n=(e?.efforts??[]).map(e=>({value:e,label:lz(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function fz(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 pz(e){return[{id:`claude`,label:`Claude Code`,options:nz.map(e=>({model:e.value,label:e.label,defaultEffort:`high`,efforts:sz(e.value)}))},{id:`codex`,label:`Codex`,options:e.map(e=>({model:e.slug,label:e.displayName,defaultEffort:e.defaultEffort,efforts:e.efforts}))}]}function mz(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`?nz.some(e=>e.value===i):t.some(e=>e.slug===i),s=n===`claude`?`high`:a?.defaultEffort??``,c=r.effort??s,l=n===`claude`?uz(i,{withDefault:!1}):dz(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 hz(){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`],fz(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?mz(t.data,r):void 0,[a,t.data,r]),codexList:r,loadError:t.isError||n.isError,saveProfile:i.mutate}}var gz=`frizz-drafts:v1`,_z=80,vz=512*1024,yz=2*1024*1024,bz=new TextEncoder;function xz(e){return bz.encode(e).byteLength}function Sz(){return{version:1,entries:{}}}function Cz(e){if(!e)return Sz();try{let t=JSON.parse(e);if(!t||typeof t!=`object`||t.version!==1)return Sz();let n=t.entries;if(!n||typeof n!=`object`||Array.isArray(n))return Sz();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||xz(t.value)>vz||(r[e]={value:t.value,touchedAt:t.touchedAt});return{version:1,entries:r}}catch{return Sz()}}function wz(e){let t=Object.entries(e.entries).filter(([,e])=>e.value&&xz(e.value)<=vz).sort((e,t)=>t[1].touchedAt-e[1].touchedAt),n={};for(let[e,r]of t){if(Object.keys(n).length>=_z)break;n[e]=r,xz(JSON.stringify({version:1,entries:n}))>yz&&delete n[e]}return{version:1,entries:n}}var Tz=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=wz(Cz(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(gz,JSON.stringify(wz(e)))}catch{}for(let e of this.listeners)e()}};function Ez(e){return encodeURIComponent(e||`unresolved-project`)}var Dz={dispatch:e=>`dispatch:${Ez(e)}:new`,followUp:(e,t,n)=>`followup:${Ez(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}`,adopt:(e,t)=>`adopt:${Ez(e)}:${encodeURIComponent(t)}`,answer:(e,t,n,r,i)=>`answer:${Ez(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}:${encodeURIComponent(r)}:${i}`,interaction:(e,t,n,r,i,a,o)=>`interaction:${Ez(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}:${i}:${encodeURIComponent(a)}:${encodeURIComponent(o)}`,question:(e,t,n,r)=>`question:${Ez(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}`};function Oz(){return Zt(X).board?.projectDir}function kz(e){return Zt(X).board?.threads.find(t=>t.id===e)?.sessionId}function Az(e){let t=(0,I.useCallback)(()=>Tz.get(e),[e]);return[(0,I.useSyncExternalStore)(Tz.subscribe,t,t),(0,I.useCallback)(t=>Tz.set(e,t),[e]),(0,I.useCallback)(()=>Tz.clear(e),[e])]}function jz(e){let t=(0,I.useCallback)(()=>JSON.stringify(Object.fromEntries(e.map(e=>[e,Tz.get(e)]))),[e.join(`\0`)]),n=(0,I.useSyncExternalStore)(Tz.subscribe,t,t);return(0,I.useMemo)(()=>new Map(Object.entries(JSON.parse(n))),[n])}function Mz({autoFocus:e,onDispatched:t}){let{resolved:n,codexList:r,loadError:i,saveProfile:a}=hz(),o=yR(),s=Oz(),[c,l,u]=Az(Dz.dispatch(s)),d=Dz.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)=>{Tz.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=JR(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)(UR,{groups:pz(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)(UR,{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)(gR,{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)(bR,{}):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)(XR,{backend:g,onClose:()=>_(null),onAuthed:()=>{let e=b.current;b.current=null,_(null),e&&S(e)}}),v&&(0,L.jsx)(ZR,{backend:v,onClose:()=>y(null)})]})}function Nz({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)(eL,{open:!0,onOpenChange:t=>{t||e()},children:(0,L.jsxs)(oL,{children:[(0,L.jsx)(cL,{className:`fixed inset-0 z-50 bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(fL,{ref:t,"aria-modal":`true`,"aria-describedby":void 0,onEscapeKeyDown:VR,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)(_L,{className:`mb-1 text-[14px] font-medium`,children:`New thread`}),(0,L.jsx)(Mz,{autoFocus:!0,onDispatched:e})]})]})})}function Pz({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 Fz=`-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`,Iz={claude:`size-[11px] translate-y-px`,codex:`size-[10px]`},Lz={claude:{backend:`claude`,label:`Claude Code`},codex:{backend:`codex`,label:`OpenAI Codex`}};function Rz(e){return e===`claude`||e===`codex`?Lz[e]:void 0}function zz({backend:e,className:t}){let n=Rz(e);return n?(0,L.jsx)(`span`,{role:`img`,"aria-label":n.label,className:`inline-flex shrink-0 text-muted/65 ${Iz[n.backend]} ${t??``}`,children:n.backend===`codex`?(0,L.jsx)(Bz,{}):(0,L.jsx)(Vz,{})}):null}function Bz(){return(0,L.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,L.jsx)(`path`,{d:`M22.282 9.821a6 6 0 0 0-.516-4.91a6.05 6.05 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a6 6 0 0 0-3.998 2.9a6.05 6.05 0 0 0 .743 7.097a5.98 5.98 0 0 0 .51 4.911a6.05 6.05 0 0 0 6.515 2.9A6 6 0 0 0 13.26 24a6.06 6.06 0 0 0 5.772-4.206a6 6 0 0 0 3.997-2.9a6.06 6.06 0 0 0-.747-7.073M13.26 22.43a4.48 4.48 0 0 1-2.876-1.04l.141-.081l4.779-2.758a.8.8 0 0 0 .392-.681v-6.737l2.02 1.168a.07.07 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494M3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085l4.783 2.759a.77.77 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646M2.34 7.896a4.5 4.5 0 0 1 2.366-1.973V11.6a.77.77 0 0 0 .388.677l5.815 3.354l-2.02 1.168a.08.08 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855l-5.833-3.387L15.119 7.2a.08.08 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667m2.01-3.023l-.141-.085l-4.774-2.782a.78.78 0 0 0-.785 0L9.409 9.23V6.897a.07.07 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135l-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.8.8 0 0 0-.393.681zm1.097-2.365l2.602-1.5l2.607 1.5v2.999l-2.597 1.5l-2.607-1.5Z`})})}function Vz(){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 Hz(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)}}function Uz(e,t=[]){let n=[];function r(t,r){let i=I.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=I.useMemo(()=>o,Object.values(o));return(0,L.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=I.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>I.createContext(e));return function(n){let r=n?.[e]||t;return I.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,Wz(i,...t)]}function Wz(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return I.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var Gz=`DismissableLayer`,Kz=`dismissableLayer.update`,qz=`dismissableLayer.pointerDownOutside`,Jz=`dismissableLayer.focusOutside`,Yz,Xz=I.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Zz=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(Xz),[d,f]=I.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=I.useState({}),h=TD(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=tB(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=nB(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=UD(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&&(Yz=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),rB(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=Yz))}},[d,p,n,u]),I.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),rB())},[d,u]),I.useEffect(()=>{let e=()=>m({});return document.addEventListener(Kz,e),()=>document.removeEventListener(Kz,e)},[]),(0,L.jsx)(VD.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:Hz(e.onFocusCapture,w.onFocusCapture),onBlurCapture:Hz(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:Hz(e.onPointerDownCapture,C.onPointerDownCapture)})});Zz.displayName=Gz;var Qz=`DismissableLayerBranch`,$z=I.forwardRef((e,t)=>{let n=I.useContext(Xz),r=I.useRef(null),i=TD(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)(VD.div,{...e,ref:i})});$z.displayName=Qz;var eB=()=>!0;function tB(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=eB}=t,s=UD(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||iB(qz,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 nB(e,t=globalThis?.document){let n=UD(e),r=I.useRef(!1);return I.useEffect(()=>{let e=e=>{e.target&&!r.current&&iB(Jz,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 rB(){let e=new CustomEvent(Kz);document.dispatchEvent(e)}function iB(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?HD(i,a):i.dispatchEvent(a)}var aB=`focusScope.autoFocusOnMount`,oB=`focusScope.autoFocusOnUnmount`,sB={bubbles:!1,cancelable:!0},cB=`FocusScope`,lB=I.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=I.useState(null),l=UD(i),u=UD(a),d=I.useRef(null),f=TD(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:gB(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||gB(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&gB(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){_B.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(aB,sB);s.addEventListener(aB,l),s.dispatchEvent(t),t.defaultPrevented||(uB(bB(fB(s)),{select:!0}),document.activeElement===e&&gB(s))}return()=>{s.removeEventListener(aB,l),setTimeout(()=>{let t=new CustomEvent(oB,sB);s.addEventListener(oB,u),s.dispatchEvent(t),t.defaultPrevented||gB(e??document.body,{select:!0}),s.removeEventListener(oB,u),_B.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]=dB(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&gB(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&gB(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,L.jsx)(VD.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});lB.displayName=cB;function uB(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(gB(r,{select:t}),document.activeElement!==n)return}function dB(e){let t=fB(e);return[pB(t,e),pB(t.reverse(),e)]}function fB(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 pB(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):mB(r,{upTo:t})))return r}function mB(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 hB(e){return e instanceof HTMLInputElement&&`select`in e}function gB(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&hB(e)&&t&&e.select()}}var _B=vB();function vB(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=yB(e,t),e.unshift(t)},remove(t){e=yB(e,t),e[0]?.resume()}}}function yB(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function bB(e){return e.filter(e=>e.tagName!==`A`)}var xB=`Popper`,[SB,CB]=Uz(xB),[wB,TB]=SB(xB),EB=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null),[a,o]=I.useState(void 0);return(0,L.jsx)(wB,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};EB.displayName=xB;var DB=`PopperAnchor`,OB=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=TB(DB,n),o=I.useRef(null),s=a.onAnchorChange,c=TD(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&&RB(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,L.jsx)(VD.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})});OB.displayName=DB;var kB=`PopperContent`,[AB,jB]=SB(kB),MB=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=TB(kB,n),[_,v]=I.useState(null),y=TD(t,v),[b,x]=I.useState(null),S=EA(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(IB),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=mA({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>eA(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[gA({mainAxis:i+w,alignmentAxis:o}),c&&_A({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?vA():void 0,...k}),c&&yA({...k}),bA({...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&&SA({element:b,padding:s}),LB({arrowWidth:C,arrowHeight:w}),f&&xA({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ee=g.setPlacementState;WD(()=>(ee(M),()=>{ee(void 0)}),[M,ee]);let[F,te]=RB(M),ne=UD(m);WD(()=>{N&&ne?.()},[N,ne]);let re=P.arrow?.x,ie=P.arrow?.y,ae=P.arrow?.centerOffset!==0,[oe,se]=I.useState();return WD(()=>{_&&se(window.getComputedStyle(_).zIndex)},[_]),(0,L.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:N?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,L.jsx)(AB,{scope:n,placedSide:F,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,L.jsx)(VD.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});MB.displayName=kB;var NB=`PopperArrow`,PB={top:`bottom`,right:`left`,bottom:`top`,left:`right`},FB=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=jB(NB,n),a=PB[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)(TA,{...r,ref:t,style:{...r.style,display:`block`}})})});FB.displayName=NB;function IB(e){return e!==null}var LB=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]=RB(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 RB(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var zB=EB,BB=OB,VB=MB,HB=FB;function UB(e,t){return I.useReducer((e,n)=>t[e][n]??e,e)}var WB=e=>{let{present:t,children:n}=e,r=GB(t),i=typeof n==`function`?n({present:r.isPresent}):I.Children.only(n),a=qB(r.ref,YB(i));return typeof n==`function`||r.isPresent?I.cloneElement(i,{ref:a}):null};WB.displayName=`Presence`;function GB(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]=UB(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??JB(r.current),o.current=void 0):a.current=`none`},[s]),WD(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=JB(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),WD(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=JB(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=JB(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=JB(t)}else r.current=null;n(e)},[])}}function KB(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function qB(...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=KB(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():KB(n[e],null)}}},[])}function JB(e){return e?.animationName||`none`}function YB(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 XB=`Popover`,[ZB,QB]=Uz(XB,[CB]),$B=CB(),[eV,tV]=ZB(XB),nV=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=$B(t),c=I.useRef(null),[l,u]=I.useState(!1),[d,f]=aj({prop:r,defaultProp:i??!1,onChange:a,caller:XB});return(0,L.jsx)(zB,{...s,children:(0,L.jsx)(eV,{scope:t,contentId:uO(),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})})};nV.displayName=XB;var rV=`PopoverAnchor`,iV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=tV(rV,n),a=$B(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return I.useEffect(()=>(o(),()=>s()),[o,s]),(0,L.jsx)(BB,{...a,...r,ref:t})});iV.displayName=rV;var aV=`PopoverTrigger`,oV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=tV(aV,n),a=$B(n),o=TD(t,i.triggerRef),s=(0,L.jsx)(VD.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":xV(i.open),...r,ref:o,onClick:Hz(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,L.jsx)(BB,{asChild:!0,...a,children:s})});oV.displayName=aV;var sV=`PopoverPortal`,[cV,lV]=ZB(sV,{forceMount:void 0}),uV=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=tV(sV,t);return(0,L.jsx)(cV,{scope:t,forceMount:n,children:(0,L.jsx)(WB,{present:n||a.open,children:(0,L.jsx)(XA,{asChild:!0,container:i,children:r})})})};uV.displayName=sV;var dV=`PopoverContent`,fV=I.forwardRef((e,t)=>{let n=lV(dV,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=tV(dV,e.__scopePopover);return(0,L.jsx)(WB,{present:r||a.open,children:a.modal?(0,L.jsx)(mV,{...i,ref:t}):(0,L.jsx)(hV,{...i,ref:t})})});fV.displayName=dV;var pV=OD(`PopoverContent.RemoveScroll`),mV=I.forwardRef((e,t)=>{let n=tV(dV,e.__scopePopover),r=I.useRef(null),i=TD(t,r),a=I.useRef(!1);return I.useEffect(()=>{let e=r.current;if(e)return oN(e)},[]),(0,L.jsx)(hP,{as:pV,allowPinchZoom:!0,children:(0,L.jsx)(gV,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Hz(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Hz(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:Hz(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),hV=I.forwardRef((e,t)=>{let n=tV(dV,e.__scopePopover),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(gV,{...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()}})}),gV=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=tV(dV,n),p=$B(n);return pM(),(0,L.jsx)(lB,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(Zz,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,L.jsx)(VB,{"data-state":xV(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)`}})})})}),_V=`PopoverClose`,vV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=tV(_V,n);return(0,L.jsx)(VD.button,{type:`button`,...r,ref:t,onClick:Hz(e.onClick,()=>i.onOpenChange(!1))})});vV.displayName=_V;var yV=`PopoverArrow`,bV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=$B(n);return(0,L.jsx)(HB,{...i,...r,ref:t})});bV.displayName=yV;function xV(e){return e?`open`:`closed`}var SV=nV,CV=iV,wV=oV,TV=uV,EV=fV;function DV({modal:e=!1,...t}){return(0,L.jsx)(SV,{modal:e,...t})}var OV=wV,kV=CV;function AV({children:e,side:t=`top`,align:n=`center`,sideOffset:r=6,className:i=``,...a}){return(0,L.jsx)(TV,{children:(0,L.jsx)(EV,{side:t,align:n,sideOffset:r,avoidCollisions:!0,collisionPadding:12,onEscapeKeyDown:e=>e.stopPropagation(),className:`${Qj} ${nM} rounded-lg outline-none ${i}`,...a,children:e})})}var jV=3e4,MV=45e3;function NV(e,t){return t?AbortSignal.any([t,AbortSignal.timeout(e)]):AbortSignal.timeout(e)}var PV=`text-[9px]`,FV={claude:`text-fg/75! size-[14px]! translate-y-0!`,codex:`text-fg/75! size-[12.75px]! translate-y-0!`};function IV(){let e=nt({queryKey:[`quota`],queryFn:()=>Y.quota(),staleTime:1e4}),t=nt({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4});return[`claude`,`codex`].some(n=>LV(e.data?.[n],t.data?.[n],e.isLoading))}function LV(e,t,n){return t===`signed-out`||!e&&n?!1:!!e&&e.status===`ok`&&e.windows.length>0}function RV(){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:NV(jV,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:NV(jV,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:NV(MV)}).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 ${PV}`,children:[(0,L.jsx)(zV,{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)(zV,{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 zV({backend:e,quota:t,auth:n,email:r,loading:i,fetching:a,onRecheck:o}){let s=qR[e];if(!LV(t,n,i))return null;let c=BV(100-HV(t.windows).usedPercent);return(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(DV,{onOpenChange:e=>{e&&o()},children:[(0,L.jsx)(OV,{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)(zz,{backend:e,className:FV[e]}),(0,L.jsxs)(`span`,{className:`tabular-nums ${UV(c)}`,children:[c,`%`]})]})}),(0,L.jsxs)(AV,{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)(zz,{backend:e}),(0,L.jsx)(`span`,{children:s}),t?.planType&&(0,L.jsxs)(`span`,{className:`text-muted/70`,children:[`· `,WV(t.planType),` plan`]}),a&&(0,L.jsx)(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=BV(100-e.usedPercent),n=GV(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:UV(t),children:[t,`% left`]}),n&&(0,L.jsxs)(`span`,{className:`text-muted/55`,children:[`resets `,n]})]})]},e.key)}),t.detail&&(0,L.jsx)(`li`,{className:`pt-1 text-muted/55`,children:t.detail})]})]})]})})}function BV(e){return Math.max(0,Math.min(100,Math.round(e)))}var VV=25;function HV(e){return e.find(e=>e.key===`5h`)??e.reduce((e,t)=>t.usedPercent>e.usedPercent?t:e)}function UV(e){return e<=8?`text-red-400`:e<=VV?`text-accent`:`text-fg/70`}function WV(e){return e&&e[0].toUpperCase()+e.slice(1)}function GV(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 KV=`frizz:supervisor-status-wake`,qV=`frizz:reload-after-update-restart`,JV=`frizz:update-restart-from-version`;function YV(e,t){return t.version===e?{kind:`previous-kept`}:{kind:`successor-failed`,version:t.version}}function XV(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 ZV(e){return e?.artifactDigest??e?.version??null}function QV(e,t){if(e===null||t?.state!==`ready`)return!1;let n=ZV(t);return n!==null&&n!==e}var $V=3*6e4,eH={silentSince:null,silentForMs:0,stalled:!1};function tH(e,t,n=$V){if(!t.restarting||t.answered)return eH;let r=e.silentSince??t.at,i=Math.max(0,t.at-r);return{silentSince:r,silentForMs:i,stalled:i>=n}}function nH(e,t){return e.ackedAt!==null&&t.requestedAt>=e.ackedAt}function rH(e,t){return e.attempt&&!(nH(e.attempt,t)&&iH(e.attempt,t))?e:{state:t.state,message:t.message??null,attempt:null}}function iH(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 aH(e,t){return t.state===`ready`&&e.attempt===null}function oH(e){return e!==null}function sH(e){return e?.updateRestart===!0&&e.updateAvailable!==!1}function cH(e){return e?.dev===!0}async function lH(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 uH(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 dH(e=fetch){return uH(`/_frizz/control/restart`,e)}function fH(e=fetch){return uH(`/_frizz/control/update-restart`,e)}var pH=8e3,mH=500,hH=[`supervisorStatus`];function gH(e,t){return e===`restarting`||t?mH:pH}var _H=rt({queryKey:hH,queryFn:async()=>{let e=Date.now(),t=await lH();return t?{...t,requestedAt:e}:null},refetchInterval:e=>gH(e.state.data?.state,X.controlPlaneRestartAttempt!==null),staleTime:e=>gH(e.state.data?.state,X.controlPlaneRestartAttempt!==null)});function vH(){return nt(_H)}var yH=null;function bH(e){yH||(yH=e,window.addEventListener(KV,()=>{e.refetchQueries({queryKey:hH,exact:!0})}))}function xH(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 SH=`Install the latest version of Frizz. Your running threads will not be affected.`,CH=`A newer version of Frizz is available. Your running threads will not be affected.`,wH=`Restart Frizz. Your running threads will not be affected.`,TH=`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)]`,EH=`absolute -top-[7px] left-4 h-3 w-3 rotate-45 border-l border-t bg-elevated`,DH=`sm:w-[min(23rem,calc(100vw-1.5rem))]`,OH=`sm:w-[min(34rem,calc(100vw-1.5rem))]`,kH=`rounded-xl bg-elevated p-3.5 shadow-xl shadow-black/45`;function AH({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:`${TH} ${DH} ${kH} border border-border-strong`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${EH} 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?CH:SH:wH})]})}var jH={kind:`previous-kept`};function MH({update:e,message:t,outcome:n=jH,onDismiss:r}){return(0,L.jsxs)(`div`,{role:`alert`,className:`${TH} ${OH} ${kH} border border-red-500/45`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${EH} 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:XV(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 NH({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 ${Fz}`,onFocus:i,onBlur:a,onClick:o,children:[(0,L.jsx)(lh,{size:14,"aria-hidden":`true`,className:t?`animate-spin`:void 0}),e&&!t&&xH(n,r)&&(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-[2px] top-[2px] h-[4px] w-[4px] rounded-full bg-accent`})]})}function PH(){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=vH().data??null,f=sH(d),p={version:d?.version,updateVersion:d?.updateVersion};if(!oH(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?YV(l.current.version,{version:d?.version}):jH,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:ZV(d)});try{if(f?await fH():await dH(),f){sessionStorage.setItem(qV,e),l.current.version?sessionStorage.setItem(JV,l.current.version):sessionStorage.removeItem(JV);let t=X.controlPlaneRestartAttempt;t&&(X.controlPlaneRestartAttempt={...t,ackedAt:Date.now()}),window.dispatchEvent(new Event(KV)),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)(NH,{update:f,busy:r,version:p.version,updateVersion:p.updateVersion,onFocus:()=>n(!0),onBlur:()=>n(!1),onClick:()=>void y()}),_&&(0,L.jsx)(MH,{update:f,message:_,outcome:v,onDismiss:()=>c(_)}),(0,L.jsx)(AH,{open:t&&!_,update:f,version:p.version,updateVersion:p.updateVersion})]})}function FH(){return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px shrink-0 bg-border`})}function IH({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 LH(){let e=qC(),t=gW(e),n=IV(),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:`${Fz} -ml-px`,children:(0,L.jsx)(Wm,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(FH,{}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Settings`,title:`Settings`,className:Fz,onClick:()=>X.showSettings=!0,children:(0,L.jsx)(ph,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(PH,{}),n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(FH,{}),(0,L.jsx)(RV,{})]}),(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)(IH,{text:i})}):i?(0,L.jsx)(IH,{text:i,title:i,className:`font-semibold text-fg/90`}):(0,L.jsx)(`span`,{className:`identity-placeholder w-24`,"aria-hidden":`true`})})]})}var RH=qt({at:{}}),zH=12e3,BH=new Map;function VH(e,t=Date.now()){RH.at[e]=t;let n=BH.get(e);n!==void 0&&clearTimeout(n),BH.set(e,setTimeout(()=>{BH.delete(e),delete RH.at[e]},zH))}function HH(e){let t=BH.get(e);t!==void 0&&(clearTimeout(t),BH.delete(e)),delete RH.at[e]}function UH(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 WH(){return Zt(RH).at}function GH(e,t,n=Date.now()){return t===void 0||!UH(e,t,n)?e:{...e,runtime:`running`,needsYou:!1,pendingAsk:void 0,pendingQuestion:!1,actionableInteraction:!1,lastUserAt:new Date(t).toISOString()}}function KH(e){let t=WH();return(0,I.useMemo)(()=>e.map(e=>GH(e,t[e.id])),[e,t])}var qH=0;function JH(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(qH+=1,`browser-${Date.now()}-${qH}`)}function YH({optimistic:e,request:t,success:n,failure:r}){e(),t().then(()=>n?.(),e=>r(e instanceof Error?e:Error(String(e))))}var XH=new Map;function ZH(e,t){let n=(XH.get(e)??Promise.resolve()).then(t,t);return XH.set(e,n.then(()=>{},()=>{})),n}var QH=[300,800,1800,3500],$H=12e4,eU=e=>new Promise(t=>{setTimeout(t,e)});async function tU(e,t,n=eU){for(let r=0;;r++){try{await e()}catch(e){if(r>=QH.length||!ff(e))throw e;t(),await n(QH[r]);continue}t();return}}function nU(e,t,n,r,i,a=$H){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 rU(e,t,n,r,i){return tU(()=>nU(e,t,n,r,i),()=>VH(e))}function iU(e,t,n,r={}){let i=n.trim();if(!i)return!1;let a=JH();return YH({optimistic:()=>{r.onOptimistic?.(),dw(e,t,i,{scrollToBottom:r.scrollToBottom,deliveryId:a}),VH(t),Y.markRead({slug:t}).catch(()=>{})},request:()=>ZH(t,()=>rU(t,i,a,r.freshProcess,r.interrupt)),success:()=>r.onSuccess?.(),failure:n=>{fw(e,t,i,a),HH(t),r.onRollback?.(),Z(r.failureToast?.(n.message)??`Steer failed — ${n.message.slice(0,160)}`)}}),!0}function aU(e){let t=Ve(),[n,r]=(0,I.useState)(0);return{submit:(0,I.useCallback)((n,i={})=>iU(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 oU(e,t){return new Promise(n=>{iU(e,t,`Continue exactly where you left off.`,{onSuccess:()=>{Z(`Retrying…`),n()},onRollback:()=>n(),failureToast:e=>`Retry failed: ${e.slice(0,80)}`})||n()})}function sU(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 cU=`Waiting for an external update.`;function lU(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:sU(n)}])})}function uU(e){let t=(e.body??``).split(/\n\s*\n/).map(e=>e.trim()).find(Boolean);return t?pU(dU(t.replace(/\s*\n\s*/g,` `))):null}function dU(e){if(e.length<=fU)return e;let t=e.slice(0,fU),n=t.lastIndexOf(` `);return`${(n>fU/2?t.slice(0,n):t).replace(/[.,;:]$/,``)}…`}var fU=240;function pU(e){let t=(e.split(/\s/,1)[0]??``).replace(/[.,:;]+$/,``);return/[^a-zA-Z]/.test(t)||/[A-Z]/.test(t.slice(1))||mU.has(t)?e:e.charAt(0).toUpperCase()+e.slice(1)}var mU=new Set([`npm`,`npx`,`pnpm`,`nub`,`nubx`,`gh`,`git`,`node`,`bun`,`tsc`,`vite`,`curl`,`ssh`]);function hU(e){return e&&_U(e)||null}var gU=new Set([...rl,`shells`,`agents`,`timers`,`prs`,`for`,`title`]);function _U(e){return e.split(`
200
+ `).filter(e=>{let t=/^\s*([a-z][a-z-]*):/i.exec(e)?.[1]?.toLowerCase();return!(t&&gU.has(t))}).join(`
201
+ `).trim()}function vU(e){let t=t=>e.filter(e=>e.kind===t&&e.value.trim()).length,n=[...lU(e).map(e=>e.ref),yU(t(`shell`),`background shell`,`background shells`),yU(t(`agent`),`sub-agent`,`sub-agents`),yU(t(`timer`),`timer`,`timers`)].filter(e=>e!==null);return n.length>0?`waiting on ${bU(n)}`:null}function yU(e,t,n){return e<=0?null:e===1?`a ${t}`:`${e} ${n}`}function bU(e){return e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function xU(e){let t=e.find(e=>e.kind===`pr`);return t?`PR ${t.value}`:null}var SU=qt({at:{}}),CU=12e3,wU=new Map;function TU(e,t=Date.now()){SU.at[e]=t;let n=wU.get(e);n!==void 0&&clearTimeout(n),wU.set(e,setTimeout(()=>{wU.delete(e),delete SU.at[e]},CU))}function EU(e){let t=wU.get(e);t!==void 0&&(clearTimeout(t),wU.delete(e)),delete SU.at[e]}function DU(){return Zt(SU).at}function OU(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 kU(e){let t=DU();return(0,I.useMemo)(()=>e.map(e=>OU(e,t[e.id])),[e,t])}var AU=.5;function jU(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*AU,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 MU(e,t,n,r){return!e||e.top<=r&&e.bottom>r?!0:Math.abs(t-n)>1}function NU(e,t,n,r,i=8){return n<e+i?n-e-i:r>t-i?r-t+i:0}var PU=`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`,FU=`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 IU(){let e=Zt(X),t=kU(KH(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(MU(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=jU(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=NU(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:FU,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)(LH,{}),(0,L.jsx)(Mz,{})]}),(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)(WU,{t:e,active:l===e.id,onQueueNavigate:p}),(0,L.jsx)(YU,{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)(WU,{t,active:l===t.id,onQueueNavigate:p,restedAge:e}),(0,L.jsx)(YU,{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)(LU,{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)(WU,{t:e,active:l===e.id,onQueueNavigate:p}),(0,L.jsx)(YU,{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)(LU,{label:`Done`,count:s.length,collapsed:i.inactive,onToggle:()=>X.sidebarCollapsed.inactive=!X.sidebarCollapsed.inactive}),!i.inactive&&(0,L.jsx)(BU,{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)(LU,{label:`External`,count:r.length,collapsed:i.external,onToggle:()=>X.sidebarCollapsed.external=!X.sidebarCollapsed.external}),!i.external&&r.map(e=>(0,L.jsx)(WU,{t:e,active:l===e.id,onQueueNavigate:p,restedAge:!0},e.id))]})]})]})})}function LU({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 RU=27,zU=8;function BU({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:()=>RU,overscan:zU,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)(WU,{t:i,active:n===i.id,onQueueNavigate:r}),(0,L.jsx)(YU,{t:i})]},i.id):null})})}var VU=16,HU=12;function UU({title:e,children:t}){let n=e.trimEnd(),r=n.lastIndexOf(` `)+1,i=n.length-r<=VU?r:n.length-HU;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 WU=(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)(eW,{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)(UU,{title:CT(e),children:[!t&&(0,L.jsx)(zz,{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)(XU,{status:e.archived?`archived`:e.status})]})}),i&&(0,L.jsx)(GU,{t:e,yieldsToRetry:!0}),d&&!i&&(0,L.jsx)(qU,{})]})})]}),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)(JI,{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)(JU,{t:e,className:`-mr-0.5`}),(0,L.jsx)(aM,{slug:e.id,size:12,className:PU}),u&&(0,L.jsx)(KU,{slug:e.id}),!a&&d&&(0,L.jsx)(JU,{t:e})]})]})});function GU({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 KU({slug:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return(0,L.jsx)(iM,{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),oU(t,e).finally(()=>r(!1))},className:`${PU} disabled:opacity-50`,children:n?(0,L.jsx)(Xm,{size:13,className:`animate-spin`}):(0,L.jsx)(dh,{size:13})})})}function qU(){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 JU({t:e,className:t=``}){let n=BT(e),[r,i]=(0,I.useState)(!1);return(0,L.jsx)(iM,{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:`${PU} disabled:opacity-50 ${t}`,children:n?(0,L.jsx)(ah,{size:12,fill:`currentColor`}):(0,L.jsx)(oh,{size:12})})})}function YU({t:e}){let t=sD(e.subAgents??[],`rail`);return t.length===0?null:(0,L.jsx)(`div`,{className:`flex flex-col`,children:t.map(t=>(0,L.jsx)(uD,{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:sM(e.id,t),title:t.subagentType?`[${t.subagentType}] ${t.label}`:t.label},t.id))})}function XU({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 ZU(e,t,n=null){return[[t,vU(e.lastFence?.kind===`awaiting`?e.lastFence.hints:[]),n].filter(e=>!!e).join(` — `),QU(e)].filter(e=>!!e).join(`
202
202
 
203
- `)}function XU(e){return e.lastFence?.kind===`awaiting`?cU(e.lastFence):null}var ZU=7;function QU({t:e,legacy:t}){let{node:n,tip:r}=t?lW(e):$U(e),i=t?void 0:eE(e);return r?(0,L.jsx)(nM,{label:r,side:`left`,multiline:r.includes(`
204
- `),children:(0,L.jsx)(`span`,{"data-rail-glyph":i,className:`flex items-center justify-center`,children:n})}):i?(0,L.jsx)(`span`,{"data-rail-glyph":i,className:`flex items-center justify-center`,children:n}):n}function $U(e){let t=oW(e);if(eE(e)===`snoozed`)return t;let n=GT(e),r=n?pT(n,e.snoozePrompt):null;return r?{node:t.node,tip:eW(t.tip,r)}:t}function eW(e,t){if(!e)return t;let[n,...r]=e.split(`
203
+ `)}function QU(e){return e.lastFence?.kind===`awaiting`?uU(e.lastFence):null}var $U=7;function eW({t:e,legacy:t}){let{node:n,tip:r}=t?dW(e):tW(e),i=t?void 0:eE(e);return r?(0,L.jsx)(iM,{label:r,side:`left`,multiline:r.includes(`
204
+ `),children:(0,L.jsx)(`span`,{"data-rail-glyph":i,className:`flex items-center justify-center`,children:n})}):i?(0,L.jsx)(`span`,{"data-rail-glyph":i,className:`flex items-center justify-center`,children:n}):n}function tW(e){let t=cW(e);if(eE(e)===`snoozed`)return t;let n=GT(e),r=n?pT(n,e.snoozePrompt):null;return r?{node:t.node,tip:nW(t.tip,r)}:t}function nW(e,t){if(!e)return t;let[n,...r]=e.split(`
205
205
 
206
206
  `);return[`${n}\n${t}`,...r].join(`
207
207
 
208
- `)}var tW=(0,L.jsx)(sW,{children:(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-rail-dot`,"data-running-indicator":`thread-background`})}),nW=9,rW=(0,L.jsx)(sW,{children:(0,L.jsx)(Hm,{size:nW,className:`text-muted/70`,style:{transform:`translateX(${nW/24}px)`}})}),iW=(0,L.jsx)(sW,{children:(0,L.jsx)(Um,{size:9,className:`text-muted/70`})});function aW(e,t=Date.now()){let n=(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`).map(e=>Date.parse(e.timer?.fireAt??``)).filter(e=>Number.isFinite(e)).sort((e,t)=>e-t)[0];return n===void 0?null:n>t?`fires in ${IE(n-t)}`:`firing…`}function oW(e){let t=eE(e);if(t===`archived`)return{node:(0,L.jsx)(sW,{children:(0,L.jsx)(gm,{size:10,strokeWidth:3,className:`text-muted/75`})}),tip:`Done`};if(t===`needs-input`)return{node:(0,L.jsx)(sW,{children:(0,L.jsx)(cW,{ch:`?`,muted:!0})}),tip:`Needs your input`};if(t===`working`)return{node:(0,L.jsx)(EE,{}),tip:`Working`};if(t===`background`)return{node:tW,tip:YU(e,e.lastFence?.kind===`awaiting`&&gU(e.lastFence.hints)!==null?`At rest`:`At rest — a background shell is still running`)};if(t===`done`)return{node:(0,L.jsx)(sW,{children:(0,L.jsx)(gm,{size:10,strokeWidth:3,className:`text-muted/75`})}),tip:`Done`};if(t===`stalled`){let t=e.crashed===!0?`Stalled — the agent exited mid-turn`:`Stalled — the agent's process exited`;return{node:(0,L.jsx)(sW,{accent:!0,children:(0,L.jsx)(cW,{ch:`!`})}),tip:t}}if(t===`limit`){let t=e.limitPause,n=t?.window===`weekly`?`weekly limit`:t?.window===`session`?`session limit`:`usage limit`,r=t?.autoResume?t.resumesAt?`continuing automatically at ${gE(t.resumesAt)}`:`continuing automatically once the window resets`:`won't resume by itself — Retry to continue`;return{node:(0,L.jsx)(sW,{accent:!0,children:(0,L.jsx)(Um,{size:9,className:`text-accent`})}),tip:`Paused by the ${t?.backend===`codex`?`Codex`:`Claude`} ${n} — ${r}`}}if(t===`pr`)return{node:rW,tip:YU(e,`At rest`)};if(t===`timer`)return{node:iW,tip:YU(e,e.lastFence?.kind===`awaiting`&&gU(e.lastFence.hints)!==null?`At rest`:`At rest — waiting on a timer`,aW(e))};if(t===`snoozed`){let t=iW,n=rW,r=QT(e)?n:t,i=GT(e);if(i){let t=pT(i,e.snoozePrompt)??`Snoozed until a scheduled check`;return{node:r,tip:YU(e,(e.questions?.length??0)>0||e.pendingQuestion===!0||e.pendingAsk?`${t}\nA question is unanswered behind this park`:t)}}let a=e.bgSnoozed===!0?`Snoozed until the background work returns`:null;if(e.lastFence?.kind!==`awaiting`)return a?{node:QT(e)?n:tW,tip:a}:{node:t,tip:(typeof e.revalidate==`string`?mT(e.revalidate):null)??`Auto-snoozed until a scheduled check`};let o=e.lastFence.hints.find(e=>e.kind===`pr`||e.kind===`shell`||e.kind===`agent`||e.kind===`timer`)?.kind;return{node:QT(e)?n:o===`shell`||o===`agent`?tW:t,tip:YU(e,a??`Snoozed`,o===`timer`?aW(e):null)}}return{node:(0,L.jsx)(sW,{children:(0,L.jsx)(jm,{size:11,className:`text-muted/70`})}),tip:YU(e,`At rest`)}}function sW({accent:e,children:t}){return(0,L.jsx)(`span`,{className:`inline-flex items-center justify-center rounded-[4px] border ${e?`border-accent/90`:`border-muted/45`}`,style:{width:15,height:15},children:t})}function cW({ch:e,muted:t}){return(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-rail-glyph font-bold leading-none ${t?`text-muted/70`:`text-accent`}`,style:{fontSize:10},children:e})}function lW(e){if(e.runtime===`running`||e.runtime===`spawning`||e.runtime===`perm-prompt`)return{node:(0,L.jsx)(uW,{}),tip:`Working`};let t=(e.subAgents??[]).some(e=>e.state===`running`);return e.runtime===`turn-idle`&&t&&!e.humanBlocked?{node:(0,L.jsx)(uW,{}),tip:`Working`}:jT(e)?{node:(0,L.jsx)(dW,{}),tip:`Needs your input`}:e.status===`needs-human`?{node:(0,L.jsx)(fW,{}),tip:`Awaiting you — open to read & reply`}:e.status===`blocked`&&e.mechanism===`timer`?{node:(0,L.jsx)(bh,{size:8,className:`text-muted/70`}),tip:`Waiting on a timer`}:e.status===`blocked`&&e.mechanism===`threads`?{node:(0,L.jsx)(wm,{size:8,className:`text-muted/70`}),tip:`Waiting on other work`}:{node:(0,L.jsx)(pW,{}),tip:null}}function uW(){return(0,L.jsx)(`span`,{className:`block rounded-full border border-muted/70 border-t-transparent animate-spin`,style:{width:8,height:8}})}function dW(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-sky-400`,style:{width:ZU,height:ZU}})}function fW(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-yellow-400`,style:{width:ZU,height:ZU}})}function pW(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-muted/30`,style:{width:ZU,height:ZU}})}function mW(e){if(!e)return{state:`loading`};let t=e.projectLabel?.trim()??``,n=t.lastIndexOf(`/`),r=n===-1?``:t.slice(0,n).trim(),i=n===-1?``:t.slice(n+1).trim();if(r&&i)return{state:`verified`,label:t,owner:r,repo:i};let a=t||e.projectName?.trim()||``;return a?{state:`local`,name:a}:{state:`unavailable`}}var hW={planning:`Being designed`,planned:`Roadmap`,active:`Active`,"needs-human":`Awaiting you`,blocked:`Blocked`,done:`Done`,dismissed:`Dismissed`,archived:`Done`};function gW({status:e}){let t=FT(YC(qC()?.threads??[])).filter(t=>e===`archived`?t.archived:t.status===e);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`header`,{className:`shrink-0 flex items-center gap-2 px-4 h-10 border-b border-border`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:hW[e]??e}),(0,L.jsx)(`span`,{className:`text-[11px] text-muted tabular-nums`,children:t.length})]}),(0,L.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto py-1.5`,children:[t.length===0&&(0,L.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted`,children:`No threads.`}),t.map(e=>(0,L.jsxs)(`button`,{className:`w-full text-left px-4 py-2 hover:bg-panel-2/60`,onClick:()=>_p(`thread`,e.id),children:[(0,L.jsx)(`div`,{className:`leading-snug`,children:CT(e)}),e.statusText&&(0,L.jsx)(`div`,{className:`text-[11px] text-muted mt-0.5`,children:e.statusText})]},e.id))]})]})}var _W=21,vW=4/15;function yW({children:e,tone:t=`border-muted/45`,size:n=18}){return(0,L.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center border ${t}`,style:{width:n,height:n,borderRadius:n*vW},children:e})}function bW({size:e=18}){return(0,L.jsx)(yW,{size:e,children:(0,L.jsx)(`svg`,{width:Math.round(e*.52),height:Math.round(e*.52),viewBox:`0 0 10 10`,"aria-hidden":!0,className:`translate-x-[8%] text-muted/85`,children:(0,L.jsx)(`path`,{d:`M2.5 1.4 8.2 5 2.5 8.6Z`,fill:`currentColor`})})})}function xW({size:e=18}){return(0,L.jsx)(yW,{size:e,tone:`border-accent/90`,children:(0,L.jsx)(`span`,{className:`font-sans font-bold leading-none text-accent`,style:{fontSize:e*10/15},children:`?`})})}function SW({size:e=18}){return(0,L.jsx)(yW,{size:e,tone:`border-muted/40`,children:(0,L.jsx)(gm,{size:Math.round(e*10/15),strokeWidth:3,className:`text-muted/85`})})}function CW({size:e=18}){return(0,L.jsx)(yW,{size:e,children:(0,L.jsx)(Um,{size:Math.round(e*10/15),className:`text-muted/75`})})}function wW({kind:e}){return e===`needs-input`?(0,L.jsx)(xW,{}):e===`stalled`?(0,L.jsx)(yW,{tone:`border-accent/90`,children:(0,L.jsx)(`span`,{className:`font-sans text-[12px] font-bold leading-none text-accent`,children:`!`})}):e===`working`||e===`background`?(0,L.jsx)(bW,{}):e===`limit`?(0,L.jsx)(yW,{tone:`border-accent/90`,children:(0,L.jsx)(Um,{size:12,className:`text-accent`})}):e===`snoozed`||e===`timer`?(0,L.jsx)(CW,{}):e===`done`||e===`archived`?(0,L.jsx)(SW,{}):(0,L.jsx)(yW,{})}var TW=76,EW=10;function DW({open:e,onOpenChange:t,onSnooze:n,onDone:r,snoozeLabel:i,children:a}){let[o,s]=(0,I.useState)(0),c=(0,I.useRef)(null),l=e?-152:0,u=c.current?.claimed?o:l;return(0,L.jsxs)(`div`,{className:`relative overflow-hidden`,style:{touchAction:`pan-y`},children:[(0,L.jsxs)(`div`,{className:`absolute inset-y-0 right-0 flex`,"aria-hidden":!e,children:[(0,L.jsxs)(`button`,{"data-mobile-swipe-snooze":!0,onClick:()=>{t(!1),n()},className:`flex flex-col items-center justify-center gap-1 bg-elevated text-muted active:bg-panel-2`,style:{width:TW},children:[(0,L.jsx)(km,{size:19}),(0,L.jsx)(`span`,{className:`text-[11.5px]`,children:i})]}),(0,L.jsxs)(`button`,{"data-mobile-swipe-done":!0,onClick:()=>{t(!1),r()},className:`flex flex-col items-center justify-center gap-1 bg-live/85 text-bg active:brightness-95`,style:{width:TW},children:[(0,L.jsx)(gm,{size:19,strokeWidth:2.6}),(0,L.jsx)(`span`,{className:`text-[11.5px] font-medium`,children:`Done`})]})]}),(0,L.jsx)(`div`,{className:`relative bg-bg ${c.current?.claimed?``:`transition-transform duration-200 ease-out motion-reduce:transition-none`}`,style:{transform:`translateX(${u}px)`},onPointerDown:e=>{e.pointerType===`mouse`&&e.button!==0||(c.current={x:e.clientX,y:e.clientY,claimed:!1})},onPointerMove:e=>{let t=c.current;if(!t)return;let n=e.clientX-t.x,r=e.clientY-t.y;if(!t.claimed){if(Math.abs(n)<EW||Math.abs(n)<=Math.abs(r))return;t.claimed=!0,e.currentTarget.setPointerCapture(e.pointerId)}let i=Math.min(0,Math.max(-176,l+n));s(i)},onPointerUp:()=>{let e=c.current;if(c.current=null,!e?.claimed)return;let n=o<-152/2;s(0),t(n)},onPointerCancel:()=>{c.current=null,s(0)},onClickCapture:n=>{e&&(n.preventDefault(),n.stopPropagation(),t(!1))},children:a})]})}function OW({t:e,last:t,openSwipe:n,onOpenSwipe:r}){let i=Zt(yT).snoozePreset,a=TE(),o=eE(e),s=PT(e),c=e.runtime===`running`||e.runtime===`spawning`||o===`working`||o===`background`?null:fE(s,a),l=e.lastFence?.kind===`awaiting`?yU(e.lastFence.hints):null,u=aD(e.subAgents??[],`rail`);return(0,L.jsxs)(`div`,{className:o===`snoozed`?`opacity-60`:void 0,children:[(0,L.jsx)(DW,{open:n,onOpenChange:r,snoozeLabel:tT(i),onSnooze:async()=>{try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:iT(i),prompt:null}),Z(`Snoozed · ${tT(i)}`)}catch(e){Z(e instanceof Error?e.message.slice(0,100):`Snooze failed`)}},onDone:async()=>{CU(e.id);try{let t=await Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:!1});if(t.needsConfirmation){wU(e.id),Z(t.hold?.cutOff?`Cut off mid-turn — open the thread to retry it, or to mark it done anyway`:`Still running — open the thread to finish it`);return}Z(`Marked as done`)}catch(t){wU(e.id),Z(t instanceof Error?t.message.slice(0,100):`Could not mark as done`)}},children:(0,L.jsxs)(`button`,{"data-mobile-thread-row":e.id,onClick:()=>bp(e.id),className:`flex w-full items-start gap-3 px-4 pb-2.5 pt-2.5 text-left active:bg-white/[0.04]`,children:[(0,L.jsx)(`span`,{className:`flex h-[21px] shrink-0 items-center justify-center`,children:(0,L.jsx)(wW,{kind:o})}),(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-3`,children:[(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 text-[15px] font-medium leading-[21px] tracking-[-0.01em] text-fg`,children:[CT(e),(0,L.jsx)(Lz,{backend:e.backend,className:`ml-1.5`})]}),c?(0,L.jsx)(`span`,{className:`shrink-0 text-[11.5px] leading-[21px] tabular-nums text-muted/60`,children:c}):null]}),l?(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[13px] leading-[18px] text-muted`,children:l}):null,e.activity?(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[13px] leading-[18px] text-muted/85`,children:e.activity}):null]})]})}),u.length>0?(0,L.jsx)(`div`,{className:`flex flex-col pb-1`,children:u.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))}):null,t?null:(0,L.jsx)(`div`,{className:`ml-[46px] h-px bg-border/70`})]})}function kW({label:e}){return(0,L.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center px-10 pb-24 text-center`,children:(0,L.jsx)(`p`,{className:`m-0 text-[15px] text-muted`,children:e})})}function AW({active:e,label:t,count:n,asks:r,icon:i,onClick:a}){return(0,L.jsxs)(`button`,{"data-mobile-tab":t.toLowerCase(),"aria-current":e?`page`:void 0,onClick:a,className:`flex flex-1 flex-col items-center justify-center gap-[3px] pt-[3px]`,children:[(0,L.jsxs)(`span`,{className:`relative ${e?`opacity-100`:`opacity-55`}`,children:[i,n>0?(0,L.jsx)(`span`,{className:`absolute -right-[11px] -top-[7px] flex h-[16px] min-w-[16px] items-center justify-center rounded-full border-[1.5px] border-bg px-[3.5px] text-[10px] font-semibold tabular-nums ${r?`bg-accent text-bg`:`bg-elevated text-muted`}`,children:n}):null]}),(0,L.jsx)(`span`,{className:`text-[10px] leading-[12px] tracking-[-0.005em] ${e?`text-fg`:`text-muted/70`}`,children:t})]})}var jW={open:{cls:`bg-live`,word:`connected`},connecting:{cls:`bg-accent`,word:`connecting…`},closed:{cls:`bg-red-500`,word:`disconnected`}};function MW({connection:e,onClose:t}){let n=jW[e],[r,i]=(0,I.useState)(!1);return(0,I.useEffect)(()=>{let e=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(e)},[]),(0,L.jsxs)(`div`,{"data-mobile-more-sheet":!0,className:`fixed inset-0 z-[70] flex flex-col justify-end`,children:[(0,L.jsx)(`button`,{"aria-label":`Close`,onClick:t,className:`absolute inset-0 bg-black/50 transition-opacity duration-200 ${r?`opacity-100`:`opacity-0`}`}),(0,L.jsxs)(`div`,{className:`relative flex max-h-[80%] flex-col overflow-hidden rounded-t-[14px] border-t border-border-strong bg-panel pb-[calc(24px+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 ${r?`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 items-center justify-between gap-3 px-4 pb-3 pt-3`,children:[(0,L.jsxs)(`span`,{className:`flex items-baseline gap-2 text-[13px] text-muted`,children:[(0,L.jsx)(`span`,{className:`inline-block size-[7px] translate-y-[-1px] rounded-full ${n.cls}`}),n.word]}),(0,L.jsx)(IV,{})]}),(0,L.jsx)(`div`,{className:`min-h-0 overflow-y-auto`,children:(0,L.jsx)(`div`,{className:`border-y border-border/70 bg-panel/60`,children:(0,L.jsxs)(`button`,{"data-mobile-settings-row":!0,onClick:()=>{X.showSettings=!0,t()},className:`flex min-h-[48px] w-full items-center gap-3 px-4 text-left active:bg-white/[0.04]`,children:[(0,L.jsx)(ph,{size:16,className:`shrink-0 text-muted/70`}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 text-[16px] leading-[21px] text-fg`,children:`Settings`}),(0,L.jsx)(ym,{size:17,className:`shrink-0 text-muted/45`})]})})})]})]})}function NW(){let e=Zt(X),t=qC(),[n,r]=(0,I.useState)(`queue`),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(null),c=DU(WH(YC(t?.threads??[]))),l=Zt(yT).queueOrder,u=(0,I.useMemo)(()=>oE(c,l),[c,l]),d=(0,I.useMemo)(()=>{let e=u.active.filter(jT),t=u.active.filter(e=>!jT(e));return[...u.pinned,...e,...t]},[u.pinned,u.active]),f=d.filter(jT).length,p=n===`queue`?d:n===`snoozed`?u.snoozed:u.inactive,m=e.view.startsWith(`status:`)?e.view.slice(7):null,h=mW(t);return(0,L.jsxs)(`div`,{"data-mobile-board":!0,className:`relative min-h-dvh bg-bg`,children:[(0,L.jsx)(`div`,{className:`fixed inset-x-0 top-0 z-30 border-b border-border/70 bg-bg/85 pt-[env(safe-area-inset-top)] backdrop-blur-xl backdrop-saturate-150`,children:(0,L.jsxs)(`div`,{className:`flex h-[48px] items-center gap-1 px-2`,children:[(0,L.jsxs)(`a`,{href:`/`,className:`-ml-1 flex h-[44px] items-center gap-0.5 pl-1 pr-2 text-[16px] text-fg/85`,children:[(0,L.jsx)(vm,{size:20,strokeWidth:2.2}),(0,L.jsx)(`span`,{className:`truncate`,children:`Projects`})]}),(0,L.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 flex h-[48px] items-center justify-center px-[86px]`,children:(0,L.jsx)(`span`,{className:`truncate font-mono-keep text-[15px] font-semibold tracking-[-0.01em] text-fg`,children:h.state===`verified`?h.label:`Frizz`})}),(0,L.jsx)(`button`,{"aria-label":`Board actions`,"data-mobile-more":!0,onClick:()=>a(!0),className:`ml-auto flex size-[44px] items-center justify-center rounded-full text-fg/85 active:bg-white/[0.06]`,children:(0,L.jsx)(jm,{size:20})})]})}),(0,L.jsx)(`div`,{className:`flex min-h-dvh flex-col pb-[calc(83px+env(safe-area-inset-bottom))] pt-[calc(48px+env(safe-area-inset-top))]`,children:m?(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,L.jsx)(gW,{status:m})}):p.length===0?(0,L.jsx)(kW,{label:t?n===`queue`?`Nothing in the queue. Tap + to start a thread.`:n===`snoozed`?`Nothing held.`:`Nothing finished yet.`:`Loading…`}):(0,L.jsx)(`div`,{className:`border-b border-border/70 bg-panel/60`,children:p.map((e,t)=>(0,L.jsx)(OW,{t:e,last:t===p.length-1,openSwipe:o===e.id,onOpenSwipe:t=>s(t?e.id:null)},e.id))})}),(0,L.jsx)(`button`,{"aria-label":`New thread`,onClick:()=>X.showNewThread=!0,className:`fixed bottom-[calc(65px+env(safe-area-inset-bottom))] right-4 z-30 flex size-[56px] items-center justify-center rounded-full bg-fg text-bg shadow-lg shadow-black/50 active:opacity-85`,children:(0,L.jsx)(ch,{size:24,strokeWidth:2.2})}),i?(0,L.jsx)(MW,{connection:e.connection,onClose:()=>a(!1)}):null,(0,L.jsx)(`div`,{className:`fixed inset-x-0 bottom-0 z-30 border-t border-border/70 bg-bg/85 pb-[env(safe-area-inset-bottom)] backdrop-blur-xl backdrop-saturate-150`,children:(0,L.jsxs)(`div`,{className:`flex h-[49px] items-stretch`,children:[(0,L.jsx)(AW,{active:n===`queue`,label:`Queue`,count:f>0?f:d.length,asks:f>0,onClick:()=>r(`queue`),icon:(0,L.jsx)(bW,{size:_W})}),(0,L.jsx)(AW,{active:n===`snoozed`,label:`Snoozed`,count:u.snoozed.length,onClick:()=>r(`snoozed`),icon:(0,L.jsx)(CW,{size:_W})}),(0,L.jsx)(AW,{active:n===`done`,label:`Done`,count:u.inactive.length,onClick:()=>r(`done`),icon:(0,L.jsx)(SW,{size:_W})})]})})]})}var PW=`(max-width: 700px)`,FW=new Set,IW=null;function LW(e){return typeof window>`u`?()=>{}:(IW||(IW=window.matchMedia(PW),IW.addEventListener(`change`,()=>FW.forEach(e=>e()))),FW.add(e),()=>FW.delete(e))}function RW(){return IW?IW.matches:typeof window<`u`&&window.matchMedia(PW).matches}function zW(){return(0,I.useSyncExternalStore)(LW,RW,()=>!1)}var BW={schedule:(e,t)=>window.setTimeout(e,t),cancel:e=>window.clearTimeout(e)},VW=class{#e=`waiting`;#t=null;#n;#r;#i;#a;#o;constructor(e){this.#n=e.isActive,this.#r=e.isContentReady,this.#i=e.scrollToBottom,this.#a=e.clock??BW,this.#o=e.settleMs??120,e.preserveAnchor?.()&&(this.#e=`suppressed`)}get phase(){return this.#e}activationChanged(){if(!this.#s){if(!this.#n()){this.#l(),this.#e=`waiting`;return}this.#c()}}layoutChanged(){this.#s||!this.#n()||this.#c()}userIntent(){this.#s||(this.#l(),this.#e=`suppressed`)}dispose(){this.#l(),this.#e=`disposed`}get#s(){return this.#e===`complete`||this.#e===`suppressed`||this.#e===`disposed`}#c(){if(!this.#n()||!this.#r()){this.#l(),this.#e=`waiting`;return}this.#e=`settling`,this.#i(),this.#l(),this.#t=this.#a.schedule(()=>{if(this.#t=null,!this.#n()||!this.#r()){this.#e=`waiting`;return}if(!this.#i()){this.#c();return}this.#e=`complete`},this.#o)}#l(){this.#t!==null&&(this.#a.cancel(this.#t),this.#t=null)}};function HW(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var UW=HW();function WW(e){UW=e}var GW={exec:()=>null};function KW(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(qW.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var qW={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`)},JW=/^(?:[ \t]*(?:\n|$))+/,YW=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,XW=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,ZW=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,QW=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,$W=/(?:[*+-]|\d{1,9}[.)])/,eG=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,tG=KW(eG).replace(/bull/g,$W).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),nG=KW(eG).replace(/bull/g,$W).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),rG=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,iG=/^[^\n]+/,aG=/(?!\s*\])(?:\\.|[^\[\]\\])+/,oG=KW(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,aG).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),sG=KW(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,$W).getRegex(),cG=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,lG=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,uG=KW(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,lG).replace(`tag`,cG).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),dG=KW(rG).replace(`hr`,ZW).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,cG).getRegex(),fG={blockquote:KW(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,dG).getRegex(),code:YW,def:oG,fences:XW,heading:QW,hr:ZW,html:uG,lheading:tG,list:sG,newline:JW,paragraph:dG,table:GW,text:iG},pG=KW(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,ZW).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,cG).getRegex(),mG={...fG,lheading:nG,table:pG,paragraph:KW(rG).replace(`hr`,ZW).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,pG).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,cG).getRegex()},hG={...fG,html:KW(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,lG).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:GW,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:KW(rG).replace(`hr`,ZW).replace(`heading`,` *#{1,6} *[^
209
- ]`).replace(`lheading`,tG).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},gG=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,_G=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,vG=/^( {2,}|\\)\n(?!\s*$)/,yG=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,bG=/[\p{P}\p{S}]/u,xG=/[\s\p{P}\p{S}]/u,SG=/[^\s\p{P}\p{S}]/u,CG=KW(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,xG).getRegex(),wG=/(?!~)[\p{P}\p{S}]/u,TG=/(?!~)[\s\p{P}\p{S}]/u,EG=/(?:[^\s\p{P}\p{S}]|~)/u,DG=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,OG=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,kG=KW(OG,`u`).replace(/punct/g,bG).getRegex(),AG=KW(OG,`u`).replace(/punct/g,wG).getRegex(),jG=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,MG=KW(jG,`gu`).replace(/notPunctSpace/g,SG).replace(/punctSpace/g,xG).replace(/punct/g,bG).getRegex(),NG=KW(jG,`gu`).replace(/notPunctSpace/g,EG).replace(/punctSpace/g,TG).replace(/punct/g,wG).getRegex(),PG=KW(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,SG).replace(/punctSpace/g,xG).replace(/punct/g,bG).getRegex(),FG=KW(/\\(punct)/,`gu`).replace(/punct/g,bG).getRegex(),IG=KW(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),LG=KW(lG).replace(`(?:-->|$)`,`-->`).getRegex(),RG=KW(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,LG).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),zG=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,BG=KW(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,zG).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),VG=KW(/^!?\[(label)\]\[(ref)\]/).replace(`label`,zG).replace(`ref`,aG).getRegex(),HG=KW(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,aG).getRegex(),UG={_backpedal:GW,anyPunctuation:FG,autolink:IG,blockSkip:DG,br:vG,code:_G,del:GW,emStrongLDelim:kG,emStrongRDelimAst:MG,emStrongRDelimUnd:PG,escape:gG,link:BG,nolink:HG,punctuation:CG,reflink:VG,reflinkSearch:KW(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,VG).replace(`nolink`,HG).getRegex(),tag:RG,text:yG,url:GW},WG={...UG,link:KW(/^!?\[(label)\]\((.*?)\)/).replace(`label`,zG).getRegex(),reflink:KW(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,zG).getRegex()},GG={...UG,emStrongRDelimAst:NG,emStrongLDelim:AG,url:KW(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,`i`).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},KG={...GG,br:KW(vG).replace(`{2,}`,`*`).getRegex(),text:KW(GG.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},qG={normal:fG,gfm:mG,pedantic:hG},JG={normal:UG,gfm:GG,breaks:KG,pedantic:WG},YG={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},XG=e=>YG[e];function ZG(e,t){if(t){if(qW.escapeTest.test(e))return e.replace(qW.escapeReplace,XG)}else if(qW.escapeTestNoEncode.test(e))return e.replace(qW.escapeReplaceNoEncode,XG);return e}function QG(e){try{e=encodeURI(e).replace(qW.percentDecode,`%`)}catch{return null}return e}function $G(e,t){let n=e.replace(qW.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(qW.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(qW.slashPipe,`|`);return n}function eK(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function tK(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function nK(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function rK(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
208
+ `)}var rW=(0,L.jsx)(lW,{children:(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-rail-dot`,"data-running-indicator":`thread-background`})}),iW=9,aW=(0,L.jsx)(lW,{children:(0,L.jsx)(Hm,{size:iW,className:`text-muted/70`,style:{transform:`translateX(${iW/24}px)`}})}),oW=(0,L.jsx)(lW,{children:(0,L.jsx)(Um,{size:9,className:`text-muted/70`})});function sW(e,t=Date.now()){let n=(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`).map(e=>Date.parse(e.timer?.fireAt??``)).filter(e=>Number.isFinite(e)).sort((e,t)=>e-t)[0];return n===void 0?null:n>t?`fires in ${IE(n-t)}`:`firing…`}function cW(e){let t=eE(e);if(t===`archived`)return{node:(0,L.jsx)(lW,{children:(0,L.jsx)(gm,{size:10,strokeWidth:3,className:`text-muted/75`})}),tip:`Done`};if(t===`needs-input`)return{node:(0,L.jsx)(lW,{children:(0,L.jsx)(uW,{ch:`?`,muted:!0})}),tip:`Needs your input`};if(t===`working`)return{node:(0,L.jsx)(EE,{}),tip:`Working`};if(t===`background`)return{node:rW,tip:ZU(e,e.lastFence?.kind===`awaiting`&&vU(e.lastFence.hints)!==null?`At rest`:`At rest — a background shell is still running`)};if(t===`done`)return{node:(0,L.jsx)(lW,{children:(0,L.jsx)(gm,{size:10,strokeWidth:3,className:`text-muted/75`})}),tip:`Done`};if(t===`stalled`){let t=e.crashed===!0?`Stalled — the agent exited mid-turn`:`Stalled — the agent's process exited`;return{node:(0,L.jsx)(lW,{accent:!0,children:(0,L.jsx)(uW,{ch:`!`})}),tip:t}}if(t===`limit`){let t=e.limitPause,n=t?.window===`weekly`?`weekly limit`:t?.window===`session`?`session limit`:`usage limit`,r=t?.autoResume?t.resumesAt?`continuing automatically at ${gE(t.resumesAt)}`:`continuing automatically once the window resets`:`won't resume by itself — Retry to continue`;return{node:(0,L.jsx)(lW,{accent:!0,children:(0,L.jsx)(Um,{size:9,className:`text-accent`})}),tip:`Paused by the ${t?.backend===`codex`?`Codex`:`Claude`} ${n} — ${r}`}}if(t===`pr`)return{node:aW,tip:ZU(e,`At rest`)};if(t===`timer`)return{node:oW,tip:ZU(e,e.lastFence?.kind===`awaiting`&&vU(e.lastFence.hints)!==null?`At rest`:`At rest — waiting on a timer`,sW(e))};if(t===`snoozed`){let t=oW,n=aW,r=QT(e)?n:t,i=GT(e);if(i){let t=pT(i,e.snoozePrompt)??`Snoozed until a scheduled check`;return{node:r,tip:ZU(e,(e.questions?.length??0)>0||e.pendingQuestion===!0||e.pendingAsk?`${t}\nA question is unanswered behind this park`:t)}}let a=e.bgSnoozed===!0?`Snoozed until the background work returns`:null;if(e.lastFence?.kind!==`awaiting`)return a?{node:QT(e)?n:rW,tip:a}:{node:t,tip:(typeof e.revalidate==`string`?mT(e.revalidate):null)??`Auto-snoozed until a scheduled check`};let o=e.lastFence.hints.find(e=>e.kind===`pr`||e.kind===`shell`||e.kind===`agent`||e.kind===`timer`)?.kind;return{node:QT(e)?n:o===`shell`||o===`agent`?rW:t,tip:ZU(e,a??`Snoozed`,o===`timer`?sW(e):null)}}return{node:(0,L.jsx)(lW,{children:(0,L.jsx)(jm,{size:11,className:`text-muted/70`})}),tip:ZU(e,`At rest`)}}function lW({accent:e,children:t}){return(0,L.jsx)(`span`,{className:`inline-flex items-center justify-center rounded-[4px] border ${e?`border-accent/90`:`border-muted/45`}`,style:{width:15,height:15},children:t})}function uW({ch:e,muted:t}){return(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-rail-glyph font-bold leading-none ${t?`text-muted/70`:`text-accent`}`,style:{fontSize:10},children:e})}function dW(e){if(e.runtime===`running`||e.runtime===`spawning`||e.runtime===`perm-prompt`)return{node:(0,L.jsx)(fW,{}),tip:`Working`};let t=(e.subAgents??[]).some(e=>e.state===`running`);return e.runtime===`turn-idle`&&t&&!e.humanBlocked?{node:(0,L.jsx)(fW,{}),tip:`Working`}:jT(e)?{node:(0,L.jsx)(pW,{}),tip:`Needs your input`}:e.status===`needs-human`?{node:(0,L.jsx)(mW,{}),tip:`Awaiting you — open to read & reply`}:e.status===`blocked`&&e.mechanism===`timer`?{node:(0,L.jsx)(bh,{size:8,className:`text-muted/70`}),tip:`Waiting on a timer`}:e.status===`blocked`&&e.mechanism===`threads`?{node:(0,L.jsx)(wm,{size:8,className:`text-muted/70`}),tip:`Waiting on other work`}:{node:(0,L.jsx)(hW,{}),tip:null}}function fW(){return(0,L.jsx)(`span`,{className:`block rounded-full border border-muted/70 border-t-transparent animate-spin`,style:{width:8,height:8}})}function pW(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-sky-400`,style:{width:$U,height:$U}})}function mW(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-yellow-400`,style:{width:$U,height:$U}})}function hW(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-muted/30`,style:{width:$U,height:$U}})}function gW(e){if(!e)return{state:`loading`};let t=e.projectLabel?.trim()??``,n=t.lastIndexOf(`/`),r=n===-1?``:t.slice(0,n).trim(),i=n===-1?``:t.slice(n+1).trim();if(r&&i)return{state:`verified`,label:t,owner:r,repo:i};let a=t||e.projectName?.trim()||``;return a?{state:`local`,name:a}:{state:`unavailable`}}var _W={planning:`Being designed`,planned:`Roadmap`,active:`Active`,"needs-human":`Awaiting you`,blocked:`Blocked`,done:`Done`,dismissed:`Dismissed`,archived:`Done`};function vW({status:e}){let t=FT(YC(qC()?.threads??[])).filter(t=>e===`archived`?t.archived:t.status===e);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`header`,{className:`shrink-0 flex items-center gap-2 px-4 h-10 border-b border-border`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:_W[e]??e}),(0,L.jsx)(`span`,{className:`text-[11px] text-muted tabular-nums`,children:t.length})]}),(0,L.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto py-1.5`,children:[t.length===0&&(0,L.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted`,children:`No threads.`}),t.map(e=>(0,L.jsxs)(`button`,{className:`w-full text-left px-4 py-2 hover:bg-panel-2/60`,onClick:()=>_p(`thread`,e.id),children:[(0,L.jsx)(`div`,{className:`leading-snug`,children:CT(e)}),e.statusText&&(0,L.jsx)(`div`,{className:`text-[11px] text-muted mt-0.5`,children:e.statusText})]},e.id))]})]})}var yW=21,bW=4/15;function xW({children:e,tone:t=`border-muted/45`,size:n=18}){return(0,L.jsx)(`span`,{className:`inline-flex shrink-0 items-center justify-center border ${t}`,style:{width:n,height:n,borderRadius:n*bW},children:e})}function SW({size:e=18}){return(0,L.jsx)(xW,{size:e,children:(0,L.jsx)(`svg`,{width:Math.round(e*.52),height:Math.round(e*.52),viewBox:`0 0 10 10`,"aria-hidden":!0,className:`translate-x-[8%] text-muted/85`,children:(0,L.jsx)(`path`,{d:`M2.5 1.4 8.2 5 2.5 8.6Z`,fill:`currentColor`})})})}function CW({size:e=18}){return(0,L.jsx)(xW,{size:e,tone:`border-accent/90`,children:(0,L.jsx)(`span`,{className:`font-sans font-bold leading-none text-accent`,style:{fontSize:e*10/15},children:`?`})})}function wW({size:e=18}){return(0,L.jsx)(xW,{size:e,tone:`border-muted/40`,children:(0,L.jsx)(gm,{size:Math.round(e*10/15),strokeWidth:3,className:`text-muted/85`})})}function TW({size:e=18}){return(0,L.jsx)(xW,{size:e,children:(0,L.jsx)(Um,{size:Math.round(e*10/15),className:`text-muted/75`})})}function EW({kind:e}){return e===`needs-input`?(0,L.jsx)(CW,{}):e===`stalled`?(0,L.jsx)(xW,{tone:`border-accent/90`,children:(0,L.jsx)(`span`,{className:`font-sans text-[12px] font-bold leading-none text-accent`,children:`!`})}):e===`working`||e===`background`?(0,L.jsx)(SW,{}):e===`limit`?(0,L.jsx)(xW,{tone:`border-accent/90`,children:(0,L.jsx)(Um,{size:12,className:`text-accent`})}):e===`snoozed`||e===`timer`?(0,L.jsx)(TW,{}):e===`done`||e===`archived`?(0,L.jsx)(wW,{}):(0,L.jsx)(xW,{})}var DW=76,OW=10;function kW({open:e,onOpenChange:t,onSnooze:n,onDone:r,snoozeLabel:i,children:a}){let[o,s]=(0,I.useState)(0),c=(0,I.useRef)(null),l=e?-152:0,u=c.current?.claimed?o:l;return(0,L.jsxs)(`div`,{className:`relative overflow-hidden`,style:{touchAction:`pan-y`},children:[(0,L.jsxs)(`div`,{className:`absolute inset-y-0 right-0 flex`,"aria-hidden":!e,children:[(0,L.jsxs)(`button`,{"data-mobile-swipe-snooze":!0,onClick:()=>{t(!1),n()},className:`flex flex-col items-center justify-center gap-1 bg-elevated text-muted active:bg-panel-2`,style:{width:DW},children:[(0,L.jsx)(km,{size:19}),(0,L.jsx)(`span`,{className:`text-[11.5px]`,children:i})]}),(0,L.jsxs)(`button`,{"data-mobile-swipe-done":!0,onClick:()=>{t(!1),r()},className:`flex flex-col items-center justify-center gap-1 bg-live/85 text-bg active:brightness-95`,style:{width:DW},children:[(0,L.jsx)(gm,{size:19,strokeWidth:2.6}),(0,L.jsx)(`span`,{className:`text-[11.5px] font-medium`,children:`Done`})]})]}),(0,L.jsx)(`div`,{className:`relative bg-bg ${c.current?.claimed?``:`transition-transform duration-200 ease-out motion-reduce:transition-none`}`,style:{transform:`translateX(${u}px)`},onPointerDown:e=>{e.pointerType===`mouse`&&e.button!==0||(c.current={x:e.clientX,y:e.clientY,claimed:!1})},onPointerMove:e=>{let t=c.current;if(!t)return;let n=e.clientX-t.x,r=e.clientY-t.y;if(!t.claimed){if(Math.abs(n)<OW||Math.abs(n)<=Math.abs(r))return;t.claimed=!0,e.currentTarget.setPointerCapture(e.pointerId)}let i=Math.min(0,Math.max(-176,l+n));s(i)},onPointerUp:()=>{let e=c.current;if(c.current=null,!e?.claimed)return;let n=o<-152/2;s(0),t(n)},onPointerCancel:()=>{c.current=null,s(0)},onClickCapture:n=>{e&&(n.preventDefault(),n.stopPropagation(),t(!1))},children:a})]})}function AW({t:e,last:t,openSwipe:n,onOpenSwipe:r}){let i=Zt(yT).snoozePreset,a=TE(),o=eE(e),s=PT(e),c=e.runtime===`running`||e.runtime===`spawning`||o===`working`||o===`background`?null:fE(s,a),l=e.lastFence?.kind===`awaiting`?xU(e.lastFence.hints):null,u=sD(e.subAgents??[],`rail`);return(0,L.jsxs)(`div`,{className:o===`snoozed`?`opacity-60`:void 0,children:[(0,L.jsx)(kW,{open:n,onOpenChange:r,snoozeLabel:tT(i),onSnooze:async()=>{try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:iT(i),prompt:null}),Z(`Snoozed · ${tT(i)}`)}catch(e){Z(e instanceof Error?e.message.slice(0,100):`Snooze failed`)}},onDone:async()=>{TU(e.id);try{let t=await Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:!1});if(t.needsConfirmation){EU(e.id),Z(t.hold?.cutOff?`Cut off mid-turn — open the thread to retry it, or to mark it done anyway`:`Still running — open the thread to finish it`);return}Z(`Marked as done`)}catch(t){EU(e.id),Z(t instanceof Error?t.message.slice(0,100):`Could not mark as done`)}},children:(0,L.jsxs)(`button`,{"data-mobile-thread-row":e.id,onClick:()=>bp(e.id),className:`flex w-full items-start gap-3 px-4 pb-2.5 pt-2.5 text-left active:bg-white/[0.04]`,children:[(0,L.jsx)(`span`,{className:`flex h-[21px] shrink-0 items-center justify-center`,children:(0,L.jsx)(EW,{kind:o})}),(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[3px]`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-3`,children:[(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 text-[15px] font-medium leading-[21px] tracking-[-0.01em] text-fg`,children:[CT(e),(0,L.jsx)(zz,{backend:e.backend,className:`ml-1.5`})]}),c?(0,L.jsx)(`span`,{className:`shrink-0 text-[11.5px] leading-[21px] tabular-nums text-muted/60`,children:c}):null]}),l?(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[13px] leading-[18px] text-muted`,children:l}):null,e.activity?(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[13px] leading-[18px] text-muted/85`,children:e.activity}):null]})]})}),u.length>0?(0,L.jsx)(`div`,{className:`flex flex-col pb-1`,children:u.map(t=>(0,L.jsx)(uD,{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:sM(e.id,t),title:t.subagentType?`[${t.subagentType}] ${t.label}`:t.label},t.id))}):null,t?null:(0,L.jsx)(`div`,{className:`ml-[46px] h-px bg-border/70`})]})}function jW({label:e}){return(0,L.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center px-10 pb-24 text-center`,children:(0,L.jsx)(`p`,{className:`m-0 text-[15px] text-muted`,children:e})})}function MW({active:e,label:t,count:n,asks:r,icon:i,onClick:a}){return(0,L.jsxs)(`button`,{"data-mobile-tab":t.toLowerCase(),"aria-current":e?`page`:void 0,onClick:a,className:`flex flex-1 flex-col items-center justify-center gap-[3px] pt-[3px]`,children:[(0,L.jsxs)(`span`,{className:`relative ${e?`opacity-100`:`opacity-55`}`,children:[i,n>0?(0,L.jsx)(`span`,{className:`absolute -right-[11px] -top-[7px] flex h-[16px] min-w-[16px] items-center justify-center rounded-full border-[1.5px] border-bg px-[3.5px] text-[10px] font-semibold tabular-nums ${r?`bg-accent text-bg`:`bg-elevated text-muted`}`,children:n}):null]}),(0,L.jsx)(`span`,{className:`text-[10px] leading-[12px] tracking-[-0.005em] ${e?`text-fg`:`text-muted/70`}`,children:t})]})}var NW={open:{cls:`bg-live`,word:`connected`},connecting:{cls:`bg-accent`,word:`connecting…`},closed:{cls:`bg-red-500`,word:`disconnected`}};function PW({connection:e,onClose:t}){let n=NW[e],[r,i]=(0,I.useState)(!1);return(0,I.useEffect)(()=>{let e=requestAnimationFrame(()=>i(!0));return()=>cancelAnimationFrame(e)},[]),(0,L.jsxs)(`div`,{"data-mobile-more-sheet":!0,className:`fixed inset-0 z-[70] flex flex-col justify-end`,children:[(0,L.jsx)(`button`,{"aria-label":`Close`,onClick:t,className:`absolute inset-0 bg-black/50 transition-opacity duration-200 ${r?`opacity-100`:`opacity-0`}`}),(0,L.jsxs)(`div`,{className:`relative flex max-h-[80%] flex-col overflow-hidden rounded-t-[14px] border-t border-border-strong bg-panel pb-[calc(24px+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 ${r?`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 items-center justify-between gap-3 px-4 pb-3 pt-3`,children:[(0,L.jsxs)(`span`,{className:`flex items-baseline gap-2 text-[13px] text-muted`,children:[(0,L.jsx)(`span`,{className:`inline-block size-[7px] translate-y-[-1px] rounded-full ${n.cls}`}),n.word]}),(0,L.jsx)(RV,{})]}),(0,L.jsx)(`div`,{className:`min-h-0 overflow-y-auto`,children:(0,L.jsx)(`div`,{className:`border-y border-border/70 bg-panel/60`,children:(0,L.jsxs)(`button`,{"data-mobile-settings-row":!0,onClick:()=>{X.showSettings=!0,t()},className:`flex min-h-[48px] w-full items-center gap-3 px-4 text-left active:bg-white/[0.04]`,children:[(0,L.jsx)(ph,{size:16,className:`shrink-0 text-muted/70`}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 text-[16px] leading-[21px] text-fg`,children:`Settings`}),(0,L.jsx)(ym,{size:17,className:`shrink-0 text-muted/45`})]})})})]})]})}function FW(){let e=Zt(X),t=qC(),[n,r]=(0,I.useState)(`queue`),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(null),c=kU(KH(YC(t?.threads??[]))),l=Zt(yT).queueOrder,u=(0,I.useMemo)(()=>oE(c,l),[c,l]),d=(0,I.useMemo)(()=>{let e=u.active.filter(jT),t=u.active.filter(e=>!jT(e));return[...u.pinned,...e,...t]},[u.pinned,u.active]),f=d.filter(jT).length,p=n===`queue`?d:n===`snoozed`?u.snoozed:u.inactive,m=e.view.startsWith(`status:`)?e.view.slice(7):null,h=gW(t);return(0,L.jsxs)(`div`,{"data-mobile-board":!0,className:`relative min-h-dvh bg-bg`,children:[(0,L.jsx)(`div`,{className:`fixed inset-x-0 top-0 z-30 border-b border-border/70 bg-bg/85 pt-[env(safe-area-inset-top)] backdrop-blur-xl backdrop-saturate-150`,children:(0,L.jsxs)(`div`,{className:`flex h-[48px] items-center gap-1 px-2`,children:[(0,L.jsxs)(`a`,{href:`/`,className:`-ml-1 flex h-[44px] items-center gap-0.5 pl-1 pr-2 text-[16px] text-fg/85`,children:[(0,L.jsx)(vm,{size:20,strokeWidth:2.2}),(0,L.jsx)(`span`,{className:`truncate`,children:`Projects`})]}),(0,L.jsx)(`div`,{className:`pointer-events-none absolute inset-x-0 bottom-0 flex h-[48px] items-center justify-center px-[86px]`,children:(0,L.jsx)(`span`,{className:`truncate font-mono-keep text-[15px] font-semibold tracking-[-0.01em] text-fg`,children:h.state===`verified`?h.label:`Frizz`})}),(0,L.jsx)(`button`,{"aria-label":`Board actions`,"data-mobile-more":!0,onClick:()=>a(!0),className:`ml-auto flex size-[44px] items-center justify-center rounded-full text-fg/85 active:bg-white/[0.06]`,children:(0,L.jsx)(jm,{size:20})})]})}),(0,L.jsx)(`div`,{className:`flex min-h-dvh flex-col pb-[calc(83px+env(safe-area-inset-bottom))] pt-[calc(48px+env(safe-area-inset-top))]`,children:m?(0,L.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,L.jsx)(vW,{status:m})}):p.length===0?(0,L.jsx)(jW,{label:t?n===`queue`?`Nothing in the queue. Tap + to start a thread.`:n===`snoozed`?`Nothing held.`:`Nothing finished yet.`:`Loading…`}):(0,L.jsx)(`div`,{className:`border-b border-border/70 bg-panel/60`,children:p.map((e,t)=>(0,L.jsx)(AW,{t:e,last:t===p.length-1,openSwipe:o===e.id,onOpenSwipe:t=>s(t?e.id:null)},e.id))})}),(0,L.jsx)(`button`,{"aria-label":`New thread`,onClick:()=>X.showNewThread=!0,className:`fixed bottom-[calc(65px+env(safe-area-inset-bottom))] right-4 z-30 flex size-[56px] items-center justify-center rounded-full bg-fg text-bg shadow-lg shadow-black/50 active:opacity-85`,children:(0,L.jsx)(ch,{size:24,strokeWidth:2.2})}),i?(0,L.jsx)(PW,{connection:e.connection,onClose:()=>a(!1)}):null,(0,L.jsx)(`div`,{className:`fixed inset-x-0 bottom-0 z-30 border-t border-border/70 bg-bg/85 pb-[env(safe-area-inset-bottom)] backdrop-blur-xl backdrop-saturate-150`,children:(0,L.jsxs)(`div`,{className:`flex h-[49px] items-stretch`,children:[(0,L.jsx)(MW,{active:n===`queue`,label:`Queue`,count:f>0?f:d.length,asks:f>0,onClick:()=>r(`queue`),icon:(0,L.jsx)(SW,{size:yW})}),(0,L.jsx)(MW,{active:n===`snoozed`,label:`Snoozed`,count:u.snoozed.length,onClick:()=>r(`snoozed`),icon:(0,L.jsx)(TW,{size:yW})}),(0,L.jsx)(MW,{active:n===`done`,label:`Done`,count:u.inactive.length,onClick:()=>r(`done`),icon:(0,L.jsx)(wW,{size:yW})})]})})]})}var IW=`(max-width: 700px)`,LW=new Set,RW=null;function zW(e){return typeof window>`u`?()=>{}:(RW||(RW=window.matchMedia(IW),RW.addEventListener(`change`,()=>LW.forEach(e=>e()))),LW.add(e),()=>LW.delete(e))}function BW(){return RW?RW.matches:typeof window<`u`&&window.matchMedia(IW).matches}function VW(){return(0,I.useSyncExternalStore)(zW,BW,()=>!1)}var HW={schedule:(e,t)=>window.setTimeout(e,t),cancel:e=>window.clearTimeout(e)},UW=class{#e=`waiting`;#t=null;#n;#r;#i;#a;#o;constructor(e){this.#n=e.isActive,this.#r=e.isContentReady,this.#i=e.scrollToBottom,this.#a=e.clock??HW,this.#o=e.settleMs??120,e.preserveAnchor?.()&&(this.#e=`suppressed`)}get phase(){return this.#e}activationChanged(){if(!this.#s){if(!this.#n()){this.#l(),this.#e=`waiting`;return}this.#c()}}layoutChanged(){this.#s||!this.#n()||this.#c()}userIntent(){this.#s||(this.#l(),this.#e=`suppressed`)}dispose(){this.#l(),this.#e=`disposed`}get#s(){return this.#e===`complete`||this.#e===`suppressed`||this.#e===`disposed`}#c(){if(!this.#n()||!this.#r()){this.#l(),this.#e=`waiting`;return}this.#e=`settling`,this.#i(),this.#l(),this.#t=this.#a.schedule(()=>{if(this.#t=null,!this.#n()||!this.#r()){this.#e=`waiting`;return}if(!this.#i()){this.#c();return}this.#e=`complete`},this.#o)}#l(){this.#t!==null&&(this.#a.cancel(this.#t),this.#t=null)}};function WW(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var GW=WW();function KW(e){GW=e}var qW={exec:()=>null};function JW(e,t=``){let n=typeof e==`string`?e:e.source,r={replace:(e,t)=>{let i=typeof t==`string`?t:t.source;return i=i.replace(YW.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var YW={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^<a /i,endATag:/^<\/a>/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^</,endAngleBracket:/>$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/gi,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:e=>RegExp(`^( {0,3}${e})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}#`),htmlBeginRegex:e=>RegExp(`^ {0,${Math.min(3,e-1)}}<(?:[a-z].*>|!--)`,`i`)},XW=/^(?:[ \t]*(?:\n|$))+/,ZW=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,QW=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,$W=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,eG=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,tG=/(?:[*+-]|\d{1,9}[.)])/,nG=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,rG=JW(nG).replace(/bull/g,tG).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,``).getRegex(),iG=JW(nG).replace(/bull/g,tG).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),aG=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,oG=/^[^\n]+/,sG=/(?!\s*\])(?:\\.|[^\[\]\\])+/,cG=JW(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,sG).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),lG=JW(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,tG).getRegex(),uG=`address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul`,dG=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,fG=JW(`^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))`,`i`).replace(`comment`,dG).replace(`tag`,uG).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),pG=JW(aG).replace(`hr`,$W).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,uG).getRegex(),mG={blockquote:JW(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,pG).getRegex(),code:ZW,def:cG,fences:QW,heading:eG,hr:$W,html:fG,lheading:rG,list:lG,newline:XW,paragraph:pG,table:qW,text:oG},hG=JW(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,$W).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`blockquote`,` {0,3}>`).replace(`code`,`(?: {4}| {0,3} )[^\\n]`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,uG).getRegex(),gG={...mG,lheading:iG,table:hG,paragraph:JW(aG).replace(`hr`,$W).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,hG).replace(`blockquote`,` {0,3}>`).replace(`fences`," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace(`list`,` {0,3}(?:[*+-]|1[.)]) `).replace(`html`,`</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)`).replace(`tag`,uG).getRegex()},_G={...mG,html:JW(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,dG).replace(/tag/g,`(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b`).getRegex(),def:/^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:qW,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:JW(aG).replace(`hr`,$W).replace(`heading`,` *#{1,6} *[^
209
+ ]`).replace(`lheading`,rG).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},vG=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,yG=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,bG=/^( {2,}|\\)\n(?!\s*$)/,xG=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,SG=/[\p{P}\p{S}]/u,CG=/[\s\p{P}\p{S}]/u,wG=/[^\s\p{P}\p{S}]/u,TG=JW(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,CG).getRegex(),EG=/(?!~)[\p{P}\p{S}]/u,DG=/(?!~)[\s\p{P}\p{S}]/u,OG=/(?:[^\s\p{P}\p{S}]|~)/u,kG=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,AG=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,jG=JW(AG,`u`).replace(/punct/g,SG).getRegex(),MG=JW(AG,`u`).replace(/punct/g,EG).getRegex(),NG=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,PG=JW(NG,`gu`).replace(/notPunctSpace/g,wG).replace(/punctSpace/g,CG).replace(/punct/g,SG).getRegex(),FG=JW(NG,`gu`).replace(/notPunctSpace/g,OG).replace(/punctSpace/g,DG).replace(/punct/g,EG).getRegex(),IG=JW(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,wG).replace(/punctSpace/g,CG).replace(/punct/g,SG).getRegex(),LG=JW(/\\(punct)/,`gu`).replace(/punct/g,SG).getRegex(),RG=JW(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace(`scheme`,/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace(`email`,/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),zG=JW(dG).replace(`(?:-->|$)`,`-->`).getRegex(),BG=JW(`^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>`).replace(`comment`,zG).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),VG=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,HG=JW(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,VG).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),UG=JW(/^!?\[(label)\]\[(ref)\]/).replace(`label`,VG).replace(`ref`,sG).getRegex(),WG=JW(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,sG).getRegex(),GG={_backpedal:qW,anyPunctuation:LG,autolink:RG,blockSkip:kG,br:bG,code:yG,del:qW,emStrongLDelim:jG,emStrongRDelimAst:PG,emStrongRDelimUnd:IG,escape:vG,link:HG,nolink:WG,punctuation:TG,reflink:UG,reflinkSearch:JW(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,UG).replace(`nolink`,WG).getRegex(),tag:BG,text:xG,url:qW},KG={...GG,link:JW(/^!?\[(label)\]\((.*?)\)/).replace(`label`,VG).getRegex(),reflink:JW(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,VG).getRegex()},qG={...GG,emStrongRDelimAst:FG,emStrongLDelim:MG,url:JW(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,`i`).replace(`email`,/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/},JG={...qG,br:JW(bG).replace(`{2,}`,`*`).getRegex(),text:JW(qG.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},YG={normal:mG,gfm:gG,pedantic:_G},XG={normal:GG,gfm:qG,breaks:JG,pedantic:KG},ZG={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},QG=e=>ZG[e];function $G(e,t){if(t){if(YW.escapeTest.test(e))return e.replace(YW.escapeReplace,QG)}else if(YW.escapeTestNoEncode.test(e))return e.replace(YW.escapeReplaceNoEncode,QG);return e}function eK(e){try{e=encodeURI(e).replace(YW.percentDecode,`%`)}catch{return null}return e}function tK(e,t){let n=e.replace(YW.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(YW.splitPipe),r=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),t)if(n.length>t)n.splice(t);else for(;n.length<t;)n.push(``);for(;r<n.length;r++)n[r]=n[r].trim().replace(YW.slashPipe,`|`);return n}function nK(e,t,n){let r=e.length;if(r===0)return``;let i=0;for(;i<r;){let a=e.charAt(r-i-1);if(a===t&&!n)i++;else if(a!==t&&n)i++;else break}return e.slice(0,r-i)}function rK(e,t){if(e.indexOf(t[1])===-1)return-1;let n=0;for(let r=0;r<e.length;r++)if(e[r]===`\\`)r++;else if(e[r]===t[0])n++;else if(e[r]===t[1]&&(n--,n<0))return r;return n>0?-2:-1}function iK(e,t,n,r,i){let a=t.href,o=t.title||null,s=e[1].replace(i.other.outputLinkReplace,`$1`);r.state.inLink=!0;let c={type:e[0].charAt(0)===`!`?`image`:`link`,raw:n,href:a,title:o,text:s,tokens:r.inlineTokens(s)};return r.state.inLink=!1,c}function aK(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
210
210
  `).map(e=>{let t=e.match(n.other.beginningSpace);if(t===null)return e;let[r]=t;return r.length>=i.length?e.slice(i.length):e}).join(`
211
- `)}var iK=class{options;rules;lexer;constructor(e){this.options=e||UW}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:eK(e,`
212
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=rK(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=eK(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:eK(t[0],`
213
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=eK(t[0],`
211
+ `)}var oK=class{options;rules;lexer;constructor(e){this.options=e||GW}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:`space`,raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let e=t[0].replace(this.rules.other.codeRemoveIndent,``);return{type:`code`,raw:t[0],codeBlockStyle:`indented`,text:this.options.pedantic?e:nK(e,`
212
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=aK(e,t[3]||``,this.rules);return{type:`code`,raw:e,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,`$1`):t[2],text:n}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let e=t[2].trim();if(this.rules.other.endingHash.test(e)){let t=nK(e,`#`);(this.options.pedantic||!t||this.rules.other.endingSpaceChar.test(t))&&(e=t.trim())}return{type:`heading`,raw:t[0],depth:t[1].length,text:e,tokens:this.lexer.inline(e)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:`hr`,raw:nK(t[0],`
213
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=nK(t[0],`
214
214
  `).split(`
215
215
  `),n=``,r=``,i=[];for(;e.length>0;){let t=!1,a=[],o;for(o=0;o<e.length;o++)if(this.rules.other.blockquoteStart.test(e[o]))a.push(e[o]),t=!0;else if(!t)a.push(e[o]);else break;e=e.slice(o);let s=a.join(`
216
216
  `),c=s.replace(this.rules.other.blockquoteSetextReplace,`
@@ -228,10 +228,10 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
228
228
  `,1)[0],p;if(l=f,this.options.pedantic?(l=l.replace(this.rules.other.listReplaceNesting,` `),p=l):p=l.replace(this.rules.other.tabCharGlobal,` `),i.test(l)||a.test(l)||o.test(l)||t.test(l)||n.test(l))break;if(p.search(this.rules.other.nonSpaceChar)>=d||!l.trim())s+=`
229
229
  `+p.slice(d);else{if(u||c.replace(this.rules.other.tabCharGlobal,` `).search(this.rules.other.nonSpaceChar)>=4||i.test(c)||a.test(c)||n.test(c))break;s+=`
230
230
  `+l}!u&&!l.trim()&&(u=!0),r+=f+`
231
- `,e=e.substring(f.length+1),c=p.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0));let f=null,p;this.options.gfm&&(f=this.rules.other.listIsTask.exec(s),f&&(p=f[0]!==`[ ] `,s=s.replace(this.rules.other.listReplaceTask,``))),i.items.push({type:`list_item`,raw:r,task:!!f,checked:p,loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e=0;e<i.items.length;e++)if(this.lexer.state.top=!1,i.items[e].tokens=this.lexer.blockTokens(i.items[e].text,[]),!i.loose){let t=i.items[e].tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}if(i.loose)for(let e=0;e<i.items.length;e++)i.items[e].loose=!0;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=$G(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
232
- `):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push($G(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
233
- `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=eK(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=tK(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),nK(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return nK(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(r&&!(r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},aK=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||UW,this.options.tokenizer=this.options.tokenizer||new iK,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:qW,block:qG.normal,inline:JG.normal};this.options.pedantic?(t.block=qG.pedantic,t.inline=JG.pedantic):this.options.gfm&&(t.block=qG.gfm,this.options.breaks?t.inline=JG.breaks:t.inline=JG.gfm),this.tokenizer.rules=t}static get rules(){return{block:qG,inline:JG}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(qW.carriageReturn,`
234
- `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(qW.tabCharGlobal,` `).replace(qW.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
231
+ `,e=e.substring(f.length+1),c=p.slice(d)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(r)&&(o=!0));let f=null,p;this.options.gfm&&(f=this.rules.other.listIsTask.exec(s),f&&(p=f[0]!==`[ ] `,s=s.replace(this.rules.other.listReplaceTask,``))),i.items.push({type:`list_item`,raw:r,task:!!f,checked:p,loose:!1,text:s,tokens:[]}),i.raw+=r}let s=i.items.at(-1);if(s)s.raw=s.raw.trimEnd(),s.text=s.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let e=0;e<i.items.length;e++)if(this.lexer.state.top=!1,i.items[e].tokens=this.lexer.blockTokens(i.items[e].text,[]),!i.loose){let t=i.items[e].tokens.filter(e=>e.type===`space`);i.loose=t.length>0&&t.some(e=>this.rules.other.anyLine.test(e.raw))}if(i.loose)for(let e=0;e<i.items.length;e++)i.items[e].loose=!0;return i}}html(e){let t=this.rules.block.html.exec(e);if(t)return{type:`html`,block:!0,raw:t[0],pre:t[1]===`pre`||t[1]===`script`||t[1]===`style`,text:t[0]}}def(e){let t=this.rules.block.def.exec(e);if(t){let e=t[1].toLowerCase().replace(this.rules.other.multipleSpaceGlobal,` `),n=t[2]?t[2].replace(this.rules.other.hrefBrackets,`$1`).replace(this.rules.inline.anyPunctuation,`$1`):``,r=t[3]?t[3].substring(1,t[3].length-1).replace(this.rules.inline.anyPunctuation,`$1`):t[3];return{type:`def`,tag:e,raw:t[0],href:n,title:r}}}table(e){let t=this.rules.block.table.exec(e);if(!t||!this.rules.other.tableDelimiter.test(t[2]))return;let n=tK(t[1]),r=t[2].replace(this.rules.other.tableAlignChars,``).split(`|`),i=t[3]?.trim()?t[3].replace(this.rules.other.tableRowBlankLine,``).split(`
232
+ `):[],a={type:`table`,raw:t[0],header:[],align:[],rows:[]};if(n.length===r.length){for(let e of r)this.rules.other.tableAlignRight.test(e)?a.align.push(`right`):this.rules.other.tableAlignCenter.test(e)?a.align.push(`center`):this.rules.other.tableAlignLeft.test(e)?a.align.push(`left`):a.align.push(null);for(let e=0;e<n.length;e++)a.header.push({text:n[e],tokens:this.lexer.inline(n[e]),header:!0,align:a.align[e]});for(let e of i)a.rows.push(tK(e,a.header.length).map((e,t)=>({text:e,tokens:this.lexer.inline(e),header:!1,align:a.align[t]})));return a}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:`heading`,raw:t[0],depth:t[2].charAt(0)===`=`?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let e=t[1].charAt(t[1].length-1)===`
233
+ `?t[1].slice(0,-1):t[1];return{type:`paragraph`,raw:t[0],text:e,tokens:this.lexer.inline(e)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:`text`,raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:`escape`,raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:`html`,raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let e=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(e)){if(!this.rules.other.endAngleBracket.test(e))return;let t=nK(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=rK(t[2],`()`);if(e===-2)return;if(e>-1){let n=(t[0].indexOf(`!`)===0?5:4)+t[1].length+e;t[2]=t[2].substring(0,e),t[0]=t[0].substring(0,n).trim(),t[3]=``}}let n=t[2],r=``;if(this.options.pedantic){let e=this.rules.other.pedanticHrefTitle.exec(n);e&&(n=e[1],r=e[3])}else r=t[3]?t[3].slice(1,-1):``;return n=n.trim(),this.rules.other.startAngleBracket.test(n)&&(n=this.options.pedantic&&!this.rules.other.endAngleBracket.test(e)?n.slice(1):n.slice(1,-1)),iK(t,{href:n&&n.replace(this.rules.inline.anyPunctuation,`$1`),title:r&&r.replace(this.rules.inline.anyPunctuation,`$1`)},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let e=t[(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal,` `).toLowerCase()];if(!e){let e=n[0].charAt(0);return{type:`text`,raw:e,text:e}}return iK(n,e,n[0],this.lexer,this.rules)}}emStrong(e,t,n=``){let r=this.rules.inline.emStrongLDelim.exec(e);if(r&&!(r[3]&&n.match(this.rules.other.unicodeAlphaNumeric))&&(!(r[1]||r[2])||!n||this.rules.inline.punctuation.exec(n))){let n=[...r[0]].length-1,i,a,o=n,s=0,c=r[0][0]===`*`?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(c.lastIndex=0,t=t.slice(-1*e.length+n);(r=c.exec(t))!=null;){if(i=r[1]||r[2]||r[3]||r[4]||r[5]||r[6],!i)continue;if(a=[...i].length,r[3]||r[4]){o+=a;continue}else if((r[5]||r[6])&&n%3&&!((n+a)%3)){s+=a;continue}if(o-=a,o>0)continue;a=Math.min(a,a+o+s);let t=[...r[0]][0].length,c=e.slice(0,n+r.index+t+a);if(Math.min(n,a)%2){let e=c.slice(1,-1);return{type:`em`,raw:c,text:e,tokens:this.lexer.inlineTokens(e)}}let l=c.slice(2,-2);return{type:`strong`,raw:c,text:l,tokens:this.lexer.inlineTokens(l)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let e=t[2].replace(this.rules.other.newLineCharGlobal,` `),n=this.rules.other.nonSpaceChar.test(e),r=this.rules.other.startingSpaceChar.test(e)&&this.rules.other.endingSpaceChar.test(e);return n&&r&&(e=e.substring(1,e.length-1)),{type:`codespan`,raw:t[0],text:e}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:`br`,raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let e,n;return t[2]===`@`?(e=t[1],n=`mailto:`+e):(e=t[1],n=e),{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let e,n;if(t[2]===`@`)e=t[0],n=`mailto:`+e;else{let r;do r=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??``;while(r!==t[0]);e=t[0],n=t[1]===`www.`?`http://`+t[0]:t[0]}return{type:`link`,raw:t[0],text:e,href:n,tokens:[{type:`text`,raw:e,text:e}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let e=this.lexer.state.inRawBlock;return{type:`text`,raw:t[0],text:t[0],escaped:e}}}},sK=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||GW,this.options.tokenizer=this.options.tokenizer||new oK,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:YW,block:YG.normal,inline:XG.normal};this.options.pedantic?(t.block=YG.pedantic,t.inline=XG.pedantic):this.options.gfm&&(t.block=YG.gfm,this.options.breaks?t.inline=XG.breaks:t.inline=XG.gfm),this.tokenizer.rules=t}static get rules(){return{block:YG,inline:XG}}static lex(t,n){return new e(n).lex(t)}static lexInline(t,n){return new e(n).inlineTokens(t)}lex(e){e=e.replace(YW.carriageReturn,`
234
+ `),this.blockTokens(e,this.tokens);for(let e=0;e<this.inlineQueue.length;e++){let t=this.inlineQueue[e];this.inlineTokens(t.src,t.tokens)}return this.inlineQueue=[],this.tokens}blockTokens(e,t=[],n=!1){for(this.options.pedantic&&(e=e.replace(YW.tabCharGlobal,` `).replace(YW.spaceLine,``));e;){let r;if(this.options.extensions?.block?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.space(e)){e=e.substring(r.raw.length);let n=t.at(-1);r.raw.length===1&&n!==void 0?n.raw+=`
235
235
  `:t.push(r);continue}if(r=this.tokenizer.code(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=`
236
236
  `+r.raw,n.text+=`
237
237
  `+r.text,this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(r=this.tokenizer.fences(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.heading(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.hr(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.blockquote(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.list(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.html(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.def(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`paragraph`||n?.type===`text`?(n.raw+=`
@@ -240,16 +240,16 @@ ${c}`:c;let l=this.lexer.state.top;if(this.lexer.state.top=!0,this.lexer.blockTo
240
240
  `+r.raw,a.text+=`
241
241
  `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=a.text):t.push(r),n=i.length!==e.length,e=e.substring(r.raw.length);continue}if(r=this.tokenizer.text(e)){e=e.substring(r.raw.length);let n=t.at(-1);n?.type===`text`?(n.raw+=`
242
242
  `+r.raw,n.text+=`
243
- `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let i=!1,a=``;for(;e;){i||(a=``),i=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,a)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let o=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(o=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(o)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(a=r.raw.slice(-1)),i=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},oK=class{options;parser;constructor(e){this.options=e||UW}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(qW.notSpaceStart)?.[0],i=e.replace(qW.endingNewline,``)+`
244
- `;return r?`<pre><code class="language-`+ZG(r)+`">`+(n?i:ZG(i,!0))+`</code></pre>
245
- `:`<pre><code>`+(n?i:ZG(i,!0))+`</code></pre>
243
+ `+r.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=n.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,r=null;if(this.tokens.links){let e=Object.keys(this.tokens.links);if(e.length>0)for(;(r=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)e.includes(r[0].slice(r[0].lastIndexOf(`[`)+1,-1))&&(n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(r=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,r.index)+`++`+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(r=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,r.index)+`[`+`a`.repeat(r[0].length-2)+`]`+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let i=!1,a=``;for(;e;){i||(a=``),i=!1;let r;if(this.options.extensions?.inline?.some(n=>(r=n.call({lexer:this},e,t))?(e=e.substring(r.raw.length),t.push(r),!0):!1))continue;if(r=this.tokenizer.escape(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.tag(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.link(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(r.raw.length);let n=t.at(-1);r.type===`text`&&n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(r=this.tokenizer.emStrong(e,n,a)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.codespan(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.br(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.del(e)){e=e.substring(r.raw.length),t.push(r);continue}if(r=this.tokenizer.autolink(e)){e=e.substring(r.raw.length),t.push(r);continue}if(!this.state.inLink&&(r=this.tokenizer.url(e))){e=e.substring(r.raw.length),t.push(r);continue}let o=e;if(this.options.extensions?.startInline){let t=1/0,n=e.slice(1),r;this.options.extensions.startInline.forEach(e=>{r=e.call({lexer:this},n),typeof r==`number`&&r>=0&&(t=Math.min(t,r))}),t<1/0&&t>=0&&(o=e.substring(0,t+1))}if(r=this.tokenizer.inlineText(o)){e=e.substring(r.raw.length),r.raw.slice(-1)!==`_`&&(a=r.raw.slice(-1)),i=!0;let n=t.at(-1);n?.type===`text`?(n.raw+=r.raw,n.text+=r.text):t.push(r);continue}if(e){let t=`Infinite loop on byte: `+e.charCodeAt(0);if(this.options.silent){console.error(t);break}else throw Error(t)}}return t}},cK=class{options;parser;constructor(e){this.options=e||GW}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(YW.notSpaceStart)?.[0],i=e.replace(YW.endingNewline,``)+`
244
+ `;return r?`<pre><code class="language-`+$G(r)+`">`+(n?i:$G(i,!0))+`</code></pre>
245
+ `:`<pre><code>`+(n?i:$G(i,!0))+`</code></pre>
246
246
  `}blockquote({tokens:e}){return`<blockquote>
247
247
  ${this.parser.parse(e)}</blockquote>
248
248
  `}html({text:e}){return e}heading({tokens:e,depth:t}){return`<h${t}>${this.parser.parseInline(e)}</h${t}>
249
249
  `}hr(e){return`<hr>
250
250
  `}list(e){let t=e.ordered,n=e.start,r=``;for(let t=0;t<e.items.length;t++){let n=e.items[t];r+=this.listitem(n)}let i=t?`ol`:`ul`,a=t&&n!==1?` start="`+n+`"`:``;return`<`+i+a+`>
251
251
  `+r+`</`+i+`>
252
- `}listitem(e){let t=``;if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type===`paragraph`?(e.tokens[0].text=n+` `+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type===`text`&&(e.tokens[0].tokens[0].text=n+` `+ZG(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:`text`,raw:n+` `,text:n+` `,escaped:!0}):t+=n+` `}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
252
+ `}listitem(e){let t=``;if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type===`paragraph`?(e.tokens[0].text=n+` `+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type===`text`&&(e.tokens[0].tokens[0].text=n+` `+$G(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:`text`,raw:n+` `,text:n+` `,escaped:!0}):t+=n+` `}return t+=this.parser.parse(e.tokens,!!e.loose),`<li>${t}</li>
253
253
  `}checkbox({checked:e}){return`<input `+(e?`checked="" `:``)+`disabled="" type="checkbox">`}paragraph({tokens:e}){return`<p>${this.parser.parseInline(e)}</p>
254
254
  `}table(e){let t=``,n=``;for(let t=0;t<e.header.length;t++)n+=this.tablecell(e.header[t]);t+=this.tablerow({text:n});let r=``;for(let t=0;t<e.rows.length;t++){let i=e.rows[t];n=``;for(let e=0;e<i.length;e++)n+=this.tablecell(i[e]);r+=this.tablerow({text:n})}return r&&=`<tbody>${r}</tbody>`,`<table>
255
255
  <thead>
@@ -258,62 +258,62 @@ ${this.parser.parse(e)}</blockquote>
258
258
  `}tablerow({text:e}){return`<tr>
259
259
  ${e}</tr>
260
260
  `}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?`th`:`td`;return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+`</${n}>
261
- `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${ZG(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=QG(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+ZG(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=QG(e);if(i===null)return ZG(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${ZG(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:ZG(e.text)}},sK=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}},cK=class e{options;renderer;textRenderer;constructor(e){this.options=e||UW,this.options.renderer=this.options.renderer||new oK,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new sK}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(t!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`paragraph`,`text`].includes(e.type)){n+=t||``;continue}}let a=i;switch(a.type){case`space`:n+=this.renderer.space(a);continue;case`hr`:n+=this.renderer.hr(a);continue;case`heading`:n+=this.renderer.heading(a);continue;case`code`:n+=this.renderer.code(a);continue;case`table`:n+=this.renderer.table(a);continue;case`blockquote`:n+=this.renderer.blockquote(a);continue;case`list`:n+=this.renderer.list(a);continue;case`html`:n+=this.renderer.html(a);continue;case`paragraph`:n+=this.renderer.paragraph(a);continue;case`text`:{let i=a,o=this.renderer.text(i);for(;r+1<e.length&&e[r+1].type===`text`;)i=e[++r],o+=`
262
- `+this.renderer.text(i);t?n+=this.renderer.paragraph({type:`paragraph`,raw:o,text:o,tokens:[{type:`text`,raw:o,text:o,escaped:!0}]}):n+=o;continue}default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t=this.renderer){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},lK=class{options;block;constructor(e){this.options=e||UW}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?aK.lex:aK.lexInline}provideParser(){return this.block?cK.parse:cK.parseInline}},uK=class{defaults=HW();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=cK;Renderer=oK;TextRenderer=sK;Lexer=aK;Tokenizer=iK;Hooks=lK;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new oK(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new iK(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new lK;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];lK.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async)return Promise.resolve(i.call(t,e)).then(e=>a.call(t,e));let n=i.call(t,e);return a.call(t,n)}:t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return aK.lex(e,t??this.defaults)}parser(e,t){return cK.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(t==null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));i.hooks&&(i.hooks.options=i,i.hooks.block=e);let o=i.hooks?i.hooks.provideLexer():e?aK.lex:aK.lexInline,s=i.hooks?i.hooks.provideParser():e?cK.parse:cK.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(t):t).then(e=>o(e,i)).then(e=>i.hooks?i.hooks.processAllTokens(e):e).then(e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then(()=>e):e).then(e=>s(e,i)).then(e=>i.hooks?i.hooks.postprocess(e):e).catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let e=o(t,i);i.hooks&&(e=i.hooks.processAllTokens(e)),i.walkTokens&&this.walkTokens(e,i.walkTokens);let n=s(e,i);return i.hooks&&(n=i.hooks.postprocess(n)),n}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
263
- Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+ZG(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},dK=new uK;function fK(e,t){return dK.parse(e,t)}fK.options=fK.setOptions=function(e){return dK.setOptions(e),fK.defaults=dK.defaults,WW(fK.defaults),fK},fK.getDefaults=HW,fK.defaults=UW,fK.use=function(...e){return dK.use(...e),fK.defaults=dK.defaults,WW(fK.defaults),fK},fK.walkTokens=function(e,t){return dK.walkTokens(e,t)},fK.parseInline=dK.parseInline,fK.Parser=cK,fK.parser=cK.parse,fK.Renderer=oK,fK.TextRenderer=sK,fK.Lexer=aK,fK.lexer=aK.lex,fK.Tokenizer=iK,fK.Hooks=lK,fK.parse=fK,fK.options,fK.setOptions,fK.use,fK.walkTokens,fK.parseInline,cK.parse,aK.lex;function pK({header:e,caption:t,children:n}){return(0,L.jsxs)(`figure`,{className:mK,children:[e,(0,L.jsx)(`div`,{className:hK,children:n}),t]})}var mK=`frizz-bash max-w-full`,hK=`flex justify-center bg-panel-2 p-1.5`,gK=`block max-h-[420px] max-w-full w-auto rounded-md object-contain`,_K=/^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,vK={del(e){let t=_K.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}},yK=/^:?-+:?$/,bK=/^ {0,3}$/,xK=/^[ \t]*$/;function SK(e){let t=[],n=``;for(let r=0;r<e.length;r++){let i=e[r];i===`\\`&&r+1<e.length?(n+=i+e[r+1],r++):i===`|`?(t.push(n),n=``):n+=i}return t.push(n),t.length<4||!bK.test(t[0])||!xK.test(t.at(-1))?null:t.slice(1,-1).map(e=>e.trim())}function CK(e){let t=[],n=0;for(let r of e.split(`
264
- `)){let e=SK(r);if(!e)break;if(e.every(e=>yK.test(e)))return null;t.push(e),n+=r.length+1}return t.length<2?null:{raw:e.slice(0,Math.min(n,e.length)),rows:t}}var wK={name:`headerlessTable`,level:`block`,start(e){let t=0;for(let n of e.split(`
265
- `)){if(n.includes(`|`)&&CK(e.slice(t)))return t;t+=n.length+1}},tokenizer(e){let t=CK(e);if(!t)return;let n=Math.max(...t.rows.map(e=>e.length)),r=t.rows.map(e=>Array.from({length:n},(t,n)=>({tokens:this.lexer.inline(e[n]??``)})));return{type:`headerlessTable`,raw:t.raw,rows:r}},renderer(e){return`<table>\n<tbody>${e.rows.map(e=>`<tr>${e.map(e=>`<td>${this.parser.parseInline(e.tokens)}</td>`).join(``)}</tr>`).join(`
266
- `)}</tbody></table>\n`}},TK=/^\[([ xX/\-?])\](?:[ \t]+|[ \t]*$)/,EK={" ":{className:``,label:`To do`},x:{className:`md-task-checked`,label:`Done`},"/":{className:`md-task-in-progress`,label:`In progress`},"-":{className:`md-task-cancelled`,label:`Cancelled`},"?":{className:`md-task-blocked`,label:`Blocked`}},DK={name:`frizzTaskStatus`,level:`inline`,tokenizer(){},renderer(e){let{status:t}=e,n=EK[t];return`<span class="md-task${n.className?` ${n.className}`:``}" title="${n.label}"></span> `}},OK={name:`frizzTaskText`,level:`inline`,tokenizer(){},renderer(e){return`<span class="md-task-text">${this.parser.parseInline(e.tokens)}</span>`}};function kK(e){let t=e.tokens[0],n=t&&`tokens`in t?t.tokens:void 0;if(!Array.isArray(n)||n[0]?.type===`frizzTaskStatus`)return;let r,i;if(e.task)r=e.checked?`x`:` `,i=``,e.task=!1,e.checked=void 0;else{let t=TK.exec(e.text);if(!t)return;let a=t[0].length,o=[];for(let e=0;e<n.length&&a>0;e++){let t=n[e];if(t.type!==`text`)return;let r=Math.min(a,t.raw.length);o.push({token:t,count:r}),a-=r}if(a>0)return;for(let{token:e,count:t}of o)e.raw=e.raw.slice(t),e.text=e.text.slice(t);for(let e=n.length-1;e>=0;e--)n[e].type===`text`&&!n[e].raw&&n.splice(e,1);e.text=e.text.slice(t[0].length),r=t[1]===`X`?`x`:t[1],i=t[0]}let a=n.splice(0,n.length);n.push({type:`frizzTaskStatus`,raw:i,status:r}),a.length&&n.push({type:`frizzTaskText`,raw:``,tokens:a})}var AK={breaks:!0,extensions:[wK,DK,OK],tokenizer:vK,hooks:{processAllTokens(e){return af(e),e}},walkTokens(e){e.type===`list_item`&&kK(e)},renderer:{code:({text:e,lang:t})=>FS(e,t)}},jK=new uK(AK),MK=new uK({...AK,breaks:!1});function NK(e,t){return e.trim()?VK((t?.document?MK:jK).parse(e,{async:!1}),{block:!0,baseDir:t?.baseDir,homeDir:t?.homeDir}):``}function PK(e,t){if(!e.trim())return``;let{baseDir:n,homeDir:r}=t??{};return VK(jK.parseInline(e,{async:!1}),{baseDir:n,homeDir:r})}function FK(e){let t=e.match(/^?---\r?\n[\s\S]*?\r?\n---\r?\n?/);return t?e.slice(t[0].length):e}var IK=new Set(`h1.h2.h3.h4.h5.h6.p.br.hr.strong.em.del.code.pre.blockquote.ul.ol.li.a.img.button.table.thead.tbody.tr.th.td.span`.split(`.`)),LK=new Set([`href`,`src`,`alt`,`title`,`type`,`class`,`data-local-path`,`data-local-image`]),RK=RegExp(`^(?:hljs(?:-[a-z0-9_-]+)?|language-[a-z0-9-]+|md-task(?:-(?:checked|in-progress|cancelled|blocked|text))?|${AS})$`),zK={ol:{start:/^\d{1,9}$/},th:{align:/^(?:left|center|right)$/},td:{align:/^(?:left|center|right)$/}},BK=new Set([`script`,`style`,`textarea`,`title`,`xmp`,`iframe`,`frame`,`frameset`,`object`,`embed`,`applet`,`noscript`,`template`,`svg`,`math`]);function VK(e,{block:t=!1,baseDir:n,homeDir:r}={}){let i=document.createElement(`template`);return i.innerHTML=e,HK(i.content,{block:t,baseDir:n,homeDir:r}),i.innerHTML}function HK(e,t){let{block:n}=t;for(let r of Array.from(e.children)){let e=r.tagName.toLowerCase();if(!IK.has(e)){BK.has(e)?r.remove():GK(r,t);continue}if((e===`a`||e===`img`)&&UK(r,e===`a`?`href`:`src`,t),e===`a`){let e=Fd(r.getAttribute(`href`));e&&r.setAttribute(`href`,e);let t=JS(r.getAttribute(`href`));if(t){let e=ZS(t);if(e)r.setAttribute(`href`,e),r.setAttribute(`title`,t.display),r.setAttribute(`data-local-path`,t.posixPath),r.setAttribute(`data-local-image`,`true`);else{let e=t.posixPath&&$S(t.posixPath),n=document.createElement(`button`);for(n.type=`button`,n.className=`local-file-action`,n.title=e?`Read ${t.display}`:t.display,t.posixPath&&n.setAttribute(`data-local-path`,t.posixPath);r.firstChild;)n.append(r.firstChild);r.replaceWith(n);continue}}}if(e===`img`){let e=JS(r.getAttribute(`src`)),t=e&&ZS(e);if(!t){r.remove();continue}r.setAttribute(`src`,t),r.setAttribute(`title`,e.display),r.setAttribute(`data-local-path`,e.posixPath),r.setAttribute(`data-local-image`,`true`),r.getAttribute(`alt`)||r.setAttribute(`alt`,e.display),n&&WK(r)}for(let t of Array.from(r.attributes)){let n=t.name.toLowerCase();if(n===`class`&&(e===`code`||e===`span`)){let e=t.value.split(/\s+/).filter(e=>RK.test(e));e.length>0?r.setAttribute(`class`,e.join(` `)):r.removeAttribute(t.name);continue}let i=zK[e]?.[n];if(i){i.test(t.value)||r.removeAttribute(t.name);continue}if(!LK.has(n)){r.removeAttribute(t.name);continue}n===`href`&&/^\s*javascript:/i.test(t.value)&&r.removeAttribute(t.name)}if(e===`a`){r.setAttribute(`target`,`_blank`),r.setAttribute(`rel`,`noopener noreferrer`),r.removeAttribute(`data-gh-ref`);let e=Yd(r.getAttribute(`href`));e&&r.setAttribute(`data-gh-ref`,e)}HK(r,t)}}function UK(e,t,{baseDir:n,homeDir:r}){if(!n&&!r)return;let i=eC(e.getAttribute(t),n??``,r);i&&e.setAttribute(t,i)}function WK(e){let t=e.ownerDocument,n=t.createElement(`span`);n.className=`${mK} md-image-frame`;let r=t.createElement(`span`);r.className=hK,e.replaceWith(n),n.append(r),r.append(e),e.setAttribute(`class`,gK)}function GK(e,t){let n=e.ownerDocument.createDocumentFragment();for(;e.firstChild;)n.append(e.firstChild);HK(n,t),e.replaceWith(n)}function KK(){return(0,I.useSyncExternalStore)(Kd,Gd,Gd)}function qK(){return(0,I.useSyncExternalStore)(Hf,Vf,Vf)}function JK(e,t){let n=KK(),r=qK(),{baseDir:i,asDocument:a}=t??{},o=i??r.dir,s=(0,I.useMemo)(()=>NK(e,{baseDir:o,homeDir:r.home,document:a}),[e,o,r.home,a,n]);return YK(s),s}function YK(e){let t=(0,I.useMemo)(()=>Af(e),[e]);(0,I.useEffect)(()=>{t.length>0&&jf(t)},[t])}function XK(e){let t=KK(),n=qK(),r=(0,I.useMemo)(()=>PK(e,{baseDir:n.dir,homeDir:n.home}),[e,n.dir,n.home,t]);return YK(r),r}var ZK=e=>new Set(e.split(/\s+/).filter(Boolean)),QK=ZK(`
261
+ `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${$G(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=eK(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+$G(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=eK(e);if(i===null)return $G(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${$G(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:$G(e.text)}},lK=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}},uK=class e{options;renderer;textRenderer;constructor(e){this.options=e||GW,this.options.renderer=this.options.renderer||new cK,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new lK}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e,t=!0){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=i,t=this.options.extensions.renderers[e.type].call({parser:this},e);if(t!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`paragraph`,`text`].includes(e.type)){n+=t||``;continue}}let a=i;switch(a.type){case`space`:n+=this.renderer.space(a);continue;case`hr`:n+=this.renderer.hr(a);continue;case`heading`:n+=this.renderer.heading(a);continue;case`code`:n+=this.renderer.code(a);continue;case`table`:n+=this.renderer.table(a);continue;case`blockquote`:n+=this.renderer.blockquote(a);continue;case`list`:n+=this.renderer.list(a);continue;case`html`:n+=this.renderer.html(a);continue;case`paragraph`:n+=this.renderer.paragraph(a);continue;case`text`:{let i=a,o=this.renderer.text(i);for(;r+1<e.length&&e[r+1].type===`text`;)i=e[++r],o+=`
262
+ `+this.renderer.text(i);t?n+=this.renderer.paragraph({type:`paragraph`,raw:o,text:o,tokens:[{type:`text`,raw:o,text:o,escaped:!0}]}):n+=o;continue}default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}parseInline(e,t=this.renderer){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},dK=class{options;block;constructor(e){this.options=e||GW}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?sK.lex:sK.lexInline}provideParser(){return this.block?uK.parse:uK.parseInline}},fK=class{defaults=WW();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=uK;Renderer=cK;TextRenderer=lK;Lexer=sK;Tokenizer=oK;Hooks=dK;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new cK(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new oK(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new dK;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];dK.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async)return Promise.resolve(i.call(t,e)).then(e=>a.call(t,e));let n=i.call(t,e);return a.call(t,n)}:t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return sK.lex(e,t??this.defaults)}parser(e,t){return uK.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(t==null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));i.hooks&&(i.hooks.options=i,i.hooks.block=e);let o=i.hooks?i.hooks.provideLexer():e?sK.lex:sK.lexInline,s=i.hooks?i.hooks.provideParser():e?uK.parse:uK.parseInline;if(i.async)return Promise.resolve(i.hooks?i.hooks.preprocess(t):t).then(e=>o(e,i)).then(e=>i.hooks?i.hooks.processAllTokens(e):e).then(e=>i.walkTokens?Promise.all(this.walkTokens(e,i.walkTokens)).then(()=>e):e).then(e=>s(e,i)).then(e=>i.hooks?i.hooks.postprocess(e):e).catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let e=o(t,i);i.hooks&&(e=i.hooks.processAllTokens(e)),i.walkTokens&&this.walkTokens(e,i.walkTokens);let n=s(e,i);return i.hooks&&(n=i.hooks.postprocess(n)),n}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
263
+ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+$G(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},pK=new fK;function mK(e,t){return pK.parse(e,t)}mK.options=mK.setOptions=function(e){return pK.setOptions(e),mK.defaults=pK.defaults,KW(mK.defaults),mK},mK.getDefaults=WW,mK.defaults=GW,mK.use=function(...e){return pK.use(...e),mK.defaults=pK.defaults,KW(mK.defaults),mK},mK.walkTokens=function(e,t){return pK.walkTokens(e,t)},mK.parseInline=pK.parseInline,mK.Parser=uK,mK.parser=uK.parse,mK.Renderer=cK,mK.TextRenderer=lK,mK.Lexer=sK,mK.lexer=sK.lex,mK.Tokenizer=oK,mK.Hooks=dK,mK.parse=mK,mK.options,mK.setOptions,mK.use,mK.walkTokens,mK.parseInline,uK.parse,sK.lex;function hK({header:e,caption:t,children:n}){return(0,L.jsxs)(`figure`,{className:gK,children:[e,(0,L.jsx)(`div`,{className:_K,children:n}),t]})}var gK=`frizz-bash max-w-full`,_K=`flex justify-center bg-panel-2 p-1.5`,vK=`block max-h-[420px] max-w-full w-auto rounded-md object-contain`,yK=/^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,bK={del(e){let t=yK.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}},xK=/^:?-+:?$/,SK=/^ {0,3}$/,CK=/^[ \t]*$/;function wK(e){let t=[],n=``;for(let r=0;r<e.length;r++){let i=e[r];i===`\\`&&r+1<e.length?(n+=i+e[r+1],r++):i===`|`?(t.push(n),n=``):n+=i}return t.push(n),t.length<4||!SK.test(t[0])||!CK.test(t.at(-1))?null:t.slice(1,-1).map(e=>e.trim())}function TK(e){let t=[],n=0;for(let r of e.split(`
264
+ `)){let e=wK(r);if(!e)break;if(e.every(e=>xK.test(e)))return null;t.push(e),n+=r.length+1}return t.length<2?null:{raw:e.slice(0,Math.min(n,e.length)),rows:t}}var EK={name:`headerlessTable`,level:`block`,start(e){let t=0;for(let n of e.split(`
265
+ `)){if(n.includes(`|`)&&TK(e.slice(t)))return t;t+=n.length+1}},tokenizer(e){let t=TK(e);if(!t)return;let n=Math.max(...t.rows.map(e=>e.length)),r=t.rows.map(e=>Array.from({length:n},(t,n)=>({tokens:this.lexer.inline(e[n]??``)})));return{type:`headerlessTable`,raw:t.raw,rows:r}},renderer(e){return`<table>\n<tbody>${e.rows.map(e=>`<tr>${e.map(e=>`<td>${this.parser.parseInline(e.tokens)}</td>`).join(``)}</tr>`).join(`
266
+ `)}</tbody></table>\n`}},DK=/^\[([ xX/\-?])\](?:[ \t]+|[ \t]*$)/,OK={" ":{className:``,label:`To do`},x:{className:`md-task-checked`,label:`Done`},"/":{className:`md-task-in-progress`,label:`In progress`},"-":{className:`md-task-cancelled`,label:`Cancelled`},"?":{className:`md-task-blocked`,label:`Blocked`}},kK={name:`frizzTaskStatus`,level:`inline`,tokenizer(){},renderer(e){let{status:t}=e,n=OK[t];return`<span class="md-task${n.className?` ${n.className}`:``}" title="${n.label}"></span> `}},AK={name:`frizzTaskText`,level:`inline`,tokenizer(){},renderer(e){return`<span class="md-task-text">${this.parser.parseInline(e.tokens)}</span>`}};function jK(e){let t=e.tokens[0],n=t&&`tokens`in t?t.tokens:void 0;if(!Array.isArray(n)||n[0]?.type===`frizzTaskStatus`)return;let r,i;if(e.task)r=e.checked?`x`:` `,i=``,e.task=!1,e.checked=void 0;else{let t=DK.exec(e.text);if(!t)return;let a=t[0].length,o=[];for(let e=0;e<n.length&&a>0;e++){let t=n[e];if(t.type!==`text`)return;let r=Math.min(a,t.raw.length);o.push({token:t,count:r}),a-=r}if(a>0)return;for(let{token:e,count:t}of o)e.raw=e.raw.slice(t),e.text=e.text.slice(t);for(let e=n.length-1;e>=0;e--)n[e].type===`text`&&!n[e].raw&&n.splice(e,1);e.text=e.text.slice(t[0].length),r=t[1]===`X`?`x`:t[1],i=t[0]}let a=n.splice(0,n.length);n.push({type:`frizzTaskStatus`,raw:i,status:r}),a.length&&n.push({type:`frizzTaskText`,raw:``,tokens:a})}var MK={breaks:!0,extensions:[EK,kK,AK],tokenizer:bK,hooks:{processAllTokens(e){return af(e),e}},walkTokens(e){e.type===`list_item`&&jK(e)},renderer:{code:({text:e,lang:t})=>FS(e,t)}},NK=new fK(MK),PK=new fK({...MK,breaks:!1});function FK(e,t){return e.trim()?UK((t?.document?PK:NK).parse(e,{async:!1}),{block:!0,baseDir:t?.baseDir,homeDir:t?.homeDir}):``}function IK(e,t){if(!e.trim())return``;let{baseDir:n,homeDir:r}=t??{};return UK(NK.parseInline(e,{async:!1}),{baseDir:n,homeDir:r})}function LK(e){let t=e.match(/^?---\r?\n[\s\S]*?\r?\n---\r?\n?/);return t?e.slice(t[0].length):e}var RK=new Set(`h1.h2.h3.h4.h5.h6.p.br.hr.strong.em.del.code.pre.blockquote.ul.ol.li.a.img.button.table.thead.tbody.tr.th.td.span`.split(`.`)),zK=new Set([`href`,`src`,`alt`,`title`,`type`,`class`,`data-local-path`,`data-local-image`]),BK=RegExp(`^(?:hljs(?:-[a-z0-9_-]+)?|language-[a-z0-9-]+|md-task(?:-(?:checked|in-progress|cancelled|blocked|text))?|${AS})$`),VK={ol:{start:/^\d{1,9}$/},th:{align:/^(?:left|center|right)$/},td:{align:/^(?:left|center|right)$/}},HK=new Set([`script`,`style`,`textarea`,`title`,`xmp`,`iframe`,`frame`,`frameset`,`object`,`embed`,`applet`,`noscript`,`template`,`svg`,`math`]);function UK(e,{block:t=!1,baseDir:n,homeDir:r}={}){let i=document.createElement(`template`);return i.innerHTML=e,WK(i.content,{block:t,baseDir:n,homeDir:r}),i.innerHTML}function WK(e,t){let{block:n}=t;for(let r of Array.from(e.children)){let e=r.tagName.toLowerCase();if(!RK.has(e)){HK.has(e)?r.remove():qK(r,t);continue}if((e===`a`||e===`img`)&&GK(r,e===`a`?`href`:`src`,t),e===`a`){let e=Fd(r.getAttribute(`href`));e&&r.setAttribute(`href`,e);let t=JS(r.getAttribute(`href`));if(t){let e=ZS(t);if(e)r.setAttribute(`href`,e),r.setAttribute(`title`,t.display),r.setAttribute(`data-local-path`,t.posixPath),r.setAttribute(`data-local-image`,`true`);else{let e=t.posixPath&&$S(t.posixPath),n=document.createElement(`button`);for(n.type=`button`,n.className=`local-file-action`,n.title=e?`Read ${t.display}`:t.display,t.posixPath&&n.setAttribute(`data-local-path`,t.posixPath);r.firstChild;)n.append(r.firstChild);r.replaceWith(n);continue}}}if(e===`img`){let e=JS(r.getAttribute(`src`)),t=e&&ZS(e);if(!t){r.remove();continue}r.setAttribute(`src`,t),r.setAttribute(`title`,e.display),r.setAttribute(`data-local-path`,e.posixPath),r.setAttribute(`data-local-image`,`true`),r.getAttribute(`alt`)||r.setAttribute(`alt`,e.display),n&&KK(r)}for(let t of Array.from(r.attributes)){let n=t.name.toLowerCase();if(n===`class`&&(e===`code`||e===`span`)){let e=t.value.split(/\s+/).filter(e=>BK.test(e));e.length>0?r.setAttribute(`class`,e.join(` `)):r.removeAttribute(t.name);continue}let i=VK[e]?.[n];if(i){i.test(t.value)||r.removeAttribute(t.name);continue}if(!zK.has(n)){r.removeAttribute(t.name);continue}n===`href`&&/^\s*javascript:/i.test(t.value)&&r.removeAttribute(t.name)}if(e===`a`){r.setAttribute(`target`,`_blank`),r.setAttribute(`rel`,`noopener noreferrer`),r.removeAttribute(`data-gh-ref`);let e=Yd(r.getAttribute(`href`));e&&r.setAttribute(`data-gh-ref`,e)}WK(r,t)}}function GK(e,t,{baseDir:n,homeDir:r}){if(!n&&!r)return;let i=eC(e.getAttribute(t),n??``,r);i&&e.setAttribute(t,i)}function KK(e){let t=e.ownerDocument,n=t.createElement(`span`);n.className=`${gK} md-image-frame`;let r=t.createElement(`span`);r.className=_K,e.replaceWith(n),n.append(r),r.append(e),e.setAttribute(`class`,vK)}function qK(e,t){let n=e.ownerDocument.createDocumentFragment();for(;e.firstChild;)n.append(e.firstChild);WK(n,t),e.replaceWith(n)}function JK(){return(0,I.useSyncExternalStore)(Kd,Gd,Gd)}function YK(){return(0,I.useSyncExternalStore)(Hf,Vf,Vf)}function XK(e,t){let n=JK(),r=YK(),{baseDir:i,asDocument:a}=t??{},o=i??r.dir,s=(0,I.useMemo)(()=>FK(e,{baseDir:o,homeDir:r.home,document:a}),[e,o,r.home,a,n]);return ZK(s),s}function ZK(e){let t=(0,I.useMemo)(()=>Af(e),[e]);(0,I.useEffect)(()=>{t.length>0&&jf(t)},[t])}function QK(e){let t=JK(),n=YK(),r=(0,I.useMemo)(()=>IK(e,{baseDir:n.dir,homeDir:n.home}),[e,n.dir,n.home,t]);return ZK(r),r}var $K=e=>new Set(e.split(/\s+/).filter(Boolean)),eq=$K(`
267
267
  break case catch class const continue debugger default delete do else enum export extends
268
268
  false finally for function if import in instanceof new null return super switch this throw
269
269
  true try typeof var void while with yield async await let static get set of as from
270
270
  interface type namespace declare readonly public private protected implements abstract
271
271
  package struct func go defer chan map fn impl trait mut pub use mod match loop where
272
272
  int long short float double char boolean byte final synchronized volatile transient native
273
- `),$K=ZK(`
273
+ `),tq=$K(`
274
274
  string number boolean object symbol bigint unknown any never void undefined
275
275
  String Number Boolean Object Array Promise Map Set Record Partial
276
276
  i8 i16 i32 i64 u8 u16 u32 u64 usize isize f32 f64 str Vec Option Result Box
277
277
  int8 int16 int32 int64 uint float32 float64 error rune
278
- `),eq={typescript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:QK,types:$K},javascript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:QK,types:$K},go:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:QK,types:$K},rust:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:QK,types:$K},java:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:QK,types:$K},c:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:QK,types:$K},cpp:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:QK,types:$K},css:{line:null,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:ZK(`important media supports keyframes import from to`),types:new Set},json:{line:null,block:null,quotes:[`"`],keywords:ZK(`true false null`),types:new Set},python:{line:`#`,block:null,quotes:[`"`,`'`],keywords:ZK(`
278
+ `),nq={typescript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:eq,types:tq},javascript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:eq,types:tq},go:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:eq,types:tq},rust:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:eq,types:tq},java:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:eq,types:tq},c:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:eq,types:tq},cpp:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:eq,types:tq},css:{line:null,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:$K(`important media supports keyframes import from to`),types:new Set},json:{line:null,block:null,quotes:[`"`],keywords:$K(`true false null`),types:new Set},python:{line:`#`,block:null,quotes:[`"`,`'`],keywords:$K(`
279
279
  def class return if elif else for while break continue pass import from as with try except
280
280
  finally raise lambda yield global nonlocal del assert async await and or not in is None True
281
- False self lambda`),types:ZK(`int float str bool list dict set tuple bytes object`)},shell:{line:`#`,block:null,quotes:[`"`,`'`],keywords:ZK(`if then else elif fi for while do done case esac in function return export local echo cd exit set unset source`),types:new Set},yaml:{line:`#`,block:null,quotes:[`"`,`'`],keywords:ZK(`true false null yes no on off ~`),types:new Set,lineStart:[{re:/^([ \t]*)(- +)?("[^"\n]*"|'[^'\n]*'|[A-Za-z_][\w.\-/]*)([ \t]*)(:)/,kinds:[`plain`,`punct`,`key`,`plain`,`punct`]}]},toml:{line:`#`,block:null,quotes:[`"`,`'`],keywords:ZK(`true false`),types:new Set,keyChars:`=`,lineStart:[{re:/^([ \t]*)(\[\[?[^\]\n]*\]\]?)/,kinds:[`plain`,`fn`]}]},html:{line:null,block:[`<!--`,`-->`],quotes:[`"`,`'`],keywords:new Set,types:new Set,keyChars:`=`,tagNames:!0}},tq=(e,t)=>{let n=e.indexOf(`
282
- `,t);return n===-1?e.length:n},nq=(e,t)=>{let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;return e[n]??``},rq=new Set(Object.keys(eq)),iq=e=>/[A-Za-z_$]/.test(e),aq=e=>/[A-Za-z0-9_$]/.test(e),oq=e=>e>=`0`&&e<=`9`,sq=new Set(`{}()[];,.`),cq=new Set(`+-*/%=<>!&|^~?:@`);function lq(e,t){let n=[],r=e.length,i=(e,t)=>e&&n.push({text:e,kind:t}),a=0;for(;a<r;){let n=e[a];if(t.lineStart&&(a===0||e[a-1]===`
283
- `)){let n=!1;for(let r of t.lineStart){let t=r.re.exec(e.slice(a,tq(e,a)));if(t){for(let e=1;e<t.length;e++)i(t[e]??``,r.kinds[e-1]??`plain`);a+=t[0].length,n=!0;break}}if(n)continue}if(t.block&&e.startsWith(t.block[0],a)){let n=e.indexOf(t.block[1],a+t.block[0].length),o=n===-1?r:n+t.block[1].length;i(e.slice(a,o),`com`),a=o;continue}if(t.line&&e.startsWith(t.line,a)){let t=e.indexOf(`
281
+ False self lambda`),types:$K(`int float str bool list dict set tuple bytes object`)},shell:{line:`#`,block:null,quotes:[`"`,`'`],keywords:$K(`if then else elif fi for while do done case esac in function return export local echo cd exit set unset source`),types:new Set},yaml:{line:`#`,block:null,quotes:[`"`,`'`],keywords:$K(`true false null yes no on off ~`),types:new Set,lineStart:[{re:/^([ \t]*)(- +)?("[^"\n]*"|'[^'\n]*'|[A-Za-z_][\w.\-/]*)([ \t]*)(:)/,kinds:[`plain`,`punct`,`key`,`plain`,`punct`]}]},toml:{line:`#`,block:null,quotes:[`"`,`'`],keywords:$K(`true false`),types:new Set,keyChars:`=`,lineStart:[{re:/^([ \t]*)(\[\[?[^\]\n]*\]\]?)/,kinds:[`plain`,`fn`]}]},html:{line:null,block:[`<!--`,`-->`],quotes:[`"`,`'`],keywords:new Set,types:new Set,keyChars:`=`,tagNames:!0}},rq=(e,t)=>{let n=e.indexOf(`
282
+ `,t);return n===-1?e.length:n},iq=(e,t)=>{let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;return e[n]??``},aq=new Set(Object.keys(nq)),oq=e=>/[A-Za-z_$]/.test(e),sq=e=>/[A-Za-z0-9_$]/.test(e),cq=e=>e>=`0`&&e<=`9`,lq=new Set(`{}()[];,.`),uq=new Set(`+-*/%=<>!&|^~?:@`);function dq(e,t){let n=[],r=e.length,i=(e,t)=>e&&n.push({text:e,kind:t}),a=0;for(;a<r;){let n=e[a];if(t.lineStart&&(a===0||e[a-1]===`
283
+ `)){let n=!1;for(let r of t.lineStart){let t=r.re.exec(e.slice(a,rq(e,a)));if(t){for(let e=1;e<t.length;e++)i(t[e]??``,r.kinds[e-1]??`plain`);a+=t[0].length,n=!0;break}}if(n)continue}if(t.block&&e.startsWith(t.block[0],a)){let n=e.indexOf(t.block[1],a+t.block[0].length),o=n===-1?r:n+t.block[1].length;i(e.slice(a,o),`com`),a=o;continue}if(t.line&&e.startsWith(t.line,a)){let t=e.indexOf(`
284
284
  `,a);t===-1&&(t=r),i(e.slice(a,t),`com`),a=t;continue}if(t.quotes.includes(n)){let t=n==="`",o=a+1;for(;o<r;){if(e[o]===`\\`){o+=2;continue}if(e[o]===n){o++;break}if(e[o]===`
285
- `&&!t)break;o++}i(e.slice(a,o),`str`),a=o;continue}if(oq(n)){let t=a+1;for(;t<r&&/[0-9a-fA-FxXbBoO_.]/.test(e[t]);)t++;i(e.slice(a,t),`num`),a=t;continue}if(iq(n)){let n=a+1;for(;n<r&&aq(e[n]);)n++;let o=e.slice(a,n);i(o,t.keywords.has(o)?`kw`:t.types.has(o)?`type`:t.tagNames&&(e[a-1]===`<`||e[a-1]===`/`&&e[a-2]===`<`)?`kw`:t.keyChars&&t.keyChars.includes(nq(e,n))?`key`:e[n]===`(`?`fn`:`plain`),a=n;continue}if(sq.has(n)){i(n,`punct`),a++;continue}if(cq.has(n)){let t=a+1;for(;t<r&&cq.has(e[t]);)t++;i(e.slice(a,t),`op`),a=t;continue}let o=a+1;for(;o<r&&!iq(e[o])&&!oq(e[o])&&!t.quotes.includes(e[o])&&!sq.has(e[o])&&!cq.has(e[o])&&!(t.line&&e.startsWith(t.line,o));)o++;i(e.slice(a,o),`plain`),a=o}return n}function uq(e){let t=[[]];for(let n of e){let e=n.text.split(`
286
- `);for(let r=0;r<e.length;r++)r>0&&t.push([]),e[r]&&t[t.length-1].push({text:e[r],kind:n.kind})}return t}function dq(e,t){if(e===``)return[];let n=eq[t];return n?uq(lq(e,n)):e.split(`
287
- `).map(e=>e?[{text:e,kind:`plain`}]:[])}var fq={".ts":`typescript`,".tsx":`typescript`,".mts":`typescript`,".cts":`typescript`,".js":`javascript`,".jsx":`javascript`,".mjs":`javascript`,".cjs":`javascript`,".json":`json`,".jsonc":`json`,".css":`css`,".scss":`css`,".less":`css`,".py":`python`,".go":`go`,".rs":`rust`,".java":`java`,".c":`c`,".h":`c`,".cpp":`cpp`,".hpp":`cpp`,".cc":`cpp`,".sh":`shell`,".bash":`shell`,".zsh":`shell`,".yaml":`yaml`,".yml":`yaml`,".toml":`toml`,".html":`html`,".htm":`html`,".xml":`html`,".svg":`html`},pq={Dockerfile:`shell`,Makefile:`shell`,".gitignore":`shell`,".env":`shell`,".bashrc":`shell`,".zshrc":`shell`};function mq(e){let t=Qf(e),n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=pq[t]??fq[r]??`text`;return rq.has(i)?i:`text`}function hq(e,t,n){let r=e.length,i=t.length,a=Array.from({length:r+1},()=>new Uint32Array(i+1));for(let n=r-1;n>=0;n--)for(let r=i-1;r>=0;r--)a[n][r]=e[n]===t[r]?a[n+1][r+1]+1:Math.max(a[n+1][r],a[n][r+1]);let o=[],s=0,c=0;for(;s<r&&c<i;)e[s]===t[c]?(o.push({type:`eq`,a:n+s,b:n+c}),s++,c++):a[s+1][c]>=a[s][c+1]?(o.push({type:`del`,a:n+s,b:null}),s++):(o.push({type:`add`,a:null,b:n+c}),c++);for(;s<r;)o.push({type:`del`,a:n+s++,b:null});for(;c<i;)o.push({type:`add`,a:null,b:n+c++});return o}function gq(e,t){let n=e.length,r=t.length,i=0;for(;i<n&&i<r&&e[i]===t[i];)i++;let a=0;for(;a<n-i&&a<r-i&&e[n-1-a]===t[r-1-a];)a++;let o=[];for(let e=0;e<i;e++)o.push({type:`eq`,a:e,b:e});o.push(...hq(e.slice(i,n-a),t.slice(i,r-a),i));for(let e=0;e<a;e++)o.push({type:`eq`,a:n-a+e,b:r-a+e});return o}var _q=3,vq=e=>e===``?[]:e.split(`
288
- `);function yq(e,t,n){return e.type===`del`?{type:`del`,oldLine:e.a+1,newLine:null,tokens:t[e.a]??[]}:e.type===`add`?{type:`add`,oldLine:null,newLine:e.b+1,tokens:n[e.b]??[]}:{type:`context`,oldLine:e.a+1,newLine:e.b+1,tokens:n[e.b]??[]}}function bq(e){let t=[];for(let n=0;n<e.length;n++)e[n].type!==`context`&&t.push(n);if(t.length===0)return{hunks:[],collapsedAfter:e.length};let n=[],r=Math.max(0,t[0]-_q),i=-1;for(let a=0;a<t.length;a++){let o=t[a],s=t[a+1];i=Math.min(e.length-1,o+_q),!(s!==void 0&&s-o<=7)&&(n.push({collapsedBefore:r,lines:e.slice(r,i+1)}),s!==void 0&&(r=Math.max(i+1,s-_q)))}let a=n.length?n[n.length-1].collapsedBefore+n[n.length-1].lines.length:0;return{hunks:n,collapsedAfter:Math.max(0,e.length-a)}}function xq(e,t,n){let r=mq(n),i=dq(e,r),a=dq(t,r),o=vq(e),s=vq(t),c=e===``?`added`:t===``?`deleted`:`modified`;if(c===`added`){let e=s.map((e,t)=>({type:`add`,oldLine:null,newLine:t+1,tokens:a[t]??[]}));return{file:n,lang:r,status:c,hunks:[{collapsedBefore:0,lines:e}],collapsedAfter:0,additions:e.length,deletions:0}}if(c===`deleted`){let e=o.map((e,t)=>({type:`del`,oldLine:t+1,newLine:null,tokens:i[t]??[]}));return{file:n,lang:r,status:c,hunks:[{collapsedBefore:0,lines:e}],collapsedAfter:0,additions:0,deletions:e.length}}let l=gq(o,s).map(e=>yq(e,i,a)),u=l.filter(e=>e.type===`add`).length,d=l.filter(e=>e.type===`del`).length,{hunks:f,collapsedAfter:p}=bq(l);return{file:n,lang:r,status:c,hunks:f,collapsedAfter:p,additions:u,deletions:d}}function Sq(){let e=e=>{if(e.button!==0||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`[data-local-path]`):null,n=t?.dataset.localPath;!t||!n||(e.preventDefault(),e.stopPropagation(),wq(n,t.dataset.localImage===`true`))};document.addEventListener(`click`,e);let t=Cq();return document.addEventListener(`error`,t,!0),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`error`,t,!0)}}function Cq(){return e=>{let t=e.target;if(!(t instanceof HTMLImageElement)||t.dataset.localImage!==`true`||!t.closest(`.md-body, .md-inline`))return;let n=t.dataset.localPath??t.getAttribute(`src`)??``,r=document.createElement(`span`);r.className=`md-image-missing font-mono-keep`,r.textContent=n,t.alt&&t.alt!==n&&(r.title=t.alt),(t.closest(`.md-image-frame`)??t).replaceWith(r)}}function wq(e,t=!1){if(!t&&$S(e)){Op(e);return}if(!t&&X.splitFileViewer){Ap(e);return}Tq(e,t)}async function Tq(e,t){try{let n=await Y.openLocalFile({path:e,...t?{image:!0}:{}});n.action===`copy`&&(await HR(n.path),Z(`Copied local path`))}catch(e){Z(`Could not open local file: ${e.message.slice(0,100)}`)}}var Eq=`a, button, input, select, textarea, summary, label, [role="button"], [role="link"]`;function Dq(e){let t=e;return typeof t?.closest==`function`&&t.closest(Eq)!=null}function Oq({children:e,className:t,controls:n,expanded:r,label:i,meta:a,onToggle:o,chevronSize:s=12}){function c(e){if(Dq(e.target))return;let t=typeof window>`u`?null:window.getSelection();t&&!t.isCollapsed&&t.toString().trim()!==``||o()}return(0,I.createElement)(`div`,{className:`${t} w-full cursor-pointer text-left`,"data-expanded":r,onClick:c},(0,I.createElement)(`span`,{className:`flex min-w-0 items-center gap-2`},e),(0,I.createElement)(`span`,{className:`flex shrink-0 items-center gap-1.5`},a,(0,I.createElement)(`button`,{type:`button`,"data-tool-disclosure":!0,"aria-controls":n,"aria-expanded":r,"aria-label":i,title:i,onClick:o,className:`-m-1 inline-flex shrink-0 items-center justify-center rounded p-1 text-muted outline-none transition-colors hover:text-fg/80 focus-visible:ring-1 focus-visible:ring-fg/60`},(0,I.createElement)(ym,{"aria-hidden":!0,size:s,className:`relative -top-px shrink-0 transition-transform ${r?`rotate-90`:``}`}))))}function kq({path:e,className:t=``,children:n}){return(0,L.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),wq(e)},title:e,className:`font-mono-keep block max-w-full cursor-pointer truncate text-left hover:underline hover:text-fg/80 ${t}`,children:n??e})}function Aq({edits:e,meta:t}){let{compactDiffs:n}=Zt(yT),r=(0,I.useId)(),i=e[0].file,a=(0,I.useMemo)(()=>e.map(e=>xq(e.old,e.new,e.file)),[e]),o=a.reduce((e,t)=>e+t.additions,0),s=a.reduce((e,t)=>e+t.deletions,0),[c,l]=(0,I.useState)(null);(0,I.useEffect)(()=>l(null),[n]);let u=c??!n;return(0,L.jsxs)(`div`,{className:`frizz-diff`,children:[(0,L.jsxs)(Oq,{className:`frizz-diff-header`,controls:r,expanded:u,label:`${u?`Collapse`:`Expand`} Edit diff: ${i}`,onToggle:()=>l(!u),meta:t,chevronSize:11,children:[(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Edit`}),(0,L.jsx)(`span`,{className:`frizz-diff-file`,children:(0,L.jsx)(kq,{path:i,className:`text-inherit no-underline`,children:Qf(i)})}),o>0&&(0,L.jsxs)(`span`,{className:`frizz-diff-add tabular-nums shrink-0`,children:[`+`,o]}),s>0&&(0,L.jsxs)(`span`,{className:`frizz-diff-del tabular-nums shrink-0`,children:[`−`,s]})]}),(0,L.jsx)(`div`,{id:r,className:`frizz-diff-body`,hidden:!u,children:u&&a.map((e,t)=>(0,L.jsx)(`div`,{className:t>0?`frizz-diff-editsep`:void 0,children:(0,L.jsx)(jq,{hunks:e.hunks,collapsedAfter:e.collapsedAfter})},t))})]})}function jq({hunks:e,collapsedAfter:t}){let n=0,r=[];return e.forEach((e,t)=>{let i=e.collapsedBefore-n;i>0&&r.push((0,L.jsx)(Mq,{n:i},`s${t}`));for(let n of e.lines){let e=n.type===`del`?n.oldLine:n.newLine,i=n.type===`add`?`+`:n.type===`del`?`-`:` `;r.push((0,L.jsxs)(`div`,{className:`frizz-diff-line`,"data-type":n.type,children:[(0,L.jsx)(`span`,{className:`frizz-diff-gutter`,children:e}),(0,L.jsx)(`span`,{className:`frizz-diff-sign`,children:i}),(0,L.jsx)(`span`,{className:`frizz-diff-code`,children:n.tokens.map((e,t)=>(0,L.jsx)(`span`,{className:`ftk-${e.kind}`,children:e.text},t))})]},`${t}:${n.oldLine}:${n.newLine}`))}n=e.collapsedBefore+e.lines.length}),t>0&&r.push((0,L.jsx)(Mq,{n:t},`safter`)),(0,L.jsx)(L.Fragment,{children:r})}function Mq({n:e}){return(0,L.jsxs)(`div`,{className:`frizz-diff-sep`,children:[e,` unchanged line`,e===1?``:`s`]})}function Nq(e){return(0,I.useMemo)(()=>({__html:e}),[e])}var Pq=/^[\w.@+-]+\.[a-z][a-z0-9]{0,7}$/i,Fq=/^(?:[A-Za-z]:\\|\\\\)?[\w.@+~-]+(?:\\[\w.@+~-]+)*(?::\d+(?::\d+)?)?$/;function Iq(e){let t=e.trim();return!t||t.length>1024||/\s/.test(t)||/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?!1:t===`~`||t.startsWith(`~/`)||t.startsWith(`/`)||t.includes(`/`)||t.includes(`\\`)&&Fq.test(t)?!0:Pq.test(t)}var Lq=new Map,Rq=new Set,zq=0,Bq=new Set,Vq=e=>(Bq.add(e),()=>{Bq.delete(e)}),Hq=()=>zq,Uq=128;async function Wq(e){let t=[...new Set(e)].filter(e=>!Lq.has(e)&&!Rq.has(e));if(!t.length)return;for(let e of t)Rq.add(e);let n=[];for(let e=0;e<t.length;e+=Uq)n.push(t.slice(e,e+Uq));let r=await Promise.all(n.map(async e=>{try{return(await Y.resolveLocalPaths({paths:e})).resolved}catch{return e.map(e=>({input:e,path:null}))}})),i=!1;for(let e of r)for(let t of e)Lq.has(t.input)||(Lq.set(t.input,t.path),i=!0);for(let e of t)Rq.delete(e);if(i){zq+=1;for(let e of Bq)e()}}function Gq(e,t){e.setAttribute(`data-local-path`,t),e.setAttribute(`title`,`Open ${t}`),e.classList.add(`local-file-code`)}function Kq(e,t){(0,I.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=[];for(let e of t.querySelectorAll(`code`)){if(e.closest(`pre`)||e.closest(`a, [data-local-path]`))continue;let t=(e.textContent??``).trim();if(!Iq(t))continue;let r=Lq.get(t);r===void 0?n.push(t):r&&Gq(e,r)}n.length&&Wq(n)},[e,t,(0,I.useSyncExternalStore)(Vq,Hq,Hq)])}function qq({as:e=`div`,className:t,html:n}){let r=Nq(n),i=(0,I.useRef)(null);return Kq(i,n),(0,I.createElement)(e,{ref:i,className:t,dangerouslySetInnerHTML:r})}function Jq({text:e,language:t,className:n=``,...r}){let i=Nq((0,I.useMemo)(()=>US(e,t),[e,t]));return(0,L.jsx)(`pre`,{...r,className:`hljs ${n}`,dangerouslySetInnerHTML:i})}var Yq=`Todos`,Xq={pending:{Icon:yh,className:`text-muted/50`},in_progress:{Icon:_h,className:`text-accent`},completed:{Icon:gh,className:`text-muted/75`}},Zq={pending:`text-fg/75`,in_progress:`text-fg`,completed:`text-muted/70`};function Qq({status:e}){let{Icon:t,className:n}=Xq[e];return(0,L.jsx)(t,{"aria-hidden":`true`,size:`1em`,strokeWidth:2,className:`frizz-todo-mark shrink-0 ${n}`})}var $q={pending:`to do`,in_progress:`in progress`,completed:`done`};function eJ({todos:e,note:t,meta:n}){let[r,i]=(0,I.useState)(!1),a=(0,I.useId)(),o=e.filter(e=>e.status===`completed`).length,s=e.find(e=>e.status===`in_progress`),c=e.length>0||!!t,l=e.length>0?`${o}/${e.length}`:void 0,u=s?s.text:e.length===0?`empty`:void 0;return(0,L.jsxs)(`div`,{className:`frizz-bash`,"data-todo-card":!0,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>c&&i(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":c?a:void 0,"aria-expanded":c?r:void 0,"aria-label":`${c?`${r?`Collapse`:`Expand`} `:``}${Yq}${u?`: ${u}`:``}${l?` — ${o} of ${e.length} done`:``}`,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:Yq}),u&&(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-[11.5px]`,title:u,"data-todo-headline":!0,children:[s&&(0,L.jsx)(Qq,{status:`in_progress`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate text-muted`,children:u})]})]}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[l&&(0,L.jsx)(`span`,{className:`frizz-tool-header-caps tabular-nums text-[11px] text-muted/55`,title:`${o} of ${e.length} done`,children:l}),n,c&&(0,L.jsx)(ym,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${r?`rotate-90`:``}`})]})]}),c&&(0,L.jsxs)(`div`,{id:a,hidden:!r,children:[r&&e.length>0&&(0,L.jsx)(`ul`,{className:`frizz-todo-list`,children:e.map((e,t)=>(0,L.jsxs)(`li`,{className:`frizz-todo-row`,"data-current":e.status===`in_progress`?`true`:void 0,children:[(0,L.jsx)(Qq,{status:e.status}),(0,L.jsx)(`span`,{className:`min-w-0 ${Zq[e.status]}`,children:e.text}),(0,L.jsx)(`span`,{className:`sr-only`,children:` — ${$q[e.status]}`})]},t))}),r&&t&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`frizz-bash-output-label petite-caps`,children:`note`}),(0,L.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body`,children:t})]})]})]})}var tJ=/^```question(?:[ \t]+([A-Za-z][^\r\n]*?))?[ \t]*\r?\n(?:([\s\S]*?)\r?\n)??```[ \t]*$/gm,nJ=/^qst_[a-z0-9]+$/;function rJ(e){let t=(e??``).toLowerCase().split(/\s+/).filter(Boolean),n=e=>t.includes(e),r=t.find(e=>nJ.test(e));return{kind:n(`multi`)?`multi`:`question`,danger:n(`danger`),...r?{registeredId:r}:{}}}function iJ(e){let t=[],n=Ec(e),r=0;tJ.lastIndex=0;for(let i=tJ.exec(e);i!==null;i=tJ.exec(e)){if(n(i.index)){tJ.lastIndex=i.index+1;continue}let{kind:a,danger:o,registeredId:s}=rJ(i[1]);if(i[2]===void 0&&!s){tJ.lastIndex=i.index+1;continue}let c=e.slice(r,i.index);c.trim()&&t.push({kind:`prose`,text:c}),t.push({kind:`question`,text:i[2]??``,questionKind:a,danger:o,...s?{registeredId:s}:{}}),r=i.index+i[0].length}let i=e.slice(r);return i.trim()&&t.push({kind:`prose`,text:i}),aJ(t)}function aJ(e){for(let t=0;t<e.length-1;t++){let n=e[t],r=e[t+1];if(n.kind!==`question`||r.kind!==`prose`||n.registeredId&&n.text.trim()===``)continue;let i=_J(n.text,n.questionKind,n.danger),a=null;if(i.options.length>0){if(i.trailingMd!==void 0||i.recommendation!==void 0)continue;let e=bJ(i.options[i.options.length-1]);if(!/^([A-Z]|\d+)$/.test(e))continue;a=e}let o=oJ(r.text,a);o!==null&&(e[t]={...n,text:n.text.replace(/\s+$/,``)+`
285
+ `&&!t)break;o++}i(e.slice(a,o),`str`),a=o;continue}if(cq(n)){let t=a+1;for(;t<r&&/[0-9a-fA-FxXbBoO_.]/.test(e[t]);)t++;i(e.slice(a,t),`num`),a=t;continue}if(oq(n)){let n=a+1;for(;n<r&&sq(e[n]);)n++;let o=e.slice(a,n);i(o,t.keywords.has(o)?`kw`:t.types.has(o)?`type`:t.tagNames&&(e[a-1]===`<`||e[a-1]===`/`&&e[a-2]===`<`)?`kw`:t.keyChars&&t.keyChars.includes(iq(e,n))?`key`:e[n]===`(`?`fn`:`plain`),a=n;continue}if(lq.has(n)){i(n,`punct`),a++;continue}if(uq.has(n)){let t=a+1;for(;t<r&&uq.has(e[t]);)t++;i(e.slice(a,t),`op`),a=t;continue}let o=a+1;for(;o<r&&!oq(e[o])&&!cq(e[o])&&!t.quotes.includes(e[o])&&!lq.has(e[o])&&!uq.has(e[o])&&!(t.line&&e.startsWith(t.line,o));)o++;i(e.slice(a,o),`plain`),a=o}return n}function fq(e){let t=[[]];for(let n of e){let e=n.text.split(`
286
+ `);for(let r=0;r<e.length;r++)r>0&&t.push([]),e[r]&&t[t.length-1].push({text:e[r],kind:n.kind})}return t}function pq(e,t){if(e===``)return[];let n=nq[t];return n?fq(dq(e,n)):e.split(`
287
+ `).map(e=>e?[{text:e,kind:`plain`}]:[])}var mq={".ts":`typescript`,".tsx":`typescript`,".mts":`typescript`,".cts":`typescript`,".js":`javascript`,".jsx":`javascript`,".mjs":`javascript`,".cjs":`javascript`,".json":`json`,".jsonc":`json`,".css":`css`,".scss":`css`,".less":`css`,".py":`python`,".go":`go`,".rs":`rust`,".java":`java`,".c":`c`,".h":`c`,".cpp":`cpp`,".hpp":`cpp`,".cc":`cpp`,".sh":`shell`,".bash":`shell`,".zsh":`shell`,".yaml":`yaml`,".yml":`yaml`,".toml":`toml`,".html":`html`,".htm":`html`,".xml":`html`,".svg":`html`},hq={Dockerfile:`shell`,Makefile:`shell`,".gitignore":`shell`,".env":`shell`,".bashrc":`shell`,".zshrc":`shell`};function gq(e){let t=Qf(e),n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=hq[t]??mq[r]??`text`;return aq.has(i)?i:`text`}function _q(e,t,n){let r=e.length,i=t.length,a=Array.from({length:r+1},()=>new Uint32Array(i+1));for(let n=r-1;n>=0;n--)for(let r=i-1;r>=0;r--)a[n][r]=e[n]===t[r]?a[n+1][r+1]+1:Math.max(a[n+1][r],a[n][r+1]);let o=[],s=0,c=0;for(;s<r&&c<i;)e[s]===t[c]?(o.push({type:`eq`,a:n+s,b:n+c}),s++,c++):a[s+1][c]>=a[s][c+1]?(o.push({type:`del`,a:n+s,b:null}),s++):(o.push({type:`add`,a:null,b:n+c}),c++);for(;s<r;)o.push({type:`del`,a:n+s++,b:null});for(;c<i;)o.push({type:`add`,a:null,b:n+c++});return o}function vq(e,t){let n=e.length,r=t.length,i=0;for(;i<n&&i<r&&e[i]===t[i];)i++;let a=0;for(;a<n-i&&a<r-i&&e[n-1-a]===t[r-1-a];)a++;let o=[];for(let e=0;e<i;e++)o.push({type:`eq`,a:e,b:e});o.push(..._q(e.slice(i,n-a),t.slice(i,r-a),i));for(let e=0;e<a;e++)o.push({type:`eq`,a:n-a+e,b:r-a+e});return o}var yq=3,bq=e=>e===``?[]:e.split(`
288
+ `);function xq(e,t,n){return e.type===`del`?{type:`del`,oldLine:e.a+1,newLine:null,tokens:t[e.a]??[]}:e.type===`add`?{type:`add`,oldLine:null,newLine:e.b+1,tokens:n[e.b]??[]}:{type:`context`,oldLine:e.a+1,newLine:e.b+1,tokens:n[e.b]??[]}}function Sq(e){let t=[];for(let n=0;n<e.length;n++)e[n].type!==`context`&&t.push(n);if(t.length===0)return{hunks:[],collapsedAfter:e.length};let n=[],r=Math.max(0,t[0]-yq),i=-1;for(let a=0;a<t.length;a++){let o=t[a],s=t[a+1];i=Math.min(e.length-1,o+yq),!(s!==void 0&&s-o<=7)&&(n.push({collapsedBefore:r,lines:e.slice(r,i+1)}),s!==void 0&&(r=Math.max(i+1,s-yq)))}let a=n.length?n[n.length-1].collapsedBefore+n[n.length-1].lines.length:0;return{hunks:n,collapsedAfter:Math.max(0,e.length-a)}}function Cq(e,t,n){let r=gq(n),i=pq(e,r),a=pq(t,r),o=bq(e),s=bq(t),c=e===``?`added`:t===``?`deleted`:`modified`;if(c===`added`){let e=s.map((e,t)=>({type:`add`,oldLine:null,newLine:t+1,tokens:a[t]??[]}));return{file:n,lang:r,status:c,hunks:[{collapsedBefore:0,lines:e}],collapsedAfter:0,additions:e.length,deletions:0}}if(c===`deleted`){let e=o.map((e,t)=>({type:`del`,oldLine:t+1,newLine:null,tokens:i[t]??[]}));return{file:n,lang:r,status:c,hunks:[{collapsedBefore:0,lines:e}],collapsedAfter:0,additions:0,deletions:e.length}}let l=vq(o,s).map(e=>xq(e,i,a)),u=l.filter(e=>e.type===`add`).length,d=l.filter(e=>e.type===`del`).length,{hunks:f,collapsedAfter:p}=Sq(l);return{file:n,lang:r,status:c,hunks:f,collapsedAfter:p,additions:u,deletions:d}}function wq(){let e=e=>{if(e.button!==0||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`[data-local-path]`):null,n=t?.dataset.localPath;!t||!n||(e.preventDefault(),e.stopPropagation(),Eq(n,t.dataset.localImage===`true`))};document.addEventListener(`click`,e);let t=Tq();return document.addEventListener(`error`,t,!0),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`error`,t,!0)}}function Tq(){return e=>{let t=e.target;if(!(t instanceof HTMLImageElement)||t.dataset.localImage!==`true`||!t.closest(`.md-body, .md-inline`))return;let n=t.dataset.localPath??t.getAttribute(`src`)??``,r=document.createElement(`span`);r.className=`md-image-missing font-mono-keep`,r.textContent=n,t.alt&&t.alt!==n&&(r.title=t.alt),(t.closest(`.md-image-frame`)??t).replaceWith(r)}}function Eq(e,t=!1){if(!t&&$S(e)){Op(e);return}if(!t&&X.splitFileViewer){Ap(e);return}Dq(e,t)}async function Dq(e,t){try{let n=await Y.openLocalFile({path:e,...t?{image:!0}:{}});n.action===`copy`&&(await WR(n.path),Z(`Copied local path`))}catch(e){Z(`Could not open local file: ${e.message.slice(0,100)}`)}}var Oq=`a, button, input, select, textarea, summary, label, [role="button"], [role="link"]`;function kq(e){let t=e;return typeof t?.closest==`function`&&t.closest(Oq)!=null}function Aq({children:e,className:t,controls:n,expanded:r,label:i,meta:a,onToggle:o,chevronSize:s=12}){function c(e){if(kq(e.target))return;let t=typeof window>`u`?null:window.getSelection();t&&!t.isCollapsed&&t.toString().trim()!==``||o()}return(0,I.createElement)(`div`,{className:`${t} w-full cursor-pointer text-left`,"data-expanded":r,onClick:c},(0,I.createElement)(`span`,{className:`flex min-w-0 items-center gap-2`},e),(0,I.createElement)(`span`,{className:`flex shrink-0 items-center gap-1.5`},a,(0,I.createElement)(`button`,{type:`button`,"data-tool-disclosure":!0,"aria-controls":n,"aria-expanded":r,"aria-label":i,title:i,onClick:o,className:`-m-1 inline-flex shrink-0 items-center justify-center rounded p-1 text-muted outline-none transition-colors hover:text-fg/80 focus-visible:ring-1 focus-visible:ring-fg/60`},(0,I.createElement)(ym,{"aria-hidden":!0,size:s,className:`relative -top-px shrink-0 transition-transform ${r?`rotate-90`:``}`}))))}function jq({path:e,className:t=``,children:n}){return(0,L.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),Eq(e)},title:e,className:`font-mono-keep block max-w-full cursor-pointer truncate text-left hover:underline hover:text-fg/80 ${t}`,children:n??e})}function Mq({edits:e,meta:t}){let{compactDiffs:n}=Zt(yT),r=(0,I.useId)(),i=e[0].file,a=(0,I.useMemo)(()=>e.map(e=>Cq(e.old,e.new,e.file)),[e]),o=a.reduce((e,t)=>e+t.additions,0),s=a.reduce((e,t)=>e+t.deletions,0),[c,l]=(0,I.useState)(null);(0,I.useEffect)(()=>l(null),[n]);let u=c??!n;return(0,L.jsxs)(`div`,{className:`frizz-diff`,children:[(0,L.jsxs)(Aq,{className:`frizz-diff-header`,controls:r,expanded:u,label:`${u?`Collapse`:`Expand`} Edit diff: ${i}`,onToggle:()=>l(!u),meta:t,chevronSize:11,children:[(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Edit`}),(0,L.jsx)(`span`,{className:`frizz-diff-file`,children:(0,L.jsx)(jq,{path:i,className:`text-inherit no-underline`,children:Qf(i)})}),o>0&&(0,L.jsxs)(`span`,{className:`frizz-diff-add tabular-nums shrink-0`,children:[`+`,o]}),s>0&&(0,L.jsxs)(`span`,{className:`frizz-diff-del tabular-nums shrink-0`,children:[`−`,s]})]}),(0,L.jsx)(`div`,{id:r,className:`frizz-diff-body`,hidden:!u,children:u&&a.map((e,t)=>(0,L.jsx)(`div`,{className:t>0?`frizz-diff-editsep`:void 0,children:(0,L.jsx)(Nq,{hunks:e.hunks,collapsedAfter:e.collapsedAfter})},t))})]})}function Nq({hunks:e,collapsedAfter:t}){let n=0,r=[];return e.forEach((e,t)=>{let i=e.collapsedBefore-n;i>0&&r.push((0,L.jsx)(Pq,{n:i},`s${t}`));for(let n of e.lines){let e=n.type===`del`?n.oldLine:n.newLine,i=n.type===`add`?`+`:n.type===`del`?`-`:` `;r.push((0,L.jsxs)(`div`,{className:`frizz-diff-line`,"data-type":n.type,children:[(0,L.jsx)(`span`,{className:`frizz-diff-gutter`,children:e}),(0,L.jsx)(`span`,{className:`frizz-diff-sign`,children:i}),(0,L.jsx)(`span`,{className:`frizz-diff-code`,children:n.tokens.map((e,t)=>(0,L.jsx)(`span`,{className:`ftk-${e.kind}`,children:e.text},t))})]},`${t}:${n.oldLine}:${n.newLine}`))}n=e.collapsedBefore+e.lines.length}),t>0&&r.push((0,L.jsx)(Pq,{n:t},`safter`)),(0,L.jsx)(L.Fragment,{children:r})}function Pq({n:e}){return(0,L.jsxs)(`div`,{className:`frizz-diff-sep`,children:[e,` unchanged line`,e===1?``:`s`]})}function Fq(e){return(0,I.useMemo)(()=>({__html:e}),[e])}var Iq=/^[\w.@+-]+\.[a-z][a-z0-9]{0,7}$/i,Lq=/^(?:[A-Za-z]:\\|\\\\)?[\w.@+~-]+(?:\\[\w.@+~-]+)*(?::\d+(?::\d+)?)?$/;function Rq(e){let t=e.trim();return!t||t.length>1024||/\s/.test(t)||/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?!1:t===`~`||t.startsWith(`~/`)||t.startsWith(`/`)||t.includes(`/`)||t.includes(`\\`)&&Lq.test(t)?!0:Iq.test(t)}var zq=new Map,Bq=new Set,Vq=0,Hq=new Set,Uq=e=>(Hq.add(e),()=>{Hq.delete(e)}),Wq=()=>Vq,Gq=128;async function Kq(e){let t=[...new Set(e)].filter(e=>!zq.has(e)&&!Bq.has(e));if(!t.length)return;for(let e of t)Bq.add(e);let n=[];for(let e=0;e<t.length;e+=Gq)n.push(t.slice(e,e+Gq));let r=await Promise.all(n.map(async e=>{try{return(await Y.resolveLocalPaths({paths:e})).resolved}catch{return e.map(e=>({input:e,path:null}))}})),i=!1;for(let e of r)for(let t of e)zq.has(t.input)||(zq.set(t.input,t.path),i=!0);for(let e of t)Bq.delete(e);if(i){Vq+=1;for(let e of Hq)e()}}function qq(e,t){e.setAttribute(`data-local-path`,t),e.setAttribute(`title`,`Open ${t}`),e.classList.add(`local-file-code`)}function Jq(e,t){(0,I.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=[];for(let e of t.querySelectorAll(`code`)){if(e.closest(`pre`)||e.closest(`a, [data-local-path]`))continue;let t=(e.textContent??``).trim();if(!Rq(t))continue;let r=zq.get(t);r===void 0?n.push(t):r&&qq(e,r)}n.length&&Kq(n)},[e,t,(0,I.useSyncExternalStore)(Uq,Wq,Wq)])}function Yq({as:e=`div`,className:t,html:n}){let r=Fq(n),i=(0,I.useRef)(null);return Jq(i,n),(0,I.createElement)(e,{ref:i,className:t,dangerouslySetInnerHTML:r})}function Xq({text:e,language:t,className:n=``,...r}){let i=Fq((0,I.useMemo)(()=>US(e,t),[e,t]));return(0,L.jsx)(`pre`,{...r,className:`hljs ${n}`,dangerouslySetInnerHTML:i})}var Zq=`Todos`,Qq={pending:{Icon:yh,className:`text-muted/50`},in_progress:{Icon:_h,className:`text-accent`},completed:{Icon:gh,className:`text-muted/75`}},$q={pending:`text-fg/75`,in_progress:`text-fg`,completed:`text-muted/70`};function eJ({status:e}){let{Icon:t,className:n}=Qq[e];return(0,L.jsx)(t,{"aria-hidden":`true`,size:`1em`,strokeWidth:2,className:`frizz-todo-mark shrink-0 ${n}`})}var tJ={pending:`to do`,in_progress:`in progress`,completed:`done`};function nJ({todos:e,note:t,meta:n}){let[r,i]=(0,I.useState)(!1),a=(0,I.useId)(),o=e.filter(e=>e.status===`completed`).length,s=e.find(e=>e.status===`in_progress`),c=e.length>0||!!t,l=e.length>0?`${o}/${e.length}`:void 0,u=s?s.text:e.length===0?`empty`:void 0;return(0,L.jsxs)(`div`,{className:`frizz-bash`,"data-todo-card":!0,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>c&&i(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":c?a:void 0,"aria-expanded":c?r:void 0,"aria-label":`${c?`${r?`Collapse`:`Expand`} `:``}${Zq}${u?`: ${u}`:``}${l?` — ${o} of ${e.length} done`:``}`,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:Zq}),u&&(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-[11.5px]`,title:u,"data-todo-headline":!0,children:[s&&(0,L.jsx)(eJ,{status:`in_progress`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate text-muted`,children:u})]})]}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[l&&(0,L.jsx)(`span`,{className:`frizz-tool-header-caps tabular-nums text-[11px] text-muted/55`,title:`${o} of ${e.length} done`,children:l}),n,c&&(0,L.jsx)(ym,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${r?`rotate-90`:``}`})]})]}),c&&(0,L.jsxs)(`div`,{id:a,hidden:!r,children:[r&&e.length>0&&(0,L.jsx)(`ul`,{className:`frizz-todo-list`,children:e.map((e,t)=>(0,L.jsxs)(`li`,{className:`frizz-todo-row`,"data-current":e.status===`in_progress`?`true`:void 0,children:[(0,L.jsx)(eJ,{status:e.status}),(0,L.jsx)(`span`,{className:`min-w-0 ${$q[e.status]}`,children:e.text}),(0,L.jsx)(`span`,{className:`sr-only`,children:` — ${tJ[e.status]}`})]},t))}),r&&t&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`frizz-bash-output-label petite-caps`,children:`note`}),(0,L.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body`,children:t})]})]})]})}var rJ=/^```question(?:[ \t]+([A-Za-z][^\r\n]*?))?[ \t]*\r?\n(?:([\s\S]*?)\r?\n)??```[ \t]*$/gm,iJ=/^qst_[a-z0-9]+$/;function aJ(e){let t=(e??``).toLowerCase().split(/\s+/).filter(Boolean),n=e=>t.includes(e),r=t.find(e=>iJ.test(e));return{kind:n(`multi`)?`multi`:`question`,danger:n(`danger`),...r?{registeredId:r}:{}}}function oJ(e){let t=[],n=Ec(e),r=0;rJ.lastIndex=0;for(let i=rJ.exec(e);i!==null;i=rJ.exec(e)){if(n(i.index)){rJ.lastIndex=i.index+1;continue}let{kind:a,danger:o,registeredId:s}=aJ(i[1]);if(i[2]===void 0&&!s){rJ.lastIndex=i.index+1;continue}let c=e.slice(r,i.index);c.trim()&&t.push({kind:`prose`,text:c}),t.push({kind:`question`,text:i[2]??``,questionKind:a,danger:o,...s?{registeredId:s}:{}}),r=i.index+i[0].length}let i=e.slice(r);return i.trim()&&t.push({kind:`prose`,text:i}),sJ(t)}function sJ(e){for(let t=0;t<e.length-1;t++){let n=e[t],r=e[t+1];if(n.kind!==`question`||r.kind!==`prose`||n.registeredId&&n.text.trim()===``)continue;let i=yJ(n.text,n.questionKind,n.danger),a=null;if(i.options.length>0){if(i.trailingMd!==void 0||i.recommendation!==void 0)continue;let e=SJ(i.options[i.options.length-1]);if(!/^([A-Z]|\d+)$/.test(e))continue;a=e}let o=cJ(r.text,a);o!==null&&(e[t]={...n,text:n.text.replace(/\s+$/,``)+`
289
289
 
290
- `+o.run},o.rest.trim()?e[t+1]={kind:`prose`,text:o.rest}:e.splice(t+1,1))}return e}function oJ(e,t){let n=e.split(`
291
- `).map(e=>e.replace(/\r$/,``)),r=0;for(;r<n.length&&n[r].trim()===``;)r++;if(r>=n.length||!cJ.test(n[r]))return null;let i=dJ(n[r]);if(t===null?!pJ(i):!fJ(t,i))return null;let a=r,o=i;for(let e=r+1;e<n.length;e++){let t=n[e];if(cJ.test(t)){if(!fJ(o,dJ(t)))break;o=dJ(t),a=e;continue}if(t.trim()===``)continue;if(lJ.test(t)){a=e;break}let r=n.findIndex((t,n)=>n>e&&cJ.test(t));if(r===-1||!fJ(o,dJ(n[r])))break}let s=n.slice(r,a+1);return s.filter(e=>cJ.test(e)).length<(t===null?2:1)?null:{run:s.join(`
290
+ `+o.run},o.rest.trim()?e[t+1]={kind:`prose`,text:o.rest}:e.splice(t+1,1))}return e}function cJ(e,t){let n=e.split(`
291
+ `).map(e=>e.replace(/\r$/,``)),r=0;for(;r<n.length&&n[r].trim()===``;)r++;if(r>=n.length||!uJ.test(n[r]))return null;let i=pJ(n[r]);if(t===null?!hJ(i):!mJ(t,i))return null;let a=r,o=i;for(let e=r+1;e<n.length;e++){let t=n[e];if(uJ.test(t)){if(!mJ(o,pJ(t)))break;o=pJ(t),a=e;continue}if(t.trim()===``)continue;if(dJ.test(t)){a=e;break}let r=n.findIndex((t,n)=>n>e&&uJ.test(t));if(r===-1||!mJ(o,pJ(n[r])))break}let s=n.slice(r,a+1);return s.filter(e=>uJ.test(e)).length<(t===null?2:1)?null:{run:s.join(`
292
292
  `),rest:n.slice(a+1).join(`
293
- `)}}function sJ(e){return e.includes("```question")&&iJ(e).some(e=>e.kind===`question`)}var cJ=/^\s*(?:[-*+]\s+)?([A-Z]|\d+)[.)]\s+\S/,lJ=/^\s*recommendation\b/i;function uJ(e){return e.trim().replace(/^[-*+]\s+/,``)}function dJ(e){return uJ(e).match(/^([A-Za-z]|\d+)[.)]/)?.[1].toUpperCase()??``}function fJ(e,t){return/^\d+$/.test(e)?/^\d+$/.test(t)&&Number(t)===Number(e)+1:/^[A-Z]$/.test(e)&&/^[A-Z]$/.test(t)&&t.charCodeAt(0)===e.charCodeAt(0)+1}var pJ=e=>e===`A`||e===`1`,mJ=/(^|[^a-z])recommended([^a-z]|$)/i;function hJ(e){return e.replace(/\s{2,}/g,` `).trim()}function gJ(e){if(!mJ.test(e))return{label:e,recommended:!1};let t=e.match(/\s*[—–-]?\s*[([]\s*[*_`~]*recommended\b(?:\s*[::,;—–-]\s*([^)\]]*?))?\s*[*_`~]*\s*[)\]]/i);if(t){let n=t[1]?.trim()||void 0;return{label:hJ(e.slice(0,t.index)+e.slice(t.index+t[0].length)),recommended:!0,note:n}}let n=e.match(/\s*[—–:-]?\s*[*_`~]+recommended\b[*_`~]+\s*[—–:-]?\s*/i);if(n)return{label:hJ(e.slice(0,n.index)+` `+e.slice(n.index+n[0].length)),recommended:!0};let r=e.match(/\s*[—–:-]?\s*recommended\b\s*$/i);if(r&&r.index>0)return{label:hJ(e.slice(0,r.index)),recommended:!0};let i=e.match(/^(\s*(?:[A-Za-z]|\d+)[.)]\s*)?[*_`~]*recommended\b[*_`~]*\s*[::—–-]\s*/i);if(i){let t=hJ((i[1]??``)+e.slice(i[0].length));if(t)return{label:t,recommended:!0}}return{label:e,recommended:!1}}function _J(e,t,n=!1){let r=e.split(`
294
- `).map(e=>e.replace(/\r$/,``)),i=e=>r.findIndex((t,n)=>n>e&&cJ.test(t)),a=e=>{let t=[];for(let n=e;n<r.length;n++){if(cJ.test(r[n])){t.push(n);continue}if(t.length===0||r[n].trim()===``)continue;if(lJ.test(r[n]))break;let e=i(n);if(e===-1||!fJ(dJ(r[t[t.length-1]]),dJ(r[e])))break}return t},o=e=>{for(let t=e.length-1;t>0;t--)if(!fJ(dJ(r[e[t-1]]),dJ(r[e[t]])))return pJ(dJ(r[e[t]]))?t:0;return+(e.length===1&&!/^\s*[-*+]\s/.test(r[e[0]])&&!r.slice(0,e[0]).some(e=>e.trim()))},s=[];for(let e=0;e<r.length;){let t=a(e);if(t.length===0)break;let n=o(t);if(n<t.length){s=t.slice(n);break}e=t[0]+1}if(s.length===0)return{kind:t,danger:n,contextMd:e,options:[],recommendedIdx:null};let c=s[0],l=s[s.length-1],u=[],d=null,f,p=[];for(let[e,t]of s.entries()){let{label:n,recommended:i,note:a}=gJ(uJ(r[t]));i&&d===null&&(d=u.length,f=a),u.push(n);let o=e===0?[]:r.slice(s[e-1]+1,t).filter(e=>e.trim());p.push(o.length?o.join(`
293
+ `)}}function lJ(e){return e.includes("```question")&&oJ(e).some(e=>e.kind===`question`)}var uJ=/^\s*(?:[-*+]\s+)?([A-Z]|\d+)[.)]\s+\S/,dJ=/^\s*recommendation\b/i;function fJ(e){return e.trim().replace(/^[-*+]\s+/,``)}function pJ(e){return fJ(e).match(/^([A-Za-z]|\d+)[.)]/)?.[1].toUpperCase()??``}function mJ(e,t){return/^\d+$/.test(e)?/^\d+$/.test(t)&&Number(t)===Number(e)+1:/^[A-Z]$/.test(e)&&/^[A-Z]$/.test(t)&&t.charCodeAt(0)===e.charCodeAt(0)+1}var hJ=e=>e===`A`||e===`1`,gJ=/(^|[^a-z])recommended([^a-z]|$)/i;function _J(e){return e.replace(/\s{2,}/g,` `).trim()}function vJ(e){if(!gJ.test(e))return{label:e,recommended:!1};let t=e.match(/\s*[—–-]?\s*[([]\s*[*_`~]*recommended\b(?:\s*[::,;—–-]\s*([^)\]]*?))?\s*[*_`~]*\s*[)\]]/i);if(t){let n=t[1]?.trim()||void 0;return{label:_J(e.slice(0,t.index)+e.slice(t.index+t[0].length)),recommended:!0,note:n}}let n=e.match(/\s*[—–:-]?\s*[*_`~]+recommended\b[*_`~]+\s*[—–:-]?\s*/i);if(n)return{label:_J(e.slice(0,n.index)+` `+e.slice(n.index+n[0].length)),recommended:!0};let r=e.match(/\s*[—–:-]?\s*recommended\b\s*$/i);if(r&&r.index>0)return{label:_J(e.slice(0,r.index)),recommended:!0};let i=e.match(/^(\s*(?:[A-Za-z]|\d+)[.)]\s*)?[*_`~]*recommended\b[*_`~]*\s*[::—–-]\s*/i);if(i){let t=_J((i[1]??``)+e.slice(i[0].length));if(t)return{label:t,recommended:!0}}return{label:e,recommended:!1}}function yJ(e,t,n=!1){let r=e.split(`
294
+ `).map(e=>e.replace(/\r$/,``)),i=e=>r.findIndex((t,n)=>n>e&&uJ.test(t)),a=e=>{let t=[];for(let n=e;n<r.length;n++){if(uJ.test(r[n])){t.push(n);continue}if(t.length===0||r[n].trim()===``)continue;if(dJ.test(r[n]))break;let e=i(n);if(e===-1||!mJ(pJ(r[t[t.length-1]]),pJ(r[e])))break}return t},o=e=>{for(let t=e.length-1;t>0;t--)if(!mJ(pJ(r[e[t-1]]),pJ(r[e[t]])))return hJ(pJ(r[e[t]]))?t:0;return+(e.length===1&&!/^\s*[-*+]\s/.test(r[e[0]])&&!r.slice(0,e[0]).some(e=>e.trim()))},s=[];for(let e=0;e<r.length;){let t=a(e);if(t.length===0)break;let n=o(t);if(n<t.length){s=t.slice(n);break}e=t[0]+1}if(s.length===0)return{kind:t,danger:n,contextMd:e,options:[],recommendedIdx:null};let c=s[0],l=s[s.length-1],u=[],d=null,f,p=[];for(let[e,t]of s.entries()){let{label:n,recommended:i,note:a}=vJ(fJ(r[t]));i&&d===null&&(d=u.length,f=a),u.push(n);let o=e===0?[]:r.slice(s[e-1]+1,t).filter(e=>e.trim());p.push(o.length?o.join(`
295
295
  `):void 0)}let m=e=>{let t=0,n=e.length-1;for(;t<=n&&e[t].trim()===``;)t++;for(;n>=t&&e[n].trim()===``;)n--;return e.slice(t,n+1)},h=m(r.slice(0,c)).join(`
296
- `),g,_=[];for(let e of r.slice(l+1))g===void 0&&lJ.test(e)?g=e.trim():_.push(e);let v=m(_).join(`
297
- `)||void 0;return d===null&&g&&(d=yJ(g,u),d!==null&&(f=g)),{kind:t,danger:n,contextMd:h,options:u,recommendedIdx:d,recommendedNote:f,recommendation:g,trailingMd:v,...p.some(Boolean)?{optionHeadings:p}:{}}}var vJ=/^[*_`~\s]+/;function yJ(e,t){if(!e)return null;let n=e.replace(/^\s*recommendation\s*:?\s*/i,``).replace(vJ,``).match(/^([A-Za-z]|\d+)(?![A-Za-z0-9])/);if(!n)return null;let r=n[1].toUpperCase(),i=t.findIndex(e=>{let t=e.replace(vJ,``).match(/^([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase()===r:!1});return i===-1?null:i}function bJ(e){let t=e.match(/^\s*([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase():e.trim()}function xJ(e,t){let n=t.text.trim();if(e.kind===`multi`){let r=(t.chosenSet??[]).slice().sort((e,t)=>e-t).map(t=>bJ(e.options[t]??``)).filter(Boolean).join(`, `);return r&&n?`${r} — ${n}`:r||n}return t.chosen==null?n:e.options[t.chosen]??``}var SJ=/^```(done|awaiting)[ \t]*\r?\n([\s\S]*?)\r?\n```[ \t]*$/gm;function CJ(e,t){return t===`done`?{body:e.trim(),hints:[]}:cl(e)}function wJ(e){let t=[],n=Ec(e),r=0;SJ.lastIndex=0;for(let i=SJ.exec(e);i!==null;i=SJ.exec(e)){if(n(i.index)){SJ.lastIndex=i.index+1;continue}let a=e.slice(r,i.index);a.trim()&&t.push({kind:`prose`,text:a});let o=i[1],{body:s,hints:c}=CJ(i[2],o);t.push({kind:`fence`,fenceKind:o,body:s,hints:c}),r=i.index+i[0].length}let i=e.slice(r);return i.trim()&&t.push({kind:`prose`,text:i}),t}function TJ(e,t){let n=e?.lastFence;return!(!n||n.kind!==`done`||n.registered!==!0||t&&wJ(t).some(e=>e.kind===`fence`&&e.fenceKind===`done`))}var EJ=`[overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`,DJ=`rounded-xl`,OJ=`rounded-t-xl`,kJ=`rounded-b-[calc(var(--block-radius)_-_1px)]`,AJ={neutral:{border:`border-border-strong`,head:`text-fg`},attention:{border:`border-accent/45`,head:`text-accent`},caution:{border:`border-border-strong`,head:`text-amber-400`},risk:{border:`border-border-strong`,head:`text-red-400`},danger:{border:`border-red-500/45`,head:`text-red-400`}},jJ=`card-icon-offset`;function MJ({icon:e,label:t,head:n=AJ.neutral.head,aside:r}){return(0,L.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 text-[16px] font-semibold leading-6 tracking-tight ${n}`,children:t}),r&&(0,L.jsx)(`span`,{className:`shrink-0 leading-6`,children:r}),e&&(0,L.jsx)(e,{"aria-hidden":`true`,size:16,className:`shrink-0 ${jJ} ${n}`})]})}function NJ({children:e}){return(0,L.jsx)(`div`,{className:`card-md mt-1 min-w-0 text-fg/75`,children:e})}function PJ({tone:e=`neutral`,icon:t,label:n,aside:r,children:i,className:a=``,...o}){let{border:s,head:c}=AJ[e];return(0,L.jsxs)(`div`,{...o,className:`min-w-0 ${DJ} border ${s} bg-panel-2 p-4 ${a}`,children:[(0,L.jsx)(MJ,{icon:t,label:n,head:c,aside:r}),i!=null&&(0,L.jsx)(NJ,{children:i})]})}var FJ=`block min-w-0 text-[13px] leading-5 text-fg/75`;function IJ({children:e,className:t=``}){return(0,L.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center justify-start gap-x-2.5 gap-y-2 ${t}`,children:e})}var LJ=`min-w-0 flex-1 text-[11px] leading-snug text-muted/70`,RJ=`text-accent underline underline-offset-2 decoration-accent/40 hover:decoration-accent`,zJ=`flex shrink-0 items-center gap-1 rounded-md text-[11px] font-medium outline-none transition-colors focus-visible:ring-1 focus-visible:ring-fg/60 bg-fg px-2.5 py-1 text-bg hover:opacity-90`;function BJ(e,t){return!e||e.kind!==`session`||e.foreign||e.runtime!==`turn-idle`&&e.runtime!==`exited`||e.needsYou!==!0||e.providerError?!1:e.crashed===!0?!0:!(e.lastFence||e.pendingQuestion||(e.questions?.length??0)>0||e.answersInFlight||e.pendingAsk||e.pendingInteraction||e.awaitingBackground||e.limitPause||e.providerFault||!e.lastAssistantAt||t===void 0||wJ(t).some(e=>e.kind===`fence`)||sJ(t))}function VJ({thread:e}){return e.crashed===!0?(0,L.jsx)(PJ,{"data-rested-card":`stalled`,icon:xh,label:`Stalled`,children:(0,L.jsx)(`p`,{className:FJ,children:`The agent's process exited mid-turn. Retry, in the header, re-sends the last message.`})}):(0,L.jsx)(PJ,{"data-rested-card":`bare`,icon:wm,label:`Rested without a sign-off`,children:(0,L.jsx)(`p`,{className:FJ,children:`The worker stopped without a done card, a question or a registered wait. Frizz nudges it for one; a reply here also wakes it.`})})}function HJ(e,t){return t!==void 0&&e.some(e=>e.providerError?.at===t.at&&e.providerError?.message===t.message&&e.providerError?.code===t.code)}function UJ({error:e}){return(0,L.jsxs)(PJ,{"data-codex-error":e.code??`unknown`,tone:e.retrying?`caution`:`danger`,icon:xh,label:e.retrying?`Codex retrying`:`Codex request failed`,children:[e.code&&(0,L.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75 font-mono [overflow-wrap:anywhere]`,children:e.code}),(0,L.jsx)(`p`,{className:`${FJ} whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.message}),e.details&&(0,L.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75 whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details})]})}var WJ=/^(\d+)\.\s+(.*)$/;function GJ(e){if(!e)return null;let t=e.replace(/\r\n?/g,`
296
+ `),g,_=[];for(let e of r.slice(l+1))g===void 0&&dJ.test(e)?g=e.trim():_.push(e);let v=m(_).join(`
297
+ `)||void 0;return d===null&&g&&(d=xJ(g,u),d!==null&&(f=g)),{kind:t,danger:n,contextMd:h,options:u,recommendedIdx:d,recommendedNote:f,recommendation:g,trailingMd:v,...p.some(Boolean)?{optionHeadings:p}:{}}}var bJ=/^[*_`~\s]+/;function xJ(e,t){if(!e)return null;let n=e.replace(/^\s*recommendation\s*:?\s*/i,``).replace(bJ,``).match(/^([A-Za-z]|\d+)(?![A-Za-z0-9])/);if(!n)return null;let r=n[1].toUpperCase(),i=t.findIndex(e=>{let t=e.replace(bJ,``).match(/^([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase()===r:!1});return i===-1?null:i}function SJ(e){let t=e.match(/^\s*([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase():e.trim()}function CJ(e,t){let n=t.text.trim();if(e.kind===`multi`){let r=(t.chosenSet??[]).slice().sort((e,t)=>e-t).map(t=>SJ(e.options[t]??``)).filter(Boolean).join(`, `);return r&&n?`${r} — ${n}`:r||n}return t.chosen==null?n:e.options[t.chosen]??``}var wJ=/^```(done|awaiting)[ \t]*\r?\n([\s\S]*?)\r?\n```[ \t]*$/gm;function TJ(e,t){return t===`done`?{body:e.trim(),hints:[]}:cl(e)}function EJ(e){let t=[],n=Ec(e),r=0;wJ.lastIndex=0;for(let i=wJ.exec(e);i!==null;i=wJ.exec(e)){if(n(i.index)){wJ.lastIndex=i.index+1;continue}let a=e.slice(r,i.index);a.trim()&&t.push({kind:`prose`,text:a});let o=i[1],{body:s,hints:c}=TJ(i[2],o);t.push({kind:`fence`,fenceKind:o,body:s,hints:c}),r=i.index+i[0].length}let i=e.slice(r);return i.trim()&&t.push({kind:`prose`,text:i}),t}function DJ(e,t){let n=e?.lastFence;return!(!n||n.kind!==`done`||n.registered!==!0||t&&EJ(t).some(e=>e.kind===`fence`&&e.fenceKind===`done`))}var OJ=`[overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`,kJ=`rounded-xl`,AJ=`rounded-t-xl`,jJ=`rounded-b-[calc(var(--block-radius)_-_1px)]`,MJ={neutral:{border:`border-border-strong`,head:`text-fg`},attention:{border:`border-accent/45`,head:`text-accent`},caution:{border:`border-border-strong`,head:`text-amber-400`},risk:{border:`border-border-strong`,head:`text-red-400`},danger:{border:`border-red-500/45`,head:`text-red-400`}},NJ=`card-icon-offset`;function PJ({icon:e,label:t,head:n=MJ.neutral.head,aside:r}){return(0,L.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 text-[16px] font-semibold leading-6 tracking-tight ${n}`,children:t}),r&&(0,L.jsx)(`span`,{className:`shrink-0 leading-6`,children:r}),e&&(0,L.jsx)(e,{"aria-hidden":`true`,size:16,className:`shrink-0 ${NJ} ${n}`})]})}function FJ({children:e}){return(0,L.jsx)(`div`,{className:`card-md mt-1 min-w-0 text-fg/75`,children:e})}function IJ({tone:e=`neutral`,icon:t,label:n,aside:r,children:i,className:a=``,...o}){let{border:s,head:c}=MJ[e];return(0,L.jsxs)(`div`,{...o,className:`min-w-0 ${kJ} border ${s} bg-panel-2 p-4 ${a}`,children:[(0,L.jsx)(PJ,{icon:t,label:n,head:c,aside:r}),i!=null&&(0,L.jsx)(FJ,{children:i})]})}var LJ=`block min-w-0 text-[13px] leading-5 text-fg/75`;function RJ({children:e,className:t=``}){return(0,L.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center justify-start gap-x-2.5 gap-y-2 ${t}`,children:e})}var zJ=`min-w-0 flex-1 text-[11px] leading-snug text-muted/70`,BJ=`text-accent underline underline-offset-2 decoration-accent/40 hover:decoration-accent`,VJ=`flex shrink-0 items-center gap-1 rounded-md text-[11px] font-medium outline-none transition-colors focus-visible:ring-1 focus-visible:ring-fg/60 bg-fg px-2.5 py-1 text-bg hover:opacity-90`;function HJ(e,t){return!e||e.kind!==`session`||e.foreign||e.runtime!==`turn-idle`&&e.runtime!==`exited`||e.needsYou!==!0||e.providerError?!1:e.crashed===!0?!0:!(e.lastFence||e.pendingQuestion||(e.questions?.length??0)>0||e.answersInFlight||e.pendingAsk||e.pendingInteraction||e.awaitingBackground||e.limitPause||e.providerFault||!e.lastAssistantAt||t===void 0||EJ(t).some(e=>e.kind===`fence`)||lJ(t))}function UJ({thread:e}){return e.crashed===!0?(0,L.jsx)(IJ,{"data-rested-card":`stalled`,icon:xh,label:`Stalled`,children:(0,L.jsx)(`p`,{className:LJ,children:`The agent's process exited mid-turn. Retry, in the header, re-sends the last message.`})}):(0,L.jsx)(IJ,{"data-rested-card":`bare`,icon:wm,label:`Rested without a sign-off`,children:(0,L.jsx)(`p`,{className:LJ,children:`The worker stopped without a done card, a question or a registered wait. Frizz nudges it for one; a reply here also wakes it.`})})}function WJ(e,t){return t!==void 0&&e.some(e=>e.providerError?.at===t.at&&e.providerError?.message===t.message&&e.providerError?.code===t.code)}function GJ({error:e}){return(0,L.jsxs)(IJ,{"data-codex-error":e.code??`unknown`,tone:e.retrying?`caution`:`danger`,icon:xh,label:e.retrying?`Codex retrying`:`Codex request failed`,children:[e.code&&(0,L.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75 font-mono [overflow-wrap:anywhere]`,children:e.code}),(0,L.jsx)(`p`,{className:`${LJ} whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.message}),e.details&&(0,L.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75 whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details})]})}var KJ=/^(\d+)\.\s+(.*)$/;function qJ(e){if(!e)return null;let t=e.replace(/\r\n?/g,`
298
298
  `).split(`
299
- `),n=0;for(;n<t.length&&!t[n].trim();)n++;if(n>=t.length||t[n].trim()!==`Answers:`)return null;n++;let r=[];for(;n<t.length;n++){let e=t[n],i=e.match(WJ);if(i)r.push({n:Number(i[1]),answer:i[2]});else if(r.length>0){let t=r[r.length-1];t.answer=t.answer?`${t.answer}\n${e}`:e}else if(e.trim())return null}if(r.length===0)return null;for(let e of r)e.answer=e.answer.replace(/\s+$/,``);return r}var KJ=nu,qJ=RegExp(`^(\\d+)\\.\\s+(⤷\\s+)?[“"](.*?)[”"]\\s+→\\s+(.*)$`);function JJ(e){if(!e)return null;let t=e.replace(/\r\n?/g,`
299
+ `),n=0;for(;n<t.length&&!t[n].trim();)n++;if(n>=t.length||t[n].trim()!==`Answers:`)return null;n++;let r=[];for(;n<t.length;n++){let e=t[n],i=e.match(KJ);if(i)r.push({n:Number(i[1]),answer:i[2]});else if(r.length>0){let t=r[r.length-1];t.answer=t.answer?`${t.answer}\n${e}`:e}else if(e.trim())return null}if(r.length===0)return null;for(let e of r)e.answer=e.answer.replace(/\s+$/,``);return r}var JJ=nu,YJ=RegExp(`^(\\d+)\\.\\s+(⤷\\s+)?[“"](.*?)[”"]\\s+→\\s+(.*)$`);function XJ(e){if(!e)return null;let t=e.replace(/\r\n?/g,`
300
300
  `).split(`
301
- `),n=0;for(;n<t.length&&!t[n].trim();)n++;if(n>=t.length||t[n].trim()!==KJ)return null;n++;let r=[];for(;n<t.length;n++){let e=t[n],i=e.match(qJ);if(i){let e=i[3].trim(),t={n:Number(i[1]),answer:i[4]};e&&(t.question=e),i[2]&&(t.followUp=!0),r.push(t)}else if(r.length>0){let t=r[r.length-1];t.answer=t.answer?`${t.answer}\n${e}`:e}else if(e.trim())return null}if(r.length===0)return null;for(let e of r)e.answer=e.answer.replace(/\s+$/,``);return r}function YJ(e){return JJ(e)??GJ(e)}var XJ=e=>e.displayText??e.text;function ZJ(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`?!1:YJ(XJ(e))!==null}var QJ=e=>`${e.question??``}${e.answer}`;function $J(e,t){let n=t?YJ(t):null;if(!n?.length)return null;let r=new Set;for(let t of e)if(!(t.role!==`user`||t.kind===`event`||t.kind===`reasoning`))for(let e of YJ(XJ(t))??[])r.add(QJ(e));if(r.size===0)return n;let i=n.filter(e=>!r.has(QJ(e)));return i.length>0?i:null}function eY(e,t){for(let n=t-1;n>=0;n--){let t=e[n];if(t.kind===`event`||t.kind===`reasoning`||!t.text.trim())continue;if(t.role===`user`)return null;if(!t.text.includes("```question"))continue;let r=iJ(t.text).filter(e=>e.kind===`question`);if(r.length>0)return r}return null}var tY=e=>e.kind===`question`?_J(e.text,e.questionKind,e.danger).contextMd.trim():``;function nY(e,t){if(t.length!==1)return null;let n=e.trim();if(!n)return null;let r=t[0];if(r.kind!==`question`)return null;let i=_J(r.text,r.questionKind,r.danger);if(!i.options.some(e=>e.trim()===n))return null;let a=i.contextMd.trim();return[a?{n:1,answer:n,question:a}:{n:1,answer:n}]}function rY(e,t){let n=e[t];if(!n||n.role!==`user`||n.kind===`event`)return null;let r=XJ(n),i=JJ(r);if(i)return i;let a=GJ(r),o=eY(e,t);return a?!o||!a.every((e,t)=>Number.isInteger(e.n)&&e.n>=1&&e.n<=o.length&&(t===0||e.n>a[t-1].n))?a:a.map(e=>{let t=tY(o[e.n-1]);return t?{...e,question:t}:{...e}}):o?nY(r,o):null}function iY(e){return e.map((t,n)=>rY(e,n))}function aY(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function oY(e){for(let t=e.length-1;t>=0;t--){if(e[t].role===`assistant`)return!0;if(aY(e[t]))return!1}return!1}function sY(e,t){let n=Date.parse(t),r=e.length-1;if(!Number.isFinite(n))return r;for(let t=0;t<e.length;t++){let r=e[t];if(!aY(r))continue;let i=r.at?Date.parse(r.at):NaN;if(!(!Number.isFinite(i)||i<=n))return t-1}return r}function cY(e,t,n={}){if(n.atRest&&t.length>0&&oY(e))return new Map([[e.length-1,[...t]]]);let r=new Map;for(let n of t){let t=sY(e,n.askedAt),i=r.get(t);i?i.push(n):r.set(t,[n])}return r}function lY(e,t){for(let n=t;n>=0;n--)if(uY(e[n]))return n+1;return 0}function uY(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function dY(e,t){let n=new Map;for(let[r,i]of cY(e,t))for(let t=lY(e,r);t<e.length;t++){if(uY(e[t]))continue;let r=n.get(t);r?r.push(...i):n.set(t,[...i])}return n}var fY=12;function pY(e){return e.replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[*_~`]/g,``).replace(/\s+/g,` `).trim().toLowerCase()}function mY(e){let t=e.indexOf(`?`);return t===-1?void 0:e.slice(0,t+1)}function hY(e,t){if(t.length===0)return!1;let n=pY(_J(e,`question`).contextMd);if(n.length<fY)return!1;let r=mY(n);return t.some(({spec:e})=>{let t=pY(e.question);if(t.length<fY)return!1;if(n.includes(t)||t.startsWith(n))return!0;let i=mY(t);return i!==void 0&&i.length>=fY&&n.includes(i)?!0:r!==void 0&&r.length>=fY&&t.includes(r)})}function gY(e,t){if(t.length===0||!e.includes("```question"))return!1;let n=iJ(e).filter(e=>e.kind===`question`);return n.length>0&&n.every(e=>e.kind===`question`&&_Y(e,t)!==void 0)}function _Y(e,t){return e.registeredId?t.find(t=>t.id.toLowerCase()===e.registeredId):t.find(t=>hY(e.text,[t]))}function vY(e){return e.includes("```question")?iJ(e).flatMap(e=>e.kind===`question`&&e.registeredId&&e.text.trim()===``?[e.registeredId]:[]):[]}function yY(e,t){let n=new Map,r=new Set;if(t.length===0)return{placed:n,placedIds:r};let i=new Map,a=t=>{let n=i.get(t);if(n===void 0){let r=e[t];n=r.role===`assistant`&&r.text?vY(r.text):[],i.set(t,n)}return n};for(let[i,o]of cY(e,t))for(let t of o){let o=t.id.toLowerCase(),s=-1;for(let t=lY(e,i);t<e.length;t++)uY(e[t])||a(t).includes(o)&&(s=t);if(s<0)continue;let c=n.get(s);c?c.push(t):n.set(s,[t]),r.add(t.id)}return{placed:n,placedIds:r}}function bY({h:e=14}){return(0,L.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0`,style:{height:e}})}function xY({icon:e,children:t,sourceId:n,ariaLabel:r,marker:i,at:a,onClick:o,ariaExpanded:s,ariaControls:c}){let l=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`h-px flex-1 bg-border/70 transition-colors group-hover/wake:bg-border`}),(0,L.jsxs)(`span`,{className:`petite-caps flex min-w-0 items-center gap-1 break-words text-center text-[12px] text-muted/70 transition-colors group-hover/wake:text-fg`,children:[e&&(0,L.jsx)(e,{"aria-hidden":`true`,size:12,className:CY}),t,(0,L.jsx)(SY,{at:a})]}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`h-px flex-1 bg-border/70 transition-colors group-hover/wake:bg-border`})]});return o?(0,L.jsx)(`button`,{type:`button`,"data-wake-divider":i,onClick:o,onMouseDown:e=>e.preventDefault(),"aria-label":r,"aria-expanded":s,"aria-controls":c,className:`group/wake my-1 flex w-full items-center gap-3 rounded-sm text-left outline-none focus-visible:ring-1 focus-visible:ring-fg/60`,children:l}):(0,L.jsx)(`div`,{"data-frizz-msg":n,"data-wake-divider":i,className:`my-1 flex items-center gap-3`,role:r?`separator`:void 0,"aria-label":r,children:l})}function SY({at:e}){let t=mE(e,TE());return t?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,L.jsx)(`span`,{title:hE(e)??void 0,className:`shrink-0 tabular-nums`,children:t})]}):null}var CY=`shrink-0 translate-y-[0.04em]`;function wY(e,t,n){return e===1?n?`New ${t} from @${n}`:`New ${t}`:`${e} new items`}var TY=`rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`;function EY({steer:e,text:t,sourceId:n,at:r,wrap:i}){let a=Ol(t);if(a)return(0,L.jsx)(PY,{wake:a,sourceId:n,at:r});let o=Al(t);if(o)return(0,L.jsx)(OY,{wake:o,sourceId:n});let s=Pl(t);if(s)return(0,L.jsx)(MY,{window:s.window,sourceId:n,at:r});let c=Ml(t);if(c)return(0,L.jsx)(NY,{capped:c.capped,to:c.to,sourceId:n,at:r});let l=Rl(t);if(l)return(0,L.jsx)(AY,{wake:l,sourceId:n,at:r});let u=Bl(t);if(u)return(0,L.jsx)(jY,{watchRef:u.ref,sourceId:n,at:r});let d=iu(t);if(d)return(0,L.jsx)(kY,{count:d.count,sourceId:n,at:r});let f=Yu(t),p=qu(t),m=e??Hu(f||p?t.split(`
301
+ `),n=0;for(;n<t.length&&!t[n].trim();)n++;if(n>=t.length||t[n].trim()!==JJ)return null;n++;let r=[];for(;n<t.length;n++){let e=t[n],i=e.match(YJ);if(i){let e=i[3].trim(),t={n:Number(i[1]),answer:i[4]};e&&(t.question=e),i[2]&&(t.followUp=!0),r.push(t)}else if(r.length>0){let t=r[r.length-1];t.answer=t.answer?`${t.answer}\n${e}`:e}else if(e.trim())return null}if(r.length===0)return null;for(let e of r)e.answer=e.answer.replace(/\s+$/,``);return r}function ZJ(e){return XJ(e)??qJ(e)}var QJ=e=>e.displayText??e.text;function $J(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`?!1:ZJ(QJ(e))!==null}var eY=e=>`${e.question??``}${e.answer}`;function tY(e,t){let n=t?ZJ(t):null;if(!n?.length)return null;let r=new Set;for(let t of e)if(!(t.role!==`user`||t.kind===`event`||t.kind===`reasoning`))for(let e of ZJ(QJ(t))??[])r.add(eY(e));if(r.size===0)return n;let i=n.filter(e=>!r.has(eY(e)));return i.length>0?i:null}function nY(e,t){for(let n=t-1;n>=0;n--){let t=e[n];if(t.kind===`event`||t.kind===`reasoning`||!t.text.trim())continue;if(t.role===`user`)return null;if(!t.text.includes("```question"))continue;let r=oJ(t.text).filter(e=>e.kind===`question`);if(r.length>0)return r}return null}var rY=e=>e.kind===`question`?yJ(e.text,e.questionKind,e.danger).contextMd.trim():``;function iY(e,t){if(t.length!==1)return null;let n=e.trim();if(!n)return null;let r=t[0];if(r.kind!==`question`)return null;let i=yJ(r.text,r.questionKind,r.danger);if(!i.options.some(e=>e.trim()===n))return null;let a=i.contextMd.trim();return[a?{n:1,answer:n,question:a}:{n:1,answer:n}]}function aY(e,t){let n=e[t];if(!n||n.role!==`user`||n.kind===`event`)return null;let r=QJ(n),i=XJ(r);if(i)return i;let a=qJ(r),o=nY(e,t);return a?!o||!a.every((e,t)=>Number.isInteger(e.n)&&e.n>=1&&e.n<=o.length&&(t===0||e.n>a[t-1].n))?a:a.map(e=>{let t=rY(o[e.n-1]);return t?{...e,question:t}:{...e}}):o?iY(r,o):null}function oY(e){return e.map((t,n)=>aY(e,n))}function sY(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function cY(e){for(let t=e.length-1;t>=0;t--){if(e[t].role===`assistant`)return!0;if(sY(e[t]))return!1}return!1}function lY(e,t){let n=Date.parse(t),r=e.length-1;if(!Number.isFinite(n))return r;for(let t=0;t<e.length;t++){let r=e[t];if(!sY(r))continue;let i=r.at?Date.parse(r.at):NaN;if(!(!Number.isFinite(i)||i<=n))return t-1}return r}function uY(e,t,n={}){if(n.atRest&&t.length>0&&cY(e))return new Map([[e.length-1,[...t]]]);let r=new Map;for(let n of t){let t=lY(e,n.askedAt),i=r.get(t);i?i.push(n):r.set(t,[n])}return r}function dY(e,t){for(let n=t;n>=0;n--)if(fY(e[n]))return n+1;return 0}function fY(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function pY(e,t){let n=new Map;for(let[r,i]of uY(e,t))for(let t=dY(e,r);t<e.length;t++){if(fY(e[t]))continue;let r=n.get(t);r?r.push(...i):n.set(t,[...i])}return n}var mY=12;function hY(e){return e.replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[*_~`]/g,``).replace(/\s+/g,` `).trim().toLowerCase()}function gY(e){let t=e.indexOf(`?`);return t===-1?void 0:e.slice(0,t+1)}function _Y(e,t){if(t.length===0)return!1;let n=hY(yJ(e,`question`).contextMd);if(n.length<mY)return!1;let r=gY(n);return t.some(({spec:e})=>{let t=hY(e.question);if(t.length<mY)return!1;if(n.includes(t)||t.startsWith(n))return!0;let i=gY(t);return i!==void 0&&i.length>=mY&&n.includes(i)?!0:r!==void 0&&r.length>=mY&&t.includes(r)})}function vY(e,t){if(t.length===0||!e.includes("```question"))return!1;let n=oJ(e).filter(e=>e.kind===`question`);return n.length>0&&n.every(e=>e.kind===`question`&&yY(e,t)!==void 0)}function yY(e,t){return e.registeredId?t.find(t=>t.id.toLowerCase()===e.registeredId):t.find(t=>_Y(e.text,[t]))}function bY(e){return e.includes("```question")?oJ(e).flatMap(e=>e.kind===`question`&&e.registeredId&&e.text.trim()===``?[e.registeredId]:[]):[]}function xY(e,t){let n=new Map,r=new Set;if(t.length===0)return{placed:n,placedIds:r};let i=new Map,a=t=>{let n=i.get(t);if(n===void 0){let r=e[t];n=r.role===`assistant`&&r.text?bY(r.text):[],i.set(t,n)}return n};for(let[i,o]of uY(e,t))for(let t of o){let o=t.id.toLowerCase(),s=-1;for(let t=dY(e,i);t<e.length;t++)fY(e[t])||a(t).includes(o)&&(s=t);if(s<0)continue;let c=n.get(s);c?c.push(t):n.set(s,[t]),r.add(t.id)}return{placed:n,placedIds:r}}function SY({h:e=14}){return(0,L.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0`,style:{height:e}})}function CY({icon:e,children:t,sourceId:n,ariaLabel:r,marker:i,at:a,onClick:o,ariaExpanded:s,ariaControls:c}){let l=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`h-px flex-1 bg-border/70 transition-colors group-hover/wake:bg-border`}),(0,L.jsxs)(`span`,{className:`petite-caps flex min-w-0 items-center gap-1 break-words text-center text-[12px] text-muted/70 transition-colors group-hover/wake:text-fg`,children:[e&&(0,L.jsx)(e,{"aria-hidden":`true`,size:12,className:TY}),t,(0,L.jsx)(wY,{at:a})]}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`h-px flex-1 bg-border/70 transition-colors group-hover/wake:bg-border`})]});return o?(0,L.jsx)(`button`,{type:`button`,"data-wake-divider":i,onClick:o,onMouseDown:e=>e.preventDefault(),"aria-label":r,"aria-expanded":s,"aria-controls":c,className:`group/wake my-1 flex w-full items-center gap-3 rounded-sm text-left outline-none focus-visible:ring-1 focus-visible:ring-fg/60`,children:l}):(0,L.jsx)(`div`,{"data-frizz-msg":n,"data-wake-divider":i,className:`my-1 flex items-center gap-3`,role:r?`separator`:void 0,"aria-label":r,children:l})}function wY({at:e}){let t=mE(e,TE());return t?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,L.jsx)(`span`,{title:hE(e)??void 0,className:`shrink-0 tabular-nums`,children:t})]}):null}var TY=`shrink-0 translate-y-[0.04em]`;function EY(e,t,n){return e===1?n?`New ${t} from @${n}`:`New ${t}`:`${e} new items`}var DY=`rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`;function OY({steer:e,text:t,sourceId:n,at:r,wrap:i}){let a=Ol(t);if(a)return(0,L.jsx)(IY,{wake:a,sourceId:n,at:r});let o=Al(t);if(o)return(0,L.jsx)(AY,{wake:o,sourceId:n});let s=Pl(t);if(s)return(0,L.jsx)(PY,{window:s.window,sourceId:n,at:r});let c=Ml(t);if(c)return(0,L.jsx)(FY,{capped:c.capped,to:c.to,sourceId:n,at:r});let l=Rl(t);if(l)return(0,L.jsx)(MY,{wake:l,sourceId:n,at:r});let u=Bl(t);if(u)return(0,L.jsx)(NY,{watchRef:u.ref,sourceId:n,at:r});let d=iu(t);if(d)return(0,L.jsx)(jY,{count:d.count,sourceId:n,at:r});let f=Yu(t),p=qu(t),m=e??Hu(f||p?t.split(`
302
302
  `).filter(e=>!Yu(e)&&!qu(e)).join(`
303
- `):t);return!m&&!f&&!p?(0,L.jsx)(`div`,{"data-frizz-msg":n,"data-frizz-wake":!0,className:`min-w-0 max-w-[85%]`,children:(0,L.jsx)(PJ,{icon:pm,label:`Frizz`,children:(0,L.jsx)(DY,{text:Eu(t),wrap:i})})}):f||p?(0,L.jsxs)(`div`,{"data-frizz-wake":!0,className:`flex flex-col`,children:[f&&(0,L.jsx)(FY,{wake:f,sourceId:n,at:r}),p&&(0,L.jsxs)(L.Fragment,{children:[f&&(0,L.jsx)(bY,{}),(0,L.jsx)(IY,{wake:p,sourceId:f?void 0:n,at:r})]}),m&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(bY,{}),(0,L.jsx)(LY,{steer:m,text:t,at:r})]})]}):(0,L.jsx)(LY,{steer:m,text:t,sourceId:n,at:r})}function DY({text:e,wrap:t}){let n=Nq(JK(e));return(0,L.jsx)(`div`,{className:`md-body [overflow-wrap:anywhere]${t?` ${EJ}`:``}`,dangerouslySetInnerHTML:n})}function OY({wake:e,sourceId:t}){let[n,r]=(0,I.useState)(!1),i=(0,I.useId)();return(0,L.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,L.jsxs)(xY,{icon:lm,marker:`timer`,at:e.at,onClick:()=>r(e=>!e),ariaExpanded:n,ariaControls:i,ariaLabel:`${n?`Collapse`:`Expand`} the text this timer handed back`,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:`Timer`}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,L.jsx)(`span`,{className:`shrink-0`,children:n?`Click to collapse`:`Click to expand`})]}),n&&(0,L.jsx)(`div`,{id:i,className:`mt-1.5 whitespace-pre-wrap border-l border-border/70 pl-3 text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.prompt})]})}function kY({count:e,sourceId:t,at:n}){let r=`${e} question${e===1?``:`s`} cancelled — the worker decides ${e===1?`it`:`them`} itself`;return(0,L.jsx)(xY,{icon:Qm,sourceId:t,marker:`event`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function AY({wake:e,sourceId:t,at:n}){let[r,i]=(0,I.useState)(!1),a=(0,I.useId)(),o=e.kind===`expired`?`Wait expired — nothing resolved`:`Wait over — its work finished`;return e.items.length?(0,L.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,L.jsxs)(xY,{icon:Um,marker:`event`,at:n,onClick:()=>i(e=>!e),ariaExpanded:r,ariaControls:a,ariaLabel:`${r?`Collapse`:`Expand`} what this wait named`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:o}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,L.jsx)(`span`,{className:`shrink-0`,children:r?`Click to collapse`:`Click to expand`})]}),r&&(0,L.jsx)(`div`,{id:a,className:`mt-1.5 whitespace-pre-wrap border-l border-border/70 pl-3 text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.items.join(`
304
- `)})]}):(0,L.jsx)(xY,{icon:Um,sourceId:t,marker:`event`,ariaLabel:o,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:o})})}function jY({watchRef:e,sourceId:t,at:n}){let r=aU(e);return(0,L.jsx)(xY,{icon:Hm,sourceId:t,marker:`event`,ariaLabel:`Watcher on ${e} expired`,at:n,children:(0,L.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Watcher on`,` `,r?(0,L.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:TY,children:e}):e,` `,`expired`]})})}function MY({window:e,sourceId:t,at:n}){let r=`${e===`weekly`?`Weekly usage limit`:e===`session`?`Session usage limit`:`Usage limit`} reset — resuming`;return(0,L.jsx)(xY,{icon:Um,sourceId:t,marker:`limit-resume`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function NY({capped:e,to:t,sourceId:n,at:r}){let i=`${e} limit — switched to ${t}`;return(0,L.jsx)(xY,{icon:Um,sourceId:n,marker:`limit-model-switch`,ariaLabel:i,at:r,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:i})})}function PY({wake:e,sourceId:t,at:n}){let r=`Background task «${e.label.length>64?`${e.label.slice(0,63)}…`:e.label}» ${e.outcome}`;return(0,L.jsx)(xY,{icon:vh,sourceId:t,marker:`event`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function FY({wake:e,sourceId:t,at:n}){let r=aU(e.ref),i=r?(0,L.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:TY,children:e.ref}):(0,L.jsx)(`span`,{children:e.ref}),a=e.kind===`ci`?e.verdict===`passing`?`passed`:e.verdict===`failing`?`failed`:`awaiting approval`:``,o=e.kind===`ci`?`CI ${a} on `:`PR ${e.kind} on `,s=e.kind===`ci`?e.verdict===`failing`&&e.failing.length?`: ${e.failing.join(`, `)}`:e.verdict===`gated`&&e.gating.length?`: ${e.gating.join(`, `)}`:``:``,c=e.kind===`ci`?e.verdict===`passing`&&e.passed!==void 0?`${e.passed} ${e.passed===1?`check`:`checks`} green${e.skipped?`, ${e.skipped} skipped`:``}`:e.verdict===`gated`?`${e.gated} ${e.gated===1?`workflow`:`workflows`} held`:null:null;return(0,L.jsxs)(xY,{icon:Hm,sourceId:t,marker:`github`,at:n,ariaLabel:r?void 0:`${o}${e.ref}${s}${c?` · ${c}`:``}`,children:[(0,L.jsxs)(`span`,{className:`min-w-0 truncate`,children:[o,i,s]}),c&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,L.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:c})]})]})}function IY({wake:e,sourceId:t,at:n}){let r=aU(e.ref),i=r?(0,L.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:TY,children:e.ref}):(0,L.jsx)(`span`,{children:e.ref});return(0,L.jsx)(xY,{icon:Hm,sourceId:t,marker:`github`,at:n,ariaLabel:r?void 0:`PR updated on ${e.ref}: ${e.detail}`,children:(0,L.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`PR updated on `,i,`: ${e.detail}`]})})}function LY({steer:e,text:t,sourceId:n,at:r}){let i=aU(e.ref),a=e.items.length+e.omitted,o=Iu(t),s=!o&&e.items.length===1&&e.omitted===0?e.items[0]:null,c=s?.url??i,l=o?`${a} ${a===1?`item`:`items`} already`:wY(a,e.items[0]?.label??`item`,s?.actor),u=c?(0,L.jsx)(`a`,{href:c,target:`_blank`,rel:`noreferrer noopener`,className:TY,children:e.ref}):(0,L.jsx)(`span`,{children:e.ref});return(0,L.jsx)(xY,{icon:Hm,sourceId:n,marker:`github`,at:s?.at??r,ariaLabel:c?void 0:`${l} on ${e.ref}`,children:(0,L.jsxs)(`span`,{className:`min-w-0 truncate`,children:[l,` on `,u]})})}function RY({bump:e,sourceId:t,at:n}){let r=e.kind===`schedule`;if(e.kind===`signoff`){let e=`Frizz asked for a sign-off`;return(0,L.jsx)(xY,{icon:hh,sourceId:t,marker:`rest`,ariaLabel:e,at:n,children:e})}let i=r?`Goal${e.every?` · every ${e.every}`:``}`:`Goal · at rest`;return(0,L.jsx)(xY,{icon:r?bh:uh,sourceId:t,marker:r?`schedule`:`rest`,ariaLabel:i,at:n,children:i})}var zY=/(^|[^\w/.@-])(https?:\/\/[^\s<>`]+|www\.[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:[^\s<>`]*)?)/gi,BY=new Set([`.`,`,`,`:`,`;`,`!`,`?`,`*`,`_`,`~`,`'`,`"`]),VY={")":`(`,"]":`[`,"}":`{`};function HY(e){let t=e;for(;;){let e=t[t.length-1];if(e!==void 0&&BY.has(e)){t=t.slice(0,-1);continue}let n=e===void 0?void 0:VY[e];if(n){let r=0;for(let i of t)i===n?r++:i===e&&r--;if(r<0){t=t.slice(0,-1);continue}}break}return t}function UY(e,t){if(t===``)return;let n=0;for(let r of ef(t))r.start>n&&e.push({kind:`text`,text:t.slice(n,r.start)}),e.push({kind:`link`,text:r.text,href:r.href,title:r.title,ghRef:Yd(r.href)}),n=r.start+r.text.length;n<t.length&&e.push({kind:`text`,text:t.slice(n)})}function WY(e){let t=[],n=0;zY.lastIndex=0;for(let r=zY.exec(e);r;r=zY.exec(e)){let[,i,a]=r,o=HY(a);if(/^https?:\/\/$/i.test(o)||o===``)continue;let s=r.index+i.length;zY.lastIndex=s+o.length;let c=/^www\./i.test(o)?`http://${o}`:o;s>n&&UY(t,e.slice(n,s)),t.push({kind:`link`,text:o,href:c,ghRef:Yd(c)}),n=s+o.length}return n<e.length&&UY(t,e.slice(n)),t}function GY({text:e}){let t=(0,I.useMemo)(()=>WY(e),[e,KK()]),n=(0,I.useMemo)(()=>t.flatMap(e=>e.kind===`link`&&e.ghRef?[e.ghRef]:[]),[t]);return(0,I.useEffect)(()=>{n.length>0&&jf(n)},[n]),(0,L.jsx)(L.Fragment,{children:t.map((e,t)=>e.kind===`text`?e.text:(0,L.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,title:e.title,"data-gh-ref":e.ghRef??void 0,className:`underline underline-offset-2`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:e.text},t))})}function KY({answers:e,queued:t,sourceId:n}){return(0,L.jsx)(`div`,{"data-frizz-msg":n,"data-answers-card":!0,className:`self-end flex w-full max-w-[85%] flex-col items-end ${t?`opacity-50`:``}`,children:(0,L.jsxs)(`div`,{className:`w-full min-w-0 ${DJ} rounded-br-sm border border-border-strong bg-elevated p-4`,children:[(0,L.jsx)(MJ,{icon:Ym,label:`Answers`}),(0,L.jsx)(NJ,{children:(0,L.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:e.map((e,t)=>(0,L.jsxs)(`div`,{className:e.followUp?`ml-3 flex flex-col gap-1 border-l border-border pl-3`:`flex flex-col gap-1`,children:[e.question&&(0,L.jsx)(`div`,{title:e.question,className:`line-clamp-2 min-w-0 text-[11px] leading-snug text-muted`,children:e.question}),(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[!e.question&&(0,L.jsx)(`span`,{className:`mt-1.5 shrink-0 text-[10px] uppercase tabular-nums tracking-wide text-muted/70`,children:e.n}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap [overflow-wrap:anywhere] rounded-md border border-border-strong border-l-2 border-l-accent/40 bg-bg/50 px-2.5 py-1.5 text-[12px] leading-snug text-fg`,children:(0,L.jsx)(GY,{text:e.answer})})]})]},t))})})]})})}function qY(e){return e.sourceId??`legacy-${rX(e.text)}`}function JY(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.kind===`event`||n.kind===`reasoning`)&&n.role===`assistant`&&n.text.trim())return t}return-1}var YY=e=>iJ(e).filter(e=>e.kind===`question`).map(e=>e.kind===`question`?_J(e.text,e.questionKind,e.danger):_J(``,`question`));function XY(){let e=new Set;return(t,n)=>{let r=qY(t);return e.has(r)&&(r=`${r}#${n}`),e.add(r),r}}function ZY(e){let t=JY(e),n=XY(),r=[];for(let i=0;i<e.length;i++){let a=e[i];if(a.kind===`event`||a.kind===`reasoning`||a.role!==`assistant`||!a.text.trim()||!a.text.includes("```question"))continue;let o=YY(a.text);o.length>0&&r.push({idx:i,identity:n(a,i),blocks:o,isLive:i===t})}return r}function QY(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.kind===`event`||n.kind===`reasoning`)){if(n.role===`user`&&n.text.trim())break;if(!(n.role!==`assistant`||!n.text.trim())&&YY(n.text).length>0)return t}}return-1}function $Y(e){let{answered:t,live:n}=e;return t.length>0&&t.every(e=>e.isLive)&&n?`Answers:\n${n.numbered.map(({n:e,a:t})=>`${e}. ${t}`).join(`
303
+ `):t);return!m&&!f&&!p?(0,L.jsx)(`div`,{"data-frizz-msg":n,"data-frizz-wake":!0,className:`min-w-0 max-w-[85%]`,children:(0,L.jsx)(IJ,{icon:pm,label:`Frizz`,children:(0,L.jsx)(kY,{text:Eu(t),wrap:i})})}):f||p?(0,L.jsxs)(`div`,{"data-frizz-wake":!0,className:`flex flex-col`,children:[f&&(0,L.jsx)(LY,{wake:f,sourceId:n,at:r}),p&&(0,L.jsxs)(L.Fragment,{children:[f&&(0,L.jsx)(SY,{}),(0,L.jsx)(RY,{wake:p,sourceId:f?void 0:n,at:r})]}),m&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(SY,{}),(0,L.jsx)(zY,{steer:m,text:t,at:r})]})]}):(0,L.jsx)(zY,{steer:m,text:t,sourceId:n,at:r})}function kY({text:e,wrap:t}){let n=Fq(XK(e));return(0,L.jsx)(`div`,{className:`md-body [overflow-wrap:anywhere]${t?` ${OJ}`:``}`,dangerouslySetInnerHTML:n})}function AY({wake:e,sourceId:t}){let[n,r]=(0,I.useState)(!1),i=(0,I.useId)();return(0,L.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,L.jsxs)(CY,{icon:lm,marker:`timer`,at:e.at,onClick:()=>r(e=>!e),ariaExpanded:n,ariaControls:i,ariaLabel:`${n?`Collapse`:`Expand`} the text this timer handed back`,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:`Timer`}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,L.jsx)(`span`,{className:`shrink-0`,children:n?`Click to collapse`:`Click to expand`})]}),n&&(0,L.jsx)(`div`,{id:i,className:`mt-1.5 whitespace-pre-wrap border-l border-border/70 pl-3 text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.prompt})]})}function jY({count:e,sourceId:t,at:n}){let r=`${e} question${e===1?``:`s`} cancelled — the worker decides ${e===1?`it`:`them`} itself`;return(0,L.jsx)(CY,{icon:Qm,sourceId:t,marker:`event`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function MY({wake:e,sourceId:t,at:n}){let[r,i]=(0,I.useState)(!1),a=(0,I.useId)(),o=e.kind===`expired`?`Wait expired — nothing resolved`:`Wait over — its work finished`;return e.items.length?(0,L.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,L.jsxs)(CY,{icon:Um,marker:`event`,at:n,onClick:()=>i(e=>!e),ariaExpanded:r,ariaControls:a,ariaLabel:`${r?`Collapse`:`Expand`} what this wait named`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:o}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,L.jsx)(`span`,{className:`shrink-0`,children:r?`Click to collapse`:`Click to expand`})]}),r&&(0,L.jsx)(`div`,{id:a,className:`mt-1.5 whitespace-pre-wrap border-l border-border/70 pl-3 text-[13px] text-muted [overflow-wrap:anywhere]`,children:e.items.join(`
304
+ `)})]}):(0,L.jsx)(CY,{icon:Um,sourceId:t,marker:`event`,ariaLabel:o,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:o})})}function NY({watchRef:e,sourceId:t,at:n}){let r=sU(e);return(0,L.jsx)(CY,{icon:Hm,sourceId:t,marker:`event`,ariaLabel:`Watcher on ${e} expired`,at:n,children:(0,L.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Watcher on`,` `,r?(0,L.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:DY,children:e}):e,` `,`expired`]})})}function PY({window:e,sourceId:t,at:n}){let r=`${e===`weekly`?`Weekly usage limit`:e===`session`?`Session usage limit`:`Usage limit`} reset — resuming`;return(0,L.jsx)(CY,{icon:Um,sourceId:t,marker:`limit-resume`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function FY({capped:e,to:t,sourceId:n,at:r}){let i=`${e} limit — switched to ${t}`;return(0,L.jsx)(CY,{icon:Um,sourceId:n,marker:`limit-model-switch`,ariaLabel:i,at:r,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:i})})}function IY({wake:e,sourceId:t,at:n}){let r=`Background task «${e.label.length>64?`${e.label.slice(0,63)}…`:e.label}» ${e.outcome}`;return(0,L.jsx)(CY,{icon:vh,sourceId:t,marker:`event`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function LY({wake:e,sourceId:t,at:n}){let r=sU(e.ref),i=r?(0,L.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:DY,children:e.ref}):(0,L.jsx)(`span`,{children:e.ref}),a=e.kind===`ci`?e.verdict===`passing`?`passed`:e.verdict===`failing`?`failed`:`awaiting approval`:``,o=e.kind===`ci`?`CI ${a} on `:`PR ${e.kind} on `,s=e.kind===`ci`?e.verdict===`failing`&&e.failing.length?`: ${e.failing.join(`, `)}`:e.verdict===`gated`&&e.gating.length?`: ${e.gating.join(`, `)}`:``:``,c=e.kind===`ci`?e.verdict===`passing`&&e.passed!==void 0?`${e.passed} ${e.passed===1?`check`:`checks`} green${e.skipped?`, ${e.skipped} skipped`:``}`:e.verdict===`gated`?`${e.gated} ${e.gated===1?`workflow`:`workflows`} held`:null:null;return(0,L.jsxs)(CY,{icon:Hm,sourceId:t,marker:`github`,at:n,ariaLabel:r?void 0:`${o}${e.ref}${s}${c?` · ${c}`:``}`,children:[(0,L.jsxs)(`span`,{className:`min-w-0 truncate`,children:[o,i,s]}),c&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,L.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:c})]})]})}function RY({wake:e,sourceId:t,at:n}){let r=sU(e.ref),i=r?(0,L.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:DY,children:e.ref}):(0,L.jsx)(`span`,{children:e.ref});return(0,L.jsx)(CY,{icon:Hm,sourceId:t,marker:`github`,at:n,ariaLabel:r?void 0:`PR updated on ${e.ref}: ${e.detail}`,children:(0,L.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`PR updated on `,i,`: ${e.detail}`]})})}function zY({steer:e,text:t,sourceId:n,at:r}){let i=sU(e.ref),a=e.items.length+e.omitted,o=Iu(t),s=!o&&e.items.length===1&&e.omitted===0?e.items[0]:null,c=s?.url??i,l=o?`${a} ${a===1?`item`:`items`} already`:EY(a,e.items[0]?.label??`item`,s?.actor),u=c?(0,L.jsx)(`a`,{href:c,target:`_blank`,rel:`noreferrer noopener`,className:DY,children:e.ref}):(0,L.jsx)(`span`,{children:e.ref});return(0,L.jsx)(CY,{icon:Hm,sourceId:n,marker:`github`,at:s?.at??r,ariaLabel:c?void 0:`${l} on ${e.ref}`,children:(0,L.jsxs)(`span`,{className:`min-w-0 truncate`,children:[l,` on `,u]})})}function BY({bump:e,sourceId:t,at:n}){let r=e.kind===`schedule`;if(e.kind===`signoff`){let e=`Frizz asked for a sign-off`;return(0,L.jsx)(CY,{icon:hh,sourceId:t,marker:`rest`,ariaLabel:e,at:n,children:e})}let i=r?`Goal${e.every?` · every ${e.every}`:``}`:`Goal · at rest`;return(0,L.jsx)(CY,{icon:r?bh:uh,sourceId:t,marker:r?`schedule`:`rest`,ariaLabel:i,at:n,children:i})}var VY=/(^|[^\w/.@-])(https?:\/\/[^\s<>`]+|www\.[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:[^\s<>`]*)?)/gi,HY=new Set([`.`,`,`,`:`,`;`,`!`,`?`,`*`,`_`,`~`,`'`,`"`]),UY={")":`(`,"]":`[`,"}":`{`};function WY(e){let t=e;for(;;){let e=t[t.length-1];if(e!==void 0&&HY.has(e)){t=t.slice(0,-1);continue}let n=e===void 0?void 0:UY[e];if(n){let r=0;for(let i of t)i===n?r++:i===e&&r--;if(r<0){t=t.slice(0,-1);continue}}break}return t}function GY(e,t){if(t===``)return;let n=0;for(let r of ef(t))r.start>n&&e.push({kind:`text`,text:t.slice(n,r.start)}),e.push({kind:`link`,text:r.text,href:r.href,title:r.title,ghRef:Yd(r.href)}),n=r.start+r.text.length;n<t.length&&e.push({kind:`text`,text:t.slice(n)})}function KY(e){let t=[],n=0;VY.lastIndex=0;for(let r=VY.exec(e);r;r=VY.exec(e)){let[,i,a]=r,o=WY(a);if(/^https?:\/\/$/i.test(o)||o===``)continue;let s=r.index+i.length;VY.lastIndex=s+o.length;let c=/^www\./i.test(o)?`http://${o}`:o;s>n&&GY(t,e.slice(n,s)),t.push({kind:`link`,text:o,href:c,ghRef:Yd(c)}),n=s+o.length}return n<e.length&&GY(t,e.slice(n)),t}function qY({text:e}){let t=(0,I.useMemo)(()=>KY(e),[e,JK()]),n=(0,I.useMemo)(()=>t.flatMap(e=>e.kind===`link`&&e.ghRef?[e.ghRef]:[]),[t]);return(0,I.useEffect)(()=>{n.length>0&&jf(n)},[n]),(0,L.jsx)(L.Fragment,{children:t.map((e,t)=>e.kind===`text`?e.text:(0,L.jsx)(`a`,{href:e.href,target:`_blank`,rel:`noopener noreferrer`,title:e.title,"data-gh-ref":e.ghRef??void 0,className:`underline underline-offset-2`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:e.text},t))})}function JY({answers:e,queued:t,sourceId:n}){return(0,L.jsx)(`div`,{"data-frizz-msg":n,"data-answers-card":!0,className:`self-end flex w-full max-w-[85%] flex-col items-end ${t?`opacity-50`:``}`,children:(0,L.jsxs)(`div`,{className:`w-full min-w-0 ${kJ} rounded-br-sm border border-border-strong bg-elevated p-4`,children:[(0,L.jsx)(PJ,{icon:Ym,label:`Answers`}),(0,L.jsx)(FJ,{children:(0,L.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:e.map((e,t)=>(0,L.jsxs)(`div`,{className:e.followUp?`ml-3 flex flex-col gap-1 border-l border-border pl-3`:`flex flex-col gap-1`,children:[e.question&&(0,L.jsx)(`div`,{title:e.question,className:`line-clamp-2 min-w-0 text-[11px] leading-snug text-muted`,children:e.question}),(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[!e.question&&(0,L.jsx)(`span`,{className:`mt-1.5 shrink-0 text-[10px] uppercase tabular-nums tracking-wide text-muted/70`,children:e.n}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap [overflow-wrap:anywhere] rounded-md border border-border-strong border-l-2 border-l-accent/40 bg-bg/50 px-2.5 py-1.5 text-[12px] leading-snug text-fg`,children:(0,L.jsx)(qY,{text:e.answer})})]})]},t))})})]})})}function YY(e){return e.sourceId??`legacy-${aX(e.text)}`}function XY(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.kind===`event`||n.kind===`reasoning`)&&n.role===`assistant`&&n.text.trim())return t}return-1}var ZY=e=>oJ(e).filter(e=>e.kind===`question`).map(e=>e.kind===`question`?yJ(e.text,e.questionKind,e.danger):yJ(``,`question`));function QY(){let e=new Set;return(t,n)=>{let r=YY(t);return e.has(r)&&(r=`${r}#${n}`),e.add(r),r}}function $Y(e){let t=XY(e),n=QY(),r=[];for(let i=0;i<e.length;i++){let a=e[i];if(a.kind===`event`||a.kind===`reasoning`||a.role!==`assistant`||!a.text.trim()||!a.text.includes("```question"))continue;let o=ZY(a.text);o.length>0&&r.push({idx:i,identity:n(a,i),blocks:o,isLive:i===t})}return r}function eX(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.kind===`event`||n.kind===`reasoning`)){if(n.role===`user`&&n.text.trim())break;if(!(n.role!==`assistant`||!n.text.trim())&&ZY(n.text).length>0)return t}}return-1}function tX(e){let{answered:t,live:n}=e;return t.length>0&&t.every(e=>e.isLive)&&n?`Answers:\n${n.numbered.map(({n:e,a:t})=>`${e}. ${t}`).join(`
305
305
  `)}`:`${nu}\n${t.map((e,t)=>`${t+1}. “${e.question}” → ${e.answer}`).join(`
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
- `).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
- `).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 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
- `).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(`
306
+ `)}`}function nX(e,t,n,r={}){let i=aU(e),[a,o]=(0,I.useState)({}),s=(0,I.useMemo)(()=>$Y(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)(()=>eX(t)!==-1,[t]),u=Oz(),d=kz(e),f=(0,I.useCallback)((t,n)=>Dz.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=jz(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];Tz.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)=>CJ(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)=>CJ(e.blocks[t],_(e.identity,t)),l=n.flatMap(e=>e.blocks.map((t,n)=>({ask:e,bi:n,question:iX(t),answer:c(e,n)})).filter(e=>e.answer!==``));if(l.length===0)return;let u=n.find(e=>e.isLive),d=tX({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,Tz.get(e)]);C(d,{onOptimistic:()=>{r.forEach(e=>Tz.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&&!Tz.get(e)&&Tz.set(e,t)})}})},[a,s,_,C,p,f]),T=(0,I.useCallback)(e=>{let t=v.get(YY(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)=>CJ(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 rX(e){let t=e.split(`
307
+ `).map(e=>e.trim()).find(e=>e.length>0)??``;return t.length>120?`${t.slice(0,117)}…`:t}function iX(e){return rX(e.contextMd)||rX(e.options.join(` / `))||`earlier question`}function aX(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 oX({raw:e,question:t,questionKind:n,danger:r,interactive:i,wrap:a,aside:o,label:s,settled:c}){let l=(0,I.useMemo)(()=>t??yJ(e??``,n??`question`,r),[t,e,n,r]),u=XK(l.contextMd),d=XK(l.trailingMd??``),f=l.recommendedIdx,p=QK(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)(IJ,{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)(Yq,{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||nR({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)(sX,{md:l.optionHeadings[t],wrap:a}),(0,L.jsx)(lX,{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}nR({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?`${cX(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)(Yq,{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)(Yq,{className:`md-inline mt-1.5 text-[11px] text-muted/70`,html:p})]})}function sX({md:e,wrap:t}){let n=QK(e.split(`
308
+ `).join(` `));return(0,L.jsx)(`div`,{className:`mt-1 text-fg`,children:(0,L.jsx)(Yq,{className:`md-body${t?` ${OJ}`:``}`,html:n})})}function cX(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 lX({label:e,bodyMd:t,wrap:n,selected:r,settledPick:i,disabled:a,multi:o,recommended:s,recTitle:c,onClick:l}){let u=QK(e),d=XK(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)(Yq,{as:`span`,className:`md-inline`,html:u})]}),t!==void 0&&(0,L.jsx)(Yq,{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 uX({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)(oX,{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 dX(e){return(0,I.useSyncExternalStore)(e=>Jt(X,e),()=>e?fX(e)!==`codex`:!1,()=>!1)}function fX(e){return Gp(X.board,e)?.backend}function pX(e,t,n,r){let i=Dz.followUp(e,t,n),a=Tz.get(i),o=a?`${r}\n\n${a}`:r;return Tz.set(i,o),i}function mX(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 hX(e){let t=Ve(),n=Oz(),[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),pX(n,e,o,a.text),mX(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 gX(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 _X(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 vX(e){return e.displayText??e.text}function yX(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 bX(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&&!$J(n)))return t}return 0}function xX(e,t){if(e.kind===`event`||e.kind===`reasoning`||e.role!==`user`)return!1;let n=vX(e).replace(/\r\n?/g,`
309
+ `);return(t===void 0?ZJ(n):t)?!0:!(e.wake||e.peerFrom)}function SX(e,t){return xX(e,t)?`bubble`:`prose`}var CX=`icon-label-nudge`,wX=new Set([`planning`,`planned`,`active`,`needs-human`,`blocked`]);function TX(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&&wX.has(e.status))}function EX(e,t){let n=e.trim();if(!(!n||n===t.trim()))return n}function DX(e,t){let n=e.trim();return!n||n===t||n===`Untitled thread`||n===`Spinning up a thread…`?``:n}function OX(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 kX=`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`,AX=`min-w-0 flex-1 pl-1 max-[640px]:basis-full`,jX=`flex shrink-0 items-center max-[640px]:w-full max-[640px]:justify-between`;function MX(e){return e?.trim()?{kind:`profile-error`,message:`Profile controls unavailable: ${e.trim().slice(0,160)}`}:null}function NX(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 PX(e){return e.permissionChangePending===!0||e.permissionPending!==void 0||e.profileChangePending===!0||e.runtimeControlPending===!0}function FX(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 IX(e){return e===`right`?`pl-3 pr-7`:`pl-7 pr-3`}function LX(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 RX=`__frizz_empty_select_value__`,zX=e=>e===``?RX:e,BX=e=>e===RX?``:e,VX={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`},HX={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 UX({o:e,indicatorPosition:t,typography:n}){return(0,L.jsxs)(BI,{value:zX(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 ${IX(t)} ${n??``}`,children:[(0,L.jsx)(VI,{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 WX({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=LX(e,n,r,i),p=s?HX[c]:VX[c],m=c===`readout`?xR:``,[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)(MI,{modal:!1,open:h,onOpenChange:e=>{y.current?.(),y.current=void 0,_.current=e,g(e),e&&(y.current=zR(()=>{_.current=!1,y.current=void 0,g(!1)}))},children:[(0,L.jsx)(NI,{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)(PI,{children:(0,L.jsx)(FI,{align:`start`,side:u,sideOffset:5,onEscapeKeyDown:e=>e.stopPropagation(),className:`${eM} min-w-[var(--radix-dropdown-menu-trigger-width)] max-w-[calc(100vw-1rem)] overflow-hidden rounded-lg p-1 ${m}`,children:(0,L.jsx)(zI,{value:zX(e),onValueChange:e=>t(BX(e)),className:`max-h-[300px] min-w-0 overflow-y-auto`,children:r?r.map((e,t)=>(0,L.jsxs)(II,{children:[e.label&&(0,L.jsx)(LI,{className:`${IX(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)(UX,{o:e,indicatorPosition:l,typography:m},e.value))]},e.label||`g${t}`)):(n??[]).map(e=>(0,L.jsx)(UX,{o:e,indicatorPosition:l,typography:m},e.value))})})})]})}function GX(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 KX(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||PX(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}=GX(p,s,c,t.runtime===`exited`),h=n.data!==void 0,g=[{id:l,label:l===`codex`?`Codex`:`Claude Code`,options:p}],_=MX(n.isError?n.error.message:void 0),v=t.permissionMode?rz(t.permissionMode):`auto`,y=tz.some(e=>e.value===v)?v:`auto`,b=i.isPending?i.variables:y,x=NX(t);function S(e){e!==y&&i.mutate(e,{onSuccess:e=>Z(FX(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)(UR,{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)(WX,{variant:`readout`,side:`top`,value:b,onValueChange:e=>S(e),options:tz,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 qX=new Map;function JX(e){let t=qX.get(e);if(t)return t;let n=Y.threadSkills({slug:e}).then(e=>e.skills,()=>(qX.delete(e),[]));return qX.set(e,n),n}function YX({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=Oz(),u=Dz.followUp(l,e,c?.sessionId),[d,f,p]=Az(u),m=KX(e),h=aU(e),[g,_]=(0,I.useState)(null),v=(0,I.useMemo)(()=>()=>JX(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}=FL(d),r=t.filter(e=>VL(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=JR(n);if(r){p();let e=c?.backend===`codex`?`codex`:`claude`;r===`login`?_(e):b(e);return}let i=Pp(e),a=XL(n,i,l),s={onOptimistic:p,onRollback:()=>{Tz.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)(gR,{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)(XR,{backend:g,onClose:()=>_(null),onAuthed:()=>_(null)}),y&&(0,L.jsx)(ZR,{backend:y,onClose:()=>b(null)})]})}function XX({slug:e,ops:t}){let n=Zt(X).board?.threads.find(t=>t.id===e);return n?(0,L.jsx)(YX,{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 ZX({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)(iM,{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:xD,children:(0,L.jsx)(sh,{size:14,strokeWidth:2})})})}function QX(e,t){return new Promise(n=>{iU(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 $X(){return cH(vH().data??null)}function eZ({thread:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return!$X()||e.kind!==`session`||e.foreign||e.backend===`codex`||e.runtime===`exited`?null:(0,L.jsx)(iM,{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),QX(t,e.id).finally(()=>r(!1))},className:`${xD} mx-[2px]`,children:n?(0,L.jsx)(Xm,{size:14,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(lh,{size:14,strokeWidth:2})})})}function tZ({slug:e,label:t=`Exit fullscreen`}){let n=bD(e)??hw(`/`);function r(e){zd(e)&&(e.preventDefault(),bw(n,{viewTransition:!Xp()}))}return(0,L.jsx)(iM,{label:t,children:(0,L.jsx)(`a`,{href:n,"aria-label":t,"data-standalone-return":!0,onMouseDown:e=>e.preventDefault(),onClick:r,className:xD,children:(0,L.jsx)(th,{size:14})})})}function nZ({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)(iZ,{label:o?`Expand`:`Collapse`,icon:o?xm:bm,size:13,onClick:a}),(0,L.jsx)(ZX,{thread:e}),(0,L.jsx)(eZ,{thread:e}),r&&(0,L.jsx)(iZ,{label:`Frizz document`,icon:Pm,size:14,onClick:r}),t&&(0,L.jsx)(aM,{slug:e.id}),n&&(0,L.jsx)(tZ,{slug:e.id}),d?tE(e)?(0,L.jsx)(rZ,{slug:e.id}):null:(0,L.jsx)(`div`,{className:`ml-1`,children:(0,L.jsx)(JI,{slug:e.id,onDone:i,doneBusy:s,onMutateStart:c,onApplied:l,onFailed:u})})]})}function rZ({slug:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return(0,L.jsx)(iM,{label:`Retry — resume this session where it left off`,children:(0,L.jsxs)(`button`,{onClick:()=>{r(!0),oU(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 iZ({label:e,icon:t,size:n,busy:r,...i}){return(0,L.jsx)(iM,{label:e,children:(0,L.jsx)(`button`,{...i,"aria-label":e,onMouseDown:e=>e.preventDefault(),className:xD,children:r?(0,L.jsx)(Xm,{size:n,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(t,{size:n,strokeWidth:2})})})}function aZ(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 oZ(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 sZ(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=[cZ(`agent`,`sub-agent`,e.subAgents,e.subAgentCount),cZ(`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 cZ(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 lZ({open:e,onOpenChange:t,title:n,children:r,footer:i,className:a=`w-[640px] max-w-[92vw] max-h-[82vh]`}){return(0,L.jsx)(eL,{open:e,onOpenChange:t,children:(0,L.jsxs)(oL,{children:[(0,L.jsx)(cL,{className:`overlay-in fixed inset-0 z-[200] bg-black/55 backdrop-blur-[1px]`}),(0,L.jsxs)(fL,{"aria-modal":`true`,onEscapeKeyDown:VR,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)(_L,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:n}),(0,L.jsx)(xL,{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 uZ({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)(UI,{children:[(0,L.jsx)(WI,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,disabled:n,"aria-label":`Snooze options`,title:`Selected snooze: ${_}`,className:`flex min-w-0 items-center justify-center gap-1 rounded-r-md px-2 text-fg/75 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60 disabled:cursor-not-allowed disabled:opacity-45`,children:(0,L.jsx)(_m,{size:12})})}),(0,L.jsxs)(GI,{align:`end`,children:[Qw.map(e=>(0,L.jsx)(KI,{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)(qI,{}),(0,L.jsx)(KI,{onSelect:S,children:`Custom time & prompt…`}),h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(qI,{}),(0,L.jsx)(KI,{onSelect:()=>void b(null),children:`Wake now`})]})]})]})]}),(0,L.jsx)(lZ,{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=>{nR({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 dZ=1.25,fZ=7.5-dZ/2,pZ=2*Math.PI*fZ;function mZ(e,t){return Math.max(0,Math.min(100,Math.floor(e/t*100)))}function hZ({thread:e}){let t=e.context;if(!t||t.window<=0)return null;let n=mZ(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)(iM,{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:fZ,fill:`none`,stroke:`currentColor`,strokeOpacity:.3,strokeWidth:dZ}),(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:fZ,fill:`none`,stroke:`currentColor`,strokeWidth:dZ,strokeDasharray:`${pZ*r} ${pZ}`})]})})})}var gZ={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 _Z({checked:e,onChange:t,disabled:n,label:r,size:i=`sm`,testId:a}){let o=gZ[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 vZ({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 yZ({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),bZ)}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)(DV,{open:t!==`closed`,onOpenChange:e=>{e||(clearTimeout(i.current),n(`closed`))},children:[(0,L.jsx)(kV,{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 ${sR}`,children:(0,L.jsx)(vZ,{size:12,className:o?`text-amber-400/90`:`text-muted/60 hover:text-muted`})})}),t===`preview`?(0,L.jsx)(AV,{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)(xZ,{armed:a})}):(0,L.jsx)(AV,{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)(jZ,{thread:e,armed:a,close:()=>n(`closed`)})})]})}var bZ=260;function xZ({armed:e}){let t=e?.prompt?.trim(),n=e?AZ({stopHook:e.stopHook===!0,heartbeat:e.heartbeat===!0,postCompaction:e.postCompaction===!0,seconds:e.intervalSeconds??wZ}):[];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 SZ=1,CZ=1440,wZ=600;function TZ(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(CZ,Math.max(SZ,n))*60:t}var EZ=null;function DZ(e){return{prompt:e.text.trim(),stopHook:e.stopHook,heartbeat:e.heartbeat,postCompaction:e.postCompaction,seconds:e.seconds}}function OZ(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 kZ(e,t){return!e.archived&&!t}function AZ(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 jZ({thread:e,armed:t,close:n}){let r=kZ(e,t)?_l:``,i=EZ?.slug===e.id?EZ.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??wZ),h=s||l||d,[g,_]=(0,I.useState)(String(Math.round((i?.seconds??t?.intervalSeconds??wZ)/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??wZ}),b=e=>({text:a,stopHook:s,heartbeat:l,postCompaction:d,seconds:TZ(g,p),...e}),x=(0,I.useRef)(b());x.current=b(),(0,I.useEffect)(()=>()=>{let n=x.current;if(OZ(n,y.current)){EZ?.slug===e.id&&(EZ=null);return}if(n.text.trim()===``&&!t){EZ={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?EZ?.slug===e.id&&(EZ=null):EZ={slug:e.id,draft:t},n});return S.current=n,n}async function w(t){let n=t.text.trim()||null;if(OZ(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={...DZ(t),prompt:n??``};let r=AZ(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(OZ(b(),y.current)||a.trim()===``&&!t){n();return}C(b()).then(e=>{e&&n()})}function E(){let e=TZ(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=>{nR({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)(_Z,{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)(_Z,{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:SZ,max:CZ,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)(_Z,{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 MZ({thread:e,sticky:t=!1,safeArea:n=!1,onArchived:r,onDismissCancel:i,onSnoozed:a}){let o=aZ(e);return o.footer?(0,L.jsxs)(`footer`,{"aria-label":`Thread lifecycle actions`,"data-thread-lifecycle-footer":!0,className:`${t?`z-20`:jJ} flex min-h-10 shrink-0 flex-wrap items-center justify-end ${aR} 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 ${aR}`,children:[(0,L.jsx)(hZ,{thread:e}),(0,L.jsx)(PZ,{thread:e}),(0,L.jsx)(yZ,{thread:e})]}),o.done?(0,L.jsx)(NZ,{}):(0,L.jsxs)(L.Fragment,{children:[o.snooze&&(0,L.jsx)(uZ,{thread:e,onSnoozed:a}),(0,L.jsx)(FZ,{thread:e,onArchived:r,onDismissCancel:i})]})]}):null}function NZ(){let e=`Marked done — send a message to reopen it`;return(0,L.jsx)(iM,{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 PZ({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)(iM,{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 ${oR}`,children:(0,L.jsx)(Um,{size:12})})})}function FZ({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||oZ(e))&&TU(e.id),Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:r}).then(r=>{if(r.needsConfirmation){EU(e.id),i&&n?.(),u(r.hold),c(!0),o(!1);return}c(!1),Z(`Done`),i||t?.()}).catch(t=>{EU(e.id),i&&n?.(),Z(`Couldn’t finish: ${t.message.slice(0,80)}`),o(!1)})},f=!!t&&!!n&&oZ(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)(lZ,{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)(IZ,{hold:l})})]})}function IZ({hold:e}){let t=sZ(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 LZ({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=OX(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)(iM,{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 RZ=new Set([`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]);function zZ(e,t){let n=e.lastIndexOf(t);if(n<=0)return{model:e};let r=e.slice(n+1);return RZ.has(r)?{model:e.slice(0,n),effort:r}:{model:e}}function BZ(e){let t=e?.trim();if(!t)return`Profile unknown`;if(t.startsWith(`frizz:`)){let{model:e,effort:n}=zZ(t.slice(6).replace(/^frizz-/,``),`-`);return n?`${e} › ${n}`:e}let n=t.split(/\s+/),{model:r,effort:i}=zZ(n.at(-1)??t,`/`);if(!i)return t;let a=n.slice(0,-1).join(` `);return`${a?`${a} · `:``}${r} › ${i}`}function VZ(e){return e?.trim()?BZ(e):void 0}function HZ(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 UZ={completed:`finished`,killed:`stopped`,failed:`failed`};function WZ(e){let t=UZ[e.agentStatus??`completed`],n=e.agentElapsedMs===void 0?void 0:zE(e.agentElapsedMs);return{outcome:t,tail:`${t}${n?` · ${n}`:``}`}}var GZ=e=>e===void 0?void 0:PE(e),KZ=e=>{if(e!==void 0)return zE(e)||void 0};function qZ(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=GZ(n);return{label:t===`completed`?void 0:UZ[t],duration:KZ(n),tone:r?`failed`:`muted`,title:`${e?`Stopped`:r?`Failed`:`Ran for`}${e||r?` after`:``} ${i??`an unknown time`}`}}if(r){let e=GZ(i);return{label:void 0,duration:KZ(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=GZ(o);return{label:c?UZ.killed:s?UZ.failed:void 0,duration:KZ(o),tone:s?`failed`:`muted`,title:`${c?`Stopped after`:s?`Failed after`:`Ran for`} ${l??`an unknown time`}`}}var JZ=`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`,YZ=`${KE} -mt-[1em] self-baseline`,XZ=`h-[1em] w-[1em] shrink-0 translate-y-[calc(0.5em_-_0.5cap)] text-muted/45`;function ZZ({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)(`span`,{className:YZ,children:(0,L.jsx)(t?Mm:Pm,{"aria-hidden":!0,className:XZ})}),(0,L.jsx)(`span`,{"data-link-kind":!0,className:GE,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:JZ,onClick:e=>e.stopPropagation(),children:n},e.id):(0,L.jsx)(`button`,{"data-thread-link":e.id,type:`button`,title:e.target,className:`${JZ} cursor-pointer`,onClick:t=>{t.stopPropagation(),Eq(e.target)},children:n},e.id)})}):null}function QZ({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 $Z({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)(QZ,{at:e,host:t})]})}var eQ=`text-[14px] leading-5 text-muted`,tQ=`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 nQ(e){return`${tQ} ${e?`-mx-[0.208em] rotate-90`:`-mx-[0.333em]`}`}var $=I.createElement;function rQ({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,$(iQ,{label:`Redacted command preview`,text:e.command.preview}),e.command.actions?$(aQ,{actions:e.command.actions}):null,e.capabilities?$(sQ,{capabilities:e.capabilities}):null):e.kind===`file-approval`?$(I.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},dQ(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?$(iQ,{label:`Plain-text diff preview`,text:e.diffPreview}):null,e.changes?$(oQ,{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?$(sQ,{capabilities:e.capabilities}):null)}function iQ({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 aQ({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`},uQ(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,$(iQ,{label:`${uQ(e.kind)} command detail`,text:e.commandPreview})))))}function oQ({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`},dQ(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?$(iQ,{label:`${dQ(e.operation)} plain-text diff`,text:e.diffPreview}):null))))}function sQ({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`},$(cQ,{capability:e})))))}function cQ({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?$(lQ,{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),$(lQ,{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`),$(lQ,{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`),$(lQ,{label:`Hosts`,values:e.hosts}))}function lQ({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 uQ(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 dQ(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 fQ(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 pQ={semantic:`approve`,label:`Approve once`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`},mQ={semantic:`approve`,label:`Approve for session`,order:20,tone:`primary`,durable:!0,scope:`Persists for later matching requests in this thread session.`},hQ={semantic:`approve`,label:`Grant for turn`,order:10,tone:`primary`,durable:!1,scope:`Applies to this turn only.`},gQ={semantic:`approve`,label:`Grant for session`,order:20,tone:`primary`,durable:!0,scope:`Persists until this thread session ends.`},_Q={semantic:`deny`,label:`Deny`,order:70,tone:`danger`,durable:!1,scope:`Rejects this request.`},vQ={semantic:`decline`,label:`Decline`,order:70,tone:`danger`,durable:!1,scope:`Declines this request.`},yQ={semantic:`cancel`,label:`Cancel request`,order:80,tone:`neutral`,durable:!1,scope:`Cancels this pending request.`};function bQ(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`?pQ:n===`acceptForSession`&&r===`approve`?mQ:(n===`decline`||n===`deny`)&&r===`deny`?_Q:n===`cancel`&&r===`cancel`?yQ:void 0;if(e.kind===`permission-approval`)return n===`grant-turn`&&r===`approve`?hQ:n===`grant-session`&&r===`approve`?gQ:(n===`deny`||n===`decline`)&&r===`deny`?_Q:n===`cancel`&&r===`cancel`?yQ: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`?vQ:n===`cancel`&&r===`cancel`?yQ: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 vQ;if(n===`cancel`&&r===`cancel`)return yQ}function xQ(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=bQ(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 SQ(e){switch(e){case`claude`:return`Claude`;case`codex`:return`Codex`;case`frizz`:return`Frizz`}}function CQ(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 wQ(e,t){let n=e.options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t));return n<0?``:String(n)}function TQ(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?``:wQ(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 EQ(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 DQ(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 OQ(e,t){return JSON.stringify([e,t??null])}function kQ(e,t){try{let n=new URL(e,t);return n.protocol===`http:`||n.protocol===`https:`?n.toString():null}catch{return null}}function AQ(e,t){let n=e.getAttribute(`href`);if(!n)return!1;let r=kQ(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 jQ(e=()=>location.href){return t=>{if(t.defaultPrevented||t.button!==0)return;let n=NQ(t);n&&AQ(n,e())}}function MQ(){let e=jQ();return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)}function NQ(e){let t=typeof e.composedPath==`function`?e.composedPath():[];for(let e of t)if(PQ(e))return e;let n=e.target?.closest?.(`a[href]`);return PQ(n)?n:null}function PQ(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 FQ(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 IQ(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)=>`${FQ(t)} ${e.label}`),recommendedIdx:null},...e?{optionFieldId:e.id}:{},optionValues:r.map(e=>e.value),...t?{notesFieldId:t.id}:{}}}function LQ(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=IQ(r,a);if(!e)return null;n.push(e)}else if(r.input===`text`||r.input===`multiline`){let e=IQ(void 0,r);if(!e)return null;n.push(e)}else return null}return n.length>0?n:null}function RQ(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)=>`${FQ(t)} ${e.label}${e.description?` — ${e.description}`:``}`),recommendedIdx:null},chosenIdxs:n,text:r}}function zQ(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 BQ(e){let t=e instanceof Error?e.message:`The request could not be updated.`;return t.length>240?`${t.slice(0,239)}…`:t}function VQ(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`frizz-response-${Date.now()}-${Math.random().toString(36).slice(2)}`}function HQ({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:`${kJ} 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:BQ(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)(WQ,{record:e,autoFocus:n&&t===0},e.id))}):null}function UQ({record:e,questions:t,autoFocus:n}){let r=Ve(),i=(0,I.useRef)(null),a=(0,I.useRef)(new Map),o=Oz(),s=fQ(e.delivery?.effect),c=(0,I.useMemo)(()=>xQ(e).find(e=>e.semantic===`answer`),[e]),l=jz(t.flatMap(t=>t.notesFieldId?[Dz.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(Dz.interaction(o,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId))??``:``})),p=zQ(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(BQ(t))}}),y=()=>{if(!c||!p||v.isPending||g||!s.actionsEnabled)return;h(void 0);let e=OQ(c.id,p),t=a.current.get(e)??VQ();a.current.set(e,t),v.mutate({decisionId:c.id,values:p,responseId:t})},b=(t,n)=>{t.notesFieldId&&Tz.set(Dz.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)(oX,{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 WQ({record:e,autoFocus:t=!1}){let n=(0,I.useMemo)(()=>LQ(e),[e]);return n?(0,L.jsx)(UQ,{record:e,questions:n,autoFocus:t}):(0,L.jsx)(GQ,{record:e,autoFocus:t})}function GQ({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=Oz(),l=o.filter(e=>!e.secret&&(e.input===`text`||e.input===`multiline`)).map(t=>Dz.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.id)),u=jz(l),[d,f]=(0,I.useState)(()=>TQ(o)),p=(0,I.useMemo)(()=>{let t={...d};return o.forEach(n=>{if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=Dz.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=fQ(e.delivery?.effect),D=(0,I.useMemo)(()=>xQ(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`&&Tz.set(Dz.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(OQ(r.decision.id,r.values)),_(void 0),C(void 0),T(!1),x(!0),l.forEach(e=>Tz.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),_(BQ(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=DQ(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=OQ(e.id,n),i=a.current.get(r)??VQ();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 ${kJ} 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||nR({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)(qQ,{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:KQ(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}`))]}),!JQ.has(e.payload.kind)&&(0,L.jsx)(ZQ,{record:e})]})})]})}function KQ(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 qQ({record:e,instanceId:t,draft:n,setDraft:r,errors:i,autoFocus:a}){let o=e.payload,s=(e,t)=>r(EQ(n,e,t)),c;return c=o.kind===`command-approval`||o.kind===`file-approval`||o.kind===`permission-approval`?(0,L.jsx)(rQ,{payload:o}):o.kind===`mcp-elicitation-url`?(0,L.jsx)(XQ,{url:o.url}):(0,L.jsx)(QQ,{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)(YQ,{text:o.message}),(0,L.jsx)(`div`,{className:`message`in o&&o.message?`mt-3`:``,children:c})]})}var JQ=new Set([`command-approval`,`file-approval`,`permission-approval`]);function YQ({text:e}){return e.length>600||e.split(`
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 XQ({url:e}){let t=kQ(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 ZQ({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:SQ(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:CQ(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 QQ({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)($Q,{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 $Q({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 e$(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 t$(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-8aee8nsf.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
- `).length,[e]),x=b>j2,S=(0,I.useMemo)(()=>n?n.split(`
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
- `).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(`
317
- `).length:0,[h]),_=g>F2,v=E0(),y=qC(),b=v?Gp(y,v):void 0,x=!a&&i?(b?.subAgents??[]).find(e=>e.id===i):void 0,S=x?.state===`running`,C=!!(v&&i),w=e??`sub-agent`,T=zZ(r),E=TE(),D=GZ({agentStatus:a,agentElapsedMs:o,liveState:x?.state,liveElapsedMs:x?.startedAt?Math.max(E-Date.parse(x.startedAt),0):void 0,status:s,durationMs:c}),O=S?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--agent`,"data-running-indicator":`subagent-disclosure`}):x?.state===`stale`?(0,L.jsx)(`span`,{className:GE,title:KE}):x?.state===`rested`?(0,L.jsx)(`span`,{className:qE,title:JE}):null;function k(){!v||!i||vp(v,i,{label:w,subagentType:r,startedAt:x?.startedAt})}return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(Oq,{className:`frizz-bash-header`,controls:m,expanded:u,label:`${u?`Collapse`:`Expand`} Agent dispatch: ${w}`,onToggle:()=>d(e=>!e),meta:(T||D)&&(0,L.jsxs)(L.Fragment,{children:[T&&(0,L.jsx)(`span`,{"data-subagent-profile":!0,className:`petite-caps frizz-tool-header-caps shrink-0 whitespace-nowrap text-[11.5px] leading-none text-muted/55`,title:`Sub-agent profile: ${T}`,children:T}),T&&D&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`petite-caps frizz-tool-header-caps -mx-[2px] shrink-0 text-[11.5px] leading-none text-muted/55`,children:`·`}),D&&(0,L.jsx)(x2,{tone:D.tone===`failed`?`frizz-tool-failed`:`text-muted/55`,title:D.title,label:D.label,duration:D.duration})]}),children:[O&&(0,L.jsx)(`span`,{className:`frizz-tool-mark -mr-1 flex w-[9px] shrink-0 justify-center`,children:O}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Agent`}),C?(0,L.jsx)(`button`,{type:`button`,"aria-label":`Open sub-agent transcript: ${w}`,title:`Open sub-agent transcript`,onClick:k,className:`min-w-[4rem] flex-1 truncate text-left text-[11.5px] text-muted outline-none hover:underline hover:text-fg/80 focus-visible:underline focus-visible:text-fg/80`,children:w}):(0,L.jsx)(`span`,{className:`min-w-[4rem] flex-1 truncate text-[11.5px] text-muted`,title:w,children:w})]}),(0,L.jsx)(`div`,{id:m,hidden:!u,children:u&&(0,L.jsxs)(L.Fragment,{children:[h&&(0,L.jsx)(`pre`,{className:`frizz-bash-body${_&&!f?` frizz-bash-clamp`:``}`,children:h}),_&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>p(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:f?`Collapse`:`Show all ${g} lines`}),l&&(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`,children:l})]})]})})]})}function L2(e,t){return t===`shutdown_request`?`Shutdown`:t===`codex_followup`?`Followed up`:e===`main`?`Reported`:`Steered`}function R2({to:e,summary:t,body:n,type:r,dispatchId:i,targetLabel:a,status:o,durationMs:s,at:c}){return(0,I.useContext)(w0)===null?(0,L.jsx)(B2,{to:e,summary:t,body:n,type:r,status:o,durationMs:s}):(0,L.jsx)(a4,{to:e,type:r,dispatchId:i,targetLabel:a,at:c})}var z2=16;function B2({to:e,summary:t,body:n,type:r,status:i,durationMs:a}){let[o,s]=(0,I.useState)(!t),[c,l]=(0,I.useState)(!1),u=(0,I.useId)(),d=Nq(JK(n)),f=(0,I.useMemo)(()=>n.split(`
318
- `).length,[n]),p=f>z2,m=!!n.trim(),h=L2(e,r);return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":m?u:void 0,"aria-expanded":m?o:void 0,"aria-label":`${m?`${o?`Collapse`:`Expand`} `:``}${h}${e?` to ${e}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/60`,disabled:!m,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:h}),t&&(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:t})]}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,L.jsx)(w2,{status:i,durationMs:a}),m&&(0,L.jsx)(ym,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${o?`rotate-90`:``}`})]})]}),m&&(0,L.jsx)(`div`,{id:u,hidden:!o,children:o&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`border-t border-border px-2.5 py-2${p&&!c?` frizz-bash-clamp`:``}`,children:(0,L.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:d})}),p&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:c?`Collapse`:`Show all ${f} lines`})]})})]})}function V2({body:e,items:t}){let[n,r]=(0,I.useState)(null),i=(0,I.useMemo)(()=>new Map(t.map(e=>[e.token,e])),[t]),a=n===null?void 0:i.get(n);return(0,L.jsxs)(L.Fragment,{children:[(0,I.useMemo)(()=>UL(e,[...i.keys()]),[e,i]).map((e,t)=>{let a=e.token?i.get(e.token):void 0;if(!a)return(0,L.jsx)(GY,{text:e.text},t);let o=n===a.token;return(0,L.jsx)(`button`,{type:`button`,title:a.display,"aria-expanded":o,onClick:e=>{e.stopPropagation(),r(o?null:a.token)},onKeyDown:e=>e.stopPropagation(),className:`inline-flex max-w-56 items-baseline rounded border px-1 align-baseline font-mono-keep text-[11px] leading-snug transition-colors ${o?`border-bg/40 bg-bg/15`:`border-bg/25 bg-bg/[0.08] hover:bg-bg/15`}`,children:(0,L.jsx)(`span`,{className:`truncate`,children:IL(a.token)})},t)}),a&&(0,L.jsxs)(`span`,{className:`mt-2 block cursor-auto rounded-md border border-bg/20 bg-bg/[0.06] px-2 py-1.5`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`span`,{className:`block truncate font-mono-keep text-[11px] text-bg/60`,children:[a.display,a.startLine===void 0?``:` · ${a.startLine===a.endLine?`line ${a.startLine}`:`lines ${a.startLine}-${a.endLine}`}`]}),(0,L.jsx)(`span`,{className:`mt-1 block max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono-keep text-[11.5px] leading-4 text-bg/80`,children:a.text})]})]})}function H2({text:e,rawText:t,queued:n,deliveryUnconfirmed:r,deliveryId:i,sourceId:a}){let o=(0,I.useContext)(w0),s=lX(o),{unqueue:c,pending:l}=pX(o),u=!!(n&&i&&o&&s),d=mX(n?o:null),{deliverNow:f,pending:p}=hX(o),m=!!(n&&o&&d),{prose:h,attachments:g}=(0,I.useMemo)(()=>NL(e),[e]),_=(0,I.useMemo)(()=>XL(h),[h]);return(0,L.jsxs)(`div`,{"data-frizz-msg":a,className:`self-end flex flex-col items-end gap-0.5 max-w-[85%]`,children:[h.trim()!==``&&(0,L.jsxs)(`div`,{className:`group relative`,children:[(0,L.jsx)(`div`,{...u?{role:`button`,tabIndex:0,"data-unqueue":i,"aria-label":`Unqueue this message and put it back in the prompt box`,title:l?`Taking it back…`:void 0,onClick:n=>c({deliveryId:i,text:e,rawText:t??e,from:n.currentTarget}),onKeyDown:n=>{n.key!==`Enter`&&n.key!==` `||(n.preventDefault(),c({deliveryId:i,text:e,rawText:t??e,from:n.currentTarget}))}}:{},className:`relative rounded-xl rounded-br-sm bg-user-bubble px-3.5 py-3 text-[14px] whitespace-pre-wrap [overflow-wrap:anywhere] text-bg ${n?`opacity-50`:``} ${u?`cursor-pointer transition-opacity group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-bg`:``} ${l?`!opacity-30`:``}`,children:_?(0,L.jsx)(V2,{body:_.body,items:_.items}):(0,L.jsx)(GY,{text:h})}),m&&(0,L.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:f,disabled:p,title:`Send now — interrupts what the worker is doing so it reads the queue immediately`,"aria-label":`Send now`,className:`absolute bottom-0 right-full mr-2 flex h-7 w-7 items-center justify-center rounded-lg text-muted opacity-0 outline-none transition-[opacity,color,background-color] group-hover:opacity-100 enabled:hover:bg-panel-2/70 enabled:hover:text-fg enabled:focus-visible:opacity-100 enabled:focus-visible:bg-panel-2/70 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`,children:p?(0,L.jsx)(Xm,{size:15,strokeWidth:2.2,className:`animate-spin`}):(0,L.jsx)(fm,{size:15,strokeWidth:2.2})})]}),g.length>0&&(0,L.jsxs)(`div`,{className:`mt-1 flex flex-col items-end gap-1.5`,children:[g.filter(e=>e.kind===`image`).map((e,t)=>(0,L.jsx)(G2,{path:e.path,hideCaption:!0},`i${t}-${e.path}`)),g.some(e=>e.kind===`file`)&&(0,L.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,children:g.filter(e=>e.kind===`file`).map((e,t)=>(0,L.jsx)(K2,{path:e.path},`f${t}-${e.path}`))})]}),r&&(0,L.jsx)(`div`,{className:`text-[11px] text-amber-400/80`,children:`Delivery unconfirmed — no receipt from the worker`}),u&&l&&(0,L.jsx)(`div`,{"aria-hidden":!0,className:`h-0 overflow-visible text-[11px] text-muted`,children:`Taking it back…`})]})}var U2=(0,I.memo)(function({m:e,answering:t,dense:n,paired:r,textOnly:i,showSendButton:a,staleAwaiting:o,shadowedBy:s,placed:c,thread:l,restingCardShown:u,restedAt:d}){let f=zW(),[p,m]=(0,I.useState)(!1);if(e.providerError)return(0,L.jsx)(UJ,{error:e.providerError});if(e.kind===`event`)return(0,L.jsx)(o4,{text:e.text,boundary:e.boundary,sourceId:e.sourceId,at:e.at});if(e.kind===`reasoning`)return(0,L.jsx)(s4,{text:e.text,sourceId:e.sourceId});let h=BZ(e);if(h)return(0,L.jsx)(r4,{call:h,sourceId:e.sourceId,at:e.at});if(e.role===`user`){let t=gX(e).replace(/\r\n?/g,`
319
- `),i=r===void 0?YJ(t):r;if(i)return(0,L.jsx)(KY,{answers:i,queued:e.queued,sourceId:e.sourceId});let a=e.wake?xl(t):void 0;return a?(0,L.jsx)(RY,{bump:a,sourceId:e.sourceId,at:e.at}):e.wake?(0,L.jsx)(EY,{steer:e.wakeSteer,text:t,sourceId:e.sourceId,at:e.at,wrap:n}):e.peerFrom?(0,L.jsx)(i4,{from:e.peerFrom,unnamed:e.peerUnnamed,dispatchId:e.peerDispatchId,sourceId:e.sourceId,at:e.at}):(0,L.jsx)(H2,{text:t,rawText:e.text,queued:e.queued,deliveryUnconfirmed:e.deliveryState===`unconfirmed`,deliveryId:e.deliveryId,sourceId:e.sourceId})}let g=[],_=[],v=(e,t=d2)=>{g.push(e),_.push(t)},y={n:-1},b={drawn:!1},x=[],S=new Set,C=(r,i)=>{for(let[a,l]of wJ(r).entries()){if(l.kind===`fence`){if(l.fenceKind===`awaiting`&&(e.fenceRefused||o||u))continue;l.fenceKind===`awaiting`&&(b.drawn=!0),v((0,L.jsx)(X2,{fenceKind:l.fenceKind,body:l.body,hints:l.hints,wrap:n,notAfter:d},`${i}-f${a}`));continue}for(let[e,r]of iJ(l.text).entries()){if(r.kind===`prose`){for(let[t,o]of ML(r.text).entries()){let r=`${i}-${a}-p${e}-${t}`;v(o.kind===`image`?(0,L.jsx)(G2,{path:o.path},r):o.kind===`file`?(0,L.jsx)(K2,{path:o.path},r):o.kind===`visualization`?(0,L.jsx)(Y2,{file:o.file},r):o.kind===`directive`?(0,L.jsx)(b0,{directive:o.directive},r):o.kind===`mermaid`?(0,L.jsx)(C0,{source:o.source},r):(0,L.jsx)(W2,{md:o.text,wrap:n},r))}continue}y.n+=1;let o=y.n,l=c&&r.registeredId?c.find(e=>e.id.toLowerCase()===r.registeredId):void 0;if(l&&!S.has(l.id)){S.add(l.id),v((0,L.jsx)(d$,{q:l},`${i}-${a}-q${e}`));continue}if(s&&_Y(r,s)!==void 0||r.registeredId&&r.text.trim()===``)continue;t&&x.push({raw:r.text,kind:r.questionKind,danger:r.danger,bi:o});let u=t&&!f?{answer:t.answerFor(o),onChip:(e,n)=>t.onChip(o,e,n),onText:e=>t.onText(o,e),onSubmit:t.onSubmit}:void 0;v((0,L.jsx)(iX,{raw:r.text,questionKind:r.questionKind,danger:r.danger,interactive:u,wrap:n},`${i}-${a}-q${e}`))}}};if(e.parts&&e.parts.length>0)l2(e.parts).forEach((t,r)=>{if(t.kind===`tools`){if(i)return;let a=m2(t.tools);a.length&&v((0,L.jsx)(v2,{tools:a,dense:n,at:e.at},`t${r}`),p2(a))}else C(t.text,`x${r}`)});else{if(!i){let t=m2(e.tools);t.length>0&&v((0,L.jsx)(v2,{tools:t,dense:n,at:e.at},`tools`),p2(t))}C(e.text,`leg`)}return d!==void 0&&l&&!b.drawn&&!e.fenceRefused&&Z$(l,{notAfter:d})&&v((0,L.jsx)(i1,{thread:l,notAfter:d},`rested-on`)),g.length===0?null:(a&&t&&f&&x.length>0?v((0,L.jsx)(`div`,{className:`flex justify-start`,children:(0,L.jsx)(`button`,{type:`button`,"data-mobile-answer-open":!0,onClick:()=>m(!0),className:`flex h-[40px] items-center justify-center rounded-[12px] bg-accent px-4 text-[15px] font-semibold text-bg active:brightness-90`,children:x.length>1?`Answer ${x.length} questions`:`Answer`})},`answer-open`)):a&&t&&x.length>0&&v((0,L.jsx)(`div`,{className:`flex justify-start`,children:(0,L.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:!t.anyAnswered||t.sending,onClick:t.onSubmit,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`})},`send-answers`)),(0,L.jsxs)(`div`,{"data-frizz-msg":e.sourceId,className:`flex flex-col text-[13px] min-w-0`,children:[u2(g,f2(_,14)),p&&t&&x.length>0?(0,L.jsx)(cX,{blocks:x,answering:t,onClose:()=>m(!1)}):null]}))});function W2({md:e,wrap:t}){let n=JK(e),r=Nq(n),i=(0,I.useRef)(null);return Kq(i,n),n?(0,L.jsx)(`div`,{ref:i,className:`md-body${t?` ${EJ}`:``}`,dangerouslySetInnerHTML:r}):null}function G2({path:e,hideCaption:t,altText:n,header:r}){let[i,a]=(0,I.useState)(!1);if(i)return(0,L.jsx)(`div`,{className:`font-mono-keep text-[12px] text-muted/70 break-all`,children:e});let o=Qf(e);return(0,L.jsx)(pK,{header:r,caption:t?void 0:(0,L.jsx)(`figcaption`,{className:`bg-panel-2 px-2 pb-1.5 font-mono-keep text-[11px] text-muted/60 break-all`,children:o}),children:(0,L.jsx)(`img`,{src:YS(e),alt:n??o,"data-local-path":e,"data-local-image":`true`,onError:()=>a(!0),className:`cursor-pointer ${gK}`})})}function K2({path:e}){let t=Qf(e);return(0,L.jsxs)(`button`,{type:`button`,className:`local-file-action inline-flex max-w-full items-center gap-1.5 ${DJ} border border-border bg-panel-2 px-3 py-1.5 text-left align-top no-underline hover:border-accent`,"data-local-path":e,title:e,children:[(0,L.jsx)(Pm,{size:14,strokeWidth:2,className:`shrink-0 text-muted`}),(0,L.jsx)(`span`,{className:`font-mono-keep truncate text-[12px] text-fg`,children:t})]})}var q2={"--background":`--color-bg`,"--foreground":`--color-fg`,"--card":`--color-panel-2`,"--card-foreground":`--color-fg`,"--popover":`--color-elevated`,"--popover-foreground":`--color-fg`,"--primary":`--color-fg`,"--primary-foreground":`--color-bg`,"--secondary":`--color-panel-2`,"--secondary-foreground":`--color-fg`,"--muted":`--color-panel-2`,"--muted-foreground":`--color-muted`,"--accent":`--color-border-strong`,"--accent-foreground":`--color-fg`,"--border":`--color-border-strong`,"--input":`--color-border-strong`,"--ring":`--color-accent`};function J2(){let e=getComputedStyle(document.documentElement),t=Object.fromEntries(Object.entries(q2).map(([t,n])=>[t,e.getPropertyValue(n).trim()]));return t[`--font-size-base`]=getComputedStyle(document.body).fontSize,{type:`frizz-inline-vis-theme`,colorScheme:e.colorScheme===`light`?`light`:`dark`,vars:t}}function Y2({file:e}){let t=(0,I.useContext)(w0),n=(0,I.useRef)(null),[r,i]=(0,I.useState)(360),[a,o]=(0,I.useState)(null),s=t?`${Id()}/local-visualization?slug=${encodeURIComponent(t)}&file=${encodeURIComponent(e)}`:null;return(0,I.useEffect)(()=>{if(!s){o(!1);return}let e=new AbortController;return o(null),fetch(s,{method:`HEAD`,signal:e.signal}).then(t=>{e.signal.aborted||o(t.ok)}).catch(()=>{e.signal.aborted||o(!1)}),()=>e.abort()},[s]),(0,I.useEffect)(()=>{let e=e=>{if(e.source!==n.current?.contentWindow||e.data?.type!==`frizz-inline-vis-height`)return;let t=Number(e.data.height);Number.isFinite(t)&&i(Math.max(80,Math.min(2400,Math.ceil(t))))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]),a===!1||!s?(0,L.jsxs)(`div`,{role:`status`,className:`${DJ} border border-border bg-panel-2 px-4 py-2.5 text-[12px] text-muted`,children:[`Visualization unavailable: `,(0,L.jsx)(`span`,{className:`font-mono-keep break-all`,children:e})]}):a===null?(0,L.jsx)(`div`,{role:`status`,className:`h-20 animate-pulse ${DJ} bg-panel-2`,"aria-label":`Loading ${e}`}):(0,L.jsx)(`iframe`,{ref:n,src:s,title:e.replace(/\.html$/,``).replaceAll(`-`,` `),sandbox:`allow-scripts`,onLoad:()=>n.current?.contentWindow?.postMessage(J2(),`*`),className:`block w-full border-0 bg-transparent`,style:{height:r}})}function X2({fenceKind:e,body:t,hints:n,wrap:r,notAfter:i}){let a=JK(t),o=(0,I.useContext)(w0),s=(0,I.useContext)(D0),c=qC(),l=o?Gp(c,o):void 0,u=l?rZ(l):void 0,d=!!(l&&u?.archive),f=(0,I.useRef)(null);d&&l&&(f.current=l);let p=d&&l?l:f.current;return e===`done`?(0,L.jsxs)(PJ,{icon:gm,label:`Done`,children:[a&&(0,L.jsx)(qq,{className:`md-body${r?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:a}),p&&(0,L.jsx)(IJ,{children:(0,L.jsx)(NZ,{thread:p,className:`rounded-md text-[11px] bg-fg px-2.5 py-1 text-bg hover:opacity-90`,iconClassName:`icon-label-nudge`,onArchived:s?.dismiss,onDismissCancel:s?.cancel})})]}):l&&t1(l)?null:(0,L.jsx)(i1,{thread:l,fence:{body:t,hints:n},notAfter:i})}function Z2({slug:e,sessionId:t,fault:n,retryText:r}){let[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(!1),c=Ve(),l=GR[n.backend],u=t=>{s(!0),nU(c,e,t,{onSuccess:()=>{s(!1),Z(`Retrying with the previous message…`)},onRollback:()=>s(!1),failureToast:e=>`Retry failed: ${e.slice(0,80)}`})||s(!1)};return(0,L.jsxs)(PJ,{"data-provider-fault":!0,tone:`danger`,icon:qm,label:`${l} sign-in required`,children:[(0,L.jsx)(`span`,{className:FJ,children:`The provider rejected this session's credential. Sign in, then retry.`}),(0,L.jsxs)(IJ,{children:[r?.trim()&&(0,L.jsx)(`button`,{onClick:()=>u(r),disabled:o,onMouseDown:e=>e.preventDefault(),className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel hover:border-border-strong disabled:opacity-60`,children:`Retry`}),(0,L.jsx)(`button`,{onClick:()=>a(!0),onMouseDown:e=>e.preventDefault(),className:zJ,children:`Sign in`})]}),i&&(0,L.jsx)(JR,{backend:n.backend,onClose:()=>a(!1),onAuthed:()=>a(!1)})]})}function Q2({slug:e,sessionId:t,pause:n}){let r=GR[n.backend],i=n.window===`weekly`?`weekly limit`:n.window===`session`?`session limit`:`usage limit`,[a,o]=(0,I.useState)(!1),s=Ve();return(0,L.jsxs)(PJ,{"data-limit-pause":!0,tone:`caution`,icon:Um,label:`Paused by the ${r} ${i}`,children:[(0,L.jsx)(`span`,{className:FJ,children:n.autoResume?n.resumesAt?`Continuing automatically at ${gE(n.resumesAt)}.`:`Continuing automatically once the window resets.`:`Continue it whenever you have capacity again.`}),(0,L.jsx)(IJ,{children:(0,L.jsx)(`button`,{onClick:()=>{o(!0),nU(s,e,`Continue exactly where you left off.`,{onSuccess:()=>{o(!1),Z(`Continuing…`)},onRollback:()=>o(!1),failureToast:e=>`Continue failed: ${e.slice(0,80)}`})||o(!1)},disabled:a,onMouseDown:e=>e.preventDefault(),className:`disabled:opacity-45 ${zJ}`,children:`Continue now`})})]})}function $2({onTerminal:e}){return(0,L.jsxs)(PJ,{tone:`attention`,icon:qm,label:`Permission approval`,children:[(0,L.jsx)(`span`,{className:FJ,children:`The agent is waiting on your approval — respond in your external terminal.`}),(0,L.jsx)(IJ,{children:(0,L.jsx)(`button`,{onClick:()=>e(),onMouseDown:e=>e.preventDefault(),className:zJ,children:`Copy terminal command`})})]})}function e4({policy:e,denies:t}){let n=[e.tool,e.command].filter(Boolean).join(`: `);return(0,L.jsxs)(PJ,{tone:`caution`,icon:xh,label:`Blocked by frizz's permission policy`,children:[n?(0,L.jsx)(`code`,{className:`mb-1.5 block min-w-0 break-all rounded bg-panel px-1.5 py-1 text-[11px] text-fg/85`,children:n}):null,(0,L.jsx)(`span`,{className:FJ,children:e.reason}),(0,L.jsxs)(`span`,{className:`mt-1.5 block text-[11px] text-muted`,children:[`Rule `,(0,L.jsx)(`code`,{className:`rounded bg-panel px-1 py-0.5`,children:e.rule}),t&&t>1?` · ${t} denials this session`:``]})]})}function t4({slug:e,className:t=`px-4 pb-2 pt-1`,includeAgents:n=!0,transcriptShells:r=[],parentAgentId:i}){let a=Gp(qC(),e),o=a?.subAgents??[],s=n?i?rD(o,i):o:[],c=i?[...r]:sD(a?.bgShells??[],r),l=i?[]:(a?.watches??[]).filter(e=>e.kind===`github`),u=i?[]:a?.links??[],d=s.length+c.length+l.length,f=new Set((a?.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`).map(e=>e.target)),p=e=>f.has(e.taskId??``)||f.has(e.id??``)||f.has(e.label),[,m]=(0,I.useState)(0);(0,I.useEffect)(()=>{if(d===0)return;let e=setInterval(()=>m(e=>e+1),3e4);return()=>clearInterval(e)},[d]);let h=uw(e,c.flatMap(e=>e.id&&!e.outputUnavailable?[e.id]:[]));return d===0&&u.length===0?null:(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5 ${t}`,"data-background-ops":!0,children:[aD(s,`sheet`).map((t,n)=>(0,L.jsx)(cD,{kind:`AGENT`,label:t.label,state:t.state,density:`sheet`,depth:t.displayDepth??t.depth,startedAt:t.startedAt,onOpen:t.id?()=>vp(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:aM(e,t)},`a${n}`)),aD(c,`sheet`).map((t,n)=>(0,L.jsx)(cD,{kind:`SHELL`,label:t.label,state:t.state,density:`sheet`,startedAt:t.startedAt,counter:t.id?ZE(h.get(t.id)):void 0,counterTitle:`Lines of output so far — open the row to read them`,onOpen:t.id&&!t.outputUnavailable?()=>yp(e,t.id,{label:t.label,startedAt:t.startedAt}):void 0,onDismiss:aM(e,t,`SHELL`),title:p(t)?`${t.label}\nWatched — this thread wakes when it finishes`:void 0},`s${n}`)),l.map(e=>(0,L.jsx)(cD,{kind:`GITHUB`,label:e.target,state:`running`,density:`sheet`,startedAt:e.createdAt,counter:QE(e.github),counterTone:e.github?.checks===`failing`?`danger`:void 0,counterTitle:e.github?`${e.target} — ${N$(e.github)}`:void 0,onOpen:()=>window.open(aU(e.target)??`https://github.com/${e.target.replace(`#`,`/pull/`)}`,`_blank`,`noreferrer,noopener`)},e.id)),(0,L.jsx)(JZ,{links:u})]})}function n4({ask:e,onTerminal:t}){return(0,L.jsxs)(PJ,{tone:`attention`,icon:Em,label:`Waiting on your answer — in your external terminal`,children:[(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.header&&(0,L.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted/55`,children:e.header}),(0,L.jsx)(`div`,{className:`min-w-0 text-[12px] font-medium leading-5 text-fg`,children:e.question}),e.options.length>0&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.options.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border border-border bg-elevated px-3 py-1.5 text-[12px] text-fg/80`,children:[(0,L.jsx)(`span`,{className:`font-medium text-fg/90`,children:e.label}),e.description&&(0,L.jsxs)(`span`,{className:`text-muted/70`,children:[` — `,e.description]})]},t)),e.multiSelect&&(0,L.jsx)(`div`,{className:`text-[10px] text-muted/50`,children:`select one or more`})]})]},t))}),(0,L.jsx)(IJ,{children:(0,L.jsxs)(`button`,{onClick:()=>t(),onMouseDown:e=>e.preventDefault(),className:zJ,children:[(0,L.jsx)(qm,{size:12,className:`shrink-0 ${xX}`}),`Copy terminal command`]})})]})}function r4({call:e,sourceId:t,at:n}){let r=E0(),i=e.detail??`sub-agent`,{tail:a}=HZ(e),o=!!(r&&e.agentId);return(0,L.jsxs)(xY,{icon:mm,sourceId:t,marker:`agent`,ariaLabel:o?void 0:`Sub-agent ${i} ${a}`,at:n,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:`Sub-agent`}),(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:`«`}),o?(0,L.jsx)(`button`,{type:`button`,"data-subagent-completion-open":!0,title:XE.AGENT,"aria-label":`${XE.AGENT}: ${i}`,onClick:()=>vp(r,e.agentId,{label:i,subagentType:e.subagentType}),onMouseDown:e=>e.preventDefault(),className:`min-w-0 truncate rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:i}):(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:i}),(0,L.jsx)(`span`,{className:`shrink-0`,children:`»`})]}),(0,L.jsx)(`span`,{className:`shrink-0`,children:a})]})}function i4({from:e,unnamed:t,dispatchId:n,sourceId:r,at:i}){let a=E0(),o=!!(a&&n),s=t?void 0:e,c=t&&e?`${XE.AGENT} — ${e}`:XE.AGENT;return s===void 0?(0,L.jsx)(xY,{icon:mm,sourceId:r,marker:`agent-report`,ariaLabel:o?void 0:`Sub-agent reported`,at:i,children:o?(0,L.jsx)(`button`,{type:`button`,"data-subagent-report-open":!0,title:c,"aria-label":`${XE.AGENT}${e?`: ${e}`:``}`,onClick:()=>vp(a,n,{label:`Sub-agent`,subagentType:e}),onMouseDown:e=>e.preventDefault(),className:`shrink-0 rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:`Sub-agent reported`}):(0,L.jsx)(`span`,{className:`shrink-0`,title:e||void 0,children:`Sub-agent reported`})}):(0,L.jsxs)(xY,{icon:mm,sourceId:r,marker:`agent-report`,ariaLabel:o?void 0:`Sub-agent ${s} reported`,at:i,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:`Sub-agent`}),(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:`«`}),o?(0,L.jsx)(`button`,{type:`button`,"data-subagent-report-open":!0,title:XE.AGENT,"aria-label":`${XE.AGENT}: ${s}`,onClick:()=>vp(a,n,{label:s,subagentType:e}),onMouseDown:e=>e.preventDefault(),className:`min-w-0 truncate rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:s}):(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:s}),(0,L.jsx)(`span`,{className:`shrink-0`,children:`»`})]}),(0,L.jsx)(`span`,{className:`shrink-0`,children:`reported`})]})}function a4({to:e,type:t,dispatchId:n,targetLabel:r,sourceId:i,at:a}){let o=E0(),s=L2(e,t),c=e===`main`?void 0:r??e,l=!!(o&&n);return(0,L.jsxs)(xY,{icon:mm,sourceId:i,marker:`agent-steer`,ariaLabel:l?void 0:`${s}${c?` ${c}`:``}`,at:a,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:s}),c&&(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:`«`}),l?(0,L.jsx)(`button`,{type:`button`,"data-subagent-steer-open":!0,title:XE.AGENT,"aria-label":`${XE.AGENT}: ${c}`,onClick:()=>vp(o,n,{label:c}),onMouseDown:e=>e.preventDefault(),className:`min-w-0 truncate rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:c}):(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:c}),(0,L.jsx)(`span`,{className:`shrink-0`,children:`»`})]})]})}function o4({text:e,boundary:t,sourceId:n,at:r}){return t?(0,L.jsx)(xY,{icon:t===`wake`?vh:void 0,sourceId:n,marker:t===`rest`?`rest`:`event`,ariaLabel:e,at:r,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:e})}):(0,L.jsx)(`div`,{"data-frizz-msg":n,className:ZZ,children:e})}function s4({text:e,sourceId:t}){let[n,r]=(0,I.useState)(!1),i=(0,I.useId)();return(0,L.jsxs)(`div`,{"data-frizz-msg":t,className:`flex 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`} model reasoning`,className:`${ZZ} flex items-baseline gap-1.5 self-start rounded outline-none transition-colors hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:[(0,L.jsx)(`span`,{children:`Reasoning`}),(0,L.jsx)(ym,{"aria-hidden":`true`,size:13,className:$Z(n)})]}),n&&(0,L.jsx)(`div`,{id:i,className:`frizz-reasoning mt-1.5 ml-[5px] border-l border-border/70 pl-3`,children:(0,L.jsx)(W2,{md:e,wrap:!0})})]})}function c4(){return(0,L.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-full border border-muted/70 border-t-transparent animate-spin`})}function l4({since:e,startedAt:t,activityLabel:n,run:r}){let[i]=(0,I.useState)(()=>Date.now()),a=(0,I.useMemo)(()=>{for(let n of[t,e]){let e=Date.parse(n??``);if(Number.isFinite(e)&&e<=Date.now())return e}return i},[t,e,i]),[o,s]=(0,I.useState)(()=>Date.now()),[c,l]=(0,I.useState)(!1),u=(0,I.useId)();(0,I.useEffect)(()=>{let e=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(e)},[]);let d=LE(Math.max(0,o-a)),f=(0,I.useMemo)(()=>m2([...r?.tools??[]]),[r]),p=f.reduce((e,t)=>e+t.count,0),m=p>0,h=`group flex min-w-0 items-baseline justify-between gap-3 rounded text-left outline-none focus-visible:ring-1 focus-visible:ring-fg/60 ${ZZ}`,g=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate shimmer-text`,children:n??o0(p)}),m&&(0,L.jsx)(ym,{"data-working-chevron":!0,"aria-hidden":`true`,size:13,className:$Z(c)})]}),(0,L.jsx)(`span`,{className:`shrink-0 whitespace-nowrap tabular-nums text-[12px] text-muted/60`,children:d})]});return(0,L.jsxs)(`div`,{"data-working-indicator":!0,"data-working-activity":n?`tool`:`generic`,className:`flex min-w-0 flex-col`,children:[m?(0,L.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":u,"aria-expanded":c,"aria-label":`${c?`Collapse`:`Expand`} ${p} tool ${p===1?`call`:`calls`}${n?`: ${n}`:``}`,className:`${h} w-full`,children:g}):(0,L.jsx)(`div`,{className:h,children:g}),m&&c&&(0,L.jsx)(`div`,{id:u,className:`mt-1.5 flex flex-col`,children:u2(f.map((e,t)=>(0,L.jsx)(y2,{t:e,startedAt:r?.at},t)),6)}),m&&!c&&(0,L.jsx)(`div`,{id:u,hidden:!0})]})}function u4(){let[e,t]=(0,I.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: 800px)`).matches);return(0,I.useEffect)(()=>{let e=window.matchMedia(`(max-width: 800px)`),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function d4({id:e,slug:t,depth:n,widthDepth:r,initiallyOpen:i}){let{shown:a,close:o,closingRef:s}=Zp(e,i===!0),[c,l]=(0,I.useState)(i===!0),u=(0,I.useRef)(null),d=(0,I.useRef)(null),f=Zt(X),p=[...f.drawers].reverse().find(e=>!e.closing)?.id===e,m=u4(),h=(0,I.useRef)(typeof document<`u`&&document.activeElement instanceof HTMLElement?document.activeElement:null),g=(0,I.useCallback)(()=>{let e=h.current,t=document.activeElement;t&&t!==document.body||e?.isConnected&&e.focus({preventScroll:!0})},[]);(0,I.useEffect)(()=>()=>{window.setTimeout(g,0)},[g]);let _=qC(),v=Td(_,t),y=v.kind===`found`?v.thread:void 0;_?.projectDir;let b=y?y.runtime===`turn-idle`||y.runtime===`exited`||y.runtime===`none`:!1;return(0,I.useEffect)(()=>{!y||!b||Y.threadSeen({slug:t}).catch(()=>{})},[t,b,b?y?.lastActivityAt:void 0]),(0,I.useEffect)(()=>{let t=u.current;if(!t||!c)return;let n=()=>t.querySelector(`[data-drawer-scroll-ready]`),r=()=>t.querySelector(`[data-drawer-transcript-scroll]`),i=new VW({isActive:()=>[...X.drawers].reverse().find(e=>!e.closing)?.id===e,isContentReady:()=>n()?.dataset.drawerScrollReady===`true`,scrollToBottom:()=>{let e=r();return e?(e.scrollTop=e.scrollHeight,!0):!1},preserveAnchor:()=>location.hash.length>1});d.current=i;let a=null,o=new ResizeObserver(()=>i.layoutChanged()),s=()=>{let e=n();e!==a&&(a&&o.unobserve(a),a=e,e&&o.observe(e)),i.layoutChanged()},l=new MutationObserver(s);l.observe(t,{attributes:!0,attributeFilter:[`data-drawer-scroll-ready`],childList:!0,subtree:!0});let f=()=>i.userIntent(),p=e=>{[`Shift`,`Control`,`Alt`,`Meta`].includes(e.key)||f()};return t.addEventListener(`wheel`,f,{capture:!0,passive:!0}),t.addEventListener(`touchstart`,f,{capture:!0,passive:!0}),t.addEventListener(`pointerdown`,f,!0),t.addEventListener(`keydown`,p,!0),s(),()=>{i.dispose(),d.current===i&&(d.current=null),t.removeEventListener(`wheel`,f,!0),t.removeEventListener(`touchstart`,f,!0),t.removeEventListener(`pointerdown`,f,!0),t.removeEventListener(`keydown`,p,!0),o.disconnect(),l.disconnect()}},[c,e]),(0,I.useEffect)(()=>{d.current?.activationChanged()},[p]),(0,I.useEffect)(()=>{if(i)return;let e=!1,t=()=>{e||s.current||(e=!0,l(!0))},n=0,r=requestAnimationFrame(()=>{n=requestAnimationFrame(t)}),a=window.setTimeout(t,120);return()=>{window.clearTimeout(a),cancelAnimationFrame(r),n&&cancelAnimationFrame(n)}},[i]),(0,I.useEffect)(()=>{let e=u.current;if(!c||!e||document.activeElement!==e)return;let t=requestAnimationFrame(()=>{e.querySelector(`[data-dialog-initial-focus]`)?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(t)},[c]),(0,I.useEffect)(()=>(vd(e,()=>{(u.current?.querySelector(`[data-dialog-initial-focus]`)??u.current)?.focus({preventScroll:!0})}),()=>vd(e,null)),[e]),(0,L.jsx)(QI,{modal:m,open:!0,onOpenChange:e=>{e||o()},children:(0,L.jsxs)(iL,{children:[(0,L.jsx)(oL,{className:`${Kp} ${a?`opacity-100`:`opacity-0`}`,style:{zIndex:50+n*2}}),(0,L.jsxs)(uL,{ref:u,"aria-modal":m||void 0,"aria-describedby":void 0,tabIndex:-1,onEscapeKeyDown:t=>{if(X.drawers.at(-1)?.id!==e){t.preventDefault();return}zR(t)},onPointerDownOutside:n=>{let r=X.drawers.findIndex(t=>t.id===e);if(r!==-1&&r<X.drawers.length-1){n.preventDefault();return}(n.target instanceof Element?n.target.closest(`[data-subagent-parent]`):null)?.getAttribute(`data-subagent-parent`)===t&&n.preventDefault()},onFocusOutside:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),g()},onOpenAutoFocus:e=>{e.preventDefault();let t=u.current;(t?.querySelector(`[data-dialog-initial-focus]`)??t)?.focus({preventScroll:!0})},"data-vt-chat":!0,className:`fixed right-0 top-0 overflow-hidden outline-none ${qp} ${a?`translate-x-0`:`translate-x-full`}`,style:{zIndex:51+n*2,width:Yp(r),viewTransitionName:f.vtReturnTarget===t?`thread-chat`:void 0},children:[(0,L.jsx)(hL,{className:`sr-only`,children:v.kind===`found`?`Thread: ${CT(v.thread)}`:`Thread: ${t}`}),c&&v.kind===`found`?(0,L.jsx)(j0,{slug:t,onStatusApplied:o,onClose:o,virtualized:!0}):c&&v.kind===`missing`?(0,L.jsx)(f4,{slug:t,onClose:o}):(0,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,L.jsx)(`span`,{className:`block h-5 w-5 rounded-full border-2 border-muted/50 border-t-transparent animate-spin`})})]})]})})}function f4({slug:e,onClose:t}){return(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,L.jsxs)(`header`,{className:`flex ${wh} shrink-0 items-center gap-3 border-b border-border bg-panel px-4`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:`Thread unavailable`}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Close`,"data-dialog-initial-focus":!0,onClick:t,className:`p-1 text-muted hover:text-fg`,children:`×`})]}),(0,L.jsxs)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-muted`,role:`status`,children:[`Thread “`,e,`” was not found in this project.`]})]})}function p4({id:e,slug:t,subId:n,label:r,subagentType:i,startedAt:a,depth:o,widthDepth:s}){let[c,l]=(0,I.useState)(!1),u=(0,I.useRef)(null),d=cw(t,n),f=JC(),p=(0,I.useMemo)(()=>d.data?.messages??[],[d.data]),m=d.data?.state,h=m===`running`,g=(0,I.useMemo)(()=>k0(p),[p]),_=(0,I.useMemo)(()=>A0(p),[p]),v=(0,I.useMemo)(()=>H1(_),[_]),y=h?G1(v):void 0,b=h?W1(v):void 0,x=b?t0(b,f):void 0,S=h?q1(v):void 0,C=(0,I.useMemo)(()=>h?X1(v):v,[v,h]),w=h,T=d.isError||m===`gone`||p.length===0&&(m===`done`||m===`stale`);return(0,I.useEffect)(()=>{let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>l(!0))});return()=>{cancelAnimationFrame(t),e&&cancelAnimationFrame(e)}},[]),(0,I.useEffect)(()=>{let e=u.current;if(!e||!c)return;let t=!0,n=()=>{t&&(e.scrollTop=e.scrollHeight)},r=()=>{t=e.scrollHeight-e.scrollTop-e.clientHeight<160};e.addEventListener(`scroll`,r,{passive:!0});let i=new ResizeObserver(n);for(let t of e.children)i.observe(t);return n(),()=>{e.removeEventListener(`scroll`,r),i.disconnect()}},[c]),(0,L.jsx)(tm,{id:e,depth:o,widthDepth:s,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Th,{title:r,onClose:e}),(0,L.jsx)(`div`,{ref:u,className:`flex-1 min-h-0 overflow-y-auto`,children:T?(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center px-8 text-center text-[13px] text-muted`,children:`Transcript unavailable (agent completed or cleaned up).`}):!c||d.isLoading||p.length===0?(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,L.jsx)(`span`,{className:`block h-5 w-5 rounded-full border-2 border-muted/50 border-t-transparent animate-spin`})}):(0,L.jsx)(T0.Provider,{value:t,children:(0,L.jsxs)(`div`,{"data-transcript-column":!0,className:`flex flex-col px-6 py-5`,children:[c2(C.map(e=>e.message),(e,t)=>(0,L.jsx)(U2,{m:e},t)),w&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(bY,{h:s2(C.map(e=>e.message))}),(0,L.jsx)(l4,{since:a,startedAt:S,activityLabel:x,run:y})]})]})})}),(0,L.jsx)(m4,{slug:t,subId:n,subagentType:i,steerable:d.data?.steerable===!0,note:d.data?.steerNote??null,stoppable:d.data?.stoppable===!0,stopNote:d.data?.stopNote??null,ops:e=>(0,L.jsx)(t4,{slug:t,parentAgentId:n,transcriptShells:g,className:e})})]})})}function m4({slug:e,subId:t,subagentType:n,steerable:r,note:i,stoppable:a,stopNote:o,ops:s}){let[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(!1),m=Ve();function h(){let n=c.trim();!n||u||(d(!0),l(``),Y.subAgentSteer({slug:e,id:t,message:n,deliveryId:crypto.randomUUID()}).then(()=>{m.invalidateQueries({queryKey:[`subAgentTranscript`,e,t]}),Z(`Steer sent`)}).catch(e=>{l(n),Z(e instanceof Error?e.message:`Could not steer this sub-agent`)}).finally(()=>d(!1)))}function g(){f||(p(!0),Y.subAgentStop({slug:e,id:t}).then(({descendantsStopped:n,note:r})=>{r?Z(`Sub-agent stopped. ${r}`,{duration:7e3}):Z(n>0?`Sub-agent and ${n} descendant${n===1?``:`s`} stopped`:`Sub-agent stopped`),m.invalidateQueries({queryKey:[`subAgentTranscript`,e,t]})}).catch(e=>{Z(e instanceof Error?e.message:`Could not stop this sub-agent`)}).finally(()=>p(!1)))}if(!r&&!a){let e=i??o;return e?(0,L.jsxs)(`div`,{"data-subagent-steer-note":!0,className:`w-full shrink-0 border-t border-border bg-panel px-3 py-3`,children:[(0,L.jsx)(`div`,{className:`px-1 pb-2 text-[11.5px] text-muted/70`,children:e}),(0,L.jsx)(`div`,{className:`pl-1.5`,children:(0,L.jsx)(h4,{subagentType:n})}),s?.(`px-1 pt-1.5 ops-column-optical-inset`)]}):(0,L.jsx)(L.Fragment,{children:s?.(`w-full shrink-0 border-t border-border bg-panel px-4 pb-2 pt-3`)})}return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{"data-subagent-steer":!0,className:`w-full shrink-0 border-t border-border bg-panel px-3 py-3`,children:[r?(0,L.jsx)(mR,{value:c,onChange:l,onSubmit:h,surface:`subAgentComposer`,placeholder:`Steer this sub-agent…`,busy:u||f,footer:(0,L.jsx)(h4,{subagentType:n})}):i?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`px-1 pb-2 text-[11.5px] text-muted/70`,children:i}),(0,L.jsx)(`div`,{className:`pl-1.5`,children:(0,L.jsx)(h4,{subagentType:n})})]}):null,r&&!a&&o&&(0,L.jsx)(`div`,{className:`mt-2 px-1 text-[11.5px] text-muted/70`,children:o}),s?.(`px-1 pt-1.5 ops-column-optical-inset`)]}),a&&(0,L.jsx)(`footer`,{"aria-label":`Sub-agent lifecycle actions`,"data-subagent-lifecycle-footer":!0,className:`flex min-h-10 w-full shrink-0 items-center justify-end gap-1.5 border-t border-border/70 bg-panel/95 px-3 pt-2 pb-[max(0.5rem,env(safe-area-inset-bottom))] text-[12px] backdrop-blur-sm`,children:(0,L.jsx)(`button`,{type:`button`,"data-stop-subagent":!0,disabled:f,onClick:g,className:`rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] text-fg/80 transition-colors hover:border-red-400/40 hover:bg-red-400/10 hover:text-red-300 disabled:opacity-50`,children:f?`Stopping…`:`Stop sub-agent`})})]})}function h4({subagentType:e}){let t=RZ(e);return(0,L.jsx)(`span`,{"data-subagent-profile":!0,"aria-label":`Sub-agent profile: ${t}`,title:e?.trim()||`The provider did not report this sub-agent's model and effort`,className:`inline-flex min-w-0 max-w-[min(72%,20rem)] items-center rounded-md border border-border/50 bg-transparent px-1.5 py-0.5 text-muted ${yR}`,children:(0,L.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 truncate`,children:t})})}var g4=`font-mono-keep overflow-x-auto whitespace-pre-wrap break-words ${DJ} border border-border bg-bg/75 px-4 py-2.5 text-[12px] leading-relaxed text-fg/85`;function _4({id:e,slug:t,shellId:n,label:r,startedAt:i,depth:a,widthDepth:o}){let s=(0,I.useRef)(null),c=lw(t,n),l=c.data?.state,u=c.data?.command,d=c.data?.output??``,[f,p]=(0,I.useState)(!1),m=Ve();(0,I.useEffect)(()=>{let e=s.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<160&&(e.scrollTop=e.scrollHeight)},[d]);let h=VE(i),g=l===`running`?`running${h?` ${h}`:``}`:l===`done`?`finished`:l===`gone`?`unavailable`:``,_=c.isError||l===`gone`;function v(){f||(p(!0),Y.subAgentStop({slug:t,id:n}).then(({note:e})=>{e?Z(`Background shell stopped. ${e}`,{duration:7e3}):Z(`Background shell stopped — the worker was told`),m.invalidateQueries({queryKey:[`backgroundShellOutput`,t,n]})}).catch(e=>{Z(e instanceof Error?e.message:`Could not stop this background shell`)}).finally(()=>p(!1)))}async function y(){if(u)try{await HR(u),Z(`Command copied`)}catch{Z(`Could not copy command`)}}return(0,L.jsx)(tm,{id:e,depth:a,widthDepth:o,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Th,{title:r,icon:(0,L.jsx)(vh,{"aria-hidden":!0,size:14,className:`shrink-0 text-muted/60`}),meta:g?(0,L.jsx)(`span`,{className:`shrink-0 whitespace-nowrap text-[11.5px] text-muted/60`,children:g}):void 0,onClose:e}),(0,L.jsx)(`div`,{ref:s,className:`min-h-0 flex-1 overflow-y-auto px-5 py-5`,children:_?(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center px-8 text-center text-[13px] text-muted`,children:`Background shell output is no longer available.`}):(0,L.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,L.jsxs)(`section`,{children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,L.jsx)(`h2`,{className:`petite-caps text-[10px] text-muted/65`,children:`Command`}),u&&(0,L.jsxs)(`button`,{type:`button`,onClick:y,className:`flex items-center gap-1 rounded px-1.5 py-1 text-[10.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:[(0,L.jsx)(Am,{"aria-hidden":!0,size:11}),` Copy`]})]}),u?(0,L.jsx)(Jq,{"data-background-shell-command":!0,text:u,language:`bash`,className:g4}):(0,L.jsx)(`pre`,{"data-background-shell-command":!0,className:g4,children:c.isLoading?`Loading…`:`Command unavailable for this background operation.`})]}),(0,L.jsxs)(`section`,{children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,L.jsx)(`h2`,{className:`petite-caps text-[10px] text-muted/65`,children:`Output`}),l===`running`&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--shell`,"data-running-indicator":`shell-drawer`}),c.data?.truncated&&(0,L.jsx)(`span`,{className:`text-[10.5px] text-muted/50`,children:`Showing latest 512 KB`})]}),d?(0,L.jsx)(`pre`,{"data-background-shell-output":!0,className:`font-mono-keep min-h-40 whitespace-pre-wrap break-words ${DJ} border border-border bg-[#090b10] px-4 py-3 text-[12px] leading-relaxed text-fg/85`,children:d}):(0,L.jsx)(`div`,{"data-background-shell-output":!0,className:`flex min-h-40 items-center justify-center ${DJ} border border-border bg-[#090b10] px-4 text-center text-[12px] text-muted/60`,children:l===`done`?`No output was captured.`:`No output yet.`})]})]})}),!_&&c.data?.stoppable&&(0,L.jsx)(`footer`,{"aria-label":`Background shell lifecycle actions`,"data-background-shell-lifecycle-footer":!0,className:`flex min-h-10 w-full shrink-0 items-center justify-end gap-1.5 border-t border-border/70 bg-panel/95 px-3 pt-2 pb-[max(0.5rem,env(safe-area-inset-bottom))] text-[12px] backdrop-blur-sm`,children:(0,L.jsx)(`button`,{type:`button`,"data-stop-background-shell":!0,disabled:f,onClick:v,className:`rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] text-fg/80 transition-colors hover:border-red-400/40 hover:bg-red-400/10 hover:text-red-300 disabled:opacity-50`,children:f?`Stopping…`:`Stop shell`})}),!_&&!c.data?.stoppable&&l===`running`&&c.data?.stopNote&&(0,L.jsx)(`footer`,{"data-background-shell-stop-note":!0,className:`w-full shrink-0 border-t border-border/70 bg-panel/95 px-4 pt-2 pb-[max(0.5rem,env(safe-area-inset-bottom))] text-[11.5px] text-muted/70`,children:c.data.stopNote})]})})}function v4(e){let t=/^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(e);return t?{front:t[1],body:e.slice(t[0].length)}:{front:null,body:e}}var y4={paddingBottom:`max(0.75rem, env(safe-area-inset-bottom))`};function b4({path:e}){return(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{Y.openLocalFile({path:e}).then(async e=>{e.action===`copy`&&(await HR(e.path),Z(`Copied local path`))}).catch(e=>Z(`Could not open local file: ${e.message.slice(0,100)}`))},onMouseDown:e=>e.preventDefault(),className:`flex items-center gap-1.5 rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] font-medium text-fg/80 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,title:`Open ${e} outside Frizz`,"aria-label":`Open`,children:[(0,L.jsx)(Mm,{size:12,"aria-hidden":`true`}),` Open`]})}function x4({source:e}){return(0,L.jsx)(Jq,{text:e,language:`yaml`,className:`mb-4 whitespace-pre-wrap break-words rounded-md border border-border/60 bg-panel-2/40 px-3 py-2 font-mono-keep text-[12px] leading-5 text-muted`})}function S4({id:e,path:t,title:n,depth:r,widthDepth:i}){let a=XC(t),o=nt({...rC(t),refetchInterval:a?!1:iC}),s=o.data?.path??t,{front:c,body:l}=v4(o.data?.markdown??``),u=JK(l,{baseDir:tC(s),asDocument:!0}),d=Nq(u),f=(0,I.useRef)(null);return Kq(f,u),(0,L.jsx)(tm,{id:e,depth:r,widthDepth:i,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Th,{title:n,subtitle:s,onClose:e}),(0,L.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:o.isLoading?(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):o.error?(0,L.jsxs)(`div`,{className:`text-[13px] text-red-400/90`,children:[`Couldn’t read this file: `,o.error.message]}):u?(0,L.jsxs)(L.Fragment,{children:[c&&(0,L.jsx)(x4,{source:c}),(0,L.jsx)(`div`,{ref:f,className:`md-body`,dangerouslySetInnerHTML:d}),o.data?.truncated&&(0,L.jsx)(`p`,{className:`mt-4 border-t border-border/60 pt-3 text-[12px] text-muted`,children:`This file is too long to render in full — everything above the cut is shown. Open it to read the rest.`})]}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`})}),(0,L.jsx)(`div`,{className:`shrink-0 flex items-center justify-end gap-1.5 border-t border-border/60 bg-panel px-5 pt-3`,style:y4,children:(0,L.jsx)(b4,{path:s})})]})})}function C4({id:e,slug:t,title:n,depth:r,widthDepth:i}){let a=nt({queryKey:[`threadBody`,t],queryFn:()=>Y.threadBody({slug:t})}),o=Zt(X);(0,I.useEffect)(()=>{a.refetch()},[o.board]);let s=CX(Gp(o.board,t)),c=Ez(),l=Tz.adopt(c,t),[u,d,f]=Oz(l),p=it({mutationFn:async e=>{await Y.adoptThread({slug:t,message:e.trim()||void 0})},onSuccess:()=>{X.drawers.find(t=>t.id===e)?.closing||(X.drawers=X.drawers.map(t=>t.id===e?{...t,kind:`thread`}:t))},onError:(e,t)=>{Cz.get(l)||d(t),Z(`Start failed: ${e.message.slice(0,80)}`)}}),m=JK(FK(a.data?.markdown??``)),h=Nq(m);return(0,L.jsx)(tm,{id:e,depth:r,widthDepth:i,widthOffset:1,subagentParent:t,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Th,{title:n,subtitle:`${t}.md`,onClose:e}),(0,L.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:a.isLoading?(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):m?(0,L.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:h}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`No thread file found.`})}),s&&(0,L.jsxs)(`div`,{className:`shrink-0 border-t border-border/60 px-5 pb-4 pt-3`,children:[(0,L.jsx)(`p`,{className:`mb-2.5 text-[11.5px] text-muted/80`,children:`No session is attached to this thread yet. Send a message below to start one on this plan.`}),(0,L.jsx)(mR,{surface:`adoptComposer`,value:u,onChange:d,onSubmit:()=>{if(!u.trim()||p.isPending)return;let e=u;f(),Z(`Starting thread…`,{spinner:!0,sticky:!0}),p.mutate(e)},placeholder:`Kick off work on this thread…`,minHeight:44,busy:p.isPending})]})]})})}function w4(){let e=Zt(X),t=qC();(0,I.useEffect)(()=>{function e(e){if(e.key===`Escape`&&!(e.target instanceof Element&&e.target.closest(`.xterm`))){if(RR()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(X.showPalette)X.showPalette=!1;else if(X.showNewThread)X.showNewThread=!1;else if(X.showGithubPicker)up();else if(X.showSettings)pd()||(X.showSettings=!1);else if(X.drawers.length>0){let e=X.drawers[X.drawers.length-1];_d(e.id)||X.drawers.pop()}else X.filePanel&&jp()}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let n=0;return(0,L.jsx)(L.Fragment,{children:e.drawers.map((e,r)=>{let i=n;e.closing||n++;let a=e.kind===`thread`?(0,L.jsx)(d4,{id:e.id,slug:e.slug,depth:r,widthDepth:i,initiallyOpen:e.routed},e.id):e.kind===`subagent`?(0,L.jsx)(p4,{id:e.id,slug:e.slug,subId:e.subId??``,label:e.label??e.slug,subagentType:e.subagentType,startedAt:e.startedAt,depth:r,widthDepth:i},e.id):e.kind===`shell`?(0,L.jsx)(_4,{id:e.id,slug:e.slug,shellId:e.subId??``,label:e.label??`Background shell`,startedAt:e.startedAt,depth:r,widthDepth:i},e.id):e.kind===`markdown`?(0,L.jsx)(S4,{id:e.id,path:e.path??e.slug,title:e.label??e.slug,depth:r,widthDepth:i},e.id):(0,L.jsx)(C4,{id:e.id,slug:e.slug,depth:r,widthDepth:i,title:(()=>{let n=Gp(t,e.slug);return n?CT(n):e.slug})()},e.id);return(0,L.jsx)(Dh,{label:`this drawer`,resetKeys:[e.kind,e.slug,e.subId,e.path],fallback:(t,n)=>(0,L.jsx)(Mh,{id:e.id,depth:r,widthDepth:i,error:t,onRetry:n}),children:a},e.id)})})}function T4(e){return(e.tools??[]).some(e=>e.name===`mcp__frizz__done`&&e.status===`completed`)}function E4(e){let t=iJ(e).filter(e=>e.kind===`question`);if(t.length!==0)return JSON.stringify(t.map(e=>e.kind===`question`?[e.questionKind,e.danger===!0,e.text.trim()]:null))}function D4(e){let t=new Map,n=[];for(let r=0;r<e.length;r++){let i=E4(e[r].text);n.push(i),i!==void 0&&t.set(i,r)}let r=new Set;for(let e=0;e<n.length;e++){let i=n[e];i!==void 0&&t.get(i)!==e&&r.add(e)}return r}function O4(e,t,n){return sJ(e.text)?!n.has(t):T4(e)?!0:e.wake===!0}function k4(e){return e.wake===!0}function A4(e,t){let n=[],r,i=!1,a=()=>{r&&r.start<=r.end&&n.push(r),r=void 0};for(let n=Math.max(0,t);n<e.length;n++){let t=e[n];if(t.closes===!0){a(),i=!0;continue}if(t.skip===!0)continue;if(t.opens===!0){a(),i=!0,r={start:n+1,end:n,open:-1,close:-1,steps:0,tools:0,resumed:!0,waker:-1};continue}let o=r===void 0;r||={start:n,end:n,open:-1,close:-1,steps:0,tools:0,resumed:i,waker:-1},o&&t.completion===!0&&r.resumed&&(r.waker=n),r.end=n,r.tools+=t.tools??0,t.text===!0&&(r.open<0&&(r.open=n),r.close=n)}a();for(let t of n)for(let n=t.start;n<=t.end;n++){let r=e[n];r.skip===!0||r.survives===!0||n===t.open||n===t.close||n===t.waker||r.countable===!0&&t.steps++}return n}function j4(e){return e.open<0||e.tools<1&&e.steps<1?!1:e.resumed||e.open!==e.close}function M4(e){if(e.length<3)return{kept:[...e]};let t=e[0],n=e[e.length-1],r=e.slice(1,-1);return{kept:[t,n],middle:{start:Math.max(t.end+1,r[0].start-1),end:r[r.length-1].end,runs:r.length,tools:r.reduce((e,t)=>e+t.tools,0)}}}function N4(e){return aD(e,`card`).length>0}function P4({slug:e,subAgents:t,className:n=`px-1 pt-1.5`}){let r=aD(t,`card`);return r.length===0?null:(0,L.jsx)(`div`,{"data-queue-subagents":!0,className:`flex min-w-0 flex-col gap-0.5 ${n}`,children:r.map((t,n)=>(0,L.jsx)(cD,{kind:`AGENT`,label:t.label,state:t.state,density:`card`,depth:t.depth,startedAt:t.startedAt,parentSlug:e,onOpen:t.id?()=>vp(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:aM(e,t)},t.id??`${t.startedAt}-${n}`))})}var F4=320;function I4(e){let t=[...document.querySelectorAll(`[data-queue-card]`)],n=t.findIndex(t=>t.dataset.queueCard===e);if(n<0)return null;let r=window.innerHeight,i=e=>{if(!e||e.dataset.queueLeaving===`true`||!e.dataset.queueCard)return!1;let t=e.getBoundingClientRect();return t.bottom>0&&t.top<r},a=i(t[n-1])?t[n-1]:i(t[n+1])?t[n+1]:null;return a?{slug:a.dataset.queueCard,top:a.getBoundingClientRect().top}:null}function L4(e){let t=[...document.querySelectorAll(`[data-queue-card]`)],n=t.findIndex(t=>t.dataset.queueCard===e);if(n<0)return null;let r=e=>e.dataset.queueLeaving!==`true`&&!!e.dataset.queueCard;for(let e=n+1;e<t.length;e++)if(r(t[e]))return t[e].dataset.queueCard;for(let e=n-1;e>=0;e--)if(r(t[e]))return t[e].dataset.queueCard;return null}var R4=0,z4=``;function B4(){R4++===0&&(z4=document.documentElement.style.overflowAnchor,document.documentElement.style.overflowAnchor=`none`)}function V4(){R4>0&&--R4===0&&(document.documentElement.style.overflowAnchor=z4)}function H4({thread:e,onSnooze:t,onSnoozeFailed:n}){return(0,L.jsx)(i1,{thread:e,onSnooze:t,onSnoozeFailed:n})}function U4(){let e=qC(),t=LT(YC(e?.threads??[]).filter(RT),Zt(yT).queueOrder),n=t.map(e=>e.id).join(`,`),[r,i]=(0,I.useState)(()=>new Set),a=(0,I.useRef)(t);a.current=t;let o=(0,I.useRef)(r);o.current=r;let s=new Set(t.map(e=>e.id)),c=(0,I.useRef)([]),l=(0,I.useRef)([]),u=(0,I.useRef)(new Map),d=(0,I.useRef)(new Set),f=(0,I.useRef)(new Set),p=(0,I.useRef)(new Map),m=(0,I.useRef)(new Map),h=(0,I.useRef)(null),[g,_]=(0,I.useState)(0);c.current.forEach(e=>{if(!s.has(e.id)&&!f.current.has(e.id)){let t=l.current.indexOf(e.id);u.current.delete(e.id),u.current.set(e.id,{view:e,index:t>=0?t:l.current.length}),r.has(e.id)&&d.current.add(e.id)}}),c.current=t;for(let e of[...f.current])s.has(e)?r.has(e)||(f.current.delete(e),d.current.delete(e)):r.has(e)||(f.current.delete(e),u.current.delete(e),d.current.delete(e));for(;u.current.size>32;){let e=u.current.keys().next().value;if(e===void 0)break;u.current.delete(e),d.current.delete(e);let t=p.current.get(e);t&&(clearTimeout(t),p.current.delete(e))}let v=e=>s.has(e)?r.has(e):d.current.has(e),y=HH(),b=e=>v(e.id)||VH(e,y[e.id]),x=(0,I.useMemo)(()=>{let e=t.filter(e=>!f.current.has(e.id)),n=[...u.current.entries()].filter(([e])=>!s.has(e)&&!f.current.has(e)).map(([,e])=>e).sort((e,t)=>e.index-t.index);for(let{view:t,index:r}of n)e.splice(Math.min(r,e.length),0,t);return e},[t,r,g]);l.current=x.map(e=>e.id),(0,I.useEffect)(()=>{let e=[...u.current.keys()].filter(e=>!s.has(e)&&!f.current.has(e)),t=e.filter(e=>!d.current.has(e)),n;t.length&&(n=requestAnimationFrame(()=>{t.forEach(e=>{u.current.has(e)&&d.current.add(e)}),_(e=>e+1)}));let i=new Set;for(let e of r)f.current.has(e)||i.add(e);for(let t of e)i.add(t);for(let e of i){if(p.current.has(e))continue;let t=setTimeout(()=>{if(p.current.delete(e),o.current.has(e)){let t=L4(e);h.current=t?{kind:`top`,slug:t}:null}else{let t=I4(e);h.current=t?{kind:`hold`,...t}:null}f.current.add(e),d.current.delete(e),_(e=>e+1)},F4);p.current.set(e,t)}return()=>{n!==void 0&&cancelAnimationFrame(n)}},[n,r,g]),(0,I.useEffect)(()=>{let e=[...r].filter(e=>f.current.has(e)&&!s.has(e));if(e.length!==0){for(let t of e)f.current.delete(t),u.current.delete(t),d.current.delete(t);i(t=>{let n=new Set(t);for(let t of e)n.delete(t);return n})}},[n,g]),(0,I.useEffect)(()=>()=>{for(let e of p.current.values())clearTimeout(e);for(let e of m.current.values())clearTimeout(e)},[]),(0,I.useLayoutEffect)(()=>{let e=h.current;if(!e)return;h.current=null;let t=document.querySelector(`[data-queue-card="${CSS.escape(e.slug)}"]`);if(!t)return;if(e.kind===`hold`){let n=t.getBoundingClientRect().top-e.top;Math.abs(n)>.5&&window.scrollBy({top:n,left:0,behavior:`auto`});return}B4();let n=()=>{let t=sp(e.slug);t!==null&&Math.abs(bd()-t)>.5&&window.scrollTo({top:t,left:0,behavior:`auto`})};n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n(),V4()})})},[g]);let S=(0,I.useCallback)(e=>{i(t=>new Set(t).add(e));let t=m.current.get(e);t&&clearTimeout(t);let n=setTimeout(()=>{m.current.delete(e),a.current.some(t=>t.id===e)&&(f.current.delete(e),d.current.delete(e),i(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),_(e=>e+1))},8e3);m.current.set(e,n)},[]),C=(0,I.useCallback)(e=>{let t=m.current.get(e);t&&(clearTimeout(t),m.current.delete(e));let n=p.current.get(e);n&&(clearTimeout(n),p.current.delete(e)),f.current.delete(e),d.current.delete(e),i(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),_(e=>e+1)},[]),w=(e?.threads.length??0)===0;return(0,L.jsxs)(`div`,{className:`my-auto w-full min-w-0 flex flex-col py-8`,children:[(0,L.jsx)(W4,{board:e}),x.length>0&&(0,L.jsx)(`div`,{className:`flex flex-col`,children:x.map((e,t)=>(0,L.jsxs)(I.Fragment,{children:[(0,L.jsx)(K4,{slug:e.id,leaving:v(e.id),children:(0,L.jsx)(Y4,{thread:e,leaving:v(e.id),frozen:b(e),onResolve:S,onUnresolve:C})}),t<x.length-1&&(0,L.jsx)(`hr`,{className:`my-10 border-0 border-t border-border/60`})]},e.id))}),w?(0,L.jsxs)(`div`,{className:`w-full flex flex-col gap-3`,children:[(0,L.jsx)(`h2`,{className:`text-[15px] font-medium text-center`,children:`What should the agent do?`}),(0,L.jsx)(FH,{}),(0,L.jsx)(Az,{autoFocus:!0})]}):x.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-2 pt-2`,children:[(0,L.jsx)(Km,{size:40,strokeWidth:1.25,className:`text-muted/30`}),(0,L.jsx)(`div`,{className:`text-[13px] text-muted/80`,children:`No threads awaiting human input`})]}):null]})}function W4({board:e}){let t=e?.errorItems??[],n=e?.errors??[];return t.length===0&&n.length===0?null:(0,L.jsxs)(`div`,{className:`mb-6 ${DJ} border border-amber-500/25 bg-amber-500/[0.06] px-4 py-2.5 text-[12px] text-amber-200/90`,children:[(0,L.jsx)(`div`,{className:`font-medium mb-0.5`,children:`Board errors`}),t.length>0?t.slice(0,6).map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5`,children:[(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:`${e.file?`${e.file}: `:``}${e.message}`,children:[e.file?`${e.file}: `:``,e.message]}),e.kind===`no-frontmatter`&&(0,L.jsx)(G4,{file:e.file})]},t)):n.slice(0,3).map((e,t)=>(0,L.jsx)(`div`,{className:`truncate`,title:e,children:e},t))]})}function G4({file:e}){let t=it({mutationFn:()=>Y.repairThread({file:e}),onSuccess:({slug:e})=>Z(`Repaired ${e} — verify its status`),onError:e=>Z(e instanceof Error?e.message:`Repair failed`)});return(0,L.jsx)(`button`,{onClick:()=>t.mutate(),disabled:t.isPending,className:`shrink-0 rounded border border-amber-400/50 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-100 transition-colors hover:bg-amber-500/25 disabled:opacity-50`,title:`Prepend minimal frontmatter (title + status: active) so this thread becomes visible again`,children:t.isPending?`Repairing…`:`Repair`})}function K4({leaving:e,slug:t,children:n}){return(0,L.jsx)(`div`,{"data-queue-card":t,"data-queue-leaving":e,className:`frizz-card-slot min-w-0`,children:(0,L.jsx)(`div`,{className:`frizz-card-clip min-h-0 min-w-0`,children:(0,L.jsx)(`div`,{className:`frizz-card-body min-w-0`,children:n})})})}function q4({runs:e,toolCount:t,onExpand:n}){let r=t>0?`${t} tool call${t===1?``:`s`}`:``,i=`${e} more round${e===1?``:`s`}`;return(0,L.jsxs)(xY,{icon:xm,marker:`middle-runs-summary`,onClick:n,ariaLabel:`Expand ${i}${r?` and ${r}`:``} of intermediate agent activity`,children:[(0,L.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:i}),r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,L.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:r})]}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,L.jsx)(`span`,{className:`shrink-0`,children:`Click to expand`})]})}function J4({toolCount:e,onExpand:t}){let n=e>0?`${e} tool call${e===1?``:`s`}`:``;return(0,L.jsxs)(xY,{icon:xm,marker:`intermediate-summary`,onClick:t,ariaLabel:`Expand ${n?`${n} of `:``}intermediate agent activity`,children:[n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:n}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`})]}),(0,L.jsx)(`span`,{className:`shrink-0`,children:`Click to expand`})]})}var Y4=(0,I.memo)(function({thread:e,leaving:t,frozen:n,onResolve:r,onUnresolve:i}){let a=Zt(X),[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(0),v=(0,I.useRef)(null),y=(0,I.useRef)(null),b=(0,I.useRef)(!1),x=(0,I.useRef)(!1),S=(0,I.useRef)(null),C=Ve(),w=v1(e.id),T=sw(e.id,{poll:!1}),E=(0,I.useRef)(T.data);n||(E.current=T.data);let D=n?E.current:T.data,O=(0,I.useRef)(null),k=(0,I.useRef)(0);(0,I.useEffect)(()=>{let e=O.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(t=>{if(e.style.height)return;let n=t[0]?.borderBoxSize?.[0];n&&(k.current=n.blockSize)});return t.observe(e),()=>t.disconnect()},[]),(0,I.useLayoutEffect)(()=>{let e=O.current;if(e){if(!t){e.style.height=``,e.style.overflow=``;return}k.current>0&&(e.style.height=`${k.current}px`,e.style.overflow=`hidden`)}});let A=(0,I.useMemo)(()=>D?.messages??[],[D]),j=(0,I.useMemo)(()=>r2(A),[A]),M=e=>j>=0&&e<j,N=t1(e),P=e=>M(e)||e===j&&N,ee=(0,I.useMemo)(()=>iY(A),[A]),F=(0,I.useMemo)(()=>vX(A),[A]),te=(0,I.useMemo)(()=>{for(let e=A.length-1;e>=0;e--)if(A[e].boundary===`rest`)for(let t=e+1;t<A.length;t++){let n=A[t];if(!(n.queued||n.boundary===`rest`||n2(n,P(t))))return e+1}return 0},[A]),ne=(0,I.useMemo)(()=>{for(let e=A.length-1;e>=0;e--)if(A[e].role===`user`&&!A[e].queued)return e;return-1},[A]),re=(0,I.useMemo)(()=>D4(A),[A]),ie=(0,I.useMemo)(()=>A.map((e,t)=>{if(!e||e.queued||n2(e,P(t)))return{skip:!0};if(e.boundary===`rest`)return{skip:!0,closes:!0};let n=BZ(e),r=n?0:e.tools.length;return{text:o2(e,P(t)),tools:r,countable:o2(e,P(t))||r>0||n!==void 0||e.kind!==void 0,survives:O4(e,t,re),opens:k4(e),completion:e.boundary===`wake`||n!==void 0}}),[A,re]),ae=(0,I.useMemo)(()=>A4(ie,F+1),[ie,F]),{kept:oe,middle:se}=(0,I.useMemo)(()=>M4(ae),[ae]),ce=(0,I.useMemo)(()=>oe.filter(j4),[oe]),le=(0,I.useMemo)(()=>{let e=new Map;return ce.forEach((t,n)=>{for(let r=t.start;r<=t.end;r++)e.set(r,n)}),e},[ce]),ue=!c&&(ne>=0||te>0)&&(ce.length>0||se!==void 0),de=Ox(A,f,F),fe=(0,I.useMemo)(()=>A.slice(de),[A,de]),pe=(0,I.useMemo)(()=>H1(fe).map(e=>({...e,messageIndex:e.messageIndex+de})),[fe,de]),me=(0,I.useMemo)(()=>yY(A,e?.questions??[]),[A,e?.questions]),he=(0,I.useMemo)(()=>{let t=[],n=new Map,r=A.length-1,i=e.runtime!==`running`&&e.runtime!==`spawning`,a=(e?.questions??[]).filter(e=>!me.placedIds.has(e.id));for(let[e,o]of cY(A,a,{atRest:i})){if(e>=r){t.push(...o);continue}let i=n.get(e);i?i.push(...o):n.set(e,[...o])}return{byAnchor:n,tail:t}},[A,me.placedIds,e.runtime,e?.questions]),ge=Xl(e.spawnedAt),_e=(0,I.useMemo)(()=>dY(A,e?.questions??[]),[A,e?.questions]),ve=(0,I.useMemo)(()=>$J(A,e.answersInFlight),[A,e.answersInFlight]),ye=de>0||D?.hasEarlier===!0;(0,I.useLayoutEffect)(()=>{let e=y.current,t=v.current;if(!e||!t||![...t.querySelectorAll(`[data-transcript-source-id]`)].some(t=>t.dataset.transcriptSourceId===e.targetStartId))return;let n=()=>{Fx(t,e.anchor,e=>{e!==0&&window.scrollBy({top:e,left:0,behavior:`auto`})});let n=0;return Fx(t,e.anchor,e=>{n=e}),n},r=n();if(Ix({remaining:r,scrollY:window.scrollY,maxScrollY:Math.max(0,document.documentElement.scrollHeight-window.innerHeight),alreadyReserved:e.reserved===!0})===`reserve`){e.reserved=!0,_(e=>e+Math.ceil(r));return}x.current||(x.current=!0,requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n(),y.current=null,x.current=!1,b.current&&(b.current=!1,V4())})}))},[g,A,f]),(0,I.useEffect)(()=>{let e=D?.transcriptKey;if(!e)return;let t=S.current;S.current=e,!(!t||t===e)&&(p(null),_(0),l(!1),y.current=null,x.current=!1,b.current&&(b.current=!1,V4()))},[D?.transcriptKey]),(0,I.useEffect)(()=>()=>{b.current&&(b.current=!1,V4())},[]);let be=e=>{let t=Nx(v.current);!e||!t||(b.current||(b.current=!0,B4()),y.current={anchor:t,targetStartId:e})},xe=async()=>{if(m||!ye)return;let t=Dx(A,de),n=t!==null&&A[t]?.role===`user`?t:null;if(n!==null){let e=A[n].sourceId;be(e),p(e??null);return}let r=D?.beforeCursor;if(!r){if(de>0){let e=A[0]?.sourceId;be(e),p(e??null)}return}let i=D?.transcriptKey;if(i){h(!0);try{let t=await Y.threadTranscriptEarlier({slug:e.id,cursor:r}),n=C.getQueryData([`transcript`,e.id]);if(!n?.transcriptKey||n.transcriptKey!==i||t.transcriptKey!==i){await T.refetch(),p(null),Z(`Transcript changed while loading history; refreshed the current session`);return}let a=t.messages[0]?.sourceId??A[0]?.sourceId;be(a);let o=Mx(n,t);C.setQueryData([`transcript`,e.id],o),p(a??null)}catch(e){await T.refetch(),p(null),Z(e instanceof Error?e.message:`Could not load earlier transcript history`)}finally{h(!1)}}},Se=it({mutationFn:()=>Y.markComplete({slug:e.id})}),{answeringForMessage:Ce,answerable:we,anyAnswered:Te,sendAnswers:Ee,sendMessage:De}=eX(e.id,A,()=>{document.activeElement?.blur(),r(e.id)},{scrollToBottom:!1,onSendFailed:()=>i(e.id)}),Oe=(0,I.useMemo)(()=>{let e=QY(A);return e!==-1&&gY(A[e].text,_e.get(e)??[])},[A,_e]),ke=ge&&(we&&!Oe||Te),Ae=(0,I.useCallback)(()=>r(e.id),[r,e.id]),je=(0,I.useCallback)(()=>i(e.id),[i,e.id]),Me=(0,I.useMemo)(()=>({dismiss:Ae,cancel:je}),[Ae,je]);return(0,L.jsx)(w0.Provider,{value:e.id,children:(0,L.jsx)(D0.Provider,{value:Me,children:(0,L.jsx)(u$,{thread:e,children:(0,L.jsxs)(`div`,{ref:O,"data-queue-card-root":e.id,"data-queue-leaving":t,style:{...g?{marginBottom:g}:null,...a.vtReturnTarget===e.id?{viewTransitionName:`thread-chat`}:null},onKeyDown:e=>{if(!Te)return;let t=e.target;t instanceof HTMLButtonElement||t instanceof HTMLAnchorElement||t instanceof HTMLTextAreaElement&&t.value.trim()||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(),Ee())},"data-vt-chat":!0,className:`flex flex-col min-w-0 max-w-full ${DJ} border border-border-strong bg-panel shadow-lg shadow-black/25 transition-opacity ${u?`opacity-40`:``}`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,L.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 bg-panel px-5 py-3.5 max-[800px]:top-10 ${o?DJ:`${OJ} border-b border-border/60`}`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`group/thread-title flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`min-w-0 shrink truncate font-semibold text-[15px] leading-snug`,title:CT(e),children:CT(e)}),(0,L.jsx)(FZ,{thread:e})]}),(0,L.jsx)(l1,{at:PT(e),fallbackAt:e.spawnedAt,className:`mt-0.5 block truncate text-[11px] leading-tight text-muted/75`}),e.statusText&&e.status===`needs-human`&&(0,L.jsx)(`div`,{className:`text-[11px] text-muted/80 mt-0.5 truncate`,title:e.statusText,children:e.statusText})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[e.kind===`session`&&e.foreign!==!0&&(0,L.jsx)(y1,{slug:e.id}),(0,L.jsx)(eZ,{thread:e,collapsed:o,onCollapse:()=>s(e=>!e),expand:!0,onDone:()=>Se.mutate(void 0,{onSuccess:()=>r(e.id),onError:()=>d(!1)}),doneBusy:Se.isPending,onStatusMutate:()=>d(!0),onStatusApplied:()=>r(e.id),onStatusFailed:()=>d(!1)})]})]}),o?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`px-5 pt-5 ${ke?`pb-2`:`pb-5`}`,children:[A.length===0?(0,L.jsx)(`p`,{className:`text-[13px] text-muted`,children:T.isLoading?`Loading…`:e.statusText||`No message yet.`}):(0,L.jsxs)(`div`,{ref:v,className:`flex flex-col`,children:[ye&&(0,L.jsx)(`button`,{className:`mb-3.5 self-center rounded-md border border-border px-2 py-0.5 text-[11px] text-muted transition-colors hover:text-fg hover:bg-panel-2 outline-none`,onClick:()=>void xe(),onMouseDown:e=>e.preventDefault(),disabled:m,children:m?`Loading earlier messages…`:D?.reachedTurnBoundary===!1?`Continue loading this turn`:`Load earlier messages`}),(()=>{let t=de,n=[],r=null,i=[...he.byAnchor.entries()].sort((e,t)=>e[0]-t[0]),a=t=>{for(;i.length>0&&i[0][0]<=t;){let[t,a]=i.shift();r!==null&&n.push((0,L.jsx)(bY,{h:14},`qa-space-${t}`)),n.push((0,L.jsx)(f$,{thread:e,questions:a},`qa-${t}`)),r=!1}};a(t-1);let o=new Set,s=!1;return pe.forEach(({message:t,messageIndex:i},c)=>{if(t.queued||n2(t,P(i))||t.boundary===`rest`)return;if(ue&&se&&i>=se.start&&i<=se.end){s||(s=!0,r!==null&&n.push((0,L.jsx)(bY,{h:14},`middle-runs-space`)),n.push((0,L.jsx)(q4,{runs:se.runs,toolCount:se.tools,onExpand:()=>l(!0)},`middle-runs-summary`)),r=!1);return}let u=ue?le.get(i):void 0,d=u===void 0?void 0:ce[u],f=d!==void 0,p=d!==void 0&&i===d.open,m=d!==void 0&&i===d.close,h=f&&!p&&!m&&!sJ(t.text)&&!T4(t)&&O4(t,i,re);if(d!==void 0&&i===d.waker){r!==null&&n.push((0,L.jsx)(bY,{h:r&&X0(t)?6:14},`s${c}`));let e=t.sourceId??`legacy-${i}`;n.push((0,L.jsx)(`div`,{"data-transcript-source-id":e,className:`flex flex-col`,children:(0,L.jsx)(U2,{m:t,dense:!0})},e)),r=Y0(t);return}if(f&&!h){if(!p&&!m&&!O4(t,i,re)||(!p&&u!==void 0&&!o.has(u)&&(r!==null&&n.push((0,L.jsx)(bY,{h:14},`im-space-${u}`)),n.push((0,L.jsx)(J4,{toolCount:d.tools,onExpand:()=>l(!0)},`intermediate-summary-${u}`)),r=!1,o.add(u)),!o2(t,P(i))))return;r!==null&&n.push((0,L.jsx)(bY,{h:14},`s${c}`));let s=t.sourceId??`legacy-${i}`;n.push((0,L.jsx)(`div`,{"data-transcript-source-id":s,className:`flex flex-col`,children:(0,L.jsx)(U2,{m:t,dense:!0,textOnly:!0,answering:ge?Ce(t):void 0,paired:ee[i],staleAwaiting:M(i),restingCardShown:i===j&&N,shadowedBy:_e.get(i),placed:me.placed.get(i),thread:e})},s)),r=!1,a(i);return}r!==null&&n.push((0,L.jsx)(bY,{h:r&&X0(t)?6:14},`s${c}`));let g=t.sourceId??`legacy-${i}`;n.push((0,L.jsx)(`div`,{"data-transcript-source-id":g,className:`flex flex-col`,children:(0,L.jsx)(U2,{m:t,dense:!0,staleAwaiting:M(i),restingCardShown:i===j&&N,answering:ge?Ce(t):void 0,paired:ee[i],shadowedBy:_e.get(i),placed:me.placed.get(i),thread:e})},g)),r=Y0(t),a(i)}),fe.forEach((e,r)=>{e.queued&&(n.push((0,L.jsx)(bY,{},`qs${r}`)),n.push((0,L.jsx)(U2,{m:e,dense:!0,paired:ee[t+r]},`q${t+r}`)))}),n})()]}),!T.isLoading&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(zQ,{thread:e,className:`mt-4`}),e.pendingInteraction?null:e.pendingAsk?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(n4,{ask:e.pendingAsk,onTerminal:w})}):e.runtime===`perm-prompt`?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)($2,{onTerminal:w})}):null,e.permPolicy?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(e4,{policy:e.permPolicy,denies:e.permDenies})}):null]}),!T.isLoading&&t1(e)&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(H4,{thread:e,onSnooze:Ae,onSnoozeFailed:je})}),!T.isLoading&&TJ(e,j>=0?A[j]?.text:void 0)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(bY,{}),(0,L.jsx)(X2,{fenceKind:`done`,body:e.lastFence.body,hints:[],wrap:!0})]}),!T.isLoading&&e.limitPause&&e.foreign!==!0&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(Q2,{slug:e.id,sessionId:e.sessionId,pause:e.limitPause})}),!T.isLoading&&BJ(e,j>=0?A[j]?.text:void 0)&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(VJ,{thread:e})})]}),(0,L.jsx)(f$,{thread:e,questions:he.tail,inFlight:ve,showSend:me.placedIds.size>0,className:`shrink-0 px-5 pb-4 pt-0`}),ke&&(0,L.jsx)(`div`,{className:`shrink-0 px-5 pt-0`,children:(0,L.jsx)(`div`,{className:`mb-4 flex items-center justify-start gap-2`,children:(0,L.jsx)(`button`,{disabled:!Te,onClick:()=>Ee(),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`})})}),(0,L.jsx)(qX,{slug:e.id,surface:`queueComposer`,className:`shrink-0 px-5 pb-3 pt-0`,placeholder:we||(e.questions?.length??0)>0?`Or skip the questions and reply…`:`Reply to the agent…`,submitOverride:De,ops:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(P4,{slug:e.id,subAgents:e.subAgents??[],className:`px-1 pt-1.5`}),(0,L.jsx)(t4,{slug:e.id,includeAgents:!1,className:`px-1 ${N4(e.subAgents??[])?`pt-0.5`:`pt-1.5`}`})]})})]})]}),(0,L.jsx)(AZ,{thread:e,onArchived:()=>r(e.id),onDismissCancel:()=>i(e.id),onSnoozed:()=>r(e.id)})]})})})})},X4);function X4(e,t){return e.leaving===t.leaving&&e.frozen===t.frozen&&e.onResolve===t.onResolve&&e.onUnresolve===t.onUnresolve&&(e.thread===t.thread||JSON.stringify(e.thread)===JSON.stringify(t.thread))}function Z4(e,t){if(e.backend===`claude`)return ez.some(t=>t.value===e.model)?az(e.model).includes(e.effort)?void 0:`Reasoning level ${e.effort} is not available for ${e.model}`:`Claude model ${e.model} is no longer available`;let n=t.find(t=>t.slug===e.model);if(!n)return`Codex model ${e.model} is no longer available`;if(!n.efforts.includes(e.effort))return`Reasoning level ${e.effort} is not available for ${e.model}`}function Q4(e,t){return{items:t.map(e=>({...e})),backend:e.backend,model:e.model,effort:e.effort}}function $4({keys:e,key:t,shiftKey:n,anchor:r,selected:i}){let a=e.indexOf(t),o=r===null?-1:e.indexOf(r);if(!n||a===-1||o===-1||r===null){let e=new Set(i);return e.has(t)?e.delete(t):e.add(t),{selected:e,anchor:a===-1?r:t}}let s=a>=o?1:-1,c=i.has(r),l=new Set(i);for(let t=o;;t+=s){let n=e[t];if(c?l.add(n):l.delete(n),t===a)break}return{selected:l,anchor:r}}var e3=30;function t3({onClose:e}){let t=gR(),{resolved:n,codexList:r,loadError:i,saveProfile:a}=pz(),[o,s]=(0,I.useState)(`issues`),[c,l]=(0,I.useState)(`recent`),[u,d]=(0,I.useState)(1),[f,p]=(0,I.useState)(()=>new Set),[m,h]=(0,I.useState)(null),g=nt({queryKey:[`githubList`,o,c,u],queryFn:()=>Y.githubList({kind:o,sort:c,page:u,perPage:e3}),placeholderData:ee}),_=g.data?.items??[],v=g.data?.page??u,y=g.data?.pageCount??1,b=g.data?.total??0,x=(0,I.useRef)(null);(0,I.useEffect)(()=>{x.current&&(x.current.scrollTop=0)},[u,o,c]);let S=it({mutationFn:e=>Y.githubDispatchBatch(e),onMutate:e=>Z(`Starting ${e.items.length} thread${e.items.length===1?``:`s`}…`,{spinner:!0,sticky:!0}),onSuccess:t=>{let n=t.dispatched.length,r=t.failed.length;Z(`Started ${n} thread${n===1?``:`s`}${r?` (${r} failed)`:``}`),e()},onError:e=>Z(`Dispatch failed: ${e.message.slice(0,80)}`)});function C(e){e!==o&&(s(e),d(1),p(new Set),h(null))}function w(e){e!==c&&(l(e),d(1),p(new Set),h(null))}function T(e,t){let n=$4({keys:_.map(e=>e.number),key:e,shiftKey:t,anchor:m,selected:f});p(n.selected),h(n.anchor)}function E(){p(new Set),h(null)}let D=t.data?.nameWithOwner??`this repo`,O=f.size,k=(0,I.useMemo)(()=>dz(r),[r]),A=n?{backend:n.backend,model:n.model,effort:n.effort}:void 0,j=A?Z4(A,r):i?`Could not load the model catalogue — reopen once it loads`:void 0,M=j??(A?void 0:`Loading the model catalogue…`);function N(){if(!A||M){Z(M??`Choose a model and reasoning level`);return}S.mutate(Q4(A,[...f].map(e=>({kind:o===`issues`?`issue`:`pr`,number:e}))))}return(0,L.jsx)(Mz,{onClose:e,children:(0,L.jsxs)(`div`,{className:`flex max-h-[85vh] w-[720px] max-w-[90vw] flex-col rounded-xl border border-border bg-panel p-5 shadow-2xl shadow-black/50`,onKeyDownCapture:t=>{t.key===`Escape`&&(t.stopPropagation(),e())},children:[(0,L.jsxs)(`h2`,{className:`mb-4 flex items-center gap-2 text-[14px] font-medium`,children:[(0,L.jsx)(Hm,{size:15,className:`text-muted`}),(0,L.jsx)(`span`,{children:`Investigate this issue and make recommendations`}),(0,L.jsx)(`span`,{className:`text-muted/40`,children:`—`}),(0,L.jsx)(`span`,{className:`font-mono-keep text-[12.5px] text-muted`,children:D})]}),(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,L.jsx)(r3,{value:o,onChange:e=>C(e),options:[{value:`issues`,label:`Issues`},{value:`prs`,label:`PRs`}]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`petite-caps text-[11px] text-muted/70`,children:`Sort`}),(0,L.jsx)(r3,{value:c,onChange:w,options:[{value:`recent`,label:`Recent`},{value:`reactions`,label:`Reactions`}]})]})]}),(0,L.jsx)(`div`,{ref:x,className:`min-h-[240px] flex-1 overflow-y-auto rounded-lg border border-border/70 bg-bg/40 transition-opacity ${g.isPlaceholderData?`opacity-40`:``}`,children:g.isLoading?(0,L.jsx)(f3,{}):g.isError?(0,L.jsxs)(p3,{children:[(0,L.jsxs)(`span`,{className:`text-[12.5px] text-muted/80`,children:[`Couldn't load `,o===`issues`?`issues`:`pull requests`,`.`]}),(0,L.jsx)(`span`,{className:`max-w-[80%] text-center text-[11px] text-muted/45`,children:g.error.message.slice(0,140)})]}):_.length===0?(0,L.jsxs)(p3,{children:[(0,L.jsx)(Km,{size:28,strokeWidth:1.25,className:`text-muted/30`}),(0,L.jsxs)(`span`,{className:`text-[12.5px] text-muted/60`,children:[`No open `,o===`issues`?`issues`:`pull requests`]})]}):_.map(e=>(0,L.jsx)(o3,{item:e,checked:f.has(e.number),onActivate:t=>T(e.number,t)},e.number))}),!g.isLoading&&!g.isError&&(0,L.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between gap-3 whitespace-nowrap text-[11.5px] text-muted/60`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsxs)(`span`,{className:`truncate tabular-nums`,children:[b,` open `,o===`issues`?b===1?`issue`:`issues`:b===1?`pull request`:`pull requests`]}),O>0&&(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`text-muted/30`,children:`·`}),(0,L.jsxs)(`span`,{className:`tabular-nums text-fg/70`,children:[O,` selected`]}),(0,L.jsx)(`button`,{onClick:E,onMouseDown:e=>e.preventDefault(),className:`rounded py-0.5 text-muted/60 underline-offset-2 outline-none transition-colors hover:text-fg hover:underline`,children:`Clear`})]})]}),y>1&&(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,L.jsx)(n3,{label:`Previous page`,disabled:v<=1,onClick:()=>d(Math.max(1,v-1)),children:(0,L.jsx)(vm,{size:14})}),(0,L.jsxs)(`span`,{className:`relative px-2 text-center tabular-nums`,children:[(0,L.jsxs)(`span`,{"aria-hidden":!0,className:`invisible`,children:[`Page `,y,` of `,y]}),(0,L.jsxs)(`span`,{className:`absolute inset-0`,children:[`Page `,v,` of `,y]})]}),(0,L.jsx)(n3,{label:`Next page`,disabled:v>=y,onClick:()=>d(Math.min(y,v+1)),children:(0,L.jsx)(ym,{size:14})})]})]}),(0,L.jsxs)(`div`,{className:`mt-4 flex items-end justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(VR,{groups:k,value:n?{provider:n.backend,model:n.model,effort:n.effort}:void 0,onValueChange:e=>a({field:`profile`,backend:e.provider,model:e.model,effort:e.effort}),placeholder:i?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort`,title:M??`Model and reasoning effort for every thread this batch starts`,disabled:!n,side:`top`,menuZClass:$j,className:`max-w-[min(21rem,60vw)]`}),j&&(0,L.jsx)(`p`,{className:`mt-1 max-w-[430px] text-[10.5px] text-red-400`,children:j})]}),(0,L.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,L.jsxs)(`button`,{disabled:O===0||S.isPending||!!M,onClick:N,onMouseDown:e=>e.preventDefault(),className:`flex items-center gap-2 rounded-md bg-fg px-3.5 py-1.5 text-[12.5px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:[S.isPending&&(0,L.jsx)(Xm,{size:13,className:`animate-spin`}),O<=1?`Start investigation`:`Start ${O} investigations`]})})]})]})})}function n3({label:e,disabled:t,onClick:n,children:r}){return(0,L.jsx)(`button`,{type:`button`,"aria-label":e,title:e,disabled:t,onClick:n,onMouseDown:e=>e.preventDefault(),className:`inline-flex h-[22px] w-[22px] items-center justify-center rounded-md border border-border/70 text-muted/70 outline-none transition-colors hover:border-border hover:bg-elevated hover:text-fg disabled:pointer-events-none disabled:opacity-30`,children:r})}function r3({value:e,onChange:t,options:n}){return(0,L.jsx)(`div`,{className:`inline-flex items-center gap-0.5 rounded-lg border border-border bg-panel-2 p-0.5`,children:n.map(n=>(0,L.jsx)(`button`,{onClick:()=>t(n.value),onMouseDown:e=>e.preventDefault(),className:`rounded-md px-3 py-1 text-[12px] font-medium outline-none transition-colors ${e===n.value?`bg-elevated text-fg shadow-sm shadow-black/20`:`text-muted hover:text-fg`}`,children:n.label},n.value))})}function i3({item:e}){let t=(e.state??`OPEN`).toUpperCase();return e.kind===`pr`?t===`MERGED`?(0,L.jsx)(Rm,{size:15,className:`shrink-0`,style:{color:UE.fgDone}}):t===`CLOSED`?(0,L.jsx)(zm,{size:15,className:`shrink-0`,style:{color:UE.fgDanger}}):e.isDraft?(0,L.jsx)(Bm,{size:15,className:`shrink-0`,style:{color:UE.fgNeutral}}):(0,L.jsx)(Vm,{size:15,className:`shrink-0`,style:{color:UE.fgSuccess}}):t===`CLOSED`?(0,L.jsx)(Cm,{size:15,className:`shrink-0`,style:{color:UE.fgDone}}):(0,L.jsx)(Tm,{size:15,className:`shrink-0`,style:{color:UE.fgSuccess}})}function a3({name:e,color:t}){let n=/^[0-9a-fA-F]{6}$/.test(t)?`#${t}`:void 0;return(0,L.jsx)(`span`,{className:`max-w-[130px] shrink-0 truncate rounded-full border px-1.5 py-px text-[9.5px] leading-[13px]`,style:n?{borderColor:`${n}59`,color:n,backgroundColor:`${n}14`}:void 0,title:e,children:e})}function o3({item:e,checked:t,onActivate:n}){let r=mE(e.createdAt)??``,i=[e.author,r?`opened ${r}`:``].filter(Boolean).join(` `);return(0,L.jsxs)(`div`,{role:`button`,tabIndex:0,"data-row-number":e.number,"aria-pressed":t,onClick:e=>n(e.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n(e.shiftKey))},className:`group flex w-full cursor-pointer items-start gap-2.5 border-b border-border/40 px-3 py-2.5 text-left outline-none transition-colors last:border-b-0 hover:bg-white/[0.03]`,children:[(0,L.jsx)(`span`,{className:`mt-px shrink-0`,children:(0,L.jsx)(s3,{checked:t})}),(0,L.jsx)(`span`,{className:`mt-px`,children:(0,L.jsx)(i3,{item:e})}),(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,onClick:e=>e.stopPropagation(),title:e.title,className:`min-w-0 truncate text-[13px] font-medium text-fg/90 hover:underline`,children:e.title}),e.labels.slice(0,4).map(e=>(0,L.jsx)(a3,{name:e.name,color:e.color},e.name))]}),(0,L.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-muted/55`,children:[(0,L.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,onClick:e=>e.stopPropagation(),className:`shrink-0 tabular-nums hover:text-muted hover:underline`,children:[`#`,e.number]}),i?(0,L.jsxs)(`span`,{className:`truncate`,children:[`· `,i]}):null]})]}),(0,L.jsxs)(`span`,{className:`mt-px flex shrink-0 items-center gap-2.5 text-[11.5px] text-muted/70`,children:[e.linkedPrs?(0,L.jsx)(u3,{prs:e.linkedPrs}):null,e.comments?(0,L.jsx)(d3,{icon:eh,n:e.comments,label:`comments`}):null,e.reactions?(0,L.jsx)(d3,{emoji:`👍`,n:e.reactions,label:`reactions`}):null]})]})}function s3({checked:e}){return(0,L.jsx)(`span`,{className:`inline-flex h-[15px] w-[15px] items-center justify-center rounded-[4px] border transition-colors ${e?`border-fg bg-fg`:`border-muted/45 group-hover:border-muted/80`}`,children:e&&(0,L.jsx)(gm,{size:11,strokeWidth:3,className:`text-bg`})})}var c3={octicon:`-0.1em`,stroke:`-0.112em`};function l3({size:e=12,className:t}){return(0,L.jsx)(`svg`,{viewBox:`0 0 16 16`,width:e,height:e,fill:`currentColor`,"aria-hidden":!0,className:t,style:{transform:`translateY(${c3.octicon})`},children:(0,L.jsx)(`path`,{d:`M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z`})})}function u3({prs:e}){let t=e.state.toUpperCase()===`MERGED`,n=e.count>1?`${e.count} linked pull requests — `:``,r=t?`#${e.number} merged`:e.isDraft?`#${e.number} open (draft)`:`#${e.number} open`;return(0,L.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,onClick:e=>e.stopPropagation(),title:`${n}${r}`,className:`inline-flex items-center gap-1 tabular-nums hover:text-fg/90`,children:[(0,L.jsx)(l3,{size:12}),e.count]})}function d3({icon:e,emoji:t,n,label:r}){return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 tabular-nums`,title:`${n} ${r}`,children:[t?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`text-[11px] leading-none`,children:t}):e?(0,L.jsx)(`span`,{className:`inline-flex`,style:{transform:`translateY(${c3.stroke})`},children:(0,L.jsx)(e,{size:12,strokeWidth:2})}):null,n]})}function f3(){return(0,L.jsx)(`div`,{className:`animate-pulse`,children:Array.from({length:6}).map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border/40 px-3 py-2.5 last:border-b-0`,children:[(0,L.jsx)(`span`,{className:`h-[15px] w-[15px] shrink-0 rounded-[4px] bg-muted/20`}),(0,L.jsx)(`span`,{className:`h-3 w-8 shrink-0 rounded bg-muted/20`}),(0,L.jsx)(`span`,{className:`h-3 flex-1 rounded bg-muted/15`,style:{maxWidth:`${55+t*7%35}%`}})]},t))})}function p3({children:e}){return(0,L.jsx)(`div`,{className:`flex h-full min-h-[240px] flex-col items-center justify-center gap-1.5`,children:e})}var m3=`default`;function h3(e){return e>=1e6?`${g3(e/1e6)}M`:e>=1e3?`${g3(e/1e3)}K`:String(e)}function g3(e){return Number.isInteger(e)?String(e):e.toFixed(2).replace(/0+$/,``).replace(/\.$/,``)}var _3=[{value:872e3,models:[]}];function v3(e,t){let n=e??[],r=n.find(e=>e.contextWindow!==void 0),i=r?`Model default (${h3(r.contextWindow)} on ${r.displayName})`:`Model default`,a=new Map;for(let e of n)e.maxContextWindow===void 0||e.contextWindow===void 0||e.maxContextWindow<=e.contextWindow||a.set(e.maxContextWindow,[...a.get(e.maxContextWindow)??[],e.displayName]);let o=a.size?[...a.entries()].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({value:e,models:t})):_3,s=[{value:m3,label:i}];for(let e of o){let t=o.length===1||e.models.length===0?`model maximum`:`${e.models.join(`, `)} maximum`;s.push({value:String(e.value),label:`${h3(e.value)} tokens (${t})`})}return t!==void 0&&!s.some(e=>e.value===String(t))&&s.push({value:String(t),label:`${h3(t)} tokens`}),s}var y3={permissionMode:`The permission mode new Claude Code threads launch with. Auto runs safe actions and asks you to approve the risky ones in the thread. Bypass launches the worker with --dangerously-skip-permissions: it never asks, so nothing waits on you and nothing is checked either. Takes effect on the next thread you dispatch; to change a thread that already exists, use the picker beside its model in the prompt box. Codex threads always run with full workspace access and are unaffected.`,promptCacheTtl:`Which prompt-cache tier a new Claude thread writes to. A 1-hour entry costs twice the input price to write, a 5-minute entry 1.25 times; the hour only pays off when the thread's cache actually survives that long. Measured 2026-09-03: cache writes were half of a day's spend and the entries were lost every 15 to 30 minutes regardless, so 5 minutes was the cheaper tier. Automatic leaves the choice to Claude Code, which picks 1 hour on a subscription. Takes effect on the next thread you dispatch and on a thread that resumes after its worker exited.`,autoCompactWindow:`How large a new Claude thread's conversation may grow, in tokens, before Claude Code compacts it. Frizz launches every Claude thread with the 1M context window, so without a ceiling a long thread keeps re-sending everything it has read on every turn; 500K halves that at the cost of an earlier summary. Takes effect on the next thread you dispatch and on a thread that resumes after its worker exited; a thread whose worker is already running keeps its current ceiling. A thread's context dial reads against the ceiling it was launched with, not the model's full window.`,codexContextWindow:`How much context a new Codex thread runs with, in tokens. The presets are the numbers in Codex's own model catalogue: the default model's stock window, and each larger window a listed model accepts (872K on GPT-5.6 and GPT-6; the model's 1M total minus the 128K it reserves for its reply). Codex compacts at 90% of whatever window the thread has, so a larger window is also a later compaction and a larger prompt re-sent on every turn. A model that does not accept the value keeps its own window (GPT-5.5 stays at 272K). Takes effect on the next thread you dispatch and on a thread Codex picks back up after a restart; a thread its app-server already holds keeps its current window. A thread's context dial reads the usable 95% of the window (828K for 872K).`,font:`Changes the interface reading font for this browser.`,localFileOpener:`Chooses how vetted local artifact links open. Markdown files open in Frizz's own reader (which carries an Open action that uses this setting), and image clicks always use the OS default viewer.`,density:`How much of a diff shows before you ask for it, in this browser. Compact collapses every diff to its header row (click one to open it); Comfortable shows them in full. Applies immediately.`,queueOrder:`Orders the Needs-you queue and the sidebar's rested threads by when each was last active. Oldest first (FIFO, default) surfaces the longest-waiting item first so you cycle through everything; Newest first (LIFO) keeps the most recently active on top. Applies immediately in this browser.`,notifications:`Shows a desktop notification when work needs attention while this window is hidden.`,projectRail:`Shows a permanent column of every project on this machine down the left edge. Off by default: Frizz's home is one board, and a standing list of the others is an easy way to leave the thread you were in. With it off, the home crumb in the status bar is the way back to the projects page.`};function b3(){return typeof Notification>`u`?`unsupported`:Notification.permission}var x3=500,S3=1600,C3=2e3,w3=6;function T3(){let[e,t]=(0,I.useState)(`idle`),n=(0,I.useRef)(null),r=(0,I.useRef)(void 0),i=(0,I.useRef)(Promise.resolve()),a=(0,I.useRef)(0),o=(0,I.useRef)(void 0),s=(0,I.useRef)(0),c=(0,I.useRef)(()=>{}),l=(0,I.useCallback)(()=>{r.current!==void 0&&window.clearTimeout(r.current),r.current=void 0;let e=n.current;e&&(n.current=null,a.current+=1,t(`saving`),i.current=i.current.then(()=>Y.settingsSet(e)).then(e=>{s7.setQueryData([`settingsGet`],e),--a.current,s.current=0,!(a.current>0||n.current)&&(t(`saved`),o.current!==void 0&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>t(`idle`),S3))}).catch(i=>{--a.current,t(`error`),!(n.current||!ff(i)||s.current>=w3)&&(s.current+=1,n.current=e,r.current=window.setTimeout(c.current,C3))}))},[]);c.current=l;let u=(0,I.useCallback)((e,t=!1)=>{if(n.current=e,s.current=0,r.current!==void 0&&window.clearTimeout(r.current),r.current=void 0,!t)return l();r.current=window.setTimeout(l,x3)},[l]);return(0,I.useEffect)(()=>()=>{l(),o.current!==void 0&&window.clearTimeout(o.current)},[l]),{state:e,queue:u,flush:l}}function E3(){let e=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()}),[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(b3()),{state:a,queue:o,flush:s}=T3(),[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let e=requestAnimationFrame(()=>l(!0));return()=>cancelAnimationFrame(e)},[]),(0,I.useEffect)(()=>(fd(p),()=>fd(null)),[]),(0,I.useEffect)(()=>{e.data&&!t&&n(e.data)},[e.data,t]);let f=(0,I.useCallback)((e,t)=>{n(e),o(e,t?.debounce)},[o]);function p(){u||(s(),d(!0),l(!1),window.setTimeout(()=>X.showSettings=!1,Xp()?0:210))}async function m(e){if(t){if(e&&typeof Notification<`u`&&Notification.permission==="default"){let e=await Notification.requestPermission();i(e)}f({...t,notifications:e})}}return(0,L.jsx)(`div`,{className:`${Kp} z-50 flex justify-end ${c?`opacity-100`:`opacity-0`}`,onMouseDown:e=>e.target===e.currentTarget&&p(),children:(0,L.jsxs)(`div`,{className:`${qp} w-[560px] max-w-[94vw] ${c?`translate-x-0`:`translate-x-full`}`,children:[(0,L.jsx)(Th,{title:`Settings`,actions:(0,L.jsx)(D3,{state:a}),onClose:p}),t?(0,L.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-5 flex flex-col gap-6`,children:[(0,L.jsx)(k3,{label:`Font`,help:y3.font,children:(0,L.jsx)(B3,{value:t.font??`mono`,onChange:e=>f({...t,font:e})})}),(0,L.jsx)(k3,{label:`Project sidebar`,help:y3.projectRail,children:(0,L.jsx)(HX,{variant:`bordered`,value:t.projectRail?`shown`:`hidden`,onValueChange:e=>f({...t,projectRail:e===`shown`}),options:[{value:`hidden`,label:`Hidden`},{value:`shown`,label:`Always shown`}],indicatorPosition:`right`,ariaLabel:`Project sidebar`})}),(0,L.jsx)(k3,{label:`Local file links`,help:y3.localFileOpener,children:(0,L.jsx)(HX,{variant:`bordered`,value:t.localFileOpener??`system`,onValueChange:e=>f({...t,localFileOpener:e}),options:[{value:`system`,label:`System default`},{value:`cursor`,label:`Cursor`},{value:`vscode`,label:`VS Code`},{value:`finder`,label:`Reveal in Finder`},{value:`copy`,label:`Copy path`}],indicatorPosition:`right`,ariaLabel:`Local file link opener`})}),(0,L.jsx)(k3,{label:`Density`,help:y3.density,children:(0,L.jsx)(H3,{})}),(0,L.jsx)(k3,{label:`Queue order`,help:y3.queueOrder,children:(0,L.jsx)(U3,{})}),(0,L.jsxs)(k3,{label:`Desktop notifications`,help:y3.notifications,children:[(0,L.jsx)(V3,{value:t.notifications,onChange:m}),t.notifications&&(0,L.jsx)(W3,{perm:r})]}),(0,L.jsx)(P3,{draft:t,setDraft:f}),(0,L.jsx)(F3,{draft:t,setDraft:f}),(0,L.jsx)(I3,{draft:t,setDraft:f})]}):(0,L.jsx)(`div`,{className:`p-4 text-[13px] text-muted`,children:`Loading…`})]})})}function D3({state:e}){return e===`idle`?null:e===`error`?(0,L.jsx)(`span`,{className:`text-[11px] font-normal text-accent`,children:`Couldn't save`}):(0,L.jsx)(`span`,{className:`text-[11px] font-normal text-muted transition-opacity ${e===`saved`?`opacity-70`:`opacity-100`}`,children:e===`saving`?`Saving…`:`Saved`})}function O3({label:e,help:t}){return(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] uppercase tracking-wide text-muted`,children:[e,(0,L.jsx)(nM,{label:t,side:`right`,clickable:!0,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":`About ${e}`,className:`inline-flex size-4 items-center justify-center text-muted/60 hover:text-fg transition-colors`,children:(0,L.jsx)(Em,{size:12})})})]})}function k3({label:e,help:t,children:n}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(O3,{label:e,help:t}),n]})}var A3=[{token:`repo`,gloss:`repository`},{token:`n`,gloss:`number`},{token:`title`,gloss:`title`},{token:`url`,gloss:`link`},{token:`labels`,gloss:`labels`},{token:`body`,gloss:`description`}],j3=5e5,M3=[{value:`200000`,label:`200K tokens`},{value:`350000`,label:`350K tokens`},{value:`500000`,label:`500K tokens (default)`},{value:`750000`,label:`750K tokens`},{value:`1000000`,label:`1M tokens`}],N3=[{value:`auto`,label:`Automatic (default)`},{value:`5m`,label:`5 minutes`},{value:`1h`,label:`1 hour`}];function P3({draft:e,setDraft:t}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(L3,{label:`Claude`}),(0,L.jsx)(k3,{label:`Permissions`,help:y3.permissionMode,children:(0,L.jsx)(HX,{variant:`bordered`,value:e.permissionMode===`bypassPermissions`?`bypassPermissions`:`auto`,onValueChange:n=>t({...e,permissionMode:n}),options:$R,indicatorPosition:`right`,ariaLabel:`Claude permission mode`})}),(0,L.jsx)(k3,{label:`Compaction window`,help:y3.autoCompactWindow,children:(0,L.jsx)(HX,{variant:`bordered`,value:String(e.autoCompactWindow??j3),onValueChange:n=>t({...e,autoCompactWindow:Number(n)}),options:M3,indicatorPosition:`right`,ariaLabel:`Claude compaction window`})}),(0,L.jsx)(k3,{label:`Prompt cache tier`,help:y3.promptCacheTtl,children:(0,L.jsx)(HX,{variant:`bordered`,value:e.promptCacheTtl??`auto`,onValueChange:n=>t({...e,promptCacheTtl:n}),options:N3,indicatorPosition:`right`,ariaLabel:`Claude prompt cache tier`})})]})}function F3({draft:e,setDraft:t}){let n=nt({queryKey:[`codexModels`],queryFn:()=>Y.codexModels()}),r=e.codexContextWindow,i=r===void 0?m3:String(r),a=v3(n.data,r);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(L3,{label:`Codex`}),(0,L.jsx)(k3,{label:`Context window`,help:y3.codexContextWindow,children:(0,L.jsx)(HX,{variant:`bordered`,value:i,onValueChange:n=>t({...e,codexContextWindow:n==="default"?void 0:Number(n)}),options:a,indicatorPosition:`right`,ariaLabel:`Codex context window`})})]})}function I3({draft:e,setDraft:t}){let n=nt({queryKey:[`githubPromptDefaults`],queryFn:()=>Y.githubPromptDefaults()});return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(L3,{label:`Prompts`}),n.data?(0,L.jsx)(z3,{label:`Issue and PR triage prompt`,help:`The prompt for every item dispatched from the GitHub picker, issues and PRs alike. The default has the worker read the whole thread, classify it, and branch — reproduce + fix-plan for a bug, a plan for a feature, an adversarial review for a PR.`,value:e.githubPrompt,fallback:n.data.prompt,onChange:(n,r)=>t({...e,githubPrompt:n},r)}):(0,L.jsx)(`div`,{className:`text-[12px] text-muted`,children:`Loading defaults…`})]})}function L3({label:e}){return(0,L.jsxs)(`div`,{className:`mt-4 mb-1 flex items-center gap-2.5 text-[11px] uppercase tracking-wide text-muted/70`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border/60`}),(0,L.jsx)(`span`,{className:`shrink-0`,children:e}),(0,L.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border/60`})]})}function R3(){let[e,t]=(0,I.useState)(!1);return(0,L.jsxs)(TV,{open:e,onOpenChange:t,children:[(0,L.jsx)(EV,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] transition-colors ${e?`text-accent`:`text-muted hover:text-accent`}`,children:`Tokens`})}),(0,L.jsxs)(OV,{side:`top`,align:`end`,className:`w-56 p-3`,children:[(0,L.jsx)(`div`,{className:`mb-2 text-[11px] font-medium text-fg`,children:`Substitution tokens`}),(0,L.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:A3.map(({token:e,gloss:t})=>(0,L.jsxs)(`li`,{className:`flex items-center justify-between gap-3 text-[11px]`,children:[(0,L.jsx)(`code`,{className:`font-mono-keep rounded border border-border bg-bg px-1 py-0.5 text-[10px] text-fg/80`,children:`{${e}}`}),(0,L.jsx)(`span`,{className:`text-muted/80`,children:t})]},e))})]})]})}function z3({label:e,help:t,value:n,fallback:r,onChange:i}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(O3,{label:e,help:t}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[n!=null&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,className:`text-[11px] text-muted hover:text-accent transition-colors`,onClick:()=>i(void 0),children:`Reset to default`}),(0,L.jsx)(`span`,{"aria-hidden":!0,className:`text-[11px] text-muted/40`,children:`·`})]}),(0,L.jsx)(R3,{})]})]}),(0,L.jsx)(`textarea`,{value:n??r,onChange:e=>i(e.target.value===``?void 0:e.target.value,{debounce:!0}),rows:10,className:`input resize-none text-[12px] leading-relaxed font-mono-keep`,spellCheck:!1})]})}function B3({value:e,onChange:t}){return(0,L.jsx)(`div`,{className:`inline-flex w-fit rounded-md border border-border bg-bg p-0.5`,children:[{v:`mono`,label:`Mono`,cls:``},{v:`sans`,label:`Sans`,cls:``}].map(n=>(0,L.jsx)(`button`,{onClick:()=>t(n.v),className:`rounded px-3 py-1 text-[12px] transition-colors ${n.cls} ${e===n.v?`bg-fg text-bg`:`text-muted hover:text-fg`}`,children:n.label},n.v))})}function V3({value:e,onChange:t}){return(0,L.jsx)(`div`,{className:`inline-flex w-fit rounded-md border border-border bg-bg p-0.5`,children:[{v:!1,label:`Off`},{v:!0,label:`On`}].map(n=>(0,L.jsx)(`button`,{onClick:()=>t(n.v),className:`rounded px-3 py-1 text-[12px] transition-colors ${e===n.v?`bg-fg text-bg`:`text-muted hover:text-fg`}`,children:n.label},n.label))})}function H3(){let{compactDiffs:e}=Zt(yT);return(0,L.jsx)(`div`,{className:`inline-flex w-fit rounded-md border border-border bg-bg p-0.5`,children:[{v:!1,label:`Comfortable`},{v:!0,label:`Compact`}].map(t=>(0,L.jsx)(`button`,{onClick:()=>yT.compactDiffs=t.v,className:`rounded px-3 py-1 text-[12px] transition-colors ${e===t.v?`bg-fg text-bg`:`text-muted hover:text-fg`}`,children:t.label},t.label))})}function U3(){let{queueOrder:e}=Zt(yT);return(0,L.jsx)(`div`,{className:`inline-flex w-fit rounded-md border border-border bg-bg p-0.5`,children:[{v:`fifo`,label:`Oldest first`},{v:`lifo`,label:`Newest first`}].map(t=>(0,L.jsx)(`button`,{onClick:()=>yT.queueOrder=t.v,className:`rounded px-3 py-1 text-[12px] transition-colors ${e===t.v?`bg-fg text-bg`:`text-muted hover:text-fg`}`,children:t.label},t.v))})}function W3({perm:e}){return e===`denied`?(0,L.jsx)(K3,{}):(0,L.jsx)(`span`,{className:`text-[11px] text-muted/70`,children:{granted:`Browser permission granted — notifications fire when the window is hidden.`,default:`Browser permission not yet granted — notifications won't fire until you allow them.`,unsupported:`This browser does not support desktop notifications.`}[e]})}function G3(){let e=typeof navigator<`u`?navigator.userAgent:``;return/Firefox\//.test(e)?`firefox`:/Edg\//.test(e)?`edge`:/OPR\/|Brave\//.test(e)?`other`:/Chrome\//.test(e)?`chrome`:/Safari\//.test(e)?`safari`:`other`}function K3(){let e=(0,I.useMemo)(G3,[]),t=typeof location<`u`?location.origin:``,n=`${e===`edge`?`edge`:`chrome`}://settings/content/siteDetails?site=${encodeURIComponent(t)}`;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1 text-[11px] text-muted/70`,children:[(0,L.jsx)(`span`,{children:`Notifications are blocked for this site. Re-enable them in your browser, then reload.`}),e===`chrome`||e===`edge`?(0,L.jsx)(J3,{url:n,hint:`Paste this into a new tab, set Notifications → Allow:`}):e===`safari`?(0,L.jsxs)(`span`,{children:[`Safari → Settings → Websites → Notifications → allow `,q3(t),`, then reload.`]}):e===`firefox`?(0,L.jsx)(`span`,{children:`Firefox → Settings → Privacy & Security → Permissions → Notifications → Settings → allow this site.`}):(0,L.jsx)(`span`,{children:`Open this site's notification permission in your browser's settings and set it to Allow.`})]})}function q3(e){try{return new URL(e).host}catch{return e}}function J3({url:e,hint:t}){let[n,r]=(0,I.useState)(!1);async function i(){try{await HR(e),r(!0),window.setTimeout(()=>r(!1),1500)}catch{}}return(0,L.jsxs)(`span`,{className:`flex w-full flex-col gap-1`,children:[(0,L.jsx)(`span`,{children:t}),(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsx)(`code`,{className:`min-w-0 flex-1 font-mono-keep select-all rounded border border-border bg-bg px-1.5 py-0.5 text-[10.5px] text-fg/90 break-all`,children:e}),(0,L.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`Copy address`,className:`shrink-0 rounded border border-border p-1 text-muted hover:bg-panel-2 hover:text-fg transition-colors`,children:n?(0,L.jsx)(gm,{size:11,className:`text-live`}):(0,L.jsx)(Am,{size:11})})]})]})}var Y3=1,X3=.9,Z3=.8,Q3=.17,$3=.1,e6=.999,t6=.9999,n6=.99,r6=/[\\\/_+.#"@\[\(\{&]/,i6=/[\\\/_+.#"@\[\(\{&]/g,a6=/[\s-]/,o6=/[\s-]/g;function s6(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Y3:n6;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=s6(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Y3:r6.test(e.charAt(l-1))?(d*=Z3,p=e.slice(i,l-1).match(i6),p&&i>0&&(d*=e6**+p.length)):a6.test(e.charAt(l-1))?(d*=X3,m=e.slice(i,l-1).match(o6),m&&i>0&&(d*=e6**+m.length)):(d*=Q3,i>0&&(d*=e6**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=t6)),(d<$3&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=s6(e,t,n,r,l+1,a+2,o),f*$3>d&&(d=f*$3)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function c6(e){return e.toLowerCase().replace(o6,` `)}function l6(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,s6(e,t,c6(e),c6(t),0,0,{})}var u6=`[cmdk-group=""]`,d6=`[cmdk-group-items=""]`,f6=`[cmdk-group-heading=""]`,p6=`[cmdk-item=""]`,m6=`${p6}:not([aria-disabled="true"])`,h6=`cmdk-item-select`,g6=`data-value`,_6=(e,t,n)=>l6(e,t,n),v6=I.createContext(void 0),y6=()=>I.useContext(v6),b6=I.createContext(void 0),x6=()=>I.useContext(b6),S6=I.createContext(void 0),C6=I.forwardRef((e,t)=>{let n=L6(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=L6(()=>new Set),i=L6(()=>new Map),a=L6(()=>new Map),o=L6(()=>new Set),s=F6(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=cO(),y=cO(),b=cO(),x=I.useRef(null),S=B6();I6(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),I6(()=>{S(6,k)},[]);let C=I.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=I.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??_6;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(d6);t?t.appendChild(e.parentElement===t?e:e.closest(`${d6} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${d6} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${u6}[${g6}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(g6);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(u6)?.querySelector(f6))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${p6}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(m6)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(g6))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(g6))}function P(e){let t=A()?.closest(u6),n;for(;t&&!n;)t=e>0?N6(t,u6):P6(t,u6),n=t?.querySelector(m6);n?C.setState(`value`,n.getAttribute(g6)):N(e)}let ee=()=>M(j().length-1),F=e=>{e.preventDefault(),e.metaKey?ee():e.altKey?P(1):N(1)},te=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return I.createElement(zD.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&F(e);break;case`ArrowDown`:F(e);break;case`p`:case`k`:g&&e.ctrlKey&&te(e);break;case`ArrowUp`:te(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),ee();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(h6);t.dispatchEvent(e)}}}}},I.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:U6},c),H6(e,e=>I.createElement(b6.Provider,{value:C},I.createElement(v6.Provider,{value:w},e))))}),w6=I.forwardRef((e,t)=>{let n=cO(),r=I.useRef(null),i=I.useContext(S6),a=y6(),o=F6(e),s=o.current?.forceMount??i?.forceMount;I6(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=z6(n,r,[e.value,e.children,r],e.keywords),l=x6(),u=R6(e=>e.value&&e.value===c.current),d=R6(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);I.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(h6,f),()=>t.removeEventListener(h6,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return I.createElement(zD.div,{ref:SD(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),T6=I.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=cO(),s=I.useRef(null),c=I.useRef(null),l=cO(),u=y6(),d=R6(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);I6(()=>u.group(o),[]),z6(o,s,[e.value,e.heading,c]);let f=I.useMemo(()=>({id:o,forceMount:i}),[i]);return I.createElement(zD.div,{ref:SD(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&I.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),H6(e,e=>I.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},I.createElement(S6.Provider,{value:f},e))))}),E6=I.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=I.useRef(null),a=R6(e=>!e.search);return!n&&!a?null:I.createElement(zD.div,{ref:SD(i,t),...r,"cmdk-separator":``,role:`separator`})}),D6=I.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=x6(),o=R6(e=>e.search),s=R6(e=>e.selectedItemId),c=y6();return I.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),I.createElement(zD.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),O6=I.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=I.useRef(null),o=I.useRef(null),s=R6(e=>e.selectedItemId),c=y6();return I.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),I.createElement(zD.div,{ref:SD(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},H6(e,e=>I.createElement(`div`,{ref:SD(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),k6=I.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return I.createElement(QI,{open:n,onOpenChange:r},I.createElement(iL,{container:o},I.createElement(oL,{"cmdk-overlay":``,className:i}),I.createElement(uL,{"aria-label":e.label,"cmdk-dialog":``,className:a},I.createElement(C6,{ref:t,...s}))))}),A6=I.forwardRef((e,t)=>R6(e=>e.filtered.count===0)?I.createElement(zD.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),j6=I.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return I.createElement(zD.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},H6(e,e=>I.createElement(`div`,{"aria-hidden":!0},e)))}),M6=Object.assign(C6,{List:O6,Item:w6,Input:D6,Group:T6,Separator:E6,Dialog:k6,Empty:A6,Loading:j6});function N6(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function P6(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function F6(e){let t=I.useRef(e);return I6(()=>{t.current=e}),t}var I6=typeof window>`u`?I.useEffect:I.useLayoutEffect;function L6(e){let t=I.useRef();return t.current===void 0&&(t.current=e()),t}function R6(e){let t=x6(),n=()=>e(t.snapshot());return I.useSyncExternalStore(t.subscribe,n,n)}function z6(e,t,n,r=[]){let i=I.useRef(),a=y6();return I6(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(g6,s),i.current=s}),i}var B6=()=>{let[e,t]=I.useState(),n=L6(()=>new Map);return I6(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function V6(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function H6({asChild:e,children:t},n){return e&&I.isValidElement(t)?I.cloneElement(V6(t),{ref:t.ref},n(t.props.children)):n(t)}var U6={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function W6(){let e=Zt(X),t=qC(),[n,r]=(0,I.useState)(``);if((0,I.useEffect)(()=>{e.showPalette&&r(``)},[e.showPalette]),!e.showPalette)return null;let i=FT(YC(t?.threads??[])),a=e.drawers.length?[...e.drawers].reverse().find(e=>e.kind===`thread`)?.slug:void 0,o=t?.threads.find(e=>e.id===a);function s(){X.showPalette=!1}function c(e){e(),s()}function l(e){bp(e)}return(0,L.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-start justify-center bg-black/50 pt-[12vh]`,onMouseDown:e=>e.target===e.currentTarget&&s(),children:(0,L.jsxs)(M6,{label:`Command palette`,className:`w-[560px] max-w-[92vw] rounded-lg border border-border bg-panel shadow-2xl overflow-hidden`,filter:(e,t,n)=>+!!e.toLowerCase().includes(t.toLowerCase()),children:[(0,L.jsx)(M6.Input,{autoFocus:!0,value:n,onValueChange:r,placeholder:`Jump to a thread or run a command…`,className:`w-full px-4 h-12 bg-transparent outline-none border-b border-border text-sm placeholder:text-muted`}),(0,L.jsxs)(M6.List,{className:`max-h-[52vh] overflow-y-auto py-1.5`,children:[(0,L.jsx)(M6.Empty,{className:`px-4 py-6 text-center text-sm text-muted`,children:`No matches.`}),(0,L.jsxs)(M6.Group,{heading:`Actions`,className:`cmdk-group`,children:[(0,L.jsx)(G6,{value:`new thread create home`,onSelect:()=>c(()=>cp()),children:`New thread`}),(0,L.jsx)(G6,{value:`queue todos inbox pending`,onSelect:()=>c(()=>{zp(X.drawers.map(e=>e.id)),X.view=`todos`}),children:`Queue`}),(0,L.jsx)(G6,{value:`open settings preferences`,onSelect:()=>c(()=>X.showSettings=!0),children:`Open settings`}),o&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(G6,{value:`open details drawer doc ${CT(o)}`,onSelect:()=>c(()=>{let e=Bp();e&&_p(`doc`,e)}),children:`Open thread details`}),(0,L.jsxs)(G6,{value:`mark complete done ${CT(o)}`,onSelect:()=>c(()=>Y.markComplete({slug:o.id}).catch(()=>{})),children:[`Mark “`,CT(o),`” complete`]}),(0,L.jsxs)(G6,{value:`mark read ${CT(o)}`,onSelect:()=>c(()=>Y.markRead({slug:o.id}).catch(()=>{})),children:[`Mark “`,CT(o),`” read`]})]})]}),i.length>0&&(0,L.jsx)(M6.Group,{heading:`Threads`,className:`cmdk-group`,children:i.map(e=>(0,L.jsxs)(G6,{value:`${CT(e)} ${e.id}`,onSelect:()=>c(()=>l(e.id)),children:[(0,L.jsx)(`span`,{className:`truncate`,children:CT(e)}),(0,L.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted/70`,children:e.id})]},e.id))})]})]})})}function G6({value:e,onSelect:t,children:n}){return(0,L.jsx)(M6.Item,{value:e,onSelect:t,className:`mx-1.5 px-2.5 py-1.5 rounded flex items-center gap-2 text-sm cursor-pointer data-[selected=true]:bg-panel-2 data-[selected=true]:text-fg text-muted`,children:n})}var K6=`Updating and restarting Frizz`,q6=`This may take a moment while the new build is being prepared. All of your threads will continue running normally.`,J6=`Frizz did not come back`;function Y6(e){return`${e?`Nothing has answered for ${e}.`:`Nothing is answering.`} Restart Frizz from the terminal with npx frizz (or frizz, if it is installed globally). This page reconnects on its own once the board is back.`}function X6(e){if(e.key===`Tab`||e.key===`Enter`)return!0;if(e.metaKey||e.ctrlKey){let t=e.key.toLowerCase();if(t===`k`||t===`i`)return!0}return!1}function Z6({open:e,message:t,stalled:n=!1,silentFor:r}){let i=(0,I.useRef)(null),[a,o]=(0,I.useState)(!1),s=e&&!n;if((0,I.useEffect)(()=>{n||o(!1)},[n]),(0,I.useEffect)(()=>{if(!s)return;let e=document.activeElement;e instanceof HTMLElement&&e.blur(),i.current?.focus({preventScroll:!0});let t=e=>{X6(e)&&(e.preventDefault(),e.stopImmediatePropagation())};return window.addEventListener(`keydown`,t,{capture:!0}),()=>window.removeEventListener(`keydown`,t,{capture:!0})},[s]),!e)return null;if(n)return a?null:(0,L.jsx)(`div`,{className:`pointer-events-none fixed inset-x-0 top-6 z-[300] flex justify-center px-4`,children:(0,L.jsxs)(`div`,{role:`alert`,className:`pointer-events-auto w-[min(26rem,calc(100vw-2rem))] rounded-2xl border border-red-500/45 bg-elevated p-5 text-left shadow-2xl shadow-black/60`,children:[(0,L.jsxs)(`div`,{className:`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)(`h2`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:J6}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,onClick:()=>o(!0),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`,{"aria-live":`polite`,className:`mt-2.5 text-[12px] leading-relaxed text-muted`,children:Y6(r)})]})});let c=t?.trim()?t.trim():null;return(0,L.jsx)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":K6,className:`fixed inset-0 z-[300] flex items-center justify-center bg-black/55 px-4 backdrop-blur-md backdrop-saturate-150`,children:(0,L.jsxs)(`div`,{ref:i,tabIndex:-1,className:`w-[min(26rem,calc(100vw-2rem))] rounded-2xl border border-border-strong bg-elevated p-6 text-center shadow-2xl shadow-black/60 outline-none`,children:[(0,L.jsx)(`span`,{className:`mx-auto flex h-11 w-11 items-center justify-center rounded-full bg-fg/10 text-fg`,children:(0,L.jsx)(lh,{size:20,strokeWidth:2.25,className:`animate-spin`,"aria-hidden":`true`})}),(0,L.jsx)(`h2`,{className:`mt-4 text-[15px] font-semibold tracking-[-0.01em] text-fg`,children:K6}),(0,L.jsx)(`p`,{className:`mt-2 text-[12.5px] leading-relaxed text-muted`,children:q6}),c&&(0,L.jsx)(`p`,{"aria-live":`polite`,className:`mt-2 text-[11.5px] leading-relaxed text-muted/80`,children:c})]})})}var Q6=!1;function $6(){Q6||(Q6=!0,Z("Sign in to the GitHub CLI (`gh auth login`) to dispatch from issues/PRs.",{duration:6e3}))}function e8(){let e=Zt(X),t=(0,I.useRef)({projectDir:null,hasBeenVisible:!1});(0,I.useEffect)(()=>{Y.board().then(Up).catch(()=>{})},[]);let n=ny();(0,I.useEffect)(()=>xw((e,t)=>n(e,t)),[n]);let{data:r,dataUpdatedAt:i}=gH(),a=(0,I.useRef)(null),[o,s]=(0,I.useState)(QV),c=(0,I.useRef)(null),l=(0,I.useRef)(!1);(0,I.useEffect)(()=>{let e=r;if(e){let t=tH({state:X.controlPlaneState,message:X.controlPlaneMessage,attempt:X.controlPlaneRestartAttempt},e);X.controlPlaneState=t.state,X.controlPlaneMessage=t.message,X.controlPlaneRestartAttempt=t.attempt,c.current===null&&(c.current=YV(e))}if(s(t=>$V(t,{restarting:X.controlPlaneState===`restarting`,answered:e!=null,at:Date.now()})),!e||l.current)return;let t=sessionStorage.getItem(GV);if(rH({state:X.controlPlaneState,message:X.controlPlaneMessage,attempt:X.controlPlaneRestartAttempt},e)){if(t){sessionStorage.removeItem(GV),sessionStorage.removeItem(KV),l.current=!0,window.location.replace(t);return}if(XV(c.current,e)){l.current=!0,window.location.reload();return}}if(e.state===`failed`&&t){let t=sessionStorage.getItem(`frizz:update-restart-from-version`)??void 0;sessionStorage.removeItem(GV),sessionStorage.removeItem(KV),a.current!==e.message&&(a.current=e.message??`Update & Restart failed`,Z(`Update & Restart failed — ${JV(qV(t,e)).summary}`,{duration:7e3}))}},[r,i]);let u=e.drawers.length>0||e.showSettings||e.showNewThread||e.showGithubPicker||e.showPalette;(0,I.useEffect)(()=>{if(!u)return;let e=window.scrollY,t=document.body;return wd(),t.style.position=`fixed`,t.style.top=`-${e}px`,t.style.left=`0`,t.style.right=`0`,t.style.width=`100%`,()=>{t.style.position=``,t.style.top=``,t.style.left=``,t.style.right=``,t.style.width=``,window.scrollTo(0,wd()??e)}},[u]);let d=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()});(0,I.useEffect)(()=>{X.notificationsEnabled=d.data?.notifications??!1},[d.data?.notifications]);let f=gR();(0,I.useEffect)(()=>{f.data?.inRepo&&!f.data.authed&&$6()},[f.data?.inRepo,f.data?.authed]),(0,I.useEffect)(()=>{function e(e){if(e.target instanceof Element&&e.target.closest(`.xterm`)||!(e.metaKey||e.ctrlKey))return;let t=e.key.toLowerCase();if(t===`k`)e.preventDefault(),X.showPalette=!X.showPalette;else if(t===`i`){let t=Ip(),n=Bp();t?.kind===`doc`?(e.preventDefault(),_d(t.id)||X.drawers.pop()):n&&(e.preventDefault(),_p(`doc`,n))}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let p=qC(),m=zW();(0,I.useEffect)(()=>{xp()},[p,e.routeThreadSlug]),t.current=Sw(t.current,p);let h=p!==null&&t.current.hasBeenVisible,g=p===null&&ww(Ad()),_=t.current.hasBeenVisible;(0,I.useEffect)(()=>{p!==null&&Tw(Ad(),_)},[p,_]);let v=p?.projectLabel??p?.projectName;return(0,I.useEffect)(()=>{let e=window.matchMedia?.(`(display-mode: standalone)`).matches;document.title=e?v??`Frizz`:v?`${v} — Frizz`:`Frizz`},[v]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Z6,{open:e.controlPlaneState===`restarting`,message:e.controlPlaneMessage,stalled:o.stalled,silentFor:o.silentSince===null?void 0:IE(o.silentForMs)}),(0,L.jsxs)(`div`,{inert:e.controlPlaneState===`restarting`&&!o.stalled,className:`relative min-h-screen bg-bg text-fg text-sm`,children:[m?(0,L.jsx)(NW,{}):(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(`div`,{className:`flex min-h-screen justify-center gap-[clamp(28px,3.4vw,52px)] px-5 max-[800px]:flex-col max-[800px]:justify-start max-[800px]:gap-0 max-[800px]:px-3`,children:[h&&(0,L.jsx)(Dh,{label:`the sidebar`,children:(0,L.jsx)(PU,{})}),g&&(0,L.jsx)(`aside`,{"aria-hidden":!0,className:`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`,"data-sidebar-reserved":!0}),(0,L.jsx)(`main`,{id:`workpane`,className:`w-[720px] max-w-[62vw] min-w-0 flex flex-col py-5 max-[800px]:w-full max-[800px]:max-w-none ${e.view===`todos`||!p?`min-h-screen`:``} ${e.view===`todos`?``:`rounded-lg border border-border bg-panel`}`,children:p?(0,L.jsxs)(Dh,{label:`the queue`,resetKeys:[e.view],children:[e.view.startsWith(`status:`)&&(0,L.jsx)(gW,{status:e.view.slice(7)}),e.view===`todos`&&(0,L.jsx)(U4,{})]}):(0,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,L.jsx)(`span`,{className:`block h-5 w-5 rounded-full border-2 border-muted/50 border-t-transparent animate-spin`})})})]})}),(0,L.jsx)(w4,{}),e.showSettings&&(0,L.jsx)(E3,{}),e.showNewThread&&(0,L.jsx)(jz,{onClose:()=>{X.showNewThread=!1}}),e.showGithubPicker&&(0,L.jsx)(t3,{onClose:up}),(0,L.jsx)(W6,{})]})]})}function t8(e,t,n){let r=[...e];if(t<0||t>=r.length||n<0||n>=r.length||t===n)return r;let[i]=r.splice(t,1);return r.splice(n,0,i),r}function n8(e,t,n,r=48){let i=Math.round(t/r);return Math.max(0,Math.min(n-1,e+i))}function r8(e,t,n,r=48){return e===t?0:n>t&&e>t&&e<=n?-r:n<t&&e>=n&&e<t?r:0}function i8(e,t,n=44,r=14){let i=t.top+n-e;if(i>0)return-Math.min(r,i/n*r);let a=e-(t.bottom-n);return a>0?Math.min(r,a/n*r):0}var a8=`w-[57px]`,o8=`max-[800px]:pl-0 pl-[57px]`;function s8(e){let t=0;for(let n=0;n<e.length;n++)t=(t*31+e.charCodeAt(n))%360;return t}function c8(e){let t=e.split(/[\s\-_./]+/u).filter(Boolean);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}function l8(e){let t=e.iconVersion?`&v=${encodeURIComponent(e.iconVersion)}`:``;return`/_frizz/project-icon?id=${encodeURIComponent(e.id)}${t}`}function u8({project:e,size:t}){let[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(!1),o=s8(e.id),s=e.iconStatus!==`none`,[c,l]=(0,I.useState)(!1),u=!s||c;return(0,L.jsxs)(`span`,{className:`relative block overflow-hidden rounded-[30%] bg-elevated`,style:{width:t,height:t,background:s&&!c?void 0:`hsl(${o} 32% 24%)`},children:[u&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-0 flex items-center justify-center font-semibold leading-none`,style:{fontSize:t*.4,color:`hsl(${o} 55% 78%)`},children:(0,L.jsx)(`span`,{style:{textBox:`trim-both cap alphabetic`},children:c8(e.name)})}),s&&!c&&(0,L.jsx)(`img`,{src:l8(e),alt:``,width:t,height:t,loading:`eager`,decoding:`async`,onLoad:e=>{let t=e.currentTarget;t.naturalWidth>0&&t.naturalHeight>0&&a(Math.abs(t.naturalWidth/t.naturalHeight-1)<=.05),r(!0)},onError:()=>l(!0),className:`relative h-full w-full transition-opacity ${i?`object-cover`:`object-contain p-[6%]`} ${n?`opacity-100`:`opacity-0`}`})]})}var d8=40;function f8({project:e,current:t,count:n,index:r,drag:i,onPointerDown:a,onKeyDown:o}){let s=i?.fromIndex===r,c=i?s?i.deltaY:r8(r,i.fromIndex,i.toIndex):0;return(0,L.jsx)(nM,{side:`right`,disabled:i!==null,label:e.stale?`${e.name} — directory is missing`:n?`${e.name} — ${n} in the queue`:e.name,children:(0,L.jsxs)(Ab,{to:jd(e.slug),"aria-current":t?`page`:void 0,"aria-grabbed":s||void 0,onPointerDown:e=>a(e,r),onKeyDown:e=>o(e,r),onClick:e=>{(i||g8())&&e.preventDefault()},onDragStart:e=>e.preventDefault(),className:`group relative flex h-10 w-full items-center justify-center outline-none ${s?`z-10 cursor-grabbing`:``}`,style:{transform:c?`translateY(${c}px)`:void 0,transition:s?`none`:`transform 160ms ease`},children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`absolute left-0 w-[3px] rounded-r-full bg-fg transition-all duration-150 ${t?`h-7 opacity-100`:`h-2.5 opacity-0 group-hover:opacity-60`}`}),(0,L.jsx)(`span`,{className:`rounded-[30%] transition-[transform,opacity,box-shadow] duration-150 group-focus-visible:ring-1 group-focus-visible:ring-fg/60 ${s?`scale-[1.12] opacity-100 shadow-lg shadow-black/50`:`group-hover:scale-[1.06] ${t?``:`opacity-75 group-hover:opacity-100`}`} ${e.stale?`grayscale`:``}`,children:(0,L.jsx)(u8,{project:e,size:d8})}),n?(0,L.jsx)(`span`,{"aria-label":`${n} in the queue`,"data-rail-queue-count":n,className:`pointer-events-none absolute -bottom-[5px] right-[3px] flex h-[16px] min-w-[16px] items-center justify-center rounded-full border-[1.5px] border-bg bg-accent px-[3.5px] text-[10px] font-semibold leading-none proportional-nums text-bg`,children:(0,L.jsx)(`span`,{style:{textBox:`trim-both cap alphabetic`},children:n})}):null]})})}function p8({project:e,children:t}){let n=(0,I.useRef)(null),r=Ve(),i=()=>r.invalidateQueries({queryKey:[`projectsList`]}),a=e=>Z(e instanceof Error?e.message:String(e),{duration:7e3}),o=it({mutationFn:async t=>{let n=new Uint8Array(await t.arrayBuffer()),r=``;for(let e=0;e<n.length;e+=8192)r+=String.fromCharCode(...n.subarray(e,e+8192));return Y.projectIconSet({id:e.id,name:t.name,data:btoa(r)})},onSuccess:()=>void i(),onError:a}),s=it({mutationFn:()=>Y.projectIconClear({id:e.id}),onSuccess:()=>void i(),onError:a}),c=it({mutationFn:()=>Y.projectIconPick({id:e.id}),onSuccess:e=>{if(e.kind!==`cancelled`){if(e.kind===`unavailable`){n.current?.click();return}i()}},onError:()=>n.current?.click()}),l=`cursor-default rounded px-2 py-1.5 text-[12.5px] text-fg outline-none data-[highlighted]:bg-panel-2`;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`input`,{ref:n,type:`file`,accept:ld.map(e=>`.${e}`).join(`,`),className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&o.mutate(t)}}),(0,L.jsxs)(AI,{children:[(0,L.jsx)(jI,{asChild:!0,children:t}),(0,L.jsx)(MI,{children:(0,L.jsxs)(NI,{align:`start`,sideOffset:6,className:`z-[220] min-w-[190px] rounded-lg border border-border bg-panel p-1 shadow-xl shadow-black/40`,children:[(0,L.jsx)(II,{className:l,onSelect:()=>c.mutate(),children:o.isPending?`Uploading…`:`Choose an icon…`}),(0,L.jsx)(II,{className:l,onSelect:()=>s.mutate(),children:e.iconIsCustom?`Use the detected icon`:`Look for an icon again`})]})})]})]})}var m8=4,h8=0;function g8(){return Date.now()-h8<250}function _8(e,t){let n=nt({queryKey:[`projectsQueueCounts`],queryFn:()=>Y.projectsQueueCounts(),refetchInterval:5e3}),r=Zt(X).board,i=e!==void 0&&r?YC(r.threads).filter(RT).length:void 0,a=e===void 0?void 0:t.find(t=>t.slug===e)?.id;return e=>e.id===a&&i!==void 0?i:n.data?.[e.id]}function v8(){let e=Ve(),{data:t}=nt({queryKey:[`projectsList`],queryFn:()=>Y.projectsList()}),n=Ad(),[r,i]=(0,I.useState)(!1),a=ny(),[o,s]=(0,I.useState)(null),[c,l]=(0,I.useState)(null),u=(0,I.useRef)(null),d=it({mutationFn:()=>Y.projectPick({}),onSuccess:e=>{e.kind===`picked`?a(jd(e.project.slug)):e.kind===`unavailable`&&a(`/`)},onSettled:()=>i(!1)}),f=it({mutationFn:e=>Y.projectsReorder({ids:e}),onSuccess:async()=>{await e.invalidateQueries({queryKey:[`projectsList`]}),l(null)},onError:()=>l(null)}),p=c??t??[],m=_8(n,p),[h,g]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>g(e.scrollTop+e.clientHeight<e.scrollHeight-1);t(),e.addEventListener(`scroll`,t,{passive:!0});let n=new ResizeObserver(t);return n.observe(e),window.addEventListener(`resize`,t),()=>{e.removeEventListener(`scroll`,t),n.disconnect(),window.removeEventListener(`resize`,t)}},[p.length]);let _=(0,I.useCallback)((e,t)=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let n=e.currentTarget,r=e.clientY,i=p,a=!1,o=null,c=0,d=e=>{let n=u.current,a=0;if(n){let t=i8(e,n.getBoundingClientRect());if(t){let e=n.scrollTop;n.scrollTop+=t,a=n.scrollTop-e}}m+=a;let c=e-r+m;o={id:i[t].id,fromIndex:t,toIndex:n8(t,c,i.length),deltaY:c},s(o)},m=0,h=e=>{if(!a){if(Math.abs(e.clientY-r)<m8)return;a=!0,n.setPointerCapture(e.pointerId)}e.preventDefault();let t=e.clientY;cancelAnimationFrame(c);let i=()=>{d(t),u.current&&i8(t,u.current.getBoundingClientRect())&&(c=requestAnimationFrame(i))};c=requestAnimationFrame(i)},g=()=>{if(cancelAnimationFrame(c),window.removeEventListener(`pointermove`,h),window.removeEventListener(`pointerup`,g),window.removeEventListener(`pointercancel`,g),s(null),!a||!o)return;h8=Date.now();let e=t8(i,o.fromIndex,o.toIndex);o.fromIndex!==o.toIndex&&(l(e),f.mutate(e.map(e=>e.id)))};window.addEventListener(`pointermove`,h,{passive:!1}),window.addEventListener(`pointerup`,g),window.addEventListener(`pointercancel`,g)},[p,f]),v=(0,I.useCallback)((e,t)=>{if(!e.altKey||e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;let n=t+(e.key===`ArrowUp`?-1:1);if(n<0||n>=p.length)return;e.preventDefault();let r=t8(p,t,n);l(r),f.mutate(r.map(e=>e.id)),requestAnimationFrame(()=>{u.current?.querySelectorAll(`a`)[n]?.focus()})},[p,f]);return(0,L.jsxs)(`nav`,{"aria-label":`Projects`,className:`fixed inset-y-0 left-0 z-[60] flex flex-col items-center border-r border-border bg-panel/60 py-3 max-[800px]:hidden ${a8}`,children:[(0,L.jsx)(nM,{side:`right`,label:`All projects`,children:(0,L.jsx)(Ab,{to:`/`,"aria-label":`All projects`,"aria-current":n?void 0:`page`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted/70 outline-none transition-colors hover:bg-elevated hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:(0,L.jsx)(Wm,{size:17})})}),(0,L.jsx)(`hr`,{className:`my-2.5 w-6 shrink-0 border-0 border-t border-border`}),(0,L.jsx)(`div`,{ref:u,"data-overflowing":h||void 0,className:`frizz-rail-scroll flex w-full min-h-0 flex-1 flex-col items-center gap-2 overflow-y-auto pb-1.5`,children:p.map((e,t)=>(0,L.jsx)(f8,{project:e,index:t,current:e.slug===n,count:m(e),drag:o,onPointerDown:_,onKeyDown:v},e.id))}),(0,L.jsx)(nM,{side:`right`,label:`Add a project`,children:(0,L.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>{i(!0),d.mutate()},"aria-label":`Add a project`,className:`mt-3 flex h-10 w-10 shrink-0 items-center justify-center rounded-[30%] border-[1.5px] border-dotted border-border-strong text-muted/80 outline-none transition-colors hover:border-accent hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60 disabled:opacity-50`,children:(0,L.jsx)(ch,{size:16})})})]})}var y8=76;function b8(e,t){return t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}var x8=`flex flex-col gap-1 rounded-lg border px-4 py-3 outline-none transition-colors focus-visible:ring-1 focus-visible:ring-fg/60`,S8=`max-[700px]:rounded-none max-[700px]:border-x-0 max-[700px]:border-t-0 max-[700px]:border-b-border/70 max-[700px]:bg-transparent max-[700px]:py-3.5`,C8=38;function w8({project:e,home:t}){let n=lE(e.lastOpenedAt),[r,i]=(0,I.useState)(!1);return(0,L.jsxs)(`div`,{className:`group/card relative`,children:[(0,L.jsxs)(Ab,{to:jd(e.slug),className:`${x8} ${S8} flex-row items-center gap-3 border-border bg-panel pr-10 group-hover/card:border-border-strong group-hover/card:bg-panel-2 ${e.stale?`opacity-60`:``}`,children:[(0,L.jsx)(`span`,{className:`shrink-0 ${e.stale?`grayscale`:``}`,children:(0,L.jsx)(u8,{project:e,size:C8})}),(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium text-fg`,children:e.name}),e.slug===e.name?null:(0,L.jsxs)(`span`,{className:`max-w-[45%] shrink-0 truncate font-mono text-[11px] text-muted/70`,children:[`/`,e.slug]})]}),(0,L.jsx)(`span`,{className:`truncate text-[11px] text-muted`,title:e.path,children:b8(e.path,t)}),(0,L.jsx)(`span`,{className:`truncate text-[11px] text-muted/70`,children:e.stale?`Directory is missing`:n?`Opened ${n}`:`Never opened`})]})]}),(0,L.jsx)(p8,{project:e,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":`Change the icon for ${e.name}`,style:{width:C8,height:C8},className:`absolute left-[17px] top-1/2 flex -translate-y-1/2 items-center justify-center rounded-[30%] bg-black/75 text-fg opacity-0 outline-none transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-1 focus-visible:ring-fg/60 data-[state=open]:opacity-100 max-[700px]:left-4 max-[700px]:top-[calc(50%-0.5px)]`,children:(0,L.jsx)(Gm,{size:16,strokeWidth:1.75})})}),(0,L.jsx)(T8,{onDelete:()=>i(!0),children:(0,L.jsx)(`button`,{type:`button`,"aria-label":`More actions for ${e.name}`,className:`absolute right-[8px] top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-muted opacity-0 outline-none transition-opacity hover:bg-panel-2 hover:text-fg focus-visible:opacity-100 focus-visible:ring-1 focus-visible:ring-fg/60 group-hover/card:opacity-100 data-[state=open]:opacity-100 max-[700px]:right-[7px] max-[700px]:opacity-100`,children:(0,L.jsx)(jm,{size:15})})}),r?(0,L.jsx)(E8,{project:e,home:t,onClose:()=>i(!1)}):null]})}function T8({onDelete:e,children:t}){return(0,L.jsxs)(AI,{children:[(0,L.jsx)(jI,{asChild:!0,children:t}),(0,L.jsx)(MI,{children:(0,L.jsx)(NI,{align:`end`,sideOffset:6,className:`z-[220] min-w-[170px] rounded-lg border border-border bg-panel p-1 shadow-xl shadow-black/40`,children:(0,L.jsx)(II,{className:`cursor-default rounded px-2 py-1.5 text-[12.5px] text-red-400 outline-none data-[highlighted]:bg-red-500/10 data-[highlighted]:text-red-300`,onSelect:e,children:`Delete project…`})})})]})}function E8({project:e,home:t,onClose:n}){let[r,i]=(0,I.useState)(!1),a=Ve(),o=it({mutationFn:()=>Y.projectRemove({id:e.id,deleteData:r}),onSuccess:t=>{a.invalidateQueries({queryKey:[`projectsList`]}),Z(t.stoppedWorkers>0?`Deleted ${e.name} — ${t.stoppedWorkers} ${t.stoppedWorkers===1?`worker`:`workers`} stopped`:`Deleted ${e.name}`),n()}}),s=o.error instanceof Error?o.error.message:o.error?String(o.error):null;return(0,L.jsx)(sZ,{open:!0,onOpenChange:e=>{!e&&!o.isPending&&n()},title:`Delete ${e.name}?`,className:`w-[440px] max-w-[92vw]`,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,onClick:n,disabled:o.isPending,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`,onClick:()=>o.mutate(),disabled:o.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:[o.isPending&&(0,L.jsx)(Xm,{size:12,className:`animate-spin`}),r?`Delete project and threads`:`Delete project`]})]}),children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 p-4 text-[12.5px] leading-relaxed text-muted`,children:[(0,L.jsxs)(`p`,{children:[`Frizz forgets this project. The folder itself is not touched — nothing inside`,` `,(0,L.jsx)(`span`,{className:`font-mono text-[11.5px] text-fg/80`,children:b8(e.path,t)}),` is changed or removed.`]}),(0,L.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md border border-border bg-bg/30 px-2.5 py-2 text-fg/85`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked),className:`mt-[3px] accent-[var(--color-accent)]`}),(0,L.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{children:`Also delete its threads and history`}),(0,L.jsx)(`span`,{className:`text-[11.5px] text-muted/80`,children:r?`Everything Frizz has stored for this project, and any workers still running are stopped. This cannot be undone.`:`Left off, its threads are kept — adding the folder again brings the board back.`})]})]}),s?(0,L.jsx)(`p`,{className:`text-[11.5px] text-red-400`,children:s}):null]})})}function D8({hero:e,pending:t,onClick:n}){return(0,L.jsxs)(`button`,{type:`button`,onClick:n,disabled:t,className:`${x8} items-center justify-center gap-1.5 border-dashed border-border-strong bg-transparent text-muted hover:border-accent hover:text-fg max-[700px]:mx-4 max-[700px]:mt-4 ${e?`min-h-[118px]`:`min-h-[74px]`}`,children:[(0,L.jsx)(`span`,{className:`text-[17px] leading-none text-muted/70`,children:`+`}),(0,L.jsx)(`span`,{className:`text-[12.5px]`,children:t?`Choosing a folder…`:`Add a project`}),e?(0,L.jsx)(`span`,{className:`text-[11px] text-muted/70`,children:`Point Frizz at a folder on this machine`}):null]})}function O8({reason:e,proposed:t,onClose:n}){let[r,i]=(0,I.useState)(t??``),a=ny(),o=Ve(),s=it({mutationFn:e=>Y.projectAdd({path:e}),onSuccess:e=>{o.invalidateQueries({queryKey:[`projectsList`]}),a(jd(e.slug))}}),c=s.error instanceof Error?s.error.message:s.error?String(s.error):null;return(0,L.jsx)(QI,{open:!0,onOpenChange:e=>{!e&&!s.isPending&&n()},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-[460px] max-w-[90vw] -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.jsx)(hL,{className:`mb-1 text-[14px] font-medium`,children:t?`Add this folder as a project?`:`Add a project`}),(0,L.jsx)(`p`,{className:`mb-3.5 text-[12.5px] leading-relaxed text-muted`,children:t?`You ran Frizz here and it is not a project yet. Nothing has been written — adding it is what creates its board.`:e?`${e}. Paste the folder instead — Frizz walks up to the repository root, the same way it does when you run it in a terminal.`:`Paste the folder you want a board for. Frizz walks up to the repository root, the same way it does when you run it in a terminal.`}),(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),s.isPending||s.mutate(r)},children:[(0,L.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),placeholder:`~/code/my-project`,spellCheck:!1,className:`w-full rounded-md border bg-bg px-2.5 py-2 font-mono text-[12px] text-fg outline-none placeholder:text-muted/50 focus-visible:ring-1 focus-visible:ring-fg/60 ${c?`border-red-500/60`:`border-border-strong`}`}),c?(0,L.jsx)(`p`,{className:`mt-1.5 text-[11.5px] text-red-400`,children:c}):null,(0,L.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:n,disabled:s.isPending,className:`rounded-md border border-border-strong bg-elevated px-3 py-1.5 text-[12.5px] text-fg outline-none hover:bg-panel-2 focus-visible:ring-1 focus-visible:ring-fg/60 disabled:opacity-50`,children:t?`Not now`:`Cancel`}),(0,L.jsx)(`button`,{type:`submit`,disabled:s.isPending||r.trim().length===0,className:`rounded-md border border-accent bg-accent px-3 py-1.5 text-[12.5px] font-medium text-bg outline-none hover:brightness-110 focus-visible:ring-1 focus-visible:ring-fg/60 disabled:opacity-50`,children:s.isPending?`Adding…`:t?`Add it`:`Add project`})]})]})]})]})})}function k8(){let[e]=(0,I.useState)(()=>{let e=new URLSearchParams(location.search).get(`add`)??void 0;return e&&history.replaceState(null,``,location.pathname),e}),[t,n]=(0,I.useState)(e?{}:null);(0,I.useEffect)(()=>{let e=new URLSearchParams(location.search).get(`unknown`);e&&(history.replaceState(null,``,location.pathname),Z(`No project named ${e} — showing all projects instead`,{duration:7e3}))},[]);let r=ny(),i=Ve(),a=it({mutationFn:()=>Y.projectPick({}),onSuccess:e=>{if(e.kind!==`cancelled`){if(e.kind===`unavailable`){n({reason:e.reason});return}i.invalidateQueries({queryKey:[`projectsList`]}),r(jd(e.project.slug))}},onError:e=>n({reason:e instanceof Error?e.message:String(e)})}),{data:o,isPending:s,error:c}=nt({queryKey:[`projectsList`],queryFn:()=>Y.projectsList()}),l=o?.[0]?.path.match(/^(\/(?:Users|home)\/[^/]+)\//u)?.[1],u=o!==void 0&&o.length===0;return(0,L.jsxs)(`div`,{className:`flex min-h-dvh w-full flex-col px-6 py-14 max-[700px]:px-0 max-[700px]:py-10`,children:[(0,L.jsxs)(`div`,{className:`m-auto flex w-full flex-col items-center`,children:[(0,L.jsxs)(`div`,{className:`mb-8 flex flex-col items-center gap-2.5 text-center`,children:[(0,L.jsx)(`img`,{src:`/favicon.svg`,width:y8,height:y8,alt:``,className:`rounded-[17px]`}),(0,L.jsx)(`h1`,{className:`text-[19px] font-semibold tracking-[-0.01em] text-fg`,children:u?`Welcome to Frizz`:`Select a project`}),u?(0,L.jsx)(`p`,{className:`max-w-[420px] text-[13px] leading-relaxed text-muted`,children:`A project is a folder on this machine. Frizz keeps one board of threads per project, and serves them all from here.`}):null]}),c?(0,L.jsxs)(`p`,{className:`text-[13px] text-muted`,children:[`Could not read the project registry: `,String(c)]}):s?(0,L.jsx)(`p`,{className:`text-[13px] text-muted`,children:`Loading…`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`grid w-full gap-2.5 max-[700px]:gap-0 ${u?`max-w-[360px] grid-cols-1`:`max-w-[720px] grid-cols-1 sm:grid-cols-2`}`,children:[o.map(e=>(0,L.jsx)(w8,{project:e,home:l},e.id)),(0,L.jsx)(D8,{hero:u,pending:a.isPending,onClick:()=>a.mutate()})]}),u?(0,L.jsxs)(`p`,{className:`mt-6 text-[11.5px] text-muted/70`,children:[`Or run`,` `,(0,L.jsx)(`code`,{className:`rounded border border-border bg-panel px-1.5 py-0.5 font-mono text-muted`,children:`frizz`}),` `,`inside any folder — it registers itself and opens.`]}):null]})]}),t?(0,L.jsx)(O8,{reason:t.reason,proposed:e,onClose:()=>n(null)}):null]})}function A8(e,t,n){let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=0;for(let e=r.nextNode();e;e=r.nextNode()){if(e===t)return i+n;i+=e.textContent?.length??0}if(t instanceof Element&&e.contains(t)){let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=0;for(let e=n.nextNode();e;e=n.nextNode())(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING||t.contains(e))&&(r+=e.textContent?.length??0);return r}return null}function j8(e,t){let n=1,r=Math.min(t,e.length);for(let t=0;t<r;t++)e.charCodeAt(t)===10&&n++;return n}function M8({slug:e,path:t}){let n=$S(t),r=XC(t),i=nt({...rC(t),refetchInterval:r?!1:iC}),a=i.data?.path??t,o=i.data?.markdown??``,{front:s,body:c}=v4(n?o:``),[l,u]=(0,I.useState)(n?`rendered`:`source`),d=JK(c,{baseDir:tC(a),asDocument:!0}),f=Nq(d),p=Nq((0,I.useMemo)(()=>l===`source`?sC(a,o):``,[o,a,l])),m=(0,I.useRef)(null),h=(0,I.useRef)(null),g=(0,I.useRef)(null);Kq(m,d);let _=Qf(a),v=Ez(),y=Dz(e);return(0,I.useEffect)(()=>{let t=()=>document.querySelector(`main[data-standalone-thread] textarea`);function n(e,t){return e?document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0?t.length:Math.min(e.selectionStart??t.length,t.length):t.length}function r(r){if(!(r.metaKey||r.ctrlKey)||r.altKey||r.shiftKey||r.key.toLowerCase()!==`i`)return;let i=g.current,s=window.getSelection(),c=s&&!s.isCollapsed&&s.rangeCount>0?s.getRangeAt(0):null,l=!!(i&&c&&i.contains(c.commonAncestorContainer)),u=l?s.toString():``;if(!l||!u.trim()){r.preventDefault(),r.stopPropagation();let e=t();if(!e)return;document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0&&e.setSelectionRange(e.value.length,e.value.length),e.focus();return}r.preventDefault(),r.stopPropagation();let d=null,f=h.current;if(f&&f.contains(c.commonAncestorContainer)){let e=A8(f,c.startContainer,c.startOffset),t=A8(f,c.endContainer,c.endOffset);e!==null&&t!==null&&(d={startLine:j8(o,Math.min(e,t)),endLine:j8(o,Math.max(0,Math.max(e,t)-1))})}else d=WL(o,u);let p=t(),m=Tz.followUp(v,e,y),{prose:_,attachments:b}=NL(Cz.get(m)),x=VL(FL({path:a,...d??{}}),X.composerContext[e]??[],_),S=HL(_,n(p,_),x);Cz.set(m,PL(S.prose,b.map(e=>e.path))),Np(e,{token:x,path:a,text:u,...d??{}}),s.removeAllRanges(),requestAnimationFrame(()=>{let e=t();e&&(e.setSelectionRange(S.caret,S.caret),e.focus())})}return window.addEventListener(`keydown`,r,!0),()=>window.removeEventListener(`keydown`,r,!0)},[e,a,o,v,y]),(0,L.jsxs)(`div`,{ref:g,"data-file-viewer-panel":!0,className:`flex h-full min-h-0 flex-col`,children:[(0,L.jsx)(Th,{title:_,subtitle:a,onClose:jp,actions:n?(0,L.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5 rounded-md border border-border-strong p-0.5 text-[11px] font-medium`,role:`group`,"aria-label":`File view`,children:[`rendered`,`source`].map(e=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>u(e),"aria-pressed":l===e,className:`rounded px-2 py-0.5 transition-colors ${l===e?`bg-panel-2 text-fg`:`text-muted hover:text-fg`}`,children:e===`rendered`?`Rendered`:`Source`},e))}):null}),(0,L.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:[i.isLoading?(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):i.error?(0,L.jsxs)(`div`,{className:`text-[13px] text-red-400/90`,children:[`Couldn’t read this file: `,i.error.message]}):l===`source`?o?(0,L.jsx)(`pre`,{ref:h,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:p}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):d?(0,L.jsxs)(L.Fragment,{children:[s&&(0,L.jsx)(x4,{source:s}),(0,L.jsx)(`div`,{ref:m,className:`md-body`,dangerouslySetInnerHTML:f})]}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!i.isLoading&&!i.error&&i.data?.truncated&&(0,L.jsx)(`p`,{className:`mt-4 border-t border-border/60 pt-3 text-[12px] text-muted`,children:`This file is too long to render in full — everything above the cut is shown. Open it to read the rest.`})]}),(0,L.jsxs)(`div`,{className:`shrink-0 flex items-center justify-between gap-3 border-t border-border/60 bg-panel px-5 pt-3`,style:y4,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-muted/70`,children:`Select text and press ⌘I to add it to the chat`}),(0,L.jsx)(b4,{path:a})]})]})}function N8(){return{dirs:new Map,files:new Map}}function P8(e,t){let n=e.replace(/[\\/]+$/,``);if(t){let e=np(t,n);if(e!==null)return Kf(e)}let r=Kf(n);return/^[\\/]/.test(n)?[`/`,...r]:r}var F8=(e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`,numeric:!0});function I8(e,t){let n=[];for(let r of[...e.dirs.keys()].sort(F8)){let i=e.dirs.get(r),a=r;for(;i.files.size===0&&i.dirs.size===1;){let[e,t]=[...i.dirs.entries()][0];a=a===`/`?`/${e}`:`${a}/${e}`,i=t}n.push({kind:`dir`,name:a,depth:t,children:I8(i,t+1)})}for(let r of[...e.files.keys()].sort(F8))n.push({kind:`file`,name:r,depth:t,file:e.files.get(r)});return n}function L8(e,t){let n=N8();for(let r of e){let e=P8(r.path,t);if(e.length===0)continue;let i=n;for(let t of e.slice(0,-1)){let e=i.dirs.get(t);e||(e=N8(),i.dirs.set(t,e)),i=e}i.files.set(e[e.length-1],r)}return I8(n,0)}function R8(e){let t=[],n=e=>{for(let r of e)t.push(r),r.kind===`dir`&&n(r.children)};return n(e),t}var z8=10;function B8({name:e,depth:t}){return(0,L.jsxs)(`div`,{"data-file-dir":e,className:`flex items-baseline text-[12px] leading-5 text-muted/70`,style:{paddingLeft:t*z8},children:[(0,L.jsx)(`span`,{className:`flex shrink-0`,children:(0,L.jsx)(Fm,{size:12,className:`${O$} text-muted/45`})}),(0,L.jsx)(`span`,{className:`ml-[5px] min-w-0 truncate`,title:e,children:e})]})}function V8({files:e}){return(0,L.jsx)(`div`,{"data-edited-file-tree":!0,className:`col-span-4 flex flex-col gap-y-px`,children:R8(L8(e,JC())).map(e=>e.kind===`dir`?(0,L.jsx)(B8,{name:e.name,depth:e.depth},`d:${e.depth}:${e.name}`):(0,L.jsx)(H8,{file:e.file,name:e.name,depth:e.depth},e.file.path))})}function H8({file:e,name:t,depth:n}){let r=Ve();return(0,L.jsx)(B$,{testKind:`file`,testId:e.path,mark:(0,L.jsx)(Nm,{size:12,className:`${O$} -mr-[2px] text-muted/60`}),name:t,indent:n*z8,onOpen:()=>wq(e.path),onPrewarm:()=>lC(r,e.path),title:e.path,status:(0,L.jsxs)(L.Fragment,{children:[(e.added??0)>0&&(0,L.jsxs)(`span`,{style:{color:UE.fgSuccess},children:[`+`,e.added]}),(e.added??0)>0&&(e.removed??0)>0&&` `,(e.removed??0)>0&&(0,L.jsxs)(`span`,{style:{color:UE.fgDanger},children:[`−`,e.removed]})]})})}function U8({thread:e}){let t=TE(),n=sw(e.id,{poll:!1}).data?.editedFiles??[],r=q$(e),i=(e.bgShells??[]).filter(e=>e.state===`running`),a=(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`),o=(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`),{railFilesCollapsed:s}=Zt(yT),c=[{head:`Sub-agents`,rows:r.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)(G$,{shell:n,slug:e.id,now:t},n.id??n.label))},{head:`Pull requests`,rows:a.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))},{head:`Edited files`,rows:n.length>0?[(0,L.jsx)(V8,{files:n},`tree`)]:[],count:n.length,collapsed:s,onToggle:()=>yT.railFilesCollapsed=!yT.railFilesCollapsed}].filter(e=>e.rows.length>0);return(0,L.jsx)(`aside`,{"data-focus-rail":!0,"aria-label":`Thread activity`,className:`flex h-full shrink-0 flex-col overflow-y-auto px-4 [view-transition-name:thread-rail]`,style:{width:340},children:(0,L.jsx)(`div`,{className:`my-auto py-6`,children:c.length===0?(0,L.jsx)(`div`,{className:`text-[11.5px] text-muted/50`,children:`Nothing running, watched or edited yet.`}):(0,L.jsx)(e1,{groups:c,divider:!1})})})}function W8(){let e=Zt(X),t=e.toast,[n,r]=(0,I.useState)(!1),i=e.drawers.some(e=>!e.closing);return(0,I.useEffect)(()=>{if(!t||(r(!0),t.sticky))return;let e=setTimeout(()=>r(!1),t.duration??(t.link?5e3:1600));return()=>clearTimeout(e)},[t?.id]),t?(0,L.jsx)(`div`,{className:`pointer-events-none fixed right-4 z-[70] flex justify-end ${i?`bottom-20`:`bottom-4`}`,children:(0,L.jsxs)(`div`,{"data-toast":!0,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`flex max-w-[min(30rem,calc(100vw-2rem))] items-center gap-2.5 break-words rounded-lg border border-border-strong bg-elevated px-4 py-2 text-[13px] font-medium text-fg shadow-xl shadow-black/40 transition-all duration-200 ease-out ${n?`translate-y-0 opacity-100`:`translate-y-8 opacity-0`}`,children:[t.spinner&&(0,L.jsx)(Xm,{size:13,className:`animate-spin text-muted`}),t.text,t.link&&(0,L.jsx)(`button`,{onClick:()=>{_p(`thread`,t.link.slug),X.toast=null},className:`pointer-events-auto shrink-0 rounded-md border border-border px-2 py-0.5 text-[12px] text-fg/90 transition-colors hover:bg-panel-2`,children:t.link.label})]})}):null}var G8=`max(50%, calc(100% - 720px))`,K8={"--full-thread":`min(720px, ${G8})`,"--full-thread-narrow":`min(720px, 100%)`,"--full-pane":G8,"--full-gutter":`max(0px, calc((100% - min(720px, ${G8}) - 340px) / 2))`};function q8(e,t){return`${jd(e)}${Ld(t,`/`)}`}function J8({slug:e}){let t=!!Zt(X).filePanel,n=qC(),r=Td(n,e),i=r.kind===`found`?r.thread:void 0;n?.projectDir,(0,I.useEffect)(()=>{Y.board().then(Up).catch(()=>{})},[]),(0,I.useEffect)(()=>{let e=window.matchMedia(`(min-width: ${Jp}px)`),t=()=>{X.splitFileViewer=e.matches};return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),X.splitFileViewer=!1,X.filePanel=null}},[]);let a=i?.runtime===`turn-idle`||i?.runtime===`exited`||i?.runtime===`none`;return(0,I.useEffect)(()=>{!i||!a||Y.threadSeen({slug:e}).catch(()=>{})},[a,e,i?.lastActivityAt]),(0,I.useEffect)(()=>{let t=n?.projectLabel??n?.projectName,r=i?CT(i):e;document.title=t?`${r} · ${t} — Frizz`:`${r} · Frizz`},[n?.projectLabel,n?.projectName,e,i]),(0,L.jsx)(tM,{children:(0,L.jsxs)(`div`,{className:`h-dvh min-h-0 bg-bg text-sm text-fg`,children:[(0,L.jsx)(`div`,{className:`h-full w-full overflow-hidden`,children:(0,L.jsxs)(`div`,{className:`flex h-full w-full justify-center transition-transform duration-200 ease-out motion-reduce:transition-none split:justify-start`,style:{...K8,transform:t?`translateX(calc(-1 * var(--full-gutter)))`:void 0},children:[(0,L.jsx)(`div`,{className:`hidden w-[var(--full-gutter)] shrink-0 split:block`,"aria-hidden":`true`}),(0,L.jsx)(`main`,{"data-standalone-thread":!0,className:`flex h-full w-[var(--full-thread-narrow)] min-w-0 shrink-0 flex-col overflow-hidden border-border bg-panel sm:border-x split:w-[var(--full-thread)] [view-transition-name:thread-chat]`,children:r.kind===`loading`?(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,role:`status`,"aria-label":`Loading thread`,children:(0,L.jsx)(`span`,{className:`block h-5 w-5 animate-spin rounded-full border-2 border-muted/50 border-t-transparent`})}):r.kind===`missing`?(0,L.jsx)(X8,{slug:e}):(0,L.jsx)(j0,{slug:e,virtualized:!0,showReturnToQueue:!0})}),i?(0,L.jsx)(Y8,{slug:e,thread:i}):(0,L.jsx)(`div`,{className:`hidden w-[var(--full-pane)] shrink-0 split:block`,"aria-hidden":`true`})]})}),(0,L.jsx)(w4,{}),(0,L.jsx)(W8,{})]})})}function Y8({slug:e,thread:t}){let n=Zt(X).filePanel,[r,i]=(0,I.useState)(null),a=n?.path??r;return(0,I.useEffect)(()=>{if(n){i(n.path);return}let e=window.setTimeout(()=>i(null),210);return()=>window.clearTimeout(e)},[n]),(0,L.jsxs)(`div`,{"data-side-pane":!0,className:`relative hidden h-full w-[var(--full-pane)] min-h-0 min-w-0 shrink-0 grow-0 overflow-hidden split:block`,children:[(0,L.jsx)(`div`,{inert:n?!0:void 0,className:`h-full min-h-0`,children:(0,L.jsx)(U8,{thread:t})}),(0,L.jsx)(`aside`,{"data-file-viewer-slot":!0,"aria-hidden":!n,className:`absolute inset-0 transition-[translate,opacity] duration-200 ease-out motion-reduce:transition-none ${n?`translate-x-0 opacity-100`:`translate-x-full opacity-0`}`,children:a&&(0,L.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-panel`,children:(0,L.jsx)(M8,{slug:e,path:a},a)})})]})}function X8({slug:e}){let{data:t,isPending:n}=nt({queryKey:[`threadLocate`,e],queryFn:()=>Y.threadLocate({slug:e})});return(0,I.useEffect)(()=>{t?.length===1&&location.replace(q8(t[0].projectSlug,e))},[t,e]),(0,L.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4 px-6 text-center`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`font-medium text-fg`,children:`Thread unavailable`}),n?(0,L.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Looking for “`,e,`” in your other projects…`]}):t&&t.length>0?(0,L.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`“`,e,`” lives in `,t.length===1?`another project`:`these projects`,` — opening it there.`]}):(0,L.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Thread “`,e,`” was not found in any project on this machine.`]})]}),t&&t.length>1?(0,L.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:t.map(t=>(0,L.jsx)(`a`,{href:q8(t.projectSlug,e),className:`rounded-md border border-border px-3 py-1.5 text-[12px] text-fg/90 hover:bg-panel-2`,children:t.projectName},t.projectSlug))}):(0,L.jsx)(`a`,{href:`/`,className:`rounded-md border border-border px-3 py-1.5 text-[12px] text-fg/90 hover:bg-panel-2`,children:`All projects`})]})}var Z8={OPEN_ISSUE:{bg:UE.bgSuccessEmphasis,icon:Tm,label:`Open`},CLOSED_ISSUE:{bg:UE.bgDoneEmphasis,icon:Cm,label:`Closed`},NOT_PLANNED:{bg:UE.bgNeutralEmphasis,icon:Dm,label:`Closed as not planned`},OPEN_PR:{bg:UE.bgSuccessEmphasis,icon:Vm,label:`Open`},DRAFT:{bg:UE.bgNeutralEmphasis,icon:Bm,label:`Draft`},MERGED:{bg:UE.bgDoneEmphasis,icon:Rm,label:`Merged`},CLOSED_PR:{bg:UE.bgDangerEmphasis,icon:zm,label:`Closed`}};function Q8(e){return e.kind===`commit`?null:e.state===`MERGED`?`MERGED`:e.state===`DRAFT`?`DRAFT`:e.state===`OPEN`?e.kind===`pr`?`OPEN_PR`:`OPEN_ISSUE`:e.state===`CLOSED`?e.kind===`pr`?`CLOSED_PR`:e.stateReason===`NOT_PLANNED`?`NOT_PLANNED`:`CLOSED_ISSUE`:null}function $8(e,t=Date.now()){if(!e)return``;let n=new Date(e);if(Number.isNaN(n.getTime()))return``;let r=n.getFullYear()===new Date(t).getFullYear();return n.toLocaleDateString(void 0,{month:`short`,day:`numeric`,...r?{}:{year:`numeric`}})}function e5(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?Math.floor(Math.max(0,t-n)/864e5)>=360?`on ${$8(e,t)}`:mE(e,t)??``:``}function t5(e,t){let n=e+t;if(n<=0)return[,,,,,].fill(`none`);let r=Math.min(5,Math.floor(e/n*5)),i=Math.min(5-r,Math.floor(t/n*5));return[...Array(r).fill(`add`),...Array(i).fill(`del`),...Array(5-r-i).fill(`none`)]}var n5={add:UE.fgSuccess,del:UE.fgDanger},r5={add:{backgroundColor:UE.bgSuccessEmphasis,borderColor:UE.bgSuccessEmphasis},del:{backgroundColor:UE.bgDangerEmphasis,borderColor:UE.bgDangerEmphasis},none:{backgroundColor:`${UE.bgNeutralEmphasis}33`,borderColor:`#3d444d`}};function i5({additions:e,deletions:t}){return(0,L.jsxs)(`div`,{className:`flex items-baseline gap-1.5 text-[12px] tabular-nums`,children:[(0,L.jsxs)(`span`,{"data-gh-add":!0,style:{color:n5.add},children:[`+`,e.toLocaleString()]}),(0,L.jsxs)(`span`,{"data-gh-del":!0,style:{color:n5.del},children:[`−`,t.toLocaleString()]}),(0,L.jsx)(`span`,{"data-gh-blocks":!0,className:`ml-0.5 inline-flex gap-[1px] self-baseline translate-y-[calc(4px_-_0.5cap)]`,children:t5(e,t).map((e,t)=>(0,L.jsx)(`span`,{className:`size-[8px] rounded-[2px] border`,style:r5[e]},t))})]})}function a5({card:e}){let t=Q8(e),n=t?Z8[t]:void 0;if(!n)return null;let r=n.icon;return(0,L.jsxs)(`span`,{"data-gh-pill":!0,className:`inline-flex items-baseline gap-1 rounded-full px-2.5 py-1 text-[12px] font-medium text-white`,style:{backgroundColor:n.bg},children:[(0,L.jsx)(r,{strokeWidth:2,"aria-hidden":!0,className:`size-[1.1em] shrink-0 self-baseline -mr-px translate-y-[calc(0.55em_-_0.5cap)]`}),(0,L.jsx)(`span`,{"data-gh-pill-label":!0,children:n.label})]})}function o5({name:e,color:t}){let n=/^[0-9a-fA-F]{6}$/.test(t)?`#${t}`:`#8b8f96`;return(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full border px-2 py-[1px] text-[11px] font-medium`,style:{color:n,backgroundColor:`${n}26`,borderColor:`${n}59`},children:e})}var s5=/`([^`\n]+)`/g;function c5(e,t){if(!t)return[e];let n=[],r=0;for(let t of e.matchAll(s5))t.index>r&&n.push(e.slice(r,t.index)),n.push({code:t[1]}),r=t.index+t[0].length;return r<e.length&&n.push(e.slice(r)),n}function l5({text:e,code:t,className:n}){return(0,L.jsx)(`div`,{className:n,children:c5(e,t).map((e,t)=>typeof e==`string`?e:(0,L.jsx)(`code`,{className:`rounded-[3px] bg-panel-2 px-[3px] py-[1px] font-mono-keep text-[0.92em]`,children:e.code},t))})}var u5=new Set([`avatars.githubusercontent.com`,`camo.githubusercontent.com`]);function d5(e){if(e)try{let t=new URL(e);return t.protocol===`https:`&&u5.has(t.hostname)?e:void 0}catch{return}}function f5({card:e,nowMs:t}){let n=d5(e.authorAvatar),r=e.authorLogin??e.authorName??`Someone`,i=e.kind===`commit`?`committed`:e.kind===`pr`?`opened this pull request`:`opened this issue`,a=e5(e.at,t);return(0,L.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-2 text-[12px] text-muted`,children:[n?(0,L.jsx)(`img`,{"data-gh-avatar":!0,src:n,alt:``,className:`size-[18px] shrink-0 rounded-full`}):(0,L.jsx)(`span`,{"data-gh-avatar":!0,className:`size-[18px] shrink-0 rounded-full bg-border`}),(0,L.jsxs)(`span`,{"data-gh-byline-text":!0,className:`truncate`,children:[(0,L.jsx)(`span`,{className:`text-fg`,children:r}),` `,i,` `,a]})]})}var p5=`w-[360px] max-w-[min(360px,calc(100vw-24px))] leading-normal`;function m5({card:e,nowMs:t=Date.now()}){let n=e.additions!==void 0&&e.deletions!==void 0;if(e.kind===`commit`)return(0,L.jsxs)(`div`,{className:p5,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline gap-2 px-3 pt-3 pb-2.5`,children:[(0,L.jsx)(`span`,{"data-gh-commit-glyph":!0,className:`shrink-0 self-baseline -mr-px text-[14px] translate-y-[calc(0.5em_-_0.5cap)]`,children:(0,L.jsx)(Lm,{className:`size-[1em] text-muted`,"aria-hidden":!0})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`a`,{"data-gh-title":!0,href:e.url,target:`_blank`,rel:`noreferrer noopener`,tabIndex:-1,className:`block text-[14px] font-semibold leading-snug text-fg hover:underline`,children:e.title}),e.body?(0,L.jsx)(l5,{text:e.body,code:!1,className:`mt-1.5 line-clamp-6 text-[12px] text-muted`}):null,n?(0,L.jsx)(`div`,{className:`mt-2.5`,children:(0,L.jsx)(i5,{additions:e.additions,deletions:e.deletions})}):null]})]}),(0,L.jsx)(f5,{card:e,nowMs:t})]});let r=e.ref.slice(e.ref.indexOf(`#`));return(0,L.jsxs)(`div`,{className:p5,children:[(0,L.jsxs)(`div`,{className:`px-3 pt-3 pb-3`,children:[(0,L.jsxs)(`div`,{className:`text-[12px] text-muted`,children:[(0,L.jsx)(`span`,{className:`underline decoration-border underline-offset-2`,children:e.repo}),e.at?` on ${$8(e.at,t)}`:``]}),(0,L.jsxs)(`a`,{"data-gh-title":!0,href:e.url,target:`_blank`,rel:`noreferrer noopener`,tabIndex:-1,className:`mt-1 block text-[14px] font-semibold leading-snug text-fg hover:underline`,children:[e.title,` `,(0,L.jsx)(`span`,{className:`font-normal text-muted`,children:r})]}),(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,L.jsx)(a5,{card:e}),n?(0,L.jsx)(i5,{additions:e.additions,deletions:e.deletions}):null]})]}),e.body||e.labels.length>0?(0,L.jsxs)(`div`,{className:`border-t border-border px-3 py-2.5`,children:[e.body?(0,L.jsx)(l5,{text:e.body,code:!0,className:`line-clamp-2 text-[12px] text-muted`}):null,e.labels.length>0?(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1 ${e.body?`mt-2`:``}`,children:e.labels.map(e=>(0,L.jsx)(o5,{name:e.name,color:e.color},e.name))}):null]}):null,(0,L.jsx)(f5,{card:e,nowMs:t})]})}var h5=250,g5=180;function _5(e){let t=e.getClientRects()[0]??e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}}function v5(){let[e,t]=(0,I.useState)(null),n=(0,I.useRef)(void 0),r=(0,I.useRef)(void 0),i=(0,I.useRef)(!1),a=(0,I.useCallback)(()=>{clearTimeout(n.current),clearTimeout(r.current),n.current=void 0,r.current=void 0},[]),o=(0,I.useCallback)(()=>{clearTimeout(r.current),r.current=setTimeout(()=>{i.current||t(null)},g5)},[]);return(0,I.useEffect)(()=>{let i=i=>{if(i.pointerType!==`mouse`)return;let a=i.target?.closest?.(`a[data-gh-ref]`)??null,o=a?.getAttribute(`data-gh-ref`);!a||!o||(clearTimeout(r.current),e?.ref!==o&&(clearTimeout(n.current),jf([o]),n.current=setTimeout(()=>t({ref:o,rect:_5(a)}),h5)))},a=e=>{e.pointerType===`mouse`&&e.target?.closest?.(`a[data-gh-ref]`)&&(clearTimeout(n.current),o())};return document.addEventListener(`pointerover`,i),document.addEventListener(`pointerout`,a),()=>{document.removeEventListener(`pointerover`,i),document.removeEventListener(`pointerout`,a)}},[e?.ref,o]),(0,I.useEffect)(()=>{if(!e)return;let n=()=>{i.current=!1,a(),t(null)};return window.addEventListener(`scroll`,n,!0),window.addEventListener(`resize`,n),()=>{window.removeEventListener(`scroll`,n,!0),window.removeEventListener(`resize`,n)}},[e,a]),(0,I.useEffect)(()=>a,[a]),(0,L.jsxs)(TV,{open:e!==null,children:[(0,L.jsx)(DV,{asChild:!0,children:(0,L.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none fixed`,style:{top:e?.rect.top??0,left:e?.rect.left??0,width:e?.rect.width??0,height:e?.rect.height??0}})}),e?(0,L.jsx)(OV,{side:`top`,align:`start`,sideOffset:8,alignOffset:-8,"aria-hidden":!0,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onPointerEnter:()=>{i.current=!0,clearTimeout(r.current)},onPointerLeave:()=>{i.current=!1,o()},className:`overflow-hidden`,children:(0,L.jsx)(y5,{refKey:e.ref})}):null]})}function y5({refKey:e}){let t=(0,I.useSyncExternalStore)(Ef,()=>Df(e),()=>Df(e));return(0,I.useEffect)(()=>{Of(Df(e))&&Ff(e)},[e]),t?.card?(0,L.jsx)(m5,{card:t.card}):(0,L.jsx)(`div`,{className:`flex h-[64px] w-[220px] items-center px-3 text-[12px] text-muted`,children:t?.missing?`Not found on GitHub`:`Loading…`})}var b5=`frizz-project-rail`;function x5(){try{return localStorage.getItem(b5)===`shown`}catch{return!1}}function S5(e){try{localStorage.setItem(b5,e?`shown`:`hidden`)}catch{}}function C5(){ey();let e=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet(),placeholderData:ee}).data?.projectRail;return(0,I.useEffect)(()=>{e!==void 0&&S5(e===!0)},[e]),e===void 0?x5():e===!0}var w5=`/project/:slug`;function T5(){A5();let e=C5();return(0,L.jsxs)(tM,{children:[e?(0,L.jsx)(v8,{}):null,(0,L.jsx)(`div`,{className:e?o8:void 0,children:(0,L.jsx)(Iy,{})}),(0,L.jsx)(W8,{}),(0,L.jsx)(v5,{})]})}function E5(e){(0,I.useEffect)(()=>{OC(e)||(Hp(),GC())},[e])}function D5(){let{slug:e,thread:t}=oy();return E5(e),k5(),(0,I.useState)(()=>wp(t)),(0,L.jsx)(e8,{},e??`__launching__`)}function O5(){return(0,L.jsx)(k8,{})}function k5(){let e=ey();(0,I.useEffect)(()=>{gw(Nd(e.pathname))},[e.pathname])}function A5(){let e=ny();(0,I.useEffect)(()=>(yw((t,n)=>e(t,n)),()=>yw(null)),[e])}function j5(){let{thread:e,slug:t}=oy();return A5(),E5(t),(0,I.useState)(()=>{X.drawers.length>0&&(X.drawers=[])}),Cp(e),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(J8,{slug:e}),(0,L.jsx)(W8,{})]})}var M5=[{index:!0,element:(0,L.jsx)(D5,{})},{path:`thread/:thread`,element:(0,L.jsx)(D5,{})},{path:`status/:status`,element:(0,L.jsx)(D5,{})}],N5=Eb([{path:`/thread/:thread/full`,element:(0,L.jsx)(j5,{})},{path:`${w5}/thread/:thread/full`,element:(0,L.jsx)(j5,{})},{element:(0,L.jsx)(T5,{}),children:[{path:`/`,element:(0,L.jsx)(O5,{})},{path:`/thread/:thread`,element:(0,L.jsx)(D5,{})},{path:`/status/:status`,element:(0,L.jsx)(D5,{})},{path:w5,children:M5},{path:`*`,element:(0,L.jsx)(D5,{})}]}]),P5=24,F5=6,I5=700,L5=new Map,R5=null,z5=null;function B5(e){return!Array.isArray(e)||e.length!==2?null:e[0]===`transcript`&&typeof e[1]==`string`?e[1]:null}function V5(e){return X.board?.threads.find(t=>t.id===e)?.lastActivityAt}function H5(){let e=[...L5.entries()].filter(([,e])=>e.observers>0),t=new Set(e.slice(-24).map(([e])=>e));for(let[e,n]of L5){if(n.observers<=0){n.live&&(n.live=!1,VC(e)),L5.delete(e);continue}t.has(e)?!n.live&&!n.queued&&(n.queued=!0):(n.queued=!1,n.live&&(n.live=!1,VC(e)))}U5()}function U5(){z5||[...L5.values()].some(e=>e.queued)&&(z5=setTimeout(()=>{z5=null;let e=0,t=[...L5.values()].filter(e=>e.live).length;for(let[n,r]of L5){if(e>=F5||t>=P5)break;r.queued&&(r.queued=!1,!(r.observers<=0||r.live)&&(r.live=!0,t++,r.lastActivityAt=V5(n),BC(n),e++))}U5()},I5))}function W5(){if(R5)for(let[e,t]of L5){if(t.observers<=0)continue;let n=V5(e);n!==t.lastActivityAt&&(t.lastActivityAt=n,!(t.live&&X.socketTranscripts)&&(X.socketTranscriptFallbacks[e]||R5.refetchQueries({queryKey:[`transcript`,e],exact:!0,type:`active`})))}}function G5(e){R5||(R5=e,e.getQueryCache().subscribe(e=>{let t=B5(e.query.queryKey);if(!t||e.type!==`observerAdded`&&e.type!==`observerRemoved`)return;let n=e.query.getObserversCount(),r=L5.get(t);e.type===`observerAdded`?(L5.delete(t),L5.set(t,{observers:n,live:r?.live??!1,queued:r?.queued??!1,lastActivityAt:r?r.lastActivityAt:V5(t)})):r&&(r.observers=n),H5()}),Jt(X,W5))}var K5=`ui-monospace, "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Mono", Consolas, Menlo, "DejaVu Sans Mono", monospace`,q5=`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;function J5(e){let t=e===`mono`?`mono`:`sans`;document.documentElement.dataset.font=t,document.body&&(document.body.style.fontFamily=t===`sans`?q5:K5);try{localStorage.setItem(`frizz-font`,t)}catch{}}function Y5(e){let t=e.getQueryData([`settingsGet`]);t&&J5(t.font),Y.settingsGet().then(e=>J5(e.font)).catch(()=>{}),e.getQueryCache().subscribe(()=>{let t=e.getQueryData([`settingsGet`]);t&&J5(t.font)})}function X5(){let e=e=>{if(e.button!==0||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`.${jS}`):null;t&&(e.preventDefault(),e.stopPropagation(),Q5(t))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)}function Z5(e){return e.closest(`.md-code`)?.querySelector(`pre code`)??null}async function Q5(e){let t=Z5(e);if(!t)return;let n=(t.textContent??``).replace(/\n$/,``);if(n){try{await HR(n)}catch(e){Z(`Could not copy code: ${e.message.slice(0,100)}`,{duration:7e3});return}e7(e)}}var $5=new WeakMap;function e7(e){e.classList.add(MS),e.title=`Copied`;let t=$5.get(e);t!==void 0&&window.clearTimeout(t),$5.set(e,window.setTimeout(()=>{e.classList.remove(MS),e.title=NS,$5.delete(e)},u1))}var t7=/^\/thread\/([a-z0-9][a-z0-9-]*)\/?$/;function n7(){let e=e=>{if(e.button!==0||e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target instanceof Element?e.target.closest(`a[href*="/thread/"]`):null,n=t?.getAttribute(`href`);if(!t||!n||!n.startsWith(`/`))return;let r=Ad(n);if(r&&r!==Ad())return;let i=t7.exec(Nd(n));i&&(e.preventDefault(),e.stopPropagation(),bp(i[1]))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)}var r7=new Set([`projectsList`,`projectsQueueCounts`,`threadLocate`,`dispatchPreferencesGet`,`supervisorStatus`]);function i7(e){let t=e[0];return typeof t==`string`&&r7.has(t)?T(e):T([`project:${Ad()??``}`,...e])}var a7=typeof window<`u`&&window.location.pathname.endsWith(`/settings-formatting-fixture.html`),o7=typeof window<`u`?Rd(Nd()):null;!a7&&!o7&&_w();var s7=new Le({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,queryKeyHashFn:i7}}});a7||(KC(s7),G5(s7),vH(s7),Y5(s7),kQ(),Sq(),X5(),n7()),a7||(0,at.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(He,{client:s7,children:(0,L.jsx)(jh,{children:(0,L.jsx)(My,{router:N5})})}));export{a as i,Id as n,ze as r,ib as t};
313
+ `)||void 0;return{line:`${e$(e)} ${t.label}${r?` — ${r}`:``}`,...i?{body:i}:{}}}var n$=`root`;function r$(e,t,n){return`${e}/${t}.${n}`}function i$(e){let t=e.options??[],n=t.findIndex(e=>e.recommended),r=t.map((e,t)=>t$(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 a$(e,t){return!t||e.kind===`multi`?null:t.chosen}function o$(e,t){let n=[],r=(e,i,a)=>{let{question:o,optionLabels:s}=i$(e);n.push({path:i,spec:e,question:o,optionLabels:s,depth:a});let c=a$(e,t.get(i));c!==null&&(e.options?.[c]?.followUps??[]).forEach((e,t)=>r(e,r$(i,c,t),a+1))};return r(e,n$,1),n}function s$(e,t){return t?t.text.trim()?!0:e.kind===`multi`?(t.chosenSet??[]).length>0:t.chosen!==null:!1}function c$(e,t){if(!s$(e.spec,t.get(`root`)))return;let n=(r,i)=>{let a=t.get(i),o=(r.options??[]).map(e=>e.label),s=a$(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,r$(i,s,t)));return{questionId:e.id,question:r.question,chosen:c,...l?{text:l}:{},...u.length>0?{followUps:u}:{}}};return n(e.spec,n$)}function l$(e){let t=e instanceof Error?e.message:`The answer could not be sent.`;return t.length>240?`${t.slice(0,239)}…`:t}var u$=(e,t)=>`${e}|${t}`,d$=(0,I.createContext)(null);function f$(e){let t=e?.id,n=e?.questions??[],r=Oz(),[i,a]=(0,I.useState)(()=>new Map),[o,s]=(0,I.useState)(),c=(0,I.useContext)(A0),l=jz((0,I.useMemo)(()=>t?n.flatMap(e=>g$(e).map(n=>Dz.question(r,t,e.id,n))):[],[r,t,n])),u=(e,n)=>{let a=i.get(u$(e.id,n));return{chosen:a?.chosen??null,chosenSet:a?.chosenSet??[],text:(t?l.get(Dz.question(r,t,e.id,n)):void 0)??``}},d=e=>new Map(g$(e).map(t=>[t,u(e,t)])),f=n.flatMap(e=>{let t=c$(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 g$(e))Tz.set(Dz.question(r,t,e.id,n),``)}},onError:e=>{c?.cancel(),s(l$(e))}}),m=it({mutationFn:async e=>Y.dismissQuestions({slug:t,ids:[e]}),onError:e=>s(l$(e))});return{slug:t,answerFor:u,answersOf:d,onChip:(e,t,n,r)=>{a(i=>{let a=new Map(i),o=u$(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&&(Tz.set(Dz.question(r,t,e.id,n),o),i||a(t=>{let r=u$(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 p$({thread:e,children:t}){let n=f$(e);return(0,L.jsx)(d$.Provider,{value:n,children:t})}function m$({q:e,answering:t}){let n=(0,I.useContext)(d$),r=t??n;if(!r||!r.slug)return null;let i=o$(e.spec,r.answersOf(e)),a=t=>(0,L.jsx)(oX,{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 h$({thread:e,questions:t,inFlight:n=null,showSend:r=!1,className:i=``}){let a=e?.id,o=t??e?.questions??[],s=(0,I.useContext)(d$),c=f$(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)(JY,{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)(m$,{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 g$(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,n$),t}function _$(e){return(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).length}function v$(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:_$(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 y$(e){return(e.subAgents??[]).some(e=>Xc(e)&&e.state===`running`)}function b$(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length}function x$(e){return y$(e)||b$(e)>0}function S$(e,t){return ul(t)??(C$(e)?`Background shells running`:`Awaiting`)}function C$(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length>0&&!y$(e)&&_$(e)===0&&w$(e).length===0}function w$(e){return(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`)}var T$={id:``,subAgents:[],bgShells:[],watches:[]},E$=[];function D$(e,t){let n=new Set((e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).map(e=>e.target));return lU(t).filter(e=>!n.has(e.ref))}function O$({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:`${BJ} text-[12px]`,children:e.ref}):(0,L.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.ref})}var k$={mergeable:`no conflicts`,blocked:`merge blocked`,conflicting:`has conflicts`,unknown:null};function A$(e){return e.state!==`open`||e.merge===`blocked`&&e.checks!==`passing`&&e.checks!==`none`?null:k$[e.merge]}var j$=`shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`;function M$({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 ${j$}`})}function N$(){return(0,L.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 16 16`,width:12,height:12,fill:`none`,stroke:`currentColor`,overflow:`visible`,className:j$,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 P$({status:e}){return e?e.state===`merged`?(0,L.jsx)(Rm,{size:12,className:j$,style:{color:UE.fgDone}}):e.state===`closed`?(0,L.jsx)(zm,{size:12,className:j$,style:{color:UE.fgDanger}}):e.checks===`failing`?(0,L.jsx)(Om,{size:12,className:j$,style:{color:UE.fgDanger}}):e.checks===`passing`?(0,L.jsx)(Cm,{size:12,className:j$,style:{color:UE.fgSuccess}}):e.gated>0&&e.running===0?(0,L.jsx)(Sm,{size:12,className:j$,style:{color:UE.fgAttention}}):e.checks===`running`?(0,L.jsx)(N$,{}):(0,L.jsx)(wm,{size:12,className:`${j$} text-muted/60`}):(0,L.jsx)(wm,{size:12,className:`${j$} text-muted/60`})}function F$(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 I$(e){if(!e)return`Checking…`;if(e.state===`merged`)return`Merged`;if(e.state===`closed`)return`Closed`;let t=F$(e),n=A$(e);return[t||`No checks`,n].filter(e=>e!==null).join(` · `)}var L$=`group relative col-span-4 grid grid-cols-subgrid items-baseline rounded-sm text-[12px] leading-5`,R$=`group relative col-span-4 flex items-baseline rounded-sm text-[12px] leading-5`,z$=`ml-1.5 min-w-0 truncate font-medium text-fg/90`,B$=`ml-3 min-w-0 truncate text-right text-muted/70`,V$=`outline-none after:absolute after:inset-0 after:rounded-sm focus-visible:after:ring-1 focus-visible:after:ring-fg/60`;function H$(){return(0,L.jsx)(ym,{size:13,"aria-hidden":!0,className:`${j$} ml-[3px] -mr-[4px] text-muted/35 transition-colors group-hover:text-muted/70`})}function U$({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?`${z$} flex-1`:z$,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} ${V$} 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} ${V$} 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?R$:L$} ${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:B$,children:n}),m?(0,L.jsx)(H$,{}):(0,L.jsx)(`span`,{})]})}function W$({watch:e}){let t=e.github,n=sU(e.target);return(0,I.useEffect)(()=>{n&&jf([e.target])},[n,e.target]),(0,L.jsx)(U$,{testKind:`github`,testId:e.target,mark:(0,L.jsx)(P$,{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:[I$(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 G$(e,t){return(e.bgShells??[]).find(e=>e.id===t||e.taskId===t||e.label===t)}function K$(e){return(e.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`)}function q$({watch:e,thread:t,slug:n,now:r}){let i=G$(t,e.target);if(i)return(0,L.jsx)(J$,{shell:i,slug:n,now:r,testId:e.target});let a=RE(e.createdAt,r);return(0,L.jsx)(U$,{testKind:`shell`,testId:e.target,mark:(0,L.jsx)(vh,{size:12,className:`${j$} text-shell`}),name:e.target,title:e.target,status:a?`running · ${a}`:`running`})}function J$({shell:e,slug:t,now:n,testId:r}){let i=RE(e.startedAt,n),a=e.id&&!e.outputUnavailable;return(0,L.jsx)(U$,{testKind:`shell`,testId:r??e.id??e.label,mark:(0,L.jsx)(vh,{size:12,className:`${j$} 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 Y$({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)(U$,{testKind:`timer`,testId:e.target,mark:(0,L.jsx)(km,{size:12,className:`${j$} 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 X$(e){return(e.subAgents??[]).filter(e=>Xc(e)&&e.state===`running`)}function Z$({agent:e,slug:t,now:n}){let r=RE(e.startedAt,n),i=e.subagentType?.replace(/^frizz:/,``);return(0,L.jsx)(U$,{testKind:`agent`,testId:e.id??e.label,mark:(0,L.jsx)(M$,{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 Q$(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=G$(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 $$(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=K$(e).filter(t=>r(G$(e,t.target)?.startedAt??t.createdAt));return{prs:i,shells:[...a,...Q$(e,t.hints??[],a)],agents:X$(e).filter(e=>r(e.startedAt)),timers:w$(e).filter(e=>r(e.createdAt))}}function e1(e,t={}){let n=$$(e,t);return n.prs.length+n.shells.length+n.agents.length+n.timers.length>0}function t1(e,t,n={}){let{prs:r,shells:i,agents:a,timers:o}=$$(e,n);return[{head:`Sub-agents`,rows:a.map(n=>(0,L.jsx)(Z$,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:i.map(n=>(0,L.jsx)(q$,{watch:n,thread:e,slug:e.id,now:t},n.id))},{head:`Pull requests`,rows:r.map(e=>(0,L.jsx)(W$,{watch:e},e.id))},{head:`Timers`,rows:o.map(e=>(0,L.jsx)(Y$,{watch:e,now:t},e.id))}].filter(e=>e.rows.length>0)}function n1({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:`${j$} ml-[5px] transition-transform ${e.collapsed?``:`rotate-90`}`})]}):(0,L.jsx)(`div`,{className:n,children:e.head})}function r1({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)(n1,{group:e,first:t===0}),!e.collapsed&&e.rows]},e.head))})]})}function i1(e){return e?.awaitingBackground===!0&&e.runtime===`turn-idle`&&e.bgSnoozed!==!0}var a1=`Hides card until new activity is detected`;function o1({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:a1,className:`disabled:opacity-45 ${VJ}`,children:[(0,L.jsx)(Um,{size:12,className:CX}),`Snooze`]}),(0,L.jsx)(`span`,{className:zJ,children:a1})]})}function s1({thread:e,fence:t,onSnooze:n,onSnoozeFailed:r,notAfter:i}){let a=e??T$,o=t??(e?.lastFence?.kind===`awaiting`?e.lastFence:void 0),s=o?.hints??E$,c=y$(a),l=hU(o?.body),u=XK(l??``),d=t1(a,TE(),{hints:s,notAfter:i}),f=D$(a,s),p=i===void 0&&e!==void 0&&i1(e)&&aZ(e).snooze;return(0,L.jsxs)(IJ,{"data-awaiting-background":!0,icon:C$(a)?vh:Um,label:(0,L.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:S$(a,s)}),aside:f.length===1?(0,L.jsx)(O$,{watch:f[0]}):void 0,className:p?`pb-0`:``,children:[l?(0,L.jsx)(Yq,{className:`md-body ${OJ}`,html:u}):d.length===0&&!x$(a)?(0,L.jsx)(`p`,{className:LJ,children:cU}):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)(O$,{watch:e},e.ref))}),d.length===0&&x$(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 `,v$(a,{watchers:!1}),` it dispatched. It returns to the queue on its own when the work comes back.`]}):(0,L.jsxs)(L.Fragment,{children:[v$(a,{watchers:!1}),` `,b$(a)===1?`is`:`are`,` still running. It resumes on its own when`,` `,b$(a)===1?`it finishes`:`one of them finishes`,`.`]})}),(0,L.jsx)(r1,{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 ${jJ}`,children:(0,L.jsx)(o1,{thread:e,onSnooze:n,onSnoozeFailed:r})}):null]})}function c1(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 l1(e,t=Date.now()){return e!==void 0&&GT(e,t)!==void 0}function u1(){let[e,t]=(0,I.useState)(()=>Date.now());return(0,I.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function d1({thread:e}){let t=u1(),[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)(IJ,{"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:LJ,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)(RJ,{children:(0,L.jsx)(`button`,{type:`button`,"data-snooze-wake-now":!0,disabled:n,onClick:()=>void c(),className:`${VJ} disabled:cursor-not-allowed disabled:opacity-45`,children:`Wake now`})})]})}function f1({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 p1=1500;function m1(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},p1),a},fail(t){t===n&&(i(),e(!1))},dispose(){n++,i()}}}var h1=`Could not copy terminal command`,g1={attach:`Attach command copied`,resume:`Resume command copied`},_1={attach:`Copy command to attach to this thread's live terminal`,resume:`Copy command to resume this thread in a new terminal`},v1=e=>[`terminalCommand`,e];function y1(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 b1(e){let t=y1(e);if(typeof ClipboardItem<`u`&&navigator.clipboard?.write)return await navigator.clipboard.write([new ClipboardItem({"text/plain":t.then(({command:e})=>new Blob([e],{type:`text/plain`}))})]),(await t).mode;let{command:n,mode:r}=await t;return await WR(n),r}function x1(e){let t=it({mutationFn:()=>b1(e)});return e=>t.mutate(void 0,{onSuccess:t=>{e?.onSuccess?.(),Z(g1[t])},onError:t=>{e?.onError?.(),Z(t instanceof Error?`${h1}: ${t.message}`:h1,{duration:7e3})}})}function S1({slug:e}){let[t,n]=(0,I.useState)(!1),r=(0,I.useRef)(null);r.current||=m1(n,{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)});let i=Ve(),a=x1(e);(0,I.useEffect)(()=>()=>r.current?.dispose(),[]);function o(){i.prefetchQuery({queryKey:v1(e),queryFn:()=>y1(e),staleTime:15e3})}function s(){let t=i.getQueryData(v1(e));if(t){WR(t.command).then(()=>{r.current?.begin(),Z(g1[t.mode])},()=>Z(h1,{duration:7e3}));return}a({onSuccess:()=>r.current?.begin()})}let c=i.getQueryData(v1(e)),l=t?c?g1[c.mode]:`Terminal command copied`:c?_1[c.mode]:`Copy terminal command`;return(0,L.jsx)(iM,{label:l,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":l,title:l,onClick:s,onPointerEnter:o,onFocus:o,className:xD,children:t?(0,L.jsx)(gm,{size:14,strokeWidth:2.2,className:`text-fg`}):(0,L.jsx)(vh,{size:14,strokeWidth:1.8})})})}function C1(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 w1(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 T1(e){return`legacy:${e.role}:${e.kind??`message`}:${e.at??``}:${e.text}`}function E1(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??T1(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 D1(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 O1(e,t){let n=e.map(e=>e.message);return e.filter((e,r)=>!D1(n,r,t))}var k1=new Set([`agent`,`follow up`,`interrupt`,`send message`,`spawn agent`,`wait for agents`]),A1=new Set([`poll process`,`wait`]);function j1(e){return(e.split(`__`).pop()||e).replaceAll(`_`,` `).trim()}function M1(e){return j1(e).toLowerCase()}function N1(e){return e.prompt!==void 0||e.agentId!==void 0||e.sendTo!==void 0||e.sendBody!==void 0||e.backgroundState!==void 0&&!I1(e)||F1(e)||P1(e)||k1.has(M1(e.name))}function P1(e){return e.ask!==void 0&&e.ask.length>0&&e.status!==void 0&&e.status!==`pending`}function F1(e){return e.outputImage!==void 0||e.sentImages!==void 0&&e.sentImages.length>0}function I1(e){return e.backgroundState===`unknown`&&A1.has(M1(e.name))}function L1(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=>!N1(e))?t:null}return e.text.trim()||e.tools.length===0?null:e.tools.every(e=>!N1(e))?e.tools:null}function R1(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 z1(e){if(e.role!==`assistant`||e.kind||e.queued)return null;if(!e.parts?.length)return B1(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 B1(n.tools)}return null}function B1(e){let t=[];for(let n=e.length-1;n>=0&&!N1(e[n]);n--)t.unshift(e[n]);return t.length>0?t:null}function V1(e){if(e.role!==`assistant`||e.kind||e.queued)return null;let t=[],n=e=>{for(let n of e){if(N1(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 H1(e,t){return U1(e,new Set(t))}function U1(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 W1(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 G1(e){let t=[],n=null;return e.forEach((e,r)=>{if(R1(e))return;if(e.queued){t.push({message:e,messageIndex:r});return}let i=L1(e);if(i&&n){n.message=W1(n.message,i,e.at);return}let a=n?V1(e):null,o=a?H1(e,a):e;a&&n&&(n.message=W1(n.message,a,e.at));let s={message:o,messageIndex:r};t.push(s),z1(o)?(s.runStartedAt=o.at,n=s):n=null}),t}function K1(e){return e.status===`completed`||e.status===`failed`||e.status===`cancelled`}function q1(e){let t=J1(e);return t?.tools.some(e=>!K1(e))?t.tools.at(-1):void 0}function J1(e){let t=Y1(e);if(!t)return;let n=z1(t.message);return n?{tools:n,at:t.message.at}:void 0}function Y1(e){for(let t=e.length-1;t>=0;t--)if(!e[t].message.queued)return e[t]}function X1(e){let t=Y1(e);if(t)return z1(t.message)?t.runStartedAt??t.message.at:t.message.at}function Z1(e){return e.runStartedAt??e.message.at}function Q1(e){let t=z1(e);return t?U1(e,new Set(t)):e}function $1(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].message;if(!r.queued){z1(r)&&(t=r);break}}if(!t)return[...e];let n=[];for(let r of e){let e=r.message===t?Q1(r.message):r.message;R1(e)||n.push(e===r.message?r:{...r,message:e})}return n}function e0(e){return e.detail?.trim()||void 0}var t0={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 n0(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=t0[i.toLowerCase()];return a?a+(r===-1?``:n.slice(r)):n.charAt(0).toUpperCase()+n.slice(1)}function r0(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 i0(e,t,n=Vf().home){return r0(a0(e),t,n)}function a0(e){let t=M1(e.name),n=e0(e),r=n?` ${n}`:``;return t===`bash`||t===`exec`||t===`run command`?n0(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 ${j1(e.name)||`a tool`}`}var o0=new Set([`edit`,`multiedit`,`write`,`apply patch`]);function s0(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&&o0.has(M1(n.name))&&t.add(e)}return t.size}function c0(e,t=0){let n=`Ran ${e} tool ${e===1?`call`:`calls`}`;return t===0?n:`${n}, edited ${t} file${t===1?``:`s`}`}function l0(e){return e>0?`${c0(e)}. Thinking…`:`Thinking…`}function u0(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function d0(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function f0(e,t){let n=u0(e,t);if(n)try{let e=new URL(n);return e.protocol===`https:`||e.protocol===`http:`?e.href:void 0}catch{return}}function p0({directive:e,icon:t,title:n,meta:r,children:i}){return(0,L.jsxs)(`section`,{"data-codex-directive":e.name,className:`min-w-0 ${kJ} 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 m0({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 h0({directive:e}){let t=e.attrs,n=u0(t,`display_name`)??u0(t,`skill_name`)??`Artifact template`,r=u0(t,`artifact_kind`),i=u0(t,`skill_name`),a=u0(t,`skill_directory`),[o,s]=(0,I.useState)(!!a);return(0,L.jsxs)(p0,{directive:e,icon:(0,L.jsx)(Jm,{size:15}),title:n,meta:r?`${r} template`:`Template`,children:[i&&(0,L.jsx)(m0,{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 g0({directive:e}){let t=e.attrs,n=u0(t,`file`),r=d0(t,`start`),i=d0(t,`end`)??r,a=d0(t,`priority`),o=n?`${n}${r?`:${r}${i&&i!==r?`-${i}`:``}`:``}`:`Code location unavailable`;return(0,L.jsxs)(p0,{directive:e,icon:(0,L.jsx)($m,{size:15}),title:u0(t,`title`)??`Review finding`,meta:a===void 0?void 0:`P${a}`,children:[u0(t,`body`)&&(0,L.jsx)(m0,{children:u0(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)(m0,{mono:!0,children:o})]})}var _0={"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 v0({directive:e}){let[t,n]=_0[e.name],r=u0(e.attrs,`branch`),i=f0(e.attrs,`url`),a=`${n}${e.attrs.isDraft===!0?` as draft`:``}`;return(0,L.jsx)(p0,{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 y0({directive:e}){let t=u0(e.attrs,`threadId`),n=u0(e.attrs,`pendingWorktreeId`);return(0,L.jsx)(p0,{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 b0({directive:e}){let t=u0(e.attrs,`reason`);return(0,L.jsx)(p0,{directive:e,icon:(0,L.jsx)(um,{size:15}),title:`Archive suggested`,meta:t})}function x0(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 S0({directive:e}){let t=e.attrs,n=u0(t,`mode`),r=u0(t,`name`)??`Automation`,i=x0(t.rrule),a=[r,n,u0(t,`status`),i].filter(Boolean).join(` · `);return(0,L.jsx)(p0,{directive:e,icon:(0,L.jsx)(hm,{size:15}),title:`Automation suggested`,meta:a,children:u0(t,`prompt`)&&(0,L.jsx)(m0,{children:u0(t,`prompt`)})})}function C0({directive:e}){return e.name===`artifact-template`?(0,L.jsx)(h0,{directive:e}):e.name===`code-comment`?(0,L.jsx)(g0,{directive:e}):e.name.startsWith(`git-`)?(0,L.jsx)(v0,{directive:e}):e.name===`created-thread`?(0,L.jsx)(y0,{directive:e}):e.name===`archive`||e.name===`archive-thread`?(0,L.jsx)(b0,{directive:e}):(0,L.jsx)(S0,{directive:e})}var w0;function T0(){return w0??=ib(async()=>{let{default:e}=await import(`./mermaid.core-Bo-3lWY-.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)),w0}function E0({source:e}){let t=(0,I.useId)(),[n,r]=(0,I.useState)({}),i=Fq(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 T0().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:`${kJ} 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 ${kJ} 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 ${kJ} bg-panel-2`})}var D0=(0,I.createContext)(null),O0=(0,I.createContext)(null);function k0(){let e=(0,I.useContext)(D0),t=(0,I.useContext)(O0);return e??t}var A0=(0,I.createContext)(null);function j0(e){return e.status===`pending`&&e.backgroundState===`background`}function M0(e){let t=[];for(let n of e)for(let e of n.tools)j0(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 N0(e){return e.map(e=>{if(!e.tools.some(j0))return e;let t=e.tools.filter(e=>!j0(e)),n=e.parts?.map(e=>e.kind===`tools`?{...e,tools:e.tools.filter(e=>!j0(e))}:e).filter(e=>e.kind!==`tools`||e.tools.length>0);return{...e,tools:t,parts:n}})}function P0({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)(K0,{slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:i}),(0,L.jsx)(F0,{slug:e,virtualized:r}),a&&(0,L.jsx)(MZ,{thread:a,sticky:!0,safeArea:!0,onArchived:t})]})}function F0({slug:e,virtualized:t}){let n=qC(),r=Gp(n,e),i=r?.runtime===`running`||r?.runtime===`spawning`,a=x1(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)(()=>M0(p),[p]),h=(0,I.useMemo)(()=>N0(p),[p]),g=(0,I.useMemo)(()=>o2(h),[h]),_=(0,I.useMemo)(()=>i?c1(h):void 0,[i,h]),v=_&&_.index>=0?_.index:g,y=(0,I.useMemo)(()=>G1(h),[h]),b=i?J1(y):void 0,x=i?q1(y):void 0,S=x?i0(x,n?.projectDir):void 0,C=i?X1(y):void 0,w=i1(r),T=(0,I.useMemo)(()=>{let e=i?$1(y):y;return O1(e,s2(e,v,w))},[y,i,v,w]),E=i,D=(0,I.useMemo)(()=>oY(p),[p]),O=(0,I.useMemo)(()=>tY(p,r?.answersInFlight),[p,r?.answersInFlight]),k=(0,I.useMemo)(()=>yX(p),[p]),A={thread:r,showWorking:E,registeredDone:DJ(r,g>=0?h[g]?.text:void 0),restedCard:HJ(r,g>=0?h[g]?.text:void 0),errorVisible:WJ(h,r?.providerError)},{answeringForMessage:j}=nX(e,p),M=(0,I.useMemo)(()=>pY(p,r?.questions??[]),[p,r?.questions]),N=(0,I.useMemo)(()=>xY(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)(D0.Provider,{value:e,children:(0,L.jsx)(p$,{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)(W0,{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)(HQ,{thread:r,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(h$,{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)(d4,{}),` Loading…`]}):i?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(d4,{}),` Session starting…`]}):TX(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:[d2(T.map(e=>e.message),(e,t)=>{let n=T[t].messageIndex;return(0,L.jsx)(K2,{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&&V0(A)!==null&&(0,L.jsx)(SY,{h:H0(A,T.map(e=>e.message))}),re&&(0,L.jsx)(U0,{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)(r4,{policy:r.permPolicy,denies:r.permDenies})}):null,p.some(e=>e.queued)&&(0,L.jsx)(SY,{}),(0,L.jsx)(`div`,{className:`flex flex-col gap-3.5`,children:p.map((e,t)=>e.queued?(0,L.jsx)(K2,{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)(XX,{slug:e,onTerminal:a,ops:(0,L.jsx)(i4,{slug:e,transcriptShells:m,className:`px-1 pt-1.5`})})})]})})})}var I0=700,L0=250,R0=(()=>{try{return localStorage.getItem(`frizz.debugScroll`)===`1`}catch{return!1}})();function z0(e){return e?.pendingInteraction===!0}function B0(e){return z0(e)?void 0:e?.pendingAsk}function V0({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`:B0(e)?`pending-ask`:e?.runtime===`perm-prompt`&&!z0(e)?`perm-prompt`:t?`working`:e?.providerError?i?null:`provider-error`:l1(e)?`snooze`:i1(e)?`resting`:n?`registered-done`:r?`rested`:null}function H0(e,t){return V0(e)===`working`?u2(t):14}function U0({state:e,slug:t,retryText:n,onTerminal:r,liveRuntimeStart:i,liveActivityLabel:a,liveToolRun:o}){let s=e.thread;switch(V0(e)){case`provider-fault`:return(0,L.jsx)(e4,{slug:t,sessionId:s.sessionId,fault:s.providerFault,retryText:n});case`provider-error`:return(0,L.jsx)(GJ,{error:s.providerError});case`limit-pause`:return(0,L.jsx)(t4,{slug:t,sessionId:s.sessionId,pause:s.limitPause});case`pending-ask`:return(0,L.jsx)(a4,{ask:B0(s),onTerminal:r});case`perm-prompt`:return(0,L.jsx)(n4,{onTerminal:r});case`working`:return(0,L.jsx)(f4,{since:s?.lastUserAt,startedAt:i,activityLabel:a,run:o});case`snooze`:return(0,L.jsx)(d1,{thread:s});case`resting`:return(0,L.jsx)(s1,{thread:s});case`registered-done`:return(0,L.jsx)($2,{fenceKind:`done`,body:s.lastFence.body,hints:[]});case`rested`:return(0,L.jsx)(UJ,{thread:s});default:return null}}function W0({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)(()=>G1(r),[r]),w=u?J1(C):void 0,T=u?q1(C):void 0,E=T?i0(T,S):void 0,D=u?X1(C):void 0,O=(0,I.useMemo)(()=>o2(r),[r]),k=(0,I.useMemo)(()=>u?c1(r):void 0,[u,r]),A=k&&k.index>=0?k.index:O,j=i1(l),M=(0,I.useMemo)(()=>{let e=u?$1(C):C;return O1(e,s2(e,A,j))},[C,u,A,j]),N=u,P=(0,I.useMemo)(()=>E1(M.map(e=>e.message),s2(M,A,j),i2).map(e=>{let t=M[e.messageIndex];return{...e,messageIndex:t.messageIndex,stampAt:Z1(t)}}),[M,A,j]),ee=(0,I.useMemo)(()=>yX(r),[r]),F=DJ(l,O>=0?r[O]?.text:void 0),te=HJ(l,O>=0?r[O]?.text:void 0),ne=WJ(r,l?.providerError),re={thread:l,showWorking:N,registeredDone:F,restedCard:te,errorVisible:ne},ie=V0(re)!==null,ae=(0,I.useMemo)(()=>H0({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 uY(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)(()=>pY(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=_D(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()+L0;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=C1({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),R0&&!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=w1({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()+I0,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)(HQ,{thread:l,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(h$,{thread:l,questions:oe.tail,inFlight:a,showSend:s.placedIds.size>0,className:`px-6 pt-5`})]}):n.kind===`questions`?(0,L.jsx)(h$,{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 ${kJ} 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)($Z,{at:n.stampAt,host:SX(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(K2,{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)(U0,{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)(r4,{policy:l.permPolicy,denies:l.permDenies})}):null]}):(0,L.jsx)($Z,{at:n.message.at,host:SX(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(K2,{m:n.message,paired:i[n.messageIndex]})})},n.key):null}),(0,L.jsx)(G0,{overlay:x,hidden:ue,onJump:()=>le.scrollToEnd({behavior:`smooth`})})]})}function G0({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 K0({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=LK(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=EX(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:kX,children:[(0,L.jsx)(`div`,{className:AX,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(DX(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)(LZ,{thread:i,hidden:s})]}),(0,L.jsx)(f1,{at:PT(i),fallbackAt:i.spawnedAt,className:`mt-0.5 block truncate text-[11px] leading-tight text-muted/75`})]})}),(0,L.jsxs)(`div`,{className:jX,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[p&&(0,L.jsx)(S1,{slug:e}),(0,L.jsx)(nZ,{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)(aM,{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 q0(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||HZ(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 J0(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||HZ(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 Y0(e){return q0(e)!==null}function X0(e){return J0(e)!==null}function Z0(e){return e.kind===`event`&&!e.boundary||e.kind===`reasoning`}function Q0(e){return Z0(e)||Y0(e)}function $0(e){return Z0(e)||X0(e)}function e2(e){if(Z0(e))return!0;let t=q0(e);return t!==null&&!N1(t[t.length-1])}function t2(e){if(Z0(e))return!0;let t=J0(e);return t!==null&&!N1(t[0])}function n2(e){let t=q0(e);return t!==null&&F1(t[t.length-1])}function r2(e){let t=J0(e);return t!==null&&F1(t[0])}function i2(e,t){let n=n2(e)||r2(t),r=!n&&Q0(e)&&$0(t)&&!(e2(e)&&t2(t));return(n?22:r?6:14)+(e.role===`user`&&t.role!==`user`?3:0)}function a2(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:c2(e,n.text,t)):(e.tools?.length??0)===0&&c2(e,e.text,t)}function o2(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`&&e[t].kind!==`event`)return t;return-1}function s2(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=>a2(e,r.has(e))}function c2(e,t,n){return!e.fenceRefused&&!n?!t.trim():EJ(t).every(e=>e.kind===`fence`&&e.fenceKind===`awaiting`)}function l2(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`&&!c2(e,n.text,t)):typeof e.text==`string`&&!c2(e,e.text,t)}function u2(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.queued||a2(n)))return n2(n)?22:Q0(n)&&!e2(n)?6:14+(n.role===`user`?3:0)}return 0}function d2(e,t,n){let r=[],i=null;return e.forEach((e,a)=>{n?.(e,a)||a2(e)||(i!==null&&r.push((0,L.jsx)(SY,{h:i2(i,e)},`s${a}`)),r.push(t(e,a)),i=e)}),r}function f2(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 p2(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)(SY,{h:typeof t==`number`?t:t(n)},`vs${n}`)),r.push(e)}),r}var m2={head:!1,tail:!1};function h2(e,t){return n=>e[n-1]?.tail||e[n]?.head?22:t}function g2(e){return{head:F1(e[0]),tail:F1(e[e.length-1])}}function _2(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}):P1(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 v2(e){return e.split(`__`).pop()||e}function y2(e){let t=X.board?.projectDir;return t&&e.startsWith(t+`/`)?e.slice(t.length+1):e}function b2({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=c0(a,s0(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 ${eQ}`,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:nQ(n)})]}),n&&(0,L.jsx)(`div`,{id:i,className:`mt-1.5 flex flex-col`,children:p2(e.map((e,n)=>(0,L.jsx)(S2,{t:e,startedAt:t},n)),6)}),!n&&(0,L.jsx)(`div`,{id:i,hidden:!0})]})}function x2({tools:e,at:t}){let n=[];for(let t of e){let e=N1(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:p2(n.map((e,n)=>e.exceptional?(0,L.jsx)(`div`,{className:`flex flex-col`,children:p2(e.tools.map((e,n)=>(0,L.jsx)(S2,{t:e,startedAt:t},n)),h2(e.tools.map(e=>g2([e])),6))},`exceptions-${n}`):(0,L.jsx)(b2,{tools:e.tools,at:t},`activity-${n}`)),h2(n.map(e=>g2(e.tools)),6))})}function S2({t:e,startedAt:t}){let n=(0,I.useContext)(D0),r=qC(),i=NE(e,(n?Gp(r,n):void 0)?.bgShells??[]);return e.edits&&e.status!==`failed`&&e.status!==`cancelled`?(0,L.jsx)(Mq,{edits:e.edits,meta:(0,L.jsx)(D2,{status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,durationMs:e.durationMs})}):e.command?(0,L.jsx)(F2,{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)(M2,{name:e.name,detail:e.detail,outputImage:e.outputImage,output:e.output,status:e.status,durationMs:e.durationMs}):e.read?(0,L.jsx)(L2,{detail:e.detail,read:e.read,status:e.status,durationMs:e.durationMs}):e.prompt||e.agentId?(0,L.jsx)(z2,{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)(V2,{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)(N2,{images:e.sentImages??[],files:e.sentFiles??[],caption:e.caption,status:e.status,durationMs:e.durationMs}):e.todos?(0,L.jsx)(nJ,{todos:e.todos,note:e.input,meta:(0,L.jsx)(D2,{status:e.status,durationMs:e.durationMs})}):P1(e)?(0,L.jsx)(C2,{ask:e.ask??[],askAnswers:e.askAnswers}):e.input||e.output?(0,L.jsx)(F2,{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)(j2,{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 C2({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=RQ(e,t?.[n]);return(0,L.jsx)(oX,{question:r.question,settled:{chosenIdxs:r.chosenIdxs,text:r.text}},n)})})}function w2({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 T2(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 E2({status:e,backgroundState:t,liveBackgroundState:n,startedAt:r}){let i=T2(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:ZE}):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 D2({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)(w2,{tone:e===`failed`?`frizz-tool-failed`:e===`cancelled`?`text-amber-400`:`text-muted/55`,title:c,label:a,duration:s})}function O2(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 k2(e,t,n){let r=t&&t!==X.board?.projectDir?`in ${y2(t)}`:void 0;return[e,t?r:n!==void 0&&!e?.includes(String(n))?`session ${n}`:void 0].filter(Boolean).join(` · `)||void 0}function A2(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.includes(`…`)}function j2({name:e,detail:t,count:n,status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,cwd:s,sessionId:c,durationMs:l,startedAt:u}){let d=k2(t,s,c),f=d?y2(d):void 0,p=t&&A2(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)(E2,{status:r,backgroundState:i,liveBackgroundState:a,startedAt:u}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:v2(e)}),f&&(p?(0,L.jsx)(`span`,{className:`min-w-0 truncate`,onClick:e=>e.stopPropagation(),children:(0,L.jsx)(jq,{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)(D2,{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 M2({name:e,detail:t,outputImage:n,output:r,status:i,durationMs:a}){let o=t?y2(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:v2(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)(D2,{status:i,durationMs:a})})]});return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(J2,{path:n,hideCaption:!0,altText:o?`${v2(e)}: ${o}`:v2(e),header:s}),r&&(0,L.jsx)(`pre`,{className:`frizz-bash frizz-bash-body frizz-bash-output-body mt-1.5`,children:r})]})}function N2({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)(D2,{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)(J2,{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)(Y2,{path:e},`f${t}`))}),n&&(0,L.jsx)(`div`,{className:`max-w-[65%] text-[12px] leading-snug text-muted`,children:n})]})})]})}var P2=16;function F2({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=O2(i,d,l),b=(0,I.useMemo)(()=>e.split(`
314
+ `).length,[e]),x=b>P2,S=(0,I.useMemo)(()=>n?n.split(`
315
+ `).length:0,[n]),C=S>P2,w=k2(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`} `:``}${v2(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)(E2,{status:i,backgroundState:a,liveBackgroundState:o,startedAt:d}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:v2(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)(D2,{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)(Xq,{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 I2=16;function L2({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
+ `).length,[t]),u=l>I2,d=e?y2(e):void 0,f=e&&A2(e)?e:void 0;return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(Aq,{className:`frizz-bash-header`,controls:c,expanded:i,label:`${i?`Collapse`:`Expand`} Read${e?`: ${e}`:``}`,onToggle:()=>a(e=>!e),meta:(0,L.jsx)(D2,{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)(jq,{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)(Xq,{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 R2=16;function z2({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(`
317
+ `).length:0,[h]),_=g>R2,v=k0(),y=qC(),b=v?Gp(y,v):void 0,x=!a&&i?(b?.subAgents??[]).find(e=>e.id===i):void 0,S=x?.state===`running`,C=!!(v&&i),w=e??`sub-agent`,T=VZ(r),E=TE(),D=qZ({agentStatus:a,agentElapsedMs:o,liveState:x?.state,liveElapsedMs:x?.startedAt?Math.max(E-Date.parse(x.startedAt),0):void 0,status:s,durationMs:c}),O=S?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--agent`,"data-running-indicator":`subagent-disclosure`}):x?.state===`stale`?(0,L.jsx)(`span`,{className:qE,title:JE}):x?.state===`rested`?(0,L.jsx)(`span`,{className:YE,title:XE}):null;function k(){!v||!i||vp(v,i,{label:w,subagentType:r,startedAt:x?.startedAt})}return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(Aq,{className:`frizz-bash-header`,controls:m,expanded:u,label:`${u?`Collapse`:`Expand`} Agent dispatch: ${w}`,onToggle:()=>d(e=>!e),meta:(T||D)&&(0,L.jsxs)(L.Fragment,{children:[T&&(0,L.jsx)(`span`,{"data-subagent-profile":!0,className:`petite-caps frizz-tool-header-caps shrink-0 whitespace-nowrap text-[11.5px] leading-none text-muted/55`,title:`Sub-agent profile: ${T}`,children:T}),T&&D&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`petite-caps frizz-tool-header-caps -mx-[2px] shrink-0 text-[11.5px] leading-none text-muted/55`,children:`·`}),D&&(0,L.jsx)(w2,{tone:D.tone===`failed`?`frizz-tool-failed`:`text-muted/55`,title:D.title,label:D.label,duration:D.duration})]}),children:[O&&(0,L.jsx)(`span`,{className:`frizz-tool-mark -mr-1 flex w-[9px] shrink-0 justify-center`,children:O}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Agent`}),C?(0,L.jsx)(`button`,{type:`button`,"aria-label":`Open sub-agent transcript: ${w}`,title:`Open sub-agent transcript`,onClick:k,className:`min-w-[4rem] flex-1 truncate text-left text-[11.5px] text-muted outline-none hover:underline hover:text-fg/80 focus-visible:underline focus-visible:text-fg/80`,children:w}):(0,L.jsx)(`span`,{className:`min-w-[4rem] flex-1 truncate text-[11.5px] text-muted`,title:w,children:w})]}),(0,L.jsx)(`div`,{id:m,hidden:!u,children:u&&(0,L.jsxs)(L.Fragment,{children:[h&&(0,L.jsx)(`pre`,{className:`frizz-bash-body${_&&!f?` frizz-bash-clamp`:``}`,children:h}),_&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>p(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:f?`Collapse`:`Show all ${g} lines`}),l&&(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`,children:l})]})]})})]})}function B2(e,t){return t===`shutdown_request`?`Shutdown`:t===`codex_followup`?`Followed up`:e===`main`?`Reported`:`Steered`}function V2({to:e,summary:t,body:n,type:r,dispatchId:i,targetLabel:a,status:o,durationMs:s,at:c}){return(0,I.useContext)(D0)===null?(0,L.jsx)(U2,{to:e,summary:t,body:n,type:r,status:o,durationMs:s}):(0,L.jsx)(c4,{to:e,type:r,dispatchId:i,targetLabel:a,at:c})}var H2=16;function U2({to:e,summary:t,body:n,type:r,status:i,durationMs:a}){let[o,s]=(0,I.useState)(!t),[c,l]=(0,I.useState)(!1),u=(0,I.useId)(),d=Fq(XK(n)),f=(0,I.useMemo)(()=>n.split(`
318
+ `).length,[n]),p=f>H2,m=!!n.trim(),h=B2(e,r);return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>s(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":m?u:void 0,"aria-expanded":m?o:void 0,"aria-label":`${m?`${o?`Collapse`:`Expand`} `:``}${h}${e?` to ${e}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/60`,disabled:!m,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:h}),t&&(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:t})]}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,L.jsx)(D2,{status:i,durationMs:a}),m&&(0,L.jsx)(ym,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${o?`rotate-90`:``}`})]})]}),m&&(0,L.jsx)(`div`,{id:u,hidden:!o,children:o&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`border-t border-border px-2.5 py-2${p&&!c?` frizz-bash-clamp`:``}`,children:(0,L.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:d})}),p&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:c?`Collapse`:`Show all ${f} lines`})]})})]})}function W2({body:e,items:t}){let[n,r]=(0,I.useState)(null),i=(0,I.useMemo)(()=>new Map(t.map(e=>[e.token,e])),[t]),a=n===null?void 0:i.get(n);return(0,L.jsxs)(L.Fragment,{children:[(0,I.useMemo)(()=>GL(e,[...i.keys()]),[e,i]).map((e,t)=>{let a=e.token?i.get(e.token):void 0;if(!a)return(0,L.jsx)(qY,{text:e.text},t);let o=n===a.token;return(0,L.jsx)(`button`,{type:`button`,title:a.display,"aria-expanded":o,onClick:e=>{e.stopPropagation(),r(o?null:a.token)},onKeyDown:e=>e.stopPropagation(),className:`inline-flex max-w-56 items-baseline rounded border px-1 align-baseline font-mono-keep text-[11px] leading-snug transition-colors ${o?`border-bg/40 bg-bg/15`:`border-bg/25 bg-bg/[0.08] hover:bg-bg/15`}`,children:(0,L.jsx)(`span`,{className:`truncate`,children:RL(a.token)})},t)}),a&&(0,L.jsxs)(`span`,{className:`mt-2 block cursor-auto rounded-md border border-bg/20 bg-bg/[0.06] px-2 py-1.5`,onClick:e=>e.stopPropagation(),children:[(0,L.jsxs)(`span`,{className:`block truncate font-mono-keep text-[11px] text-bg/60`,children:[a.display,a.startLine===void 0?``:` · ${a.startLine===a.endLine?`line ${a.startLine}`:`lines ${a.startLine}-${a.endLine}`}`]}),(0,L.jsx)(`span`,{className:`mt-1 block max-h-40 overflow-y-auto whitespace-pre-wrap break-words font-mono-keep text-[11.5px] leading-4 text-bg/80`,children:a.text})]})]})}function G2({text:e,rawText:t,queued:n,deliveryUnconfirmed:r,deliveryId:i,sourceId:a}){let o=(0,I.useContext)(D0),s=dX(o),{unqueue:c,pending:l}=hX(o),u=!!(n&&i&&o&&s),d=gX(n?o:null),{deliverNow:f,pending:p}=_X(o),m=!!(n&&o&&d),{prose:h,attachments:g}=(0,I.useMemo)(()=>FL(e),[e]),_=(0,I.useMemo)(()=>QL(h),[h]);return(0,L.jsxs)(`div`,{"data-frizz-msg":a,className:`self-end flex flex-col items-end gap-0.5 max-w-[85%]`,children:[h.trim()!==``&&(0,L.jsxs)(`div`,{className:`group relative`,children:[(0,L.jsx)(`div`,{...u?{role:`button`,tabIndex:0,"data-unqueue":i,"aria-label":`Unqueue this message and put it back in the prompt box`,title:l?`Taking it back…`:void 0,onClick:n=>c({deliveryId:i,text:e,rawText:t??e,from:n.currentTarget}),onKeyDown:n=>{n.key!==`Enter`&&n.key!==` `||(n.preventDefault(),c({deliveryId:i,text:e,rawText:t??e,from:n.currentTarget}))}}:{},className:`relative rounded-xl rounded-br-sm bg-user-bubble px-3.5 py-3 text-[14px] whitespace-pre-wrap [overflow-wrap:anywhere] text-bg ${n?`opacity-50`:``} ${u?`cursor-pointer transition-opacity group-hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-offset-2 focus-visible:ring-offset-bg`:``} ${l?`!opacity-30`:``}`,children:_?(0,L.jsx)(W2,{body:_.body,items:_.items}):(0,L.jsx)(qY,{text:h})}),m&&(0,L.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:f,disabled:p,title:`Send now — interrupts what the worker is doing so it reads the queue immediately`,"aria-label":`Send now`,className:`absolute bottom-0 right-full mr-2 flex h-7 w-7 items-center justify-center rounded-lg text-muted opacity-0 outline-none transition-[opacity,color,background-color] group-hover:opacity-100 enabled:hover:bg-panel-2/70 enabled:hover:text-fg enabled:focus-visible:opacity-100 enabled:focus-visible:bg-panel-2/70 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`,children:p?(0,L.jsx)(Xm,{size:15,strokeWidth:2.2,className:`animate-spin`}):(0,L.jsx)(fm,{size:15,strokeWidth:2.2})})]}),g.length>0&&(0,L.jsxs)(`div`,{className:`mt-1 flex flex-col items-end gap-1.5`,children:[g.filter(e=>e.kind===`image`).map((e,t)=>(0,L.jsx)(J2,{path:e.path,hideCaption:!0},`i${t}-${e.path}`)),g.some(e=>e.kind===`file`)&&(0,L.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,children:g.filter(e=>e.kind===`file`).map((e,t)=>(0,L.jsx)(Y2,{path:e.path},`f${t}-${e.path}`))})]}),r&&(0,L.jsx)(`div`,{className:`text-[11px] text-amber-400/80`,children:`Delivery unconfirmed — no receipt from the worker`}),u&&l&&(0,L.jsx)(`div`,{"aria-hidden":!0,className:`h-0 overflow-visible text-[11px] text-muted`,children:`Taking it back…`})]})}var K2=(0,I.memo)(function({m:e,answering:t,dense:n,paired:r,textOnly:i,showSendButton:a,staleAwaiting:o,shadowedBy:s,placed:c,thread:l,restingCardShown:u,restedAt:d}){let f=VW(),[p,m]=(0,I.useState)(!1);if(e.providerError)return(0,L.jsx)(GJ,{error:e.providerError});if(e.kind===`event`)return(0,L.jsx)(l4,{text:e.text,boundary:e.boundary,sourceId:e.sourceId,at:e.at});if(e.kind===`reasoning`)return(0,L.jsx)(u4,{text:e.text,sourceId:e.sourceId});let h=HZ(e);if(h)return(0,L.jsx)(o4,{call:h,sourceId:e.sourceId,at:e.at});if(e.role===`user`){let t=vX(e).replace(/\r\n?/g,`
319
+ `),i=r===void 0?ZJ(t):r;if(i)return(0,L.jsx)(JY,{answers:i,queued:e.queued,sourceId:e.sourceId});let a=e.wake?xl(t):void 0;return a?(0,L.jsx)(BY,{bump:a,sourceId:e.sourceId,at:e.at}):e.wake?(0,L.jsx)(OY,{steer:e.wakeSteer,text:t,sourceId:e.sourceId,at:e.at,wrap:n}):e.peerFrom?(0,L.jsx)(s4,{from:e.peerFrom,unnamed:e.peerUnnamed,dispatchId:e.peerDispatchId,sourceId:e.sourceId,at:e.at}):(0,L.jsx)(G2,{text:t,rawText:e.text,queued:e.queued,deliveryUnconfirmed:e.deliveryState===`unconfirmed`,deliveryId:e.deliveryId,sourceId:e.sourceId})}let g=[],_=[],v=(e,t=m2)=>{g.push(e),_.push(t)},y={n:-1},b={drawn:!1},x=[],S=new Set,C=(r,i)=>{for(let[a,l]of EJ(r).entries()){if(l.kind===`fence`){if(l.fenceKind===`awaiting`&&(e.fenceRefused||o||u))continue;l.fenceKind===`awaiting`&&(b.drawn=!0),v((0,L.jsx)($2,{fenceKind:l.fenceKind,body:l.body,hints:l.hints,wrap:n,notAfter:d},`${i}-f${a}`));continue}for(let[e,r]of oJ(l.text).entries()){if(r.kind===`prose`){for(let[t,o]of PL(r.text).entries()){let r=`${i}-${a}-p${e}-${t}`;v(o.kind===`image`?(0,L.jsx)(J2,{path:o.path},r):o.kind===`file`?(0,L.jsx)(Y2,{path:o.path},r):o.kind===`visualization`?(0,L.jsx)(Q2,{file:o.file},r):o.kind===`directive`?(0,L.jsx)(C0,{directive:o.directive},r):o.kind===`mermaid`?(0,L.jsx)(E0,{source:o.source},r):(0,L.jsx)(q2,{md:o.text,wrap:n},r))}continue}y.n+=1;let o=y.n,l=c&&r.registeredId?c.find(e=>e.id.toLowerCase()===r.registeredId):void 0;if(l&&!S.has(l.id)){S.add(l.id),v((0,L.jsx)(m$,{q:l},`${i}-${a}-q${e}`));continue}if(s&&yY(r,s)!==void 0||r.registeredId&&r.text.trim()===``)continue;t&&x.push({raw:r.text,kind:r.questionKind,danger:r.danger,bi:o});let u=t&&!f?{answer:t.answerFor(o),onChip:(e,n)=>t.onChip(o,e,n),onText:e=>t.onText(o,e),onSubmit:t.onSubmit}:void 0;v((0,L.jsx)(oX,{raw:r.text,questionKind:r.questionKind,danger:r.danger,interactive:u,wrap:n},`${i}-${a}-q${e}`))}}};if(e.parts&&e.parts.length>0)f2(e.parts).forEach((t,r)=>{if(t.kind===`tools`){if(i)return;let a=_2(t.tools);a.length&&v((0,L.jsx)(x2,{tools:a,dense:n,at:e.at},`t${r}`),g2(a))}else C(t.text,`x${r}`)});else{if(!i){let t=_2(e.tools);t.length>0&&v((0,L.jsx)(x2,{tools:t,dense:n,at:e.at},`tools`),g2(t))}C(e.text,`leg`)}return d!==void 0&&l&&!b.drawn&&!e.fenceRefused&&e1(l,{notAfter:d})&&v((0,L.jsx)(s1,{thread:l,notAfter:d},`rested-on`)),g.length===0?null:(a&&t&&f&&x.length>0?v((0,L.jsx)(`div`,{className:`flex justify-start`,children:(0,L.jsx)(`button`,{type:`button`,"data-mobile-answer-open":!0,onClick:()=>m(!0),className:`flex h-[40px] items-center justify-center rounded-[12px] bg-accent px-4 text-[15px] font-semibold text-bg active:brightness-90`,children:x.length>1?`Answer ${x.length} questions`:`Answer`})},`answer-open`)):a&&t&&x.length>0&&v((0,L.jsx)(`div`,{className:`flex justify-start`,children:(0,L.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:!t.anyAnswered||t.sending,onClick:t.onSubmit,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`})},`send-answers`)),(0,L.jsxs)(`div`,{"data-frizz-msg":e.sourceId,className:`flex flex-col text-[13px] min-w-0`,children:[p2(g,h2(_,14)),p&&t&&x.length>0?(0,L.jsx)(uX,{blocks:x,answering:t,onClose:()=>m(!1)}):null]}))});function q2({md:e,wrap:t}){let n=XK(e),r=Fq(n),i=(0,I.useRef)(null);return Jq(i,n),n?(0,L.jsx)(`div`,{ref:i,className:`md-body${t?` ${OJ}`:``}`,dangerouslySetInnerHTML:r}):null}function J2({path:e,hideCaption:t,altText:n,header:r}){let[i,a]=(0,I.useState)(!1);if(i)return(0,L.jsx)(`div`,{className:`font-mono-keep text-[12px] text-muted/70 break-all`,children:e});let o=Qf(e);return(0,L.jsx)(hK,{header:r,caption:t?void 0:(0,L.jsx)(`figcaption`,{className:`bg-panel-2 px-2 pb-1.5 font-mono-keep text-[11px] text-muted/60 break-all`,children:o}),children:(0,L.jsx)(`img`,{src:YS(e),alt:n??o,"data-local-path":e,"data-local-image":`true`,onError:()=>a(!0),className:`cursor-pointer ${vK}`})})}function Y2({path:e}){let t=Qf(e);return(0,L.jsxs)(`button`,{type:`button`,className:`local-file-action inline-flex max-w-full items-center gap-1.5 ${kJ} border border-border bg-panel-2 px-3 py-1.5 text-left align-top no-underline hover:border-accent`,"data-local-path":e,title:e,children:[(0,L.jsx)(Pm,{size:14,strokeWidth:2,className:`shrink-0 text-muted`}),(0,L.jsx)(`span`,{className:`font-mono-keep truncate text-[12px] text-fg`,children:t})]})}var X2={"--background":`--color-bg`,"--foreground":`--color-fg`,"--card":`--color-panel-2`,"--card-foreground":`--color-fg`,"--popover":`--color-elevated`,"--popover-foreground":`--color-fg`,"--primary":`--color-fg`,"--primary-foreground":`--color-bg`,"--secondary":`--color-panel-2`,"--secondary-foreground":`--color-fg`,"--muted":`--color-panel-2`,"--muted-foreground":`--color-muted`,"--accent":`--color-border-strong`,"--accent-foreground":`--color-fg`,"--border":`--color-border-strong`,"--input":`--color-border-strong`,"--ring":`--color-accent`};function Z2(){let e=getComputedStyle(document.documentElement),t=Object.fromEntries(Object.entries(X2).map(([t,n])=>[t,e.getPropertyValue(n).trim()]));return t[`--font-size-base`]=getComputedStyle(document.body).fontSize,{type:`frizz-inline-vis-theme`,colorScheme:e.colorScheme===`light`?`light`:`dark`,vars:t}}function Q2({file:e}){let t=(0,I.useContext)(D0),n=(0,I.useRef)(null),[r,i]=(0,I.useState)(360),[a,o]=(0,I.useState)(null),s=t?`${Id()}/local-visualization?slug=${encodeURIComponent(t)}&file=${encodeURIComponent(e)}`:null;return(0,I.useEffect)(()=>{if(!s){o(!1);return}let e=new AbortController;return o(null),fetch(s,{method:`HEAD`,signal:e.signal}).then(t=>{e.signal.aborted||o(t.ok)}).catch(()=>{e.signal.aborted||o(!1)}),()=>e.abort()},[s]),(0,I.useEffect)(()=>{let e=e=>{if(e.source!==n.current?.contentWindow||e.data?.type!==`frizz-inline-vis-height`)return;let t=Number(e.data.height);Number.isFinite(t)&&i(Math.max(80,Math.min(2400,Math.ceil(t))))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]),a===!1||!s?(0,L.jsxs)(`div`,{role:`status`,className:`${kJ} border border-border bg-panel-2 px-4 py-2.5 text-[12px] text-muted`,children:[`Visualization unavailable: `,(0,L.jsx)(`span`,{className:`font-mono-keep break-all`,children:e})]}):a===null?(0,L.jsx)(`div`,{role:`status`,className:`h-20 animate-pulse ${kJ} bg-panel-2`,"aria-label":`Loading ${e}`}):(0,L.jsx)(`iframe`,{ref:n,src:s,title:e.replace(/\.html$/,``).replaceAll(`-`,` `),sandbox:`allow-scripts`,onLoad:()=>n.current?.contentWindow?.postMessage(Z2(),`*`),className:`block w-full border-0 bg-transparent`,style:{height:r}})}function $2({fenceKind:e,body:t,hints:n,wrap:r,notAfter:i}){let a=XK(t),o=(0,I.useContext)(D0),s=(0,I.useContext)(A0),c=qC(),l=o?Gp(c,o):void 0,u=l?aZ(l):void 0,d=!!(l&&u?.archive),f=(0,I.useRef)(null);d&&l&&(f.current=l);let p=d&&l?l:f.current;return e===`done`?(0,L.jsxs)(IJ,{icon:gm,label:`Done`,children:[a&&(0,L.jsx)(Yq,{className:`md-body${r?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:a}),p&&(0,L.jsx)(RJ,{children:(0,L.jsx)(FZ,{thread:p,className:`rounded-md text-[11px] bg-fg px-2.5 py-1 text-bg hover:opacity-90`,iconClassName:`icon-label-nudge`,onArchived:s?.dismiss,onDismissCancel:s?.cancel})})]}):l&&i1(l)?null:(0,L.jsx)(s1,{thread:l,fence:{body:t,hints:n},notAfter:i})}function e4({slug:e,sessionId:t,fault:n,retryText:r}){let[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(!1),c=Ve(),l=qR[n.backend],u=t=>{s(!0),iU(c,e,t,{onSuccess:()=>{s(!1),Z(`Retrying with the previous message…`)},onRollback:()=>s(!1),failureToast:e=>`Retry failed: ${e.slice(0,80)}`})||s(!1)};return(0,L.jsxs)(IJ,{"data-provider-fault":!0,tone:`danger`,icon:qm,label:`${l} sign-in required`,children:[(0,L.jsx)(`span`,{className:LJ,children:`The provider rejected this session's credential. Sign in, then retry.`}),(0,L.jsxs)(RJ,{children:[r?.trim()&&(0,L.jsx)(`button`,{onClick:()=>u(r),disabled:o,onMouseDown:e=>e.preventDefault(),className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel hover:border-border-strong disabled:opacity-60`,children:`Retry`}),(0,L.jsx)(`button`,{onClick:()=>a(!0),onMouseDown:e=>e.preventDefault(),className:VJ,children:`Sign in`})]}),i&&(0,L.jsx)(XR,{backend:n.backend,onClose:()=>a(!1),onAuthed:()=>a(!1)})]})}function t4({slug:e,sessionId:t,pause:n}){let r=qR[n.backend],i=n.window===`weekly`?`weekly limit`:n.window===`session`?`session limit`:`usage limit`,[a,o]=(0,I.useState)(!1),s=Ve();return(0,L.jsxs)(IJ,{"data-limit-pause":!0,tone:`caution`,icon:Um,label:`Paused by the ${r} ${i}`,children:[(0,L.jsx)(`span`,{className:LJ,children:n.autoResume?n.resumesAt?`Continuing automatically at ${gE(n.resumesAt)}.`:`Continuing automatically once the window resets.`:`Continue it whenever you have capacity again.`}),(0,L.jsx)(RJ,{children:(0,L.jsx)(`button`,{onClick:()=>{o(!0),iU(s,e,`Continue exactly where you left off.`,{onSuccess:()=>{o(!1),Z(`Continuing…`)},onRollback:()=>o(!1),failureToast:e=>`Continue failed: ${e.slice(0,80)}`})||o(!1)},disabled:a,onMouseDown:e=>e.preventDefault(),className:`disabled:opacity-45 ${VJ}`,children:`Continue now`})})]})}function n4({onTerminal:e}){return(0,L.jsxs)(IJ,{tone:`attention`,icon:qm,label:`Permission approval`,children:[(0,L.jsx)(`span`,{className:LJ,children:`The agent is waiting on your approval — respond in your external terminal.`}),(0,L.jsx)(RJ,{children:(0,L.jsx)(`button`,{onClick:()=>e(),onMouseDown:e=>e.preventDefault(),className:VJ,children:`Copy terminal command`})})]})}function r4({policy:e,denies:t}){let n=[e.tool,e.command].filter(Boolean).join(`: `);return(0,L.jsxs)(IJ,{tone:`caution`,icon:xh,label:`Blocked by frizz's permission policy`,children:[n?(0,L.jsx)(`code`,{className:`mb-1.5 block min-w-0 break-all rounded bg-panel px-1.5 py-1 text-[11px] text-fg/85`,children:n}):null,(0,L.jsx)(`span`,{className:LJ,children:e.reason}),(0,L.jsxs)(`span`,{className:`mt-1.5 block text-[11px] text-muted`,children:[`Rule `,(0,L.jsx)(`code`,{className:`rounded bg-panel px-1 py-0.5`,children:e.rule}),t&&t>1?` · ${t} denials this session`:``]})]})}function i4({slug:e,className:t=`px-4 pb-2 pt-1`,includeAgents:n=!0,transcriptShells:r=[],parentAgentId:i}){let a=Gp(qC(),e),o=a?.subAgents??[],s=n?i?aD(o,i):o:[],c=i?[...r]:lD(a?.bgShells??[],r),l=i?[]:(a?.watches??[]).filter(e=>e.kind===`github`),u=i?[]:a?.links??[],d=s.length+c.length+l.length,f=new Set((a?.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`).map(e=>e.target)),p=e=>f.has(e.taskId??``)||f.has(e.id??``)||f.has(e.label),[,m]=(0,I.useState)(0);(0,I.useEffect)(()=>{if(d===0)return;let e=setInterval(()=>m(e=>e+1),3e4);return()=>clearInterval(e)},[d]);let h=uw(e,c.flatMap(e=>e.id&&!e.outputUnavailable?[e.id]:[]));return d===0&&u.length===0?null:(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5 ${t}`,"data-background-ops":!0,children:[sD(s,`sheet`).map((t,n)=>(0,L.jsx)(uD,{kind:`AGENT`,label:t.label,state:t.state,density:`sheet`,depth:t.displayDepth??t.depth,startedAt:t.startedAt,onOpen:t.id?()=>vp(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:sM(e,t)},`a${n}`)),sD(c,`sheet`).map((t,n)=>(0,L.jsx)(uD,{kind:`SHELL`,label:t.label,state:t.state,density:`sheet`,startedAt:t.startedAt,counter:t.id?$E(h.get(t.id)):void 0,counterTitle:`Lines of output so far — open the row to read them`,onOpen:t.id&&!t.outputUnavailable?()=>yp(e,t.id,{label:t.label,startedAt:t.startedAt}):void 0,onDismiss:sM(e,t,`SHELL`),title:p(t)?`${t.label}\nWatched — this thread wakes when it finishes`:void 0},`s${n}`)),l.map(e=>(0,L.jsx)(uD,{kind:`GITHUB`,label:e.target,state:`running`,density:`sheet`,startedAt:e.createdAt,counter:eD(e.github),counterTone:e.github?.checks===`failing`?`danger`:void 0,counterTitle:e.github?`${e.target} — ${I$(e.github)}`:void 0,onOpen:()=>window.open(sU(e.target)??`https://github.com/${e.target.replace(`#`,`/pull/`)}`,`_blank`,`noreferrer,noopener`)},e.id)),(0,L.jsx)(ZZ,{links:u})]})}function a4({ask:e,onTerminal:t}){return(0,L.jsxs)(IJ,{tone:`attention`,icon:Em,label:`Waiting on your answer — in your external terminal`,children:[(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.header&&(0,L.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted/55`,children:e.header}),(0,L.jsx)(`div`,{className:`min-w-0 text-[12px] font-medium leading-5 text-fg`,children:e.question}),e.options.length>0&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.options.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border border-border bg-elevated px-3 py-1.5 text-[12px] text-fg/80`,children:[(0,L.jsx)(`span`,{className:`font-medium text-fg/90`,children:e.label}),e.description&&(0,L.jsxs)(`span`,{className:`text-muted/70`,children:[` — `,e.description]})]},t)),e.multiSelect&&(0,L.jsx)(`div`,{className:`text-[10px] text-muted/50`,children:`select one or more`})]})]},t))}),(0,L.jsx)(RJ,{children:(0,L.jsxs)(`button`,{onClick:()=>t(),onMouseDown:e=>e.preventDefault(),className:VJ,children:[(0,L.jsx)(qm,{size:12,className:`shrink-0 ${CX}`}),`Copy terminal command`]})})]})}function o4({call:e,sourceId:t,at:n}){let r=k0(),i=e.detail??`sub-agent`,{tail:a}=WZ(e),o=!!(r&&e.agentId);return(0,L.jsxs)(CY,{icon:mm,sourceId:t,marker:`agent`,ariaLabel:o?void 0:`Sub-agent ${i} ${a}`,at:n,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:`Sub-agent`}),(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:`«`}),o?(0,L.jsx)(`button`,{type:`button`,"data-subagent-completion-open":!0,title:QE.AGENT,"aria-label":`${QE.AGENT}: ${i}`,onClick:()=>vp(r,e.agentId,{label:i,subagentType:e.subagentType}),onMouseDown:e=>e.preventDefault(),className:`min-w-0 truncate rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:i}):(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:i}),(0,L.jsx)(`span`,{className:`shrink-0`,children:`»`})]}),(0,L.jsx)(`span`,{className:`shrink-0`,children:a})]})}function s4({from:e,unnamed:t,dispatchId:n,sourceId:r,at:i}){let a=k0(),o=!!(a&&n),s=t?void 0:e,c=t&&e?`${QE.AGENT} — ${e}`:QE.AGENT;return s===void 0?(0,L.jsx)(CY,{icon:mm,sourceId:r,marker:`agent-report`,ariaLabel:o?void 0:`Sub-agent reported`,at:i,children:o?(0,L.jsx)(`button`,{type:`button`,"data-subagent-report-open":!0,title:c,"aria-label":`${QE.AGENT}${e?`: ${e}`:``}`,onClick:()=>vp(a,n,{label:`Sub-agent`,subagentType:e}),onMouseDown:e=>e.preventDefault(),className:`shrink-0 rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:`Sub-agent reported`}):(0,L.jsx)(`span`,{className:`shrink-0`,title:e||void 0,children:`Sub-agent reported`})}):(0,L.jsxs)(CY,{icon:mm,sourceId:r,marker:`agent-report`,ariaLabel:o?void 0:`Sub-agent ${s} reported`,at:i,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:`Sub-agent`}),(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:`«`}),o?(0,L.jsx)(`button`,{type:`button`,"data-subagent-report-open":!0,title:QE.AGENT,"aria-label":`${QE.AGENT}: ${s}`,onClick:()=>vp(a,n,{label:s,subagentType:e}),onMouseDown:e=>e.preventDefault(),className:`min-w-0 truncate rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:s}):(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:s}),(0,L.jsx)(`span`,{className:`shrink-0`,children:`»`})]}),(0,L.jsx)(`span`,{className:`shrink-0`,children:`reported`})]})}function c4({to:e,type:t,dispatchId:n,targetLabel:r,sourceId:i,at:a}){let o=k0(),s=B2(e,t),c=e===`main`?void 0:r??e,l=!!(o&&n);return(0,L.jsxs)(CY,{icon:mm,sourceId:i,marker:`agent-steer`,ariaLabel:l?void 0:`${s}${c?` ${c}`:``}`,at:a,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:s}),c&&(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,L.jsx)(`span`,{className:`shrink-0`,children:`«`}),l?(0,L.jsx)(`button`,{type:`button`,"data-subagent-steer-open":!0,title:QE.AGENT,"aria-label":`${QE.AGENT}: ${c}`,onClick:()=>vp(o,n,{label:c}),onMouseDown:e=>e.preventDefault(),className:`min-w-0 truncate rounded-sm underline decoration-muted/30 underline-offset-2 outline-none transition-colors hover:text-fg hover:decoration-fg/60 focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:c}):(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:c}),(0,L.jsx)(`span`,{className:`shrink-0`,children:`»`})]})]})}function l4({text:e,boundary:t,sourceId:n,at:r}){return t?(0,L.jsx)(CY,{icon:t===`wake`?vh:void 0,sourceId:n,marker:t===`rest`?`rest`:`event`,ariaLabel:e,at:r,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:e})}):(0,L.jsx)(`div`,{"data-frizz-msg":n,className:eQ,children:e})}function u4({text:e,sourceId:t}){let[n,r]=(0,I.useState)(!1),i=(0,I.useId)();return(0,L.jsxs)(`div`,{"data-frizz-msg":t,className:`flex 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`} model reasoning`,className:`${eQ} flex items-baseline gap-1.5 self-start rounded outline-none transition-colors hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:[(0,L.jsx)(`span`,{children:`Reasoning`}),(0,L.jsx)(ym,{"aria-hidden":`true`,size:13,className:nQ(n)})]}),n&&(0,L.jsx)(`div`,{id:i,className:`frizz-reasoning mt-1.5 ml-[5px] border-l border-border/70 pl-3`,children:(0,L.jsx)(q2,{md:e,wrap:!0})})]})}function d4(){return(0,L.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-full border border-muted/70 border-t-transparent animate-spin`})}function f4({since:e,startedAt:t,activityLabel:n,run:r}){let[i]=(0,I.useState)(()=>Date.now()),a=(0,I.useMemo)(()=>{for(let n of[t,e]){let e=Date.parse(n??``);if(Number.isFinite(e)&&e<=Date.now())return e}return i},[t,e,i]),[o,s]=(0,I.useState)(()=>Date.now()),[c,l]=(0,I.useState)(!1),u=(0,I.useId)();(0,I.useEffect)(()=>{let e=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(e)},[]);let d=LE(Math.max(0,o-a)),f=(0,I.useMemo)(()=>_2([...r?.tools??[]]),[r]),p=f.reduce((e,t)=>e+t.count,0),m=p>0,h=`group flex min-w-0 items-baseline justify-between gap-3 rounded text-left outline-none focus-visible:ring-1 focus-visible:ring-fg/60 ${eQ}`,g=(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate shimmer-text`,children:n??l0(p)}),m&&(0,L.jsx)(ym,{"data-working-chevron":!0,"aria-hidden":`true`,size:13,className:nQ(c)})]}),(0,L.jsx)(`span`,{className:`shrink-0 whitespace-nowrap tabular-nums text-[12px] text-muted/60`,children:d})]});return(0,L.jsxs)(`div`,{"data-working-indicator":!0,"data-working-activity":n?`tool`:`generic`,className:`flex min-w-0 flex-col`,children:[m?(0,L.jsx)(`button`,{type:`button`,onClick:()=>l(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":u,"aria-expanded":c,"aria-label":`${c?`Collapse`:`Expand`} ${p} tool ${p===1?`call`:`calls`}${n?`: ${n}`:``}`,className:`${h} w-full`,children:g}):(0,L.jsx)(`div`,{className:h,children:g}),m&&c&&(0,L.jsx)(`div`,{id:u,className:`mt-1.5 flex flex-col`,children:p2(f.map((e,t)=>(0,L.jsx)(S2,{t:e,startedAt:r?.at},t)),6)}),m&&!c&&(0,L.jsx)(`div`,{id:u,hidden:!0})]})}function p4(){let[e,t]=(0,I.useState)(()=>typeof window<`u`&&window.matchMedia(`(max-width: 800px)`).matches);return(0,I.useEffect)(()=>{let e=window.matchMedia(`(max-width: 800px)`),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function m4({id:e,slug:t,depth:n,widthDepth:r,initiallyOpen:i}){let{shown:a,close:o,closingRef:s}=Zp(e,i===!0),[c,l]=(0,I.useState)(i===!0),u=(0,I.useRef)(null),d=(0,I.useRef)(null),f=Zt(X),p=[...f.drawers].reverse().find(e=>!e.closing)?.id===e,m=p4(),h=(0,I.useRef)(typeof document<`u`&&document.activeElement instanceof HTMLElement?document.activeElement:null),g=(0,I.useCallback)(()=>{let e=h.current,t=document.activeElement;t&&t!==document.body||e?.isConnected&&e.focus({preventScroll:!0})},[]);(0,I.useEffect)(()=>()=>{window.setTimeout(g,0)},[g]);let _=qC(),v=Td(_,t),y=v.kind===`found`?v.thread:void 0;_?.projectDir;let b=y?y.runtime===`turn-idle`||y.runtime===`exited`||y.runtime===`none`:!1;return(0,I.useEffect)(()=>{!y||!b||Y.threadSeen({slug:t}).catch(()=>{})},[t,b,b?y?.lastActivityAt:void 0]),(0,I.useEffect)(()=>{let t=u.current;if(!t||!c)return;let n=()=>t.querySelector(`[data-drawer-scroll-ready]`),r=()=>t.querySelector(`[data-drawer-transcript-scroll]`),i=new UW({isActive:()=>[...X.drawers].reverse().find(e=>!e.closing)?.id===e,isContentReady:()=>n()?.dataset.drawerScrollReady===`true`,scrollToBottom:()=>{let e=r();return e?(e.scrollTop=e.scrollHeight,!0):!1},preserveAnchor:()=>location.hash.length>1});d.current=i;let a=null,o=new ResizeObserver(()=>i.layoutChanged()),s=()=>{let e=n();e!==a&&(a&&o.unobserve(a),a=e,e&&o.observe(e)),i.layoutChanged()},l=new MutationObserver(s);l.observe(t,{attributes:!0,attributeFilter:[`data-drawer-scroll-ready`],childList:!0,subtree:!0});let f=()=>i.userIntent(),p=e=>{[`Shift`,`Control`,`Alt`,`Meta`].includes(e.key)||f()};return t.addEventListener(`wheel`,f,{capture:!0,passive:!0}),t.addEventListener(`touchstart`,f,{capture:!0,passive:!0}),t.addEventListener(`pointerdown`,f,!0),t.addEventListener(`keydown`,p,!0),s(),()=>{i.dispose(),d.current===i&&(d.current=null),t.removeEventListener(`wheel`,f,!0),t.removeEventListener(`touchstart`,f,!0),t.removeEventListener(`pointerdown`,f,!0),t.removeEventListener(`keydown`,p,!0),o.disconnect(),l.disconnect()}},[c,e]),(0,I.useEffect)(()=>{d.current?.activationChanged()},[p]),(0,I.useEffect)(()=>{if(i)return;let e=!1,t=()=>{e||s.current||(e=!0,l(!0))},n=0,r=requestAnimationFrame(()=>{n=requestAnimationFrame(t)}),a=window.setTimeout(t,120);return()=>{window.clearTimeout(a),cancelAnimationFrame(r),n&&cancelAnimationFrame(n)}},[i]),(0,I.useEffect)(()=>{let e=u.current;if(!c||!e||document.activeElement!==e)return;let t=requestAnimationFrame(()=>{e.querySelector(`[data-dialog-initial-focus]`)?.focus({preventScroll:!0})});return()=>cancelAnimationFrame(t)},[c]),(0,I.useEffect)(()=>(vd(e,()=>{(u.current?.querySelector(`[data-dialog-initial-focus]`)??u.current)?.focus({preventScroll:!0})}),()=>vd(e,null)),[e]),(0,L.jsx)(eL,{modal:m,open:!0,onOpenChange:e=>{e||o()},children:(0,L.jsxs)(oL,{children:[(0,L.jsx)(cL,{className:`${Kp} ${a?`opacity-100`:`opacity-0`}`,style:{zIndex:50+n*2}}),(0,L.jsxs)(fL,{ref:u,"aria-modal":m||void 0,"aria-describedby":void 0,tabIndex:-1,onEscapeKeyDown:t=>{if(X.drawers.at(-1)?.id!==e){t.preventDefault();return}VR(t)},onPointerDownOutside:n=>{let r=X.drawers.findIndex(t=>t.id===e);if(r!==-1&&r<X.drawers.length-1){n.preventDefault();return}(n.target instanceof Element?n.target.closest(`[data-subagent-parent]`):null)?.getAttribute(`data-subagent-parent`)===t&&n.preventDefault()},onFocusOutside:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),g()},onOpenAutoFocus:e=>{e.preventDefault();let t=u.current;(t?.querySelector(`[data-dialog-initial-focus]`)??t)?.focus({preventScroll:!0})},"data-vt-chat":!0,className:`fixed right-0 top-0 overflow-hidden outline-none ${qp} ${a?`translate-x-0`:`translate-x-full`}`,style:{zIndex:51+n*2,width:Yp(r),viewTransitionName:f.vtReturnTarget===t?`thread-chat`:void 0},children:[(0,L.jsx)(_L,{className:`sr-only`,children:v.kind===`found`?`Thread: ${CT(v.thread)}`:`Thread: ${t}`}),c&&v.kind===`found`?(0,L.jsx)(P0,{slug:t,onStatusApplied:o,onClose:o,virtualized:!0}):c&&v.kind===`missing`?(0,L.jsx)(h4,{slug:t,onClose:o}):(0,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,L.jsx)(`span`,{className:`block h-5 w-5 rounded-full border-2 border-muted/50 border-t-transparent animate-spin`})})]})]})})}function h4({slug:e,onClose:t}){return(0,L.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,L.jsxs)(`header`,{className:`flex ${wh} shrink-0 items-center gap-3 border-b border-border bg-panel px-4`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:`Thread unavailable`}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Close`,"data-dialog-initial-focus":!0,onClick:t,className:`p-1 text-muted hover:text-fg`,children:`×`})]}),(0,L.jsxs)(`div`,{className:`flex flex-1 items-center justify-center px-6 text-center text-sm text-muted`,role:`status`,children:[`Thread “`,e,`” was not found in this project.`]})]})}function g4({id:e,slug:t,subId:n,label:r,subagentType:i,startedAt:a,depth:o,widthDepth:s}){let[c,l]=(0,I.useState)(!1),u=(0,I.useRef)(null),d=cw(t,n),f=JC(),p=(0,I.useMemo)(()=>d.data?.messages??[],[d.data]),m=d.data?.state,h=m===`running`,g=(0,I.useMemo)(()=>M0(p),[p]),_=(0,I.useMemo)(()=>N0(p),[p]),v=(0,I.useMemo)(()=>G1(_),[_]),y=h?J1(v):void 0,b=h?q1(v):void 0,x=b?i0(b,f):void 0,S=h?X1(v):void 0,C=(0,I.useMemo)(()=>h?$1(v):v,[v,h]),w=h,T=d.isError||m===`gone`||p.length===0&&(m===`done`||m===`stale`);return(0,I.useEffect)(()=>{let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>l(!0))});return()=>{cancelAnimationFrame(t),e&&cancelAnimationFrame(e)}},[]),(0,I.useEffect)(()=>{let e=u.current;if(!e||!c)return;let t=!0,n=()=>{t&&(e.scrollTop=e.scrollHeight)},r=()=>{t=e.scrollHeight-e.scrollTop-e.clientHeight<160};e.addEventListener(`scroll`,r,{passive:!0});let i=new ResizeObserver(n);for(let t of e.children)i.observe(t);return n(),()=>{e.removeEventListener(`scroll`,r),i.disconnect()}},[c]),(0,L.jsx)(tm,{id:e,depth:o,widthDepth:s,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Th,{title:r,onClose:e}),(0,L.jsx)(`div`,{ref:u,className:`flex-1 min-h-0 overflow-y-auto`,children:T?(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center px-8 text-center text-[13px] text-muted`,children:`Transcript unavailable (agent completed or cleaned up).`}):!c||d.isLoading||p.length===0?(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,L.jsx)(`span`,{className:`block h-5 w-5 rounded-full border-2 border-muted/50 border-t-transparent animate-spin`})}):(0,L.jsx)(O0.Provider,{value:t,children:(0,L.jsxs)(`div`,{"data-transcript-column":!0,className:`flex flex-col px-6 py-5`,children:[d2(C.map(e=>e.message),(e,t)=>(0,L.jsx)(K2,{m:e},t)),w&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(SY,{h:u2(C.map(e=>e.message))}),(0,L.jsx)(f4,{since:a,startedAt:S,activityLabel:x,run:y})]})]})})}),(0,L.jsx)(_4,{slug:t,subId:n,subagentType:i,steerable:d.data?.steerable===!0,note:d.data?.steerNote??null,stoppable:d.data?.stoppable===!0,stopNote:d.data?.stopNote??null,ops:e=>(0,L.jsx)(i4,{slug:t,parentAgentId:n,transcriptShells:g,className:e})})]})})}function _4({slug:e,subId:t,subagentType:n,steerable:r,note:i,stoppable:a,stopNote:o,ops:s}){let[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(!1),m=Ve();function h(){let n=c.trim();!n||u||(d(!0),l(``),Y.subAgentSteer({slug:e,id:t,message:n,deliveryId:crypto.randomUUID()}).then(()=>{m.invalidateQueries({queryKey:[`subAgentTranscript`,e,t]}),Z(`Steer sent`)}).catch(e=>{l(n),Z(e instanceof Error?e.message:`Could not steer this sub-agent`)}).finally(()=>d(!1)))}function g(){f||(p(!0),Y.subAgentStop({slug:e,id:t}).then(({descendantsStopped:n,note:r})=>{r?Z(`Sub-agent stopped. ${r}`,{duration:7e3}):Z(n>0?`Sub-agent and ${n} descendant${n===1?``:`s`} stopped`:`Sub-agent stopped`),m.invalidateQueries({queryKey:[`subAgentTranscript`,e,t]})}).catch(e=>{Z(e instanceof Error?e.message:`Could not stop this sub-agent`)}).finally(()=>p(!1)))}if(!r&&!a){let e=i??o;return e?(0,L.jsxs)(`div`,{"data-subagent-steer-note":!0,className:`w-full shrink-0 border-t border-border bg-panel px-3 py-3`,children:[(0,L.jsx)(`div`,{className:`px-1 pb-2 text-[11.5px] text-muted/70`,children:e}),(0,L.jsx)(`div`,{className:`pl-1.5`,children:(0,L.jsx)(v4,{subagentType:n})}),s?.(`px-1 pt-1.5 ops-column-optical-inset`)]}):(0,L.jsx)(L.Fragment,{children:s?.(`w-full shrink-0 border-t border-border bg-panel px-4 pb-2 pt-3`)})}return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{"data-subagent-steer":!0,className:`w-full shrink-0 border-t border-border bg-panel px-3 py-3`,children:[r?(0,L.jsx)(gR,{value:c,onChange:l,onSubmit:h,surface:`subAgentComposer`,placeholder:`Steer this sub-agent…`,busy:u||f,footer:(0,L.jsx)(v4,{subagentType:n})}):i?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`px-1 pb-2 text-[11.5px] text-muted/70`,children:i}),(0,L.jsx)(`div`,{className:`pl-1.5`,children:(0,L.jsx)(v4,{subagentType:n})})]}):null,r&&!a&&o&&(0,L.jsx)(`div`,{className:`mt-2 px-1 text-[11.5px] text-muted/70`,children:o}),s?.(`px-1 pt-1.5 ops-column-optical-inset`)]}),a&&(0,L.jsx)(`footer`,{"aria-label":`Sub-agent lifecycle actions`,"data-subagent-lifecycle-footer":!0,className:`flex min-h-10 w-full shrink-0 items-center justify-end gap-1.5 border-t border-border/70 bg-panel/95 px-3 pt-2 pb-[max(0.5rem,env(safe-area-inset-bottom))] text-[12px] backdrop-blur-sm`,children:(0,L.jsx)(`button`,{type:`button`,"data-stop-subagent":!0,disabled:f,onClick:g,className:`rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] text-fg/80 transition-colors hover:border-red-400/40 hover:bg-red-400/10 hover:text-red-300 disabled:opacity-50`,children:f?`Stopping…`:`Stop sub-agent`})})]})}function v4({subagentType:e}){let t=BZ(e);return(0,L.jsx)(`span`,{"data-subagent-profile":!0,"aria-label":`Sub-agent profile: ${t}`,title:e?.trim()||`The provider did not report this sub-agent's model and effort`,className:`inline-flex min-w-0 max-w-[min(72%,20rem)] items-center rounded-md border border-border/50 bg-transparent px-1.5 py-0.5 text-muted ${xR}`,children:(0,L.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 truncate`,children:t})})}var y4=`font-mono-keep overflow-x-auto whitespace-pre-wrap break-words ${kJ} border border-border bg-bg/75 px-4 py-2.5 text-[12px] leading-relaxed text-fg/85`;function b4({id:e,slug:t,shellId:n,label:r,startedAt:i,depth:a,widthDepth:o}){let s=(0,I.useRef)(null),c=lw(t,n),l=c.data?.state,u=c.data?.command,d=c.data?.output??``,[f,p]=(0,I.useState)(!1),m=Ve();(0,I.useEffect)(()=>{let e=s.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<160&&(e.scrollTop=e.scrollHeight)},[d]);let h=VE(i),g=l===`running`?`running${h?` ${h}`:``}`:l===`done`?`finished`:l===`gone`?`unavailable`:``,_=c.isError||l===`gone`;function v(){f||(p(!0),Y.subAgentStop({slug:t,id:n}).then(({note:e})=>{e?Z(`Background shell stopped. ${e}`,{duration:7e3}):Z(`Background shell stopped — the worker was told`),m.invalidateQueries({queryKey:[`backgroundShellOutput`,t,n]})}).catch(e=>{Z(e instanceof Error?e.message:`Could not stop this background shell`)}).finally(()=>p(!1)))}async function y(){if(u)try{await WR(u),Z(`Command copied`)}catch{Z(`Could not copy command`)}}return(0,L.jsx)(tm,{id:e,depth:a,widthDepth:o,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Th,{title:r,icon:(0,L.jsx)(vh,{"aria-hidden":!0,size:14,className:`shrink-0 text-muted/60`}),meta:g?(0,L.jsx)(`span`,{className:`shrink-0 whitespace-nowrap text-[11.5px] text-muted/60`,children:g}):void 0,onClose:e}),(0,L.jsx)(`div`,{ref:s,className:`min-h-0 flex-1 overflow-y-auto px-5 py-5`,children:_?(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center px-8 text-center text-[13px] text-muted`,children:`Background shell output is no longer available.`}):(0,L.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,L.jsxs)(`section`,{children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,L.jsx)(`h2`,{className:`petite-caps text-[10px] text-muted/65`,children:`Command`}),u&&(0,L.jsxs)(`button`,{type:`button`,onClick:y,className:`flex items-center gap-1 rounded px-1.5 py-1 text-[10.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:[(0,L.jsx)(Am,{"aria-hidden":!0,size:11}),` Copy`]})]}),u?(0,L.jsx)(Xq,{"data-background-shell-command":!0,text:u,language:`bash`,className:y4}):(0,L.jsx)(`pre`,{"data-background-shell-command":!0,className:y4,children:c.isLoading?`Loading…`:`Command unavailable for this background operation.`})]}),(0,L.jsxs)(`section`,{children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,L.jsx)(`h2`,{className:`petite-caps text-[10px] text-muted/65`,children:`Output`}),l===`running`&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--shell`,"data-running-indicator":`shell-drawer`}),c.data?.truncated&&(0,L.jsx)(`span`,{className:`text-[10.5px] text-muted/50`,children:`Showing latest 512 KB`})]}),d?(0,L.jsx)(`pre`,{"data-background-shell-output":!0,className:`font-mono-keep min-h-40 whitespace-pre-wrap break-words ${kJ} border border-border bg-[#090b10] px-4 py-3 text-[12px] leading-relaxed text-fg/85`,children:d}):(0,L.jsx)(`div`,{"data-background-shell-output":!0,className:`flex min-h-40 items-center justify-center ${kJ} border border-border bg-[#090b10] px-4 text-center text-[12px] text-muted/60`,children:l===`done`?`No output was captured.`:`No output yet.`})]})]})}),!_&&c.data?.stoppable&&(0,L.jsx)(`footer`,{"aria-label":`Background shell lifecycle actions`,"data-background-shell-lifecycle-footer":!0,className:`flex min-h-10 w-full shrink-0 items-center justify-end gap-1.5 border-t border-border/70 bg-panel/95 px-3 pt-2 pb-[max(0.5rem,env(safe-area-inset-bottom))] text-[12px] backdrop-blur-sm`,children:(0,L.jsx)(`button`,{type:`button`,"data-stop-background-shell":!0,disabled:f,onClick:v,className:`rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] text-fg/80 transition-colors hover:border-red-400/40 hover:bg-red-400/10 hover:text-red-300 disabled:opacity-50`,children:f?`Stopping…`:`Stop shell`})}),!_&&!c.data?.stoppable&&l===`running`&&c.data?.stopNote&&(0,L.jsx)(`footer`,{"data-background-shell-stop-note":!0,className:`w-full shrink-0 border-t border-border/70 bg-panel/95 px-4 pt-2 pb-[max(0.5rem,env(safe-area-inset-bottom))] text-[11.5px] text-muted/70`,children:c.data.stopNote})]})})}function x4(e){let t=/^---[ \t]*\r?\n([\s\S]*?)\r?\n---[ \t]*(?:\r?\n|$)/.exec(e);return t?{front:t[1],body:e.slice(t[0].length)}:{front:null,body:e}}var S4={paddingBottom:`max(0.75rem, env(safe-area-inset-bottom))`};function C4({path:e}){return(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{Y.openLocalFile({path:e}).then(async e=>{e.action===`copy`&&(await WR(e.path),Z(`Copied local path`))}).catch(e=>Z(`Could not open local file: ${e.message.slice(0,100)}`))},onMouseDown:e=>e.preventDefault(),className:`flex items-center gap-1.5 rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] font-medium text-fg/80 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,title:`Open ${e} outside Frizz`,"aria-label":`Open`,children:[(0,L.jsx)(Mm,{size:12,"aria-hidden":`true`}),` Open`]})}function w4({source:e}){return(0,L.jsx)(Xq,{text:e,language:`yaml`,className:`mb-4 whitespace-pre-wrap break-words rounded-md border border-border/60 bg-panel-2/40 px-3 py-2 font-mono-keep text-[12px] leading-5 text-muted`})}function T4({id:e,path:t,title:n,depth:r,widthDepth:i}){let a=XC(t),o=nt({...rC(t),refetchInterval:a?!1:iC}),s=o.data?.path??t,{front:c,body:l}=x4(o.data?.markdown??``),u=XK(l,{baseDir:tC(s),asDocument:!0}),d=Fq(u),f=(0,I.useRef)(null);return Jq(f,u),(0,L.jsx)(tm,{id:e,depth:r,widthDepth:i,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Th,{title:n,subtitle:s,onClose:e}),(0,L.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:o.isLoading?(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):o.error?(0,L.jsxs)(`div`,{className:`text-[13px] text-red-400/90`,children:[`Couldn’t read this file: `,o.error.message]}):u?(0,L.jsxs)(L.Fragment,{children:[c&&(0,L.jsx)(w4,{source:c}),(0,L.jsx)(`div`,{ref:f,className:`md-body`,dangerouslySetInnerHTML:d}),o.data?.truncated&&(0,L.jsx)(`p`,{className:`mt-4 border-t border-border/60 pt-3 text-[12px] text-muted`,children:`This file is too long to render in full — everything above the cut is shown. Open it to read the rest.`})]}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`})}),(0,L.jsx)(`div`,{className:`shrink-0 flex items-center justify-end gap-1.5 border-t border-border/60 bg-panel px-5 pt-3`,style:S4,children:(0,L.jsx)(C4,{path:s})})]})})}function E4({id:e,slug:t,title:n,depth:r,widthDepth:i}){let a=nt({queryKey:[`threadBody`,t],queryFn:()=>Y.threadBody({slug:t})}),o=Zt(X);(0,I.useEffect)(()=>{a.refetch()},[o.board]);let s=TX(Gp(o.board,t)),c=Oz(),l=Dz.adopt(c,t),[u,d,f]=Az(l),p=it({mutationFn:async e=>{await Y.adoptThread({slug:t,message:e.trim()||void 0})},onSuccess:()=>{X.drawers.find(t=>t.id===e)?.closing||(X.drawers=X.drawers.map(t=>t.id===e?{...t,kind:`thread`}:t))},onError:(e,t)=>{Tz.get(l)||d(t),Z(`Start failed: ${e.message.slice(0,80)}`)}}),m=XK(LK(a.data?.markdown??``)),h=Fq(m);return(0,L.jsx)(tm,{id:e,depth:r,widthDepth:i,widthOffset:1,subagentParent:t,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Th,{title:n,subtitle:`${t}.md`,onClose:e}),(0,L.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:a.isLoading?(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):m?(0,L.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:h}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`No thread file found.`})}),s&&(0,L.jsxs)(`div`,{className:`shrink-0 border-t border-border/60 px-5 pb-4 pt-3`,children:[(0,L.jsx)(`p`,{className:`mb-2.5 text-[11.5px] text-muted/80`,children:`No session is attached to this thread yet. Send a message below to start one on this plan.`}),(0,L.jsx)(gR,{surface:`adoptComposer`,value:u,onChange:d,onSubmit:()=>{if(!u.trim()||p.isPending)return;let e=u;f(),Z(`Starting thread…`,{spinner:!0,sticky:!0}),p.mutate(e)},placeholder:`Kick off work on this thread…`,minHeight:44,busy:p.isPending})]})]})})}function D4(){let e=Zt(X),t=qC();(0,I.useEffect)(()=>{function e(e){if(e.key===`Escape`&&!(e.target instanceof Element&&e.target.closest(`.xterm`))){if(BR()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(X.showPalette)X.showPalette=!1;else if(X.showNewThread)X.showNewThread=!1;else if(X.showGithubPicker)up();else if(X.showSettings)pd()||(X.showSettings=!1);else if(X.drawers.length>0){let e=X.drawers[X.drawers.length-1];_d(e.id)||X.drawers.pop()}else X.filePanel&&jp()}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let n=0;return(0,L.jsx)(L.Fragment,{children:e.drawers.map((e,r)=>{let i=n;e.closing||n++;let a=e.kind===`thread`?(0,L.jsx)(m4,{id:e.id,slug:e.slug,depth:r,widthDepth:i,initiallyOpen:e.routed},e.id):e.kind===`subagent`?(0,L.jsx)(g4,{id:e.id,slug:e.slug,subId:e.subId??``,label:e.label??e.slug,subagentType:e.subagentType,startedAt:e.startedAt,depth:r,widthDepth:i},e.id):e.kind===`shell`?(0,L.jsx)(b4,{id:e.id,slug:e.slug,shellId:e.subId??``,label:e.label??`Background shell`,startedAt:e.startedAt,depth:r,widthDepth:i},e.id):e.kind===`markdown`?(0,L.jsx)(T4,{id:e.id,path:e.path??e.slug,title:e.label??e.slug,depth:r,widthDepth:i},e.id):(0,L.jsx)(E4,{id:e.id,slug:e.slug,depth:r,widthDepth:i,title:(()=>{let n=Gp(t,e.slug);return n?CT(n):e.slug})()},e.id);return(0,L.jsx)(Dh,{label:`this drawer`,resetKeys:[e.kind,e.slug,e.subId,e.path],fallback:(t,n)=>(0,L.jsx)(Mh,{id:e.id,depth:r,widthDepth:i,error:t,onRetry:n}),children:a},e.id)})})}function O4(e){return(e.tools??[]).some(e=>e.name===`mcp__frizz__done`&&e.status===`completed`)}function k4(e){let t=oJ(e).filter(e=>e.kind===`question`);if(t.length!==0)return JSON.stringify(t.map(e=>e.kind===`question`?[e.questionKind,e.danger===!0,e.text.trim()]:null))}function A4(e){let t=new Map,n=[];for(let r=0;r<e.length;r++){let i=k4(e[r].text);n.push(i),i!==void 0&&t.set(i,r)}let r=new Set;for(let e=0;e<n.length;e++){let i=n[e];i!==void 0&&t.get(i)!==e&&r.add(e)}return r}function j4(e,t,n){return lJ(e.text)?!n.has(t):O4(e)?!0:e.wake===!0}function M4(e){return e.wake===!0}function N4(e,t){let n=[],r,i=!1,a=()=>{r&&r.start<=r.end&&n.push(r),r=void 0};for(let n=Math.max(0,t);n<e.length;n++){let t=e[n];if(t.closes===!0){a(),i=!0;continue}if(t.skip===!0)continue;if(t.opens===!0){a(),i=!0,r={start:n+1,end:n,open:-1,close:-1,steps:0,tools:0,resumed:!0,waker:-1};continue}let o=r===void 0;r||={start:n,end:n,open:-1,close:-1,steps:0,tools:0,resumed:i,waker:-1},o&&t.completion===!0&&r.resumed&&(r.waker=n),r.end=n,r.tools+=t.tools??0,t.text===!0&&(r.open<0&&(r.open=n),r.close=n)}a();for(let t of n)for(let n=t.start;n<=t.end;n++){let r=e[n];r.skip===!0||r.survives===!0||n===t.open||n===t.close||n===t.waker||r.countable===!0&&t.steps++}return n}function P4(e){return e.open<0||e.tools<1&&e.steps<1?!1:e.resumed||e.open!==e.close}function F4(e){if(e.length<3)return{kept:[...e]};let t=e[0],n=e[e.length-1],r=e.slice(1,-1);return{kept:[t,n],middle:{start:Math.max(t.end+1,r[0].start-1),end:r[r.length-1].end,runs:r.length,tools:r.reduce((e,t)=>e+t.tools,0)}}}function I4(e){return sD(e,`card`).length>0}function L4({slug:e,subAgents:t,className:n=`px-1 pt-1.5`}){let r=sD(t,`card`);return r.length===0?null:(0,L.jsx)(`div`,{"data-queue-subagents":!0,className:`flex min-w-0 flex-col gap-0.5 ${n}`,children:r.map((t,n)=>(0,L.jsx)(uD,{kind:`AGENT`,label:t.label,state:t.state,density:`card`,depth:t.depth,startedAt:t.startedAt,parentSlug:e,onOpen:t.id?()=>vp(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:sM(e,t)},t.id??`${t.startedAt}-${n}`))})}var R4=320;function z4(e){let t=[...document.querySelectorAll(`[data-queue-card]`)],n=t.findIndex(t=>t.dataset.queueCard===e);if(n<0)return null;let r=window.innerHeight,i=e=>{if(!e||e.dataset.queueLeaving===`true`||!e.dataset.queueCard)return!1;let t=e.getBoundingClientRect();return t.bottom>0&&t.top<r},a=i(t[n-1])?t[n-1]:i(t[n+1])?t[n+1]:null;return a?{slug:a.dataset.queueCard,top:a.getBoundingClientRect().top}:null}function B4(e){let t=[...document.querySelectorAll(`[data-queue-card]`)],n=t.findIndex(t=>t.dataset.queueCard===e);if(n<0)return null;let r=e=>e.dataset.queueLeaving!==`true`&&!!e.dataset.queueCard;for(let e=n+1;e<t.length;e++)if(r(t[e]))return t[e].dataset.queueCard;for(let e=n-1;e>=0;e--)if(r(t[e]))return t[e].dataset.queueCard;return null}var V4=0,H4=``;function U4(){V4++===0&&(H4=document.documentElement.style.overflowAnchor,document.documentElement.style.overflowAnchor=`none`)}function W4(){V4>0&&--V4===0&&(document.documentElement.style.overflowAnchor=H4)}function G4({thread:e,onSnooze:t,onSnoozeFailed:n}){return(0,L.jsx)(s1,{thread:e,onSnooze:t,onSnoozeFailed:n})}function K4(){let e=qC(),t=LT(YC(e?.threads??[]).filter(RT),Zt(yT).queueOrder),n=t.map(e=>e.id).join(`,`),[r,i]=(0,I.useState)(()=>new Set),a=(0,I.useRef)(t);a.current=t;let o=(0,I.useRef)(r);o.current=r;let s=new Set(t.map(e=>e.id)),c=(0,I.useRef)([]),l=(0,I.useRef)([]),u=(0,I.useRef)(new Map),d=(0,I.useRef)(new Set),f=(0,I.useRef)(new Set),p=(0,I.useRef)(new Map),m=(0,I.useRef)(new Map),h=(0,I.useRef)(null),[g,_]=(0,I.useState)(0);c.current.forEach(e=>{if(!s.has(e.id)&&!f.current.has(e.id)){let t=l.current.indexOf(e.id);u.current.delete(e.id),u.current.set(e.id,{view:e,index:t>=0?t:l.current.length}),r.has(e.id)&&d.current.add(e.id)}}),c.current=t;for(let e of[...f.current])s.has(e)?r.has(e)||(f.current.delete(e),d.current.delete(e)):r.has(e)||(f.current.delete(e),u.current.delete(e),d.current.delete(e));for(;u.current.size>32;){let e=u.current.keys().next().value;if(e===void 0)break;u.current.delete(e),d.current.delete(e);let t=p.current.get(e);t&&(clearTimeout(t),p.current.delete(e))}let v=e=>s.has(e)?r.has(e):d.current.has(e),y=WH(),b=e=>v(e.id)||UH(e,y[e.id]),x=(0,I.useMemo)(()=>{let e=t.filter(e=>!f.current.has(e.id)),n=[...u.current.entries()].filter(([e])=>!s.has(e)&&!f.current.has(e)).map(([,e])=>e).sort((e,t)=>e.index-t.index);for(let{view:t,index:r}of n)e.splice(Math.min(r,e.length),0,t);return e},[t,r,g]);l.current=x.map(e=>e.id),(0,I.useEffect)(()=>{let e=[...u.current.keys()].filter(e=>!s.has(e)&&!f.current.has(e)),t=e.filter(e=>!d.current.has(e)),n;t.length&&(n=requestAnimationFrame(()=>{t.forEach(e=>{u.current.has(e)&&d.current.add(e)}),_(e=>e+1)}));let i=new Set;for(let e of r)f.current.has(e)||i.add(e);for(let t of e)i.add(t);for(let e of i){if(p.current.has(e))continue;let t=setTimeout(()=>{if(p.current.delete(e),o.current.has(e)){let t=B4(e);h.current=t?{kind:`top`,slug:t}:null}else{let t=z4(e);h.current=t?{kind:`hold`,...t}:null}f.current.add(e),d.current.delete(e),_(e=>e+1)},R4);p.current.set(e,t)}return()=>{n!==void 0&&cancelAnimationFrame(n)}},[n,r,g]),(0,I.useEffect)(()=>{let e=[...r].filter(e=>f.current.has(e)&&!s.has(e));if(e.length!==0){for(let t of e)f.current.delete(t),u.current.delete(t),d.current.delete(t);i(t=>{let n=new Set(t);for(let t of e)n.delete(t);return n})}},[n,g]),(0,I.useEffect)(()=>()=>{for(let e of p.current.values())clearTimeout(e);for(let e of m.current.values())clearTimeout(e)},[]),(0,I.useLayoutEffect)(()=>{let e=h.current;if(!e)return;h.current=null;let t=document.querySelector(`[data-queue-card="${CSS.escape(e.slug)}"]`);if(!t)return;if(e.kind===`hold`){let n=t.getBoundingClientRect().top-e.top;Math.abs(n)>.5&&window.scrollBy({top:n,left:0,behavior:`auto`});return}U4();let n=()=>{let t=sp(e.slug);t!==null&&Math.abs(bd()-t)>.5&&window.scrollTo({top:t,left:0,behavior:`auto`})};n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n(),W4()})})},[g]);let S=(0,I.useCallback)(e=>{i(t=>new Set(t).add(e));let t=m.current.get(e);t&&clearTimeout(t);let n=setTimeout(()=>{m.current.delete(e),a.current.some(t=>t.id===e)&&(f.current.delete(e),d.current.delete(e),i(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),_(e=>e+1))},8e3);m.current.set(e,n)},[]),C=(0,I.useCallback)(e=>{let t=m.current.get(e);t&&(clearTimeout(t),m.current.delete(e));let n=p.current.get(e);n&&(clearTimeout(n),p.current.delete(e)),f.current.delete(e),d.current.delete(e),i(t=>{if(!t.has(e))return t;let n=new Set(t);return n.delete(e),n}),_(e=>e+1)},[]),w=(e?.threads.length??0)===0;return(0,L.jsxs)(`div`,{className:`my-auto w-full min-w-0 flex flex-col py-8`,children:[(0,L.jsx)(q4,{board:e}),x.length>0&&(0,L.jsx)(`div`,{className:`flex flex-col`,children:x.map((e,t)=>(0,L.jsxs)(I.Fragment,{children:[(0,L.jsx)(Y4,{slug:e.id,leaving:v(e.id),children:(0,L.jsx)(Q4,{thread:e,leaving:v(e.id),frozen:b(e),onResolve:S,onUnresolve:C})}),t<x.length-1&&(0,L.jsx)(`hr`,{className:`my-10 border-0 border-t border-border/60`})]},e.id))}),w?(0,L.jsxs)(`div`,{className:`w-full flex flex-col gap-3`,children:[(0,L.jsx)(`h2`,{className:`text-[15px] font-medium text-center`,children:`What should the agent do?`}),(0,L.jsx)(LH,{}),(0,L.jsx)(Mz,{autoFocus:!0})]}):x.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-2 pt-2`,children:[(0,L.jsx)(Km,{size:40,strokeWidth:1.25,className:`text-muted/30`}),(0,L.jsx)(`div`,{className:`text-[13px] text-muted/80`,children:`No threads awaiting human input`})]}):null]})}function q4({board:e}){let t=e?.errorItems??[],n=e?.errors??[];return t.length===0&&n.length===0?null:(0,L.jsxs)(`div`,{className:`mb-6 ${kJ} border border-amber-500/25 bg-amber-500/[0.06] px-4 py-2.5 text-[12px] text-amber-200/90`,children:[(0,L.jsx)(`div`,{className:`font-medium mb-0.5`,children:`Board errors`}),t.length>0?t.slice(0,6).map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5`,children:[(0,L.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,title:`${e.file?`${e.file}: `:``}${e.message}`,children:[e.file?`${e.file}: `:``,e.message]}),e.kind===`no-frontmatter`&&(0,L.jsx)(J4,{file:e.file})]},t)):n.slice(0,3).map((e,t)=>(0,L.jsx)(`div`,{className:`truncate`,title:e,children:e},t))]})}function J4({file:e}){let t=it({mutationFn:()=>Y.repairThread({file:e}),onSuccess:({slug:e})=>Z(`Repaired ${e} — verify its status`),onError:e=>Z(e instanceof Error?e.message:`Repair failed`)});return(0,L.jsx)(`button`,{onClick:()=>t.mutate(),disabled:t.isPending,className:`shrink-0 rounded border border-amber-400/50 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-100 transition-colors hover:bg-amber-500/25 disabled:opacity-50`,title:`Prepend minimal frontmatter (title + status: active) so this thread becomes visible again`,children:t.isPending?`Repairing…`:`Repair`})}function Y4({leaving:e,slug:t,children:n}){return(0,L.jsx)(`div`,{"data-queue-card":t,"data-queue-leaving":e,className:`frizz-card-slot min-w-0`,children:(0,L.jsx)(`div`,{className:`frizz-card-clip min-h-0 min-w-0`,children:(0,L.jsx)(`div`,{className:`frizz-card-body min-w-0`,children:n})})})}function X4({runs:e,toolCount:t,onExpand:n}){let r=t>0?`${t} tool call${t===1?``:`s`}`:``,i=`${e} more round${e===1?``:`s`}`;return(0,L.jsxs)(CY,{icon:xm,marker:`middle-runs-summary`,onClick:n,ariaLabel:`Expand ${i}${r?` and ${r}`:``} of intermediate agent activity`,children:[(0,L.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:i}),r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,L.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:r})]}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,L.jsx)(`span`,{className:`shrink-0`,children:`Click to expand`})]})}function Z4({toolCount:e,onExpand:t}){let n=e>0?`${e} tool call${e===1?``:`s`}`:``;return(0,L.jsxs)(CY,{icon:xm,marker:`intermediate-summary`,onClick:t,ariaLabel:`Expand ${n?`${n} of `:``}intermediate agent activity`,children:[n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:n}),(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`})]}),(0,L.jsx)(`span`,{className:`shrink-0`,children:`Click to expand`})]})}var Q4=(0,I.memo)(function({thread:e,leaving:t,frozen:n,onResolve:r,onUnresolve:i}){let a=Zt(X),[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(0),v=(0,I.useRef)(null),y=(0,I.useRef)(null),b=(0,I.useRef)(!1),x=(0,I.useRef)(!1),S=(0,I.useRef)(null),C=Ve(),w=x1(e.id),T=sw(e.id,{poll:!1}),E=(0,I.useRef)(T.data);n||(E.current=T.data);let D=n?E.current:T.data,O=(0,I.useRef)(null),k=(0,I.useRef)(0);(0,I.useEffect)(()=>{let e=O.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(t=>{if(e.style.height)return;let n=t[0]?.borderBoxSize?.[0];n&&(k.current=n.blockSize)});return t.observe(e),()=>t.disconnect()},[]),(0,I.useLayoutEffect)(()=>{let e=O.current;if(e){if(!t){e.style.height=``,e.style.overflow=``;return}k.current>0&&(e.style.height=`${k.current}px`,e.style.overflow=`hidden`)}});let A=(0,I.useMemo)(()=>D?.messages??[],[D]),j=(0,I.useMemo)(()=>o2(A),[A]),M=e=>j>=0&&e<j,N=i1(e),P=e=>M(e)||e===j&&N,ee=(0,I.useMemo)(()=>oY(A),[A]),F=(0,I.useMemo)(()=>bX(A),[A]),te=(0,I.useMemo)(()=>{for(let e=A.length-1;e>=0;e--)if(A[e].boundary===`rest`)for(let t=e+1;t<A.length;t++){let n=A[t];if(!(n.queued||n.boundary===`rest`||a2(n,P(t))))return e+1}return 0},[A]),ne=(0,I.useMemo)(()=>{for(let e=A.length-1;e>=0;e--)if(A[e].role===`user`&&!A[e].queued)return e;return-1},[A]),re=(0,I.useMemo)(()=>A4(A),[A]),ie=(0,I.useMemo)(()=>A.map((e,t)=>{if(!e||e.queued||a2(e,P(t)))return{skip:!0};if(e.boundary===`rest`)return{skip:!0,closes:!0};let n=HZ(e),r=n?0:e.tools.length;return{text:l2(e,P(t)),tools:r,countable:l2(e,P(t))||r>0||n!==void 0||e.kind!==void 0,survives:j4(e,t,re),opens:M4(e),completion:e.boundary===`wake`||n!==void 0}}),[A,re]),ae=(0,I.useMemo)(()=>N4(ie,F+1),[ie,F]),{kept:oe,middle:se}=(0,I.useMemo)(()=>F4(ae),[ae]),ce=(0,I.useMemo)(()=>oe.filter(P4),[oe]),le=(0,I.useMemo)(()=>{let e=new Map;return ce.forEach((t,n)=>{for(let r=t.start;r<=t.end;r++)e.set(r,n)}),e},[ce]),ue=!c&&(ne>=0||te>0)&&(ce.length>0||se!==void 0),de=Ox(A,f,F),fe=(0,I.useMemo)(()=>A.slice(de),[A,de]),pe=(0,I.useMemo)(()=>G1(fe).map(e=>({...e,messageIndex:e.messageIndex+de})),[fe,de]),me=(0,I.useMemo)(()=>xY(A,e?.questions??[]),[A,e?.questions]),he=(0,I.useMemo)(()=>{let t=[],n=new Map,r=A.length-1,i=e.runtime!==`running`&&e.runtime!==`spawning`,a=(e?.questions??[]).filter(e=>!me.placedIds.has(e.id));for(let[e,o]of uY(A,a,{atRest:i})){if(e>=r){t.push(...o);continue}let i=n.get(e);i?i.push(...o):n.set(e,[...o])}return{byAnchor:n,tail:t}},[A,me.placedIds,e.runtime,e?.questions]),ge=Xl(e.spawnedAt),_e=(0,I.useMemo)(()=>pY(A,e?.questions??[]),[A,e?.questions]),ve=(0,I.useMemo)(()=>tY(A,e.answersInFlight),[A,e.answersInFlight]),ye=de>0||D?.hasEarlier===!0;(0,I.useLayoutEffect)(()=>{let e=y.current,t=v.current;if(!e||!t||![...t.querySelectorAll(`[data-transcript-source-id]`)].some(t=>t.dataset.transcriptSourceId===e.targetStartId))return;let n=()=>{Fx(t,e.anchor,e=>{e!==0&&window.scrollBy({top:e,left:0,behavior:`auto`})});let n=0;return Fx(t,e.anchor,e=>{n=e}),n},r=n();if(Ix({remaining:r,scrollY:window.scrollY,maxScrollY:Math.max(0,document.documentElement.scrollHeight-window.innerHeight),alreadyReserved:e.reserved===!0})===`reserve`){e.reserved=!0,_(e=>e+Math.ceil(r));return}x.current||(x.current=!0,requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n(),y.current=null,x.current=!1,b.current&&(b.current=!1,W4())})}))},[g,A,f]),(0,I.useEffect)(()=>{let e=D?.transcriptKey;if(!e)return;let t=S.current;S.current=e,!(!t||t===e)&&(p(null),_(0),l(!1),y.current=null,x.current=!1,b.current&&(b.current=!1,W4()))},[D?.transcriptKey]),(0,I.useEffect)(()=>()=>{b.current&&(b.current=!1,W4())},[]);let be=e=>{let t=Nx(v.current);!e||!t||(b.current||(b.current=!0,U4()),y.current={anchor:t,targetStartId:e})},xe=async()=>{if(m||!ye)return;let t=Dx(A,de),n=t!==null&&A[t]?.role===`user`?t:null;if(n!==null){let e=A[n].sourceId;be(e),p(e??null);return}let r=D?.beforeCursor;if(!r){if(de>0){let e=A[0]?.sourceId;be(e),p(e??null)}return}let i=D?.transcriptKey;if(i){h(!0);try{let t=await Y.threadTranscriptEarlier({slug:e.id,cursor:r}),n=C.getQueryData([`transcript`,e.id]);if(!n?.transcriptKey||n.transcriptKey!==i||t.transcriptKey!==i){await T.refetch(),p(null),Z(`Transcript changed while loading history; refreshed the current session`);return}let a=t.messages[0]?.sourceId??A[0]?.sourceId;be(a);let o=Mx(n,t);C.setQueryData([`transcript`,e.id],o),p(a??null)}catch(e){await T.refetch(),p(null),Z(e instanceof Error?e.message:`Could not load earlier transcript history`)}finally{h(!1)}}},Se=it({mutationFn:()=>Y.markComplete({slug:e.id})}),{answeringForMessage:Ce,answerable:we,anyAnswered:Te,sendAnswers:Ee,sendMessage:De}=nX(e.id,A,()=>{document.activeElement?.blur(),r(e.id)},{scrollToBottom:!1,onSendFailed:()=>i(e.id)}),Oe=(0,I.useMemo)(()=>{let e=eX(A);return e!==-1&&vY(A[e].text,_e.get(e)??[])},[A,_e]),ke=ge&&(we&&!Oe||Te),Ae=(0,I.useCallback)(()=>r(e.id),[r,e.id]),je=(0,I.useCallback)(()=>i(e.id),[i,e.id]),Me=(0,I.useMemo)(()=>({dismiss:Ae,cancel:je}),[Ae,je]);return(0,L.jsx)(D0.Provider,{value:e.id,children:(0,L.jsx)(A0.Provider,{value:Me,children:(0,L.jsx)(p$,{thread:e,children:(0,L.jsxs)(`div`,{ref:O,"data-queue-card-root":e.id,"data-queue-leaving":t,style:{...g?{marginBottom:g}:null,...a.vtReturnTarget===e.id?{viewTransitionName:`thread-chat`}:null},onKeyDown:e=>{if(!Te)return;let t=e.target;t instanceof HTMLButtonElement||t instanceof HTMLAnchorElement||t instanceof HTMLTextAreaElement&&t.value.trim()||nR({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(),Ee())},"data-vt-chat":!0,className:`flex flex-col min-w-0 max-w-full ${kJ} border border-border-strong bg-panel shadow-lg shadow-black/25 transition-opacity ${u?`opacity-40`:``}`,children:[(0,L.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,L.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 bg-panel px-5 py-3.5 max-[800px]:top-10 ${o?kJ:`${AJ} border-b border-border/60`}`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`group/thread-title flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`min-w-0 shrink truncate font-semibold text-[15px] leading-snug`,title:CT(e),children:CT(e)}),(0,L.jsx)(LZ,{thread:e})]}),(0,L.jsx)(f1,{at:PT(e),fallbackAt:e.spawnedAt,className:`mt-0.5 block truncate text-[11px] leading-tight text-muted/75`}),e.statusText&&e.status===`needs-human`&&(0,L.jsx)(`div`,{className:`text-[11px] text-muted/80 mt-0.5 truncate`,title:e.statusText,children:e.statusText})]}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[e.kind===`session`&&e.foreign!==!0&&(0,L.jsx)(S1,{slug:e.id}),(0,L.jsx)(nZ,{thread:e,collapsed:o,onCollapse:()=>s(e=>!e),expand:!0,onDone:()=>Se.mutate(void 0,{onSuccess:()=>r(e.id),onError:()=>d(!1)}),doneBusy:Se.isPending,onStatusMutate:()=>d(!0),onStatusApplied:()=>r(e.id),onStatusFailed:()=>d(!1)})]})]}),o?null:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`px-5 pt-5 ${ke?`pb-2`:`pb-5`}`,children:[A.length===0?(0,L.jsx)(`p`,{className:`text-[13px] text-muted`,children:T.isLoading?`Loading…`:e.statusText||`No message yet.`}):(0,L.jsxs)(`div`,{ref:v,className:`flex flex-col`,children:[ye&&(0,L.jsx)(`button`,{className:`mb-3.5 self-center rounded-md border border-border px-2 py-0.5 text-[11px] text-muted transition-colors hover:text-fg hover:bg-panel-2 outline-none`,onClick:()=>void xe(),onMouseDown:e=>e.preventDefault(),disabled:m,children:m?`Loading earlier messages…`:D?.reachedTurnBoundary===!1?`Continue loading this turn`:`Load earlier messages`}),(()=>{let t=de,n=[],r=null,i=[...he.byAnchor.entries()].sort((e,t)=>e[0]-t[0]),a=t=>{for(;i.length>0&&i[0][0]<=t;){let[t,a]=i.shift();r!==null&&n.push((0,L.jsx)(SY,{h:14},`qa-space-${t}`)),n.push((0,L.jsx)(h$,{thread:e,questions:a},`qa-${t}`)),r=!1}};a(t-1);let o=new Set,s=!1;return pe.forEach(({message:t,messageIndex:i},c)=>{if(t.queued||a2(t,P(i))||t.boundary===`rest`)return;if(ue&&se&&i>=se.start&&i<=se.end){s||(s=!0,r!==null&&n.push((0,L.jsx)(SY,{h:14},`middle-runs-space`)),n.push((0,L.jsx)(X4,{runs:se.runs,toolCount:se.tools,onExpand:()=>l(!0)},`middle-runs-summary`)),r=!1);return}let u=ue?le.get(i):void 0,d=u===void 0?void 0:ce[u],f=d!==void 0,p=d!==void 0&&i===d.open,m=d!==void 0&&i===d.close,h=f&&!p&&!m&&!lJ(t.text)&&!O4(t)&&j4(t,i,re);if(d!==void 0&&i===d.waker){r!==null&&n.push((0,L.jsx)(SY,{h:r&&$0(t)?6:14},`s${c}`));let e=t.sourceId??`legacy-${i}`;n.push((0,L.jsx)(`div`,{"data-transcript-source-id":e,className:`flex flex-col`,children:(0,L.jsx)(K2,{m:t,dense:!0})},e)),r=Q0(t);return}if(f&&!h){if(!p&&!m&&!j4(t,i,re)||(!p&&u!==void 0&&!o.has(u)&&(r!==null&&n.push((0,L.jsx)(SY,{h:14},`im-space-${u}`)),n.push((0,L.jsx)(Z4,{toolCount:d.tools,onExpand:()=>l(!0)},`intermediate-summary-${u}`)),r=!1,o.add(u)),!l2(t,P(i))))return;r!==null&&n.push((0,L.jsx)(SY,{h:14},`s${c}`));let s=t.sourceId??`legacy-${i}`;n.push((0,L.jsx)(`div`,{"data-transcript-source-id":s,className:`flex flex-col`,children:(0,L.jsx)(K2,{m:t,dense:!0,textOnly:!0,answering:ge?Ce(t):void 0,paired:ee[i],staleAwaiting:M(i),restingCardShown:i===j&&N,shadowedBy:_e.get(i),placed:me.placed.get(i),thread:e})},s)),r=!1,a(i);return}r!==null&&n.push((0,L.jsx)(SY,{h:r&&$0(t)?6:14},`s${c}`));let g=t.sourceId??`legacy-${i}`;n.push((0,L.jsx)(`div`,{"data-transcript-source-id":g,className:`flex flex-col`,children:(0,L.jsx)(K2,{m:t,dense:!0,staleAwaiting:M(i),restingCardShown:i===j&&N,answering:ge?Ce(t):void 0,paired:ee[i],shadowedBy:_e.get(i),placed:me.placed.get(i),thread:e})},g)),r=Q0(t),a(i)}),fe.forEach((e,r)=>{e.queued&&(n.push((0,L.jsx)(SY,{},`qs${r}`)),n.push((0,L.jsx)(K2,{m:e,dense:!0,paired:ee[t+r]},`q${t+r}`)))}),n})()]}),!T.isLoading&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(HQ,{thread:e,className:`mt-4`}),e.pendingInteraction?null:e.pendingAsk?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(a4,{ask:e.pendingAsk,onTerminal:w})}):e.runtime===`perm-prompt`?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(n4,{onTerminal:w})}):null,e.permPolicy?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(r4,{policy:e.permPolicy,denies:e.permDenies})}):null]}),!T.isLoading&&i1(e)&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(G4,{thread:e,onSnooze:Ae,onSnoozeFailed:je})}),!T.isLoading&&DJ(e,j>=0?A[j]?.text:void 0)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(SY,{}),(0,L.jsx)($2,{fenceKind:`done`,body:e.lastFence.body,hints:[],wrap:!0})]}),!T.isLoading&&e.limitPause&&e.foreign!==!0&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(t4,{slug:e.id,sessionId:e.sessionId,pause:e.limitPause})}),!T.isLoading&&HJ(e,j>=0?A[j]?.text:void 0)&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(UJ,{thread:e})})]}),(0,L.jsx)(h$,{thread:e,questions:he.tail,inFlight:ve,showSend:me.placedIds.size>0,className:`shrink-0 px-5 pb-4 pt-0`}),ke&&(0,L.jsx)(`div`,{className:`shrink-0 px-5 pt-0`,children:(0,L.jsx)(`div`,{className:`mb-4 flex items-center justify-start gap-2`,children:(0,L.jsx)(`button`,{disabled:!Te,onClick:()=>Ee(),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`})})}),(0,L.jsx)(YX,{slug:e.id,surface:`queueComposer`,className:`shrink-0 px-5 pb-3 pt-0`,placeholder:we||(e.questions?.length??0)>0?`Or skip the questions and reply…`:`Reply to the agent…`,submitOverride:De,ops:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(L4,{slug:e.id,subAgents:e.subAgents??[],className:`px-1 pt-1.5`}),(0,L.jsx)(i4,{slug:e.id,includeAgents:!1,className:`px-1 ${I4(e.subAgents??[])?`pt-0.5`:`pt-1.5`}`})]})})]})]}),(0,L.jsx)(MZ,{thread:e,onArchived:()=>r(e.id),onDismissCancel:()=>i(e.id),onSnoozed:()=>r(e.id)})]})})})})},$4);function $4(e,t){return e.leaving===t.leaving&&e.frozen===t.frozen&&e.onResolve===t.onResolve&&e.onUnresolve===t.onUnresolve&&(e.thread===t.thread||JSON.stringify(e.thread)===JSON.stringify(t.thread))}function e3(e,t){if(e.backend===`claude`)return nz.some(t=>t.value===e.model)?sz(e.model).includes(e.effort)?void 0:`Reasoning level ${e.effort} is not available for ${e.model}`:`Claude model ${e.model} is no longer available`;let n=t.find(t=>t.slug===e.model);if(!n)return`Codex model ${e.model} is no longer available`;if(!n.efforts.includes(e.effort))return`Reasoning level ${e.effort} is not available for ${e.model}`}function t3(e,t){return{items:t.map(e=>({...e})),backend:e.backend,model:e.model,effort:e.effort}}function n3({keys:e,key:t,shiftKey:n,anchor:r,selected:i}){let a=e.indexOf(t),o=r===null?-1:e.indexOf(r);if(!n||a===-1||o===-1||r===null){let e=new Set(i);return e.has(t)?e.delete(t):e.add(t),{selected:e,anchor:a===-1?r:t}}let s=a>=o?1:-1,c=i.has(r),l=new Set(i);for(let t=o;;t+=s){let n=e[t];if(c?l.add(n):l.delete(n),t===a)break}return{selected:l,anchor:r}}var r3=30;function i3({onClose:e}){let t=vR(),{resolved:n,codexList:r,loadError:i,saveProfile:a}=hz(),[o,s]=(0,I.useState)(`issues`),[c,l]=(0,I.useState)(`recent`),[u,d]=(0,I.useState)(1),[f,p]=(0,I.useState)(()=>new Set),[m,h]=(0,I.useState)(null),g=nt({queryKey:[`githubList`,o,c,u],queryFn:()=>Y.githubList({kind:o,sort:c,page:u,perPage:r3}),placeholderData:ee}),_=g.data?.items??[],v=g.data?.page??u,y=g.data?.pageCount??1,b=g.data?.total??0,x=(0,I.useRef)(null);(0,I.useEffect)(()=>{x.current&&(x.current.scrollTop=0)},[u,o,c]);let S=it({mutationFn:e=>Y.githubDispatchBatch(e),onMutate:e=>Z(`Starting ${e.items.length} thread${e.items.length===1?``:`s`}…`,{spinner:!0,sticky:!0}),onSuccess:t=>{let n=t.dispatched.length,r=t.failed.length;Z(`Started ${n} thread${n===1?``:`s`}${r?` (${r} failed)`:``}`),e()},onError:e=>Z(`Dispatch failed: ${e.message.slice(0,80)}`)});function C(e){e!==o&&(s(e),d(1),p(new Set),h(null))}function w(e){e!==c&&(l(e),d(1),p(new Set),h(null))}function T(e,t){let n=n3({keys:_.map(e=>e.number),key:e,shiftKey:t,anchor:m,selected:f});p(n.selected),h(n.anchor)}function E(){p(new Set),h(null)}let D=t.data?.nameWithOwner??`this repo`,O=f.size,k=(0,I.useMemo)(()=>pz(r),[r]),A=n?{backend:n.backend,model:n.model,effort:n.effort}:void 0,j=A?e3(A,r):i?`Could not load the model catalogue — reopen once it loads`:void 0,M=j??(A?void 0:`Loading the model catalogue…`);function N(){if(!A||M){Z(M??`Choose a model and reasoning level`);return}S.mutate(t3(A,[...f].map(e=>({kind:o===`issues`?`issue`:`pr`,number:e}))))}return(0,L.jsx)(Pz,{onClose:e,children:(0,L.jsxs)(`div`,{className:`flex max-h-[85vh] w-[720px] max-w-[90vw] flex-col rounded-xl border border-border bg-panel p-5 shadow-2xl shadow-black/50`,onKeyDownCapture:t=>{t.key===`Escape`&&(t.stopPropagation(),e())},children:[(0,L.jsxs)(`h2`,{className:`mb-4 flex items-center gap-2 text-[14px] font-medium`,children:[(0,L.jsx)(Hm,{size:15,className:`text-muted`}),(0,L.jsx)(`span`,{children:`Investigate this issue and make recommendations`}),(0,L.jsx)(`span`,{className:`text-muted/40`,children:`—`}),(0,L.jsx)(`span`,{className:`font-mono-keep text-[12.5px] text-muted`,children:D})]}),(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,L.jsx)(o3,{value:o,onChange:e=>C(e),options:[{value:`issues`,label:`Issues`},{value:`prs`,label:`PRs`}]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`petite-caps text-[11px] text-muted/70`,children:`Sort`}),(0,L.jsx)(o3,{value:c,onChange:w,options:[{value:`recent`,label:`Recent`},{value:`reactions`,label:`Reactions`}]})]})]}),(0,L.jsx)(`div`,{ref:x,className:`min-h-[240px] flex-1 overflow-y-auto rounded-lg border border-border/70 bg-bg/40 transition-opacity ${g.isPlaceholderData?`opacity-40`:``}`,children:g.isLoading?(0,L.jsx)(h3,{}):g.isError?(0,L.jsxs)(g3,{children:[(0,L.jsxs)(`span`,{className:`text-[12.5px] text-muted/80`,children:[`Couldn't load `,o===`issues`?`issues`:`pull requests`,`.`]}),(0,L.jsx)(`span`,{className:`max-w-[80%] text-center text-[11px] text-muted/45`,children:g.error.message.slice(0,140)})]}):_.length===0?(0,L.jsxs)(g3,{children:[(0,L.jsx)(Km,{size:28,strokeWidth:1.25,className:`text-muted/30`}),(0,L.jsxs)(`span`,{className:`text-[12.5px] text-muted/60`,children:[`No open `,o===`issues`?`issues`:`pull requests`]})]}):_.map(e=>(0,L.jsx)(l3,{item:e,checked:f.has(e.number),onActivate:t=>T(e.number,t)},e.number))}),!g.isLoading&&!g.isError&&(0,L.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between gap-3 whitespace-nowrap text-[11.5px] text-muted/60`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsxs)(`span`,{className:`truncate tabular-nums`,children:[b,` open `,o===`issues`?b===1?`issue`:`issues`:b===1?`pull request`:`pull requests`]}),O>0&&(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`text-muted/30`,children:`·`}),(0,L.jsxs)(`span`,{className:`tabular-nums text-fg/70`,children:[O,` selected`]}),(0,L.jsx)(`button`,{onClick:E,onMouseDown:e=>e.preventDefault(),className:`rounded py-0.5 text-muted/60 underline-offset-2 outline-none transition-colors hover:text-fg hover:underline`,children:`Clear`})]})]}),y>1&&(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,L.jsx)(a3,{label:`Previous page`,disabled:v<=1,onClick:()=>d(Math.max(1,v-1)),children:(0,L.jsx)(vm,{size:14})}),(0,L.jsxs)(`span`,{className:`relative px-2 text-center tabular-nums`,children:[(0,L.jsxs)(`span`,{"aria-hidden":!0,className:`invisible`,children:[`Page `,y,` of `,y]}),(0,L.jsxs)(`span`,{className:`absolute inset-0`,children:[`Page `,v,` of `,y]})]}),(0,L.jsx)(a3,{label:`Next page`,disabled:v>=y,onClick:()=>d(Math.min(y,v+1)),children:(0,L.jsx)(ym,{size:14})})]})]}),(0,L.jsxs)(`div`,{className:`mt-4 flex items-end justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(UR,{groups:k,value:n?{provider:n.backend,model:n.model,effort:n.effort}:void 0,onValueChange:e=>a({field:`profile`,backend:e.provider,model:e.model,effort:e.effort}),placeholder:i?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort`,title:M??`Model and reasoning effort for every thread this batch starts`,disabled:!n,side:`top`,menuZClass:tM,className:`max-w-[min(21rem,60vw)]`}),j&&(0,L.jsx)(`p`,{className:`mt-1 max-w-[430px] text-[10.5px] text-red-400`,children:j})]}),(0,L.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,L.jsxs)(`button`,{disabled:O===0||S.isPending||!!M,onClick:N,onMouseDown:e=>e.preventDefault(),className:`flex items-center gap-2 rounded-md bg-fg px-3.5 py-1.5 text-[12.5px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:[S.isPending&&(0,L.jsx)(Xm,{size:13,className:`animate-spin`}),O<=1?`Start investigation`:`Start ${O} investigations`]})})]})]})})}function a3({label:e,disabled:t,onClick:n,children:r}){return(0,L.jsx)(`button`,{type:`button`,"aria-label":e,title:e,disabled:t,onClick:n,onMouseDown:e=>e.preventDefault(),className:`inline-flex h-[22px] w-[22px] items-center justify-center rounded-md border border-border/70 text-muted/70 outline-none transition-colors hover:border-border hover:bg-elevated hover:text-fg disabled:pointer-events-none disabled:opacity-30`,children:r})}function o3({value:e,onChange:t,options:n}){return(0,L.jsx)(`div`,{className:`inline-flex items-center gap-0.5 rounded-lg border border-border bg-panel-2 p-0.5`,children:n.map(n=>(0,L.jsx)(`button`,{onClick:()=>t(n.value),onMouseDown:e=>e.preventDefault(),className:`rounded-md px-3 py-1 text-[12px] font-medium outline-none transition-colors ${e===n.value?`bg-elevated text-fg shadow-sm shadow-black/20`:`text-muted hover:text-fg`}`,children:n.label},n.value))})}function s3({item:e}){let t=(e.state??`OPEN`).toUpperCase();return e.kind===`pr`?t===`MERGED`?(0,L.jsx)(Rm,{size:15,className:`shrink-0`,style:{color:UE.fgDone}}):t===`CLOSED`?(0,L.jsx)(zm,{size:15,className:`shrink-0`,style:{color:UE.fgDanger}}):e.isDraft?(0,L.jsx)(Bm,{size:15,className:`shrink-0`,style:{color:UE.fgNeutral}}):(0,L.jsx)(Vm,{size:15,className:`shrink-0`,style:{color:UE.fgSuccess}}):t===`CLOSED`?(0,L.jsx)(Cm,{size:15,className:`shrink-0`,style:{color:UE.fgDone}}):(0,L.jsx)(Tm,{size:15,className:`shrink-0`,style:{color:UE.fgSuccess}})}function c3({name:e,color:t}){let n=/^[0-9a-fA-F]{6}$/.test(t)?`#${t}`:void 0;return(0,L.jsx)(`span`,{className:`max-w-[130px] shrink-0 truncate rounded-full border px-1.5 py-px text-[9.5px] leading-[13px]`,style:n?{borderColor:`${n}59`,color:n,backgroundColor:`${n}14`}:void 0,title:e,children:e})}function l3({item:e,checked:t,onActivate:n}){let r=mE(e.createdAt)??``,i=[e.author,r?`opened ${r}`:``].filter(Boolean).join(` `);return(0,L.jsxs)(`div`,{role:`button`,tabIndex:0,"data-row-number":e.number,"aria-pressed":t,onClick:e=>n(e.shiftKey),onMouseDown:e=>{e.shiftKey&&e.preventDefault()},onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n(e.shiftKey))},className:`group flex w-full cursor-pointer items-start gap-2.5 border-b border-border/40 px-3 py-2.5 text-left outline-none transition-colors last:border-b-0 hover:bg-white/[0.03]`,children:[(0,L.jsx)(`span`,{className:`mt-px shrink-0`,children:(0,L.jsx)(u3,{checked:t})}),(0,L.jsx)(`span`,{className:`mt-px`,children:(0,L.jsx)(s3,{item:e})}),(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,onClick:e=>e.stopPropagation(),title:e.title,className:`min-w-0 truncate text-[13px] font-medium text-fg/90 hover:underline`,children:e.title}),e.labels.slice(0,4).map(e=>(0,L.jsx)(c3,{name:e.name,color:e.color},e.name))]}),(0,L.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-muted/55`,children:[(0,L.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,onClick:e=>e.stopPropagation(),className:`shrink-0 tabular-nums hover:text-muted hover:underline`,children:[`#`,e.number]}),i?(0,L.jsxs)(`span`,{className:`truncate`,children:[`· `,i]}):null]})]}),(0,L.jsxs)(`span`,{className:`mt-px flex shrink-0 items-center gap-2.5 text-[11.5px] text-muted/70`,children:[e.linkedPrs?(0,L.jsx)(p3,{prs:e.linkedPrs}):null,e.comments?(0,L.jsx)(m3,{icon:eh,n:e.comments,label:`comments`}):null,e.reactions?(0,L.jsx)(m3,{emoji:`👍`,n:e.reactions,label:`reactions`}):null]})]})}function u3({checked:e}){return(0,L.jsx)(`span`,{className:`inline-flex h-[15px] w-[15px] items-center justify-center rounded-[4px] border transition-colors ${e?`border-fg bg-fg`:`border-muted/45 group-hover:border-muted/80`}`,children:e&&(0,L.jsx)(gm,{size:11,strokeWidth:3,className:`text-bg`})})}var d3={octicon:`-0.1em`,stroke:`-0.112em`};function f3({size:e=12,className:t}){return(0,L.jsx)(`svg`,{viewBox:`0 0 16 16`,width:e,height:e,fill:`currentColor`,"aria-hidden":!0,className:t,style:{transform:`translateY(${d3.octicon})`},children:(0,L.jsx)(`path`,{d:`M1.5 3.25a2.25 2.25 0 1 1 3 2.122v5.256a2.251 2.251 0 1 1-1.5 0V5.372A2.25 2.25 0 0 1 1.5 3.25Zm5.677-.177L9.573.677A.25.25 0 0 1 10 .854V2.5h1A2.5 2.5 0 0 1 13.5 5v5.628a2.251 2.251 0 1 1-1.5 0V5a1 1 0 0 0-1-1h-1v1.646a.25.25 0 0 1-.427.177L7.177 3.427a.25.25 0 0 1 0-.354ZM3.75 2.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm0 9.5a.75.75 0 1 0 0 1.5.75.75 0 0 0 0-1.5Zm8.25.75a.75.75 0 1 0 1.5 0 .75.75 0 0 0-1.5 0Z`})})}function p3({prs:e}){let t=e.state.toUpperCase()===`MERGED`,n=e.count>1?`${e.count} linked pull requests — `:``,r=t?`#${e.number} merged`:e.isDraft?`#${e.number} open (draft)`:`#${e.number} open`;return(0,L.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,onClick:e=>e.stopPropagation(),title:`${n}${r}`,className:`inline-flex items-center gap-1 tabular-nums hover:text-fg/90`,children:[(0,L.jsx)(f3,{size:12}),e.count]})}function m3({icon:e,emoji:t,n,label:r}){return(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1 tabular-nums`,title:`${n} ${r}`,children:[t?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`text-[11px] leading-none`,children:t}):e?(0,L.jsx)(`span`,{className:`inline-flex`,style:{transform:`translateY(${d3.stroke})`},children:(0,L.jsx)(e,{size:12,strokeWidth:2})}):null,n]})}function h3(){return(0,L.jsx)(`div`,{className:`animate-pulse`,children:Array.from({length:6}).map((e,t)=>(0,L.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border/40 px-3 py-2.5 last:border-b-0`,children:[(0,L.jsx)(`span`,{className:`h-[15px] w-[15px] shrink-0 rounded-[4px] bg-muted/20`}),(0,L.jsx)(`span`,{className:`h-3 w-8 shrink-0 rounded bg-muted/20`}),(0,L.jsx)(`span`,{className:`h-3 flex-1 rounded bg-muted/15`,style:{maxWidth:`${55+t*7%35}%`}})]},t))})}function g3({children:e}){return(0,L.jsx)(`div`,{className:`flex h-full min-h-[240px] flex-col items-center justify-center gap-1.5`,children:e})}var _3=`default`;function v3(e){return e>=1e6?`${y3(e/1e6)}M`:e>=1e3?`${y3(e/1e3)}K`:String(e)}function y3(e){return Number.isInteger(e)?String(e):e.toFixed(2).replace(/0+$/,``).replace(/\.$/,``)}var b3=[{value:872e3,models:[]}];function x3(e,t){let n=e??[],r=n.find(e=>e.contextWindow!==void 0),i=r?`Model default (${v3(r.contextWindow)} on ${r.displayName})`:`Model default`,a=new Map;for(let e of n)e.maxContextWindow===void 0||e.contextWindow===void 0||e.maxContextWindow<=e.contextWindow||a.set(e.maxContextWindow,[...a.get(e.maxContextWindow)??[],e.displayName]);let o=a.size?[...a.entries()].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({value:e,models:t})):b3,s=[{value:_3,label:i}];for(let e of o){let t=o.length===1||e.models.length===0?`model maximum`:`${e.models.join(`, `)} maximum`;s.push({value:String(e.value),label:`${v3(e.value)} tokens (${t})`})}return t!==void 0&&!s.some(e=>e.value===String(t))&&s.push({value:String(t),label:`${v3(t)} tokens`}),s}var S3={permissionMode:`The permission mode new Claude Code threads launch with. Auto runs safe actions and asks you to approve the risky ones in the thread. Bypass launches the worker with --dangerously-skip-permissions: it never asks, so nothing waits on you and nothing is checked either. Takes effect on the next thread you dispatch; to change a thread that already exists, use the picker beside its model in the prompt box. Codex threads always run with full workspace access and are unaffected.`,promptCacheTtl:`Which prompt-cache tier a new Claude thread writes to. A 1-hour entry costs twice the input price to write, a 5-minute entry 1.25 times; the hour only pays off when the thread's cache actually survives that long. Measured 2026-09-03: cache writes were half of a day's spend and the entries were lost every 15 to 30 minutes regardless, so 5 minutes was the cheaper tier. Automatic leaves the choice to Claude Code, which picks 1 hour on a subscription. Takes effect on the next thread you dispatch and on a thread that resumes after its worker exited.`,autoCompactWindow:`How large a new Claude thread's conversation may grow, in tokens, before Claude Code compacts it. Frizz launches every Claude thread with the 1M context window, so without a ceiling a long thread keeps re-sending everything it has read on every turn; 500K halves that at the cost of an earlier summary. Takes effect on the next thread you dispatch and on a thread that resumes after its worker exited; a thread whose worker is already running keeps its current ceiling. A thread's context dial reads against the ceiling it was launched with, not the model's full window.`,codexContextWindow:`How much context a new Codex thread runs with, in tokens. The presets are the numbers in Codex's own model catalogue: the default model's stock window, and each larger window a listed model accepts (872K on GPT-5.6 and GPT-6; the model's 1M total minus the 128K it reserves for its reply). Codex compacts at 90% of whatever window the thread has, so a larger window is also a later compaction and a larger prompt re-sent on every turn. A model that does not accept the value keeps its own window (GPT-5.5 stays at 272K). Takes effect on the next thread you dispatch and on a thread Codex picks back up after a restart; a thread its app-server already holds keeps its current window. A thread's context dial reads the usable 95% of the window (828K for 872K).`,font:`Changes the interface reading font for this browser.`,localFileOpener:`Chooses how vetted local artifact links open. Markdown files open in Frizz's own reader (which carries an Open action that uses this setting), and image clicks always use the OS default viewer.`,density:`How much of a diff shows before you ask for it, in this browser. Compact collapses every diff to its header row (click one to open it); Comfortable shows them in full. Applies immediately.`,queueOrder:`Orders the Needs-you queue and the sidebar's rested threads by when each was last active. Oldest first (FIFO, default) surfaces the longest-waiting item first so you cycle through everything; Newest first (LIFO) keeps the most recently active on top. Applies immediately in this browser.`,notifications:`Shows a desktop notification when work needs attention while this window is hidden.`,projectRail:`Shows a permanent column of every project on this machine down the left edge. Off by default: Frizz's home is one board, and a standing list of the others is an easy way to leave the thread you were in. With it off, the home crumb in the status bar is the way back to the projects page.`};function C3(){return typeof Notification>`u`?`unsupported`:Notification.permission}var w3=500,T3=1600,E3=2e3,D3=6;function O3(){let[e,t]=(0,I.useState)(`idle`),n=(0,I.useRef)(null),r=(0,I.useRef)(void 0),i=(0,I.useRef)(Promise.resolve()),a=(0,I.useRef)(0),o=(0,I.useRef)(void 0),s=(0,I.useRef)(0),c=(0,I.useRef)(()=>{}),l=(0,I.useCallback)(()=>{r.current!==void 0&&window.clearTimeout(r.current),r.current=void 0;let e=n.current;e&&(n.current=null,a.current+=1,t(`saving`),i.current=i.current.then(()=>Y.settingsSet(e)).then(e=>{u7.setQueryData([`settingsGet`],e),--a.current,s.current=0,!(a.current>0||n.current)&&(t(`saved`),o.current!==void 0&&window.clearTimeout(o.current),o.current=window.setTimeout(()=>t(`idle`),T3))}).catch(i=>{--a.current,t(`error`),!(n.current||!ff(i)||s.current>=D3)&&(s.current+=1,n.current=e,r.current=window.setTimeout(c.current,E3))}))},[]);c.current=l;let u=(0,I.useCallback)((e,t=!1)=>{if(n.current=e,s.current=0,r.current!==void 0&&window.clearTimeout(r.current),r.current=void 0,!t)return l();r.current=window.setTimeout(l,w3)},[l]);return(0,I.useEffect)(()=>()=>{l(),o.current!==void 0&&window.clearTimeout(o.current)},[l]),{state:e,queue:u,flush:l}}function k3(){let e=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()}),[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(C3()),{state:a,queue:o,flush:s}=O3(),[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let e=requestAnimationFrame(()=>l(!0));return()=>cancelAnimationFrame(e)},[]),(0,I.useEffect)(()=>(fd(p),()=>fd(null)),[]),(0,I.useEffect)(()=>{e.data&&!t&&n(e.data)},[e.data,t]);let f=(0,I.useCallback)((e,t)=>{n(e),o(e,t?.debounce)},[o]);function p(){u||(s(),d(!0),l(!1),window.setTimeout(()=>X.showSettings=!1,Xp()?0:210))}async function m(e){if(t){if(e&&typeof Notification<`u`&&Notification.permission==="default"){let e=await Notification.requestPermission();i(e)}f({...t,notifications:e})}}return(0,L.jsx)(`div`,{className:`${Kp} z-50 flex justify-end ${c?`opacity-100`:`opacity-0`}`,onMouseDown:e=>e.target===e.currentTarget&&p(),children:(0,L.jsxs)(`div`,{className:`${qp} w-[560px] max-w-[94vw] ${c?`translate-x-0`:`translate-x-full`}`,children:[(0,L.jsx)(Th,{title:`Settings`,actions:(0,L.jsx)(A3,{state:a}),onClose:p}),t?(0,L.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-5 flex flex-col gap-6`,children:[(0,L.jsx)(M3,{label:`Font`,help:S3.font,children:(0,L.jsx)(U3,{value:t.font??`mono`,onChange:e=>f({...t,font:e})})}),(0,L.jsx)(M3,{label:`Project sidebar`,help:S3.projectRail,children:(0,L.jsx)(WX,{variant:`bordered`,value:t.projectRail?`shown`:`hidden`,onValueChange:e=>f({...t,projectRail:e===`shown`}),options:[{value:`hidden`,label:`Hidden`},{value:`shown`,label:`Always shown`}],indicatorPosition:`right`,ariaLabel:`Project sidebar`})}),(0,L.jsx)(M3,{label:`Local file links`,help:S3.localFileOpener,children:(0,L.jsx)(WX,{variant:`bordered`,value:t.localFileOpener??`system`,onValueChange:e=>f({...t,localFileOpener:e}),options:[{value:`system`,label:`System default`},{value:`cursor`,label:`Cursor`},{value:`vscode`,label:`VS Code`},{value:`finder`,label:`Reveal in Finder`},{value:`copy`,label:`Copy path`}],indicatorPosition:`right`,ariaLabel:`Local file link opener`})}),(0,L.jsx)(M3,{label:`Density`,help:S3.density,children:(0,L.jsx)(G3,{})}),(0,L.jsx)(M3,{label:`Queue order`,help:S3.queueOrder,children:(0,L.jsx)(K3,{})}),(0,L.jsxs)(M3,{label:`Desktop notifications`,help:S3.notifications,children:[(0,L.jsx)(W3,{value:t.notifications,onChange:m}),t.notifications&&(0,L.jsx)(q3,{perm:r})]}),(0,L.jsx)(L3,{draft:t,setDraft:f}),(0,L.jsx)(R3,{draft:t,setDraft:f}),(0,L.jsx)(z3,{draft:t,setDraft:f})]}):(0,L.jsx)(`div`,{className:`p-4 text-[13px] text-muted`,children:`Loading…`})]})})}function A3({state:e}){return e===`idle`?null:e===`error`?(0,L.jsx)(`span`,{className:`text-[11px] font-normal text-accent`,children:`Couldn't save`}):(0,L.jsx)(`span`,{className:`text-[11px] font-normal text-muted transition-opacity ${e===`saved`?`opacity-70`:`opacity-100`}`,children:e===`saving`?`Saving…`:`Saved`})}function j3({label:e,help:t}){return(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] uppercase tracking-wide text-muted`,children:[e,(0,L.jsx)(iM,{label:t,side:`right`,clickable:!0,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":`About ${e}`,className:`inline-flex size-4 items-center justify-center text-muted/60 hover:text-fg transition-colors`,children:(0,L.jsx)(Em,{size:12})})})]})}function M3({label:e,help:t,children:n}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(j3,{label:e,help:t}),n]})}var N3=[{token:`repo`,gloss:`repository`},{token:`n`,gloss:`number`},{token:`title`,gloss:`title`},{token:`url`,gloss:`link`},{token:`labels`,gloss:`labels`},{token:`body`,gloss:`description`}],P3=5e5,F3=[{value:`200000`,label:`200K tokens`},{value:`350000`,label:`350K tokens`},{value:`500000`,label:`500K tokens (default)`},{value:`750000`,label:`750K tokens`},{value:`1000000`,label:`1M tokens`}],I3=[{value:`auto`,label:`Automatic (default)`},{value:`5m`,label:`5 minutes`},{value:`1h`,label:`1 hour`}];function L3({draft:e,setDraft:t}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(B3,{label:`Claude`}),(0,L.jsx)(M3,{label:`Permissions`,help:S3.permissionMode,children:(0,L.jsx)(WX,{variant:`bordered`,value:e.permissionMode===`bypassPermissions`?`bypassPermissions`:`auto`,onValueChange:n=>t({...e,permissionMode:n}),options:tz,indicatorPosition:`right`,ariaLabel:`Claude permission mode`})}),(0,L.jsx)(M3,{label:`Compaction window`,help:S3.autoCompactWindow,children:(0,L.jsx)(WX,{variant:`bordered`,value:String(e.autoCompactWindow??P3),onValueChange:n=>t({...e,autoCompactWindow:Number(n)}),options:F3,indicatorPosition:`right`,ariaLabel:`Claude compaction window`})}),(0,L.jsx)(M3,{label:`Prompt cache tier`,help:S3.promptCacheTtl,children:(0,L.jsx)(WX,{variant:`bordered`,value:e.promptCacheTtl??`auto`,onValueChange:n=>t({...e,promptCacheTtl:n}),options:I3,indicatorPosition:`right`,ariaLabel:`Claude prompt cache tier`})})]})}function R3({draft:e,setDraft:t}){let n=nt({queryKey:[`codexModels`],queryFn:()=>Y.codexModels()}),r=e.codexContextWindow,i=r===void 0?_3:String(r),a=x3(n.data,r);return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(B3,{label:`Codex`}),(0,L.jsx)(M3,{label:`Context window`,help:S3.codexContextWindow,children:(0,L.jsx)(WX,{variant:`bordered`,value:i,onValueChange:n=>t({...e,codexContextWindow:n==="default"?void 0:Number(n)}),options:a,indicatorPosition:`right`,ariaLabel:`Codex context window`})})]})}function z3({draft:e,setDraft:t}){let n=nt({queryKey:[`githubPromptDefaults`],queryFn:()=>Y.githubPromptDefaults()});return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(B3,{label:`Prompts`}),n.data?(0,L.jsx)(H3,{label:`Issue and PR triage prompt`,help:`The prompt for every item dispatched from the GitHub picker, issues and PRs alike. The default has the worker read the whole thread, classify it, and branch — reproduce + fix-plan for a bug, a plan for a feature, an adversarial review for a PR.`,value:e.githubPrompt,fallback:n.data.prompt,onChange:(n,r)=>t({...e,githubPrompt:n},r)}):(0,L.jsx)(`div`,{className:`text-[12px] text-muted`,children:`Loading defaults…`})]})}function B3({label:e}){return(0,L.jsxs)(`div`,{className:`mt-4 mb-1 flex items-center gap-2.5 text-[11px] uppercase tracking-wide text-muted/70`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border/60`}),(0,L.jsx)(`span`,{className:`shrink-0`,children:e}),(0,L.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border/60`})]})}function V3(){let[e,t]=(0,I.useState)(!1);return(0,L.jsxs)(DV,{open:e,onOpenChange:t,children:[(0,L.jsx)(OV,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] transition-colors ${e?`text-accent`:`text-muted hover:text-accent`}`,children:`Tokens`})}),(0,L.jsxs)(AV,{side:`top`,align:`end`,className:`w-56 p-3`,children:[(0,L.jsx)(`div`,{className:`mb-2 text-[11px] font-medium text-fg`,children:`Substitution tokens`}),(0,L.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:N3.map(({token:e,gloss:t})=>(0,L.jsxs)(`li`,{className:`flex items-center justify-between gap-3 text-[11px]`,children:[(0,L.jsx)(`code`,{className:`font-mono-keep rounded border border-border bg-bg px-1 py-0.5 text-[10px] text-fg/80`,children:`{${e}}`}),(0,L.jsx)(`span`,{className:`text-muted/80`,children:t})]},e))})]})]})}function H3({label:e,help:t,value:n,fallback:r,onChange:i}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsx)(j3,{label:e,help:t}),(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[n!=null&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,className:`text-[11px] text-muted hover:text-accent transition-colors`,onClick:()=>i(void 0),children:`Reset to default`}),(0,L.jsx)(`span`,{"aria-hidden":!0,className:`text-[11px] text-muted/40`,children:`·`})]}),(0,L.jsx)(V3,{})]})]}),(0,L.jsx)(`textarea`,{value:n??r,onChange:e=>i(e.target.value===``?void 0:e.target.value,{debounce:!0}),rows:10,className:`input resize-none text-[12px] leading-relaxed font-mono-keep`,spellCheck:!1})]})}function U3({value:e,onChange:t}){return(0,L.jsx)(`div`,{className:`inline-flex w-fit rounded-md border border-border bg-bg p-0.5`,children:[{v:`mono`,label:`Mono`,cls:``},{v:`sans`,label:`Sans`,cls:``}].map(n=>(0,L.jsx)(`button`,{onClick:()=>t(n.v),className:`rounded px-3 py-1 text-[12px] transition-colors ${n.cls} ${e===n.v?`bg-fg text-bg`:`text-muted hover:text-fg`}`,children:n.label},n.v))})}function W3({value:e,onChange:t}){return(0,L.jsx)(`div`,{className:`inline-flex w-fit rounded-md border border-border bg-bg p-0.5`,children:[{v:!1,label:`Off`},{v:!0,label:`On`}].map(n=>(0,L.jsx)(`button`,{onClick:()=>t(n.v),className:`rounded px-3 py-1 text-[12px] transition-colors ${e===n.v?`bg-fg text-bg`:`text-muted hover:text-fg`}`,children:n.label},n.label))})}function G3(){let{compactDiffs:e}=Zt(yT);return(0,L.jsx)(`div`,{className:`inline-flex w-fit rounded-md border border-border bg-bg p-0.5`,children:[{v:!1,label:`Comfortable`},{v:!0,label:`Compact`}].map(t=>(0,L.jsx)(`button`,{onClick:()=>yT.compactDiffs=t.v,className:`rounded px-3 py-1 text-[12px] transition-colors ${e===t.v?`bg-fg text-bg`:`text-muted hover:text-fg`}`,children:t.label},t.label))})}function K3(){let{queueOrder:e}=Zt(yT);return(0,L.jsx)(`div`,{className:`inline-flex w-fit rounded-md border border-border bg-bg p-0.5`,children:[{v:`fifo`,label:`Oldest first`},{v:`lifo`,label:`Newest first`}].map(t=>(0,L.jsx)(`button`,{onClick:()=>yT.queueOrder=t.v,className:`rounded px-3 py-1 text-[12px] transition-colors ${e===t.v?`bg-fg text-bg`:`text-muted hover:text-fg`}`,children:t.label},t.v))})}function q3({perm:e}){return e===`denied`?(0,L.jsx)(Y3,{}):(0,L.jsx)(`span`,{className:`text-[11px] text-muted/70`,children:{granted:`Browser permission granted — notifications fire when the window is hidden.`,default:`Browser permission not yet granted — notifications won't fire until you allow them.`,unsupported:`This browser does not support desktop notifications.`}[e]})}function J3(){let e=typeof navigator<`u`?navigator.userAgent:``;return/Firefox\//.test(e)?`firefox`:/Edg\//.test(e)?`edge`:/OPR\/|Brave\//.test(e)?`other`:/Chrome\//.test(e)?`chrome`:/Safari\//.test(e)?`safari`:`other`}function Y3(){let e=(0,I.useMemo)(J3,[]),t=typeof location<`u`?location.origin:``,n=`${e===`edge`?`edge`:`chrome`}://settings/content/siteDetails?site=${encodeURIComponent(t)}`;return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1 text-[11px] text-muted/70`,children:[(0,L.jsx)(`span`,{children:`Notifications are blocked for this site. Re-enable them in your browser, then reload.`}),e===`chrome`||e===`edge`?(0,L.jsx)(Z3,{url:n,hint:`Paste this into a new tab, set Notifications → Allow:`}):e===`safari`?(0,L.jsxs)(`span`,{children:[`Safari → Settings → Websites → Notifications → allow `,X3(t),`, then reload.`]}):e===`firefox`?(0,L.jsx)(`span`,{children:`Firefox → Settings → Privacy & Security → Permissions → Notifications → Settings → allow this site.`}):(0,L.jsx)(`span`,{children:`Open this site's notification permission in your browser's settings and set it to Allow.`})]})}function X3(e){try{return new URL(e).host}catch{return e}}function Z3({url:e,hint:t}){let[n,r]=(0,I.useState)(!1);async function i(){try{await WR(e),r(!0),window.setTimeout(()=>r(!1),1500)}catch{}}return(0,L.jsxs)(`span`,{className:`flex w-full flex-col gap-1`,children:[(0,L.jsx)(`span`,{children:t}),(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsx)(`code`,{className:`min-w-0 flex-1 font-mono-keep select-all rounded border border-border bg-bg px-1.5 py-0.5 text-[10.5px] text-fg/90 break-all`,children:e}),(0,L.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`Copy address`,className:`shrink-0 rounded border border-border p-1 text-muted hover:bg-panel-2 hover:text-fg transition-colors`,children:n?(0,L.jsx)(gm,{size:11,className:`text-live`}):(0,L.jsx)(Am,{size:11})})]})]})}var Q3=1,$3=.9,e6=.8,t6=.17,n6=.1,r6=.999,i6=.9999,a6=.99,o6=/[\\\/_+.#"@\[\(\{&]/,s6=/[\\\/_+.#"@\[\(\{&]/g,c6=/[\s-]/,l6=/[\s-]/g;function u6(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Q3:a6;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=u6(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Q3:o6.test(e.charAt(l-1))?(d*=e6,p=e.slice(i,l-1).match(s6),p&&i>0&&(d*=r6**+p.length)):c6.test(e.charAt(l-1))?(d*=$3,m=e.slice(i,l-1).match(l6),m&&i>0&&(d*=r6**+m.length)):(d*=t6,i>0&&(d*=r6**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=i6)),(d<n6&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=u6(e,t,n,r,l+1,a+2,o),f*n6>d&&(d=f*n6)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function d6(e){return e.toLowerCase().replace(l6,` `)}function f6(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,u6(e,t,d6(e),d6(t),0,0,{})}var p6=`[cmdk-group=""]`,m6=`[cmdk-group-items=""]`,h6=`[cmdk-group-heading=""]`,g6=`[cmdk-item=""]`,_6=`${g6}:not([aria-disabled="true"])`,v6=`cmdk-item-select`,y6=`data-value`,b6=(e,t,n)=>f6(e,t,n),x6=I.createContext(void 0),S6=()=>I.useContext(x6),C6=I.createContext(void 0),w6=()=>I.useContext(C6),T6=I.createContext(void 0),E6=I.forwardRef((e,t)=>{let n=B6(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=B6(()=>new Set),i=B6(()=>new Map),a=B6(()=>new Map),o=B6(()=>new Set),s=R6(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=uO(),y=uO(),b=uO(),x=I.useRef(null),S=U6();z6(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),z6(()=>{S(6,k)},[]);let C=I.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=I.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??b6;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(m6);t?t.appendChild(e.parentElement===t?e:e.closest(`${m6} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${m6} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${p6}[${y6}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(y6);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(p6)?.querySelector(h6))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${g6}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(_6)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(y6))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(y6))}function P(e){let t=A()?.closest(p6),n;for(;t&&!n;)t=e>0?I6(t,p6):L6(t,p6),n=t?.querySelector(_6);n?C.setState(`value`,n.getAttribute(y6)):N(e)}let ee=()=>M(j().length-1),F=e=>{e.preventDefault(),e.metaKey?ee():e.altKey?P(1):N(1)},te=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return I.createElement(VD.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&F(e);break;case`ArrowDown`:F(e);break;case`p`:case`k`:g&&e.ctrlKey&&te(e);break;case`ArrowUp`:te(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),ee();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(v6);t.dispatchEvent(e)}}}}},I.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:K6},c),G6(e,e=>I.createElement(C6.Provider,{value:C},I.createElement(x6.Provider,{value:w},e))))}),D6=I.forwardRef((e,t)=>{let n=uO(),r=I.useRef(null),i=I.useContext(T6),a=S6(),o=R6(e),s=o.current?.forceMount??i?.forceMount;z6(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=H6(n,r,[e.value,e.children,r],e.keywords),l=w6(),u=V6(e=>e.value&&e.value===c.current),d=V6(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);I.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(v6,f),()=>t.removeEventListener(v6,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return I.createElement(VD.div,{ref:wD(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),O6=I.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=uO(),s=I.useRef(null),c=I.useRef(null),l=uO(),u=S6(),d=V6(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);z6(()=>u.group(o),[]),H6(o,s,[e.value,e.heading,c]);let f=I.useMemo(()=>({id:o,forceMount:i}),[i]);return I.createElement(VD.div,{ref:wD(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&I.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),G6(e,e=>I.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},I.createElement(T6.Provider,{value:f},e))))}),k6=I.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=I.useRef(null),a=V6(e=>!e.search);return!n&&!a?null:I.createElement(VD.div,{ref:wD(i,t),...r,"cmdk-separator":``,role:`separator`})}),A6=I.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=w6(),o=V6(e=>e.search),s=V6(e=>e.selectedItemId),c=S6();return I.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),I.createElement(VD.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),j6=I.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=I.useRef(null),o=I.useRef(null),s=V6(e=>e.selectedItemId),c=S6();return I.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),I.createElement(VD.div,{ref:wD(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},G6(e,e=>I.createElement(`div`,{ref:wD(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),M6=I.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return I.createElement(eL,{open:n,onOpenChange:r},I.createElement(oL,{container:o},I.createElement(cL,{"cmdk-overlay":``,className:i}),I.createElement(fL,{"aria-label":e.label,"cmdk-dialog":``,className:a},I.createElement(E6,{ref:t,...s}))))}),N6=I.forwardRef((e,t)=>V6(e=>e.filtered.count===0)?I.createElement(VD.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),P6=I.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return I.createElement(VD.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},G6(e,e=>I.createElement(`div`,{"aria-hidden":!0},e)))}),F6=Object.assign(E6,{List:j6,Item:D6,Input:A6,Group:O6,Separator:k6,Dialog:M6,Empty:N6,Loading:P6});function I6(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function L6(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function R6(e){let t=I.useRef(e);return z6(()=>{t.current=e}),t}var z6=typeof window>`u`?I.useEffect:I.useLayoutEffect;function B6(e){let t=I.useRef();return t.current===void 0&&(t.current=e()),t}function V6(e){let t=w6(),n=()=>e(t.snapshot());return I.useSyncExternalStore(t.subscribe,n,n)}function H6(e,t,n,r=[]){let i=I.useRef(),a=S6();return z6(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(y6,s),i.current=s}),i}var U6=()=>{let[e,t]=I.useState(),n=B6(()=>new Map);return z6(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function W6(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function G6({asChild:e,children:t},n){return e&&I.isValidElement(t)?I.cloneElement(W6(t),{ref:t.ref},n(t.props.children)):n(t)}var K6={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function q6(){let e=Zt(X),t=qC(),[n,r]=(0,I.useState)(``);if((0,I.useEffect)(()=>{e.showPalette&&r(``)},[e.showPalette]),!e.showPalette)return null;let i=FT(YC(t?.threads??[])),a=e.drawers.length?[...e.drawers].reverse().find(e=>e.kind===`thread`)?.slug:void 0,o=t?.threads.find(e=>e.id===a);function s(){X.showPalette=!1}function c(e){e(),s()}function l(e){bp(e)}return(0,L.jsx)(`div`,{className:`fixed inset-0 z-[60] flex items-start justify-center bg-black/50 pt-[12vh]`,onMouseDown:e=>e.target===e.currentTarget&&s(),children:(0,L.jsxs)(F6,{label:`Command palette`,className:`w-[560px] max-w-[92vw] rounded-lg border border-border bg-panel shadow-2xl overflow-hidden`,filter:(e,t,n)=>+!!e.toLowerCase().includes(t.toLowerCase()),children:[(0,L.jsx)(F6.Input,{autoFocus:!0,value:n,onValueChange:r,placeholder:`Jump to a thread or run a command…`,className:`w-full px-4 h-12 bg-transparent outline-none border-b border-border text-sm placeholder:text-muted`}),(0,L.jsxs)(F6.List,{className:`max-h-[52vh] overflow-y-auto py-1.5`,children:[(0,L.jsx)(F6.Empty,{className:`px-4 py-6 text-center text-sm text-muted`,children:`No matches.`}),(0,L.jsxs)(F6.Group,{heading:`Actions`,className:`cmdk-group`,children:[(0,L.jsx)(J6,{value:`new thread create home`,onSelect:()=>c(()=>cp()),children:`New thread`}),(0,L.jsx)(J6,{value:`queue todos inbox pending`,onSelect:()=>c(()=>{zp(X.drawers.map(e=>e.id)),X.view=`todos`}),children:`Queue`}),(0,L.jsx)(J6,{value:`open settings preferences`,onSelect:()=>c(()=>X.showSettings=!0),children:`Open settings`}),o&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(J6,{value:`open details drawer doc ${CT(o)}`,onSelect:()=>c(()=>{let e=Bp();e&&_p(`doc`,e)}),children:`Open thread details`}),(0,L.jsxs)(J6,{value:`mark complete done ${CT(o)}`,onSelect:()=>c(()=>Y.markComplete({slug:o.id}).catch(()=>{})),children:[`Mark “`,CT(o),`” complete`]}),(0,L.jsxs)(J6,{value:`mark read ${CT(o)}`,onSelect:()=>c(()=>Y.markRead({slug:o.id}).catch(()=>{})),children:[`Mark “`,CT(o),`” read`]})]})]}),i.length>0&&(0,L.jsx)(F6.Group,{heading:`Threads`,className:`cmdk-group`,children:i.map(e=>(0,L.jsxs)(J6,{value:`${CT(e)} ${e.id}`,onSelect:()=>c(()=>l(e.id)),children:[(0,L.jsx)(`span`,{className:`truncate`,children:CT(e)}),(0,L.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted/70`,children:e.id})]},e.id))})]})]})})}function J6({value:e,onSelect:t,children:n}){return(0,L.jsx)(F6.Item,{value:e,onSelect:t,className:`mx-1.5 px-2.5 py-1.5 rounded flex items-center gap-2 text-sm cursor-pointer data-[selected=true]:bg-panel-2 data-[selected=true]:text-fg text-muted`,children:n})}var Y6=`Updating and restarting Frizz`,X6=`This may take a moment while the new build is being prepared. All of your threads will continue running normally.`,Z6=`Frizz did not come back`;function Q6(e){return`${e?`Nothing has answered for ${e}.`:`Nothing is answering.`} Restart Frizz from the terminal with npx frizz (or frizz, if it is installed globally). This page reconnects on its own once the board is back.`}function $6(e){if(e.key===`Tab`||e.key===`Enter`)return!0;if(e.metaKey||e.ctrlKey){let t=e.key.toLowerCase();if(t===`k`||t===`i`)return!0}return!1}function e8({open:e,message:t,stalled:n=!1,silentFor:r}){let i=(0,I.useRef)(null),[a,o]=(0,I.useState)(!1),s=e&&!n;if((0,I.useEffect)(()=>{n||o(!1)},[n]),(0,I.useEffect)(()=>{if(!s)return;let e=document.activeElement;e instanceof HTMLElement&&e.blur(),i.current?.focus({preventScroll:!0});let t=e=>{$6(e)&&(e.preventDefault(),e.stopImmediatePropagation())};return window.addEventListener(`keydown`,t,{capture:!0}),()=>window.removeEventListener(`keydown`,t,{capture:!0})},[s]),!e)return null;if(n)return a?null:(0,L.jsx)(`div`,{className:`pointer-events-none fixed inset-x-0 top-6 z-[300] flex justify-center px-4`,children:(0,L.jsxs)(`div`,{role:`alert`,className:`pointer-events-auto w-[min(26rem,calc(100vw-2rem))] rounded-2xl border border-red-500/45 bg-elevated p-5 text-left shadow-2xl shadow-black/60`,children:[(0,L.jsxs)(`div`,{className:`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)(`h2`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:Z6}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,onClick:()=>o(!0),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`,{"aria-live":`polite`,className:`mt-2.5 text-[12px] leading-relaxed text-muted`,children:Q6(r)})]})});let c=t?.trim()?t.trim():null;return(0,L.jsx)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":Y6,className:`fixed inset-0 z-[300] flex items-center justify-center bg-black/55 px-4 backdrop-blur-md backdrop-saturate-150`,children:(0,L.jsxs)(`div`,{ref:i,tabIndex:-1,className:`w-[min(26rem,calc(100vw-2rem))] rounded-2xl border border-border-strong bg-elevated p-6 text-center shadow-2xl shadow-black/60 outline-none`,children:[(0,L.jsx)(`span`,{className:`mx-auto flex h-11 w-11 items-center justify-center rounded-full bg-fg/10 text-fg`,children:(0,L.jsx)(lh,{size:20,strokeWidth:2.25,className:`animate-spin`,"aria-hidden":`true`})}),(0,L.jsx)(`h2`,{className:`mt-4 text-[15px] font-semibold tracking-[-0.01em] text-fg`,children:Y6}),(0,L.jsx)(`p`,{className:`mt-2 text-[12.5px] leading-relaxed text-muted`,children:X6}),c&&(0,L.jsx)(`p`,{"aria-live":`polite`,className:`mt-2 text-[11.5px] leading-relaxed text-muted/80`,children:c})]})})}var t8=!1;function n8(){t8||(t8=!0,Z("Sign in to the GitHub CLI (`gh auth login`) to dispatch from issues/PRs.",{duration:6e3}))}function r8(){let e=Zt(X),t=(0,I.useRef)({projectDir:null,hasBeenVisible:!1});(0,I.useEffect)(()=>{Y.board().then(Up).catch(()=>{})},[]);let n=ny();(0,I.useEffect)(()=>xw((e,t)=>n(e,t)),[n]);let{data:r,dataUpdatedAt:i}=vH(),a=(0,I.useRef)(null),[o,s]=(0,I.useState)(eH),c=(0,I.useRef)(null),l=(0,I.useRef)(!1);(0,I.useEffect)(()=>{let e=r;if(e){let t=rH({state:X.controlPlaneState,message:X.controlPlaneMessage,attempt:X.controlPlaneRestartAttempt},e);X.controlPlaneState=t.state,X.controlPlaneMessage=t.message,X.controlPlaneRestartAttempt=t.attempt,c.current===null&&(c.current=ZV(e))}if(s(t=>tH(t,{restarting:X.controlPlaneState===`restarting`,answered:e!=null,at:Date.now()})),!e||l.current)return;let t=sessionStorage.getItem(qV);if(aH({state:X.controlPlaneState,message:X.controlPlaneMessage,attempt:X.controlPlaneRestartAttempt},e)){if(t){sessionStorage.removeItem(qV),sessionStorage.removeItem(JV),l.current=!0,window.location.replace(t);return}if(QV(c.current,e)){l.current=!0,window.location.reload();return}}if(e.state===`failed`&&t){let t=sessionStorage.getItem(`frizz:update-restart-from-version`)??void 0;sessionStorage.removeItem(qV),sessionStorage.removeItem(JV),a.current!==e.message&&(a.current=e.message??`Update & Restart failed`,Z(`Update & Restart failed — ${XV(YV(t,e)).summary}`,{duration:7e3}))}},[r,i]);let u=e.drawers.length>0||e.showSettings||e.showNewThread||e.showGithubPicker||e.showPalette;(0,I.useEffect)(()=>{if(!u)return;let e=window.scrollY,t=document.body;return wd(),t.style.position=`fixed`,t.style.top=`-${e}px`,t.style.left=`0`,t.style.right=`0`,t.style.width=`100%`,()=>{t.style.position=``,t.style.top=``,t.style.left=``,t.style.right=``,t.style.width=``,window.scrollTo(0,wd()??e)}},[u]);let d=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()});(0,I.useEffect)(()=>{X.notificationsEnabled=d.data?.notifications??!1},[d.data?.notifications]);let f=vR();(0,I.useEffect)(()=>{f.data?.inRepo&&!f.data.authed&&n8()},[f.data?.inRepo,f.data?.authed]),(0,I.useEffect)(()=>{function e(e){if(e.target instanceof Element&&e.target.closest(`.xterm`)||!(e.metaKey||e.ctrlKey))return;let t=e.key.toLowerCase();if(t===`k`)e.preventDefault(),X.showPalette=!X.showPalette;else if(t===`i`){let t=Ip(),n=Bp();t?.kind===`doc`?(e.preventDefault(),_d(t.id)||X.drawers.pop()):n&&(e.preventDefault(),_p(`doc`,n))}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let p=qC(),m=VW();(0,I.useEffect)(()=>{xp()},[p,e.routeThreadSlug]),t.current=Sw(t.current,p);let h=p!==null&&t.current.hasBeenVisible,g=p===null&&ww(Ad()),_=t.current.hasBeenVisible;(0,I.useEffect)(()=>{p!==null&&Tw(Ad(),_)},[p,_]);let v=p?.projectLabel??p?.projectName;return(0,I.useEffect)(()=>{let e=window.matchMedia?.(`(display-mode: standalone)`).matches;document.title=e?v??`Frizz`:v?`${v} — Frizz`:`Frizz`},[v]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(e8,{open:e.controlPlaneState===`restarting`,message:e.controlPlaneMessage,stalled:o.stalled,silentFor:o.silentSince===null?void 0:IE(o.silentForMs)}),(0,L.jsxs)(`div`,{inert:e.controlPlaneState===`restarting`&&!o.stalled,className:`relative min-h-screen bg-bg text-fg text-sm`,children:[m?(0,L.jsx)(FW,{}):(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(`div`,{className:`flex min-h-screen justify-center gap-[clamp(28px,3.4vw,52px)] px-5 max-[800px]:flex-col max-[800px]:justify-start max-[800px]:gap-0 max-[800px]:px-3`,children:[h&&(0,L.jsx)(Dh,{label:`the sidebar`,children:(0,L.jsx)(IU,{})}),g&&(0,L.jsx)(`aside`,{"aria-hidden":!0,className:`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`,"data-sidebar-reserved":!0}),(0,L.jsx)(`main`,{id:`workpane`,className:`w-[720px] max-w-[62vw] min-w-0 flex flex-col py-5 max-[800px]:w-full max-[800px]:max-w-none ${e.view===`todos`||!p?`min-h-screen`:``} ${e.view===`todos`?``:`rounded-lg border border-border bg-panel`}`,children:p?(0,L.jsxs)(Dh,{label:`the queue`,resetKeys:[e.view],children:[e.view.startsWith(`status:`)&&(0,L.jsx)(vW,{status:e.view.slice(7)}),e.view===`todos`&&(0,L.jsx)(K4,{})]}):(0,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,L.jsx)(`span`,{className:`block h-5 w-5 rounded-full border-2 border-muted/50 border-t-transparent animate-spin`})})})]})}),(0,L.jsx)(D4,{}),e.showSettings&&(0,L.jsx)(k3,{}),e.showNewThread&&(0,L.jsx)(Nz,{onClose:()=>{X.showNewThread=!1}}),e.showGithubPicker&&(0,L.jsx)(i3,{onClose:up}),(0,L.jsx)(q6,{})]})]})}function i8(e,t,n){let r=[...e];if(t<0||t>=r.length||n<0||n>=r.length||t===n)return r;let[i]=r.splice(t,1);return r.splice(n,0,i),r}function a8(e,t,n,r=48){let i=Math.round(t/r);return Math.max(0,Math.min(n-1,e+i))}function o8(e,t,n,r=48){return e===t?0:n>t&&e>t&&e<=n?-r:n<t&&e>=n&&e<t?r:0}function s8(e,t,n=44,r=14){let i=t.top+n-e;if(i>0)return-Math.min(r,i/n*r);let a=e-(t.bottom-n);return a>0?Math.min(r,a/n*r):0}var c8=`w-[57px]`,l8=`max-[800px]:pl-0 pl-[57px]`;function u8(e){let t=0;for(let n=0;n<e.length;n++)t=(t*31+e.charCodeAt(n))%360;return t}function d8(e){let t=e.split(/[\s\-_./]+/u).filter(Boolean);return t.length===0?`?`:t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[1][0]).toUpperCase()}function f8(e){let t=e.iconVersion?`&v=${encodeURIComponent(e.iconVersion)}`:``;return`/_frizz/project-icon?id=${encodeURIComponent(e.id)}${t}`}function p8({project:e,size:t}){let[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(!1),o=u8(e.id),s=e.iconStatus!==`none`,[c,l]=(0,I.useState)(!1),u=!s||c;return(0,L.jsxs)(`span`,{className:`relative block overflow-hidden rounded-[30%] bg-elevated`,style:{width:t,height:t,background:s&&!c?void 0:`hsl(${o} 32% 24%)`},children:[u&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`absolute inset-0 flex items-center justify-center font-semibold leading-none`,style:{fontSize:t*.4,color:`hsl(${o} 55% 78%)`},children:(0,L.jsx)(`span`,{style:{textBox:`trim-both cap alphabetic`},children:d8(e.name)})}),s&&!c&&(0,L.jsx)(`img`,{src:f8(e),alt:``,width:t,height:t,loading:`eager`,decoding:`async`,onLoad:e=>{let t=e.currentTarget;t.naturalWidth>0&&t.naturalHeight>0&&a(Math.abs(t.naturalWidth/t.naturalHeight-1)<=.05),r(!0)},onError:()=>l(!0),className:`relative h-full w-full transition-opacity ${i?`object-cover`:`object-contain p-[6%]`} ${n?`opacity-100`:`opacity-0`}`})]})}var m8=40;function h8({project:e,current:t,count:n,index:r,drag:i,onPointerDown:a,onKeyDown:o}){let s=i?.fromIndex===r,c=i?s?i.deltaY:o8(r,i.fromIndex,i.toIndex):0;return(0,L.jsx)(iM,{side:`right`,disabled:i!==null,label:e.stale?`${e.name} — directory is missing`:n?`${e.name} — ${n} in the queue`:e.name,children:(0,L.jsxs)(Ab,{to:jd(e.slug),"aria-current":t?`page`:void 0,"aria-grabbed":s||void 0,onPointerDown:e=>a(e,r),onKeyDown:e=>o(e,r),onClick:e=>{(i||y8())&&e.preventDefault()},onDragStart:e=>e.preventDefault(),className:`group relative flex h-10 w-full items-center justify-center outline-none ${s?`z-10 cursor-grabbing`:``}`,style:{transform:c?`translateY(${c}px)`:void 0,transition:s?`none`:`transform 160ms ease`},children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:`absolute left-0 w-[3px] rounded-r-full bg-fg transition-all duration-150 ${t?`h-7 opacity-100`:`h-2.5 opacity-0 group-hover:opacity-60`}`}),(0,L.jsx)(`span`,{className:`rounded-[30%] transition-[transform,opacity,box-shadow] duration-150 group-focus-visible:ring-1 group-focus-visible:ring-fg/60 ${s?`scale-[1.12] opacity-100 shadow-lg shadow-black/50`:`group-hover:scale-[1.06] ${t?``:`opacity-75 group-hover:opacity-100`}`} ${e.stale?`grayscale`:``}`,children:(0,L.jsx)(p8,{project:e,size:m8})}),n?(0,L.jsx)(`span`,{"aria-label":`${n} in the queue`,"data-rail-queue-count":n,className:`pointer-events-none absolute -bottom-[5px] right-[3px] flex h-[16px] min-w-[16px] items-center justify-center rounded-full border-[1.5px] border-bg bg-accent px-[3.5px] text-[10px] font-semibold leading-none proportional-nums text-bg`,children:(0,L.jsx)(`span`,{style:{textBox:`trim-both cap alphabetic`},children:n})}):null]})})}function g8({project:e,children:t}){let n=(0,I.useRef)(null),r=Ve(),i=()=>r.invalidateQueries({queryKey:[`projectsList`]}),a=e=>Z(e instanceof Error?e.message:String(e),{duration:7e3}),o=it({mutationFn:async t=>{let n=new Uint8Array(await t.arrayBuffer()),r=``;for(let e=0;e<n.length;e+=8192)r+=String.fromCharCode(...n.subarray(e,e+8192));return Y.projectIconSet({id:e.id,name:t.name,data:btoa(r)})},onSuccess:()=>void i(),onError:a}),s=it({mutationFn:()=>Y.projectIconClear({id:e.id}),onSuccess:()=>void i(),onError:a}),c=it({mutationFn:()=>Y.projectIconPick({id:e.id}),onSuccess:e=>{if(e.kind!==`cancelled`){if(e.kind===`unavailable`){n.current?.click();return}i()}},onError:()=>n.current?.click()}),l=`cursor-default rounded px-2 py-1.5 text-[12.5px] text-fg outline-none data-[highlighted]:bg-panel-2`;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`input`,{ref:n,type:`file`,accept:ld.map(e=>`.${e}`).join(`,`),className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&o.mutate(t)}}),(0,L.jsxs)(MI,{children:[(0,L.jsx)(NI,{asChild:!0,children:t}),(0,L.jsx)(PI,{children:(0,L.jsxs)(FI,{align:`start`,sideOffset:6,className:`z-[220] min-w-[190px] rounded-lg border border-border bg-panel p-1 shadow-xl shadow-black/40`,children:[(0,L.jsx)(RI,{className:l,onSelect:()=>c.mutate(),children:o.isPending?`Uploading…`:`Choose an icon…`}),(0,L.jsx)(RI,{className:l,onSelect:()=>s.mutate(),children:e.iconIsCustom?`Use the detected icon`:`Look for an icon again`})]})})]})]})}var _8=4,v8=0;function y8(){return Date.now()-v8<250}function b8(e,t){let n=nt({queryKey:[`projectsQueueCounts`],queryFn:()=>Y.projectsQueueCounts(),refetchInterval:5e3}),r=Zt(X).board,i=e!==void 0&&r?YC(r.threads).filter(RT).length:void 0,a=e===void 0?void 0:t.find(t=>t.slug===e)?.id;return e=>e.id===a&&i!==void 0?i:n.data?.[e.id]}function x8(){let e=Ve(),{data:t}=nt({queryKey:[`projectsList`],queryFn:()=>Y.projectsList()}),n=Ad(),[r,i]=(0,I.useState)(!1),a=ny(),[o,s]=(0,I.useState)(null),[c,l]=(0,I.useState)(null),u=(0,I.useRef)(null),d=it({mutationFn:()=>Y.projectPick({}),onSuccess:e=>{e.kind===`picked`?a(jd(e.project.slug)):e.kind===`unavailable`&&a(`/`)},onSettled:()=>i(!1)}),f=it({mutationFn:e=>Y.projectsReorder({ids:e}),onSuccess:async()=>{await e.invalidateQueries({queryKey:[`projectsList`]}),l(null)},onError:()=>l(null)}),p=c??t??[],m=b8(n,p),[h,g]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let e=u.current;if(!e)return;let t=()=>g(e.scrollTop+e.clientHeight<e.scrollHeight-1);t(),e.addEventListener(`scroll`,t,{passive:!0});let n=new ResizeObserver(t);return n.observe(e),window.addEventListener(`resize`,t),()=>{e.removeEventListener(`scroll`,t),n.disconnect(),window.removeEventListener(`resize`,t)}},[p.length]);let _=(0,I.useCallback)((e,t)=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let n=e.currentTarget,r=e.clientY,i=p,a=!1,o=null,c=0,d=e=>{let n=u.current,a=0;if(n){let t=s8(e,n.getBoundingClientRect());if(t){let e=n.scrollTop;n.scrollTop+=t,a=n.scrollTop-e}}m+=a;let c=e-r+m;o={id:i[t].id,fromIndex:t,toIndex:a8(t,c,i.length),deltaY:c},s(o)},m=0,h=e=>{if(!a){if(Math.abs(e.clientY-r)<_8)return;a=!0,n.setPointerCapture(e.pointerId)}e.preventDefault();let t=e.clientY;cancelAnimationFrame(c);let i=()=>{d(t),u.current&&s8(t,u.current.getBoundingClientRect())&&(c=requestAnimationFrame(i))};c=requestAnimationFrame(i)},g=()=>{if(cancelAnimationFrame(c),window.removeEventListener(`pointermove`,h),window.removeEventListener(`pointerup`,g),window.removeEventListener(`pointercancel`,g),s(null),!a||!o)return;v8=Date.now();let e=i8(i,o.fromIndex,o.toIndex);o.fromIndex!==o.toIndex&&(l(e),f.mutate(e.map(e=>e.id)))};window.addEventListener(`pointermove`,h,{passive:!1}),window.addEventListener(`pointerup`,g),window.addEventListener(`pointercancel`,g)},[p,f]),v=(0,I.useCallback)((e,t)=>{if(!e.altKey||e.key!==`ArrowUp`&&e.key!==`ArrowDown`)return;let n=t+(e.key===`ArrowUp`?-1:1);if(n<0||n>=p.length)return;e.preventDefault();let r=i8(p,t,n);l(r),f.mutate(r.map(e=>e.id)),requestAnimationFrame(()=>{u.current?.querySelectorAll(`a`)[n]?.focus()})},[p,f]);return(0,L.jsxs)(`nav`,{"aria-label":`Projects`,className:`fixed inset-y-0 left-0 z-[60] flex flex-col items-center border-r border-border bg-panel/60 py-3 max-[800px]:hidden ${c8}`,children:[(0,L.jsx)(iM,{side:`right`,label:`All projects`,children:(0,L.jsx)(Ab,{to:`/`,"aria-label":`All projects`,"aria-current":n?void 0:`page`,className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg text-muted/70 outline-none transition-colors hover:bg-elevated hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:(0,L.jsx)(Wm,{size:17})})}),(0,L.jsx)(`hr`,{className:`my-2.5 w-6 shrink-0 border-0 border-t border-border`}),(0,L.jsx)(`div`,{ref:u,"data-overflowing":h||void 0,className:`frizz-rail-scroll flex w-full min-h-0 flex-1 flex-col items-center gap-2 overflow-y-auto pb-1.5`,children:p.map((e,t)=>(0,L.jsx)(h8,{project:e,index:t,current:e.slug===n,count:m(e),drag:o,onPointerDown:_,onKeyDown:v},e.id))}),(0,L.jsx)(iM,{side:`right`,label:`Add a project`,children:(0,L.jsx)(`button`,{type:`button`,disabled:r,onClick:()=>{i(!0),d.mutate()},"aria-label":`Add a project`,className:`mt-3 flex h-10 w-10 shrink-0 items-center justify-center rounded-[30%] border-[1.5px] border-dotted border-border-strong text-muted/80 outline-none transition-colors hover:border-accent hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60 disabled:opacity-50`,children:(0,L.jsx)(ch,{size:16})})})]})}var S8=76;function C8(e,t){return t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}var w8=`flex flex-col gap-1 rounded-lg border px-4 py-3 outline-none transition-colors focus-visible:ring-1 focus-visible:ring-fg/60`,T8=`max-[700px]:rounded-none max-[700px]:border-x-0 max-[700px]:border-t-0 max-[700px]:border-b-border/70 max-[700px]:bg-transparent max-[700px]:py-3.5`,E8=38;function D8({project:e,home:t}){let n=lE(e.lastOpenedAt),[r,i]=(0,I.useState)(!1);return(0,L.jsxs)(`div`,{className:`group/card relative`,children:[(0,L.jsxs)(Ab,{to:jd(e.slug),className:`${w8} ${T8} flex-row items-center gap-3 border-border bg-panel pr-10 group-hover/card:border-border-strong group-hover/card:bg-panel-2 ${e.stale?`opacity-60`:``}`,children:[(0,L.jsx)(`span`,{className:`shrink-0 ${e.stale?`grayscale`:``}`,children:(0,L.jsx)(p8,{project:e,size:E8})}),(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium text-fg`,children:e.name}),e.slug===e.name?null:(0,L.jsxs)(`span`,{className:`max-w-[45%] shrink-0 truncate font-mono text-[11px] text-muted/70`,children:[`/`,e.slug]})]}),(0,L.jsx)(`span`,{className:`truncate text-[11px] text-muted`,title:e.path,children:C8(e.path,t)}),(0,L.jsx)(`span`,{className:`truncate text-[11px] text-muted/70`,children:e.stale?`Directory is missing`:n?`Opened ${n}`:`Never opened`})]})]}),(0,L.jsx)(g8,{project:e,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":`Change the icon for ${e.name}`,style:{width:E8,height:E8},className:`absolute left-[17px] top-1/2 flex -translate-y-1/2 items-center justify-center rounded-[30%] bg-black/75 text-fg opacity-0 outline-none transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-1 focus-visible:ring-fg/60 data-[state=open]:opacity-100 max-[700px]:left-4 max-[700px]:top-[calc(50%-0.5px)]`,children:(0,L.jsx)(Gm,{size:16,strokeWidth:1.75})})}),(0,L.jsx)(O8,{onDelete:()=>i(!0),children:(0,L.jsx)(`button`,{type:`button`,"aria-label":`More actions for ${e.name}`,className:`absolute right-[8px] top-1/2 flex h-7 w-7 -translate-y-1/2 items-center justify-center rounded-md text-muted opacity-0 outline-none transition-opacity hover:bg-panel-2 hover:text-fg focus-visible:opacity-100 focus-visible:ring-1 focus-visible:ring-fg/60 group-hover/card:opacity-100 data-[state=open]:opacity-100 max-[700px]:right-[7px] max-[700px]:opacity-100`,children:(0,L.jsx)(jm,{size:15})})}),r?(0,L.jsx)(k8,{project:e,home:t,onClose:()=>i(!1)}):null]})}function O8({onDelete:e,children:t}){return(0,L.jsxs)(MI,{children:[(0,L.jsx)(NI,{asChild:!0,children:t}),(0,L.jsx)(PI,{children:(0,L.jsx)(FI,{align:`end`,sideOffset:6,className:`z-[220] min-w-[170px] rounded-lg border border-border bg-panel p-1 shadow-xl shadow-black/40`,children:(0,L.jsx)(RI,{className:`cursor-default rounded px-2 py-1.5 text-[12.5px] text-red-400 outline-none data-[highlighted]:bg-red-500/10 data-[highlighted]:text-red-300`,onSelect:e,children:`Delete project…`})})})]})}function k8({project:e,home:t,onClose:n}){let[r,i]=(0,I.useState)(!1),a=Ve(),o=it({mutationFn:()=>Y.projectRemove({id:e.id,deleteData:r}),onSuccess:t=>{a.invalidateQueries({queryKey:[`projectsList`]}),Z(t.stoppedWorkers>0?`Deleted ${e.name} — ${t.stoppedWorkers} ${t.stoppedWorkers===1?`worker`:`workers`} stopped`:`Deleted ${e.name}`),n()}}),s=o.error instanceof Error?o.error.message:o.error?String(o.error):null;return(0,L.jsx)(lZ,{open:!0,onOpenChange:e=>{!e&&!o.isPending&&n()},title:`Delete ${e.name}?`,className:`w-[440px] max-w-[92vw]`,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,onClick:n,disabled:o.isPending,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`,onClick:()=>o.mutate(),disabled:o.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:[o.isPending&&(0,L.jsx)(Xm,{size:12,className:`animate-spin`}),r?`Delete project and threads`:`Delete project`]})]}),children:(0,L.jsxs)(`div`,{className:`flex flex-col gap-3 p-4 text-[12.5px] leading-relaxed text-muted`,children:[(0,L.jsxs)(`p`,{children:[`Frizz forgets this project. The folder itself is not touched — nothing inside`,` `,(0,L.jsx)(`span`,{className:`font-mono text-[11.5px] text-fg/80`,children:C8(e.path,t)}),` is changed or removed.`]}),(0,L.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 rounded-md border border-border bg-bg/30 px-2.5 py-2 text-fg/85`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked),className:`mt-[3px] accent-[var(--color-accent)]`}),(0,L.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,L.jsx)(`span`,{children:`Also delete its threads and history`}),(0,L.jsx)(`span`,{className:`text-[11.5px] text-muted/80`,children:r?`Everything Frizz has stored for this project, and any workers still running are stopped. This cannot be undone.`:`Left off, its threads are kept — adding the folder again brings the board back.`})]})]}),s?(0,L.jsx)(`p`,{className:`text-[11.5px] text-red-400`,children:s}):null]})})}function A8({hero:e,pending:t,onClick:n}){return(0,L.jsxs)(`button`,{type:`button`,onClick:n,disabled:t,className:`${w8} items-center justify-center gap-1.5 border-dashed border-border-strong bg-transparent text-muted hover:border-accent hover:text-fg max-[700px]:mx-4 max-[700px]:mt-4 ${e?`min-h-[118px]`:`min-h-[74px]`}`,children:[(0,L.jsx)(`span`,{className:`text-[17px] leading-none text-muted/70`,children:`+`}),(0,L.jsx)(`span`,{className:`text-[12.5px]`,children:t?`Choosing a folder…`:`Add a project`}),e?(0,L.jsx)(`span`,{className:`text-[11px] text-muted/70`,children:`Point Frizz at a folder on this machine`}):null]})}function j8({reason:e,proposed:t,onClose:n}){let[r,i]=(0,I.useState)(t??``),a=ny(),o=Ve(),s=it({mutationFn:e=>Y.projectAdd({path:e}),onSuccess:e=>{o.invalidateQueries({queryKey:[`projectsList`]}),a(jd(e.slug))}}),c=s.error instanceof Error?s.error.message:s.error?String(s.error):null;return(0,L.jsx)(eL,{open:!0,onOpenChange:e=>{!e&&!s.isPending&&n()},children:(0,L.jsxs)(oL,{children:[(0,L.jsx)(cL,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(fL,{"aria-modal":`true`,"aria-describedby":void 0,className:`fixed left-1/2 top-1/2 z-[210] w-[460px] max-w-[90vw] -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.jsx)(_L,{className:`mb-1 text-[14px] font-medium`,children:t?`Add this folder as a project?`:`Add a project`}),(0,L.jsx)(`p`,{className:`mb-3.5 text-[12.5px] leading-relaxed text-muted`,children:t?`You ran Frizz here and it is not a project yet. Nothing has been written — adding it is what creates its board.`:e?`${e}. Paste the folder instead — Frizz walks up to the repository root, the same way it does when you run it in a terminal.`:`Paste the folder you want a board for. Frizz walks up to the repository root, the same way it does when you run it in a terminal.`}),(0,L.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),s.isPending||s.mutate(r)},children:[(0,L.jsx)(`input`,{autoFocus:!0,value:r,onChange:e=>i(e.target.value),placeholder:`~/code/my-project`,spellCheck:!1,className:`w-full rounded-md border bg-bg px-2.5 py-2 font-mono text-[12px] text-fg outline-none placeholder:text-muted/50 focus-visible:ring-1 focus-visible:ring-fg/60 ${c?`border-red-500/60`:`border-border-strong`}`}),c?(0,L.jsx)(`p`,{className:`mt-1.5 text-[11.5px] text-red-400`,children:c}):null,(0,L.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:n,disabled:s.isPending,className:`rounded-md border border-border-strong bg-elevated px-3 py-1.5 text-[12.5px] text-fg outline-none hover:bg-panel-2 focus-visible:ring-1 focus-visible:ring-fg/60 disabled:opacity-50`,children:t?`Not now`:`Cancel`}),(0,L.jsx)(`button`,{type:`submit`,disabled:s.isPending||r.trim().length===0,className:`rounded-md border border-accent bg-accent px-3 py-1.5 text-[12.5px] font-medium text-bg outline-none hover:brightness-110 focus-visible:ring-1 focus-visible:ring-fg/60 disabled:opacity-50`,children:s.isPending?`Adding…`:t?`Add it`:`Add project`})]})]})]})]})})}function M8(){let[e]=(0,I.useState)(()=>{let e=new URLSearchParams(location.search).get(`add`)??void 0;return e&&history.replaceState(null,``,location.pathname),e}),[t,n]=(0,I.useState)(e?{}:null);(0,I.useEffect)(()=>{let e=new URLSearchParams(location.search).get(`unknown`);e&&(history.replaceState(null,``,location.pathname),Z(`No project named ${e} — showing all projects instead`,{duration:7e3}))},[]);let r=ny(),i=Ve(),a=it({mutationFn:()=>Y.projectPick({}),onSuccess:e=>{if(e.kind!==`cancelled`){if(e.kind===`unavailable`){n({reason:e.reason});return}i.invalidateQueries({queryKey:[`projectsList`]}),r(jd(e.project.slug))}},onError:e=>n({reason:e instanceof Error?e.message:String(e)})}),{data:o,isPending:s,error:c}=nt({queryKey:[`projectsList`],queryFn:()=>Y.projectsList()}),l=o?.[0]?.path.match(/^(\/(?:Users|home)\/[^/]+)\//u)?.[1],u=o!==void 0&&o.length===0;return(0,L.jsxs)(`div`,{className:`flex min-h-dvh w-full flex-col px-6 py-14 max-[700px]:px-0 max-[700px]:py-10`,children:[(0,L.jsxs)(`div`,{className:`m-auto flex w-full flex-col items-center`,children:[(0,L.jsxs)(`div`,{className:`mb-8 flex flex-col items-center gap-2.5 text-center`,children:[(0,L.jsx)(`img`,{src:`/favicon.svg`,width:S8,height:S8,alt:``,className:`rounded-[17px]`}),(0,L.jsx)(`h1`,{className:`text-[19px] font-semibold tracking-[-0.01em] text-fg`,children:u?`Welcome to Frizz`:`Select a project`}),u?(0,L.jsx)(`p`,{className:`max-w-[420px] text-[13px] leading-relaxed text-muted`,children:`A project is a folder on this machine. Frizz keeps one board of threads per project, and serves them all from here.`}):null]}),c?(0,L.jsxs)(`p`,{className:`text-[13px] text-muted`,children:[`Could not read the project registry: `,String(c)]}):s?(0,L.jsx)(`p`,{className:`text-[13px] text-muted`,children:`Loading…`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`grid w-full gap-2.5 max-[700px]:gap-0 ${u?`max-w-[360px] grid-cols-1`:`max-w-[720px] grid-cols-1 sm:grid-cols-2`}`,children:[o.map(e=>(0,L.jsx)(D8,{project:e,home:l},e.id)),(0,L.jsx)(A8,{hero:u,pending:a.isPending,onClick:()=>a.mutate()})]}),u?(0,L.jsxs)(`p`,{className:`mt-6 text-[11.5px] text-muted/70`,children:[`Or run`,` `,(0,L.jsx)(`code`,{className:`rounded border border-border bg-panel px-1.5 py-0.5 font-mono text-muted`,children:`frizz`}),` `,`inside any folder — it registers itself and opens.`]}):null]})]}),t?(0,L.jsx)(j8,{reason:t.reason,proposed:e,onClose:()=>n(null)}):null]})}function N8(e,t,n){let r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),i=0;for(let e=r.nextNode();e;e=r.nextNode()){if(e===t)return i+n;i+=e.textContent?.length??0}if(t instanceof Element&&e.contains(t)){let n=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),r=0;for(let e=n.nextNode();e;e=n.nextNode())(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING||t.contains(e))&&(r+=e.textContent?.length??0);return r}return null}function P8(e,t){let n=1,r=Math.min(t,e.length);for(let t=0;t<r;t++)e.charCodeAt(t)===10&&n++;return n}function F8({slug:e,path:t}){let n=$S(t),r=XC(t),i=nt({...rC(t),refetchInterval:r?!1:iC}),a=i.data?.path??t,o=i.data?.markdown??``,{front:s,body:c}=x4(n?o:``),[l,u]=(0,I.useState)(n?`rendered`:`source`),d=XK(c,{baseDir:tC(a),asDocument:!0}),f=Fq(d),p=Fq((0,I.useMemo)(()=>l===`source`?sC(a,o):``,[o,a,l])),m=(0,I.useRef)(null),h=(0,I.useRef)(null),g=(0,I.useRef)(null);Jq(m,d);let _=Qf(a),v=Oz(),y=kz(e);return(0,I.useEffect)(()=>{let t=()=>document.querySelector(`main[data-standalone-thread] textarea`);function n(e,t){return e?document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0?t.length:Math.min(e.selectionStart??t.length,t.length):t.length}function r(r){if(!(r.metaKey||r.ctrlKey)||r.altKey||r.shiftKey||r.key.toLowerCase()!==`i`)return;let i=g.current,s=window.getSelection(),c=s&&!s.isCollapsed&&s.rangeCount>0?s.getRangeAt(0):null,l=!!(i&&c&&i.contains(c.commonAncestorContainer)),u=l?s.toString():``;if(!l||!u.trim()){r.preventDefault(),r.stopPropagation();let e=t();if(!e)return;document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0&&e.setSelectionRange(e.value.length,e.value.length),e.focus();return}r.preventDefault(),r.stopPropagation();let d=null,f=h.current;if(f&&f.contains(c.commonAncestorContainer)){let e=N8(f,c.startContainer,c.startOffset),t=N8(f,c.endContainer,c.endOffset);e!==null&&t!==null&&(d={startLine:P8(o,Math.min(e,t)),endLine:P8(o,Math.max(0,Math.max(e,t)-1))})}else d=KL(o,u);let p=t(),m=Dz.followUp(v,e,y),{prose:_,attachments:b}=FL(Tz.get(m)),x=UL(LL({path:a,...d??{}}),X.composerContext[e]??[],_),S=WL(_,n(p,_),x);Tz.set(m,IL(S.prose,b.map(e=>e.path))),Np(e,{token:x,path:a,text:u,...d??{}}),s.removeAllRanges(),requestAnimationFrame(()=>{let e=t();e&&(e.setSelectionRange(S.caret,S.caret),e.focus())})}return window.addEventListener(`keydown`,r,!0),()=>window.removeEventListener(`keydown`,r,!0)},[e,a,o,v,y]),(0,L.jsxs)(`div`,{ref:g,"data-file-viewer-panel":!0,className:`flex h-full min-h-0 flex-col`,children:[(0,L.jsx)(Th,{title:_,subtitle:a,onClose:jp,actions:n?(0,L.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5 rounded-md border border-border-strong p-0.5 text-[11px] font-medium`,role:`group`,"aria-label":`File view`,children:[`rendered`,`source`].map(e=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>u(e),"aria-pressed":l===e,className:`rounded px-2 py-0.5 transition-colors ${l===e?`bg-panel-2 text-fg`:`text-muted hover:text-fg`}`,children:e===`rendered`?`Rendered`:`Source`},e))}):null}),(0,L.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:[i.isLoading?(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):i.error?(0,L.jsxs)(`div`,{className:`text-[13px] text-red-400/90`,children:[`Couldn’t read this file: `,i.error.message]}):l===`source`?o?(0,L.jsx)(`pre`,{ref:h,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:p}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):d?(0,L.jsxs)(L.Fragment,{children:[s&&(0,L.jsx)(w4,{source:s}),(0,L.jsx)(`div`,{ref:m,className:`md-body`,dangerouslySetInnerHTML:f})]}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!i.isLoading&&!i.error&&i.data?.truncated&&(0,L.jsx)(`p`,{className:`mt-4 border-t border-border/60 pt-3 text-[12px] text-muted`,children:`This file is too long to render in full — everything above the cut is shown. Open it to read the rest.`})]}),(0,L.jsxs)(`div`,{className:`shrink-0 flex items-center justify-between gap-3 border-t border-border/60 bg-panel px-5 pt-3`,style:S4,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-muted/70`,children:`Select text and press ⌘I to add it to the chat`}),(0,L.jsx)(C4,{path:a})]})]})}function I8(){return{dirs:new Map,files:new Map}}function L8(e,t){let n=e.replace(/[\\/]+$/,``);if(t){let e=np(t,n);if(e!==null)return Kf(e)}let r=Kf(n);return/^[\\/]/.test(n)?[`/`,...r]:r}var R8=(e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`,numeric:!0});function z8(e,t){let n=[];for(let r of[...e.dirs.keys()].sort(R8)){let i=e.dirs.get(r),a=r;for(;i.files.size===0&&i.dirs.size===1;){let[e,t]=[...i.dirs.entries()][0];a=a===`/`?`/${e}`:`${a}/${e}`,i=t}n.push({kind:`dir`,name:a,depth:t,children:z8(i,t+1)})}for(let r of[...e.files.keys()].sort(R8))n.push({kind:`file`,name:r,depth:t,file:e.files.get(r)});return n}function B8(e,t){let n=I8();for(let r of e){let e=L8(r.path,t);if(e.length===0)continue;let i=n;for(let t of e.slice(0,-1)){let e=i.dirs.get(t);e||(e=I8(),i.dirs.set(t,e)),i=e}i.files.set(e[e.length-1],r)}return z8(n,0)}function V8(e){let t=[],n=e=>{for(let r of e)t.push(r),r.kind===`dir`&&n(r.children)};return n(e),t}var H8=10;function U8({name:e,depth:t}){return(0,L.jsxs)(`div`,{"data-file-dir":e,className:`flex items-baseline text-[12px] leading-5 text-muted/70`,style:{paddingLeft:t*H8},children:[(0,L.jsx)(`span`,{className:`flex shrink-0`,children:(0,L.jsx)(Fm,{size:12,className:`${j$} text-muted/45`})}),(0,L.jsx)(`span`,{className:`ml-[5px] min-w-0 truncate`,title:e,children:e})]})}function W8({files:e}){return(0,L.jsx)(`div`,{"data-edited-file-tree":!0,className:`col-span-4 flex flex-col gap-y-px`,children:V8(B8(e,JC())).map(e=>e.kind===`dir`?(0,L.jsx)(U8,{name:e.name,depth:e.depth},`d:${e.depth}:${e.name}`):(0,L.jsx)(G8,{file:e.file,name:e.name,depth:e.depth},e.file.path))})}function G8({file:e,name:t,depth:n}){let r=Ve();return(0,L.jsx)(U$,{testKind:`file`,testId:e.path,mark:(0,L.jsx)(Nm,{size:12,className:`${j$} -mr-[2px] text-muted/60`}),name:t,indent:n*H8,onOpen:()=>Eq(e.path),onPrewarm:()=>lC(r,e.path),title:e.path,status:(0,L.jsxs)(L.Fragment,{children:[(e.added??0)>0&&(0,L.jsxs)(`span`,{style:{color:UE.fgSuccess},children:[`+`,e.added]}),(e.added??0)>0&&(e.removed??0)>0&&` `,(e.removed??0)>0&&(0,L.jsxs)(`span`,{style:{color:UE.fgDanger},children:[`−`,e.removed]})]})})}function K8({thread:e}){let t=TE(),n=sw(e.id,{poll:!1}).data?.editedFiles??[],r=X$(e),i=(e.bgShells??[]).filter(e=>e.state===`running`),a=(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`),o=(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`),{railFilesCollapsed:s}=Zt(yT),c=[{head:`Sub-agents`,rows:r.map(n=>(0,L.jsx)(Z$,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:i.map(n=>(0,L.jsx)(J$,{shell:n,slug:e.id,now:t},n.id??n.label))},{head:`Pull requests`,rows:a.map(e=>(0,L.jsx)(W$,{watch:e},e.id))},{head:`Timers`,rows:o.map(e=>(0,L.jsx)(Y$,{watch:e,now:t},e.id))},{head:`Edited files`,rows:n.length>0?[(0,L.jsx)(W8,{files:n},`tree`)]:[],count:n.length,collapsed:s,onToggle:()=>yT.railFilesCollapsed=!yT.railFilesCollapsed}].filter(e=>e.rows.length>0);return(0,L.jsx)(`aside`,{"data-focus-rail":!0,"aria-label":`Thread activity`,className:`flex h-full shrink-0 flex-col overflow-y-auto px-4 [view-transition-name:thread-rail]`,style:{width:340},children:(0,L.jsx)(`div`,{className:`my-auto py-6`,children:c.length===0?(0,L.jsx)(`div`,{className:`text-[11.5px] text-muted/50`,children:`Nothing running, watched or edited yet.`}):(0,L.jsx)(r1,{groups:c,divider:!1})})})}function q8(){let e=Zt(X),t=e.toast,[n,r]=(0,I.useState)(!1),i=e.drawers.some(e=>!e.closing);return(0,I.useEffect)(()=>{if(!t||(r(!0),t.sticky))return;let e=setTimeout(()=>r(!1),t.duration??(t.link?5e3:1600));return()=>clearTimeout(e)},[t?.id]),t?(0,L.jsx)(`div`,{className:`pointer-events-none fixed right-4 z-[70] flex justify-end ${i?`bottom-20`:`bottom-4`}`,children:(0,L.jsxs)(`div`,{"data-toast":!0,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`flex max-w-[min(30rem,calc(100vw-2rem))] items-center gap-2.5 break-words rounded-lg border border-border-strong bg-elevated px-4 py-2 text-[13px] font-medium text-fg shadow-xl shadow-black/40 transition-all duration-200 ease-out ${n?`translate-y-0 opacity-100`:`translate-y-8 opacity-0`}`,children:[t.spinner&&(0,L.jsx)(Xm,{size:13,className:`animate-spin text-muted`}),t.text,t.link&&(0,L.jsx)(`button`,{onClick:()=>{_p(`thread`,t.link.slug),X.toast=null},className:`pointer-events-auto shrink-0 rounded-md border border-border px-2 py-0.5 text-[12px] text-fg/90 transition-colors hover:bg-panel-2`,children:t.link.label})]})}):null}var J8=`max(50%, calc(100% - 720px))`,Y8={"--full-thread":`min(720px, ${J8})`,"--full-thread-narrow":`min(720px, 100%)`,"--full-pane":J8,"--full-gutter":`max(0px, calc((100% - min(720px, ${J8}) - 340px) / 2))`};function X8(e,t){return`${jd(e)}${Ld(t,`/`)}`}function Z8({slug:e}){let t=!!Zt(X).filePanel,n=qC(),r=Td(n,e),i=r.kind===`found`?r.thread:void 0;n?.projectDir,(0,I.useEffect)(()=>{Y.board().then(Up).catch(()=>{})},[]),(0,I.useEffect)(()=>{let e=window.matchMedia(`(min-width: ${Jp}px)`),t=()=>{X.splitFileViewer=e.matches};return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),X.splitFileViewer=!1,X.filePanel=null}},[]);let a=i?.runtime===`turn-idle`||i?.runtime===`exited`||i?.runtime===`none`;return(0,I.useEffect)(()=>{!i||!a||Y.threadSeen({slug:e}).catch(()=>{})},[a,e,i?.lastActivityAt]),(0,I.useEffect)(()=>{let t=n?.projectLabel??n?.projectName,r=i?CT(i):e;document.title=t?`${r} · ${t} — Frizz`:`${r} · Frizz`},[n?.projectLabel,n?.projectName,e,i]),(0,L.jsx)(rM,{children:(0,L.jsxs)(`div`,{className:`h-dvh min-h-0 bg-bg text-sm text-fg`,children:[(0,L.jsx)(`div`,{className:`h-full w-full overflow-hidden`,children:(0,L.jsxs)(`div`,{className:`flex h-full w-full justify-center transition-transform duration-200 ease-out motion-reduce:transition-none split:justify-start`,style:{...Y8,transform:t?`translateX(calc(-1 * var(--full-gutter)))`:void 0},children:[(0,L.jsx)(`div`,{className:`hidden w-[var(--full-gutter)] shrink-0 split:block`,"aria-hidden":`true`}),(0,L.jsx)(`main`,{"data-standalone-thread":!0,className:`flex h-full w-[var(--full-thread-narrow)] min-w-0 shrink-0 flex-col overflow-hidden border-border bg-panel sm:border-x split:w-[var(--full-thread)] [view-transition-name:thread-chat]`,children:r.kind===`loading`?(0,L.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,role:`status`,"aria-label":`Loading thread`,children:(0,L.jsx)(`span`,{className:`block h-5 w-5 animate-spin rounded-full border-2 border-muted/50 border-t-transparent`})}):r.kind===`missing`?(0,L.jsx)($8,{slug:e}):(0,L.jsx)(P0,{slug:e,virtualized:!0,showReturnToQueue:!0})}),i?(0,L.jsx)(Q8,{slug:e,thread:i}):(0,L.jsx)(`div`,{className:`hidden w-[var(--full-pane)] shrink-0 split:block`,"aria-hidden":`true`})]})}),(0,L.jsx)(D4,{}),(0,L.jsx)(q8,{})]})})}function Q8({slug:e,thread:t}){let n=Zt(X).filePanel,[r,i]=(0,I.useState)(null),a=n?.path??r;return(0,I.useEffect)(()=>{if(n){i(n.path);return}let e=window.setTimeout(()=>i(null),210);return()=>window.clearTimeout(e)},[n]),(0,L.jsxs)(`div`,{"data-side-pane":!0,className:`relative hidden h-full w-[var(--full-pane)] min-h-0 min-w-0 shrink-0 grow-0 overflow-hidden split:block`,children:[(0,L.jsx)(`div`,{inert:n?!0:void 0,className:`h-full min-h-0`,children:(0,L.jsx)(K8,{thread:t})}),(0,L.jsx)(`aside`,{"data-file-viewer-slot":!0,"aria-hidden":!n,className:`absolute inset-0 transition-[translate,opacity] duration-200 ease-out motion-reduce:transition-none ${n?`translate-x-0 opacity-100`:`translate-x-full opacity-0`}`,children:a&&(0,L.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-panel`,children:(0,L.jsx)(F8,{slug:e,path:a},a)})})]})}function $8({slug:e}){let{data:t,isPending:n}=nt({queryKey:[`threadLocate`,e],queryFn:()=>Y.threadLocate({slug:e})});return(0,I.useEffect)(()=>{t?.length===1&&location.replace(X8(t[0].projectSlug,e))},[t,e]),(0,L.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4 px-6 text-center`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h1`,{className:`font-medium text-fg`,children:`Thread unavailable`}),n?(0,L.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Looking for “`,e,`” in your other projects…`]}):t&&t.length>0?(0,L.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`“`,e,`” lives in `,t.length===1?`another project`:`these projects`,` — opening it there.`]}):(0,L.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Thread “`,e,`” was not found in any project on this machine.`]})]}),t&&t.length>1?(0,L.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:t.map(t=>(0,L.jsx)(`a`,{href:X8(t.projectSlug,e),className:`rounded-md border border-border px-3 py-1.5 text-[12px] text-fg/90 hover:bg-panel-2`,children:t.projectName},t.projectSlug))}):(0,L.jsx)(`a`,{href:`/`,className:`rounded-md border border-border px-3 py-1.5 text-[12px] text-fg/90 hover:bg-panel-2`,children:`All projects`})]})}var e5={OPEN_ISSUE:{bg:UE.bgSuccessEmphasis,icon:Tm,label:`Open`},CLOSED_ISSUE:{bg:UE.bgDoneEmphasis,icon:Cm,label:`Closed`},NOT_PLANNED:{bg:UE.bgNeutralEmphasis,icon:Dm,label:`Closed as not planned`},OPEN_PR:{bg:UE.bgSuccessEmphasis,icon:Vm,label:`Open`},DRAFT:{bg:UE.bgNeutralEmphasis,icon:Bm,label:`Draft`},MERGED:{bg:UE.bgDoneEmphasis,icon:Rm,label:`Merged`},CLOSED_PR:{bg:UE.bgDangerEmphasis,icon:zm,label:`Closed`}};function t5(e){return e.kind===`commit`?null:e.state===`MERGED`?`MERGED`:e.state===`DRAFT`?`DRAFT`:e.state===`OPEN`?e.kind===`pr`?`OPEN_PR`:`OPEN_ISSUE`:e.state===`CLOSED`?e.kind===`pr`?`CLOSED_PR`:e.stateReason===`NOT_PLANNED`?`NOT_PLANNED`:`CLOSED_ISSUE`:null}function n5(e,t=Date.now()){if(!e)return``;let n=new Date(e);if(Number.isNaN(n.getTime()))return``;let r=n.getFullYear()===new Date(t).getFullYear();return n.toLocaleDateString(void 0,{month:`short`,day:`numeric`,...r?{}:{year:`numeric`}})}function r5(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?Math.floor(Math.max(0,t-n)/864e5)>=360?`on ${n5(e,t)}`:mE(e,t)??``:``}function i5(e,t){let n=e+t;if(n<=0)return[,,,,,].fill(`none`);let r=Math.min(5,Math.floor(e/n*5)),i=Math.min(5-r,Math.floor(t/n*5));return[...Array(r).fill(`add`),...Array(i).fill(`del`),...Array(5-r-i).fill(`none`)]}var a5={add:UE.fgSuccess,del:UE.fgDanger},o5={add:{backgroundColor:UE.bgSuccessEmphasis,borderColor:UE.bgSuccessEmphasis},del:{backgroundColor:UE.bgDangerEmphasis,borderColor:UE.bgDangerEmphasis},none:{backgroundColor:`${UE.bgNeutralEmphasis}33`,borderColor:`#3d444d`}};function s5({additions:e,deletions:t}){return(0,L.jsxs)(`div`,{className:`flex items-baseline gap-1.5 text-[12px] tabular-nums`,children:[(0,L.jsxs)(`span`,{"data-gh-add":!0,style:{color:a5.add},children:[`+`,e.toLocaleString()]}),(0,L.jsxs)(`span`,{"data-gh-del":!0,style:{color:a5.del},children:[`−`,t.toLocaleString()]}),(0,L.jsx)(`span`,{"data-gh-blocks":!0,className:`ml-0.5 inline-flex gap-[1px] self-baseline translate-y-[calc(4px_-_0.5cap)]`,children:i5(e,t).map((e,t)=>(0,L.jsx)(`span`,{className:`size-[8px] rounded-[2px] border`,style:o5[e]},t))})]})}function c5({card:e}){let t=t5(e),n=t?e5[t]:void 0;if(!n)return null;let r=n.icon;return(0,L.jsxs)(`span`,{"data-gh-pill":!0,className:`inline-flex items-baseline gap-1 rounded-full px-2.5 py-1 text-[12px] font-medium text-white`,style:{backgroundColor:n.bg},children:[(0,L.jsx)(r,{strokeWidth:2,"aria-hidden":!0,className:`size-[1.1em] shrink-0 self-baseline -mr-px translate-y-[calc(0.55em_-_0.5cap)]`}),(0,L.jsx)(`span`,{"data-gh-pill-label":!0,children:n.label})]})}function l5({name:e,color:t}){let n=/^[0-9a-fA-F]{6}$/.test(t)?`#${t}`:`#8b8f96`;return(0,L.jsx)(`span`,{className:`inline-flex items-center rounded-full border px-2 py-[1px] text-[11px] font-medium`,style:{color:n,backgroundColor:`${n}26`,borderColor:`${n}59`},children:e})}var u5=/`([^`\n]+)`/g;function d5(e,t){if(!t)return[e];let n=[],r=0;for(let t of e.matchAll(u5))t.index>r&&n.push(e.slice(r,t.index)),n.push({code:t[1]}),r=t.index+t[0].length;return r<e.length&&n.push(e.slice(r)),n}function f5({text:e,code:t,className:n}){return(0,L.jsx)(`div`,{className:n,children:d5(e,t).map((e,t)=>typeof e==`string`?e:(0,L.jsx)(`code`,{className:`rounded-[3px] bg-panel-2 px-[3px] py-[1px] font-mono-keep text-[0.92em]`,children:e.code},t))})}var p5=new Set([`avatars.githubusercontent.com`,`camo.githubusercontent.com`]);function m5(e){if(e)try{let t=new URL(e);return t.protocol===`https:`&&p5.has(t.hostname)?e:void 0}catch{return}}function h5({card:e,nowMs:t}){let n=m5(e.authorAvatar),r=e.authorLogin??e.authorName??`Someone`,i=e.kind===`commit`?`committed`:e.kind===`pr`?`opened this pull request`:`opened this issue`,a=r5(e.at,t);return(0,L.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-2 text-[12px] text-muted`,children:[n?(0,L.jsx)(`img`,{"data-gh-avatar":!0,src:n,alt:``,className:`size-[18px] shrink-0 rounded-full`}):(0,L.jsx)(`span`,{"data-gh-avatar":!0,className:`size-[18px] shrink-0 rounded-full bg-border`}),(0,L.jsxs)(`span`,{"data-gh-byline-text":!0,className:`truncate`,children:[(0,L.jsx)(`span`,{className:`text-fg`,children:r}),` `,i,` `,a]})]})}var g5=`w-[360px] max-w-[min(360px,calc(100vw-24px))] leading-normal`;function _5({card:e,nowMs:t=Date.now()}){let n=e.additions!==void 0&&e.deletions!==void 0;if(e.kind===`commit`)return(0,L.jsxs)(`div`,{className:g5,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline gap-2 px-3 pt-3 pb-2.5`,children:[(0,L.jsx)(`span`,{"data-gh-commit-glyph":!0,className:`shrink-0 self-baseline -mr-px text-[14px] translate-y-[calc(0.5em_-_0.5cap)]`,children:(0,L.jsx)(Lm,{className:`size-[1em] text-muted`,"aria-hidden":!0})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`a`,{"data-gh-title":!0,href:e.url,target:`_blank`,rel:`noreferrer noopener`,tabIndex:-1,className:`block text-[14px] font-semibold leading-snug text-fg hover:underline`,children:e.title}),e.body?(0,L.jsx)(f5,{text:e.body,code:!1,className:`mt-1.5 line-clamp-6 text-[12px] text-muted`}):null,n?(0,L.jsx)(`div`,{className:`mt-2.5`,children:(0,L.jsx)(s5,{additions:e.additions,deletions:e.deletions})}):null]})]}),(0,L.jsx)(h5,{card:e,nowMs:t})]});let r=e.ref.slice(e.ref.indexOf(`#`));return(0,L.jsxs)(`div`,{className:g5,children:[(0,L.jsxs)(`div`,{className:`px-3 pt-3 pb-3`,children:[(0,L.jsxs)(`div`,{className:`text-[12px] text-muted`,children:[(0,L.jsx)(`span`,{className:`underline decoration-border underline-offset-2`,children:e.repo}),e.at?` on ${n5(e.at,t)}`:``]}),(0,L.jsxs)(`a`,{"data-gh-title":!0,href:e.url,target:`_blank`,rel:`noreferrer noopener`,tabIndex:-1,className:`mt-1 block text-[14px] font-semibold leading-snug text-fg hover:underline`,children:[e.title,` `,(0,L.jsx)(`span`,{className:`font-normal text-muted`,children:r})]}),(0,L.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,L.jsx)(c5,{card:e}),n?(0,L.jsx)(s5,{additions:e.additions,deletions:e.deletions}):null]})]}),e.body||e.labels.length>0?(0,L.jsxs)(`div`,{className:`border-t border-border px-3 py-2.5`,children:[e.body?(0,L.jsx)(f5,{text:e.body,code:!0,className:`line-clamp-2 text-[12px] text-muted`}):null,e.labels.length>0?(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1 ${e.body?`mt-2`:``}`,children:e.labels.map(e=>(0,L.jsx)(l5,{name:e.name,color:e.color},e.name))}):null]}):null,(0,L.jsx)(h5,{card:e,nowMs:t})]})}var v5=250,y5=180;function b5(e){let t=e.getClientRects()[0]??e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}}function x5(){let[e,t]=(0,I.useState)(null),n=(0,I.useRef)(void 0),r=(0,I.useRef)(void 0),i=(0,I.useRef)(!1),a=(0,I.useCallback)(()=>{clearTimeout(n.current),clearTimeout(r.current),n.current=void 0,r.current=void 0},[]),o=(0,I.useCallback)(()=>{clearTimeout(r.current),r.current=setTimeout(()=>{i.current||t(null)},y5)},[]);return(0,I.useEffect)(()=>{let i=i=>{if(i.pointerType!==`mouse`)return;let a=i.target?.closest?.(`a[data-gh-ref]`)??null,o=a?.getAttribute(`data-gh-ref`);!a||!o||(clearTimeout(r.current),e?.ref!==o&&(clearTimeout(n.current),jf([o]),n.current=setTimeout(()=>t({ref:o,rect:b5(a)}),v5)))},a=e=>{e.pointerType===`mouse`&&e.target?.closest?.(`a[data-gh-ref]`)&&(clearTimeout(n.current),o())};return document.addEventListener(`pointerover`,i),document.addEventListener(`pointerout`,a),()=>{document.removeEventListener(`pointerover`,i),document.removeEventListener(`pointerout`,a)}},[e?.ref,o]),(0,I.useEffect)(()=>{if(!e)return;let n=()=>{i.current=!1,a(),t(null)};return window.addEventListener(`scroll`,n,!0),window.addEventListener(`resize`,n),()=>{window.removeEventListener(`scroll`,n,!0),window.removeEventListener(`resize`,n)}},[e,a]),(0,I.useEffect)(()=>a,[a]),(0,L.jsxs)(DV,{open:e!==null,children:[(0,L.jsx)(kV,{asChild:!0,children:(0,L.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none fixed`,style:{top:e?.rect.top??0,left:e?.rect.left??0,width:e?.rect.width??0,height:e?.rect.height??0}})}),e?(0,L.jsx)(AV,{side:`top`,align:`start`,sideOffset:8,alignOffset:-8,"aria-hidden":!0,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onPointerEnter:()=>{i.current=!0,clearTimeout(r.current)},onPointerLeave:()=>{i.current=!1,o()},className:`overflow-hidden`,children:(0,L.jsx)(S5,{refKey:e.ref})}):null]})}function S5({refKey:e}){let t=(0,I.useSyncExternalStore)(Ef,()=>Df(e),()=>Df(e));return(0,I.useEffect)(()=>{Of(Df(e))&&Ff(e)},[e]),t?.card?(0,L.jsx)(_5,{card:t.card}):(0,L.jsx)(`div`,{className:`flex h-[64px] w-[220px] items-center px-3 text-[12px] text-muted`,children:t?.missing?`Not found on GitHub`:`Loading…`})}var C5=`frizz-project-rail`;function w5(){try{return localStorage.getItem(C5)===`shown`}catch{return!1}}function T5(e){try{localStorage.setItem(C5,e?`shown`:`hidden`)}catch{}}function E5(){ey();let e=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet(),placeholderData:ee}).data?.projectRail;return(0,I.useEffect)(()=>{e!==void 0&&T5(e===!0)},[e]),e===void 0?w5():e===!0}var D5=`/project/:slug`;function O5(){N5();let e=E5();return(0,L.jsxs)(rM,{children:[e?(0,L.jsx)(x8,{}):null,(0,L.jsx)(`div`,{className:e?l8:void 0,children:(0,L.jsx)(Iy,{})}),(0,L.jsx)(q8,{}),(0,L.jsx)(x5,{})]})}function k5(e){(0,I.useEffect)(()=>{OC(e)||(Hp(),GC())},[e])}function A5(){let{slug:e,thread:t}=oy();return k5(e),M5(),(0,I.useState)(()=>wp(t)),(0,L.jsx)(r8,{},e??`__launching__`)}function j5(){return(0,L.jsx)(M8,{})}function M5(){let e=ey();(0,I.useEffect)(()=>{gw(Nd(e.pathname))},[e.pathname])}function N5(){let e=ny();(0,I.useEffect)(()=>(yw((t,n)=>e(t,n)),()=>yw(null)),[e])}function P5(){let{thread:e,slug:t}=oy();return N5(),k5(t),(0,I.useState)(()=>{X.drawers.length>0&&(X.drawers=[])}),Cp(e),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Z8,{slug:e}),(0,L.jsx)(q8,{})]})}var F5=[{index:!0,element:(0,L.jsx)(A5,{})},{path:`thread/:thread`,element:(0,L.jsx)(A5,{})},{path:`status/:status`,element:(0,L.jsx)(A5,{})}],I5=Eb([{path:`/thread/:thread/full`,element:(0,L.jsx)(P5,{})},{path:`${D5}/thread/:thread/full`,element:(0,L.jsx)(P5,{})},{element:(0,L.jsx)(O5,{}),children:[{path:`/`,element:(0,L.jsx)(j5,{})},{path:`/thread/:thread`,element:(0,L.jsx)(A5,{})},{path:`/status/:status`,element:(0,L.jsx)(A5,{})},{path:D5,children:F5},{path:`*`,element:(0,L.jsx)(A5,{})}]}]),L5=24,R5=6,z5=700,B5=new Map,V5=null,H5=null;function U5(e){return!Array.isArray(e)||e.length!==2?null:e[0]===`transcript`&&typeof e[1]==`string`?e[1]:null}function W5(e){return X.board?.threads.find(t=>t.id===e)?.lastActivityAt}function G5(){let e=[...B5.entries()].filter(([,e])=>e.observers>0),t=new Set(e.slice(-24).map(([e])=>e));for(let[e,n]of B5){if(n.observers<=0){n.live&&(n.live=!1,VC(e)),B5.delete(e);continue}t.has(e)?!n.live&&!n.queued&&(n.queued=!0):(n.queued=!1,n.live&&(n.live=!1,VC(e)))}K5()}function K5(){H5||[...B5.values()].some(e=>e.queued)&&(H5=setTimeout(()=>{H5=null;let e=0,t=[...B5.values()].filter(e=>e.live).length;for(let[n,r]of B5){if(e>=R5||t>=L5)break;r.queued&&(r.queued=!1,!(r.observers<=0||r.live)&&(r.live=!0,t++,r.lastActivityAt=W5(n),BC(n),e++))}K5()},z5))}function q5(){if(V5)for(let[e,t]of B5){if(t.observers<=0)continue;let n=W5(e);n!==t.lastActivityAt&&(t.lastActivityAt=n,!(t.live&&X.socketTranscripts)&&(X.socketTranscriptFallbacks[e]||V5.refetchQueries({queryKey:[`transcript`,e],exact:!0,type:`active`})))}}function J5(e){V5||(V5=e,e.getQueryCache().subscribe(e=>{let t=U5(e.query.queryKey);if(!t||e.type!==`observerAdded`&&e.type!==`observerRemoved`)return;let n=e.query.getObserversCount(),r=B5.get(t);e.type===`observerAdded`?(B5.delete(t),B5.set(t,{observers:n,live:r?.live??!1,queued:r?.queued??!1,lastActivityAt:r?r.lastActivityAt:W5(t)})):r&&(r.observers=n),G5()}),Jt(X,q5))}var Y5=`ui-monospace, "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Mono", Consolas, Menlo, "DejaVu Sans Mono", monospace`,X5=`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;function Z5(e){let t=e===`mono`?`mono`:`sans`;document.documentElement.dataset.font=t,document.body&&(document.body.style.fontFamily=t===`sans`?X5:Y5);try{localStorage.setItem(`frizz-font`,t)}catch{}}function Q5(e){let t=e.getQueryData([`settingsGet`]);t&&Z5(t.font),Y.settingsGet().then(e=>Z5(e.font)).catch(()=>{}),e.getQueryCache().subscribe(()=>{let t=e.getQueryData([`settingsGet`]);t&&Z5(t.font)})}function $5(){let e=e=>{if(e.button!==0||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`.${jS}`):null;t&&(e.preventDefault(),e.stopPropagation(),t7(t))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)}function e7(e){return e.closest(`.md-code`)?.querySelector(`pre code`)??null}async function t7(e){let t=e7(e);if(!t)return;let n=(t.textContent??``).replace(/\n$/,``);if(n){try{await WR(n)}catch(e){Z(`Could not copy code: ${e.message.slice(0,100)}`,{duration:7e3});return}r7(e)}}var n7=new WeakMap;function r7(e){e.classList.add(MS),e.title=`Copied`;let t=n7.get(e);t!==void 0&&window.clearTimeout(t),n7.set(e,window.setTimeout(()=>{e.classList.remove(MS),e.title=NS,n7.delete(e)},p1))}var i7=/^\/thread\/([a-z0-9][a-z0-9-]*)\/?$/;function a7(){let e=e=>{if(e.button!==0||e.defaultPrevented||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let t=e.target instanceof Element?e.target.closest(`a[href*="/thread/"]`):null,n=t?.getAttribute(`href`);if(!t||!n||!n.startsWith(`/`))return;let r=Ad(n);if(r&&r!==Ad())return;let i=i7.exec(Nd(n));i&&(e.preventDefault(),e.stopPropagation(),bp(i[1]))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)}var o7=new Set([`projectsList`,`projectsQueueCounts`,`threadLocate`,`dispatchPreferencesGet`,`supervisorStatus`]);function s7(e){let t=e[0];return typeof t==`string`&&o7.has(t)?T(e):T([`project:${Ad()??``}`,...e])}var c7=typeof window<`u`&&window.location.pathname.endsWith(`/settings-formatting-fixture.html`),l7=typeof window<`u`?Rd(Nd()):null;!c7&&!l7&&_w();var u7=new Le({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,queryKeyHashFn:s7}}});c7||(KC(u7),J5(u7),bH(u7),Q5(u7),MQ(),wq(),$5(),a7()),c7||(0,at.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(He,{client:u7,children:(0,L.jsx)(jh,{children:(0,L.jsx)(My,{router:I5})})}));export{a as i,Id as n,ze as r,ib as t};