frizz-server 0.14.0 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (90) hide show
  1. package/dist/claude-agent-broker.js +10859 -10590
  2. package/dist/dev-child.js +81 -42
  3. package/package.json +1 -1
  4. package/web-dist/assets/{TerminalPane-DcNJcvz9.js → TerminalPane-C0ndNP2R.js} +1 -1
  5. package/web-dist/assets/{abnfDiagram-VRR7QNED-BFKPkR0J.js → abnfDiagram-VRR7QNED-Cnsh1t8G.js} +1 -1
  6. package/web-dist/assets/architecture-TIHT7OUA-BFTL2lQD.js +1 -0
  7. package/web-dist/assets/{architectureDiagram-ZJ3FMSHR-BugbGvF7.js → architectureDiagram-ZJ3FMSHR-DnVeuKCI.js} +1 -1
  8. package/web-dist/assets/{blockDiagram-677ZJIJ3-B1drPHOm.js → blockDiagram-677ZJIJ3-DqKYXGJI.js} +1 -1
  9. package/web-dist/assets/{c4Diagram-LMCZKHZV-jA8etf56.js → c4Diagram-LMCZKHZV-DRNawTpl.js} +1 -1
  10. package/web-dist/assets/channel-Nm8jIZOi.js +1 -0
  11. package/web-dist/assets/{chunk-32BRIVSS-BfMUf_Yy.js → chunk-32BRIVSS-BKqSe_nC.js} +1 -1
  12. package/web-dist/assets/{chunk-52WLFC77-Fo52YmmC.js → chunk-52WLFC77-BCaLFglM.js} +1 -1
  13. package/web-dist/assets/{chunk-C7G6YPKG-CPiVGUnC.js → chunk-C7G6YPKG-vlAetigo.js} +1 -1
  14. package/web-dist/assets/{chunk-EX3LRPZG-DllbzsPn.js → chunk-EX3LRPZG-C1O5APJY.js} +1 -1
  15. package/web-dist/assets/{chunk-FWX5IMBZ-Cr7SCNOQ.js → chunk-FWX5IMBZ-DRBYKkzP.js} +2 -2
  16. package/web-dist/assets/{chunk-HOUHSVGY-D2qjbRMK.js → chunk-HOUHSVGY-C7BVwG9_.js} +1 -1
  17. package/web-dist/assets/{chunk-ICXQ74PX-Dl8ZZqX4.js → chunk-ICXQ74PX-DVwDQwtI.js} +1 -1
  18. package/web-dist/assets/{chunk-MOJQB5TN-C7X9x33F.js → chunk-MOJQB5TN-5DhQ9vKC.js} +1 -1
  19. package/web-dist/assets/{chunk-OGEWGWER-DrlPoLRT.js → chunk-OGEWGWER-Bgg5ovNG.js} +1 -1
  20. package/web-dist/assets/{chunk-PUDLZKDR-C1WS3qVH.js → chunk-PUDLZKDR-B-hJsSaU.js} +1 -1
  21. package/web-dist/assets/{chunk-Q4XR5HBZ-CNhqnN4i.js → chunk-Q4XR5HBZ-BRKTCm77.js} +1 -1
  22. package/web-dist/assets/{chunk-V7JOEXUC-BQsiP60Y.js → chunk-V7JOEXUC-DLg_AuLv.js} +1 -1
  23. package/web-dist/assets/{chunk-VAUOI2AC-DeQswo6G.js → chunk-VAUOI2AC-CRKn6Hdz.js} +1 -1
  24. package/web-dist/assets/{chunk-VR4S4FIN-QCzpzy3F.js → chunk-VR4S4FIN-C3tBNXjB.js} +1 -1
  25. package/web-dist/assets/{chunk-WYO6CB5R-DYEAXxaM.js → chunk-WYO6CB5R-LRVUOcLK.js} +1 -1
  26. package/web-dist/assets/{chunk-ZGVPDNZ5-BRwJsVqD.js → chunk-ZGVPDNZ5-BbjZAQf3.js} +1 -1
  27. package/web-dist/assets/classDiagram-OUVF2IWQ-C8nDRy2s.js +1 -0
  28. package/web-dist/assets/classDiagram-v2-EOCWNBFH-C8nDRy2s.js +1 -0
  29. package/web-dist/assets/{cynefin-VYW2F7L2-DFY4wScy.js → cynefin-VYW2F7L2-BiFACRL6.js} +1 -1
  30. package/web-dist/assets/{cynefinDiagram-TSTJHNR4-BFd6vF05.js → cynefinDiagram-TSTJHNR4-Ba2A7L8f.js} +1 -1
  31. package/web-dist/assets/{dagre-VKFMJZFB-BTSZ-kNz.js → dagre-VKFMJZFB-B1gwugR0.js} +1 -1
  32. package/web-dist/assets/{diagram-FQU43EPY-CM5L_Teo.js → diagram-FQU43EPY-D3yeDptD.js} +1 -1
  33. package/web-dist/assets/{diagram-G47NLZAW-DMEMjhev.js → diagram-G47NLZAW-C3ckNGcW.js} +1 -1
  34. package/web-dist/assets/{diagram-NH7WQ7WH-BINXDe2x.js → diagram-NH7WQ7WH-Be2tn4YY.js} +1 -1
  35. package/web-dist/assets/{diagram-OA4YK3LP-DhKBXS5G.js → diagram-OA4YK3LP-Dwj1ohx-.js} +1 -1
  36. package/web-dist/assets/{diagram-WEI45ONY-QaICPLa1.js → diagram-WEI45ONY-Dt-jAW5B.js} +1 -1
  37. package/web-dist/assets/{ebnfDiagram-CCIWWBDH-DDQ6NAEt.js → ebnfDiagram-CCIWWBDH-Bz3-UuRU.js} +1 -1
  38. package/web-dist/assets/{erDiagram-Q63AITRT-eftnFvxT.js → erDiagram-Q63AITRT-BaCr3-Qz.js} +1 -1
  39. package/web-dist/assets/eventmodeling-45OFAUF4-CD9TITDK.js +1 -0
  40. package/web-dist/assets/flowDiagram-23GEKE2U-Womg_Wqj.js +1 -0
  41. package/web-dist/assets/{ganttDiagram-NO4QXBWP-CBUUxbvO.js → ganttDiagram-NO4QXBWP-BvCR51Ob.js} +1 -1
  42. package/web-dist/assets/{gitGraph-TEB2WS4Q-B4j6N6bC.js → gitGraph-TEB2WS4Q-ClGknGDf.js} +1 -1
  43. package/web-dist/assets/{gitGraphDiagram-IHSO6WYX-mrIlQ6c3.js → gitGraphDiagram-IHSO6WYX-D9a31pAE.js} +1 -1
  44. package/web-dist/assets/{index-BI0k4RW8.js → index-CTcjL-eO.js} +79 -79
  45. package/web-dist/assets/{info-DKCQHKI2-Dj4G-7Y8.js → info-DKCQHKI2-BGPJKOjY.js} +1 -1
  46. package/web-dist/assets/{infoDiagram-FWYZ7A6U-Baz07f6h.js → infoDiagram-FWYZ7A6U-B9toNDZt.js} +1 -1
  47. package/web-dist/assets/{ishikawaDiagram-FXEZZL3T-C4og8CF4.js → ishikawaDiagram-FXEZZL3T-COi6cP-a.js} +1 -1
  48. package/web-dist/assets/{journeyDiagram-5HDEW3XC-B0WV30vH.js → journeyDiagram-5HDEW3XC-jDqNUKQG.js} +1 -1
  49. package/web-dist/assets/{kanban-definition-HUTT4EX6-BgDiY6B1.js → kanban-definition-HUTT4EX6-CtxeJlFi.js} +1 -1
  50. package/web-dist/assets/{line-D0SxxXfr.js → line-uNWy2FRa.js} +1 -1
  51. package/web-dist/assets/{mermaid-parser.core-CWj7pjCH.js → mermaid-parser.core-Cfuj8tio.js} +3 -3
  52. package/web-dist/assets/{mermaid.core-Dpi4Z-WK.js → mermaid.core-BtNCexa9.js} +3 -3
  53. package/web-dist/assets/{mindmap-definition-LN4V7U3C-DLmQQ7LC.js → mindmap-definition-LN4V7U3C-B2u_kZ9E.js} +1 -1
  54. package/web-dist/assets/{packet-7NZHBO7P-T7pVIfFz.js → packet-7NZHBO7P-DNfwFIg5.js} +1 -1
  55. package/web-dist/assets/{pegDiagram-2B236MQR-BvVxzZmj.js → pegDiagram-2B236MQR-Cm9NTz0P.js} +1 -1
  56. package/web-dist/assets/{pie-RZYD4A2V-BGz-hjIz.js → pie-RZYD4A2V-CMjAC3_C.js} +1 -1
  57. package/web-dist/assets/{pieDiagram-ENE6RG2P-pdOHyNTd.js → pieDiagram-ENE6RG2P-DZegJin2.js} +1 -1
  58. package/web-dist/assets/{quadrantDiagram-ABIIQ3AL-fLy3coW3.js → quadrantDiagram-ABIIQ3AL-Cr1P0TiT.js} +1 -1
  59. package/web-dist/assets/{radar-I7S5WNFK-C-VKX4OE.js → radar-I7S5WNFK-D_BiHAza.js} +1 -1
  60. package/web-dist/assets/{railroad-3IZDKUUU-BwC-mtji.js → railroad-3IZDKUUU-Kx4om6Pi.js} +1 -1
  61. package/web-dist/assets/railroad-abnf-AHOZXSZD-pLt2-q5a.js +1 -0
  62. package/web-dist/assets/railroad-ebnf-EBAXGLYW-BvNkqSim.js +1 -0
  63. package/web-dist/assets/railroad-peg-LSFZ7HO6-g9R2pEue.js +1 -0
  64. package/web-dist/assets/{railroadDiagram-RFXS5EU6-BxPp9neb.js → railroadDiagram-RFXS5EU6-CGiAkwN0.js} +1 -1
  65. package/web-dist/assets/{requirementDiagram-TGXJPOKE-P_BvOjKp.js → requirementDiagram-TGXJPOKE-Uh5FVpIq.js} +1 -1
  66. package/web-dist/assets/{sankeyDiagram-HTMAVEWB-DUv1nZCv.js → sankeyDiagram-HTMAVEWB-CMBZWUwb.js} +1 -1
  67. package/web-dist/assets/{sequenceDiagram-DBY2YBRQ-DWNx793M.js → sequenceDiagram-DBY2YBRQ-CL7uvgun.js} +1 -1
  68. package/web-dist/assets/{stateDiagram-2N3HPSRC-CaOUtkvy.js → stateDiagram-2N3HPSRC-CSU2s89c.js} +1 -1
  69. package/web-dist/assets/stateDiagram-v2-6OUMAXLB-BjWfwAZ4.js +1 -0
  70. package/web-dist/assets/{swimlanes-5IMT3BWC-D764GMah.js → swimlanes-5IMT3BWC-sfLI2FY3.js} +1 -1
  71. package/web-dist/assets/swimlanesDiagram-G3AALYLV-B5co78bI.js +8 -0
  72. package/web-dist/assets/{timeline-definition-FHXFAJF6-DeKz_jJG.js → timeline-definition-FHXFAJF6-Dl3Dx33l.js} +1 -1
  73. package/web-dist/assets/{treeView-QDETBFTQ-D3UnDOk3.js → treeView-QDETBFTQ-C6i-QhBd.js} +1 -1
  74. package/web-dist/assets/{treemap-6X3UGDF4-VItEAzU3.js → treemap-6X3UGDF4-kjzleK2t.js} +1 -1
  75. package/web-dist/assets/{vennDiagram-L72KCM5P-DuzNjZFZ.js → vennDiagram-L72KCM5P-BVYuCdzD.js} +1 -1
  76. package/web-dist/assets/{wardley-OPB4EBWU-B1uIoPVb.js → wardley-OPB4EBWU-Dd-gYK7z.js} +1 -1
  77. package/web-dist/assets/{wardleyDiagram-EHGQE667-H60TjU5y.js → wardleyDiagram-EHGQE667-BkLQ_w49.js} +1 -1
  78. package/web-dist/assets/{xychartDiagram-FW5EYKEG-BqTqYEwv.js → xychartDiagram-FW5EYKEG-Cm4pNjto.js} +1 -1
  79. package/web-dist/index.html +1 -1
  80. package/web-dist/assets/architecture-TIHT7OUA-3cEHc0mh.js +0 -1
  81. package/web-dist/assets/channel-BYQQkw21.js +0 -1
  82. package/web-dist/assets/classDiagram-OUVF2IWQ-BgM58S9B.js +0 -1
  83. package/web-dist/assets/classDiagram-v2-EOCWNBFH-BgM58S9B.js +0 -1
  84. package/web-dist/assets/eventmodeling-45OFAUF4-KZNoVoEu.js +0 -1
  85. package/web-dist/assets/flowDiagram-23GEKE2U-m4sDfmpP.js +0 -1
  86. package/web-dist/assets/railroad-abnf-AHOZXSZD-CNsCN0k6.js +0 -1
  87. package/web-dist/assets/railroad-ebnf-EBAXGLYW-Bjabtkan.js +0 -1
  88. package/web-dist/assets/railroad-peg-LSFZ7HO6-DjPlt8Lc.js +0 -1
  89. package/web-dist/assets/stateDiagram-v2-6OUMAXLB-CbgDxwEv.js +0 -1
  90. package/web-dist/assets/swimlanesDiagram-G3AALYLV-QPzvJba6.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPane-DcNJcvz9.js","assets/rolldown-runtime-Bh1tDfsg.js","assets/mermaid.core-Dpi4Z-WK.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-C4XfhTaE.js","assets/chunk-WYO6CB5R-DYEAXxaM.js","assets/chunk-ICXQ74PX-Dl8ZZqX4.js","assets/dist-DoH_9pyS.js","assets/chunk-VAUOI2AC-DeQswo6G.js","assets/chunk-HOUHSVGY-D2qjbRMK.js","assets/chunk-Q4XR5HBZ-CNhqnN4i.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-DrlPoLRT.js","assets/chunk-C7G6YPKG-CPiVGUnC.js","assets/chunk-ZGVPDNZ5-BRwJsVqD.js","assets/rough.esm-CSKSodPl.js","assets/chunk-52WLFC77-Fo52YmmC.js","assets/line-D0SxxXfr.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-FWX5IMBZ-Cr7SCNOQ.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-C0ndNP2R.js","assets/rolldown-runtime-Bh1tDfsg.js","assets/mermaid.core-BtNCexa9.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-C4XfhTaE.js","assets/chunk-WYO6CB5R-LRVUOcLK.js","assets/chunk-ICXQ74PX-DVwDQwtI.js","assets/dist-DoH_9pyS.js","assets/chunk-VAUOI2AC-CRKn6Hdz.js","assets/chunk-HOUHSVGY-C7BVwG9_.js","assets/chunk-Q4XR5HBZ-BRKTCm77.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-Bgg5ovNG.js","assets/chunk-C7G6YPKG-vlAetigo.js","assets/chunk-ZGVPDNZ5-BbjZAQf3.js","assets/rough.esm-CSKSodPl.js","assets/chunk-52WLFC77-BCaLFglM.js","assets/line-uNWy2FRa.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-FWX5IMBZ-DRBYKkzP.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(`
@@ -135,13 +135,13 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
135
135
  `?(t.push(r+`</span>`.repeat(n.length)),r=n.join(``)):i===`</span>`?(n.pop(),r+=i):(i.startsWith(`<span`)&&n.push(i),r+=i);return t.push(r+`</span>`.repeat(n.length)),t}var rC=/^(\s*\d+\t)([\s\S]*)$/,iC=/^\s*\d+$/;function aC(e){let t=0,n=0,r=0;for(let i of e)i.trim()&&(t++,rC.test(i)?(n++,r++):iC.test(i)&&n++);return t>0&&n===t&&r>0}function oC(e){return e.replace(/[&<>"']/g,e=>e===`&`?`&amp;`:e===`<`?`&lt;`:e===`>`?`&gt;`:e===`"`?`&quot;`:`&#39;`)}var sC=`frizz-code-gutter`;function cC(e,t){let n=e.split(`
136
136
  `);if(!aC(n))return $S(e,t);let r=[],i=[];for(let e of n){let t=rC.exec(e);t?(r.push(t[1]),i.push(t[2])):e.trim()&&iC.test(e)?(r.push(e),i.push(``)):(r.push(``),i.push(e))}let a=nC($S(i.join(`
137
137
  `),t));return r.map((e,t)=>(e?`<span class="${sC}">${oC(e)}</span>`:``)+(a[t]??``)).join(`
138
- `)}var lC=/^[a-zA-Z]:[\\/](?![\\/])/,uC=/^(?:cursor|vscode|vscode-insiders|windsurf):\/\/file\/(.*)$/i;function dC(e){try{return decodeURIComponent(e)}catch{return e}}function fC(e){if(e===`/`||e.startsWith(`/?`)||e.startsWith(`/#`))return!0;let t=e.replace(/[?#].*$/u,``);if(Yd(t))return!0;let n=Qd(t).split(`/`)[1]??``;return Gd.has(n)}function pC(e){let t=e?.trim();if(!t)return null;let n=dC(t);if(lC.test(n))return{display:n,filePath:n};if(n.startsWith(`/`)&&!n.startsWith(`//`)&&!fC(n)){let e=n;return{display:e,filePath:e}}let r=uC.exec(t);if(r){let e=dC(r[1].replace(/[?#].*$/u,``)).replace(/^\/+/,``);if(!e)return null;if(lC.test(e))return{display:e,filePath:e};let t=`/${e}`;return{display:t,filePath: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=dC(e.pathname);return{display:n,filePath:n}}catch{return{display:t}}}function mC(e){return`${tf()}/local-image?path=${encodeURIComponent(e)}`}var hC=/\.(?:png|jpe?g|gif|webp)$/i;function gC(e){return e.filePath&&hC.test(e.filePath)?mC(e.filePath):null}var _C=/\.(?:md|mdx|markdown)$/i;function vC(e){return _C.test(e.trim().replace(/:\d+(?::\d+)?$/,``))}function yC(e,t,n){let r=e?.trim();if(!r||/^[a-z][a-z0-9+.-]*:/i.test(r)||/^[\\/#?]/.test(r))return null;let i=dC(r.replace(/[?#].*$/u,``));if(!i)return null;let a=i===`~`||/^~[\\/]/.test(i);if(a&&!(n&&fp(n)))return null;let o=a?n:t;return fp(o)?gp(o,a?i.slice(2):i):null}function bC(e){return vp(e)||`/`}function xC(e){return[vC(e)?`localMarkdown`:`localFile`,e]}function SC(e){let t=vC(e);return{queryKey:xC(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 CC=2e3,wC=new Map,TC=12;function EC(e,t){let n=wC.get(e);if(n&&n.raw===t)return n.html;let r=cC(t,KS(e));if(wC.set(e,{raw:t,html:r}),wC.size>TC){let e=wC.keys().next();e.done||wC.delete(e.value)}return r}function DC(e){let t=globalThis.requestIdleCallback;t?t(e,{timeout:500}):setTimeout(e,0)}function OC(e,t){e.prefetchQuery(SC(t)).then(()=>{let n=e.getQueryData(SC(t).queryKey);!n?.markdown||vC(t)||DC(()=>EC(n.path,n.markdown))}).catch(()=>{})}var kC=null,AC=null,jC=null,MC=null,NC=0,PC=0,FC=!1,IC=!1,LC=!1,RC=new Map,zC=new Map,BC=0,VC=new px(()=>QC(),e=>{AC&&yx(AC,e)}),HC=35e3;function UC(){return`${location.origin.replace(/^http/,`ws`)}${tf()}/ws`}var WC,GC=!1;function KC(){WC=Yd(),GC=!0}function qC(e){return GC&&WC===e}function JC(){if(kC||LC)return;X.connection!==`open`&&(X.connection=`connecting`),KC();let e=new WebSocket(UC()),t=Yd();kC=e,FC=!1,PC=Date.now(),e.onopen=()=>{IC=!0,PC=Date.now(),X.connection=`open`,X.socketTranscripts=!0,jC&&=(clearTimeout(jC),null)},e.onmessage=n=>{if(!(kC!==e||t!==Yd())){PC=Date.now();try{let e=JSON.parse(n.data),t=nw(e);t&&(NC=0),t&&e.t===`event`&&e.event.type===`board`&&(FC=!0,BC++,iw())}catch(e){console.error(`bad /ws message`,e)}}},e.onerror=()=>{},e.onclose=()=>{kC===e&&(kC=null,XC())},$C()}function YC(){let e=kC;if(kC=null,FC=!1,e){e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close()}catch{}}}function XC(){if(VC.reset(),!IC){tw();return}NC++,X.connection=NC>3?`closed`:`connecting`,ZC()}function ZC(e=!1){if(jC){if(!e)return;clearTimeout(jC),jC=null}let t=e?0:Math.min(1e3*2**Math.min(NC-1,4),15e3);jC=setTimeout(()=>{jC=null,JC()},t)}function QC(){VC.reset(),YC(),JC()}function $C(){if(MC)return;MC=setInterval(()=>{kC&&Date.now()-PC>HC&&ew()},1e4);let e=()=>{LC||(!kC||Date.now()-PC>HC)&&ew(!0)};window.addEventListener(`focus`,e),window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,()=>{document.hidden||e()})}function ew(e=!1){if(!LC){if(YC(),VC.reset(),!IC){tw();return}NC++,X.connection=NC>3?`closed`:`connecting`,ZC(e)}}function tw(e){LC||(LC=!0,e&&(X.socketBoardFallback=e,X.socketTranscriptFallbacks={}),YC(),X.socketTranscripts=!1,Mx(AC??void 0))}function nw(e){switch(e.t){case`event`:return VC.handle(e.event),e.event.type===`board`&&(X.socketBoardFallback=null),!0;case`transcript`:return AC?.setQueryData([`transcript`,e.slug],t=>{let n=t,r=e.page?Yx(n,{...e.page,messages:e.messages,editedFiles:n?.editedFiles}):Xx(n,e.messages);return{...r,messages:Ux(t?.messages,Ix(t?.messages,r.messages))}}),delete X.socketTranscriptFallbacks[e.slug],!0;case`file-changed`:return AC?.invalidateQueries({queryKey:xC(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}),tw({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 rw(e){FC&&kC&&kC.readyState===WebSocket.OPEN&&kC.send(JSON.stringify(e))}function iw(){for(let e of RC.keys())X.socketTranscriptFallbacks[e]||rw({t:`sub`,topic:`transcript`,slug:e});for(let e of zC.keys())rw({t:`sub`,topic:`file`,path:e}),BC>1&&AC?.invalidateQueries({queryKey:xC(e)})}function aw(e){let t=(RC.get(e)??0)+1;RC.set(e,t),t===1&&!X.socketTranscriptFallbacks[e]&&rw({t:`sub`,topic:`transcript`,slug:e})}function ow(e){let t=(RC.get(e)??0)-1;t<=0?(RC.delete(e),rw({t:`unsub`,topic:`transcript`,slug:e})):RC.set(e,t)}function sw(e){let t=(zC.get(e)??0)+1;zC.set(e,t),t===1&&rw({t:`sub`,topic:`file`,path:e})}function cw(e){let t=(zC.get(e)??0)-1;t<=0?(zC.delete(e),rw({t:`unsub`,topic:`file`,path:e})):zC.set(e,t)}function lw(e){X.socketTranscriptFallbacks[e]&&(delete X.socketTranscriptFallbacks[e],RC.has(e)&&rw({t:`sub`,topic:`transcript`,slug:e}))}function uw(){RC.clear(),zC.clear(),VC.reset(),YC(),X.connection=`connecting`,KC(),LC?jx():JC()}function dw(e){AC=e,KC();let t=()=>JC();document.readyState===`complete`?t():window.addEventListener(`load`,t,{once:!0})}function fw(){return en(X).board}function pw(){return en(X).board?.projectDir}function mw(e){return e}function hw(e){let t=en(X).socketTranscripts;return(0,I.useEffect)(()=>(sw(e),()=>cw(e)),[e]),t}function gw(e){if(!(!e||e.kind!==`session`||e.foreign||!e.sessionId))return{slug:e.id,sessionId:e.sessionId}}function _w(e){let t=gw(e);if(!(!t||e?.pendingInteraction===!1))return t}function vw(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 yw(e){let t=_w(e);return nt({queryKey:t?hx(t.slug,t.sessionId):[`interactions`,`pending`,`unowned`],queryFn:()=>Y.pendingInteractions(t),enabled:t!==void 0,refetchInterval:e=>vw(e.state.data?.interactions??[]),refetchOnReconnect:!0,refetchOnWindowFocus:!0})}var bw=7e3,xw=5e3,Sw=3,Cw=15e3,ww=30*6e4;function Tw(e,t,n){let r=hm(e,t)?.lastActivityAt;if(!r)return 0;let i=Date.parse(r);return Number.isFinite(i)?i>n?0:Cw:0}function Ew(e,t){let n=Ve(),r=en(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=Yx(r,t);return{...i,messages:Ux(r?.messages,Ix(r?.messages,i.messages))}},refetchInterval:t.poll&&!i&&!a?1500:!1,refetchOnWindowFocus:!a,staleTime:t=>Tw(X.board,e,t.state.dataUpdatedAt),gcTime:ww});return(0,I.useEffect)(()=>{if(!t.poll&&!i||a)return;let r=!1,s=0,c,l=setInterval(()=>{if(r)return;let t=hm(X.board,e)?.lastActivityAt,a=Gx(n.getQueryData([`transcript`,e])?.messages);if(!Wx(t,a,xw)){s=0;return}if(a!==c&&(s=0),s>=Sw)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&&(ow(e),aw(e)),r=!0,o.refetch().finally(()=>{r=!1})},bw);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:()=>lw(e)}}function Dw(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 Ow(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 kw(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 Aw(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 jw(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 Mw(){let e=um();return e?`/thread/${encodeURIComponent(e)}`:X.routeThreadSlug?`/thread/${encodeURIComponent(X.routeThreadSlug)}`:X.view.startsWith(`status:`)?`/status/${encodeURIComponent(X.view.slice(7))}`:`/`}function Nw(e){try{return decodeURIComponent(e)}catch{return null}}function Pw(e,t=X.board?.projectSlug){let n=$d(e);return n===`/`&&t?Xd(t):n}function Fw(e){let t=e.match(/^\/thread\/([^/]+)$/);if(t){let e=Nw(t[1]);if(e===null){X.routeThreadSlug=null,lm(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,lm(X.drawers.slice(n+1).map(e=>e.id));return}X.routeThreadSlug=e;return}let n=e.match(/^\/status\/([^/]+)$/);if(n){X.routeThreadSlug=null,lm(X.drawers.map(e=>e.id));let e=Nw(n[1]);X.view=e===null?`todos`:`status:${e}`;return}X.routeThreadSlug=null,lm(X.drawers.map(e=>e.id)),X.view=`todos`}function Iw(e=location.pathname){Fw(Qd(e))}var Lw=null;function Rw(e){Lw=e}function zw(e,t){Lw?Lw(e,t):typeof location<`u`&&location.assign(e)}function Bw(e){return Iw(),Zt(X,()=>{if(rf(Qd())!==null)return;let t=Pw(Mw());t!==location.pathname&&e(t,{replace:!Mw().startsWith(`/thread/`)})})}function Vw(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 Hw=`frizz-sidebar-seen:`;function Uw(e){try{return localStorage.getItem(Hw+(e??``))===`1`}catch{return!1}}function Ww(e,t){try{localStorage.setItem(Hw+(e??``),t?`1`:`0`)}catch{}}function Gw(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 Kw(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 qw(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var Jw=(e,t)=>Math.abs(e-t)<1.01,Yw=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},Xw,Zw=()=>{if(Xw!==void 0)return Xw;if(typeof navigator>`u`)return Xw=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return Xw=!0;let e=navigator.maxTouchPoints;return Xw=navigator.platform===`MacIntel`&&e!==void 0&&e>0},Qw=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},$w=e=>e,eT=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},tT=(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(Qw(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(Qw(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},nT={passive:!0},rT=typeof window>`u`?!0:`onscrollend`in window,iT=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&rT,o=0,s=a?null:Yw(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,nT),a&&r.addEventListener(`scrollend`,u,nT),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},aT=(e,t)=>iT(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),oT=(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`]},sT=(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})},cT=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:$w,rangeExtractor:eT,onChange:()=>{},measureElement:oT,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=Kw(()=>(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,!(!Zw()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,nT),e.addEventListener(`touchend`,n,nT),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&&(Zw()&&(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=Kw(()=>[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=Kw(()=>[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=Gw(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=Kw(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=dT(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=Kw(()=>{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=Kw(()=>[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 qw(t[lT(0,t.length-1,r?e=>n[e*2]:e=>qw(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&&(Zw()&&(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&&Jw(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()}},lT=(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 uT(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 dT(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=uT(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=lT(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 fT=typeof document<`u`?I.useLayoutEffect:I.useEffect;function pT({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,lt.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[c]=I.useState(()=>{let e=new cT(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),fT(()=>c._didMount(),[]),fT(()=>c._willUpdate()),fT(()=>{o(c)}),c}function mT(e){return pT({observeElementRect:tT,observeElementOffset:aT,scrollToFn:sT,...e})}var hT=3600*1e3,gT=24*hT,_T=[{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`}],vT=new Set(_T.map(e=>e.value));function yT(e){return typeof e==`string`&&vT.has(e)}function bT(e){return xT(e).label}function xT(e){return _T.find(t=>t.value===e)??_T[2]}function ST(e){let t=xT(e);return t.kind===`calendar`?`Snooze until ${t.label}`:`Snooze ${t.label}`}function CT(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`?hT:e===`1d`?gT:e===`3d`?3*gT:7*gT)).toISOString()}function wT(e){return String(e).padStart(2,`0`)}function TT(e){return`${e.getFullYear()}-${wT(e.getMonth()+1)}-${wT(e.getDate())}T${wT(e.getHours())}:${wT(e.getMinutes())}`}function ET(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 DT(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)/gT),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 OT(e,t){if(!Number.isFinite(Date.parse(e)))return null;let n=DT(e,t);return n?n.replace(/^(Today|Tomorrow)/,e=>e.toLowerCase()):null}function kT(e,t=Date.now()){let n=OT(e,t);return n?`Snoozed until ${n}`:null}var AT=120;function jT(e,t=AT){let n=e.trim().replace(/\s+/g,` `);return n.length>t?`${n.slice(0,t-1)}…`:n}function MT(e,t,n=Date.now()){let r=t?.trim();if(!r)return kT(e,n);let i=NT(e,n);return i?`${i} — then: ${jT(r)}`:null}function NT(e,t=Date.now()){let n=OT(e,t);return n?`Auto-snoozed until ${n}`:null}var PT=`frizz.prefs.v1`;function FT(e,t){return e===`fifo`||e===`lifo`?e:t}function IT(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:yT(n.snoozePreset)?n.snoozePreset:t.snoozePreset,queueOrder:FT(n.queueOrder,t.queueOrder),railFilesCollapsed:typeof n.railFilesCollapsed==`boolean`?n.railFilesCollapsed:t.railFilesCollapsed}}catch{return t}}function LT(){try{return IT(typeof localStorage>`u`?null:localStorage.getItem(PT))}catch{return IT(null)}}var RT=Xt(LT());Zt(RT,()=>{try{typeof localStorage<`u`&&localStorage.setItem(PT,JSON.stringify(RT))}catch{}});function zT(e){return e.kind===`session`&&e.foreign!==!0&&e.runtime===`exited`}var BT=qc.options,VT={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 HT(e){return e.foreign===!0&&e.title.trim()?e.title.trim():YT(e)?GT:e.aiTitle?.trim()&&!UT(e)?WT(e.aiTitle):e.backend===`codex`&&e.titleAuto===!0&&!e.aiTitle?.trim()?KT:e.titleAuto===!1&&e.title.trim()?e.title:e.title.trim()&&!(e.titleAuto===!0&&e.title.trim()===e.id)?e.titleAuto===!0?WT(e.title):e.title.trim():e.titleAuto===!0?KT:e.id}function UT(e){return e.titleLocked??e.titleAuto===!1}function WT(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 GT=`Spinning up a thread…`,KT=`Untitled thread`,qT=6e4,JT=15e3;function YT(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<JT}let t=Date.parse(e.spawnedAt??``);return Number.isFinite(t)&&Date.now()-t<qT}function XT(e){return e.status===`done`||e.status===`dismissed`||uE(e)!==void 0&&dE(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 ZT(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 QT(e){if(fE(e))return ZT(e);let t=Date.parse(e.lastAssistantAt??``);return Number.isFinite(t)?t:ZT(e)}function $T(e){return fE(e)?e.lastActivityAt??e.spawnedAt:e.lastAssistantAt??e.lastActivityAt??e.spawnedAt}function eE(e){return[...e].sort((e,t)=>{let n=XT(e);if(n!==XT(t))return n?-1:1;let r=QT(t)-QT(e);return r===0?e.id.localeCompare(t.id):r})}function tE(e){return[...e].sort((e,t)=>{let n=QT(t)-QT(e);return n===0?e.id.localeCompare(t.id):n})}function nE(e,t=`fifo`){let n=t===`lifo`?-1:1;return[...e].sort((e,t)=>{let r=(QT(e)-QT(t))*n;return r===0?e.id.localeCompare(t.id):r})}function rE(e){return wu(e)}function iE(e){return e.filter(e=>e.kind===`session`&&e.foreign===!0)}function aE(e){return e.kind===`session`&&e.foreign!==!0&&typeof e.pinnedAt==`string`}function oE(e){return e.runtime===`turn-idle`||e.runtime===`exited`}function sE(e){return(e.subAgents??[]).some(e=>ol(e)&&e.state===`running`)}function cE(e){return sE(e)?!0:e.awaitingBackground===!0&&!lE(e)}function lE(e){if(e.awaitingBackground!==!0)return!1;let t=e.watches??[];return!t.some(e=>e.kind===`timer`&&e.state===`armed`)||sE(e)||(e.bgShells??[]).some(e=>e.state===`running`)?!1:!t.some(e=>e.kind===`github`&&e.state===`armed`)}function uE(e,t=Date.now()){let n=Date.parse(e.snoozedUntil??``);return Number.isFinite(n)&&n>t?e.snoozedUntil:void 0}function dE(e,t=Date.now()){let n=uE(e,t)!==void 0;if(e.state===`archived`)return!1;let r=e.bgSnoozed===!0&&e.runtime===`turn-idle`;if(sE(e)||cE(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`||!oE(e))return!1;if(r)return!0;let i=e.lastFence?.kind===`awaiting`;return n||i}function fE(e){return e.runtime===`running`||e.runtime===`spawning`?!0:e.runtime===`turn-idle`&&cE(e)}function pE(e){return e.needsYou===!0&&oE(e)}function mE(e){return e.runtime===`turn-idle`&&e.awaitingBackground===!0&&!sE(e)}function hE(e){return mE(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 gE(e){return e.runtime===`turn-idle`?_E(e):!1}function _E(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.kind===`issue`)&&e.value.trim()!==``)}function vE(e){return e.runtime===`turn-idle`?(e.watches??[]).some(e=>e.kind===`timer`&&e.state===`armed`):!1}function yE(e){let t=fE(e);return e.state===`archived`&&!t?`archived`:uE(e)!==void 0&&dE(e)?`snoozed`:e.actionableInteraction||e.pendingAsk||e.pendingQuestion||e.runtime===`perm-prompt`||e.humanBlocked||e.status===`needs-human`?`needs-input`:t&&!pE(e)&&!mE(e)?`working`:(e.questions?.length??0)>0?`needs-input`:dE(e)?`snoozed`:e.limitPause&&e.foreign!==!0?`limit`:e.lastFence?.kind===`done`&&oE(e)?`done`:gE(e)?`pr`:vE(e)?`timer`:hE(e)?`background`:zT(e)?`stalled`:`rest`}function bE(e){let t=yE(e);return t===`stalled`||t===`limit`}function xE(e){return e.kind===`session`?e.state===`archived`&&!fE(e)?`inactive`:dE(e)?`snoozed`:`active`:null}function SE(e,t=`fifo`){let n=e.filter(CE);return[...nE(e.filter(e=>!CE(e)),t),...tE(n)]}function CE(e){return e.needsYou!==!0}function wE(e){return{running:e.filter(CE),rested:e.filter(e=>!CE(e))}}function TE(e,t=`fifo`){let n={pinned:[],active:[],snoozed:[],inactive:[]};for(let t of e){if(t.kind===`session`&&t.foreign===!0)continue;if(aE(t)){n.pinned.push(t);continue}let e=xE(t);e&&n[e].push(t)}return n.pinned.sort((e,t)=>(e.pinnedAt??``).localeCompare(t.pinnedAt??``)||e.id.localeCompare(t.id)),n.active=SE(n.active,t),n.snoozed=tE(n.snoozed),n.inactive=tE(n.inactive),n}function EE(e,t){for(let n of[e,t])if(n&&Number.isFinite(Date.parse(n)))return n}function DE(e,t=Date.now()){let n=OE(e,t);return n&&`Last active ${n}`}function OE(e,t=Date.now()){let n=jE(e,t);return n===null||n===kE?n:`${n} ago`}var kE=`just now`;function AE(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 jE(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?kE:AE(r)}function ME(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 NE(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?kE:`${AE(r)} ago`}function PE(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 FE(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 IE=3e4,LE=new Set,RE=Date.now(),zE;function BE(){RE=Date.now();for(let e of LE)e();VE()}function VE(){if(LE.size===0)return;let e=IE-RE%IE;zE=setTimeout(BE,e||IE)}function HE(e){return LE.add(e),LE.size===1&&(RE=Date.now(),VE()),()=>{LE.delete(e),LE.size===0&&zE&&(clearTimeout(zE),zE=void 0)}}function UE(){return RE}function WE(){return(0,I.useSyncExternalStore)(HE,UE,UE)}function GE({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 KE(e){return e===`running`}function qE(e,t){return e===`pending`&&t===`background`}var JE=2e3;function YE(e,t){return e===`pending`&&t===void 0}function XE(e,t,n,r){if(!YE(e,t))return!1;let i=n?Date.parse(n):NaN;return Number.isFinite(i)?r-i>=JE:!0}function ZE(e){return e?.split(`
139
- `).find(e=>e.trim())?.trim().replace(/\s+/g,` `)||void 0}function QE(e,t){if(e.name===`Interrupt process`||e.status===`cancelled`||e.backgroundState!==`background`)return;let n=new Set([ZE(e.desc),ZE(e.detail),ZE(e.command)].filter(e=>!!e));if(n.size===0)return;let r=t.filter(e=>n.has(ZE(e.label)??``));return r.some(e=>e.state===`running`)?`running`:r.some(e=>e.state===`stale`)?`stale`:void 0}function $E(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 eD(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 tD(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 nD(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 rD(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?tD(t-n):``}function iD(e){if(!Number.isFinite(e)||e<0)return``;let t=Math.floor(e/6e4);return t<1?`<1m`:eD(t)}function aD(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 oD(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?eD(Math.floor((t-n)/6e4)):``}function sD(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`:`${eD(r)} ago`}var cD={fgSuccess:`#3fb950`,bgSuccessEmphasis:`#238636`,fgDanger:`#f85149`,bgDangerEmphasis:`#da3633`,fgDone:`#ab7df8`,bgDoneEmphasis:`#8957e5`,fgAttention:`#d29922`,fgNeutral:`#9198a1`,bgNeutralEmphasis:`#656c76`},lD=`shrink-0 text-[11px] leading-none text-muted/45`,uD=`frizz-kind-tag petite-caps shrink-0 text-[9.5px] text-muted/45`,dD=`flex w-[9px] shrink-0 justify-center`,fD=`block h-1.5 w-1.5 rounded-full bg-muted/30`,pD=`stale — no recent output`,mD=`block h-1.5 w-1.5 rounded-full border border-muted/45`,hD=`rested — it stopped, but the work it launched is still running`,gD=`running — no recent output`,_D={AGENT:`Open sub-agent transcript`,SHELL:`Open background shell output`,GITHUB:`Open this pull request on GitHub`};function vD(e){if(!(typeof e!=`number`||!Number.isFinite(e)||e<0))return e===1?`1 line`:`${xD(e)??`0`} lines`}function yD(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 bD(e){if(e)return e.state===`open`?e.comments>0?`${e.comments} comment${e.comments===1?``:`s`}`:void 0:e.state}function xD(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 SD={running:`Stop — end this operation and everything it spawned, then clear the row`,settled:`Clear — stop tracking this finished operation`},CD={running:`Stop`,settled:`Clear`},wD={AGENT:`sub-agent`,SHELL:`background shell`,GITHUB:`PR watcher`};function TD(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 ED=e=>e.state===`running`||e.state===`stale`||e.state===`rested`;function DD(e,t){return t===`card`?e.filter(ED):t===`rail`?e.filter(e=>!!e.id&&ED(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 kD(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 AD({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=KE(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=rD(a,WE()),b=Math.min(Math.max((i??1)-1,0),4)*13,x=p?`running`:`settled`,S=_D[e],C=f??(g?S:void 0),w=n===`rested`?(0,L.jsx)(`span`,{className:mD,title:hD}):(0,L.jsx)(`span`,{className:fD,title:pD}),T=_?(0,L.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:p?(0,L.jsx)(GE,{size:12}):w}):(0,L.jsx)(`span`,{className:`frizz-op-dot-slot ${dD}`,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:gD}):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:cD.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:lD,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:SD[x],"aria-label":`${CD[x]} ${wD[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)(Hh,{size:11})}),E]})}var jD=null,MD=5e3,ND=6;function PD(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 FD(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>=ND)))break;return n}function ID(e,t){if(jD=null,!e||typeof window>`u`)return;let n=[...e.querySelectorAll(`[data-transcript-source-id]`)];if(n.length===0)return;let r=PD(n[0],e),i=FD(n.map(e=>{let t=e.getBoundingClientRect();return{sourceId:e.dataset.transcriptSourceId,top:t.top,bottom:t.bottom}}),r);i.length!==0&&(jD={slug:t,candidates:i,at:performance.now()})}function LD(e){let t=jD;return!t||(jD=null,t.slug!==e||performance.now()-t.at>MD)?null:t}var RD=null;function zD(e,t){/\/full\/?$/.test(t)||(RD={slug:e,path:t})}function BD(e){return RD&&RD.slug===e?RD.path:null}var VD=`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 HD(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function UD(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=UD(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():UD(e[t],null)}}}}function GD(...e){return I.useCallback(WD(...e),e)}function KD(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,qD(i,...t)]}function qD(...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 JD(e){let t=I.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];nO(r)&&typeof oO==`function`&&(r=oO(r._payload)),I.Children.forEach(r,e=>{if(eO(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;nO(n)&&typeof oO==`function`&&(n=oO(n._payload)),a=ZD(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?$D(a):void 0,l=GD(n,c);if(!a){if(r||r===0)throw Error(o?aO(e):iO(e));return r}let u=QD(i,a.props??{});return a.type!==I.Fragment&&(u.ref=n?l:c),I.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}var YD=Symbol.for(`radix.slottable`);function XD(e){let t=e=>`child`in e?e.children(e.child):e.children;return t.displayName=`${e}.Slottable`,t.__radixId=YD,t}var ZD=(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 QD(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 $D(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 eO(e){return I.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===YD}var tO=Symbol.for(`react.lazy`);function nO(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===tO&&`_payload`in e&&rO(e._payload)}function rO(e){return typeof e==`object`&&!!e&&`then`in e}var iO=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,aO=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,oO=I.use,sO=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=JD(`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 cO(e,t){e&&lt.flushSync(()=>e.dispatchEvent(t))}function lO(e){let t=I.useRef(e);return I.useEffect(()=>{t.current=e}),I.useMemo(()=>((...e)=>t.current?.(...e)),[])}var uO=globalThis?.document?I.useLayoutEffect:()=>{},dO=I.useEffectEvent,fO=I.useInsertionEffect;function pO(e){if(typeof dO==`function`)return dO(e);let t=I.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof fO==`function`?fO(()=>{t.current=e}):uO(()=>{t.current=e}),I.useMemo(()=>((...e)=>t.current?.(...e)),[])}var mO=`DismissableLayer`,hO=`dismissableLayer.update`,gO=`dismissableLayer.pointerDownOutside`,_O=`dismissableLayer.focusOutside`,vO,yO=I.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),bO=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(yO),[d,f]=I.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=I.useState({}),h=GD(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=wO(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=TO(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=pO(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&&(vO=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),EO(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=vO))}},[d,p,n,u]),I.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),EO())},[d,u]),I.useEffect(()=>{let e=()=>m({});return document.addEventListener(hO,e),()=>document.removeEventListener(hO,e)},[]),(0,L.jsx)(sO.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:HD(e.onFocusCapture,w.onFocusCapture),onBlurCapture:HD(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:HD(e.onPointerDownCapture,C.onPointerDownCapture)})});bO.displayName=mO;var xO=`DismissableLayerBranch`,SO=I.forwardRef((e,t)=>{let n=I.useContext(yO),r=I.useRef(null),i=GD(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)(sO.div,{...e,ref:i})});SO.displayName=xO;function CO(){let e=I.useContext(yO),[t,n]=I.useState(null);return I.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}function wO(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a}=t,o=lO(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||DO(gO,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 TO(e,t=globalThis?.document){let n=lO(e),r=I.useRef(!1);return I.useEffect(()=>{let e=e=>{e.target&&!r.current&&DO(_O,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 EO(){let e=new CustomEvent(hO);document.dispatchEvent(e)}function DO(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?cO(i,a):i.dispatchEvent(a)}var OO=I.useId||(()=>void 0),kO=0;function AO(e){let[t,n]=I.useState(OO());return uO(()=>{e||n(e=>e??String(kO++))},[e]),e||(t?`radix-${t}`:``)}var jO=[`top`,`right`,`bottom`,`left`],MO=Math.min,NO=Math.max,PO=Math.round,FO=Math.floor,IO=e=>({x:e,y:e}),LO={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function RO(e,t,n){return NO(e,MO(t,n))}function zO(e,t){return typeof e==`function`?e(t):e}function BO(e){return e.split(`-`)[0]}function VO(e){return e.split(`-`)[1]}function HO(e){return e===`x`?`y`:`x`}function UO(e){return e===`y`?`height`:`width`}function WO(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function GO(e){return HO(WO(e))}function KO(e,t,n){n===void 0&&(n=!1);let r=VO(e),i=GO(e),a=UO(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=tk(o)),[o,tk(o)]}function qO(e){let t=tk(e);return[JO(e),t,JO(t)]}function JO(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var YO=[`left`,`right`],XO=[`right`,`left`],ZO=[`top`,`bottom`],QO=[`bottom`,`top`];function $O(e,t,n){switch(e){case`top`:case`bottom`:return n?t?XO:YO:t?YO:XO;case`left`:case`right`:return t?ZO:QO;default:return[]}}function ek(e,t,n,r){let i=VO(e),a=$O(BO(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(JO)))),a}function tk(e){let t=BO(e);return LO[t]+e.slice(t.length)}function nk(e){return{top:0,right:0,bottom:0,left:0,...e}}function rk(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:nk(e)}function ik(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 ak(e,t,n){let{reference:r,floating:i}=e,a=WO(t),o=GO(t),s=UO(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(VO(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 ok(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}=zO(t,e),p=rk(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=ik(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=ik(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 sk=50,ck=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:ok},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=ak(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<sk&&(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}=ak(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},lk=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}=zO(e,t)||{};if(l==null)return{};let d=rk(u),f={x:n,y:r},p=GO(i),m=UO(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=MO(d[_],T),D=MO(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=RO(O,A,k),M=!c.arrow&&VO(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}}}),uk=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}=zO(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?[tk(o)]:qO(o)),x=p!==`none`;!d&&x&&b.push(...ek(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=KO(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 dk(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function fk(e){return jO.some(t=>e[t]>=0)}var pk=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=zO(e,t);switch(i){case`referenceHidden`:{let e=dk(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:fk(e)}}}case`escaped`:{let e=dk(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:fk(e)}}}default:return{}}}}},mk=new Set([`left`,`top`]);async function hk(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=VO(n),c=WO(n)===`y`,l=mk.has(o)?-1:1,u=a&&c?-1:1,d=zO(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 gk=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 hk(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}}}}},_k=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}=zO(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=WO(BO(i)),p=HO(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=RO(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=RO(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}}}}}},vk=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}=zO(e,t),u={x:n,y:r},d=WO(i),f=HO(d),p=u[f],m=u[d],h=zO(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=mk.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}}}},yk=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}=zO(e,t),u=await o.detectOverflow(t,l),d=BO(i),f=VO(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=MO(h-u[g],v),x=MO(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=NO(u.left,0),t=NO(u.right,0),n=NO(u.top,0),r=NO(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:NO(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:NO(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 bk(){return typeof window<`u`}function xk(e){return wk(e)?(e.nodeName||``).toLowerCase():`#document`}function Sk(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ck(e){return((wk(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function wk(e){return bk()?e instanceof Node||e instanceof Sk(e).Node:!1}function Tk(e){return bk()?e instanceof Element||e instanceof Sk(e).Element:!1}function Ek(e){return bk()?e instanceof HTMLElement||e instanceof Sk(e).HTMLElement:!1}function Dk(e){return!bk()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Sk(e).ShadowRoot}function Ok(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=zk(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function kk(e){return/^(table|td|th)$/.test(xk(e))}function Ak(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var jk=/transform|translate|scale|rotate|perspective|filter/,Mk=/paint|layout|strict|content/,Nk=e=>!!e&&e!==`none`,Pk;function Fk(e){let t=Tk(e)?zk(e):e;return Nk(t.transform)||Nk(t.translate)||Nk(t.scale)||Nk(t.rotate)||Nk(t.perspective)||!Lk()&&(Nk(t.backdropFilter)||Nk(t.filter))||jk.test(t.willChange||``)||Mk.test(t.contain||``)}function Ik(e){let t=Vk(e);for(;Ek(t)&&!Rk(t);){if(Fk(t))return t;if(Ak(t))return null;t=Vk(t)}return null}function Lk(){return Pk??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Pk}function Rk(e){return/^(html|body|#document)$/.test(xk(e))}function zk(e){return Sk(e).getComputedStyle(e)}function Bk(e){return Tk(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Vk(e){if(xk(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Dk(e)&&e.host||Ck(e);return Dk(t)?t.host:t}function Hk(e){let t=Vk(e);return Rk(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ek(t)&&Ok(t)?t:Hk(t)}function Uk(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Hk(e),i=r===e.ownerDocument?.body,a=Sk(r);if(i){let e=Wk(a);return t.concat(a,a.visualViewport||[],Ok(r)?r:[],e&&n?Uk(e):[])}else return t.concat(r,Uk(r,[],n))}function Wk(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Gk(e){let t=zk(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Ek(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=PO(n)!==a||PO(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Kk(e){return Tk(e)?e:e.contextElement}function qk(e){let t=Kk(e);if(!Ek(t))return IO(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Gk(t),o=(a?PO(n.width):n.width)/r,s=(a?PO(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Jk=IO(0);function Yk(e){let t=Sk(e);return!Lk()||!t.visualViewport?Jk:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Xk(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Sk(e)?!1:t}function Zk(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Kk(e),o=IO(1);t&&(r?Tk(r)&&(o=qk(r)):o=qk(e));let s=Xk(a,n,r)?Yk(a):IO(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=Sk(a),t=r&&Tk(r)?Sk(r):r,n=e,i=Wk(n);for(;i&&r&&t!==n;){let e=qk(i),t=i.getBoundingClientRect(),r=zk(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=Sk(i),i=Wk(n)}}return ik({width:u,height:d,x:c,y:l})}function Qk(e,t){let n=Bk(e).scrollLeft;return t?t.left+n:Zk(Ck(e)).left+n}function $k(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-Qk(e,n),y:n.top+t.scrollTop}}function eA(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Ck(r),s=t?Ak(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=IO(1),u=IO(0),d=Ek(r);if((d||!d&&!a)&&((xk(r)!==`body`||Ok(o))&&(c=Bk(r)),d)){let e=Zk(r);l=qk(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?$k(o,c):IO(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 tA(e){return Array.from(e.getClientRects())}function nA(e){let t=Ck(e),n=Bk(e),r=e.ownerDocument.body,i=NO(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=NO(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+Qk(e),s=-n.scrollTop;return zk(r).direction===`rtl`&&(o+=NO(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var rA=25;function iA(e,t){let n=Sk(e),r=Ck(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Lk();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=Qk(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<=rA&&(a-=o)}else l<=rA&&(a+=l);return{width:a,height:o,x:s,y:c}}function aA(e,t){let n=Zk(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Ek(e)?qk(e):IO(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function oA(e,t,n){let r;if(t===`viewport`)r=iA(e,n);else if(t===`document`)r=nA(Ck(e));else if(Tk(t))r=aA(t,n);else{let n=Yk(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return ik(r)}function sA(e,t){let n=Vk(e);return n===t||!Tk(n)||Rk(n)?!1:zk(n).position===`fixed`||sA(n,t)}function cA(e,t){let n=t.get(e);if(n)return n;let r=Uk(e,[],!1).filter(e=>Tk(e)&&xk(e)!==`body`),i=null,a=zk(e).position===`fixed`,o=a?Vk(e):e;for(;Tk(o)&&!Rk(o);){let t=zk(o),n=Fk(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||Ok(o)&&!n&&sA(e,o))?r=r.filter(e=>e!==o):i=t,o=Vk(o)}return t.set(e,r),r}function lA(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Ak(t)?[]:cA(t,this._c):[].concat(n),r],o=oA(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=oA(t,a[e],i);s=NO(n.top,s),c=MO(n.right,c),l=MO(n.bottom,l),u=NO(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function uA(e){let{width:t,height:n}=Gk(e);return{width:t,height:n}}function dA(e,t,n){let r=Ek(t),i=Ck(t),a=n===`fixed`,o=Zk(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=IO(0);function l(){c.x=Qk(i)}if(r||!r&&!a)if((xk(t)!==`body`||Ok(i))&&(s=Bk(t)),r){let e=Zk(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?$k(i,s):IO(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 fA(e){return zk(e).position===`static`}function pA(e,t){if(!Ek(e)||zk(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Ck(e)===n&&(n=n.ownerDocument.body),n}function mA(e,t){let n=Sk(e);if(Ak(e))return n;if(!Ek(e)){let t=Vk(e);for(;t&&!Rk(t);){if(Tk(t)&&!fA(t))return t;t=Vk(t)}return n}let r=pA(e,t);for(;r&&kk(r)&&fA(r);)r=pA(r,t);return r&&Rk(r)&&fA(r)&&!Fk(r)?n:r||Ik(e)||n}var hA=async function(e){let t=this.getOffsetParent||mA,n=this.getDimensions,r=await n(e.floating);return{reference:dA(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function gA(e){return zk(e).direction===`rtl`}var _A={convertOffsetParentRelativeRectToViewportRelativeRect:eA,getDocumentElement:Ck,getClippingRect:lA,getOffsetParent:mA,getElementRects:hA,getClientRects:tA,getDimensions:uA,getScale:qk,isElement:Tk,isRTL:gA};function vA(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function yA(e,t){let n=null,r,i=Ck(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=FO(d),h=FO(i.clientWidth-(u+f)),g=FO(i.clientHeight-(d+p)),_=FO(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:NO(0,MO(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&&!vA(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 bA(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=Kk(e),u=i||a?[...l?Uk(l):[],...t?Uk(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?yA(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?Zk(e):null;c&&g();function g(){let t=Zk(e);h&&!vA(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 xA=gk,SA=_k,CA=uk,wA=yk,TA=pk,EA=lk,DA=vk,OA=(e,t,n)=>{let r=new Map,i={platform:_A,...n},a={...i.platform,_c:r};return ck(e,t,{...i,platform:a})},kA=typeof document<`u`?I.useLayoutEffect:function(){};function AA(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(!AA(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)&&!AA(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function jA(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function MA(e,t){let n=jA(e);return Math.round(t*n)/n}function NA(e){let t=I.useRef(e);return kA(()=>{t.current=e}),t}function PA(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);AA(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=NA(c),D=NA(i),O=NA(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&&!AA(w.current,t)&&(w.current=t,lt.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);kA(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=I.useRef(!1);kA(()=>(A.current=!0,()=>{A.current=!1}),[]),kA(()=>{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=MA(M.floating,u.x),r=MA(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...jA(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 FA=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?{}:EA({element:r.current,padding:i}).fn(n):r?EA({element:r,padding:i}).fn(n):{}}}},IA=(e,t)=>{let n=xA(e);return{name:n.name,fn:n.fn,options:[e,t]}},LA=(e,t)=>{let n=SA(e);return{name:n.name,fn:n.fn,options:[e,t]}},RA=(e,t)=>({fn:DA(e).fn,options:[e,t]}),zA=(e,t)=>{let n=CA(e);return{name:n.name,fn:n.fn,options:[e,t]}},BA=(e,t)=>{let n=wA(e);return{name:n.name,fn:n.fn,options:[e,t]}},VA=(e,t)=>{let n=TA(e);return{name:n.name,fn:n.fn,options:[e,t]}},HA=(e,t)=>{let n=FA(e);return{name:n.name,fn:n.fn,options:[e,t]}},UA=`Arrow`,WA=I.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,L.jsx)(sO.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=UA;var GA=WA;function KA(e){let[t,n]=I.useState(void 0);return uO(()=>{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 qA=`Popper`,[JA,YA]=KD(qA),[XA,ZA]=JA(qA),QA=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null),[a,o]=I.useState(void 0);return(0,L.jsx)(XA,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};QA.displayName=qA;var $A=`PopperAnchor`,ej=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=ZA($A,n),o=I.useRef(null),s=a.onAnchorChange,c=GD(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&&uj(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,L.jsx)(sO.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})});ej.displayName=$A;var tj=`PopperContent`,[nj,rj]=JA(tj),ij=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=ZA(tj,n),[_,v]=I.useState(null),y=GD(t,v),[b,x]=I.useState(null),S=KA(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(cj),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=PA({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>bA(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[IA({mainAxis:i+w,alignmentAxis:o}),c&&LA({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?RA():void 0,...k}),c&&zA({...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&&HA({element:b,padding:s}),lj({arrowWidth:C,arrowHeight:w}),f&&VA({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ee=g.setPlacementState;uO(()=>(ee(M),()=>{ee(void 0)}),[M,ee]);let[F,te]=uj(M),ne=lO(m);uO(()=>{N&&ne?.()},[N,ne]);let re=P.arrow?.x,ie=P.arrow?.y,ae=P.arrow?.centerOffset!==0,[oe,se]=I.useState();return uO(()=>{_&&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)(nj,{scope:n,placedSide:F,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,L.jsx)(sO.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});ij.displayName=tj;var aj=`PopperArrow`,oj={top:`bottom`,right:`left`,bottom:`top`,left:`right`},sj=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=rj(aj,n),a=oj[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)(GA,{...r,ref:t,style:{...r.style,display:`block`}})})});sj.displayName=aj;function cj(e){return e!==null}var lj=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]=uj(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 uj(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var dj=QA,fj=ej,pj=ij,mj=sj,hj=`Portal`,gj=I.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=I.useState(!1);uO(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?lt.createPortal((0,L.jsx)(sO.div,{...r,ref:t}),o):null});gj.displayName=hj;function _j(e,t){return I.useReducer((e,n)=>t[e][n]??e,e)}var vj=e=>{let{present:t,children:n}=e,r=yj(t),i=typeof n==`function`?n({present:r.isPresent}):I.Children.only(n),a=xj(r.ref,Cj(i));return typeof n==`function`||r.isPresent?I.cloneElement(i,{ref:a}):null};vj.displayName=`Presence`;function yj(e){let[t,n]=I.useState(),r=I.useRef(null),i=I.useRef(e),a=I.useRef(`none`),[o,s]=_j(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return I.useEffect(()=>{let e=Sj(r.current);a.current=o===`mounted`?e:`none`},[o]),uO(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=Sj(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),uO(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=Sj(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=Sj(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 bj(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function xj(...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=bj(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():bj(n[e],null)}}},[])}function Sj(e){return e?.animationName||`none`}function Cj(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 wj=I.useInsertionEffect||uO;function Tj({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=Ej({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=Dj(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function Ej({defaultProp:e,onChange:t}){let[n,r]=I.useState(e),i=I.useRef(n),a=I.useRef(t);return wj(()=>{a.current=t},[t]),I.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function Dj(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`}),kj=`VisuallyHidden`,Aj=I.forwardRef((e,t)=>(0,L.jsx)(sO.span,{...e,ref:t,style:{...Oj,...e.style}}));Aj.displayName=kj;var jj=Aj,[Mj,Nj]=KD(`Tooltip`,[YA]),Pj=YA(),Fj=`TooltipProvider`,Ij=700,Lj=`tooltip.open`,[Rj,zj]=Mj(Fj),Bj=e=>{let{__scopeTooltip:t,delayDuration:n=Ij,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)(Rj,{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=Fj;var Vj=`Tooltip`,[Hj,Uj]=Mj(Vj),Wj=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=zj(Vj,e.__scopeTooltip),l=Pj(t),[u,d]=I.useState(null),f=AO(),p=I.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=I.useRef(!1),[_,v]=Tj({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(Lj))):c.onClose(),a?.(e)},caller:Vj}),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)(dj,{...l,children:(0,L.jsx)(Hj,{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=Vj;var Gj=`TooltipTrigger`,Kj=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Uj(Gj,n),a=zj(Gj,n),o=Pj(n),s=GD(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)(fj,{asChild:!0,...o,children:(0,L.jsx)(sO.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:HD(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:HD(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:HD(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:HD(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:HD(e.onBlur,i.onClose),onClick:HD(e.onClick,i.onClose)})})});Kj.displayName=Gj;var qj=`TooltipPortal`,[Jj,Yj]=Mj(qj,{forceMount:void 0}),Xj=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=Uj(qj,t);return(0,L.jsx)(Jj,{scope:t,forceMount:n,children:(0,L.jsx)(vj,{present:n||a.open,children:(0,L.jsx)(gj,{asChild:!0,container:i,children:r})})})};Xj.displayName=qj;var Zj=`TooltipContent`,Qj=I.forwardRef((e,t)=>{let n=Yj(Zj,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=Uj(Zj,e.__scopeTooltip);return(0,L.jsx)(vj,{present:r||o.open,children:o.disableHoverableContent?(0,L.jsx)(rM,{side:i,...a,ref:t}):(0,L.jsx)($j,{side:i,...a,ref:t})})}),$j=I.forwardRef((e,t)=>{let n=Uj(Zj,e.__scopeTooltip),r=zj(Zj,e.__scopeTooltip),i=I.useRef(null),a=GD(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=sM(r,oM(r,n.getBoundingClientRect())),a=cM(t.getBoundingClientRect()),o=uM([...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=!lM(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,L.jsx)(rM,{...e,ref:a})}),[eM,tM]=Mj(Vj,{isInside:!1}),nM=XD(`TooltipContent`),rM=I.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=Uj(Zj,n),l=Pj(n),{onClose:u}=c;return I.useEffect(()=>(document.addEventListener(Lj,u),()=>document.removeEventListener(Lj,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)(bO,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,L.jsxs)(pj,{"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)(nM,{children:r}),(0,L.jsx)(eM,{scope:n,isInside:!0,children:(0,L.jsx)(jj,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Qj.displayName=Zj;var iM=`TooltipArrow`,aM=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Pj(n);return tM(iM,n).isInside?null:(0,L.jsx)(mj,{...i,...r,ref:t})});aM.displayName=iM;function oM(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 sM(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 cM(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 lM(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 uM(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)),dM(t)}function dM(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 fM=Bj,pM=Wj,mM=Kj,hM=Xj,gM=Qj,_M=aM,vM=`isolate bg-elevated opacity-100 border border-border shadow-2xl shadow-black/40`,yM=`z-[110]`,bM=`${yM} ${vM}`,xM=`z-[250]`,SM=`z-[250]`;function CM({children:e}){return(0,L.jsx)(fM,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!0,children:e})}function wM({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,lt.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)(pM,{open:s&&!a,onOpenChange:c,children:[(0,L.jsx)(mM,{asChild:!0,children:d}),(0,L.jsx)(hM,{children:(0,L.jsxs)(gM,{id:l,side:n,sideOffset:5,collisionPadding:12,className:`${SM} 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)(_M,{className:`fill-elevated`})]})})]})}function TM({slug:e,size:t=14,className:n,label:r=`Open fullscreen`}){let i=nf(e);function a(t){if(t.stopPropagation(),!af(t))return;t.preventDefault();let n=!Dp(),r=t.currentTarget.closest(`[data-vt-chat]`);ID(r,e),typeof location<`u`&&zD(e,location.pathname),n&&r&&(r.style.viewTransitionName=`thread-chat`,Od(r)),zw(i,{viewTransition:n})}return(0,L.jsx)(wM,{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)(gh,{size:t})})})}function EM(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 DM(e,t,n=`AGENT`){if(!t.id||!ol(t)||t.state===`running`&&!t.stoppable)return;let r=t.id;return()=>EM(e,r,n)}function OM(e){let t=e+`CollectionProvider`,[n,r]=KD(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=JD(s),l=I.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=GD(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=JD(u),p=I.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=I.useRef(null),s=GD(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 kM=I.createContext(void 0);function AM(e){let t=I.useContext(kM);return e||t||`ltr`}var jM=0,MM=null;function NM(){I.useEffect(()=>{MM||={start:PM(),end:PM()};let{start:e,end:t}=MM;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),jM++,()=>{jM===1&&(MM?.start.remove(),MM?.end.remove(),MM=null),jM=Math.max(0,jM-1)}},[])}function PM(){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 FM=`focusScope.autoFocusOnMount`,IM=`focusScope.autoFocusOnUnmount`,LM={bubbles:!1,cancelable:!0},RM=`FocusScope`,zM=I.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=I.useState(null),l=lO(i),u=lO(a),d=I.useRef(null),f=GD(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:KM(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||KM(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&KM(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){qM.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(FM,LM);s.addEventListener(FM,l),s.dispatchEvent(t),t.defaultPrevented||(BM(XM(HM(s)),{select:!0}),document.activeElement===e&&KM(s))}return()=>{s.removeEventListener(FM,l),setTimeout(()=>{let t=new CustomEvent(IM,LM);s.addEventListener(IM,u),s.dispatchEvent(t),t.defaultPrevented||KM(e??document.body,{select:!0}),s.removeEventListener(IM,u),qM.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]=VM(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&KM(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&KM(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,L.jsx)(sO.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});zM.displayName=RM;function BM(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(KM(r,{select:t}),document.activeElement!==n)return}function VM(e){let t=HM(e);return[UM(t,e),UM(t.reverse(),e)]}function HM(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 UM(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 GM(e){return e instanceof HTMLInputElement&&`select`in e}function KM(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&GM(e)&&t&&e.select()}}var qM=JM();function JM(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=YM(e,t),e.unshift(t)},remove(t){e=YM(e,t),e[0]?.resume()}}}function YM(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function XM(e){return e.filter(e=>e.tagName!==`A`)}var ZM=`rovingFocusGroup.onEntryFocus`,QM={bubbles:!1,cancelable:!0},$M=`RovingFocusGroup`,[eN,tN,nN]=OM($M),[rN,iN]=KD($M,[nN]),[aN,oN]=rN($M),sN=I.forwardRef((e,t)=>(0,L.jsx)(eN.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,L.jsx)(eN.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,L.jsx)(cN,{...e,ref:t})})}));sN.displayName=$M;var cN=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=GD(t,f),m=AM(a),[h,g]=Tj({prop:o,defaultProp:s??null,onChange:c,caller:$M}),[_,v]=I.useState(!1),y=lO(l),b=tN(n),x=I.useRef(!1),[S,C]=I.useState(0);return I.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(ZM,y),()=>e.removeEventListener(ZM,y)},[y]),(0,L.jsx)(aN,{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)(sO.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:HD(e.onMouseDown,()=>{x.current=!0}),onFocus:HD(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(ZM,QM);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);mN([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:HD(e.onBlur,()=>v(!1))})})}),lN=`RovingFocusGroupItem`,uN=I.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=AO(),l=a||c,u=oN(lN,n),d=u.currentTabStopId===l,f=tN(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return I.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,L.jsx)(eN.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,L.jsx)(sO.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:HD(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:HD(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:HD(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=pN(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?hN(n,r+1):n.slice(r+1)}setTimeout(()=>mN(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});uN.displayName=lN;var dN={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function fN(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function pN(e,t,n){let r=fN(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return dN[r]}function mN(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function hN(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var gN=sN,_N=uN,vN=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},yN=new WeakMap,bN=new WeakMap,xN={},SN=0,CN=function(e){return e&&(e.host||CN(e.parentNode))},wN=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=CN(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})},TN=function(e,t,n,r){var i=wN(t,Array.isArray(e)?e:[e]);xN[n]||(xN[n]=new WeakMap);var a=xN[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=(yN.get(e)||0)+1,l=(a.get(e)||0)+1;yN.set(e,c),a.set(e,l),o.push(e),c===1&&i&&bN.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(),SN++,function(){o.forEach(function(e){var t=yN.get(e)-1,i=a.get(e)-1;yN.set(e,t),a.set(e,i),t||(bN.has(e)||e.removeAttribute(r),bN.delete(e)),i||e.removeAttribute(n)}),SN--,SN||(yN=new WeakMap,yN=new WeakMap,bN=new WeakMap,xN={})}},EN=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||vN(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),TN(r,i,n,`aria-hidden`)):function(){return null}},DN=function(){return DN=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},DN.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 kN(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 AN=`right-scroll-bar-position`,jN=`width-before-scroll-bar`,MN=`with-scroll-bars-hidden`,NN=`--removed-body-scroll-bar-size`;function PN(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function FN(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 IN=typeof window<`u`?I.useLayoutEffect:I.useEffect,LN=new WeakMap;function RN(e,t){var n=FN(t||null,function(t){return e.forEach(function(e){return PN(e,t)})});return IN(function(){var t=LN.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||PN(e,null)}),i.forEach(function(e){r.has(e)||PN(e,a)})}LN.set(n,e)},[e]),n}function zN(e){return e}function BN(e,t){t===void 0&&(t=zN);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 VN(e){e===void 0&&(e={});var t=BN(null);return t.options=DN({async:!0,ssr:!1},e),t}var HN=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,DN({},n))};HN.isSideCarExport=!0;function UN(e,t){return e.useMedium(t),HN}var WN=VN(),GN=function(){},KN=I.forwardRef(function(e,t){var n=I.useRef(null),r=I.useState({onScrollCapture:GN,onWheelCapture:GN,onTouchMoveCapture:GN}),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=RN([n,t]),C=DN(DN({},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),DN(DN({},C),{ref:S})):I.createElement(v,DN({},C,{className:c,ref:S}),s))});KN.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},KN.classNames={fullWidth:jN,zeroRight:AN};var qN,JN=function(){if(qN)return qN;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function YN(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=JN();return t&&e.setAttribute(`nonce`,t),e}function XN(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function ZN(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var QN=function(){var e=0,t=null;return{add:function(n){e==0&&(t=YN())&&(XN(t,n),ZN(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},$N=function(){var e=QN();return function(t,n){I.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},eP=function(){var e=$N();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},tP={left:0,top:0,right:0,gap:0},nP=function(e){return parseInt(e||``,10)||0},rP=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[nP(n),nP(r),nP(i)]},iP=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return tP;var t=rP(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])}},aP=eP(),oP=`data-scroll-locked`,sP=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
- .${MN} {
138
+ `)}var lC=/^[a-zA-Z]:[\\/](?![\\/])/,uC=/^(?:cursor|vscode|vscode-insiders|windsurf):\/\/file\/(.*)$/i;function dC(e){try{return decodeURIComponent(e)}catch{return e}}function fC(e){if(e===`/`||e.startsWith(`/?`)||e.startsWith(`/#`))return!0;let t=e.replace(/[?#].*$/u,``);if(Yd(t))return!0;let n=Qd(t).split(`/`)[1]??``;return Gd.has(n)}function pC(e){let t=e?.trim();if(!t)return null;let n=dC(t);if(lC.test(n))return{display:n,filePath:n};if(n.startsWith(`/`)&&!n.startsWith(`//`)&&!fC(n)){let e=n;return{display:e,filePath:e}}let r=uC.exec(t);if(r){let e=dC(r[1].replace(/[?#].*$/u,``)).replace(/^\/+/,``);if(!e)return null;if(lC.test(e))return{display:e,filePath:e};let t=`/${e}`;return{display:t,filePath: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=dC(e.pathname);return{display:n,filePath:n}}catch{return{display:t}}}function mC(e){return`${tf()}/local-image?path=${encodeURIComponent(e)}`}var hC=/\.(?:png|jpe?g|gif|webp)$/i;function gC(e){return e.filePath&&hC.test(e.filePath)?mC(e.filePath):null}var _C=/\.(?:md|mdx|markdown)$/i;function vC(e){return _C.test(e.trim().replace(/:\d+(?::\d+)?$/,``))}function yC(e,t,n){let r=e?.trim();if(!r||/^[a-z][a-z0-9+.-]*:/i.test(r)||/^[\\/#?]/.test(r))return null;let i=dC(r.replace(/[?#].*$/u,``));if(!i)return null;let a=i===`~`||/^~[\\/]/.test(i);if(a&&!(n&&fp(n)))return null;let o=a?n:t;return fp(o)?gp(o,a?i.slice(2):i):null}function bC(e){return vp(e)||`/`}function xC(e){return[vC(e)?`localMarkdown`:`localFile`,e]}function SC(e){let t=vC(e);return{queryKey:xC(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 CC=2e3,wC=new Map,TC=12;function EC(e,t){let n=wC.get(e);if(n&&n.raw===t)return n.html;let r=cC(t,KS(e));if(wC.set(e,{raw:t,html:r}),wC.size>TC){let e=wC.keys().next();e.done||wC.delete(e.value)}return r}function DC(e){let t=globalThis.requestIdleCallback;t?t(e,{timeout:500}):setTimeout(e,0)}function OC(e,t){e.prefetchQuery(SC(t)).then(()=>{let n=e.getQueryData(SC(t).queryKey);!n?.markdown||vC(t)||DC(()=>EC(n.path,n.markdown))}).catch(()=>{})}var kC=null,AC=null,jC=null,MC=null,NC=0,PC=0,FC=!1,IC=!1,LC=!1,RC=new Map,zC=new Map,BC=0,VC=new px(()=>QC(),e=>{AC&&yx(AC,e)}),HC=35e3;function UC(){return`${location.origin.replace(/^http/,`ws`)}${tf()}/ws`}var WC,GC=!1;function KC(){WC=Yd(),GC=!0}function qC(e){return GC&&WC===e}function JC(){if(kC||LC)return;X.connection!==`open`&&(X.connection=`connecting`),KC();let e=new WebSocket(UC()),t=Yd();kC=e,FC=!1,PC=Date.now(),e.onopen=()=>{IC=!0,PC=Date.now(),X.connection=`open`,X.socketTranscripts=!0,jC&&=(clearTimeout(jC),null)},e.onmessage=n=>{if(!(kC!==e||t!==Yd())){PC=Date.now();try{let e=JSON.parse(n.data),t=nw(e);t&&(NC=0),t&&e.t===`event`&&e.event.type===`board`&&(FC=!0,BC++,sw())}catch(e){console.error(`bad /ws message`,e)}}},e.onerror=()=>{},e.onclose=()=>{kC===e&&(kC=null,XC())},$C()}function YC(){let e=kC;if(kC=null,FC=!1,e){e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close()}catch{}}}function XC(){if(VC.reset(),!IC){tw();return}NC++,X.connection=NC>3?`closed`:`connecting`,ZC()}function ZC(e=!1){if(jC){if(!e)return;clearTimeout(jC),jC=null}let t=e?0:Math.min(1e3*2**Math.min(NC-1,4),15e3);jC=setTimeout(()=>{jC=null,JC()},t)}function QC(){VC.reset(),YC(),JC()}function $C(){if(MC)return;MC=setInterval(()=>{kC&&Date.now()-PC>HC&&ew()},1e4);let e=()=>{LC||(!kC||Date.now()-PC>HC)&&ew(!0)};window.addEventListener(`focus`,e),window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,()=>{document.hidden||e()})}function ew(e=!1){if(!LC){if(YC(),VC.reset(),!IC){tw();return}NC++,X.connection=NC>3?`closed`:`connecting`,ZC(e)}}function tw(e){LC||(LC=!0,e&&(X.socketBoardFallback=e,X.socketTranscriptFallbacks={}),YC(),X.socketTranscripts=!1,Mx(AC??void 0))}function nw(e){switch(e.t){case`event`:return VC.handle(e.event),e.event.type===`board`&&(X.socketBoardFallback=null),!0;case`transcript`:return AC?.setQueryData([`transcript`,e.slug],t=>{let n=t,r=e.page?Yx(n,{...e.page,messages:e.messages,editedFiles:n?.editedFiles}):Xx(n,e.messages);return{...r,messages:Ux(t?.messages,Ix(t?.messages,r.messages))}}),delete X.socketTranscriptFallbacks[e.slug],!0;case`file-changed`:return AC?.invalidateQueries({queryKey:xC(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}),tw({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},_w(e.slug,e.retryAfterMs),!1;case`hb`:return!0}}function rw(e){FC&&kC&&kC.readyState===WebSocket.OPEN&&kC.send(JSON.stringify(e))}var iw=6,aw=700,ow=null;function sw(){for(let e of Object.keys(X.socketTranscriptFallbacks))delete X.socketTranscriptFallbacks[e];for(let e of hw.keys())vw(e);gw.clear(),ow&&=(clearTimeout(ow),null);let e=[...RC.keys()],t=()=>{ow=null;for(let t of e.splice(0,iw))RC.has(t)&&!X.socketTranscriptFallbacks[t]&&rw({t:`sub`,topic:`transcript`,slug:t});e.length&&(ow=setTimeout(t,aw))};t();for(let e of zC.keys())rw({t:`sub`,topic:`file`,path:e}),BC>1&&AC?.invalidateQueries({queryKey:xC(e)})}function cw(e){let t=(RC.get(e)??0)+1;RC.set(e,t),t===1&&!X.socketTranscriptFallbacks[e]&&rw({t:`sub`,topic:`transcript`,slug:e})}function lw(e){let t=(RC.get(e)??0)-1;t<=0?(RC.delete(e),rw({t:`unsub`,topic:`transcript`,slug:e})):RC.set(e,t)}function uw(e){let t=(zC.get(e)??0)+1;zC.set(e,t),t===1&&rw({t:`sub`,topic:`file`,path:e})}function dw(e){let t=(zC.get(e)??0)-1;t<=0?(zC.delete(e),rw({t:`unsub`,topic:`file`,path:e})):zC.set(e,t)}function fw(e){X.socketTranscriptFallbacks[e]&&(vw(e),delete X.socketTranscriptFallbacks[e],RC.has(e)&&rw({t:`sub`,topic:`transcript`,slug:e}))}var pw=5,mw=400,hw=new Map,gw=new Map;function _w(e,t){let n=gw.get(e)??0;if(n>=pw)return;vw(e);let r=Math.max(1,t)+Math.random()*mw;hw.set(e,setTimeout(()=>{hw.delete(e),gw.set(e,n+1);let t=X.socketTranscriptFallbacks[e];!t||t.kind!==`read-budget`||(delete X.socketTranscriptFallbacks[e],RC.has(e)&&rw({t:`sub`,topic:`transcript`,slug:e}))},r))}function vw(e){let t=hw.get(e);t&&(clearTimeout(t),hw.delete(e))}function yw(){RC.clear(),zC.clear(),VC.reset(),YC(),X.connection=`connecting`,KC(),LC?jx():JC()}function bw(e){AC=e,KC();let t=()=>JC();document.readyState===`complete`?t():window.addEventListener(`load`,t,{once:!0})}function xw(){return en(X).board}function Sw(){return en(X).board?.projectDir}function Cw(e){return e}function ww(e){let t=en(X).socketTranscripts;return(0,I.useEffect)(()=>(uw(e),()=>dw(e)),[e]),t}function Tw(e){if(!(!e||e.kind!==`session`||e.foreign||!e.sessionId))return{slug:e.id,sessionId:e.sessionId}}function Ew(e){let t=Tw(e);if(!(!t||e?.pendingInteraction===!1))return t}function Dw(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 Ow(e){let t=Ew(e);return nt({queryKey:t?hx(t.slug,t.sessionId):[`interactions`,`pending`,`unowned`],queryFn:()=>Y.pendingInteractions(t),enabled:t!==void 0,refetchInterval:e=>Dw(e.state.data?.interactions??[]),refetchOnReconnect:!0,refetchOnWindowFocus:!0})}var kw=7e3,Aw=5e3,jw=3,Mw=15e3,Nw=30*6e4;function Pw(e,t,n){let r=hm(e,t)?.lastActivityAt;if(!r)return 0;let i=Date.parse(r);return Number.isFinite(i)?i>n?0:Mw:0}function Fw(e,t){let n=t?Date.parse(t):NaN,r=e&&e>0?e:NaN;return!Number.isFinite(n)&&!Number.isFinite(r)?t:new Date(Math.max(Number.isFinite(n)?n:0,Number.isFinite(r)?r:0)).toISOString()}function Iw(e,t){let n=Ve(),r=en(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=Yx(r,t);return{...i,messages:Ux(r?.messages,Ix(r?.messages,i.messages))}},refetchInterval:t.poll&&!i&&!a?1500:!1,refetchOnWindowFocus:!0,staleTime:t=>Pw(X.board,e,t.state.dataUpdatedAt),gcTime:Nw});return(0,I.useEffect)(()=>{if(!t.poll&&!i||a)return;let r=!1,s=0,c,l=setInterval(()=>{if(r)return;let t=hm(X.board,e)?.lastActivityAt,a=n.getQueryState([`transcript`,e]),l=Gx(a?.data?.messages);if(!Wx(t,Fw(a?.dataUpdatedAt,l),Aw)){s=0;return}if(l!==c&&(s=0),s>=jw)return;s++,c=l;let u=t?Date.parse(t)-(l?Date.parse(l):0):0;console.warn(`[frizz] transcript watchdog: stale view — self-healing`,{slug:e,lagMs:u,transport:i?`socket`:`poll`,attempt:s}),i&&(lw(e),cw(e)),r=!0,o.refetch().finally(()=>{r=!1})},kw);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:()=>fw(e)}}function Lw(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 Rw(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 zw(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 Bw(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 Vw(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 Hw(){let e=um();return e?`/thread/${encodeURIComponent(e)}`:X.routeThreadSlug?`/thread/${encodeURIComponent(X.routeThreadSlug)}`:X.view.startsWith(`status:`)?`/status/${encodeURIComponent(X.view.slice(7))}`:`/`}function Uw(e){try{return decodeURIComponent(e)}catch{return null}}function Ww(e,t=X.board?.projectSlug){let n=$d(e);return n===`/`&&t?Xd(t):n}function Gw(e){let t=e.match(/^\/thread\/([^/]+)$/);if(t){let e=Uw(t[1]);if(e===null){X.routeThreadSlug=null,lm(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,lm(X.drawers.slice(n+1).map(e=>e.id));return}X.routeThreadSlug=e;return}let n=e.match(/^\/status\/([^/]+)$/);if(n){X.routeThreadSlug=null,lm(X.drawers.map(e=>e.id));let e=Uw(n[1]);X.view=e===null?`todos`:`status:${e}`;return}X.routeThreadSlug=null,lm(X.drawers.map(e=>e.id)),X.view=`todos`}function Kw(e=location.pathname){Gw(Qd(e))}var qw=null;function Jw(e){qw=e}function Yw(e,t){qw?qw(e,t):typeof location<`u`&&location.assign(e)}function Xw(e){return Kw(),Zt(X,()=>{if(rf(Qd())!==null)return;let t=Ww(Hw());t!==location.pathname&&e(t,{replace:!Hw().startsWith(`/thread/`)})})}function Zw(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 Qw=`frizz-sidebar-seen:`;function $w(e){try{return localStorage.getItem(Qw+(e??``))===`1`}catch{return!1}}function eT(e,t){try{localStorage.setItem(Qw+(e??``),t?`1`:`0`)}catch{}}function tT(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 nT(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 rT(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var iT=(e,t)=>Math.abs(e-t)<1.01,aT=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},oT,sT=()=>{if(oT!==void 0)return oT;if(typeof navigator>`u`)return oT=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return oT=!0;let e=navigator.maxTouchPoints;return oT=navigator.platform===`MacIntel`&&e!==void 0&&e>0},cT=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},lT=e=>e,uT=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},dT=(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(cT(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(cT(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},fT={passive:!0},pT=typeof window>`u`?!0:`onscrollend`in window,mT=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&pT,o=0,s=a?null:aT(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,fT),a&&r.addEventListener(`scrollend`,u,fT),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},hT=(e,t)=>mT(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),gT=(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`]},_T=(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})},vT=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:lT,rangeExtractor:uT,onChange:()=>{},measureElement:gT,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=nT(()=>(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,!(!sT()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,fT),e.addEventListener(`touchend`,n,fT),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&&(sT()&&(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=nT(()=>[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=nT(()=>[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=tT(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=nT(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=xT(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=nT(()=>{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=nT(()=>[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 rT(t[yT(0,t.length-1,r?e=>n[e*2]:e=>rT(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&&(sT()&&(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&&iT(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()}},yT=(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 bT(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 xT(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=bT(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=yT(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 ST=typeof document<`u`?I.useLayoutEffect:I.useEffect;function CT({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,lt.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[c]=I.useState(()=>{let e=new vT(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),ST(()=>c._didMount(),[]),ST(()=>c._willUpdate()),ST(()=>{o(c)}),c}function wT(e){return CT({observeElementRect:dT,observeElementOffset:hT,scrollToFn:_T,...e})}var TT=3600*1e3,ET=24*TT,DT=[{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`}],OT=new Set(DT.map(e=>e.value));function kT(e){return typeof e==`string`&&OT.has(e)}function AT(e){return jT(e).label}function jT(e){return DT.find(t=>t.value===e)??DT[2]}function MT(e){let t=jT(e);return t.kind===`calendar`?`Snooze until ${t.label}`:`Snooze ${t.label}`}function NT(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`?TT:e===`1d`?ET:e===`3d`?3*ET:7*ET)).toISOString()}function PT(e){return String(e).padStart(2,`0`)}function FT(e){return`${e.getFullYear()}-${PT(e.getMonth()+1)}-${PT(e.getDate())}T${PT(e.getHours())}:${PT(e.getMinutes())}`}function IT(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 LT(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)/ET),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 RT(e,t){if(!Number.isFinite(Date.parse(e)))return null;let n=LT(e,t);return n?n.replace(/^(Today|Tomorrow)/,e=>e.toLowerCase()):null}function zT(e,t=Date.now()){let n=RT(e,t);return n?`Snoozed until ${n}`:null}var BT=120;function VT(e,t=BT){let n=e.trim().replace(/\s+/g,` `);return n.length>t?`${n.slice(0,t-1)}…`:n}function HT(e,t,n=Date.now()){let r=t?.trim();if(!r)return zT(e,n);let i=UT(e,n);return i?`${i} — then: ${VT(r)}`:null}function UT(e,t=Date.now()){let n=RT(e,t);return n?`Auto-snoozed until ${n}`:null}var WT=`frizz.prefs.v1`;function GT(e,t){return e===`fifo`||e===`lifo`?e:t}function KT(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:kT(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 qT(){try{return KT(typeof localStorage>`u`?null:localStorage.getItem(WT))}catch{return KT(null)}}var JT=Xt(qT());Zt(JT,()=>{try{typeof localStorage<`u`&&localStorage.setItem(WT,JSON.stringify(JT))}catch{}});function YT(e){return e.kind===`session`&&e.foreign!==!0&&e.runtime===`exited`}var XT=qc.options,ZT={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 QT(e){return e.foreign===!0&&e.title.trim()?e.title.trim():aE(e)?tE:e.aiTitle?.trim()&&!$T(e)?eE(e.aiTitle):e.backend===`codex`&&e.titleAuto===!0&&!e.aiTitle?.trim()?nE:e.titleAuto===!1&&e.title.trim()?e.title:e.title.trim()&&!(e.titleAuto===!0&&e.title.trim()===e.id)?e.titleAuto===!0?eE(e.title):e.title.trim():e.titleAuto===!0?nE:e.id}function $T(e){return e.titleLocked??e.titleAuto===!1}function eE(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 tE=`Spinning up a thread…`,nE=`Untitled thread`,rE=6e4,iE=15e3;function aE(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<iE}let t=Date.parse(e.spawnedAt??``);return Number.isFinite(t)&&Date.now()-t<rE}function oE(e){return e.status===`done`||e.status===`dismissed`||bE(e)!==void 0&&xE(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 sE(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 cE(e){if(SE(e))return sE(e);let t=Date.parse(e.lastAssistantAt??``);return Number.isFinite(t)?t:sE(e)}function lE(e){return SE(e)?e.lastActivityAt??e.spawnedAt:e.lastAssistantAt??e.lastActivityAt??e.spawnedAt}function uE(e){return[...e].sort((e,t)=>{let n=oE(e);if(n!==oE(t))return n?-1:1;let r=cE(t)-cE(e);return r===0?e.id.localeCompare(t.id):r})}function dE(e){return[...e].sort((e,t)=>{let n=cE(t)-cE(e);return n===0?e.id.localeCompare(t.id):n})}function fE(e,t=`fifo`){let n=t===`lifo`?-1:1;return[...e].sort((e,t)=>{let r=(cE(e)-cE(t))*n;return r===0?e.id.localeCompare(t.id):r})}function pE(e){return wu(e)}function mE(e){return e.filter(e=>e.kind===`session`&&e.foreign===!0)}function hE(e){return e.kind===`session`&&e.foreign!==!0&&typeof e.pinnedAt==`string`}function gE(e){return e.runtime===`turn-idle`||e.runtime===`exited`}function _E(e){return(e.subAgents??[]).some(e=>ol(e)&&e.state===`running`)}function vE(e){return _E(e)?!0:e.awaitingBackground===!0&&!yE(e)}function yE(e){if(e.awaitingBackground!==!0)return!1;let t=e.watches??[];return!t.some(e=>e.kind===`timer`&&e.state===`armed`)||_E(e)||(e.bgShells??[]).some(e=>e.state===`running`)?!1:!t.some(e=>e.kind===`github`&&e.state===`armed`)}function bE(e,t=Date.now()){let n=Date.parse(e.snoozedUntil??``);return Number.isFinite(n)&&n>t?e.snoozedUntil:void 0}function xE(e,t=Date.now()){let n=bE(e,t)!==void 0;if(e.state===`archived`)return!1;let r=e.bgSnoozed===!0&&e.runtime===`turn-idle`;if(_E(e)||vE(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`||!gE(e))return!1;if(r)return!0;let i=e.lastFence?.kind===`awaiting`;return n||i}function SE(e){return e.runtime===`running`||e.runtime===`spawning`?!0:e.runtime===`turn-idle`&&vE(e)}function CE(e){return e.needsYou===!0&&gE(e)}function wE(e){return e.runtime===`turn-idle`&&e.awaitingBackground===!0&&!_E(e)}function TE(e){return wE(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 EE(e){return e.runtime===`turn-idle`?DE(e):!1}function DE(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.kind===`issue`)&&e.value.trim()!==``)}function OE(e){return e.runtime===`turn-idle`?(e.watches??[]).some(e=>e.kind===`timer`&&e.state===`armed`):!1}function kE(e){let t=SE(e);return e.state===`archived`&&!t?`archived`:bE(e)!==void 0&&xE(e)?`snoozed`:e.actionableInteraction||e.pendingAsk||e.pendingQuestion||e.runtime===`perm-prompt`||e.humanBlocked||e.status===`needs-human`?`needs-input`:t&&!CE(e)&&!wE(e)?`working`:(e.questions?.length??0)>0?`needs-input`:xE(e)?`snoozed`:e.limitPause&&e.foreign!==!0?`limit`:e.lastFence?.kind===`done`&&gE(e)?`done`:EE(e)?`pr`:OE(e)?`timer`:TE(e)?`background`:YT(e)?`stalled`:`rest`}function AE(e){let t=kE(e);return t===`stalled`||t===`limit`}function jE(e){return e.kind===`session`?e.state===`archived`&&!SE(e)?`inactive`:xE(e)?`snoozed`:`active`:null}function ME(e,t=`fifo`){let n=e.filter(NE);return[...fE(e.filter(e=>!NE(e)),t),...dE(n)]}function NE(e){return e.needsYou!==!0}function PE(e){return{running:e.filter(NE),rested:e.filter(e=>!NE(e))}}function FE(e,t=`fifo`){let n={pinned:[],active:[],snoozed:[],inactive:[]};for(let t of e){if(t.kind===`session`&&t.foreign===!0)continue;if(hE(t)){n.pinned.push(t);continue}let e=jE(t);e&&n[e].push(t)}return n.pinned.sort((e,t)=>(e.pinnedAt??``).localeCompare(t.pinnedAt??``)||e.id.localeCompare(t.id)),n.active=ME(n.active,t),n.snoozed=dE(n.snoozed),n.inactive=dE(n.inactive),n}function IE(e,t){for(let n of[e,t])if(n&&Number.isFinite(Date.parse(n)))return n}function LE(e,t=Date.now()){let n=RE(e,t);return n&&`Last active ${n}`}function RE(e,t=Date.now()){let n=VE(e,t);return n===null||n===zE?n:`${n} ago`}var zE=`just now`;function BE(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 VE(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?zE:BE(r)}function HE(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 UE(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?zE:`${BE(r)} ago`}function WE(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 KE=3e4,qE=new Set,JE=Date.now(),YE;function XE(){JE=Date.now();for(let e of qE)e();ZE()}function ZE(){if(qE.size===0)return;let e=KE-JE%KE;YE=setTimeout(XE,e||KE)}function QE(e){return qE.add(e),qE.size===1&&(JE=Date.now(),ZE()),()=>{qE.delete(e),qE.size===0&&YE&&(clearTimeout(YE),YE=void 0)}}function $E(){return JE}function eD(){return(0,I.useSyncExternalStore)(QE,$E,$E)}function tD({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 nD(e){return e===`running`}function rD(e,t){return e===`pending`&&t===`background`}var iD=2e3;function aD(e,t){return e===`pending`&&t===void 0}function oD(e,t,n,r){if(!aD(e,t))return!1;let i=n?Date.parse(n):NaN;return Number.isFinite(i)?r-i>=iD:!0}function sD(e){return e?.split(`
139
+ `).find(e=>e.trim())?.trim().replace(/\s+/g,` `)||void 0}function cD(e,t){if(e.name===`Interrupt process`||e.status===`cancelled`||e.backgroundState!==`background`)return;let n=new Set([sD(e.desc),sD(e.detail),sD(e.command)].filter(e=>!!e));if(n.size===0)return;let r=t.filter(e=>n.has(sD(e.label)??``));return r.some(e=>e.state===`running`)?`running`:r.some(e=>e.state===`stale`)?`stale`:void 0}function lD(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 uD(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 dD(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 fD(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 pD(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?dD(t-n):``}function mD(e){if(!Number.isFinite(e)||e<0)return``;let t=Math.floor(e/6e4);return t<1?`<1m`:uD(t)}function hD(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 gD(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?uD(Math.floor((t-n)/6e4)):``}function _D(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`:`${uD(r)} ago`}var vD={fgSuccess:`#3fb950`,bgSuccessEmphasis:`#238636`,fgDanger:`#f85149`,bgDangerEmphasis:`#da3633`,fgDone:`#ab7df8`,bgDoneEmphasis:`#8957e5`,fgAttention:`#d29922`,fgNeutral:`#9198a1`,bgNeutralEmphasis:`#656c76`},yD=`shrink-0 text-[11px] leading-none text-muted/45`,bD=`frizz-kind-tag petite-caps shrink-0 text-[9.5px] text-muted/45`,xD=`flex w-[9px] shrink-0 justify-center`,SD=`block h-1.5 w-1.5 rounded-full bg-muted/30`,CD=`stale — no recent output`,wD=`block h-1.5 w-1.5 rounded-full border border-muted/45`,TD=`rested — it stopped, but the work it launched is still running`,ED=`running — no recent output`,DD={AGENT:`Open sub-agent transcript`,SHELL:`Open background shell output`,GITHUB:`Open this pull request on GitHub`};function OD(e){if(!(typeof e!=`number`||!Number.isFinite(e)||e<0))return e===1?`1 line`:`${jD(e)??`0`} lines`}function kD(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 AD(e){if(e)return e.state===`open`?e.comments>0?`${e.comments} comment${e.comments===1?``:`s`}`:void 0:e.state}function jD(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 MD={running:`Stop — end this operation and everything it spawned, then clear the row`,settled:`Clear — stop tracking this finished operation`},ND={running:`Stop`,settled:`Clear`},PD={AGENT:`sub-agent`,SHELL:`background shell`,GITHUB:`PR watcher`};function FD(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 LD(e,t){return t===`card`?e.filter(ID):t===`rail`?e.filter(e=>!!e.id&&ID(e)):e}var RD=e=>{let t=e.launchId??e.id;return[...t?[`id:${t}`]:[],...e.command?[`cmd:${e.command}`]:[],`launch:${e.label}\u0000${e.startedAt??``}`]};function zD(e,t){let n=[...e],r=new Set(n.flatMap(RD));for(let e of t)RD(e).some(e=>r.has(e))||n.push(e);return n}function BD({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=nD(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=pD(a,eD()),b=Math.min(Math.max((i??1)-1,0),4)*13,x=p?`running`:`settled`,S=DD[e],C=f??(g?S:void 0),w=n===`rested`?(0,L.jsx)(`span`,{className:wD,title:TD}):(0,L.jsx)(`span`,{className:SD,title:CD}),T=_?(0,L.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:p?(0,L.jsx)(tD,{size:12}):w}):(0,L.jsx)(`span`,{className:`frizz-op-dot-slot ${xD}`,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:ED}):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:vD.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:yD,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:MD[x],"aria-label":`${ND[x]} ${PD[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)(Hh,{size:11})}),E]})}var VD=null,HD=5e3,UD=6;function WD(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 GD(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>=UD)))break;return n}function KD(e,t){if(VD=null,!e||typeof window>`u`)return;let n=[...e.querySelectorAll(`[data-transcript-source-id]`)];if(n.length===0)return;let r=WD(n[0],e),i=GD(n.map(e=>{let t=e.getBoundingClientRect();return{sourceId:e.dataset.transcriptSourceId,top:t.top,bottom:t.bottom}}),r);i.length!==0&&(VD={slug:t,candidates:i,at:performance.now()})}function qD(e){let t=VD;return!t||(VD=null,t.slug!==e||performance.now()-t.at>HD)?null:t}var JD=null;function YD(e,t){/\/full\/?$/.test(t)||(JD={slug:e,path:t})}function XD(e){return JD&&JD.slug===e?JD.path:null}var ZD=`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 QD(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function $D(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function eO(...e){return t=>{let n=!1,r=e.map(e=>{let r=$D(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():$D(e[t],null)}}}}function tO(...e){return I.useCallback(eO(...e),e)}function nO(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,rO(i,...t)]}function rO(...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 iO(e){let t=I.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];fO(r)&&typeof gO==`function`&&(r=gO(r._payload)),I.Children.forEach(r,e=>{if(uO(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;fO(n)&&typeof gO==`function`&&(n=gO(n._payload)),a=sO(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?lO(a):void 0,l=tO(n,c);if(!a){if(r||r===0)throw Error(o?hO(e):mO(e));return r}let u=cO(i,a.props??{});return a.type!==I.Fragment&&(u.ref=n?l:c),I.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}var aO=Symbol.for(`radix.slottable`);function oO(e){let t=e=>`child`in e?e.children(e.child):e.children;return t.displayName=`${e}.Slottable`,t.__radixId=aO,t}var sO=(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 cO(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 lO(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 uO(e){return I.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===aO}var dO=Symbol.for(`react.lazy`);function fO(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===dO&&`_payload`in e&&pO(e._payload)}function pO(e){return typeof e==`object`&&!!e&&`then`in e}var mO=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,hO=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,gO=I.use,_O=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=iO(`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 vO(e,t){e&&lt.flushSync(()=>e.dispatchEvent(t))}function yO(e){let t=I.useRef(e);return I.useEffect(()=>{t.current=e}),I.useMemo(()=>((...e)=>t.current?.(...e)),[])}var bO=globalThis?.document?I.useLayoutEffect:()=>{},xO=I.useEffectEvent,SO=I.useInsertionEffect;function CO(e){if(typeof xO==`function`)return xO(e);let t=I.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof SO==`function`?SO(()=>{t.current=e}):bO(()=>{t.current=e}),I.useMemo(()=>((...e)=>t.current?.(...e)),[])}var wO=`DismissableLayer`,TO=`dismissableLayer.update`,EO=`dismissableLayer.pointerDownOutside`,DO=`dismissableLayer.focusOutside`,OO,kO=I.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),AO=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(kO),[d,f]=I.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=I.useState({}),h=tO(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=PO(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=FO(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=CO(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&&(OO=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=OO))}},[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(TO,e),()=>document.removeEventListener(TO,e)},[]),(0,L.jsx)(_O.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:QD(e.onFocusCapture,w.onFocusCapture),onBlurCapture:QD(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:QD(e.onPointerDownCapture,C.onPointerDownCapture)})});AO.displayName=wO;var jO=`DismissableLayerBranch`,MO=I.forwardRef((e,t)=>{let n=I.useContext(kO),r=I.useRef(null),i=tO(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)(_O.div,{...e,ref:i})});MO.displayName=jO;function NO(){let e=I.useContext(kO),[t,n]=I.useState(null);return I.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}function PO(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a}=t,o=yO(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||LO(EO,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 FO(e,t=globalThis?.document){let n=yO(e),r=I.useRef(!1);return I.useEffect(()=>{let e=e=>{e.target&&!r.current&&LO(DO,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(TO);document.dispatchEvent(e)}function LO(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?vO(i,a):i.dispatchEvent(a)}var RO=I.useId||(()=>void 0),zO=0;function BO(e){let[t,n]=I.useState(RO());return bO(()=>{e||n(e=>e??String(zO++))},[e]),e||(t?`radix-${t}`:``)}var VO=[`top`,`right`,`bottom`,`left`],HO=Math.min,UO=Math.max,WO=Math.round,GO=Math.floor,KO=e=>({x:e,y:e}),qO={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function JO(e,t,n){return UO(e,HO(t,n))}function YO(e,t){return typeof e==`function`?e(t):e}function XO(e){return e.split(`-`)[0]}function ZO(e){return e.split(`-`)[1]}function QO(e){return e===`x`?`y`:`x`}function $O(e){return e===`y`?`height`:`width`}function ek(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function tk(e){return QO(ek(e))}function nk(e,t,n){n===void 0&&(n=!1);let r=ZO(e),i=tk(e),a=$O(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=dk(o)),[o,dk(o)]}function rk(e){let t=dk(e);return[ik(e),t,ik(t)]}function ik(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var ak=[`left`,`right`],ok=[`right`,`left`],sk=[`top`,`bottom`],ck=[`bottom`,`top`];function lk(e,t,n){switch(e){case`top`:case`bottom`:return n?t?ok:ak:t?ak:ok;case`left`:case`right`:return t?sk:ck;default:return[]}}function uk(e,t,n,r){let i=ZO(e),a=lk(XO(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(ik)))),a}function dk(e){let t=XO(e);return qO[t]+e.slice(t.length)}function fk(e){return{top:0,right:0,bottom:0,left:0,...e}}function pk(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:fk(e)}function mk(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 hk(e,t,n){let{reference:r,floating:i}=e,a=ek(t),o=tk(t),s=$O(o),c=XO(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(ZO(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 gk(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=pk(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=mk(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=mk(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 _k=50,vk=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:gk},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=hk(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<_k&&(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}=hk(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},yk=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=pk(u),f={x:n,y:r},p=tk(i),m=$O(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=HO(d[_],T),D=HO(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=JO(O,A,k),M=!c.arrow&&ZO(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}}}),bk=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=XO(r),_=ek(o),v=XO(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[dk(o)]:rk(o)),x=p!==`none`;!d&&x&&b.push(...uk(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=nk(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`&&_!==ek(t))||T.every(e=>ek(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=ek(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 xk(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function Sk(e){return VO.some(t=>e[t]>=0)}var Ck=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=xk(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:Sk(e)}}}case`escaped`:{let e=xk(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:Sk(e)}}}default:return{}}}}},wk=new Set([`left`,`top`]);async function Tk(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=XO(n),s=ZO(n),c=ek(n)===`y`,l=wk.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 Ek=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 Tk(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}}}}},Dk=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=ek(XO(i)),p=QO(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=JO(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=JO(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}}}}}},Ok=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=ek(i),f=QO(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=wk.has(XO(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}}}},kk=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=XO(i),f=ZO(i),p=ek(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=HO(h-u[g],v),x=HO(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=UO(u.left,0),t=UO(u.right,0),n=UO(u.top,0),r=UO(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:UO(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:UO(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 Ak(){return typeof window<`u`}function jk(e){return Pk(e)?(e.nodeName||``).toLowerCase():`#document`}function Mk(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Nk(e){return((Pk(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Pk(e){return Ak()?e instanceof Node||e instanceof Mk(e).Node:!1}function Fk(e){return Ak()?e instanceof Element||e instanceof Mk(e).Element:!1}function Ik(e){return Ak()?e instanceof HTMLElement||e instanceof Mk(e).HTMLElement:!1}function Lk(e){return!Ak()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Mk(e).ShadowRoot}function Rk(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 zk(e){return/^(table|td|th)$/.test(jk(e))}function Bk(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Vk=/transform|translate|scale|rotate|perspective|filter/,Hk=/paint|layout|strict|content/,Uk=e=>!!e&&e!==`none`,Wk;function Gk(e){let t=Fk(e)?Yk(e):e;return Uk(t.transform)||Uk(t.translate)||Uk(t.scale)||Uk(t.rotate)||Uk(t.perspective)||!qk()&&(Uk(t.backdropFilter)||Uk(t.filter))||Vk.test(t.willChange||``)||Hk.test(t.contain||``)}function Kk(e){let t=Zk(e);for(;Ik(t)&&!Jk(t);){if(Gk(t))return t;if(Bk(t))return null;t=Zk(t)}return null}function qk(){return Wk??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Wk}function Jk(e){return/^(html|body|#document)$/.test(jk(e))}function Yk(e){return Mk(e).getComputedStyle(e)}function Xk(e){return Fk(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Zk(e){if(jk(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Lk(e)&&e.host||Nk(e);return Lk(t)?t.host:t}function Qk(e){let t=Zk(e);return Jk(t)?e.ownerDocument?e.ownerDocument.body:e.body:Ik(t)&&Rk(t)?t:Qk(t)}function $k(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Qk(e),i=r===e.ownerDocument?.body,a=Mk(r);if(i){let e=eA(a);return t.concat(a,a.visualViewport||[],Rk(r)?r:[],e&&n?$k(e):[])}else return t.concat(r,$k(r,[],n))}function eA(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function tA(e){let t=Yk(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=WO(n)!==a||WO(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function nA(e){return Fk(e)?e:e.contextElement}function rA(e){let t=nA(e);if(!Ik(t))return KO(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=tA(t),o=(a?WO(n.width):n.width)/r,s=(a?WO(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var iA=KO(0);function aA(e){let t=Mk(e);return!qk()||!t.visualViewport?iA:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function oA(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Mk(e)?!1:t}function sA(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=nA(e),o=KO(1);t&&(r?Fk(r)&&(o=rA(r)):o=rA(e));let s=oA(a,n,r)?aA(a):KO(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=Mk(a),t=r&&Fk(r)?Mk(r):r,n=e,i=eA(n);for(;i&&r&&t!==n;){let e=rA(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=Mk(i),i=eA(n)}}return mk({width:u,height:d,x:c,y:l})}function cA(e,t){let n=Xk(e).scrollLeft;return t?t.left+n:sA(Nk(e)).left+n}function lA(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-cA(e,n),y:n.top+t.scrollTop}}function uA(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Nk(r),s=t?Bk(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=KO(1),u=KO(0),d=Ik(r);if((d||!d&&!a)&&((jk(r)!==`body`||Rk(o))&&(c=Xk(r)),d)){let e=sA(r);l=rA(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?lA(o,c):KO(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 dA(e){return Array.from(e.getClientRects())}function fA(e){let t=Nk(e),n=Xk(e),r=e.ownerDocument.body,i=UO(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=UO(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+cA(e),s=-n.scrollTop;return Yk(r).direction===`rtl`&&(o+=UO(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var pA=25;function mA(e,t){let n=Mk(e),r=Nk(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=qk();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=cA(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<=pA&&(a-=o)}else l<=pA&&(a+=l);return{width:a,height:o,x:s,y:c}}function hA(e,t){let n=sA(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Ik(e)?rA(e):KO(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function gA(e,t,n){let r;if(t===`viewport`)r=mA(e,n);else if(t===`document`)r=fA(Nk(e));else if(Fk(t))r=hA(t,n);else{let n=aA(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return mk(r)}function _A(e,t){let n=Zk(e);return n===t||!Fk(n)||Jk(n)?!1:Yk(n).position===`fixed`||_A(n,t)}function vA(e,t){let n=t.get(e);if(n)return n;let r=$k(e,[],!1).filter(e=>Fk(e)&&jk(e)!==`body`),i=null,a=Yk(e).position===`fixed`,o=a?Zk(e):e;for(;Fk(o)&&!Jk(o);){let t=Yk(o),n=Gk(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||Rk(o)&&!n&&_A(e,o))?r=r.filter(e=>e!==o):i=t,o=Zk(o)}return t.set(e,r),r}function yA(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Bk(t)?[]:vA(t,this._c):[].concat(n),r],o=gA(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=gA(t,a[e],i);s=UO(n.top,s),c=HO(n.right,c),l=HO(n.bottom,l),u=UO(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function bA(e){let{width:t,height:n}=tA(e);return{width:t,height:n}}function xA(e,t,n){let r=Ik(t),i=Nk(t),a=n===`fixed`,o=sA(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=KO(0);function l(){c.x=cA(i)}if(r||!r&&!a)if((jk(t)!==`body`||Rk(i))&&(s=Xk(t)),r){let e=sA(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?lA(i,s):KO(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 SA(e){return Yk(e).position===`static`}function CA(e,t){if(!Ik(e)||Yk(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Nk(e)===n&&(n=n.ownerDocument.body),n}function wA(e,t){let n=Mk(e);if(Bk(e))return n;if(!Ik(e)){let t=Zk(e);for(;t&&!Jk(t);){if(Fk(t)&&!SA(t))return t;t=Zk(t)}return n}let r=CA(e,t);for(;r&&zk(r)&&SA(r);)r=CA(r,t);return r&&Jk(r)&&SA(r)&&!Gk(r)?n:r||Kk(e)||n}var TA=async function(e){let t=this.getOffsetParent||wA,n=this.getDimensions,r=await n(e.floating);return{reference:xA(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function EA(e){return Yk(e).direction===`rtl`}var DA={convertOffsetParentRelativeRectToViewportRelativeRect:uA,getDocumentElement:Nk,getClippingRect:yA,getOffsetParent:wA,getElementRects:TA,getClientRects:dA,getDimensions:bA,getScale:rA,isElement:Fk,isRTL:EA};function OA(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function kA(e,t){let n=null,r,i=Nk(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=GO(d),h=GO(i.clientWidth-(u+f)),g=GO(i.clientHeight-(d+p)),_=GO(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:UO(0,HO(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&&!OA(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 AA(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=nA(e),u=i||a?[...l?$k(l):[],...t?$k(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?kA(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?sA(e):null;c&&g();function g(){let t=sA(e);h&&!OA(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 jA=Ek,MA=Dk,NA=bk,PA=kk,FA=Ck,IA=yk,LA=Ok,RA=(e,t,n)=>{let r=new Map,i={platform:DA,...n},a={...i.platform,_c:r};return vk(e,t,{...i,platform:a})},zA=typeof document<`u`?I.useLayoutEffect:function(){};function BA(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(!BA(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)&&!BA(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function VA(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function HA(e,t){let n=VA(e);return Math.round(t*n)/n}function UA(e){let t=I.useRef(e);return zA(()=>{t.current=e}),t}function WA(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);BA(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=UA(c),D=UA(i),O=UA(l),k=I.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),RA(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!BA(w.current,t)&&(w.current=t,lt.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);zA(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=I.useRef(!1);zA(()=>(A.current=!0,()=>{A.current=!1}),[]),zA(()=>{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=HA(M.floating,u.x),r=HA(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...VA(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 GA=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):{}}}},KA=(e,t)=>{let n=jA(e);return{name:n.name,fn:n.fn,options:[e,t]}},qA=(e,t)=>{let n=MA(e);return{name:n.name,fn:n.fn,options:[e,t]}},JA=(e,t)=>({fn:LA(e).fn,options:[e,t]}),YA=(e,t)=>{let n=NA(e);return{name:n.name,fn:n.fn,options:[e,t]}},XA=(e,t)=>{let n=PA(e);return{name:n.name,fn:n.fn,options:[e,t]}},ZA=(e,t)=>{let n=FA(e);return{name:n.name,fn:n.fn,options:[e,t]}},QA=(e,t)=>{let n=GA(e);return{name:n.name,fn:n.fn,options:[e,t]}},$A=`Arrow`,ej=I.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,L.jsx)(_O.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`})})});ej.displayName=$A;var tj=ej;function nj(e){let[t,n]=I.useState(void 0);return bO(()=>{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 rj=`Popper`,[ij,aj]=nO(rj),[oj,sj]=ij(rj),cj=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null),[a,o]=I.useState(void 0);return(0,L.jsx)(oj,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};cj.displayName=rj;var lj=`PopperAnchor`,uj=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=sj(lj,n),o=I.useRef(null),s=a.onAnchorChange,c=tO(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&&bj(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,L.jsx)(_O.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})});uj.displayName=lj;var dj=`PopperContent`,[fj,pj]=ij(dj),mj=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=sj(dj,n),[_,v]=I.useState(null),y=tO(t,v),[b,x]=I.useState(null),S=nj(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(vj),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=WA({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>AA(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[KA({mainAxis:i+w,alignmentAxis:o}),c&&qA({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?JA():void 0,...k}),c&&YA({...k}),XA({...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&&QA({element:b,padding:s}),yj({arrowWidth:C,arrowHeight:w}),f&&ZA({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ee=g.setPlacementState;bO(()=>(ee(M),()=>{ee(void 0)}),[M,ee]);let[F,te]=bj(M),ne=yO(m);bO(()=>{N&&ne?.()},[N,ne]);let re=P.arrow?.x,ie=P.arrow?.y,ae=P.arrow?.centerOffset!==0,[oe,se]=I.useState();return bO(()=>{_&&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)(fj,{scope:n,placedSide:F,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,L.jsx)(_O.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});mj.displayName=dj;var hj=`PopperArrow`,gj={top:`bottom`,right:`left`,bottom:`top`,left:`right`},_j=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=pj(hj,n),a=gj[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)(tj,{...r,ref:t,style:{...r.style,display:`block`}})})});_j.displayName=hj;function vj(e){return e!==null}var yj=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]=bj(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 bj(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var xj=cj,Sj=uj,Cj=mj,wj=_j,Tj=`Portal`,Ej=I.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=I.useState(!1);bO(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?lt.createPortal((0,L.jsx)(_O.div,{...r,ref:t}),o):null});Ej.displayName=Tj;function Dj(e,t){return I.useReducer((e,n)=>t[e][n]??e,e)}var Oj=e=>{let{present:t,children:n}=e,r=kj(t),i=typeof n==`function`?n({present:r.isPresent}):I.Children.only(n),a=jj(r.ref,Nj(i));return typeof n==`function`||r.isPresent?I.cloneElement(i,{ref:a}):null};Oj.displayName=`Presence`;function kj(e){let[t,n]=I.useState(),r=I.useRef(null),i=I.useRef(e),a=I.useRef(`none`),[o,s]=Dj(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return I.useEffect(()=>{let e=Mj(r.current);a.current=o===`mounted`?e:`none`},[o]),bO(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=Mj(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),bO(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=Mj(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=Mj(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 Aj(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function jj(...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=Aj(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():Aj(n[e],null)}}},[])}function Mj(e){return e?.animationName||`none`}function Nj(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 Pj=I.useInsertionEffect||bO;function Fj({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=Lj(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 Pj(()=>{a.current=t},[t]),I.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function Lj(e){return typeof e==`function`}var Rj=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`}),zj=`VisuallyHidden`,Bj=I.forwardRef((e,t)=>(0,L.jsx)(_O.span,{...e,ref:t,style:{...Rj,...e.style}}));Bj.displayName=zj;var Vj=Bj,[Hj,Uj]=nO(`Tooltip`,[aj]),Wj=aj(),Gj=`TooltipProvider`,Kj=700,qj=`tooltip.open`,[Jj,Yj]=Hj(Gj),Xj=e=>{let{__scopeTooltip:t,delayDuration:n=Kj,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)(Jj,{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})};Xj.displayName=Gj;var Zj=`Tooltip`,[Qj,$j]=Hj(Zj),eM=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=Yj(Zj,e.__scopeTooltip),l=Wj(t),[u,d]=I.useState(null),f=BO(),p=I.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=I.useRef(!1),[_,v]=Fj({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(qj))):c.onClose(),a?.(e)},caller:Zj}),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)(xj,{...l,children:(0,L.jsx)(Qj,{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})})};eM.displayName=Zj;var tM=`TooltipTrigger`,nM=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=$j(tM,n),a=Yj(tM,n),o=Wj(n),s=tO(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)(Sj,{asChild:!0,...o,children:(0,L.jsx)(_O.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:QD(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:QD(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:QD(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:QD(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:QD(e.onBlur,i.onClose),onClick:QD(e.onClick,i.onClose)})})});nM.displayName=tM;var rM=`TooltipPortal`,[iM,aM]=Hj(rM,{forceMount:void 0}),oM=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=$j(rM,t);return(0,L.jsx)(iM,{scope:t,forceMount:n,children:(0,L.jsx)(Oj,{present:n||a.open,children:(0,L.jsx)(Ej,{asChild:!0,container:i,children:r})})})};oM.displayName=rM;var sM=`TooltipContent`,cM=I.forwardRef((e,t)=>{let n=aM(sM,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=$j(sM,e.__scopeTooltip);return(0,L.jsx)(Oj,{present:r||o.open,children:o.disableHoverableContent?(0,L.jsx)(pM,{side:i,...a,ref:t}):(0,L.jsx)(lM,{side:i,...a,ref:t})})}),lM=I.forwardRef((e,t)=>{let n=$j(sM,e.__scopeTooltip),r=Yj(sM,e.__scopeTooltip),i=I.useRef(null),a=tO(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=_M(r,gM(r,n.getBoundingClientRect())),a=vM(t.getBoundingClientRect()),o=bM([...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=!yM(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,L.jsx)(pM,{...e,ref:a})}),[uM,dM]=Hj(Zj,{isInside:!1}),fM=oO(`TooltipContent`),pM=I.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=$j(sM,n),l=Wj(n),{onClose:u}=c;return I.useEffect(()=>(document.addEventListener(qj,u),()=>document.removeEventListener(qj,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)(AO,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,L.jsxs)(Cj,{"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)(fM,{children:r}),(0,L.jsx)(uM,{scope:n,isInside:!0,children:(0,L.jsx)(Vj,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});cM.displayName=sM;var mM=`TooltipArrow`,hM=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=Wj(n);return dM(mM,n).isInside?null:(0,L.jsx)(wj,{...i,...r,ref:t})});hM.displayName=mM;function gM(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 _M(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 vM(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 yM(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 bM(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)),xM(t)}function xM(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 SM=Xj,CM=eM,wM=nM,TM=oM,EM=cM,DM=hM,OM=`isolate bg-elevated opacity-100 border border-border shadow-2xl shadow-black/40`,kM=`z-[110]`,AM=`${kM} ${OM}`,jM=`z-[250]`,MM=`z-[250]`;function NM({children:e}){return(0,L.jsx)(SM,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!0,children:e})}function PM({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,lt.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)(CM,{open:s&&!a,onOpenChange:c,children:[(0,L.jsx)(wM,{asChild:!0,children:d}),(0,L.jsx)(TM,{children:(0,L.jsxs)(EM,{id:l,side:n,sideOffset:5,collisionPadding:12,className:`${MM} 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)(DM,{className:`fill-elevated`})]})})]})}function FM({slug:e,size:t=14,className:n,label:r=`Open fullscreen`}){let i=nf(e);function a(t){if(t.stopPropagation(),!af(t))return;t.preventDefault();let n=!Dp(),r=t.currentTarget.closest(`[data-vt-chat]`);KD(r,e),typeof location<`u`&&YD(e,location.pathname),n&&r&&(r.style.viewTransitionName=`thread-chat`,Od(r)),Yw(i,{viewTransition:n})}return(0,L.jsx)(PM,{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)(gh,{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 LM(e,t,n=`AGENT`){if(!t.id||!ol(t)||t.state===`running`&&!t.stoppable)return;let r=t.id;return()=>IM(e,r,n)}function RM(e){let t=e+`CollectionProvider`,[n,r]=nO(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=iO(s),l=I.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=tO(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=iO(u),p=I.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=I.useRef(null),s=tO(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 zM=I.createContext(void 0);function BM(e){let t=I.useContext(zM);return e||t||`ltr`}var VM=0,HM=null;function UM(){I.useEffect(()=>{HM||={start:WM(),end:WM()};let{start:e,end:t}=HM;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),VM++,()=>{VM===1&&(HM?.start.remove(),HM?.end.remove(),HM=null),VM=Math.max(0,VM-1)}},[])}function WM(){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 GM=`focusScope.autoFocusOnMount`,KM=`focusScope.autoFocusOnUnmount`,qM={bubbles:!1,cancelable:!0},JM=`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=yO(i),u=yO(a),d=I.useRef(null),f=tO(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:nN(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||nN(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&nN(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){rN.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(GM,qM);s.addEventListener(GM,l),s.dispatchEvent(t),t.defaultPrevented||(XM(oN(QM(s)),{select:!0}),document.activeElement===e&&nN(s))}return()=>{s.removeEventListener(GM,l),setTimeout(()=>{let t=new CustomEvent(KM,qM);s.addEventListener(KM,u),s.dispatchEvent(t),t.defaultPrevented||nN(e??document.body,{select:!0}),s.removeEventListener(KM,u),rN.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]=ZM(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&nN(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&nN(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,L.jsx)(_O.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});YM.displayName=JM;function XM(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(nN(r,{select:t}),document.activeElement!==n)return}function ZM(e){let t=QM(e);return[$M(t,e),$M(t.reverse(),e)]}function QM(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 $M(e,t){for(let n of e)if(!eN(n,{upTo:t}))return n}function eN(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 tN(e){return e instanceof HTMLInputElement&&`select`in e}function nN(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&tN(e)&&t&&e.select()}}var rN=iN();function iN(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=aN(e,t),e.unshift(t)},remove(t){e=aN(e,t),e[0]?.resume()}}}function aN(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function oN(e){return e.filter(e=>e.tagName!==`A`)}var sN=`rovingFocusGroup.onEntryFocus`,cN={bubbles:!1,cancelable:!0},lN=`RovingFocusGroup`,[uN,dN,fN]=RM(lN),[pN,mN]=nO(lN,[fN]),[hN,gN]=pN(lN),_N=I.forwardRef((e,t)=>(0,L.jsx)(uN.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,L.jsx)(uN.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,L.jsx)(vN,{...e,ref:t})})}));_N.displayName=lN;var vN=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=tO(t,f),m=BM(a),[h,g]=Fj({prop:o,defaultProp:s??null,onChange:c,caller:lN}),[_,v]=I.useState(!1),y=yO(l),b=dN(n),x=I.useRef(!1),[S,C]=I.useState(0);return I.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(sN,y),()=>e.removeEventListener(sN,y)},[y]),(0,L.jsx)(hN,{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)(_O.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:QD(e.onMouseDown,()=>{x.current=!0}),onFocus:QD(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(sN,cN);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);wN([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:QD(e.onBlur,()=>v(!1))})})}),yN=`RovingFocusGroupItem`,bN=I.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=BO(),l=a||c,u=gN(yN,n),d=u.currentTabStopId===l,f=dN(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return I.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,L.jsx)(uN.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,L.jsx)(_O.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:QD(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:QD(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:QD(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=CN(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?TN(n,r+1):n.slice(r+1)}setTimeout(()=>wN(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});bN.displayName=yN;var xN={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function SN(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function CN(e,t,n){let r=SN(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return xN[r]}function wN(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function TN(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var EN=_N,DN=bN,ON=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},kN=new WeakMap,AN=new WeakMap,jN={},MN=0,NN=function(e){return e&&(e.host||NN(e.parentNode))},PN=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=NN(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})},FN=function(e,t,n,r){var i=PN(t,Array.isArray(e)?e:[e]);jN[n]||(jN[n]=new WeakMap);var a=jN[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=(kN.get(e)||0)+1,l=(a.get(e)||0)+1;kN.set(e,c),a.set(e,l),o.push(e),c===1&&i&&AN.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(),MN++,function(){o.forEach(function(e){var t=kN.get(e)-1,i=a.get(e)-1;kN.set(e,t),a.set(e,i),t||(AN.has(e)||e.removeAttribute(r),AN.delete(e)),i||e.removeAttribute(n)}),MN--,MN||(kN=new WeakMap,kN=new WeakMap,AN=new WeakMap,jN={})}},IN=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||ON(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),FN(r,i,n,`aria-hidden`)):function(){return null}},LN=function(){return LN=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},LN.apply(this,arguments)};function RN(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 zN(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 BN=`right-scroll-bar-position`,VN=`width-before-scroll-bar`,HN=`with-scroll-bars-hidden`,UN=`--removed-body-scroll-bar-size`;function WN(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function GN(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 KN=typeof window<`u`?I.useLayoutEffect:I.useEffect,qN=new WeakMap;function JN(e,t){var n=GN(t||null,function(t){return e.forEach(function(e){return WN(e,t)})});return KN(function(){var t=qN.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||WN(e,null)}),i.forEach(function(e){r.has(e)||WN(e,a)})}qN.set(n,e)},[e]),n}function YN(e){return e}function XN(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 ZN(e){e===void 0&&(e={});var t=XN(null);return t.options=LN({async:!0,ssr:!1},e),t}var QN=function(e){var t=e.sideCar,n=RN(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,LN({},n))};QN.isSideCarExport=!0;function $N(e,t){return e.useMedium(t),QN}var eP=ZN(),tP=function(){},nP=I.forwardRef(function(e,t){var n=I.useRef(null),r=I.useState({onScrollCapture:tP,onWheelCapture:tP,onTouchMoveCapture:tP}),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=RN(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=JN([n,t]),C=LN(LN({},b),i);return I.createElement(I.Fragment,null,u&&I.createElement(x,{sideCar:eP,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),LN(LN({},C),{ref:S})):I.createElement(v,LN({},C,{className:c,ref:S}),s))});nP.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},nP.classNames={fullWidth:VN,zeroRight:BN};var rP,iP=function(){if(rP)return rP;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function aP(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=iP();return t&&e.setAttribute(`nonce`,t),e}function oP(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function sP(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var cP=function(){var e=0,t=null;return{add:function(n){e==0&&(t=aP())&&(oP(t,n),sP(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},lP=function(){var e=cP();return function(t,n){I.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},uP=function(){var e=lP();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},dP={left:0,top:0,right:0,gap:0},fP=function(e){return parseInt(e||``,10)||0},pP=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[fP(n),fP(r),fP(i)]},mP=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return dP;var t=pP(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])}},hP=uP(),gP=`data-scroll-locked`,_P=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
+ .${HN} {
141
141
  overflow: hidden ${r};
142
142
  padding-right: ${s}px ${r};
143
143
  }
144
- body[${oP}] {
144
+ body[${gP}] {
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
- .${AN} {
157
+ .${BN} {
158
158
  right: ${s}px ${r};
159
159
  }
160
160
 
161
- .${jN} {
161
+ .${VN} {
162
162
  margin-right: ${s}px ${r};
163
163
  }
164
164
 
165
- .${AN} .${AN} {
165
+ .${BN} .${BN} {
166
166
  right: 0 ${r};
167
167
  }
168
168
 
169
- .${jN} .${jN} {
169
+ .${VN} .${VN} {
170
170
  margin-right: 0 ${r};
171
171
  }
172
172
 
173
- body[${oP}] {
174
- ${NN}: ${s}px;
173
+ body[${gP}] {
174
+ ${UN}: ${s}px;
175
175
  }
176
- `},cP=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},lP=function(){I.useEffect(function(){return document.body.setAttribute(oP,(cP()+1).toString()),function(){var e=cP()-1;e<=0?document.body.removeAttribute(oP):document.body.setAttribute(oP,e.toString())}},[])},uP=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;lP();var a=I.useMemo(function(){return iP(i)},[i]);return I.createElement(aP,{styles:sP(a,!t,i,n?``:`!important`)})},dP=!1;if(typeof window<`u`)try{var fP=Object.defineProperty({},"passive",{get:function(){return dP=!0,!0}});window.addEventListener(`test`,fP,fP),window.removeEventListener(`test`,fP,fP)}catch{dP=!1}var pP=dP?{passive:!1}:!1,mP=function(e){return e.tagName===`TEXTAREA`},hP=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!mP(e)&&n[t]===`visible`)},gP=function(e){return hP(e,`overflowY`)},_P=function(e){return hP(e,`overflowX`)},vP=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),xP(e,r)){var i=SP(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},yP=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},bP=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},xP=function(e,t){return e===`v`?gP(t):_P(t)},SP=function(e,t){return e===`v`?yP(t):bP(t)},CP=function(e,t){return e===`h`&&t===`rtl`?-1:1},wP=function(e,t,n,r,i){var a=CP(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=SP(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&xP(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},TP=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},EP=function(e){return[e.deltaX,e.deltaY]},DP=function(e){return e&&`current`in e?e.current:e},OP=function(e,t){return e[0]===t[0]&&e[1]===t[1]},kP=function(e){return`
176
+ `},vP=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},yP=function(){I.useEffect(function(){return document.body.setAttribute(gP,(vP()+1).toString()),function(){var e=vP()-1;e<=0?document.body.removeAttribute(gP):document.body.setAttribute(gP,e.toString())}},[])},bP=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;yP();var a=I.useMemo(function(){return mP(i)},[i]);return I.createElement(hP,{styles:_P(a,!t,i,n?``:`!important`)})},xP=!1;if(typeof window<`u`)try{var SP=Object.defineProperty({},"passive",{get:function(){return xP=!0,!0}});window.addEventListener(`test`,SP,SP),window.removeEventListener(`test`,SP,SP)}catch{xP=!1}var CP=xP?{passive:!1}:!1,wP=function(e){return e.tagName===`TEXTAREA`},TP=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!wP(e)&&n[t]===`visible`)},EP=function(e){return TP(e,`overflowY`)},DP=function(e){return TP(e,`overflowX`)},OP=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),jP(e,r)){var i=MP(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},kP=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},AP=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},jP=function(e,t){return e===`v`?EP(t):DP(t)},MP=function(e,t){return e===`v`?kP(t):AP(t)},NP=function(e,t){return e===`h`&&t===`rtl`?-1:1},PP=function(e,t,n,r,i){var a=NP(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=MP(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&jP(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},FP=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},IP=function(e){return[e.deltaX,e.deltaY]},LP=function(e){return e&&`current`in e?e.current:e},RP=function(e,t){return e[0]===t[0]&&e[1]===t[1]},zP=function(e){return`
177
177
  .block-interactivity-${e} {pointer-events: none;}
178
178
  .allow-interactivity-${e} {pointer-events: all;}
179
- `},AP=0,jP=[];function MP(e){var t=I.useRef([]),n=I.useRef([0,0]),r=I.useRef(),i=I.useState(AP++)[0],a=I.useState(eP)[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=kN([e.lockRef.current],(e.shards||[]).map(DP),!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=TP(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=vP(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=vP(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 wP(h,t,e,h===`h`?s:c,!0)},[]),c=I.useCallback(function(e){var n=e;if(!(!jP.length||jP[jP.length-1]!==a)){var r=`deltaY`in n?EP(n):TP(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(DP).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:NP(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=TP(e),r.current=void 0},[]),d=I.useCallback(function(t){l(t.type,EP(t),t.target,s(t,e.lockRef.current))},[]),f=I.useCallback(function(t){l(t.type,TP(t),t.target,s(t,e.lockRef.current))},[]);I.useEffect(function(){return jP.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,pP),document.addEventListener(`touchmove`,c,pP),document.addEventListener(`touchstart`,u,pP),function(){jP=jP.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,pP),document.removeEventListener(`touchmove`,c,pP),document.removeEventListener(`touchstart`,u,pP)}},[]);var p=e.removeScrollBar,m=e.inert;return I.createElement(I.Fragment,null,m?I.createElement(a,{styles:kP(i)}):null,p?I.createElement(uP,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function NP(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var PP=UN(WN,MP),FP=I.forwardRef(function(e,t){return I.createElement(KN,DN({},e,{ref:t,sideCar:PP}))});FP.classNames=KN.classNames;var IP=[`Enter`,` `],LP=[`ArrowDown`,`PageUp`,`Home`],RP=[`ArrowUp`,`PageDown`,`End`],zP=[...LP,...RP],BP={ltr:[...IP,`ArrowRight`],rtl:[...IP,`ArrowLeft`]},VP={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},HP=`Menu`,[UP,WP,GP]=OM(HP),[KP,qP]=KD(HP,[GP,YA,iN]),JP=YA(),YP=iN(),[XP,ZP]=KP(HP),[QP,$P]=KP(HP),eF=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=JP(t),[c,l]=I.useState(null),u=I.useRef(!1),d=lO(a),f=AM(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)(dj,{...s,children:(0,L.jsx)(XP,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,L.jsx)(QP,{scope:t,onClose:I.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};eF.displayName=HP;var tF=`MenuAnchor`,nF=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=JP(n);return(0,L.jsx)(fj,{...i,...r,ref:t})});nF.displayName=tF;var rF=`MenuPortal`,[iF,aF]=KP(rF,{forceMount:void 0}),oF=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=ZP(rF,t);return(0,L.jsx)(iF,{scope:t,forceMount:n,children:(0,L.jsx)(vj,{present:n||a.open,children:(0,L.jsx)(gj,{asChild:!0,container:i,children:r})})})};oF.displayName=rF;var sF=`MenuContent`,[cF,lF]=KP(sF),uF=I.forwardRef((e,t)=>{let n=aF(sF,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=ZP(sF,e.__scopeMenu),o=$P(sF,e.__scopeMenu);return(0,L.jsx)(UP.Provider,{scope:e.__scopeMenu,children:(0,L.jsx)(vj,{present:r||a.open,children:(0,L.jsx)(UP.Slot,{scope:e.__scopeMenu,children:o.modal?(0,L.jsx)(dF,{...i,ref:t}):(0,L.jsx)(fF,{...i,ref:t})})})})}),dF=I.forwardRef((e,t)=>{let n=ZP(sF,e.__scopeMenu),r=I.useRef(null),i=GD(t,r);return I.useEffect(()=>{let e=r.current;if(e)return EN(e)},[]),(0,L.jsx)(mF,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:HD(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),fF=I.forwardRef((e,t)=>{let n=ZP(sF,e.__scopeMenu);return(0,L.jsx)(mF,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),pF=JD(`MenuContent.ScrollLock`),mF=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=ZP(sF,n),_=$P(sF,n),v=JP(n),y=YP(n),b=WP(n),[x,S]=I.useState(null),C=I.useRef(null),w=GD(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?FP:I.Fragment,M=m?{as:pF,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=QF(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),[]),NM();let P=I.useCallback(e=>k.current===O.current?.side&&eI(e,O.current?.area),[]);return(0,L.jsx)(cF,{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)(zM,{asChild:!0,trapped:i,onMountAutoFocus:HD(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,L.jsx)(bO,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,L.jsx)(gN,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:HD(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,L.jsx)(pj,{role:`menu`,"aria-orientation":`vertical`,"data-state":qF(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:HD(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||!zP.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);RP.includes(e.key)&&a.reverse(),XF(a)}),onBlur:HD(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:HD(e.onPointerMove,tI(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}}))})})})})})})});uF.displayName=sF;var hF=`MenuGroup`,gF=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(sO.div,{role:`group`,...r,ref:t})});gF.displayName=hF;var _F=`MenuLabel`,vF=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(sO.div,{...r,ref:t})});vF.displayName=_F;var yF=`MenuItem`,bF=`menu.itemSelect`,xF=I.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=I.useRef(null),o=$P(yF,e.__scopeMenu),s=lF(yF,e.__scopeMenu),c=GD(t,a),l=I.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(bF,{bubbles:!0,cancelable:!0});e.addEventListener(bF,e=>r?.(e),{once:!0}),cO(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,L.jsx)(SF,{...i,ref:c,disabled:n,onClick:HD(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:HD(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:HD(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||IP.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});xF.displayName=yF;var SF=I.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=lF(yF,n),s=YP(n),c=I.useRef(null),l=GD(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)(UP.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,L.jsx)(_N,{asChild:!0,...s,focusable:!r,children:(0,L.jsx)(sO.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:HD(e.onPointerMove,tI(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:HD(e.onPointerLeave,tI(e=>o.onItemLeave(e))),onFocus:HD(e.onFocus,()=>d(!0)),onBlur:HD(e.onBlur,()=>d(!1))})})})}),CF=`MenuCheckboxItem`,wF=I.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,L.jsx)(MF,{scope:e.__scopeMenu,checked:n,children:(0,L.jsx)(xF,{role:`menuitemcheckbox`,"aria-checked":JF(n)?`mixed`:n,...i,ref:t,"data-state":YF(n),onSelect:HD(i.onSelect,()=>r?.(JF(n)?!0:!n),{checkForDefaultPrevented:!1})})})});wF.displayName=CF;var TF=`MenuRadioGroup`,[EF,DF]=KP(TF,{value:void 0,onValueChange:()=>{}}),OF=I.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=lO(r);return(0,L.jsx)(EF,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,L.jsx)(gF,{...i,ref:t})})});OF.displayName=TF;var kF=`MenuRadioItem`,AF=I.forwardRef((e,t)=>{let{value:n,...r}=e,i=DF(kF,e.__scopeMenu),a=n===i.value;return(0,L.jsx)(MF,{scope:e.__scopeMenu,checked:a,children:(0,L.jsx)(xF,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":YF(a),onSelect:HD(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});AF.displayName=kF;var jF=`MenuItemIndicator`,[MF,NF]=KP(jF,{checked:!1}),PF=I.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=NF(jF,n);return(0,L.jsx)(vj,{present:r||JF(a.checked)||a.checked===!0,children:(0,L.jsx)(sO.span,{...i,ref:t,"data-state":YF(a.checked)})})});PF.displayName=jF;var FF=`MenuSeparator`,IF=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(sO.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});IF.displayName=FF;var LF=`MenuArrow`,RF=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=JP(n);return(0,L.jsx)(mj,{...i,...r,ref:t})});RF.displayName=LF;var zF=`MenuSub`,[BF,VF]=KP(zF),HF=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=ZP(zF,t),o=JP(t),[s,c]=I.useState(null),[l,u]=I.useState(null),d=lO(i);return I.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,L.jsx)(dj,{...o,children:(0,L.jsx)(XP,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,L.jsx)(BF,{scope:t,contentId:AO(),triggerId:AO(),trigger:s,onTriggerChange:c,children:n})})})};HF.displayName=zF;var UF=`MenuSubTrigger`,WF=I.forwardRef((e,t)=>{let n=ZP(UF,e.__scopeMenu),r=$P(UF,e.__scopeMenu),i=VF(UF,e.__scopeMenu),a=lF(UF,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=GD(t,i.onTriggerChange);return(0,L.jsx)(nF,{asChild:!0,...l,children:(0,L.jsx)(SF,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":qF(n.open),...e,ref:d,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:HD(e.onPointerMove,tI(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:HD(e.onPointerLeave,tI(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:HD(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=UF;var GF=`MenuSubContent`,KF=I.forwardRef((e,t)=>{let n=aF(sF,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=ZP(sF,e.__scopeMenu),s=$P(sF,e.__scopeMenu),c=VF(GF,e.__scopeMenu),l=I.useRef(null),u=GD(t,l);return(0,L.jsx)(UP.Provider,{scope:e.__scopeMenu,children:(0,L.jsx)(vj,{present:r||o.open,children:(0,L.jsx)(UP.Slot,{scope:e.__scopeMenu,children:(0,L.jsx)(mF,{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:HD(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:HD(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:HD(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=VP[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})});KF.displayName=GF;function qF(e){return e?`open`:`closed`}function JF(e){return e===`indeterminate`}function YF(e){return JF(e)?`indeterminate`:e?`checked`:`unchecked`}function XF(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function ZF(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function QF(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=ZF(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 $F(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 eI(e,t){return t?$F({x:e.clientX,y:e.clientY},t):!1}function tI(e){return t=>t.pointerType===`mouse`?e(t):void 0}var nI=eF,rI=nF,iI=oF,aI=uF,oI=gF,sI=vF,cI=xF,lI=wF,uI=OF,dI=AF,fI=PF,pI=IF,mI=RF,hI=WF,gI=KF,_I=`DropdownMenu`,[vI,yI]=KD(_I,[qP]),bI=qP(),[xI,SI]=vI(_I),CI=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=bI(t),l=I.useRef(null),[u,d]=Tj({prop:i,defaultProp:a??!1,onChange:o,caller:_I});return(0,L.jsx)(xI,{scope:t,triggerId:AO(),triggerRef:l,contentId:AO(),open:u,onOpenChange:d,onOpenToggle:I.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,L.jsx)(nI,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};CI.displayName=_I;var wI=`DropdownMenuTrigger`,TI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=SI(wI,n),o=bI(n),s=GD(t,a.triggerRef);return(0,L.jsx)(rI,{asChild:!0,...o,children:(0,L.jsx)(sO.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:HD(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:HD(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});TI.displayName=wI;var EI=`DropdownMenuPortal`,DI=e=>{let{__scopeDropdownMenu:t,...n}=e,r=bI(t);return(0,L.jsx)(iI,{...r,...n})};DI.displayName=EI;var OI=`DropdownMenuContent`,kI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=SI(OI,n),a=bI(n),o=I.useRef(!1);return(0,L.jsx)(aI,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:HD(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:HD(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)`}})});kI.displayName=OI;var AI=`DropdownMenuGroup`,jI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=bI(n);return(0,L.jsx)(oI,{...i,...r,ref:t})});jI.displayName=AI;var MI=`DropdownMenuLabel`,NI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=bI(n);return(0,L.jsx)(sI,{...i,...r,ref:t})});NI.displayName=MI;var PI=`DropdownMenuItem`,FI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=bI(n);return(0,L.jsx)(cI,{...i,...r,ref:t})});FI.displayName=PI;var II=`DropdownMenuCheckboxItem`,LI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=bI(n);return(0,L.jsx)(lI,{...i,...r,ref:t})});LI.displayName=II;var RI=`DropdownMenuRadioGroup`,zI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=bI(n);return(0,L.jsx)(uI,{...i,...r,ref:t})});zI.displayName=RI;var BI=`DropdownMenuRadioItem`,VI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=bI(n);return(0,L.jsx)(dI,{...i,...r,ref:t})});VI.displayName=BI;var HI=`DropdownMenuItemIndicator`,UI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=bI(n);return(0,L.jsx)(fI,{...i,...r,ref:t})});UI.displayName=HI;var WI=`DropdownMenuSeparator`,GI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=bI(n);return(0,L.jsx)(pI,{...i,...r,ref:t})});GI.displayName=WI;var KI=`DropdownMenuArrow`,qI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=bI(n);return(0,L.jsx)(mI,{...i,...r,ref:t})});qI.displayName=KI;var JI=`DropdownMenuSubTrigger`,YI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=bI(n);return(0,L.jsx)(hI,{...i,...r,ref:t})});YI.displayName=JI;var XI=`DropdownMenuSubContent`,ZI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=bI(n);return(0,L.jsx)(gI,{...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)`}})});ZI.displayName=XI;var QI=CI,$I=TI,eL=DI,tL=kI,nL=jI,rL=NI,iL=FI,aL=zI,oL=VI,sL=UI,cL=GI;function lL({modal:e=!1,...t}){return(0,L.jsx)(QI,{modal:e,...t})}var uL=$I;function dL({children:e,align:t=`end`,sideOffset:n=6}){return(0,L.jsx)(eL,{children:(0,L.jsx)(tL,{align:t,sideOffset:n,className:`${bM} min-w-[184px] overflow-hidden rounded-lg p-1`,children:e})})}function fL({children:e,onSelect:t,icon:n,danger:r}){return(0,L.jsxs)(iL,{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 pL(){return(0,L.jsx)(cL,{className:`my-1 h-px bg-border`})}var mL=(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)(hh,{size:p?11:12,className:`animate-spin`}),`Mark as `,s]}),(0,L.jsxs)(lL,{children:[(0,L.jsx)(uL,{"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)(Im,{size:p?11:12})}),(0,L.jsx)(dL,{children:BT.map(e=>(0,L.jsxs)(fL,{onSelect:()=>c(e),children:[`Mark as `,e]},e))})]})]})}),hL=`Dialog`,[gL,_L]=KD(hL),[vL,yL]=gL(hL),bL=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]=Tj({prop:r,defaultProp:i??!1,onChange:a,caller:hL});return(0,L.jsx)(vL,{scope:t,triggerRef:s,contentRef:c,contentId:AO(),titleId:AO(),descriptionId:AO(),open:l,onOpenChange:u,onOpenToggle:I.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};bL.displayName=hL;var xL=`DialogTrigger`,SL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=yL(xL,n),a=GD(t,i.triggerRef);return(0,L.jsx)(sO.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":HL(i.open),...r,ref:a,onClick:HD(e.onClick,i.onOpenToggle)})});SL.displayName=xL;var CL=`DialogPortal`,[wL,TL]=gL(CL,{forceMount:void 0}),EL=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=yL(CL,t);return(0,L.jsx)(wL,{scope:t,forceMount:n,children:I.Children.map(r,e=>(0,L.jsx)(vj,{present:n||a.open,children:(0,L.jsx)(gj,{asChild:!0,container:i,children:e})}))})};EL.displayName=CL;var DL=`DialogOverlay`,OL=I.forwardRef((e,t)=>{let n=TL(DL,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=yL(DL,e.__scopeDialog);return a.modal?(0,L.jsx)(vj,{present:r||a.open,children:(0,L.jsx)(AL,{...i,ref:t})}):null});OL.displayName=DL;var kL=JD(`DialogOverlay.RemoveScroll`),AL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=yL(DL,n),a=GD(t,CO());return(0,L.jsx)(FP,{as:kL,allowPinchZoom:!0,shards:[i.contentRef],children:(0,L.jsx)(sO.div,{"data-state":HL(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})}),jL=`DialogContent`,ML=I.forwardRef((e,t)=>{let n=TL(jL,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=yL(jL,e.__scopeDialog);return(0,L.jsx)(vj,{present:r||a.open,children:a.modal?(0,L.jsx)(NL,{...i,ref:t}):(0,L.jsx)(PL,{...i,ref:t})})});ML.displayName=jL;var NL=I.forwardRef((e,t)=>{let n=yL(jL,e.__scopeDialog),r=I.useRef(null),i=GD(t,n.contentRef,r);return I.useEffect(()=>{let e=r.current;if(e)return EN(e)},[]),(0,L.jsx)(FL,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:HD(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:HD(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:HD(e.onFocusOutside,e=>e.preventDefault())})}),PL=I.forwardRef((e,t)=>{let n=yL(jL,e.__scopeDialog),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(FL,{...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()}})}),FL=I.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=yL(jL,n);return NM(),(0,L.jsx)(L.Fragment,{children:(0,L.jsx)(zM,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(bO,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":HL(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),IL=`DialogTitle`,LL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=yL(IL,n);return(0,L.jsx)(sO.h2,{id:i.titleId,...r,ref:t})});LL.displayName=IL;var RL=`DialogDescription`,zL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=yL(RL,n);return(0,L.jsx)(sO.p,{id:i.descriptionId,...r,ref:t})});zL.displayName=RL;var BL=`DialogClose`,VL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=yL(BL,n);return(0,L.jsx)(sO.button,{type:`button`,...r,ref:t,onClick:HD(e.onClick,()=>i.onOpenChange(!1))})});VL.displayName=BL;function HL(e){return e?`open`:`closed`}var UL=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,GL=/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/;function KL(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(GL.test(a))t[i]=Number(a);else return null}if(n<e.length&&!/\s/.test(e[n]))return null}return t}function qL(e){let t=e.match(/^\s*::([a-z][a-z0-9-]*)\{([^\n]*)\}\s*$/);if(!t||!UL.has(t[1]))return null;let n=KL(t[2]);return n?{name:t[1],attrs:n}:null}var JL=String.raw`(?:[^\s\`]|[ ](?!/))+`,YL=new RegExp(String.raw`^\s*\`?(/${JL}\.(?:png|jpe?g|gif|webp))\`?\s*$`,`i`),XL=new RegExp(String.raw`^\s*\`?(/${JL}\.(?:${Bc.join(`|`)}))\`?\s*$`,`i`),ZL=/^\s{0,3}(?:```|~~~)/,QL=/^\s{0,3}(`{3,}|~{3,})\s*mermaid\s*$/i,$L=/^\s*::codex-inline-vis\{file="([a-z0-9][a-z0-9-]{0,127}\.html)"\}\s*$/;function eR(e){let t=e.split(`
179
+ `},BP=0,VP=[];function HP(e){var t=I.useRef([]),n=I.useRef([0,0]),r=I.useRef(),i=I.useState(BP++)[0],a=I.useState(uP)[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=zN([e.lockRef.current],(e.shards||[]).map(LP),!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=FP(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=OP(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=OP(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 PP(h,t,e,h===`h`?s:c,!0)},[]),c=I.useCallback(function(e){var n=e;if(!(!VP.length||VP[VP.length-1]!==a)){var r=`deltaY`in n?IP(n):FP(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&RP(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(LP).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:UP(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=FP(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,FP(t),t.target,s(t,e.lockRef.current))},[]);I.useEffect(function(){return VP.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,CP),document.addEventListener(`touchmove`,c,CP),document.addEventListener(`touchstart`,u,CP),function(){VP=VP.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,CP),document.removeEventListener(`touchmove`,c,CP),document.removeEventListener(`touchstart`,u,CP)}},[]);var p=e.removeScrollBar,m=e.inert;return I.createElement(I.Fragment,null,m?I.createElement(a,{styles:zP(i)}):null,p?I.createElement(bP,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function UP(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var WP=$N(eP,HP),GP=I.forwardRef(function(e,t){return I.createElement(nP,LN({},e,{ref:t,sideCar:WP}))});GP.classNames=nP.classNames;var KP=[`Enter`,` `],qP=[`ArrowDown`,`PageUp`,`Home`],JP=[`ArrowUp`,`PageDown`,`End`],YP=[...qP,...JP],XP={ltr:[...KP,`ArrowRight`],rtl:[...KP,`ArrowLeft`]},ZP={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},QP=`Menu`,[$P,eF,tF]=RM(QP),[nF,rF]=nO(QP,[tF,aj,mN]),iF=aj(),aF=mN(),[oF,sF]=nF(QP),[cF,lF]=nF(QP),uF=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=iF(t),[c,l]=I.useState(null),u=I.useRef(!1),d=yO(a),f=BM(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)(xj,{...s,children:(0,L.jsx)(oF,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,L.jsx)(cF,{scope:t,onClose:I.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};uF.displayName=QP;var dF=`MenuAnchor`,fF=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=iF(n);return(0,L.jsx)(Sj,{...i,...r,ref:t})});fF.displayName=dF;var pF=`MenuPortal`,[mF,hF]=nF(pF,{forceMount:void 0}),gF=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=sF(pF,t);return(0,L.jsx)(mF,{scope:t,forceMount:n,children:(0,L.jsx)(Oj,{present:n||a.open,children:(0,L.jsx)(Ej,{asChild:!0,container:i,children:r})})})};gF.displayName=pF;var _F=`MenuContent`,[vF,yF]=nF(_F),bF=I.forwardRef((e,t)=>{let n=hF(_F,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=sF(_F,e.__scopeMenu),o=lF(_F,e.__scopeMenu);return(0,L.jsx)($P.Provider,{scope:e.__scopeMenu,children:(0,L.jsx)(Oj,{present:r||a.open,children:(0,L.jsx)($P.Slot,{scope:e.__scopeMenu,children:o.modal?(0,L.jsx)(xF,{...i,ref:t}):(0,L.jsx)(SF,{...i,ref:t})})})})}),xF=I.forwardRef((e,t)=>{let n=sF(_F,e.__scopeMenu),r=I.useRef(null),i=tO(t,r);return I.useEffect(()=>{let e=r.current;if(e)return IN(e)},[]),(0,L.jsx)(wF,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:QD(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),SF=I.forwardRef((e,t)=>{let n=sF(_F,e.__scopeMenu);return(0,L.jsx)(wF,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),CF=iO(`MenuContent.ScrollLock`),wF=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=sF(_F,n),_=lF(_F,n),v=iF(n),y=aF(n),b=eF(n),[x,S]=I.useState(null),C=I.useRef(null),w=tO(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?GP:I.Fragment,M=m?{as:CF,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=cI(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),[]),UM();let P=I.useCallback(e=>k.current===O.current?.side&&uI(e,O.current?.area),[]);return(0,L.jsx)(vF,{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:QD(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,L.jsx)(AO,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,L.jsx)(EN,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:QD(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,L.jsx)(Cj,{role:`menu`,"aria-orientation":`vertical`,"data-state":rI(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:QD(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);JP.includes(e.key)&&a.reverse(),oI(a)}),onBlur:QD(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:QD(e.onPointerMove,dI(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}}))})})})})})})});bF.displayName=_F;var TF=`MenuGroup`,EF=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(_O.div,{role:`group`,...r,ref:t})});EF.displayName=TF;var DF=`MenuLabel`,OF=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(_O.div,{...r,ref:t})});OF.displayName=DF;var kF=`MenuItem`,AF=`menu.itemSelect`,jF=I.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=I.useRef(null),o=lF(kF,e.__scopeMenu),s=yF(kF,e.__scopeMenu),c=tO(t,a),l=I.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(AF,{bubbles:!0,cancelable:!0});e.addEventListener(AF,e=>r?.(e),{once:!0}),vO(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,L.jsx)(MF,{...i,ref:c,disabled:n,onClick:QD(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:QD(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:QD(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||KP.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});jF.displayName=kF;var MF=I.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=yF(kF,n),s=aF(n),c=I.useRef(null),l=tO(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)($P.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,L.jsx)(DN,{asChild:!0,...s,focusable:!r,children:(0,L.jsx)(_O.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:QD(e.onPointerMove,dI(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:QD(e.onPointerLeave,dI(e=>o.onItemLeave(e))),onFocus:QD(e.onFocus,()=>d(!0)),onBlur:QD(e.onBlur,()=>d(!1))})})})}),NF=`MenuCheckboxItem`,PF=I.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,L.jsx)(HF,{scope:e.__scopeMenu,checked:n,children:(0,L.jsx)(jF,{role:`menuitemcheckbox`,"aria-checked":iI(n)?`mixed`:n,...i,ref:t,"data-state":aI(n),onSelect:QD(i.onSelect,()=>r?.(iI(n)?!0:!n),{checkForDefaultPrevented:!1})})})});PF.displayName=NF;var FF=`MenuRadioGroup`,[IF,LF]=nF(FF,{value:void 0,onValueChange:()=>{}}),RF=I.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=yO(r);return(0,L.jsx)(IF,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,L.jsx)(EF,{...i,ref:t})})});RF.displayName=FF;var zF=`MenuRadioItem`,BF=I.forwardRef((e,t)=>{let{value:n,...r}=e,i=LF(zF,e.__scopeMenu),a=n===i.value;return(0,L.jsx)(HF,{scope:e.__scopeMenu,checked:a,children:(0,L.jsx)(jF,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":aI(a),onSelect:QD(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});BF.displayName=zF;var VF=`MenuItemIndicator`,[HF,UF]=nF(VF,{checked:!1}),WF=I.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=UF(VF,n);return(0,L.jsx)(Oj,{present:r||iI(a.checked)||a.checked===!0,children:(0,L.jsx)(_O.span,{...i,ref:t,"data-state":aI(a.checked)})})});WF.displayName=VF;var GF=`MenuSeparator`,KF=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(_O.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});KF.displayName=GF;var qF=`MenuArrow`,JF=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=iF(n);return(0,L.jsx)(wj,{...i,...r,ref:t})});JF.displayName=qF;var YF=`MenuSub`,[XF,ZF]=nF(YF),QF=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=sF(YF,t),o=iF(t),[s,c]=I.useState(null),[l,u]=I.useState(null),d=yO(i);return I.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,L.jsx)(xj,{...o,children:(0,L.jsx)(oF,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,L.jsx)(XF,{scope:t,contentId:BO(),triggerId:BO(),trigger:s,onTriggerChange:c,children:n})})})};QF.displayName=YF;var $F=`MenuSubTrigger`,eI=I.forwardRef((e,t)=>{let n=sF($F,e.__scopeMenu),r=lF($F,e.__scopeMenu),i=ZF($F,e.__scopeMenu),a=yF($F,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=tO(t,i.onTriggerChange);return(0,L.jsx)(fF,{asChild:!0,...l,children:(0,L.jsx)(MF,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":rI(n.open),...e,ref:d,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:QD(e.onPointerMove,dI(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:QD(e.onPointerLeave,dI(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:QD(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||XP[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});eI.displayName=$F;var tI=`MenuSubContent`,nI=I.forwardRef((e,t)=>{let n=hF(_F,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=sF(_F,e.__scopeMenu),s=lF(_F,e.__scopeMenu),c=ZF(tI,e.__scopeMenu),l=I.useRef(null),u=tO(t,l);return(0,L.jsx)($P.Provider,{scope:e.__scopeMenu,children:(0,L.jsx)(Oj,{present:r||o.open,children:(0,L.jsx)($P.Slot,{scope:e.__scopeMenu,children:(0,L.jsx)(wF,{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:QD(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:QD(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:QD(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=ZP[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})});nI.displayName=tI;function rI(e){return e?`open`:`closed`}function iI(e){return e===`indeterminate`}function aI(e){return iI(e)?`indeterminate`:e?`checked`:`unchecked`}function oI(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function sI(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function cI(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=sI(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 lI(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 uI(e,t){return t?lI({x:e.clientX,y:e.clientY},t):!1}function dI(e){return t=>t.pointerType===`mouse`?e(t):void 0}var fI=uF,pI=fF,mI=gF,hI=bF,gI=EF,_I=OF,vI=jF,yI=PF,bI=RF,xI=BF,SI=WF,CI=KF,wI=JF,TI=eI,EI=nI,DI=`DropdownMenu`,[OI,kI]=nO(DI,[rF]),AI=rF(),[jI,MI]=OI(DI),NI=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=AI(t),l=I.useRef(null),[u,d]=Fj({prop:i,defaultProp:a??!1,onChange:o,caller:DI});return(0,L.jsx)(jI,{scope:t,triggerId:BO(),triggerRef:l,contentId:BO(),open:u,onOpenChange:d,onOpenToggle:I.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,L.jsx)(fI,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};NI.displayName=DI;var PI=`DropdownMenuTrigger`,FI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=MI(PI,n),o=AI(n),s=tO(t,a.triggerRef);return(0,L.jsx)(pI,{asChild:!0,...o,children:(0,L.jsx)(_O.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:QD(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:QD(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});FI.displayName=PI;var II=`DropdownMenuPortal`,LI=e=>{let{__scopeDropdownMenu:t,...n}=e,r=AI(t);return(0,L.jsx)(mI,{...r,...n})};LI.displayName=II;var RI=`DropdownMenuContent`,zI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=MI(RI,n),a=AI(n),o=I.useRef(!1);return(0,L.jsx)(hI,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:QD(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:QD(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)`}})});zI.displayName=RI;var BI=`DropdownMenuGroup`,VI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=AI(n);return(0,L.jsx)(gI,{...i,...r,ref:t})});VI.displayName=BI;var HI=`DropdownMenuLabel`,UI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=AI(n);return(0,L.jsx)(_I,{...i,...r,ref:t})});UI.displayName=HI;var WI=`DropdownMenuItem`,GI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=AI(n);return(0,L.jsx)(vI,{...i,...r,ref:t})});GI.displayName=WI;var KI=`DropdownMenuCheckboxItem`,qI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=AI(n);return(0,L.jsx)(yI,{...i,...r,ref:t})});qI.displayName=KI;var JI=`DropdownMenuRadioGroup`,YI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=AI(n);return(0,L.jsx)(bI,{...i,...r,ref:t})});YI.displayName=JI;var XI=`DropdownMenuRadioItem`,ZI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=AI(n);return(0,L.jsx)(xI,{...i,...r,ref:t})});ZI.displayName=XI;var QI=`DropdownMenuItemIndicator`,$I=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=AI(n);return(0,L.jsx)(SI,{...i,...r,ref:t})});$I.displayName=QI;var eL=`DropdownMenuSeparator`,tL=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=AI(n);return(0,L.jsx)(CI,{...i,...r,ref:t})});tL.displayName=eL;var nL=`DropdownMenuArrow`,rL=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=AI(n);return(0,L.jsx)(wI,{...i,...r,ref:t})});rL.displayName=nL;var iL=`DropdownMenuSubTrigger`,aL=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=AI(n);return(0,L.jsx)(TI,{...i,...r,ref:t})});aL.displayName=iL;var oL=`DropdownMenuSubContent`,sL=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=AI(n);return(0,L.jsx)(EI,{...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)`}})});sL.displayName=oL;var cL=NI,lL=FI,uL=LI,dL=zI,fL=VI,pL=UI,mL=GI,hL=YI,gL=ZI,_L=$I,vL=tL;function yL({modal:e=!1,...t}){return(0,L.jsx)(cL,{modal:e,...t})}var bL=lL;function xL({children:e,align:t=`end`,sideOffset:n=6}){return(0,L.jsx)(uL,{children:(0,L.jsx)(dL,{align:t,sideOffset:n,className:`${AM} min-w-[184px] overflow-hidden rounded-lg p-1`,children:e})})}function SL({children:e,onSelect:t,icon:n,danger:r}){return(0,L.jsxs)(mL,{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 CL(){return(0,L.jsx)(vL,{className:`my-1 h-px bg-border`})}var wL=(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)(hh,{size:p?11:12,className:`animate-spin`}),`Mark as `,s]}),(0,L.jsxs)(yL,{children:[(0,L.jsx)(bL,{"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)(Im,{size:p?11:12})}),(0,L.jsx)(xL,{children:XT.map(e=>(0,L.jsxs)(SL,{onSelect:()=>c(e),children:[`Mark as `,e]},e))})]})]})}),TL=`Dialog`,[EL,DL]=nO(TL),[OL,kL]=EL(TL),AL=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]=Fj({prop:r,defaultProp:i??!1,onChange:a,caller:TL});return(0,L.jsx)(OL,{scope:t,triggerRef:s,contentRef:c,contentId:BO(),titleId:BO(),descriptionId:BO(),open:l,onOpenChange:u,onOpenToggle:I.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};AL.displayName=TL;var jL=`DialogTrigger`,ML=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=kL(jL,n),a=tO(t,i.triggerRef);return(0,L.jsx)(_O.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":QL(i.open),...r,ref:a,onClick:QD(e.onClick,i.onOpenToggle)})});ML.displayName=jL;var NL=`DialogPortal`,[PL,FL]=EL(NL,{forceMount:void 0}),IL=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=kL(NL,t);return(0,L.jsx)(PL,{scope:t,forceMount:n,children:I.Children.map(r,e=>(0,L.jsx)(Oj,{present:n||a.open,children:(0,L.jsx)(Ej,{asChild:!0,container:i,children:e})}))})};IL.displayName=NL;var LL=`DialogOverlay`,RL=I.forwardRef((e,t)=>{let n=FL(LL,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=kL(LL,e.__scopeDialog);return a.modal?(0,L.jsx)(Oj,{present:r||a.open,children:(0,L.jsx)(BL,{...i,ref:t})}):null});RL.displayName=LL;var zL=iO(`DialogOverlay.RemoveScroll`),BL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=kL(LL,n),a=tO(t,NO());return(0,L.jsx)(GP,{as:zL,allowPinchZoom:!0,shards:[i.contentRef],children:(0,L.jsx)(_O.div,{"data-state":QL(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})}),VL=`DialogContent`,HL=I.forwardRef((e,t)=>{let n=FL(VL,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=kL(VL,e.__scopeDialog);return(0,L.jsx)(Oj,{present:r||a.open,children:a.modal?(0,L.jsx)(UL,{...i,ref:t}):(0,L.jsx)(WL,{...i,ref:t})})});HL.displayName=VL;var UL=I.forwardRef((e,t)=>{let n=kL(VL,e.__scopeDialog),r=I.useRef(null),i=tO(t,n.contentRef,r);return I.useEffect(()=>{let e=r.current;if(e)return IN(e)},[]),(0,L.jsx)(GL,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:QD(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:QD(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:QD(e.onFocusOutside,e=>e.preventDefault())})}),WL=I.forwardRef((e,t)=>{let n=kL(VL,e.__scopeDialog),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(GL,{...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()}})}),GL=I.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=kL(VL,n);return UM(),(0,L.jsx)(L.Fragment,{children:(0,L.jsx)(YM,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(AO,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":QL(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),KL=`DialogTitle`,qL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=kL(KL,n);return(0,L.jsx)(_O.h2,{id:i.titleId,...r,ref:t})});qL.displayName=KL;var JL=`DialogDescription`,YL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=kL(JL,n);return(0,L.jsx)(_O.p,{id:i.descriptionId,...r,ref:t})});YL.displayName=JL;var XL=`DialogClose`,ZL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=kL(XL,n);return(0,L.jsx)(_O.button,{type:`button`,...r,ref:t,onClick:QD(e.onClick,()=>i.onOpenChange(!1))})});ZL.displayName=XL;function QL(e){return e?`open`:`closed`}var $L=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`]),eR=/[a-zA-Z_][a-zA-Z0-9_-]*/y,tR=/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/;function nR(e){let t={},n=0;for(;n<e.length;){for(;/\s/.test(e[n]??``);)n++;if(n>=e.length)break;eR.lastIndex=n;let r=eR.exec(e);if(!r||Object.hasOwn(t,r[0]))return null;let i=r[0];if(n=eR.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(tR.test(a))t[i]=Number(a);else return null}if(n<e.length&&!/\s/.test(e[n]))return null}return t}function rR(e){let t=e.match(/^\s*::([a-z][a-z0-9-]*)\{([^\n]*)\}\s*$/);if(!t||!$L.has(t[1]))return null;let n=nR(t[2]);return n?{name:t[1],attrs:n}:null}var iR=String.raw`(?:[^\s\`]|[ ](?!/))+`,aR=new RegExp(String.raw`^\s*\`?(/${iR}\.(?:png|jpe?g|gif|webp))\`?\s*$`,`i`),oR=new RegExp(String.raw`^\s*\`?(/${iR}\.(?:${Bc.join(`|`)}))\`?\s*$`,`i`),sR=/^\s{0,3}(?:```|~~~)/,cR=/^\s{0,3}(`{3,}|~{3,})\s*mermaid\s*$/i,lR=/^\s*::codex-inline-vis\{file="([a-z0-9][a-z0-9-]{0,127}\.html)"\}\s*$/;function uR(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(QL)?.[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(ZL.test(o)){i=!i,r.push(o);continue}if(i){r.push(o);continue}let s=o.match($L);if(s){a(),n.push({kind:`visualization`,file:s[1]});continue}let c=qL(o);if(c){a(),n.push({kind:`directive`,directive:c});continue}let l=o.match(YL);if(l){a(),n.push({kind:`image`,path:l[1]});continue}let u=o.match(XL);if(u){a(),n.push({kind:`file`,path:u[1]});continue}r.push(o)}return a(),n}function tR(e){let t=e.split(`
183
- `),n=Array(t.length),r=!1;for(let e=0;e<t.length;e++)ZL.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(YL),r=n?null:e.match(XL);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 nR(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(cR)?.[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(sR.test(o)){i=!i,r.push(o);continue}if(i){r.push(o);continue}let s=o.match(lR);if(s){a(),n.push({kind:`visualization`,file:s[1]});continue}let c=rR(o);if(c){a(),n.push({kind:`directive`,directive:c});continue}let l=o.match(aR);if(l){a(),n.push({kind:`image`,path:l[1]});continue}let u=o.match(oR);if(u){a(),n.push({kind:`file`,path:u[1]});continue}r.push(o)}return a(),n}function dR(e){let t=e.split(`
183
+ `),n=Array(t.length),r=!1;for(let e=0;e<t.length;e++)sR.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(aR),r=n?null:e.match(oR);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 fR(e,t){return t.length?`${e}${e?`
185
185
  `:``}${t.join(`
186
- `)}`:e}function rR(e){let t=_p(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 iR(e){return e.startsWith(`@`)?e.slice(1):e}function aR(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var oR=`(?![0-9#]|-\\d)`;function sR(e,t){return new RegExp(aR(t)+oR).test(e)}function cR(e,t){let n=new RegExp(aR(t)+oR).exec(e);return n?n.index:-1}function lR(e,t,n){let r=`@${e}`,i=e=>t.some(t=>t.token===e)||sR(n,e);if(!i(r))return r;for(let e=2;;e++)if(!i(`${r}#${e}`))return`${r}#${e}`}function uR(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 dR(e,t){if(!t.length||!e)return e?[{text:e}]:[];let n=[...new Set(t)].sort((e,t)=>t.length-e.length).map(aR).join(`|`),r=RegExp(`(${n})${oR}`,`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 fR(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 pR(e,t){return t&&xp(t,e)||e}function mR(e){return e.startLine===void 0||e.endLine===void 0?``:e.startLine===e.endLine?`, line ${e.startLine}`:`, lines ${e.startLine}-${e.endLine}`}function hR(e,t){return e.length?`Selected context:\n\n${e.map(e=>{let n=e.text.replace(/\s+$/,``).split(`
186
+ `)}`:e}function pR(e){let t=_p(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 mR(e){return e.startsWith(`@`)?e.slice(1):e}function hR(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var gR=`(?![0-9#]|-\\d)`;function _R(e,t){return new RegExp(hR(t)+gR).test(e)}function vR(e,t){let n=new RegExp(hR(t)+gR).exec(e);return n?n.index:-1}function yR(e,t,n){let r=`@${e}`,i=e=>t.some(t=>t.token===e)||_R(n,e);if(!i(r))return r;for(let e=2;;e++)if(!i(`${r}#${e}`))return`${r}#${e}`}function bR(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 xR(e,t){if(!t.length||!e)return e?[{text:e}]:[];let n=[...new Set(t)].sort((e,t)=>t.length-e.length).map(hR).join(`|`),r=RegExp(`(${n})${gR}`,`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 SR(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 CR(e,t){return t&&xp(t,e)||e}function wR(e){return e.startLine===void 0||e.endLine===void 0?``:e.startLine===e.endLine?`, line ${e.startLine}`:`, lines ${e.startLine}-${e.endLine}`}function TR(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} (${pR(e.path,t)}${mR(e)}):\n${n}`}).join(`
189
+ `);return`${e.token} (${CR(e.path,t)}${wR(e)}):\n${n}`}).join(`
190
190
 
191
- `)}`:``}function gR(e,t,n){let{prose:r,attachments:i}=tR(e),a=hR(t.filter(e=>sR(r,e.token)).sort((e,t)=>cR(r,e.token)-cR(r,t.token)),n);return a?nR(r.trimEnd()?`${r.trimEnd()}\n\n${a}`:a,i.map(e=>e.path)):e}var _R=`Selected context:
191
+ `)}`:``}function ER(e,t,n){let{prose:r,attachments:i}=dR(e),a=TR(t.filter(e=>_R(r,e.token)).sort((e,t)=>vR(r,e.token)-vR(r,t.token)),n);return a?fR(r.trimEnd()?`${r.trimEnd()}\n\n${a}`:a,i.map(e=>e.path)):e}var DR=`Selected context:
192
192
 
193
- `;function vR(e){let t=e.lastIndexOf(_R);if(t===-1||t!==0&&e.slice(t-2,t)!==`
193
+ `;function OR(e){let t=e.lastIndexOf(DR);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=>sR(n,e.token))?null:{body:n,items:i}}function yR(e){return e.key===`Enter`&&!e.altKey&&!e.shiftKey&&!e.isComposing&&e.keyCode!==229}function bR(e,t){return t&&yR(e)&&!e.metaKey&&!e.ctrlKey}function xR(e,t){return t&&yR(e)&&(e.metaKey||e.ctrlKey)}function SR(e){return yR(e)}function CR(e){return e.key===`Enter`&&e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing}function wR(e,t,n){return e===`queueComposer`&&t===`Enter`&&n}var TR=`gap-3`,ER=`-mx-1`,DR=`-mx-[3px]`,OR=`right-2`,kR=`right-[71px]`,AR=`right-[44px]`,jR=`pr-[6.6875rem]`,MR=`pr-20`;async function NR(e,t){let n=tf(),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 PR={project:`project`,user:`global`,builtin:`built-in`,plugin:`plugin`};function FR(e,t){e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,t)}px`}function IR({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)(()=>tR(e),[e]),w=C.map(e=>e.path),T=(0,I.useRef)(e);T.current=e;let E=e=>t(nR(e,w)),D=e=>t(nR(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})=>Gc(e)?!0:(Z(`${e||`File`}: unsupported file type`),!1));if(!n.length)return;let r=n.filter(({file:e,name:t})=>e.size>Hc?(Z(`${t} is too large (max ${Math.floor(Hc/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 NR(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=tR(T.current);t(nR(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||FR(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=dR(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(PR[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=dR(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(wR(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(bR(i,a)){e.preventDefault(),e.stopPropagation(),n();return}if(xR(i,a)){e.preventDefault(),e.stopPropagation(),(m??n)();return}if(CR(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?PR[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,"data-claims-escape":!0,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?jR:MR}`} 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)(LR,{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:Kc,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?kR:AR} 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)(hh,{size:15,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(Ch,{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)(hh,{size:14,strokeWidth:2.5,className:`animate-spin`}):(0,L.jsx)(jm,{size:14,strokeWidth:2.5})})]})}function LR({attachment:e,disabled:t,onRemove:n}){let[r,i]=(0,I.useState)(!1),a=_p(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:mC(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)($m,{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)(Hh,{size:10,strokeWidth:2.5})})]})}function RR(){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 zR(){let e=RR();return!!(e.data?.inRepo&&e.data.authed)}function BR({className:e=``}){return zR()?(0,L.jsx)(`button`,{type:`button`,onClick:Np,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)(sh,{size:15,strokeWidth:2})}):null}var VR=`prompt-control-type petite-caps`,HR=VR,UR=VR,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 ${HR} 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 GR(e){return`minmax(6rem, 7rem) repeat(${Math.max(0,e)}, auto)`}var KR=[`ultra`,`ultracode`],qR=[`low`,`medium`,`high`,`xhigh`,`max`,...KR];function JR(e){return[...new Set(e.flatMap(e=>e.options.flatMap(e=>e.efforts)))].sort((e,t)=>{let n=qR.indexOf(e),r=qR.indexOf(t);return n===-1&&r===-1?e.localeCompare(t):n===-1?1:r===-1?-1:n-r})}function YR(e){let t=[];for(let n of JR(e)){let e=KR.includes(n)?t.find(e=>KR.includes(e[0])):void 0;e?e.push(n):t.push([n])}return t}function XR(e){return e.efforts.length?e.efforts:[``]}function ZR(e){return e.flatMap(e=>e.options.flatMap(t=>XR(t).map(n=>({provider:e.id,model:t.model,effort:n}))))}function QR(e){return JSON.stringify([e.provider,e.model,e.effort])}function $R(e,t){return ZR(e).find(e=>QR(e)===t)}function ez(e,t){return!t?.model||t.effort===void 0?!1:e.some(e=>(!t.provider||e.id===t.provider)&&e.options.some(e=>e.model===t.model&&XR(e).includes(t.effort)))}function tz(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 nz(e,t,n){let r=YR(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=XR(s.option),l=c.indexOf(t.effort);if(l===-1)return null;if(n===`Home`||n===`End`||n===`ArrowLeft`||n===`ArrowRight`){let e=c[n===`Home`?0:n===`End`?c.length-1:l+(n===`ArrowLeft`?-1:1)];return e===void 0?null:{provider:s.provider,model:s.option.model,effort:e}}let u=a[o+(n===`ArrowUp`?-1:1)];if(!u)return null;let d=i(t.effort),f=XR(u.option).reduce((e,t)=>e===void 0||Math.abs(i(t)-d)<Math.abs(i(e)-d)?t:e,void 0);return f===void 0?null:{provider:u.provider,model:u.option.model,effort:f}}var rz,iz=!1;function az(){iz||typeof window>`u`||(iz=!0,window.addEventListener(`keydown`,e=>{e.key!==`Escape`||!rz||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),sz())},{capture:!0}))}function oz(e){az();let t={dismiss:e};return rz=t,()=>{rz===t&&(rz=void 0)}}function sz(){let e=rz;return e?(rz=void 0,e.dismiss(),!0):!1}function cz(e){sz()&&e.preventDefault(),e.stopPropagation()}var lz=`default`;function uz(e){return e>=1e6?`${dz(e/1e6)}M`:e>=1e3?`${dz(e/1e3)}k`:String(e)}function dz(e){return Number.isInteger(e)?String(e):e.toFixed(2).replace(/0+$/,``).replace(/\.$/,``)}var fz=[{value:872e3,models:[]}];function pz(e,t){let n=e??[],r=n.find(e=>e.contextWindow!==void 0)?.contextWindow??272e3,i=`${uz(r)} (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})):fz,s=[{value:lz,label:i}];for(let e of o){let t=o.length===1||e.models.length===0?`maximum`:`${e.models.join(`, `)} maximum`;s.push({value:String(e.value),label:`${uz(e.value)} (${t})`})}for(let e of[472e3,672e3])e>r&&o.some(t=>t.value>e)&&!s.some(t=>t.value===String(e))&&s.push({value:String(e),label:uz(e)});return t!==void 0&&!s.some(e=>e.value===String(t))&&s.push({value:String(t),label:uz(t)}),[s[0],...s.slice(1).sort((e,t)=>Number(e.value)-Number(t.value))]}var mz=[{value:`200000`,label:`200k`},{value:`350000`,label:`350k`},{value:`500000`,label:`500k (default)`},{value:`750000`,label:`750k`},{value:`1000000`,label:`1M (maximum)`}],hz={claude:`Compaction window for new Claude threads in this project. Applies on dispatch or after the worker exits, not to a running worker.`,codex:`Context window for new Codex threads in this project. Each model caps the value at its own maximum. Applies on dispatch or a cold resume, not to a running worker.`};typeof window<`u`&&window.document&&window.document.createElement;function gz(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)}}function _z(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,vz(i,...t)]}function vz(...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 yz=`DismissableLayer`,bz=`dismissableLayer.update`,xz=`dismissableLayer.pointerDownOutside`,Sz=`dismissableLayer.focusOutside`,Cz,wz=I.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Tz=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(wz),[d,f]=I.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=I.useState({}),h=GD(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=kz(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=Az(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=lO(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&&(Cz=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),jz(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=Cz))}},[d,p,n,u]),I.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),jz())},[d,u]),I.useEffect(()=>{let e=()=>m({});return document.addEventListener(bz,e),()=>document.removeEventListener(bz,e)},[]),(0,L.jsx)(sO.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:gz(e.onFocusCapture,w.onFocusCapture),onBlurCapture:gz(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:gz(e.onPointerDownCapture,C.onPointerDownCapture)})});Tz.displayName=yz;var Ez=`DismissableLayerBranch`,Dz=I.forwardRef((e,t)=>{let n=I.useContext(wz),r=I.useRef(null),i=GD(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)(sO.div,{...e,ref:i})});Dz.displayName=Ez;var Oz=()=>!0;function kz(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Oz}=t,s=lO(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||Mz(xz,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 Az(e,t=globalThis?.document){let n=lO(e),r=I.useRef(!1);return I.useEffect(()=>{let e=e=>{e.target&&!r.current&&Mz(Sz,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 jz(){let e=new CustomEvent(bz);document.dispatchEvent(e)}function Mz(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?cO(i,a):i.dispatchEvent(a)}var Nz=`focusScope.autoFocusOnMount`,Pz=`focusScope.autoFocusOnUnmount`,Fz={bubbles:!1,cancelable:!0},Iz=`FocusScope`,Lz=I.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=I.useState(null),l=lO(i),u=lO(a),d=I.useRef(null),f=GD(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:Wz(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Wz(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Wz(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){Gz.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Nz,Fz);s.addEventListener(Nz,l),s.dispatchEvent(t),t.defaultPrevented||(Rz(Jz(Bz(s)),{select:!0}),document.activeElement===e&&Wz(s))}return()=>{s.removeEventListener(Nz,l),setTimeout(()=>{let t=new CustomEvent(Pz,Fz);s.addEventListener(Pz,u),s.dispatchEvent(t),t.defaultPrevented||Wz(e??document.body,{select:!0}),s.removeEventListener(Pz,u),Gz.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]=zz(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Wz(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Wz(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,L.jsx)(sO.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});Lz.displayName=Iz;function Rz(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Wz(r,{select:t}),document.activeElement!==n)return}function zz(e){let t=Bz(e);return[Vz(t,e),Vz(t.reverse(),e)]}function Bz(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 Vz(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Hz(r,{upTo:t})))return r}function Hz(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 Uz(e){return e instanceof HTMLInputElement&&`select`in e}function Wz(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Uz(e)&&t&&e.select()}}var Gz=Kz();function Kz(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=qz(e,t),e.unshift(t)},remove(t){e=qz(e,t),e[0]?.resume()}}}function qz(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function Jz(e){return e.filter(e=>e.tagName!==`A`)}var Yz=`Popper`,[Xz,Zz]=_z(Yz),[Qz,$z]=Xz(Yz),eB=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null),[a,o]=I.useState(void 0);return(0,L.jsx)(Qz,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};eB.displayName=Yz;var tB=`PopperAnchor`,nB=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=$z(tB,n),o=I.useRef(null),s=a.onAnchorChange,c=GD(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&&fB(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,L.jsx)(sO.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})});nB.displayName=tB;var rB=`PopperContent`,[iB,aB]=Xz(rB),oB=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=$z(rB,n),[_,v]=I.useState(null),y=GD(t,v),[b,x]=I.useState(null),S=KA(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(uB),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=PA({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>bA(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[IA({mainAxis:i+w,alignmentAxis:o}),c&&LA({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?RA():void 0,...k}),c&&zA({...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&&HA({element:b,padding:s}),dB({arrowWidth:C,arrowHeight:w}),f&&VA({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ee=g.setPlacementState;uO(()=>(ee(M),()=>{ee(void 0)}),[M,ee]);let[F,te]=fB(M),ne=lO(m);uO(()=>{N&&ne?.()},[N,ne]);let re=P.arrow?.x,ie=P.arrow?.y,ae=P.arrow?.centerOffset!==0,[oe,se]=I.useState();return uO(()=>{_&&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)(iB,{scope:n,placedSide:F,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,L.jsx)(sO.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});oB.displayName=rB;var sB=`PopperArrow`,cB={top:`bottom`,right:`left`,bottom:`top`,left:`right`},lB=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=aB(sB,n),a=cB[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)(GA,{...r,ref:t,style:{...r.style,display:`block`}})})});lB.displayName=sB;function uB(e){return e!==null}var dB=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]=fB(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 fB(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var pB=eB,mB=nB,hB=oB,gB=lB;function _B(e,t){return I.useReducer((e,n)=>t[e][n]??e,e)}var vB=e=>{let{present:t,children:n}=e,r=yB(t),i=typeof n==`function`?n({present:r.isPresent}):I.Children.only(n),a=xB(r.ref,CB(i));return typeof n==`function`||r.isPresent?I.cloneElement(i,{ref:a}):null};vB.displayName=`Presence`;function yB(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]=_B(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??SB(r.current),o.current=void 0):a.current=`none`},[s]),uO(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=SB(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]),uO(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=SB(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=SB(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=SB(t)}else r.current=null;n(e)},[])}}function bB(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function xB(...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=bB(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():bB(n[e],null)}}},[])}function SB(e){return e?.animationName||`none`}function CB(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 wB=`Popover`,[TB,EB]=_z(wB,[Zz]),DB=Zz(),[OB,kB]=TB(wB),AB=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=DB(t),c=I.useRef(null),[l,u]=I.useState(!1),[d,f]=Tj({prop:r,defaultProp:i??!1,onChange:a,caller:wB});return(0,L.jsx)(pB,{...s,children:(0,L.jsx)(OB,{scope:t,contentId:AO(),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})})};AB.displayName=wB;var jB=`PopoverAnchor`,MB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=kB(jB,n),a=DB(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return I.useEffect(()=>(o(),()=>s()),[o,s]),(0,L.jsx)(mB,{...a,...r,ref:t})});MB.displayName=jB;var NB=`PopoverTrigger`,PB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=kB(NB,n),a=DB(n),o=GD(t,i.triggerRef),s=(0,L.jsx)(sO.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":YB(i.open),...r,ref:o,onClick:gz(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,L.jsx)(mB,{asChild:!0,...a,children:s})});PB.displayName=NB;var FB=`PopoverPortal`,[IB,LB]=TB(FB,{forceMount:void 0}),RB=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=kB(FB,t);return(0,L.jsx)(IB,{scope:t,forceMount:n,children:(0,L.jsx)(vB,{present:n||a.open,children:(0,L.jsx)(gj,{asChild:!0,container:i,children:r})})})};RB.displayName=FB;var zB=`PopoverContent`,BB=I.forwardRef((e,t)=>{let n=LB(zB,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=kB(zB,e.__scopePopover);return(0,L.jsx)(vB,{present:r||a.open,children:a.modal?(0,L.jsx)(HB,{...i,ref:t}):(0,L.jsx)(UB,{...i,ref:t})})});BB.displayName=zB;var VB=JD(`PopoverContent.RemoveScroll`),HB=I.forwardRef((e,t)=>{let n=kB(zB,e.__scopePopover),r=I.useRef(null),i=GD(t,r),a=I.useRef(!1);return I.useEffect(()=>{let e=r.current;if(e)return EN(e)},[]),(0,L.jsx)(FP,{as:VB,allowPinchZoom:!0,children:(0,L.jsx)(WB,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:gz(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:gz(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:gz(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),UB=I.forwardRef((e,t)=>{let n=kB(zB,e.__scopePopover),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(WB,{...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()}})}),WB=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=kB(zB,n),p=DB(n);return NM(),(0,L.jsx)(Lz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(Tz,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,L.jsx)(hB,{"data-state":YB(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)`}})})})}),GB=`PopoverClose`,KB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=kB(GB,n);return(0,L.jsx)(sO.button,{type:`button`,...r,ref:t,onClick:gz(e.onClick,()=>i.onOpenChange(!1))})});KB.displayName=GB;var qB=`PopoverArrow`,JB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=DB(n);return(0,L.jsx)(gB,{...i,...r,ref:t})});JB.displayName=qB;function YB(e){return e?`open`:`closed`}var XB=AB,ZB=MB,QB=PB,$B=RB,eV=BB;function tV({modal:e=!1,...t}){return(0,L.jsx)(XB,{modal:e,...t})}var nV=QB,rV=ZB;function iV({children:e,side:t=`top`,align:n=`center`,sideOffset:r=6,className:i=``,...a}){return(0,L.jsx)($B,{children:(0,L.jsx)(eV,{side:t,align:n,sideOffset:r,avoidCollisions:!0,collisionPadding:12,onEscapeKeyDown:e=>e.stopPropagation(),className:`${vM} ${SM} rounded-lg outline-none ${i}`,...a,children:e})})}function aV({backend:e,open:t,onOpenChange:n}){let r=Ve(),i=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()}),a=nt({queryKey:[`codexModels`],queryFn:()=>Y.codexModels(),enabled:e===`codex`}),o=it({mutationKey:[`contextWindowSet`]})>0,s=(0,I.useRef)(null),c=st({mutationKey:[`contextWindowSet`],mutationFn:t=>Y.contextWindowSet({backend:e,tokens:t}),onMutate:()=>({query:r.getQueryCache().find({queryKey:[`settingsGet`]})}),onSuccess:(e,t,n)=>{n?.query?.setData(e)},onError:e=>Z(`Could not save context window: ${e.message.slice(0,80)}`)}),l=e===`claude`?i.data?.autoCompactWindow??5e5:i.data?.codexContextWindow,u=l===void 0?lz:String(l),d=e===`codex`?pz(a.data,l):[...mz,...mz.some(e=>e.value===u)?[]:[{value:u,label:uz(l)}]],f=e===`claude`?`Compaction window`:`Context window`,p=e===`claude`?`Claude Code`:`Codex`,m=d.find(e=>e.value===u);return(0,L.jsxs)(tV,{open:t,onOpenChange:n,children:[(0,L.jsx)(iL,{asChild:!0,disabled:!i.data||o,onSelect:e=>e.preventDefault(),children:(0,L.jsx)(nV,{asChild:!0,children:(0,L.jsxs)(`button`,{type:`button`,"aria-label":`${p} ${f.toLowerCase()}`,title:hz[e],disabled:!i.data||o,className:`context-window-trigger inline-flex shrink-0 items-baseline gap-1.5 rounded-[5px] border border-border/80 bg-transparent px-1.5 py-0.5 text-[11px] leading-4 text-muted outline-none hover:border-muted hover:bg-panel-2 hover:text-fg data-[state=open]:border-muted data-[state=open]:bg-panel-2 data-[state=open]:text-fg disabled:opacity-45`,style:{fontVariantCaps:`normal`,letterSpacing:`normal`},children:[(0,L.jsx)(`span`,{className:`context-window-value`,children:i.data?m.label.split(` (`)[0]:`…`}),(0,L.jsx)(Im,{"aria-hidden":`true`,className:`-mx-[0.25em] size-[1em] shrink-0 translate-y-[calc(0.5em_-_0.5cap)]`})]})})}),(0,L.jsxs)(iV,{side:`bottom`,align:`end`,sideOffset:5,className:`w-[204px] max-w-[calc(100vw-1rem)] p-1 text-[12px] leading-[18px]`,style:{fontVariantCaps:`normal`,letterSpacing:`normal`},"data-context-window-menu":e,onOpenAutoFocus:e=>{e.preventDefault(),s.current?.querySelector(`[aria-checked="true"]`)?.focus()},onKeyDown:e=>{if(e.stopPropagation(),![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=[...s.current.querySelectorAll(`button`)],n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()},children:[(0,L.jsx)(`p`,{className:`px-2 py-1.5 text-[11px] text-muted`,children:f}),(0,L.jsx)(`div`,{ref:s,role:`menu`,"aria-label":`${p} ${f.toLowerCase()} options`,children:d.map(e=>(0,L.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e.value===u,disabled:o,onClick:()=>{n(!1),e.value!==u&&c.mutate(e.value==="default"?null:Number(e.value))},className:`flex w-full items-center justify-between rounded-[5px] px-2 py-1.5 text-left text-muted outline-none hover:bg-panel-2 hover:text-fg focus-visible:bg-panel-2 aria-checked:bg-panel-2 aria-checked:text-fg`,children:[(0,L.jsx)(`span`,{children:e.label}),e.value===u&&(0,L.jsx)(Fm,{"aria-hidden":`true`,size:13,className:`text-accent`})]},e.value))})]})]})}function oV(e){return e===`xhigh`?`X-high`:e.charAt(0).toUpperCase()+e.slice(1)}function sV({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=yM,className:f=``,contextWindows:p=!1}){let[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(null),v=(0,I.useRef)(g);v.current=g;let y=(0,I.useRef)(m),b=(0,I.useRef)(c),x=(0,I.useRef)(void 0),S=(0,I.useRef)(new Map),C=(0,I.useRef)(void 0),w=(0,I.useMemo)(()=>YR(e),[e]),T=(0,I.useMemo)(()=>ZR(e),[e]),E=l?UR:HR,D=c?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors hover:border-border hover:bg-panel-2 hover:text-fg`,O=ez(e,t),k=O&&t?.provider&&t.model?QR({provider:t.provider,model:t.model,effort:t.effort??``}):void 0,A=n?.model||n?.effort?tz(e,n,`Pending profile`):void 0;y.current=m,b.current=c;function j(){_(null),y.current=!1,x.current=void 0,h(!1)}function M(){v.current?(v.current=null,_(null),x.current=oz(M)):j()}(0,I.useLayoutEffect)(()=>{let e=e=>{e.key!==`Escape`||!y.current||b.current||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),x.current?.(),M())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]),(0,I.useLayoutEffect)(()=>{!c||!m||(x.current?.(),j())},[c,m]),(0,I.useLayoutEffect)(()=>()=>x.current?.(),[]),(0,I.useLayoutEffect)(()=>{k===C.current&&(C.current=void 0)},[k]);function N(e){let t=QR(e);C.current!==t&&(C.current=t,r(e))}function P(t,n){if(![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(t.key))return;let r=nz(e,n,t.key);r&&(t.preventDefault(),t.stopPropagation(),S.current.get(QR(r))?.focus())}return(0,L.jsxs)(QI,{modal:!1,open:m,onOpenChange:e=>{x.current?.(),x.current=void 0,y.current=e,h(e),e?x.current=oz(M):_(null)},children:[(0,L.jsx)($I,{asChild:!0,disabled:c,children:(0,L.jsxs)(`button`,{type:`button`,"aria-label":a,"aria-invalid":!O&&(t?.model||t?.effort)?!0:void 0,"aria-description":A?`Pending ${A}`:void 0,title:s,"data-profile-known":O?`true`:`false`,"data-profile-pending":A?`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 ${D} ${f} ${E}`,children:[(0,L.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 flex-1 truncate text-left ${E}`,children:tz(e,t,i)}),A&&(0,L.jsx)(hh,{"aria-hidden":`true`,size:l?10:11,className:`shrink-0 animate-spin text-muted/65`}),(0,L.jsx)(Im,{"aria-hidden":`true`,size:l?11:13,className:`shrink-0 text-fg/65 transition-transform group-data-[state=open]:rotate-180`})]})}),(0,L.jsx)(eL,{children:(0,L.jsxs)(tL,{"aria-label":o,align:`start`,side:u,sideOffset:5,collisionPadding:8,onEscapeKeyDown:e=>e.stopPropagation(),onInteractOutside:e=>{e.target instanceof Element&&e.target.closest(`[data-context-window-menu]`)&&e.preventDefault()},className:`profile-grid-menu ${d} ${vM} max-h-[min(360px,var(--radix-dropdown-menu-content-available-height))] max-w-[calc(100vw-1rem)] overflow-auto rounded-lg p-1.5 ${E}`,children:[e.map(t=>(0,L.jsxs)(nL,{children:[t.label&&(0,L.jsxs)(`div`,{className:`profile-grid-header sticky left-0 flex items-baseline justify-between gap-4 px-1.5 pb-1 pt-1 first:pt-0.5`,children:[(0,L.jsx)(rL,{className:`text-left font-medium tracking-[0.07em] text-muted/55`,children:t.label}),p&&(t.id===`claude`||t.id===`codex`)&&(0,L.jsx)(aV,{backend:t.id,open:g===t.id,onOpenChange:e=>_(e?t.id:null)})]}),(0,L.jsx)(aL,{value:k,onValueChange:t=>{let n=$R(e,t);n&&N(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:GR(w.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 ${E}`,title:e.label,children:e.label}),e.efforts.length===0&&(()=>{let n={provider:t.id,model:e.model,effort:``},r=QR(n);return(0,L.jsx)(oL,{value:r,ref:e=>{e?S.current.set(r,e):S.current.delete(r)},onKeyDown:e=>P(e,n),onSelect:e=>{e.preventDefault(),N(n),x.current?.(),j()},"aria-label":`${e.label}, the agent's own defaults`,title:`${e.label} › the agent's own model and effort`,className:WR,style:{gridColumn:`2 / -1`,justifySelf:`start`},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:`Default`}),(0,L.jsx)(`span`,{className:`col-start-1 row-start-1`,children:`Default`})]})},`default`)})(),e.efforts.length>0&&w.map(n=>{let r=n.find(t=>e.efforts.includes(t)),i=n.reduce((e,t)=>oV(t).length>oV(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 ${E}`,children:oV(i)},i);let a={provider:t.id,model:e.model,effort:r},o=QR(a);return(0,L.jsx)(oL,{value:o,ref:e=>{e?S.current.set(o,e):S.current.delete(o)},onKeyDown:e=>P(e,a),onSelect:e=>{e.preventDefault(),N(a),x.current?.(),j()},"aria-label":`${e.label}, ${oV(r)} effort`,title:`${e.label} › ${oV(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:oV(r)}),(0,L.jsx)(`span`,{className:`col-start-1 row-start-1`,children:oV(r)})]})},r)})]},e.model))}),t!==e.at(-1)&&(0,L.jsx)(cL,{className:`my-1 h-px bg-border`})]},t.id)),T.length===0&&(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-muted/60`,children:`No profiles available`})]})})]})}function cV(e,t){let n=e?.models.find(t=>t.id===e.current),r=[{value:``,label:n?`Default · ${lV(n).model}`:`Default`,title:`The model the agent opens on when Frizz asks for none`}];t&&!e?.models.some(e=>e.id===t)&&r.push(e&&!e.error?{value:t,label:`${t} (unavailable)`,title:`The agent no longer advertises this model`}:{value:t,label:t});let i=[{label:``,options:r}];for(let t of e?.models??[]){let{provider:e,model:n}=lV(t),r=i.find(t=>t.label===e);r||(r={label:e,options:[]},i.push(r)),r.options.push({value:t.id,label:n,title:t.id})}return i}function lV(e){let t=e.name.indexOf(`/`);if(t>0)return{provider:e.name.slice(0,t).trim(),model:e.name.slice(t+1).trim()};let n=e.id.indexOf(`/`);return n>0?{provider:e.id.slice(0,n),model:e.name}:{provider:`Models`,model:e.name}}function uV(e){return e===`right`?`pl-3 pr-7`:`pl-7 pr-3`}function dV(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 fV=`__frizz_empty_select_value__`,pV=e=>e===``?fV:e,mV=e=>e===fV?``:e,hV={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`},gV={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 _V({o:e,indicatorPosition:t,typography:n}){return(0,L.jsxs)(oL,{value:pV(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 ${uV(t)} ${n??``}`,children:[(0,L.jsx)(sL,{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)(Fm,{size:13})}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]})}function vV({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`,menuZClass:d=yM,className:f=``}){let p=dV(e,n,r,i),m=s?gV[c]:hV[c],h=c===`readout`?VR:``,[g,_]=(0,I.useState)(!1),v=(0,I.useRef)(g),y=(0,I.useRef)(s),b=(0,I.useRef)(void 0);return v.current=g,y.current=s,(0,I.useLayoutEffect)(()=>{let e=e=>{e.key!==`Escape`||!v.current||y.current||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),v.current=!1,b.current?.(),b.current=void 0,_(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]),(0,I.useLayoutEffect)(()=>{!s||!g||(v.current=!1,b.current?.(),b.current=void 0,_(!1))},[s,g]),(0,I.useLayoutEffect)(()=>()=>b.current?.(),[]),(0,L.jsxs)(QI,{modal:!1,open:g,onOpenChange:e=>{b.current?.(),b.current=void 0,v.current=e,_(e),e&&(b.current=oz(()=>{v.current=!1,b.current=void 0,_(!1)}))},children:[(0,L.jsx)($I,{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`} ${m} ${c===`readout`?`select-trigger-readout`:``} ${h} ${f}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left ${p.placeholder?`text-muted`:``}`,children:p.text}),(0,L.jsx)(Im,{className:`select-caret shrink-0 text-muted ${s?``:`transition-transform group-data-[state=open]:rotate-180`}`,size:13})]})}),(0,L.jsx)(eL,{children:(0,L.jsx)(tL,{align:`start`,side:u,sideOffset:5,onEscapeKeyDown:e=>e.stopPropagation(),className:`${d} ${vM} min-w-[var(--radix-dropdown-menu-trigger-width)] max-w-[calc(100vw-1rem)] overflow-hidden rounded-lg p-1 ${h}`,children:(0,L.jsx)(aL,{value:pV(e),onValueChange:e=>t(mV(e)),className:`max-h-[300px] min-w-0 overflow-y-auto`,children:r?r.map((e,t)=>(0,L.jsxs)(nL,{children:[e.label&&(0,L.jsx)(rL,{className:`${uV(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)(_V,{o:e,indicatorPosition:l,typography:h},e.value))]},e.label||`g${t}`)):(n??[]).map(e=>(0,L.jsx)(_V,{o:e,indicatorPosition:l,typography:h},e.value))})})})]})}function yV({agentId:e,agentLabel:t,modelId:n,onValueChange:r,disabled:i=!1,side:a=`bottom`,menuZClass:o=yM,className:s=``}){let c=nt({queryKey:[`acpAgentModels`,e],queryFn:()=>Y.acpAgentModels({agentId:e}),staleTime:6e4}),l=cV(c.data,n),u=c.isError?c.error.message:c.data?.error,d=u?`${t} did not list its models (${u}); the thread runs on the agent's own default`:c.data?.models.length?`Model for ${t} — the list is the agent's own, read from its session`:`${t} lists no models; the thread runs on the agent's own default`;return(0,L.jsx)(vV,{variant:`readout`,side:a,value:n??``,onValueChange:e=>r(e||void 0),groups:l,placeholder:c.isPending?`Models…`:`Default`,ariaLabel:`Model for ${t}`,title:d,disabled:i||c.isPending,indicatorPosition:`right`,menuZClass:o,className:s})}async function bV(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(!xV(e))throw Error(`the browser blocked clipboard access`)}function xV(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 SV={claude:`claude auth login`,codex:`codex login`},CV={claude:`Claude`,codex:`Codex`};function wV(e){let t=e.trim();return t===`/login`?`login`:t===`/logout`?`logout`:null}var TV=(0,I.lazy)(()=>Cb(()=>import(`./TerminalPane-DcNJcvz9.js`).then(e=>({default:e.TerminalPane})),__vite__mapDeps([0,1])));function EV({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=SV[e],u=CV[e],d=st({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 bV(l),a(!0),window.setTimeout(()=>a(!1),1500)}catch{Z(`Couldn't copy — select the command and copy it manually`,{duration:6e3})}}let g=st({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)(bL,{open:!0,onOpenChange:e=>{e||(p(),t())},children:(0,L.jsxs)(EL,{children:[(0,L.jsx)(OL,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(ML,{"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)(LL,{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)(TV,{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)(Fm,{size:14,strokeWidth:2,className:`text-green-400`}):(0,L.jsx)(Ym,{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)(hh,{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)(hh,{size:13,className:`animate-spin`}),`Sign in here`]})]})]})]})]})})}function DV({backend:e,onClose:t}){let n=Ve(),r=CV[e],i=st({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)(bL,{open:!0,onOpenChange:e=>{!e&&!i.isPending&&t()},children:(0,L.jsxs)(EL,{children:[(0,L.jsx)(OL,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(ML,{"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)(LL,{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)(hh,{size:13,className:`animate-spin`}),`Sign out`]})]})]})]})})}var OV=ju.options,kV={auto:`Auto`,default:`Default`,acceptEdits:`Accept edits`,plan:`Plan`,bypassPermissions:`Bypass`},AV={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)`};OV.filter(e=>e!==`plan`).map(e=>({value:e,label:kV[e],title:AV[e]}));var jV=[`auto`,`bypassPermissions`].map(e=>({value:e,label:kV[e],title:AV[e]})),MV=[{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 NV(e){return e===`plan`?`auto`:e}var PV=[`low`,`medium`,`high`,`xhigh`,`max`],FV=`ultracode`,IV=new Set([`fable`,`opus`,`sonnet`]);function LV(e){return e&&IV.has(e)?[...PV,FV]:[...PV]}var RV={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-high`,max:`Max`,ultra:`Ultra`,ultracode:`Ultracode`};function zV(e){return RV[e]??e.charAt(0).toUpperCase()+e.slice(1)}function BV(e,t){let n=LV(e).map(e=>({value:e,label:zV(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function VV(e,t){let n=(e?.efforts??[]).map(e=>({value:e,label:zV(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function HV(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 UV(e,t=[]){let n=t.filter(e=>e.available).map(e=>({model:Qc(e.id),label:e.label,efforts:[]}));return[{id:`claude`,label:`Claude Code`,options:MV.map(e=>({model:e.value,label:e.label,defaultEffort:`high`,efforts:LV(e.value)}))},{id:`codex`,label:`Codex`,options:e.map(e=>({model:e.slug,label:e.displayName,defaultEffort:e.defaultEffort,efforts:e.efforts}))},...n.length?[{id:`acp`,label:`ACP agents`,options:n}]:[]]}function WV(e,t,n=[]){let r=e.backend,i=e[r]??{},a=n.find(e=>e.available),o=i.model??(r===`claude`?`opus`:r===`codex`?t[0]?.slug??``:a?Qc(a.id):``),s=r===`codex`?t.find(e=>e.slug===o):void 0,c=r===`acp`?el(o):void 0,l=r===`acp`?tl(o):void 0,u=r===`acp`&&c?Qc(c):o,d=r===`claude`?MV.some(e=>e.value===o):r===`codex`?t.some(e=>e.slug===o):n.some(e=>e.available&&e.id===c),f=r===`claude`?`high`:s?.defaultEffort??``,p=r===`acp`?``:i.effort??f,m=r===`claude`?BV(o,{withDefault:!1}):r===`codex`?VV(s,{withDefault:!1}):[],h=r===`acp`||m.some(e=>e.value===p),g=p&&!h?[{value:p,label:`${p} (unavailable)`,title:`Saved reasoning level is not available for this model`},...m]:m;return{backend:r,model:o,pickerModel:u,effort:p,codexModel:s,...c?{acpAgentId:c}:{},...l?{acpModelId:l}:{},modelAvailable:d,effortAvailable:h,effortOptions:g}}function GV(){let e=Ve(),t=nt({queryKey:[`dispatchPreferencesGet`],queryFn:()=>Y.dispatchPreferencesGet()}),n=nt({queryKey:[`codexModels`],queryFn:()=>Y.codexModels()}),r=n.data??[],i=nt({queryKey:[`acpAgents`],queryFn:()=>Y.acpAgents()}),a=i.data??[],o=st({mutationFn:e=>Y.dispatchPreferenceSet(e),scope:{id:`dispatch-preferences`},onMutate:t=>{let n=e.getQueryData([`dispatchPreferencesGet`]);n&&e.setQueryData([`dispatchPreferencesGet`],HV(n,t))},onError:t=>{e.invalidateQueries({queryKey:[`dispatchPreferencesGet`]}),Z(`Could not save new-thread preference: ${t.message.slice(0,80)}`)}}),s=!!t.data&&!!n.data&&(i.isSuccess||i.isError);return{resolved:(0,I.useMemo)(()=>s?WV(t.data,r,a):void 0,[s,t.data,r,a]),codexList:r,acpList:a,loadError:t.isError||n.isError,saveProfile:o.mutate}}var KV=`frizz-drafts:v1`,qV=80,JV=512*1024,YV=2*1024*1024,XV=new TextEncoder;function ZV(e){return XV.encode(e).byteLength}function QV(){return{version:1,entries:{}}}function $V(e){if(!e)return QV();try{let t=JSON.parse(e);if(!t||typeof t!=`object`||t.version!==1)return QV();let n=t.entries;if(!n||typeof n!=`object`||Array.isArray(n))return QV();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||ZV(t.value)>JV||(r[e]={value:t.value,touchedAt:t.touchedAt});return{version:1,entries:r}}catch{return QV()}}function eH(e){let t=Object.entries(e.entries).filter(([,e])=>e.value&&ZV(e.value)<=JV).sort((e,t)=>t[1].touchedAt-e[1].touchedAt),n={};for(let[e,r]of t){if(Object.keys(n).length>=qV)break;n[e]=r,ZV(JSON.stringify({version:1,entries:n}))>YV&&delete n[e]}return{version:1,entries:n}}var tH=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=eH($V(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(KV,JSON.stringify(eH(e)))}catch{}for(let e of this.listeners)e()}};function nH(e){return encodeURIComponent(e||`unresolved-project`)}var rH={dispatch:e=>`dispatch:${nH(e)}:new`,followUp:(e,t,n)=>`followup:${nH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}`,adopt:(e,t)=>`adopt:${nH(e)}:${encodeURIComponent(t)}`,answer:(e,t,n,r,i)=>`answer:${nH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}:${encodeURIComponent(r)}:${i}`,interaction:(e,t,n,r,i,a,o)=>`interaction:${nH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}:${i}:${encodeURIComponent(a)}:${encodeURIComponent(o)}`,question:(e,t,n,r)=>`question:${nH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}`};function iH(){return en(X).board?.projectDir}function aH(e){return en(X).board?.threads.find(t=>t.id===e)?.sessionId}function oH(e){let t=(0,I.useCallback)(()=>tH.get(e),[e]);return[(0,I.useSyncExternalStore)(tH.subscribe,t,t),(0,I.useCallback)(t=>tH.set(e,t),[e]),(0,I.useCallback)(()=>tH.clear(e),[e])]}function sH(e){let t=(0,I.useCallback)(()=>JSON.stringify(Object.fromEntries(e.map(e=>[e,tH.get(e)]))),[e.join(`\0`)]),n=(0,I.useSyncExternalStore)(tH.subscribe,t,t);return(0,I.useMemo)(()=>new Map(Object.entries(JSON.parse(n))),[n])}function cH({autoFocus:e,onDispatched:t}){let{resolved:n,codexList:r,acpList:i,loadError:a,saveProfile:o}=GV(),s=it({mutationKey:[`contextWindowSet`]})>0,c=zR(),l=iH(),[u,d,f]=oH(rH.dispatch(l)),p=rH.dispatch(l),m=(0,I.useRef)(``),[h,g]=(0,I.useState)(null),_=nt({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4}),[v,y]=(0,I.useState)(null),[b,x]=(0,I.useState)(null),S=(0,I.useRef)(null),C=st({mutationFn:e=>Y.dispatch(e),onMutate:()=>Z(`Starting thread…`,{spinner:!0,sticky:!0}),onSuccess:e=>{g(null),t?.(),Z(`Thread started`,{link:{label:`Open thread`,slug:e.slug}})},onError:(e,t)=>{tH.get(p)||d(m.current||t.prompt),g(null);let n=/^AUTH_REQUIRED:(claude|codex)$/.exec(e.message);if(n){S.current=t,y(n[1]),Z(`Signed out of ${n[1]===`claude`?`Claude`:`Codex`}`,{duration:3e3});return}Z(`Dispatch failed: ${e.message.slice(0,80)}`)}});function w(e){m.current=u,f(),g(e.prompt),C.mutate(e)}function T(){if(!u.trim()||!n||s)return;let e=wV(u);if(e){if(f(),n.backend===`acp`){Z(`An ACP agent signs in through its own CLI — Frizz holds no account for it`);return}e===`login`?(S.current=null,y(n.backend)):x(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:u.trim(),model:n.model,backend:n.backend,effort:n.effort||void 0};if(n.backend!==`acp`&&_.data?.[n.backend]===`signed-out`){S.current=t,y(n.backend);return}w(t)}let E=(0,I.useMemo)(()=>{if(!n)return(0,L.jsx)(sV,{groups:[],value:void 0,onValueChange:()=>{},placeholder:a?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort loading`,disabled:!0});let e=UV(r,i),t=n.acpAgentId?i.find(e=>e.id===n.acpAgentId):void 0;return(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-1.5 gap-y-0.5`,children:[(0,L.jsx)(sV,{groups:e,contextWindows:!0,value:{provider:n.backend,model:n.pickerModel,effort:n.effort},onValueChange:e=>o({field:`profile`,backend:e.provider,model:e.model,effort:e.effort||void 0}),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)]`}),t&&(0,L.jsx)(yV,{agentId:t.id,agentLabel:t.label,modelId:n.acpModelId,onValueChange:e=>o({field:`model`,backend:`acp`,value:Qc(t.id,e)}),className:`max-w-[min(14rem,40vw)] px-2 py-1`})]})},[n,r,i,a,o]);return(0,L.jsxs)(`div`,{className:`w-full flex flex-col gap-3`,children:[(0,L.jsx)(IR,{surface:`newComposer`,autoFocus:e,value:u,onChange:d,onSubmit:T,placeholder:`Describe the task…`,minHeight:96,maxHeight:340,busy:C.isPending||s,footer:E,leftAction:c?(0,L.jsx)(BR,{}):void 0}),C.isError&&(0,L.jsx)(`span`,{className:`px-0.5 text-[11px] text-red-400 truncate`,children:C.error.message}),h&&(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:h})]}),v&&(0,L.jsx)(EV,{backend:v,onClose:()=>y(null),onAuthed:()=>{let e=S.current;S.current=null,y(null),e&&w(e)}}),b&&(0,L.jsx)(DV,{backend:b,onClose:()=>x(null)})]})}function lH({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)(bL,{open:!0,onOpenChange:t=>{t||e()},children:(0,L.jsxs)(EL,{children:[(0,L.jsx)(OL,{className:`fixed inset-0 z-50 bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(ML,{ref:t,"aria-modal":`true`,"aria-describedby":void 0,onEscapeKeyDown:cz,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)(LL,{className:`mb-1 text-[14px] font-medium`,children:`New thread`}),(0,L.jsx)(cH,{autoFocus:!0,onDispatched:e})]})]})})}function uH({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 dH=`-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`,fH={claude:`size-[11px] translate-y-px`,codex:`size-[10px]`,acp:`h-[11px] w-[6.65px] translate-y-px`,"acp:opencode":`size-[10px]`,"acp:cursor":`size-[10px]`,"acp:gemini":`size-[10px]`,"acp:copilot":`size-[12px] translate-y-px`,"acp:qwen":`size-[10px]`,"acp:kimi":`size-[10px]`},pH={claude:{key:`claude`,backend:`claude`,label:`Claude Code`},codex:{key:`codex`,backend:`codex`,label:`OpenAI Codex`},acp:{key:`acp`,backend:`acp`,label:`ACP agent`},"acp:opencode":{key:`acp:opencode`,backend:`acp`,label:`OpenCode`},"acp:cursor":{key:`acp:cursor`,backend:`acp`,label:`Cursor agent`},"acp:gemini":{key:`acp:gemini`,backend:`acp`,label:`Gemini CLI`},"acp:copilot":{key:`acp:copilot`,backend:`acp`,label:`GitHub Copilot CLI`},"acp:qwen":{key:`acp:qwen`,backend:`acp`,label:`Qwen Code`},"acp:kimi":{key:`acp:kimi`,backend:`acp`,label:`Kimi CLI`}};function mH(e){return Object.hasOwn(pH,e)}function hH(e,t){if(e===`claude`||e===`codex`)return pH[e];if(e!==`acp`)return;let n=el(t),r=n?`acp:${n}`:`acp`;return mH(r)?pH[r]:pH.acp}function gH({backend:e,model:t,className:n}){let r=hH(e,t);return r?(0,L.jsx)(`span`,{role:`img`,"aria-label":r.label,className:`inline-flex shrink-0 text-muted/65 ${fH[r.key]} ${n??``}`,children:_H[r.key]()}):null}var _H={claude:bH,codex:yH,acp:vH,"acp:opencode":xH,"acp:cursor":SH,"acp:gemini":CH,"acp:copilot":wH,"acp:qwen":TH,"acp:kimi":EH};function vH(){return(0,L.jsx)(Eh,{"aria-hidden":`true`,focusable:`false`,className:`size-full`,strokeWidth:2.5,viewBox:`4.75 0.75 14.5 22.5`})}function yH(){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 bH(){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`})})}function xH(){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 24H2V0h20zM17 4.8H7v14.4h10z`})})}function SH(){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:`M11.503.131 1.891 5.678a.84.84 0 0 0-.42.726v11.188c0 .3.162.575.42.724l9.609 5.55a1 1 0 0 0 .998 0l9.61-5.55a.84.84 0 0 0 .42-.724V6.404a.84.84 0 0 0-.42-.726L12.497.131a1.01 1.01 0 0 0-.996 0M2.657 6.338h18.55c.263 0 .43.287.297.515L12.23 22.918c-.062.107-.229.064-.229-.06V12.335a.59.59 0 0 0-.295-.51l-9.11-5.257c-.109-.063-.064-.23.061-.23`})})}function CH(){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:`M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81`})})}function wH(){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:`M23.922 16.997C23.061 18.492 18.063 22.02 12 22.02 5.937 22.02.939 18.492.078 16.997A.641.641 0 0 1 0 16.741v-2.869a.883.883 0 0 1 .053-.22c.372-.935 1.347-2.292 2.605-2.656.167-.429.414-1.055.644-1.517a10.098 10.098 0 0 1-.052-1.086c0-1.331.282-2.499 1.132-3.368.397-.406.89-.717 1.474-.952C7.255 2.937 9.248 1.98 11.978 1.98c2.731 0 4.767.957 6.166 2.093.584.235 1.077.546 1.474.952.85.869 1.132 2.037 1.132 3.368 0 .368-.014.733-.052 1.086.23.462.477 1.088.644 1.517 1.258.364 2.233 1.721 2.605 2.656a.841.841 0 0 1 .053.22v2.869a.641.641 0 0 1-.078.256Zm-11.75-5.992h-.344a4.359 4.359 0 0 1-.355.508c-.77.947-1.918 1.492-3.508 1.492-1.725 0-2.989-.359-3.782-1.259a2.137 2.137 0 0 1-.085-.104L4 11.746v6.585c1.435.779 4.514 2.179 8 2.179 3.486 0 6.565-1.4 8-2.179v-6.585l-.098-.104s-.033.045-.085.104c-.793.9-2.057 1.259-3.782 1.259-1.59 0-2.738-.545-3.508-1.492a4.359 4.359 0 0 1-.355-.508Zm2.328 3.25c.549 0 1 .451 1 1v2c0 .549-.451 1-1 1-.549 0-1-.451-1-1v-2c0-.549.451-1 1-1Zm-5 0c.549 0 1 .451 1 1v2c0 .549-.451 1-1 1-.549 0-1-.451-1-1v-2c0-.549.451-1 1-1Zm3.313-6.185c.136 1.057.403 1.913.878 2.497.442.544 1.134.938 2.344.938 1.573 0 2.292-.337 2.657-.751.384-.435.558-1.15.558-2.361 0-1.14-.243-1.847-.705-2.319-.477-.488-1.319-.862-2.824-1.025-1.487-.161-2.192.138-2.533.529-.269.307-.437.808-.438 1.578v.021c0 .265.021.562.063.893Zm-1.626 0c.042-.331.063-.628.063-.894v-.02c-.001-.77-.169-1.271-.438-1.578-.341-.391-1.046-.69-2.533-.529-1.505.163-2.347.537-2.824 1.025-.462.472-.705 1.179-.705 2.319 0 1.211.175 1.926.558 2.361.365.414 1.084.751 2.657.751 1.21 0 1.902-.394 2.344-.938.475-.584.742-1.44.878-2.497Z`})})}function TH(){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:`M23.919 14.545 20.817 9.17l1.47-2.544a.56.56 0 0 0 0-.566l-1.633-2.83a.57.57 0 0 0-.49-.283h-6.207L12.487.402a.57.57 0 0 0-.49-.284H8.732a.56.56 0 0 0-.49.284L5.139 5.775h-2.94a.56.56 0 0 0-.49.284L.077 8.887a.56.56 0 0 0 0 .567L3.18 14.83l-1.47 2.545a.56.56 0 0 0 0 .566l1.634 2.83a.57.57 0 0 0 .49.283h6.205l1.47 2.545a.57.57 0 0 0 .49.284h3.266a.57.57 0 0 0 .49-.284l3.104-5.375h2.94a.57.57 0 0 0 .49-.283l1.634-2.828a.55.55 0 0 0-.004-.568M8.733.686l1.634 2.828-1.634 2.828H21.8L20.164 9.17H7.425L5.63 6.06Zm1.306 19.801-6.205-.002 1.634-2.83h3.265L2.201 6.344h3.267q3.182 5.517 6.367 11.032zm10.124-5.66L18.53 12l-6.532 11.315-1.634-2.83c2.129-3.673 4.25-7.351 6.373-11.028h3.592l3.102 5.374z`})})}function EH(){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:`M21.765.351C22.998.351 24 1.353 24 2.586S22.998 4.82 21.765 4.82h-1.974c-.15 0-.26-.12-.26-.26V2.586A2.237 2.237 0 0 1 21.765.35M9.41 13.388l8.447-8.377c.16-.16.07-.471-.14-.471h-4.55s-.1.02-.14.06l-9.099 9.029c-.14.14-.35.02-.35-.21V4.81c0-.15-.1-.27-.221-.27H.22c-.12 0-.22.12-.22.27v18.57c0 .15.1.27.22.27h3.137c.12 0 .22-.12.22-.27v-3.79c0-.08.03-.16.08-.21l2.826-2.796c.07-.07.16-.08.241-.03l7.546 5.551a8.9 8.9 0 0 0 4.018 1.493c.12.01.23-.11.23-.27V19.76c0-.14-.08-.25-.19-.26a5.8 5.8 0 0 1-2.355-.942l-6.533-4.73c-.14-.09-.15-.32-.03-.441`})})}var DH=3e4,OH=45e3;function kH(e,t){return t?AbortSignal.any([t,AbortSignal.timeout(e)]):AbortSignal.timeout(e)}var AH=`text-[9px]`,jH={claude:`text-fg/75! size-[14px]! translate-y-0!`,codex:`text-fg/75! size-[12.75px]! translate-y-0!`};function MH(){let e=nt({queryKey:[`quota`],queryFn:()=>Y.quota(),staleTime:1e4}),t=nt({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4});return[`claude`,`codex`].some(n=>NH(e.data?.[n],t.data?.[n],e.isLoading))}function NH(e,t,n){return t===`signed-out`||!e&&n?!1:!!e&&e.status===`ok`&&e.windows.length>0}function PH(){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:kH(DH,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:kH(DH,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:kH(OH)}).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 ${AH}`,children:[(0,L.jsx)(FH,{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)(FH,{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 FH({backend:e,quota:t,auth:n,email:r,loading:i,fetching:a,onRecheck:o}){let s=CV[e];if(!NH(t,n,i))return null;let c=IH(100-RH(t.windows).usedPercent);return(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(tV,{onOpenChange:e=>{e&&o()},children:[(0,L.jsx)(nV,{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)(gH,{backend:e,className:jH[e]}),(0,L.jsxs)(`span`,{className:`tabular-nums ${zH(c)}`,children:[c,`%`]})]})}),(0,L.jsxs)(iV,{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)(gH,{backend:e}),(0,L.jsx)(`span`,{children:s}),t?.planType&&(0,L.jsxs)(`span`,{className:`text-muted/70`,children:[`· `,BH(t.planType),` plan`]}),a&&(0,L.jsx)(hh,{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=IH(100-e.usedPercent),n=VH(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:zH(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 IH(e){return Math.max(0,Math.min(100,Math.round(e)))}var LH=25;function RH(e){return e.find(e=>e.key===`5h`)??e.reduce((e,t)=>t.usedPercent>e.usedPercent?t:e)}function zH(e){return e<=8?`text-red-400`:e<=LH?`text-accent`:`text-fg/70`}function BH(e){return e&&e[0].toUpperCase()+e.slice(1)}function VH(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 HH=`frizz:supervisor-status-wake`,UH=`frizz:reload-after-update-restart`,WH=`frizz:update-restart-from-version`;function GH(e,t){return t.version===e?{kind:`previous-kept`}:{kind:`successor-failed`,version:t.version}}function KH(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 qH(e){return e?.artifactDigest??e?.version??null}function JH(e,t){if(e===null||t?.state!==`ready`)return!1;let n=qH(t);return n!==null&&n!==e}var YH=3*6e4,XH={silentSince:null,silentForMs:0,stalled:!1};function ZH(e,t,n=YH){if(!t.restarting||t.answered)return XH;let r=e.silentSince??t.at,i=Math.max(0,t.at-r);return{silentSince:r,silentForMs:i,stalled:i>=n}}function QH(e,t){return e.ackedAt!==null&&t.requestedAt>=e.ackedAt}function $H(e,t){return e.attempt&&!(QH(e.attempt,t)&&eU(e.attempt,t))?e:{state:t.state,message:t.message??null,attempt:null}}function eU(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 tU(e,t){return t.state===`ready`&&e.attempt===null}function nU(e){return e!==null}function rU(e){return e?.updateRestart===!0&&e.updateAvailable!==!1}function iU(e){return e?.dev===!0}async function aU(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 oU(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 sU(e=fetch){return oU(`/_frizz/control/restart`,e)}function cU(e=fetch){return oU(`/_frizz/control/update-restart`,e)}var lU=8e3,uU=500,dU=[`supervisorStatus`];function fU(e,t){return e===`restarting`||t?uU:lU}var pU=rt({queryKey:dU,queryFn:async()=>{let e=Date.now(),t=await aU();return t?{...t,requestedAt:e}:null},refetchInterval:e=>fU(e.state.data?.state,X.controlPlaneRestartAttempt!==null),staleTime:e=>fU(e.state.data?.state,X.controlPlaneRestartAttempt!==null)});function mU(){return nt(pU)}var hU=null;function gU(e){hU||(hU=e,window.addEventListener(HH,()=>{e.refetchQueries({queryKey:dU,exact:!0})}))}function _U(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 vU=`Install the latest version of Frizz. Your running threads will not be affected.`,yU=`A newer version of Frizz is available. Your running threads will not be affected.`,bU=`Restart Frizz. Your running threads will not be affected.`,xU=`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)]`,SU=`absolute -top-[7px] left-4 h-3 w-3 rotate-45 border-l border-t bg-elevated`,CU=`sm:w-[min(23rem,calc(100vw-1.5rem))]`,wU=`sm:w-[min(34rem,calc(100vw-1.5rem))]`,TU=`rounded-xl bg-elevated p-3.5 shadow-xl shadow-black/45`;function EU({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:`${xU} ${CU} ${TU} border border-border-strong`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${SU} 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)(Oh,{"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?yU:vU:bU})]})}var DU={kind:`previous-kept`};function OU({update:e,message:t,outcome:n=DU,onDismiss:r}){return(0,L.jsxs)(`div`,{role:`alert`,className:`${xU} ${wU} ${TU} border border-red-500/45`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${SU} 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)(Bh,{"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)(Hh,{"aria-hidden":`true`,size:14,strokeWidth:2.25})})]}),(0,L.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:KH(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 kU({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 ${dH}`,onFocus:i,onBlur:a,onClick:o,children:[(0,L.jsx)(Oh,{size:14,"aria-hidden":`true`,className:t?`animate-spin`:void 0}),e&&!t&&_U(n,r)&&(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-[2px] top-[2px] h-[4px] w-[4px] rounded-full bg-accent`})]})}function AU(){let e=en(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=mU().data??null,f=rU(d),p={version:d?.version,updateVersion:d?.updateVersion};if(!nU(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?GH(l.current.version,{version:d?.version}):DU,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:qH(d)});try{if(f?await cU():await sU(),f){sessionStorage.setItem(UH,e),l.current.version?sessionStorage.setItem(WH,l.current.version):sessionStorage.removeItem(WH);let t=X.controlPlaneRestartAttempt;t&&(X.controlPlaneRestartAttempt={...t,ackedAt:Date.now()}),window.dispatchEvent(new Event(HH)),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)(kU,{update:f,busy:r,version:p.version,updateVersion:p.updateVersion,onFocus:()=>n(!0),onBlur:()=>n(!1),onClick:()=>void y()}),_&&(0,L.jsx)(OU,{update:f,message:_,outcome:v,onDismiss:()=>c(_)}),(0,L.jsx)(EU,{open:t&&!_,update:f,version:p.version,updateVersion:p.updateVersion})]})}function jU(){return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px shrink-0 bg-border`})}function MU({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 NU(){let e=fw(),t=fG(e),n=MH(),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)(Yb,{to:`/`,title:`All projects`,"aria-label":`All projects`,className:`${dH} -ml-px`,children:(0,L.jsx)(lh,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(jU,{}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Settings`,title:`Settings`,className:dH,onClick:()=>X.showSettings=!0,children:(0,L.jsx)(Mh,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(AU,{}),n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(jU,{}),(0,L.jsx)(PH,{})]}),(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)(MU,{text:i})}):i?(0,L.jsx)(MU,{text:i,title:i,className:`font-semibold text-fg/90`}):(0,L.jsx)(`span`,{className:`identity-placeholder w-24`,"aria-hidden":`true`})})]})}var PU=Xt({at:{}}),FU=12e3,IU=new Map;function LU(e,t=Date.now()){PU.at[e]=t;let n=IU.get(e);n!==void 0&&clearTimeout(n),IU.set(e,setTimeout(()=>{IU.delete(e),delete PU.at[e]},FU))}function RU(e){let t=IU.get(e);t!==void 0&&(clearTimeout(t),IU.delete(e)),delete PU.at[e]}function zU(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 BU(){return en(PU).at}function VU(e,t,n=Date.now()){return t===void 0||!zU(e,t,n)?e:{...e,runtime:`running`,needsYou:!1,pendingAsk:void 0,pendingQuestion:!1,actionableInteraction:!1,lastUserAt:new Date(t).toISOString()}}function HU(e){let t=BU();return(0,I.useMemo)(()=>e.map(e=>VU(e,t[e.id])),[e,t])}var UU=0;function WU(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(UU+=1,`browser-${Date.now()}-${UU}`)}function GU({optimistic:e,request:t,success:n,failure:r}){e(),t().then(()=>n?.(),e=>r(e instanceof Error?e:Error(String(e))))}var KU=new Map;function qU(e,t){let n=(KU.get(e)??Promise.resolve()).then(t,t);return KU.set(e,n.then(()=>{},()=>{})),n}var JU=[300,800,1800,3500],YU=12e4,XU=e=>new Promise(t=>{setTimeout(t,e)});async function ZU(e,t,n=XU){for(let r=0;;r++){try{await e()}catch(e){if(r>=JU.length||!jf(e))throw e;t(),await n(JU[r]);continue}t();return}}function QU(e,t,n,r,i,a=YU){let o=new AbortController,s=setTimeout(()=>o.abort(Error(`Frizz did not answer this send`)),a);return Y.followUp({slug:e,sessionId:hm(X.board,e)?.sessionId??``,message:t,deliveryId:n,freshProcess:r,interrupt:i},{signal:o.signal}).finally(()=>clearTimeout(s))}function $U(e,t,n,r,i){return ZU(()=>QU(e,t,n,r,i),()=>LU(e))}function eW(e,t,n,r={}){let i=n.trim();if(!i)return!1;let a=WU();return GU({optimistic:()=>{r.onOptimistic?.(),Aw(e,t,i,{scrollToBottom:r.scrollToBottom,deliveryId:a}),LU(t),Y.markRead({slug:t}).catch(()=>{})},request:()=>qU(t,()=>$U(t,i,a,r.freshProcess,r.interrupt)),success:()=>r.onSuccess?.(),failure:n=>{jw(e,t,i,a),RU(t),r.onRollback?.(),Z(r.failureToast?.(n.message)??`Steer failed — ${n.message.slice(0,160)}`)}}),!0}function tW(e){let t=Ve(),[n,r]=(0,I.useState)(0);return{submit:(0,I.useCallback)((n,i={})=>eW(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 nW(e,t){return new Promise(n=>{eW(e,t,`Continue exactly where you left off.`,{onSuccess:()=>{Z(`Retrying…`),n()},onRollback:()=>n(),failureToast:e=>`Retry failed: ${e.slice(0,80)}`})||n()})}function rW(e,t=`pull`){let n=/^([A-Za-z0-9][\w.-]*)\/([A-Za-z0-9][\w.-]*)#(\d+)$/.exec(e.trim());return n?`https://github.com/${n[1]}/${n[2]}/${t===`issue`?`issues`:`pull`}/${n[3]}`:null}var iW=`Waiting for an external update.`;function aW(e){let t=new Set;return e.flatMap(e=>{if(e.kind!==`pr`&&e.kind!==`issue`)return[];let n=e.value.trim();return!n||t.has(`${e.kind}:${n}`)?[]:(t.add(`${e.kind}:${n}`),[{ref:n,url:rW(n,e.kind===`issue`?`issue`:`pull`)}])})}function oW(e){let t=(e.body??``).split(/\n\s*\n/).map(e=>e.trim()).find(Boolean);return t?lW(sW(t.replace(/\s*\n\s*/g,` `))):null}function sW(e){if(e.length<=cW)return e;let t=e.slice(0,cW),n=t.lastIndexOf(` `);return`${(n>cW/2?t.slice(0,n):t).replace(/[.,;:]$/,``)}…`}var cW=240;function lW(e){let t=(e.split(/\s/,1)[0]??``).replace(/[.,:;]+$/,``);return/[^a-zA-Z]/.test(t)||/[A-Z]/.test(t.slice(1))||uW.has(t)?e:e.charAt(0).toUpperCase()+e.slice(1)}var uW=new Set([`npm`,`npx`,`pnpm`,`nub`,`nubx`,`gh`,`git`,`node`,`bun`,`tsc`,`vite`,`curl`,`ssh`]);function dW(e){return e&&pW(e)||null}var fW=new Set([...pl,`shells`,`agents`,`timers`,`prs`,`issues`,`for`,`title`]);function pW(e){return e.split(`
200
- `).filter(e=>{let t=/^\s*([a-z][a-z-]*):/i.exec(e)?.[1]?.toLowerCase();return!(t&&fW.has(t))}).join(`
201
- `).trim()}function mW(e){let t=t=>e.filter(e=>e.kind===t&&e.value.trim()).length,n=[...aW(e).map(e=>e.ref),hW(t(`shell`),`background shell`,`background shells`),hW(t(`agent`),`sub-agent`,`sub-agents`),hW(t(`timer`),`timer`,`timers`)].filter(e=>e!==null);return n.length>0?`waiting on ${gW(n)}`:null}function hW(e,t,n){return e<=0?null:e===1?`a ${t}`:`${e} ${n}`}function gW(e){return e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function _W(e){let t=e.find(e=>e.kind===`pr`);if(t)return`PR ${t.value}`;let n=e.find(e=>e.kind===`issue`);return n?`Issue ${n.value}`:null}var vW=Xt({at:{}}),yW=12e3,bW=new Map;function xW(e,t=Date.now()){vW.at[e]=t;let n=bW.get(e);n!==void 0&&clearTimeout(n),bW.set(e,setTimeout(()=>{bW.delete(e),delete vW.at[e]},yW))}function SW(e){let t=bW.get(e);t!==void 0&&(clearTimeout(t),bW.delete(e)),delete vW.at[e]}function CW(){return en(vW).at}function wW(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 TW(e){let t=CW();return(0,I.useMemo)(()=>e.map(e=>wW(e,t[e.id])),[e,t])}var EW=.5;function DW(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*EW,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 OW(e,t,n,r){return!e||e.top<=r&&e.bottom>r?!0:Math.abs(t-n)>1}function kW(e,t,n,r,i=8){return n<e+i?n-e-i:r>t-i?r-t+i:0}var AW=`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`,jW=`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 MW(){let e=en(X),t=TW(HU(mw(fw()?.threads??[]))),n=TE(t,en(RT).queueOrder),r=tE(iE(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(OW(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=DW(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=kW(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:jp(e)??window.scrollY},u(e)},[]);return(0,L.jsx)(`aside`,{className:jW,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)(NU,{}),(0,L.jsx)(cH,{})]}),(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)(BW,{t:e,active:l===e.id,onQueueNavigate:p}),(0,L.jsx)(GW,{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}=wE(a),n=e=>t=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(BW,{t,active:l===t.id,onQueueNavigate:p,restedAge:e}),(0,L.jsx)(GW,{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)(NW,{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)(BW,{t:e,active:l===e.id,onQueueNavigate:p}),(0,L.jsx)(GW,{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)(NW,{label:`Done`,count:s.length,collapsed:i.inactive,onToggle:()=>X.sidebarCollapsed.inactive=!X.sidebarCollapsed.inactive}),!i.inactive&&(0,L.jsx)(IW,{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)(NW,{label:`External`,count:r.length,collapsed:i.external,onToggle:()=>X.sidebarCollapsed.external=!X.sidebarCollapsed.external}),!i.external&&r.map(e=>(0,L.jsx)(BW,{t:e,active:l===e.id,onQueueNavigate:p,restedAge:!0},e.id))]})]})]})})}function NW({label:e,count:t,collapsed:n,onToggle:r}){let i=(0,L.jsxs)(L.Fragment,{children:[r?(0,L.jsx)(Rm,{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 PW=27,FW=8;function IW({threads:e,railRef:t,activeId:n,onQueueNavigate:r}){let i=(0,I.useRef)(null),[a,o]=(0,I.useState)(0),s=mT({count:e.length,getScrollElement:()=>t.current,getItemKey:t=>e[t]?.id??t,estimateSize:()=>PW,overscan:FW,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)(BW,{t:i,active:n===i.id,onQueueNavigate:r}),(0,L.jsx)(GW,{t:i})]},i.id):null})})}var LW=16,RW=12;function zW({title:e,children:t}){let n=e.trimEnd(),r=n.lastIndexOf(` `)+1,i=n.length-r<=LW?r:n.length-RW;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 BW=(0,I.memo)(function({t:e,legacy:t,active:n=!1,onQueueNavigate:r,restedAge:i=!1}){let a=!t&&e.foreign===!0,o=!t&&dE(e),s=!t&&yE(e)===`archived`,c=o||s,l=!t&&YT(e),u=!t&&bE(e),d=!t&&aE(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&&Yp(e.id)){r?.(e.id);return}Wp(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)(XW,{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)(zW,{title:HT(e),children:[!t&&(0,L.jsx)(gH,{backend:e.backend,model:e.model,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)(KW,{status:e.archived?`archived`:e.status})]})}),i&&(0,L.jsx)(VW,{t:e,yieldsToRetry:!0}),d&&!i&&(0,L.jsx)(UW,{})]})})]}),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)(mL,{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)(WW,{t:e,className:`-mr-0.5`}),(0,L.jsx)(TM,{slug:e.id,size:12,className:AW}),u&&(0,L.jsx)(HW,{slug:e.id}),!a&&d&&(0,L.jsx)(WW,{t:e})]})]})});function VW({t:e,yieldsToRetry:t}){let n=WE(),r=$T(e),i=jE(r,n);return!r||!i?null:(0,L.jsx)(`time`,{dateTime:r,"data-rail-rested-age":!0,title:OE(r,n)??void 0,"aria-label":`Rested ${OE(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 HW({slug:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return(0,L.jsx)(wM,{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),nW(t,e).finally(()=>r(!1))},className:`${AW} disabled:opacity-50`,children:n?(0,L.jsx)(hh,{size:13,className:`animate-spin`}):(0,L.jsx)(Ah,{size:13})})})}function UW(){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)(Th,{size:12,fill:`currentColor`})})}function WW({t:e,className:t=``}){let n=aE(e),[r,i]=(0,I.useState)(!1);return(0,L.jsx)(wM,{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:`${AW} disabled:opacity-50 ${t}`,children:n?(0,L.jsx)(wh,{size:12,fill:`currentColor`}):(0,L.jsx)(Th,{size:12})})})}function GW({t:e}){let t=DD(e.subAgents??[],`rail`);return t.length===0?null:(0,L.jsx)(`div`,{className:`flex flex-col`,children:t.map(t=>(0,L.jsx)(AD,{kind:`AGENT`,label:t.label,state:t.state,density:`rail`,depth:t.depth,startedAt:t.startedAt,parentSlug:e.id,onOpen:()=>Hp(e.id,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}),onDismiss:DM(e.id,t),title:t.subagentType?`[${t.subagentType}] ${t.label}`:t.label},t.id))})}function KW({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] ${VT[e]??`text-muted border-border`}`,children:t})}function qW(e,t,n=null){return[[t,mW(e.lastFence?.kind===`awaiting`?e.lastFence.hints:[]),n].filter(e=>!!e).join(` — `),JW(e)].filter(e=>!!e).join(`
197
+ `)})}return!i.length||!i.every(e=>_R(n,e.token))?null:{body:n,items:i}}function kR(e){return e.key===`Enter`&&!e.altKey&&!e.shiftKey&&!e.isComposing&&e.keyCode!==229}function AR(e,t){return t&&kR(e)&&!e.metaKey&&!e.ctrlKey}function jR(e,t){return t&&kR(e)&&(e.metaKey||e.ctrlKey)}function MR(e){return kR(e)}function NR(e){return e.key===`Enter`&&e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing}function PR(e,t,n){return e===`queueComposer`&&t===`Enter`&&n}var FR=`gap-3`,IR=`-mx-1`,LR=`-mx-[3px]`,RR=`right-2`,zR=`right-[71px]`,BR=`right-[44px]`,VR=`pr-[6.6875rem]`,HR=`pr-20`;async function UR(e,t){let n=tf(),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 WR={project:`project`,user:`global`,builtin:`built-in`,plugin:`plugin`};function GR(e,t){e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,t)}px`}function KR({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)(()=>dR(e),[e]),w=C.map(e=>e.path),T=(0,I.useRef)(e);T.current=e;let E=e=>t(fR(e,w)),D=e=>t(fR(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})=>Gc(e)?!0:(Z(`${e||`File`}: unsupported file type`),!1));if(!n.length)return;let r=n.filter(({file:e,name:t})=>e.size>Hc?(Z(`${t} is too large (max ${Math.floor(Hc/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 UR(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=dR(T.current);t(fR(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||GR(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=xR(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(WR[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=xR(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(PR(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(AR(i,a)){e.preventDefault(),e.stopPropagation(),n();return}if(jR(i,a)){e.preventDefault(),e.stopPropagation(),(m??n)();return}if(NR(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?WR[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,"data-claims-escape":!0,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?VR:HR}`} 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)(qR,{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:Kc,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?zR:BR} 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)(hh,{size:15,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(Ch,{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 ${RR} 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)(hh,{size:14,strokeWidth:2.5,className:`animate-spin`}):(0,L.jsx)(jm,{size:14,strokeWidth:2.5})})]})}function qR({attachment:e,disabled:t,onRemove:n}){let[r,i]=(0,I.useState)(!1),a=_p(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:mC(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)($m,{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)(Hh,{size:10,strokeWidth:2.5})})]})}function JR(){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=JR();return!!(e.data?.inRepo&&e.data.authed)}function XR({className:e=``}){return YR()?(0,L.jsx)(`button`,{type:`button`,onClick:Np,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)(sh,{size:15,strokeWidth:2})}):null}var ZR=`prompt-control-type petite-caps`,QR=ZR,$R=ZR,ez=`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 ${QR} 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 tz(e){return`minmax(6rem, 7rem) repeat(${Math.max(0,e)}, auto)`}var nz=[`ultra`,`ultracode`],rz=[`low`,`medium`,`high`,`xhigh`,`max`,...nz];function iz(e){return[...new Set(e.flatMap(e=>e.options.flatMap(e=>e.efforts)))].sort((e,t)=>{let n=rz.indexOf(e),r=rz.indexOf(t);return n===-1&&r===-1?e.localeCompare(t):n===-1?1:r===-1?-1:n-r})}function az(e){let t=[];for(let n of iz(e)){let e=nz.includes(n)?t.find(e=>nz.includes(e[0])):void 0;e?e.push(n):t.push([n])}return t}function oz(e){return e.efforts.length?e.efforts:[``]}function sz(e){return e.flatMap(e=>e.options.flatMap(t=>oz(t).map(n=>({provider:e.id,model:t.model,effort:n}))))}function cz(e){return JSON.stringify([e.provider,e.model,e.effort])}function lz(e,t){return sz(e).find(e=>cz(e)===t)}function uz(e,t){return!t?.model||t.effort===void 0?!1:e.some(e=>(!t.provider||e.id===t.provider)&&e.options.some(e=>e.model===t.model&&oz(e).includes(t.effort)))}function dz(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 fz(e,t,n){let r=az(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=oz(s.option),l=c.indexOf(t.effort);if(l===-1)return null;if(n===`Home`||n===`End`||n===`ArrowLeft`||n===`ArrowRight`){let e=c[n===`Home`?0:n===`End`?c.length-1:l+(n===`ArrowLeft`?-1:1)];return e===void 0?null:{provider:s.provider,model:s.option.model,effort:e}}let u=a[o+(n===`ArrowUp`?-1:1)];if(!u)return null;let d=i(t.effort),f=oz(u.option).reduce((e,t)=>e===void 0||Math.abs(i(t)-d)<Math.abs(i(e)-d)?t:e,void 0);return f===void 0?null:{provider:u.provider,model:u.option.model,effort:f}}var pz,mz=!1;function hz(){mz||typeof window>`u`||(mz=!0,window.addEventListener(`keydown`,e=>{e.key!==`Escape`||!pz||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),_z())},{capture:!0}))}function gz(e){hz();let t={dismiss:e};return pz=t,()=>{pz===t&&(pz=void 0)}}function _z(){let e=pz;return e?(pz=void 0,e.dismiss(),!0):!1}function vz(e){_z()&&e.preventDefault(),e.stopPropagation()}var yz=`default`;function bz(e){return e>=1e6?`${xz(e/1e6)}M`:e>=1e3?`${xz(e/1e3)}k`:String(e)}function xz(e){return Number.isInteger(e)?String(e):e.toFixed(2).replace(/0+$/,``).replace(/\.$/,``)}var Sz=[{value:872e3,models:[]}];function Cz(e,t){let n=e??[],r=n.find(e=>e.contextWindow!==void 0)?.contextWindow??272e3,i=`${bz(r)} (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})):Sz,s=[{value:yz,label:i}];for(let e of o){let t=o.length===1||e.models.length===0?`maximum`:`${e.models.join(`, `)} maximum`;s.push({value:String(e.value),label:`${bz(e.value)} (${t})`})}for(let e of[472e3,672e3])e>r&&o.some(t=>t.value>e)&&!s.some(t=>t.value===String(e))&&s.push({value:String(e),label:bz(e)});return t!==void 0&&!s.some(e=>e.value===String(t))&&s.push({value:String(t),label:bz(t)}),[s[0],...s.slice(1).sort((e,t)=>Number(e.value)-Number(t.value))]}var wz=[{value:`200000`,label:`200k`},{value:`350000`,label:`350k`},{value:`500000`,label:`500k (default)`},{value:`750000`,label:`750k`},{value:`1000000`,label:`1M (maximum)`}],Tz={claude:`Compaction window for new Claude threads in this project. Applies on dispatch or after the worker exits, not to a running worker.`,codex:`Context window for new Codex threads in this project. Each model caps the value at its own maximum. Applies on dispatch or a cold resume, not to a running worker.`};typeof window<`u`&&window.document&&window.document.createElement;function Ez(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)}}function Dz(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,Oz(i,...t)]}function Oz(...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 kz=`DismissableLayer`,Az=`dismissableLayer.update`,jz=`dismissableLayer.pointerDownOutside`,Mz=`dismissableLayer.focusOutside`,Nz,Pz=I.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Fz=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(Pz),[d,f]=I.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=I.useState({}),h=tO(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=zz(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=Bz(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=yO(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&&(Nz=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Vz(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=Nz))}},[d,p,n,u]),I.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Vz())},[d,u]),I.useEffect(()=>{let e=()=>m({});return document.addEventListener(Az,e),()=>document.removeEventListener(Az,e)},[]),(0,L.jsx)(_O.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:Ez(e.onFocusCapture,w.onFocusCapture),onBlurCapture:Ez(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:Ez(e.onPointerDownCapture,C.onPointerDownCapture)})});Fz.displayName=kz;var Iz=`DismissableLayerBranch`,Lz=I.forwardRef((e,t)=>{let n=I.useContext(Pz),r=I.useRef(null),i=tO(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)(_O.div,{...e,ref:i})});Lz.displayName=Iz;var Rz=()=>!0;function zz(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Rz}=t,s=yO(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||Hz(jz,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 Bz(e,t=globalThis?.document){let n=yO(e),r=I.useRef(!1);return I.useEffect(()=>{let e=e=>{e.target&&!r.current&&Hz(Mz,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 Vz(){let e=new CustomEvent(Az);document.dispatchEvent(e)}function Hz(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?vO(i,a):i.dispatchEvent(a)}var Uz=`focusScope.autoFocusOnMount`,Wz=`focusScope.autoFocusOnUnmount`,Gz={bubbles:!1,cancelable:!0},Kz=`FocusScope`,qz=I.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=I.useState(null),l=yO(i),u=yO(a),d=I.useRef(null),f=tO(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:eB(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||eB(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&eB(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){tB.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Uz,Gz);s.addEventListener(Uz,l),s.dispatchEvent(t),t.defaultPrevented||(Jz(iB(Xz(s)),{select:!0}),document.activeElement===e&&eB(s))}return()=>{s.removeEventListener(Uz,l),setTimeout(()=>{let t=new CustomEvent(Wz,Gz);s.addEventListener(Wz,u),s.dispatchEvent(t),t.defaultPrevented||eB(e??document.body,{select:!0}),s.removeEventListener(Wz,u),tB.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]=Yz(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&eB(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&eB(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,L.jsx)(_O.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});qz.displayName=Kz;function Jz(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(eB(r,{select:t}),document.activeElement!==n)return}function Yz(e){let t=Xz(e);return[Zz(t,e),Zz(t.reverse(),e)]}function Xz(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 Zz(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Qz(r,{upTo:t})))return r}function Qz(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 $z(e){return e instanceof HTMLInputElement&&`select`in e}function eB(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&$z(e)&&t&&e.select()}}var tB=nB();function nB(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=rB(e,t),e.unshift(t)},remove(t){e=rB(e,t),e[0]?.resume()}}}function rB(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function iB(e){return e.filter(e=>e.tagName!==`A`)}var aB=`Popper`,[oB,sB]=Dz(aB),[cB,lB]=oB(aB),uB=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null),[a,o]=I.useState(void 0);return(0,L.jsx)(cB,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};uB.displayName=aB;var dB=`PopperAnchor`,fB=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=lB(dB,n),o=I.useRef(null),s=a.onAnchorChange,c=tO(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&&SB(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,L.jsx)(_O.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})});fB.displayName=dB;var pB=`PopperContent`,[mB,hB]=oB(pB),gB=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=lB(pB,n),[_,v]=I.useState(null),y=tO(t,v),[b,x]=I.useState(null),S=nj(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(bB),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=WA({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>AA(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[KA({mainAxis:i+w,alignmentAxis:o}),c&&qA({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?JA():void 0,...k}),c&&YA({...k}),XA({...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&&QA({element:b,padding:s}),xB({arrowWidth:C,arrowHeight:w}),f&&ZA({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ee=g.setPlacementState;bO(()=>(ee(M),()=>{ee(void 0)}),[M,ee]);let[F,te]=SB(M),ne=yO(m);bO(()=>{N&&ne?.()},[N,ne]);let re=P.arrow?.x,ie=P.arrow?.y,ae=P.arrow?.centerOffset!==0,[oe,se]=I.useState();return bO(()=>{_&&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)(mB,{scope:n,placedSide:F,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,L.jsx)(_O.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});gB.displayName=pB;var _B=`PopperArrow`,vB={top:`bottom`,right:`left`,bottom:`top`,left:`right`},yB=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=hB(_B,n),a=vB[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)(tj,{...r,ref:t,style:{...r.style,display:`block`}})})});yB.displayName=_B;function bB(e){return e!==null}var xB=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]=SB(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 SB(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var CB=uB,wB=fB,TB=gB,EB=yB;function DB(e,t){return I.useReducer((e,n)=>t[e][n]??e,e)}var OB=e=>{let{present:t,children:n}=e,r=kB(t),i=typeof n==`function`?n({present:r.isPresent}):I.Children.only(n),a=jB(r.ref,NB(i));return typeof n==`function`||r.isPresent?I.cloneElement(i,{ref:a}):null};OB.displayName=`Presence`;function kB(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]=DB(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??MB(r.current),o.current=void 0):a.current=`none`},[s]),bO(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=MB(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]),bO(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=MB(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=MB(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=MB(t)}else r.current=null;n(e)},[])}}function AB(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function jB(...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=AB(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():AB(n[e],null)}}},[])}function MB(e){return e?.animationName||`none`}function NB(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 PB=`Popover`,[FB,IB]=Dz(PB,[sB]),LB=sB(),[RB,zB]=FB(PB),BB=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=LB(t),c=I.useRef(null),[l,u]=I.useState(!1),[d,f]=Fj({prop:r,defaultProp:i??!1,onChange:a,caller:PB});return(0,L.jsx)(CB,{...s,children:(0,L.jsx)(RB,{scope:t,contentId:BO(),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})})};BB.displayName=PB;var VB=`PopoverAnchor`,HB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=zB(VB,n),a=LB(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return I.useEffect(()=>(o(),()=>s()),[o,s]),(0,L.jsx)(wB,{...a,...r,ref:t})});HB.displayName=VB;var UB=`PopoverTrigger`,WB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=zB(UB,n),a=LB(n),o=tO(t,i.triggerRef),s=(0,L.jsx)(_O.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":aV(i.open),...r,ref:o,onClick:Ez(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,L.jsx)(wB,{asChild:!0,...a,children:s})});WB.displayName=UB;var GB=`PopoverPortal`,[KB,qB]=FB(GB,{forceMount:void 0}),JB=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=zB(GB,t);return(0,L.jsx)(KB,{scope:t,forceMount:n,children:(0,L.jsx)(OB,{present:n||a.open,children:(0,L.jsx)(Ej,{asChild:!0,container:i,children:r})})})};JB.displayName=GB;var YB=`PopoverContent`,XB=I.forwardRef((e,t)=>{let n=qB(YB,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=zB(YB,e.__scopePopover);return(0,L.jsx)(OB,{present:r||a.open,children:a.modal?(0,L.jsx)(QB,{...i,ref:t}):(0,L.jsx)($B,{...i,ref:t})})});XB.displayName=YB;var ZB=iO(`PopoverContent.RemoveScroll`),QB=I.forwardRef((e,t)=>{let n=zB(YB,e.__scopePopover),r=I.useRef(null),i=tO(t,r),a=I.useRef(!1);return I.useEffect(()=>{let e=r.current;if(e)return IN(e)},[]),(0,L.jsx)(GP,{as:ZB,allowPinchZoom:!0,children:(0,L.jsx)(eV,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ez(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Ez(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:Ez(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),$B=I.forwardRef((e,t)=>{let n=zB(YB,e.__scopePopover),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(eV,{...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()}})}),eV=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=zB(YB,n),p=LB(n);return UM(),(0,L.jsx)(qz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(Fz,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,L.jsx)(TB,{"data-state":aV(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)`}})})})}),tV=`PopoverClose`,nV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=zB(tV,n);return(0,L.jsx)(_O.button,{type:`button`,...r,ref:t,onClick:Ez(e.onClick,()=>i.onOpenChange(!1))})});nV.displayName=tV;var rV=`PopoverArrow`,iV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=LB(n);return(0,L.jsx)(EB,{...i,...r,ref:t})});iV.displayName=rV;function aV(e){return e?`open`:`closed`}var oV=BB,sV=HB,cV=WB,lV=JB,uV=XB;function dV({modal:e=!1,...t}){return(0,L.jsx)(oV,{modal:e,...t})}var fV=cV,pV=sV;function mV({children:e,side:t=`top`,align:n=`center`,sideOffset:r=6,className:i=``,...a}){return(0,L.jsx)(lV,{children:(0,L.jsx)(uV,{side:t,align:n,sideOffset:r,avoidCollisions:!0,collisionPadding:12,onEscapeKeyDown:e=>e.stopPropagation(),className:`${OM} ${MM} rounded-lg outline-none ${i}`,...a,children:e})})}function hV({backend:e,open:t,onOpenChange:n}){let r=Ve(),i=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()}),a=nt({queryKey:[`codexModels`],queryFn:()=>Y.codexModels(),enabled:e===`codex`}),o=it({mutationKey:[`contextWindowSet`]})>0,s=(0,I.useRef)(null),c=st({mutationKey:[`contextWindowSet`],mutationFn:t=>Y.contextWindowSet({backend:e,tokens:t}),onMutate:()=>({query:r.getQueryCache().find({queryKey:[`settingsGet`]})}),onSuccess:(e,t,n)=>{n?.query?.setData(e)},onError:e=>Z(`Could not save context window: ${e.message.slice(0,80)}`)}),l=e===`claude`?i.data?.autoCompactWindow??5e5:i.data?.codexContextWindow,u=l===void 0?yz:String(l),d=e===`codex`?Cz(a.data,l):[...wz,...wz.some(e=>e.value===u)?[]:[{value:u,label:bz(l)}]],f=e===`claude`?`Compaction window`:`Context window`,p=e===`claude`?`Claude Code`:`Codex`,m=d.find(e=>e.value===u);return(0,L.jsxs)(dV,{open:t,onOpenChange:n,children:[(0,L.jsx)(mL,{asChild:!0,disabled:!i.data||o,onSelect:e=>e.preventDefault(),children:(0,L.jsx)(fV,{asChild:!0,children:(0,L.jsxs)(`button`,{type:`button`,"aria-label":`${p} ${f.toLowerCase()}`,title:Tz[e],disabled:!i.data||o,className:`context-window-trigger inline-flex shrink-0 items-baseline gap-1.5 rounded-[5px] border border-border/80 bg-transparent px-1.5 py-0.5 text-[11px] leading-4 text-muted outline-none hover:border-muted hover:bg-panel-2 hover:text-fg data-[state=open]:border-muted data-[state=open]:bg-panel-2 data-[state=open]:text-fg disabled:opacity-45`,style:{fontVariantCaps:`normal`,letterSpacing:`normal`},children:[(0,L.jsx)(`span`,{className:`context-window-value`,children:i.data?m.label.split(` (`)[0]:`…`}),(0,L.jsx)(Im,{"aria-hidden":`true`,className:`-mx-[0.25em] size-[1em] shrink-0 translate-y-[calc(0.5em_-_0.5cap)]`})]})})}),(0,L.jsxs)(mV,{side:`bottom`,align:`end`,sideOffset:5,className:`w-[204px] max-w-[calc(100vw-1rem)] p-1 text-[12px] leading-[18px]`,style:{fontVariantCaps:`normal`,letterSpacing:`normal`},"data-context-window-menu":e,onOpenAutoFocus:e=>{e.preventDefault(),s.current?.querySelector(`[aria-checked="true"]`)?.focus()},onKeyDown:e=>{if(e.stopPropagation(),![`ArrowDown`,`ArrowUp`,`Home`,`End`].includes(e.key))return;e.preventDefault();let t=[...s.current.querySelectorAll(`button`)],n=t.indexOf(document.activeElement);t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowDown`?1:-1)+t.length)%t.length]?.focus()},children:[(0,L.jsx)(`p`,{className:`px-2 py-1.5 text-[11px] text-muted`,children:f}),(0,L.jsx)(`div`,{ref:s,role:`menu`,"aria-label":`${p} ${f.toLowerCase()} options`,children:d.map(e=>(0,L.jsxs)(`button`,{type:`button`,role:`menuitemradio`,"aria-checked":e.value===u,disabled:o,onClick:()=>{n(!1),e.value!==u&&c.mutate(e.value==="default"?null:Number(e.value))},className:`flex w-full items-center justify-between rounded-[5px] px-2 py-1.5 text-left text-muted outline-none hover:bg-panel-2 hover:text-fg focus-visible:bg-panel-2 aria-checked:bg-panel-2 aria-checked:text-fg`,children:[(0,L.jsx)(`span`,{children:e.label}),e.value===u&&(0,L.jsx)(Fm,{"aria-hidden":`true`,size:13,className:`text-accent`})]},e.value))})]})]})}function gV(e){return e===`xhigh`?`X-high`:e.charAt(0).toUpperCase()+e.slice(1)}function _V({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=kM,className:f=``,contextWindows:p=!1}){let[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(null),v=(0,I.useRef)(g);v.current=g;let y=(0,I.useRef)(m),b=(0,I.useRef)(c),x=(0,I.useRef)(void 0),S=(0,I.useRef)(new Map),C=(0,I.useRef)(void 0),w=(0,I.useMemo)(()=>az(e),[e]),T=(0,I.useMemo)(()=>sz(e),[e]),E=l?$R:QR,D=c?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors hover:border-border hover:bg-panel-2 hover:text-fg`,O=uz(e,t),k=O&&t?.provider&&t.model?cz({provider:t.provider,model:t.model,effort:t.effort??``}):void 0,A=n?.model||n?.effort?dz(e,n,`Pending profile`):void 0;y.current=m,b.current=c;function j(){_(null),y.current=!1,x.current=void 0,h(!1)}function M(){v.current?(v.current=null,_(null),x.current=gz(M)):j()}(0,I.useLayoutEffect)(()=>{let e=e=>{e.key!==`Escape`||!y.current||b.current||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),x.current?.(),M())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]),(0,I.useLayoutEffect)(()=>{!c||!m||(x.current?.(),j())},[c,m]),(0,I.useLayoutEffect)(()=>()=>x.current?.(),[]),(0,I.useLayoutEffect)(()=>{k===C.current&&(C.current=void 0)},[k]);function N(e){let t=cz(e);C.current!==t&&(C.current=t,r(e))}function P(t,n){if(![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(t.key))return;let r=fz(e,n,t.key);r&&(t.preventDefault(),t.stopPropagation(),S.current.get(cz(r))?.focus())}return(0,L.jsxs)(cL,{modal:!1,open:m,onOpenChange:e=>{x.current?.(),x.current=void 0,y.current=e,h(e),e?x.current=gz(M):_(null)},children:[(0,L.jsx)(lL,{asChild:!0,disabled:c,children:(0,L.jsxs)(`button`,{type:`button`,"aria-label":a,"aria-invalid":!O&&(t?.model||t?.effort)?!0:void 0,"aria-description":A?`Pending ${A}`:void 0,title:s,"data-profile-known":O?`true`:`false`,"data-profile-pending":A?`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 ${D} ${f} ${E}`,children:[(0,L.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 flex-1 truncate text-left ${E}`,children:dz(e,t,i)}),A&&(0,L.jsx)(hh,{"aria-hidden":`true`,size:l?10:11,className:`shrink-0 animate-spin text-muted/65`}),(0,L.jsx)(Im,{"aria-hidden":`true`,size:l?11:13,className:`shrink-0 text-fg/65 transition-transform group-data-[state=open]:rotate-180`})]})}),(0,L.jsx)(uL,{children:(0,L.jsxs)(dL,{"aria-label":o,align:`start`,side:u,sideOffset:5,collisionPadding:8,onEscapeKeyDown:e=>e.stopPropagation(),onInteractOutside:e=>{e.target instanceof Element&&e.target.closest(`[data-context-window-menu]`)&&e.preventDefault()},className:`profile-grid-menu ${d} ${OM} max-h-[min(360px,var(--radix-dropdown-menu-content-available-height))] max-w-[calc(100vw-1rem)] overflow-auto rounded-lg p-1.5 ${E}`,children:[e.map(t=>(0,L.jsxs)(fL,{children:[t.label&&(0,L.jsxs)(`div`,{className:`profile-grid-header sticky left-0 flex items-baseline justify-between gap-4 px-1.5 pb-1 pt-1 first:pt-0.5`,children:[(0,L.jsx)(pL,{className:`text-left font-medium tracking-[0.07em] text-muted/55`,children:t.label}),p&&(t.id===`claude`||t.id===`codex`)&&(0,L.jsx)(hV,{backend:t.id,open:g===t.id,onOpenChange:e=>_(e?t.id:null)})]}),(0,L.jsx)(hL,{value:k,onValueChange:t=>{let n=lz(e,t);n&&N(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:tz(w.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 ${E}`,title:e.label,children:e.label}),e.efforts.length===0&&(()=>{let n={provider:t.id,model:e.model,effort:``},r=cz(n);return(0,L.jsx)(gL,{value:r,ref:e=>{e?S.current.set(r,e):S.current.delete(r)},onKeyDown:e=>P(e,n),onSelect:e=>{e.preventDefault(),N(n),x.current?.(),j()},"aria-label":`${e.label}, the agent's own defaults`,title:`${e.label} › the agent's own model and effort`,className:ez,style:{gridColumn:`2 / -1`,justifySelf:`start`},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:`Default`}),(0,L.jsx)(`span`,{className:`col-start-1 row-start-1`,children:`Default`})]})},`default`)})(),e.efforts.length>0&&w.map(n=>{let r=n.find(t=>e.efforts.includes(t)),i=n.reduce((e,t)=>gV(t).length>gV(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 ${E}`,children:gV(i)},i);let a={provider:t.id,model:e.model,effort:r},o=cz(a);return(0,L.jsx)(gL,{value:o,ref:e=>{e?S.current.set(o,e):S.current.delete(o)},onKeyDown:e=>P(e,a),onSelect:e=>{e.preventDefault(),N(a),x.current?.(),j()},"aria-label":`${e.label}, ${gV(r)} effort`,title:`${e.label} › ${gV(r)}`,className:ez,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:gV(r)}),(0,L.jsx)(`span`,{className:`col-start-1 row-start-1`,children:gV(r)})]})},r)})]},e.model))}),t!==e.at(-1)&&(0,L.jsx)(vL,{className:`my-1 h-px bg-border`})]},t.id)),T.length===0&&(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-muted/60`,children:`No profiles available`})]})})]})}function vV(e,t){let n=e?.models.find(t=>t.id===e.current),r=[{value:``,label:n?`Default · ${yV(n).model}`:`Default`,title:`The model the agent opens on when Frizz asks for none`}];t&&!e?.models.some(e=>e.id===t)&&r.push(e&&!e.error?{value:t,label:`${t} (unavailable)`,title:`The agent no longer advertises this model`}:{value:t,label:t});let i=[{label:``,options:r}];for(let t of e?.models??[]){let{provider:e,model:n}=yV(t),r=i.find(t=>t.label===e);r||(r={label:e,options:[]},i.push(r)),r.options.push({value:t.id,label:n,title:t.id})}return i}function yV(e){let t=e.name.indexOf(`/`);if(t>0)return{provider:e.name.slice(0,t).trim(),model:e.name.slice(t+1).trim()};let n=e.id.indexOf(`/`);return n>0?{provider:e.id.slice(0,n),model:e.name}:{provider:`Models`,model:e.name}}function bV(e){return e===`right`?`pl-3 pr-7`:`pl-7 pr-3`}function xV(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 SV=`__frizz_empty_select_value__`,CV=e=>e===``?SV:e,wV=e=>e===SV?``:e,TV={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`},EV={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 DV({o:e,indicatorPosition:t,typography:n}){return(0,L.jsxs)(gL,{value:CV(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 ${bV(t)} ${n??``}`,children:[(0,L.jsx)(_L,{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)(Fm,{size:13})}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]})}function OV({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`,menuZClass:d=kM,className:f=``}){let p=xV(e,n,r,i),m=s?EV[c]:TV[c],h=c===`readout`?ZR:``,[g,_]=(0,I.useState)(!1),v=(0,I.useRef)(g),y=(0,I.useRef)(s),b=(0,I.useRef)(void 0);return v.current=g,y.current=s,(0,I.useLayoutEffect)(()=>{let e=e=>{e.key!==`Escape`||!v.current||y.current||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),v.current=!1,b.current?.(),b.current=void 0,_(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]),(0,I.useLayoutEffect)(()=>{!s||!g||(v.current=!1,b.current?.(),b.current=void 0,_(!1))},[s,g]),(0,I.useLayoutEffect)(()=>()=>b.current?.(),[]),(0,L.jsxs)(cL,{modal:!1,open:g,onOpenChange:e=>{b.current?.(),b.current=void 0,v.current=e,_(e),e&&(b.current=gz(()=>{v.current=!1,b.current=void 0,_(!1)}))},children:[(0,L.jsx)(lL,{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`} ${m} ${c===`readout`?`select-trigger-readout`:``} ${h} ${f}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left ${p.placeholder?`text-muted`:``}`,children:p.text}),(0,L.jsx)(Im,{className:`select-caret shrink-0 text-muted ${s?``:`transition-transform group-data-[state=open]:rotate-180`}`,size:13})]})}),(0,L.jsx)(uL,{children:(0,L.jsx)(dL,{align:`start`,side:u,sideOffset:5,onEscapeKeyDown:e=>e.stopPropagation(),className:`${d} ${OM} min-w-[var(--radix-dropdown-menu-trigger-width)] max-w-[calc(100vw-1rem)] overflow-hidden rounded-lg p-1 ${h}`,children:(0,L.jsx)(hL,{value:CV(e),onValueChange:e=>t(wV(e)),className:`max-h-[300px] min-w-0 overflow-y-auto`,children:r?r.map((e,t)=>(0,L.jsxs)(fL,{children:[e.label&&(0,L.jsx)(pL,{className:`${bV(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)(DV,{o:e,indicatorPosition:l,typography:h},e.value))]},e.label||`g${t}`)):(n??[]).map(e=>(0,L.jsx)(DV,{o:e,indicatorPosition:l,typography:h},e.value))})})})]})}function kV({agentId:e,agentLabel:t,modelId:n,onValueChange:r,disabled:i=!1,side:a=`bottom`,menuZClass:o=kM,className:s=``}){let c=nt({queryKey:[`acpAgentModels`,e],queryFn:()=>Y.acpAgentModels({agentId:e}),staleTime:6e4}),l=vV(c.data,n),u=c.isError?c.error.message:c.data?.error,d=u?`${t} did not list its models (${u}); the thread runs on the agent's own default`:c.data?.models.length?`Model for ${t} — the list is the agent's own, read from its session`:`${t} lists no models; the thread runs on the agent's own default`;return(0,L.jsx)(OV,{variant:`readout`,side:a,value:n??``,onValueChange:e=>r(e||void 0),groups:l,placeholder:c.isPending?`Models…`:`Default`,ariaLabel:`Model for ${t}`,title:d,disabled:i||c.isPending,indicatorPosition:`right`,menuZClass:o,className:s})}async function AV(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(!jV(e))throw Error(`the browser blocked clipboard access`)}function jV(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 MV={claude:`claude auth login`,codex:`codex login`},NV={claude:`Claude`,codex:`Codex`};function PV(e){let t=e.trim();return t===`/login`?`login`:t===`/logout`?`logout`:null}var FV=(0,I.lazy)(()=>Cb(()=>import(`./TerminalPane-C0ndNP2R.js`).then(e=>({default:e.TerminalPane})),__vite__mapDeps([0,1])));function IV({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=MV[e],u=NV[e],d=st({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 AV(l),a(!0),window.setTimeout(()=>a(!1),1500)}catch{Z(`Couldn't copy — select the command and copy it manually`,{duration:6e3})}}let g=st({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)(AL,{open:!0,onOpenChange:e=>{e||(p(),t())},children:(0,L.jsxs)(IL,{children:[(0,L.jsx)(RL,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(HL,{"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)(qL,{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)(FV,{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)(Fm,{size:14,strokeWidth:2,className:`text-green-400`}):(0,L.jsx)(Ym,{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)(hh,{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)(hh,{size:13,className:`animate-spin`}),`Sign in here`]})]})]})]})]})})}function LV({backend:e,onClose:t}){let n=Ve(),r=NV[e],i=st({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)(AL,{open:!0,onOpenChange:e=>{!e&&!i.isPending&&t()},children:(0,L.jsxs)(IL,{children:[(0,L.jsx)(RL,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(HL,{"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)(qL,{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)(hh,{size:13,className:`animate-spin`}),`Sign out`]})]})]})]})})}var RV=ju.options,zV={auto:`Auto`,default:`Default`,acceptEdits:`Accept edits`,plan:`Plan`,bypassPermissions:`Bypass`},BV={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)`};RV.filter(e=>e!==`plan`).map(e=>({value:e,label:zV[e],title:BV[e]}));var VV=[`auto`,`bypassPermissions`].map(e=>({value:e,label:zV[e],title:BV[e]})),HV=[{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 UV(e){return e===`plan`?`auto`:e}var WV=[`low`,`medium`,`high`,`xhigh`,`max`],GV=`ultracode`,KV=new Set([`fable`,`opus`,`sonnet`]);function qV(e){return e&&KV.has(e)?[...WV,GV]:[...WV]}var JV={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-high`,max:`Max`,ultra:`Ultra`,ultracode:`Ultracode`};function YV(e){return JV[e]??e.charAt(0).toUpperCase()+e.slice(1)}function XV(e,t){let n=qV(e).map(e=>({value:e,label:YV(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function ZV(e,t){let n=(e?.efforts??[]).map(e=>({value:e,label:YV(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function QV(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 $V(e,t=[]){let n=t.filter(e=>e.available).map(e=>({model:Qc(e.id),label:e.label,efforts:[]}));return[{id:`claude`,label:`Claude Code`,options:HV.map(e=>({model:e.value,label:e.label,defaultEffort:`high`,efforts:qV(e.value)}))},{id:`codex`,label:`Codex`,options:e.map(e=>({model:e.slug,label:e.displayName,defaultEffort:e.defaultEffort,efforts:e.efforts}))},...n.length?[{id:`acp`,label:`ACP agents`,options:n}]:[]]}function eH(e,t,n=[]){let r=e.backend,i=e[r]??{},a=n.find(e=>e.available),o=i.model??(r===`claude`?`opus`:r===`codex`?t[0]?.slug??``:a?Qc(a.id):``),s=r===`codex`?t.find(e=>e.slug===o):void 0,c=r===`acp`?el(o):void 0,l=r===`acp`?tl(o):void 0,u=r===`acp`&&c?Qc(c):o,d=r===`claude`?HV.some(e=>e.value===o):r===`codex`?t.some(e=>e.slug===o):n.some(e=>e.available&&e.id===c),f=r===`claude`?`high`:s?.defaultEffort??``,p=r===`acp`?``:i.effort??f,m=r===`claude`?XV(o,{withDefault:!1}):r===`codex`?ZV(s,{withDefault:!1}):[],h=r===`acp`||m.some(e=>e.value===p),g=p&&!h?[{value:p,label:`${p} (unavailable)`,title:`Saved reasoning level is not available for this model`},...m]:m;return{backend:r,model:o,pickerModel:u,effort:p,codexModel:s,...c?{acpAgentId:c}:{},...l?{acpModelId:l}:{},modelAvailable:d,effortAvailable:h,effortOptions:g}}function tH(){let e=Ve(),t=nt({queryKey:[`dispatchPreferencesGet`],queryFn:()=>Y.dispatchPreferencesGet()}),n=nt({queryKey:[`codexModels`],queryFn:()=>Y.codexModels()}),r=n.data??[],i=nt({queryKey:[`acpAgents`],queryFn:()=>Y.acpAgents()}),a=i.data??[],o=st({mutationFn:e=>Y.dispatchPreferenceSet(e),scope:{id:`dispatch-preferences`},onMutate:t=>{let n=e.getQueryData([`dispatchPreferencesGet`]);n&&e.setQueryData([`dispatchPreferencesGet`],QV(n,t))},onError:t=>{e.invalidateQueries({queryKey:[`dispatchPreferencesGet`]}),Z(`Could not save new-thread preference: ${t.message.slice(0,80)}`)}}),s=!!t.data&&!!n.data&&(i.isSuccess||i.isError);return{resolved:(0,I.useMemo)(()=>s?eH(t.data,r,a):void 0,[s,t.data,r,a]),codexList:r,acpList:a,loadError:t.isError||n.isError,saveProfile:o.mutate}}var nH=`frizz-drafts:v1`,rH=80,iH=512*1024,aH=2*1024*1024,oH=new TextEncoder;function sH(e){return oH.encode(e).byteLength}function cH(){return{version:1,entries:{}}}function lH(e){if(!e)return cH();try{let t=JSON.parse(e);if(!t||typeof t!=`object`||t.version!==1)return cH();let n=t.entries;if(!n||typeof n!=`object`||Array.isArray(n))return cH();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||sH(t.value)>iH||(r[e]={value:t.value,touchedAt:t.touchedAt});return{version:1,entries:r}}catch{return cH()}}function uH(e){let t=Object.entries(e.entries).filter(([,e])=>e.value&&sH(e.value)<=iH).sort((e,t)=>t[1].touchedAt-e[1].touchedAt),n={};for(let[e,r]of t){if(Object.keys(n).length>=rH)break;n[e]=r,sH(JSON.stringify({version:1,entries:n}))>aH&&delete n[e]}return{version:1,entries:n}}var dH=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=uH(lH(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(nH,JSON.stringify(uH(e)))}catch{}for(let e of this.listeners)e()}};function fH(e){return encodeURIComponent(e||`unresolved-project`)}var pH={dispatch:e=>`dispatch:${fH(e)}:new`,followUp:(e,t,n)=>`followup:${fH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}`,adopt:(e,t)=>`adopt:${fH(e)}:${encodeURIComponent(t)}`,answer:(e,t,n,r,i)=>`answer:${fH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}:${encodeURIComponent(r)}:${i}`,interaction:(e,t,n,r,i,a,o)=>`interaction:${fH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}:${i}:${encodeURIComponent(a)}:${encodeURIComponent(o)}`,question:(e,t,n,r)=>`question:${fH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}`};function mH(){return en(X).board?.projectDir}function hH(e){return en(X).board?.threads.find(t=>t.id===e)?.sessionId}function gH(e){let t=(0,I.useCallback)(()=>dH.get(e),[e]);return[(0,I.useSyncExternalStore)(dH.subscribe,t,t),(0,I.useCallback)(t=>dH.set(e,t),[e]),(0,I.useCallback)(()=>dH.clear(e),[e])]}function _H(e){let t=(0,I.useCallback)(()=>JSON.stringify(Object.fromEntries(e.map(e=>[e,dH.get(e)]))),[e.join(`\0`)]),n=(0,I.useSyncExternalStore)(dH.subscribe,t,t);return(0,I.useMemo)(()=>new Map(Object.entries(JSON.parse(n))),[n])}function vH({autoFocus:e,onDispatched:t}){let{resolved:n,codexList:r,acpList:i,loadError:a,saveProfile:o}=tH(),s=it({mutationKey:[`contextWindowSet`]})>0,c=YR(),l=mH(),[u,d,f]=gH(pH.dispatch(l)),p=pH.dispatch(l),m=(0,I.useRef)(``),[h,g]=(0,I.useState)(null),_=nt({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4}),[v,y]=(0,I.useState)(null),[b,x]=(0,I.useState)(null),S=(0,I.useRef)(null),C=st({mutationFn:e=>Y.dispatch(e),onMutate:()=>Z(`Starting thread…`,{spinner:!0,sticky:!0}),onSuccess:e=>{g(null),t?.(),Z(`Thread started`,{link:{label:`Open thread`,slug:e.slug}})},onError:(e,t)=>{dH.get(p)||d(m.current||t.prompt),g(null);let n=/^AUTH_REQUIRED:(claude|codex)$/.exec(e.message);if(n){S.current=t,y(n[1]),Z(`Signed out of ${n[1]===`claude`?`Claude`:`Codex`}`,{duration:3e3});return}Z(`Dispatch failed: ${e.message.slice(0,80)}`)}});function w(e){m.current=u,f(),g(e.prompt),C.mutate(e)}function T(){if(!u.trim()||!n||s)return;let e=PV(u);if(e){if(f(),n.backend===`acp`){Z(`An ACP agent signs in through its own CLI — Frizz holds no account for it`);return}e===`login`?(S.current=null,y(n.backend)):x(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:u.trim(),model:n.model,backend:n.backend,effort:n.effort||void 0};if(n.backend!==`acp`&&_.data?.[n.backend]===`signed-out`){S.current=t,y(n.backend);return}w(t)}let E=(0,I.useMemo)(()=>{if(!n)return(0,L.jsx)(_V,{groups:[],value:void 0,onValueChange:()=>{},placeholder:a?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort loading`,disabled:!0});let e=$V(r,i),t=n.acpAgentId?i.find(e=>e.id===n.acpAgentId):void 0;return(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-1.5 gap-y-0.5`,children:[(0,L.jsx)(_V,{groups:e,contextWindows:!0,value:{provider:n.backend,model:n.pickerModel,effort:n.effort},onValueChange:e=>o({field:`profile`,backend:e.provider,model:e.model,effort:e.effort||void 0}),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)]`}),t&&(0,L.jsx)(kV,{agentId:t.id,agentLabel:t.label,modelId:n.acpModelId,onValueChange:e=>o({field:`model`,backend:`acp`,value:Qc(t.id,e)}),className:`max-w-[min(14rem,40vw)] px-2 py-1`})]})},[n,r,i,a,o]);return(0,L.jsxs)(`div`,{className:`w-full flex flex-col gap-3`,children:[(0,L.jsx)(KR,{surface:`newComposer`,autoFocus:e,value:u,onChange:d,onSubmit:T,placeholder:`Describe the task…`,minHeight:96,maxHeight:340,busy:C.isPending||s,footer:E,leftAction:c?(0,L.jsx)(XR,{}):void 0}),C.isError&&(0,L.jsx)(`span`,{className:`px-0.5 text-[11px] text-red-400 truncate`,children:C.error.message}),h&&(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:h})]}),v&&(0,L.jsx)(IV,{backend:v,onClose:()=>y(null),onAuthed:()=>{let e=S.current;S.current=null,y(null),e&&w(e)}}),b&&(0,L.jsx)(LV,{backend:b,onClose:()=>x(null)})]})}function yH({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)(AL,{open:!0,onOpenChange:t=>{t||e()},children:(0,L.jsxs)(IL,{children:[(0,L.jsx)(RL,{className:`fixed inset-0 z-50 bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(HL,{ref:t,"aria-modal":`true`,"aria-describedby":void 0,onEscapeKeyDown:vz,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)(qL,{className:`mb-1 text-[14px] font-medium`,children:`New thread`}),(0,L.jsx)(vH,{autoFocus:!0,onDispatched:e})]})]})})}function bH({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 xH=`-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`,SH={claude:`size-[11px] translate-y-px`,codex:`size-[10px]`,acp:`h-[11px] w-[6.65px] translate-y-px`,"acp:opencode":`size-[10px]`,"acp:cursor":`size-[10px]`,"acp:gemini":`size-[10px]`,"acp:copilot":`size-[12px] translate-y-px`,"acp:qwen":`size-[10px]`,"acp:kimi":`size-[10px]`},CH={claude:{key:`claude`,backend:`claude`,label:`Claude Code`},codex:{key:`codex`,backend:`codex`,label:`OpenAI Codex`},acp:{key:`acp`,backend:`acp`,label:`ACP agent`},"acp:opencode":{key:`acp:opencode`,backend:`acp`,label:`OpenCode`},"acp:cursor":{key:`acp:cursor`,backend:`acp`,label:`Cursor agent`},"acp:gemini":{key:`acp:gemini`,backend:`acp`,label:`Gemini CLI`},"acp:copilot":{key:`acp:copilot`,backend:`acp`,label:`GitHub Copilot CLI`},"acp:qwen":{key:`acp:qwen`,backend:`acp`,label:`Qwen Code`},"acp:kimi":{key:`acp:kimi`,backend:`acp`,label:`Kimi CLI`}};function wH(e){return Object.hasOwn(CH,e)}function TH(e,t){if(e===`claude`||e===`codex`)return CH[e];if(e!==`acp`)return;let n=el(t),r=n?`acp:${n}`:`acp`;return wH(r)?CH[r]:CH.acp}function EH({backend:e,model:t,className:n}){let r=TH(e,t);return r?(0,L.jsx)(`span`,{role:`img`,"aria-label":r.label,className:`inline-flex shrink-0 text-muted/65 ${SH[r.key]} ${n??``}`,children:DH[r.key]()}):null}var DH={claude:AH,codex:kH,acp:OH,"acp:opencode":jH,"acp:cursor":MH,"acp:gemini":NH,"acp:copilot":PH,"acp:qwen":FH,"acp:kimi":IH};function OH(){return(0,L.jsx)(Eh,{"aria-hidden":`true`,focusable:`false`,className:`size-full`,strokeWidth:2.5,viewBox:`4.75 0.75 14.5 22.5`})}function kH(){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 AH(){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`})})}function jH(){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 24H2V0h20zM17 4.8H7v14.4h10z`})})}function MH(){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:`M11.503.131 1.891 5.678a.84.84 0 0 0-.42.726v11.188c0 .3.162.575.42.724l9.609 5.55a1 1 0 0 0 .998 0l9.61-5.55a.84.84 0 0 0 .42-.724V6.404a.84.84 0 0 0-.42-.726L12.497.131a1.01 1.01 0 0 0-.996 0M2.657 6.338h18.55c.263 0 .43.287.297.515L12.23 22.918c-.062.107-.229.064-.229-.06V12.335a.59.59 0 0 0-.295-.51l-9.11-5.257c-.109-.063-.064-.23.061-.23`})})}function NH(){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:`M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81`})})}function PH(){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:`M23.922 16.997C23.061 18.492 18.063 22.02 12 22.02 5.937 22.02.939 18.492.078 16.997A.641.641 0 0 1 0 16.741v-2.869a.883.883 0 0 1 .053-.22c.372-.935 1.347-2.292 2.605-2.656.167-.429.414-1.055.644-1.517a10.098 10.098 0 0 1-.052-1.086c0-1.331.282-2.499 1.132-3.368.397-.406.89-.717 1.474-.952C7.255 2.937 9.248 1.98 11.978 1.98c2.731 0 4.767.957 6.166 2.093.584.235 1.077.546 1.474.952.85.869 1.132 2.037 1.132 3.368 0 .368-.014.733-.052 1.086.23.462.477 1.088.644 1.517 1.258.364 2.233 1.721 2.605 2.656a.841.841 0 0 1 .053.22v2.869a.641.641 0 0 1-.078.256Zm-11.75-5.992h-.344a4.359 4.359 0 0 1-.355.508c-.77.947-1.918 1.492-3.508 1.492-1.725 0-2.989-.359-3.782-1.259a2.137 2.137 0 0 1-.085-.104L4 11.746v6.585c1.435.779 4.514 2.179 8 2.179 3.486 0 6.565-1.4 8-2.179v-6.585l-.098-.104s-.033.045-.085.104c-.793.9-2.057 1.259-3.782 1.259-1.59 0-2.738-.545-3.508-1.492a4.359 4.359 0 0 1-.355-.508Zm2.328 3.25c.549 0 1 .451 1 1v2c0 .549-.451 1-1 1-.549 0-1-.451-1-1v-2c0-.549.451-1 1-1Zm-5 0c.549 0 1 .451 1 1v2c0 .549-.451 1-1 1-.549 0-1-.451-1-1v-2c0-.549.451-1 1-1Zm3.313-6.185c.136 1.057.403 1.913.878 2.497.442.544 1.134.938 2.344.938 1.573 0 2.292-.337 2.657-.751.384-.435.558-1.15.558-2.361 0-1.14-.243-1.847-.705-2.319-.477-.488-1.319-.862-2.824-1.025-1.487-.161-2.192.138-2.533.529-.269.307-.437.808-.438 1.578v.021c0 .265.021.562.063.893Zm-1.626 0c.042-.331.063-.628.063-.894v-.02c-.001-.77-.169-1.271-.438-1.578-.341-.391-1.046-.69-2.533-.529-1.505.163-2.347.537-2.824 1.025-.462.472-.705 1.179-.705 2.319 0 1.211.175 1.926.558 2.361.365.414 1.084.751 2.657.751 1.21 0 1.902-.394 2.344-.938.475-.584.742-1.44.878-2.497Z`})})}function FH(){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:`M23.919 14.545 20.817 9.17l1.47-2.544a.56.56 0 0 0 0-.566l-1.633-2.83a.57.57 0 0 0-.49-.283h-6.207L12.487.402a.57.57 0 0 0-.49-.284H8.732a.56.56 0 0 0-.49.284L5.139 5.775h-2.94a.56.56 0 0 0-.49.284L.077 8.887a.56.56 0 0 0 0 .567L3.18 14.83l-1.47 2.545a.56.56 0 0 0 0 .566l1.634 2.83a.57.57 0 0 0 .49.283h6.205l1.47 2.545a.57.57 0 0 0 .49.284h3.266a.57.57 0 0 0 .49-.284l3.104-5.375h2.94a.57.57 0 0 0 .49-.283l1.634-2.828a.55.55 0 0 0-.004-.568M8.733.686l1.634 2.828-1.634 2.828H21.8L20.164 9.17H7.425L5.63 6.06Zm1.306 19.801-6.205-.002 1.634-2.83h3.265L2.201 6.344h3.267q3.182 5.517 6.367 11.032zm10.124-5.66L18.53 12l-6.532 11.315-1.634-2.83c2.129-3.673 4.25-7.351 6.373-11.028h3.592l3.102 5.374z`})})}function IH(){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:`M21.765.351C22.998.351 24 1.353 24 2.586S22.998 4.82 21.765 4.82h-1.974c-.15 0-.26-.12-.26-.26V2.586A2.237 2.237 0 0 1 21.765.35M9.41 13.388l8.447-8.377c.16-.16.07-.471-.14-.471h-4.55s-.1.02-.14.06l-9.099 9.029c-.14.14-.35.02-.35-.21V4.81c0-.15-.1-.27-.221-.27H.22c-.12 0-.22.12-.22.27v18.57c0 .15.1.27.22.27h3.137c.12 0 .22-.12.22-.27v-3.79c0-.08.03-.16.08-.21l2.826-2.796c.07-.07.16-.08.241-.03l7.546 5.551a8.9 8.9 0 0 0 4.018 1.493c.12.01.23-.11.23-.27V19.76c0-.14-.08-.25-.19-.26a5.8 5.8 0 0 1-2.355-.942l-6.533-4.73c-.14-.09-.15-.32-.03-.441`})})}var LH=3e4,RH=45e3;function zH(e,t){return t?AbortSignal.any([t,AbortSignal.timeout(e)]):AbortSignal.timeout(e)}var BH=`text-[9px]`,VH={claude:`text-fg/75! size-[14px]! translate-y-0!`,codex:`text-fg/75! size-[12.75px]! translate-y-0!`};function HH(){let e=nt({queryKey:[`quota`],queryFn:()=>Y.quota(),staleTime:1e4}),t=nt({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4});return[`claude`,`codex`].some(n=>UH(e.data?.[n],t.data?.[n],e.isLoading))}function UH(e,t,n){return t===`signed-out`||!e&&n?!1:!!e&&e.status===`ok`&&e.windows.length>0}function WH(){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:zH(LH,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:zH(LH,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:zH(RH)}).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 ${BH}`,children:[(0,L.jsx)(GH,{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)(GH,{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 GH({backend:e,quota:t,auth:n,email:r,loading:i,fetching:a,onRecheck:o}){let s=NV[e];if(!UH(t,n,i))return null;let c=KH(100-JH(t.windows).usedPercent);return(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(dV,{onOpenChange:e=>{e&&o()},children:[(0,L.jsx)(fV,{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)(EH,{backend:e,className:VH[e]}),(0,L.jsxs)(`span`,{className:`tabular-nums ${YH(c)}`,children:[c,`%`]})]})}),(0,L.jsxs)(mV,{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)(EH,{backend:e}),(0,L.jsx)(`span`,{children:s}),t?.planType&&(0,L.jsxs)(`span`,{className:`text-muted/70`,children:[`· `,XH(t.planType),` plan`]}),a&&(0,L.jsx)(hh,{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=KH(100-e.usedPercent),n=ZH(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:YH(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 KH(e){return Math.max(0,Math.min(100,Math.round(e)))}var qH=25;function JH(e){return e.find(e=>e.key===`5h`)??e.reduce((e,t)=>t.usedPercent>e.usedPercent?t:e)}function YH(e){return e<=8?`text-red-400`:e<=qH?`text-accent`:`text-fg/70`}function XH(e){return e&&e[0].toUpperCase()+e.slice(1)}function ZH(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 QH=`frizz:supervisor-status-wake`,$H=`frizz:reload-after-update-restart`,eU=`frizz:update-restart-from-version`;function tU(e,t){return t.version===e?{kind:`previous-kept`}:{kind:`successor-failed`,version:t.version}}function nU(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 rU(e){return e?.artifactDigest??e?.version??null}function iU(e,t){if(e===null||t?.state!==`ready`)return!1;let n=rU(t);return n!==null&&n!==e}var aU=3*6e4,oU={silentSince:null,silentForMs:0,stalled:!1};function sU(e,t,n=aU){if(!t.restarting||t.answered)return oU;let r=e.silentSince??t.at,i=Math.max(0,t.at-r);return{silentSince:r,silentForMs:i,stalled:i>=n}}function cU(e,t){return e.ackedAt!==null&&t.requestedAt>=e.ackedAt}function lU(e,t){return e.attempt&&!(cU(e.attempt,t)&&uU(e.attempt,t))?e:{state:t.state,message:t.message??null,attempt:null}}function uU(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 dU(e,t){return t.state===`ready`&&e.attempt===null}function fU(e){return e!==null}function pU(e){return e?.updateRestart===!0&&e.updateAvailable!==!1}function mU(e){return e?.dev===!0}async function hU(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 gU(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 _U(e=fetch){return gU(`/_frizz/control/restart`,e)}function vU(e=fetch){return gU(`/_frizz/control/update-restart`,e)}var yU=8e3,bU=500,xU=[`supervisorStatus`];function SU(e,t){return e===`restarting`||t?bU:yU}var CU=rt({queryKey:xU,queryFn:async()=>{let e=Date.now(),t=await hU();return t?{...t,requestedAt:e}:null},refetchInterval:e=>SU(e.state.data?.state,X.controlPlaneRestartAttempt!==null),staleTime:e=>SU(e.state.data?.state,X.controlPlaneRestartAttempt!==null)});function wU(){return nt(CU)}var TU=null;function EU(e){TU||(TU=e,window.addEventListener(QH,()=>{e.refetchQueries({queryKey:xU,exact:!0})}))}function DU(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 OU=`Install the latest version of Frizz. Your running threads will not be affected.`,kU=`A newer version of Frizz is available. Your running threads will not be affected.`,AU=`Restart Frizz. Your running threads will not be affected.`,jU=`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)]`,MU=`absolute -top-[7px] left-4 h-3 w-3 rotate-45 border-l border-t bg-elevated`,NU=`sm:w-[min(23rem,calc(100vw-1.5rem))]`,PU=`sm:w-[min(34rem,calc(100vw-1.5rem))]`,FU=`rounded-xl bg-elevated p-3.5 shadow-xl shadow-black/45`;function IU({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:`${jU} ${NU} ${FU} border border-border-strong`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${MU} 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)(Oh,{"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?kU:OU:AU})]})}var LU={kind:`previous-kept`};function RU({update:e,message:t,outcome:n=LU,onDismiss:r}){return(0,L.jsxs)(`div`,{role:`alert`,className:`${jU} ${PU} ${FU} border border-red-500/45`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${MU} 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)(Bh,{"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)(Hh,{"aria-hidden":`true`,size:14,strokeWidth:2.25})})]}),(0,L.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:nU(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 zU({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 ${xH}`,onFocus:i,onBlur:a,onClick:o,children:[(0,L.jsx)(Oh,{size:14,"aria-hidden":`true`,className:t?`animate-spin`:void 0}),e&&!t&&DU(n,r)&&(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-[2px] top-[2px] h-[4px] w-[4px] rounded-full bg-accent`})]})}function BU(){let e=en(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=wU().data??null,f=pU(d),p={version:d?.version,updateVersion:d?.updateVersion};if(!fU(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?tU(l.current.version,{version:d?.version}):LU,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:rU(d)});try{if(f?await vU():await _U(),f){sessionStorage.setItem($H,e),l.current.version?sessionStorage.setItem(eU,l.current.version):sessionStorage.removeItem(eU);let t=X.controlPlaneRestartAttempt;t&&(X.controlPlaneRestartAttempt={...t,ackedAt:Date.now()}),window.dispatchEvent(new Event(QH)),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)(zU,{update:f,busy:r,version:p.version,updateVersion:p.updateVersion,onFocus:()=>n(!0),onBlur:()=>n(!1),onClick:()=>void y()}),_&&(0,L.jsx)(RU,{update:f,message:_,outcome:v,onDismiss:()=>c(_)}),(0,L.jsx)(IU,{open:t&&!_,update:f,version:p.version,updateVersion:p.updateVersion})]})}function VU(){return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px shrink-0 bg-border`})}function HU({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 UU(){let e=xw(),t=SG(e),n=HH(),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)(Yb,{to:`/`,title:`All projects`,"aria-label":`All projects`,className:`${xH} -ml-px`,children:(0,L.jsx)(lh,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(VU,{}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Settings`,title:`Settings`,className:xH,onClick:()=>X.showSettings=!0,children:(0,L.jsx)(Mh,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(BU,{}),n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(VU,{}),(0,L.jsx)(WH,{})]}),(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)(HU,{text:i})}):i?(0,L.jsx)(HU,{text:i,title:i,className:`font-semibold text-fg/90`}):(0,L.jsx)(`span`,{className:`identity-placeholder w-24`,"aria-hidden":`true`})})]})}var WU=Xt({at:{}}),GU=12e3,KU=new Map;function qU(e,t=Date.now()){WU.at[e]=t;let n=KU.get(e);n!==void 0&&clearTimeout(n),KU.set(e,setTimeout(()=>{KU.delete(e),delete WU.at[e]},GU))}function JU(e){let t=KU.get(e);t!==void 0&&(clearTimeout(t),KU.delete(e)),delete WU.at[e]}function YU(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 XU(){return en(WU).at}function ZU(e,t,n=Date.now()){return t===void 0||!YU(e,t,n)?e:{...e,runtime:`running`,needsYou:!1,pendingAsk:void 0,pendingQuestion:!1,actionableInteraction:!1,lastUserAt:new Date(t).toISOString()}}function QU(e){let t=XU();return(0,I.useMemo)(()=>e.map(e=>ZU(e,t[e.id])),[e,t])}var $U=0;function eW(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():($U+=1,`browser-${Date.now()}-${$U}`)}function tW({optimistic:e,request:t,success:n,failure:r}){e(),t().then(()=>n?.(),e=>r(e instanceof Error?e:Error(String(e))))}var nW=new Map;function rW(e,t){let n=(nW.get(e)??Promise.resolve()).then(t,t);return nW.set(e,n.then(()=>{},()=>{})),n}var iW=[300,800,1800,3500],aW=12e4,oW=e=>new Promise(t=>{setTimeout(t,e)});async function sW(e,t,n=oW){for(let r=0;;r++){try{await e()}catch(e){if(r>=iW.length||!jf(e))throw e;t(),await n(iW[r]);continue}t();return}}function cW(e,t,n,r,i,a=aW){let o=new AbortController,s=setTimeout(()=>o.abort(Error(`Frizz did not answer this send`)),a);return Y.followUp({slug:e,sessionId:hm(X.board,e)?.sessionId??``,message:t,deliveryId:n,freshProcess:r,interrupt:i},{signal:o.signal}).finally(()=>clearTimeout(s))}function lW(e,t,n,r,i){return sW(()=>cW(e,t,n,r,i),()=>qU(e))}function uW(e,t,n,r={}){let i=n.trim();if(!i)return!1;let a=eW();return tW({optimistic:()=>{r.onOptimistic?.(),Bw(e,t,i,{scrollToBottom:r.scrollToBottom,deliveryId:a}),qU(t),Y.markRead({slug:t}).catch(()=>{})},request:()=>rW(t,()=>lW(t,i,a,r.freshProcess,r.interrupt)),success:()=>r.onSuccess?.(),failure:n=>{Vw(e,t,i,a),JU(t),r.onRollback?.(),Z(r.failureToast?.(n.message)??`Steer failed — ${n.message.slice(0,160)}`)}}),!0}function dW(e){let t=Ve(),[n,r]=(0,I.useState)(0);return{submit:(0,I.useCallback)((n,i={})=>uW(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 fW(e,t){return new Promise(n=>{uW(e,t,`Continue exactly where you left off.`,{onSuccess:()=>{Z(`Retrying…`),n()},onRollback:()=>n(),failureToast:e=>`Retry failed: ${e.slice(0,80)}`})||n()})}function pW(e,t=`pull`){let n=/^([A-Za-z0-9][\w.-]*)\/([A-Za-z0-9][\w.-]*)#(\d+)$/.exec(e.trim());return n?`https://github.com/${n[1]}/${n[2]}/${t===`issue`?`issues`:`pull`}/${n[3]}`:null}var mW=`Waiting for an external update.`;function hW(e){let t=new Set;return e.flatMap(e=>{if(e.kind!==`pr`&&e.kind!==`issue`)return[];let n=e.value.trim();return!n||t.has(`${e.kind}:${n}`)?[]:(t.add(`${e.kind}:${n}`),[{ref:n,url:pW(n,e.kind===`issue`?`issue`:`pull`)}])})}function gW(e){let t=(e.body??``).split(/\n\s*\n/).map(e=>e.trim()).find(Boolean);return t?yW(_W(t.replace(/\s*\n\s*/g,` `))):null}function _W(e){if(e.length<=vW)return e;let t=e.slice(0,vW),n=t.lastIndexOf(` `);return`${(n>vW/2?t.slice(0,n):t).replace(/[.,;:]$/,``)}…`}var vW=240;function yW(e){let t=(e.split(/\s/,1)[0]??``).replace(/[.,:;]+$/,``);return/[^a-zA-Z]/.test(t)||/[A-Z]/.test(t.slice(1))||bW.has(t)?e:e.charAt(0).toUpperCase()+e.slice(1)}var bW=new Set([`npm`,`npx`,`pnpm`,`nub`,`nubx`,`gh`,`git`,`node`,`bun`,`tsc`,`vite`,`curl`,`ssh`]);function xW(e){return e&&CW(e)||null}var SW=new Set([...pl,`shells`,`agents`,`timers`,`prs`,`issues`,`for`,`title`]);function CW(e){return e.split(`
200
+ `).filter(e=>{let t=/^\s*([a-z][a-z-]*):/i.exec(e)?.[1]?.toLowerCase();return!(t&&SW.has(t))}).join(`
201
+ `).trim()}function wW(e){let t=t=>e.filter(e=>e.kind===t&&e.value.trim()).length,n=[...hW(e).map(e=>e.ref),TW(t(`shell`),`background shell`,`background shells`),TW(t(`agent`),`sub-agent`,`sub-agents`),TW(t(`timer`),`timer`,`timers`)].filter(e=>e!==null);return n.length>0?`waiting on ${EW(n)}`:null}function TW(e,t,n){return e<=0?null:e===1?`a ${t}`:`${e} ${n}`}function EW(e){return e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function DW(e){let t=e.find(e=>e.kind===`pr`);if(t)return`PR ${t.value}`;let n=e.find(e=>e.kind===`issue`);return n?`Issue ${n.value}`:null}var OW=Xt({at:{}}),kW=12e3,AW=new Map;function jW(e,t=Date.now()){OW.at[e]=t;let n=AW.get(e);n!==void 0&&clearTimeout(n),AW.set(e,setTimeout(()=>{AW.delete(e),delete OW.at[e]},kW))}function MW(e){let t=AW.get(e);t!==void 0&&(clearTimeout(t),AW.delete(e)),delete OW.at[e]}function NW(){return en(OW).at}function PW(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 FW(e){let t=NW();return(0,I.useMemo)(()=>e.map(e=>PW(e,t[e.id])),[e,t])}var IW=.5;function LW(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*IW,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 RW(e,t,n,r){return!e||e.top<=r&&e.bottom>r?!0:Math.abs(t-n)>1}function zW(e,t,n,r,i=8){return n<e+i?n-e-i:r>t-i?r-t+i:0}var BW=`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`,VW=`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 HW(){let e=en(X),t=FW(QU(Cw(xw()?.threads??[]))),n=FE(t,en(JT).queueOrder),r=dE(mE(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(RW(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=LW(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=zW(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:jp(e)??window.scrollY},u(e)},[]);return(0,L.jsx)(`aside`,{className:VW,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)(UU,{}),(0,L.jsx)(vH,{})]}),(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)(XW,{t:e,active:l===e.id,onQueueNavigate:p}),(0,L.jsx)(tG,{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}=PE(a),n=e=>t=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(XW,{t,active:l===t.id,onQueueNavigate:p,restedAge:e}),(0,L.jsx)(tG,{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)(UW,{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)(XW,{t:e,active:l===e.id,onQueueNavigate:p}),(0,L.jsx)(tG,{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)(UW,{label:`Done`,count:s.length,collapsed:i.inactive,onToggle:()=>X.sidebarCollapsed.inactive=!X.sidebarCollapsed.inactive}),!i.inactive&&(0,L.jsx)(KW,{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)(UW,{label:`External`,count:r.length,collapsed:i.external,onToggle:()=>X.sidebarCollapsed.external=!X.sidebarCollapsed.external}),!i.external&&r.map(e=>(0,L.jsx)(XW,{t:e,active:l===e.id,onQueueNavigate:p,restedAge:!0},e.id))]})]})]})})}function UW({label:e,count:t,collapsed:n,onToggle:r}){let i=(0,L.jsxs)(L.Fragment,{children:[r?(0,L.jsx)(Rm,{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 WW=27,GW=8;function KW({threads:e,railRef:t,activeId:n,onQueueNavigate:r}){let i=(0,I.useRef)(null),[a,o]=(0,I.useState)(0),s=wT({count:e.length,getScrollElement:()=>t.current,getItemKey:t=>e[t]?.id??t,estimateSize:()=>WW,overscan:GW,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)(XW,{t:i,active:n===i.id,onQueueNavigate:r}),(0,L.jsx)(tG,{t:i})]},i.id):null})})}var qW=16,JW=12;function YW({title:e,children:t}){let n=e.trimEnd(),r=n.lastIndexOf(` `)+1,i=n.length-r<=qW?r:n.length-JW;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 XW=(0,I.memo)(function({t:e,legacy:t,active:n=!1,onQueueNavigate:r,restedAge:i=!1}){let a=!t&&e.foreign===!0,o=!t&&xE(e),s=!t&&kE(e)===`archived`,c=o||s,l=!t&&aE(e),u=!t&&AE(e),d=!t&&hE(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&&Yp(e.id)){r?.(e.id);return}Wp(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)(oG,{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)(YW,{title:QT(e),children:[!t&&(0,L.jsx)(EH,{backend:e.backend,model:e.model,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)(nG,{status:e.archived?`archived`:e.status})]})}),i&&(0,L.jsx)(ZW,{t:e,yieldsToRetry:!0}),d&&!i&&(0,L.jsx)($W,{})]})})]}),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)(wL,{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)(eG,{t:e,className:`-mr-0.5`}),(0,L.jsx)(FM,{slug:e.id,size:12,className:BW}),u&&(0,L.jsx)(QW,{slug:e.id}),!a&&d&&(0,L.jsx)(eG,{t:e})]})]})});function ZW({t:e,yieldsToRetry:t}){let n=eD(),r=lE(e),i=VE(r,n);return!r||!i?null:(0,L.jsx)(`time`,{dateTime:r,"data-rail-rested-age":!0,title:RE(r,n)??void 0,"aria-label":`Rested ${RE(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 QW({slug:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return(0,L.jsx)(PM,{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),fW(t,e).finally(()=>r(!1))},className:`${BW} disabled:opacity-50`,children:n?(0,L.jsx)(hh,{size:13,className:`animate-spin`}):(0,L.jsx)(Ah,{size:13})})})}function $W(){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)(Th,{size:12,fill:`currentColor`})})}function eG({t:e,className:t=``}){let n=hE(e),[r,i]=(0,I.useState)(!1);return(0,L.jsx)(PM,{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:`${BW} disabled:opacity-50 ${t}`,children:n?(0,L.jsx)(wh,{size:12,fill:`currentColor`}):(0,L.jsx)(Th,{size:12})})})}function tG({t:e}){let t=LD(e.subAgents??[],`rail`);return t.length===0?null:(0,L.jsx)(`div`,{className:`flex flex-col`,children:t.map(t=>(0,L.jsx)(BD,{kind:`AGENT`,label:t.label,state:t.state,density:`rail`,depth:t.depth,startedAt:t.startedAt,parentSlug:e.id,onOpen:()=>Hp(e.id,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}),onDismiss:LM(e.id,t),title:t.subagentType?`[${t.subagentType}] ${t.label}`:t.label},t.id))})}function nG({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] ${ZT[e]??`text-muted border-border`}`,children:t})}function rG(e,t,n=null){return[[t,wW(e.lastFence?.kind===`awaiting`?e.lastFence.hints:[]),n].filter(e=>!!e).join(` — `),iG(e)].filter(e=>!!e).join(`
202
202
 
203
- `)}function JW(e){return e.lastFence?.kind===`awaiting`?oW(e.lastFence):null}var YW=7;function XW({t:e,legacy:t}){let{node:n,tip:r}=t?sG(e):ZW(e),i=t?void 0:yE(e);return r?(0,L.jsx)(wM,{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 ZW(e){let t=iG(e);if(yE(e)===`snoozed`)return t;let n=uE(e),r=n?MT(n,e.snoozePrompt):null;return r?{node:t.node,tip:QW(t.tip,r)}:t}function QW(e,t){if(!e)return t;let[n,...r]=e.split(`
203
+ `)}function iG(e){return e.lastFence?.kind===`awaiting`?gW(e.lastFence):null}var aG=7;function oG({t:e,legacy:t}){let{node:n,tip:r}=t?_G(e):sG(e),i=t?void 0:kE(e);return r?(0,L.jsx)(PM,{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 sG(e){let t=mG(e);if(kE(e)===`snoozed`)return t;let n=bE(e),r=n?HT(n,e.snoozePrompt):null;return r?{node:t.node,tip:cG(t.tip,r)}:t}function cG(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 $W=(0,L.jsx)(aG,{children:(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-rail-dot`,"data-running-indicator":`thread-background`})}),eG=9,tG=(0,L.jsx)(aG,{children:(0,L.jsx)(sh,{size:eG,className:`text-muted/70`,style:{transform:`translateX(${eG/24}px)`}})}),nG=(0,L.jsx)(aG,{children:(0,L.jsx)(ch,{size:9,className:`text-muted/70`})});function rG(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 ${tD(n-t)}`:`firing…`}function iG(e){let t=yE(e);if(t===`archived`)return{node:(0,L.jsx)(aG,{children:(0,L.jsx)(Fm,{size:10,strokeWidth:3,className:`text-muted/75`})}),tip:`Done`};if(t===`needs-input`)return{node:(0,L.jsx)(aG,{children:(0,L.jsx)(oG,{ch:`?`,muted:!0})}),tip:`Needs your input`};if(t===`working`)return{node:(0,L.jsx)(GE,{}),tip:`Working`};if(t===`background`)return{node:$W,tip:qW(e,e.lastFence?.kind===`awaiting`&&mW(e.lastFence.hints)!==null?`At rest`:`At rest — a background shell is still running`)};if(t===`done`)return{node:(0,L.jsx)(aG,{children:(0,L.jsx)(Fm,{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)(aG,{accent:!0,children:(0,L.jsx)(oG,{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 ${FE(t.resumesAt)}`:`continuing automatically once the window resets`:`won't resume by itself — Retry to continue`;return{node:(0,L.jsx)(aG,{accent:!0,children:(0,L.jsx)(ch,{size:9,className:`text-accent`})}),tip:`Paused by the ${t?.backend===`codex`?`Codex`:`Claude`} ${n} — ${r}`}}if(t===`pr`)return{node:tG,tip:qW(e,`At rest`)};if(t===`timer`)return{node:nG,tip:qW(e,e.lastFence?.kind===`awaiting`&&mW(e.lastFence.hints)!==null?`At rest`:`At rest — waiting on a timer`,rG(e))};if(t===`snoozed`){let t=nG,n=tG,r=_E(e)?n:t,i=uE(e);if(i){let t=MT(i,e.snoozePrompt)??`Snoozed until a scheduled check`;return{node:r,tip:qW(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:_E(e)?n:$W,tip:a}:{node:t,tip:(typeof e.revalidate==`string`?NT(e.revalidate):null)??`Auto-snoozed until a scheduled check`};let o=e.lastFence.hints.find(e=>e.kind===`pr`||e.kind===`issue`||e.kind===`shell`||e.kind===`agent`||e.kind===`timer`)?.kind;return{node:_E(e)?n:o===`shell`||o===`agent`?$W:t,tip:qW(e,a??`Snoozed`,o===`timer`?rG(e):null)}}return{node:(0,L.jsx)(aG,{children:(0,L.jsx)(Xm,{size:11,className:`text-muted/70`})}),tip:qW(e,`At rest`)}}function aG({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 oG({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 sG(e){if(e.runtime===`running`||e.runtime===`spawning`||e.runtime===`perm-prompt`)return{node:(0,L.jsx)(cG,{}),tip:`Working`};let t=(e.subAgents??[]).some(e=>e.state===`running`);return e.runtime===`turn-idle`&&t&&!e.humanBlocked?{node:(0,L.jsx)(cG,{}),tip:`Working`}:XT(e)?{node:(0,L.jsx)(lG,{}),tip:`Needs your input`}:e.status===`needs-human`?{node:(0,L.jsx)(uG,{}),tip:`Awaiting you — open to read & reply`}:e.status===`blocked`&&e.mechanism===`timer`?{node:(0,L.jsx)(zh,{size:8,className:`text-muted/70`}),tip:`Waiting on a timer`}:e.status===`blocked`&&e.mechanism===`threads`?{node:(0,L.jsx)(Um,{size:8,className:`text-muted/70`}),tip:`Waiting on other work`}:{node:(0,L.jsx)(dG,{}),tip:null}}function cG(){return(0,L.jsx)(`span`,{className:`block rounded-full border border-muted/70 border-t-transparent animate-spin`,style:{width:8,height:8}})}function lG(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-sky-400`,style:{width:YW,height:YW}})}function uG(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-yellow-400`,style:{width:YW,height:YW}})}function dG(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-muted/30`,style:{width:YW,height:YW}})}function fG(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 pG={planning:`Being designed`,planned:`Roadmap`,active:`Active`,"needs-human":`Awaiting you`,blocked:`Blocked`,done:`Done`,dismissed:`Dismissed`,archived:`Done`};function mG({status:e}){let t=eE(mw(fw()?.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:pG[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:()=>Vp(`thread`,e.id),children:[(0,L.jsx)(`div`,{className:`leading-snug`,children:HT(e)}),e.statusText&&(0,L.jsx)(`div`,{className:`text-[11px] text-muted mt-0.5`,children:e.statusText})]},e.id))]})]})}var hG=21,gG=4/15;function _G({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*gG},children:e})}function vG({size:e=18}){return(0,L.jsx)(_G,{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 yG({size:e=18}){return(0,L.jsx)(_G,{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 bG({size:e=18}){return(0,L.jsx)(_G,{size:e,tone:`border-muted/40`,children:(0,L.jsx)(Fm,{size:Math.round(e*10/15),strokeWidth:3,className:`text-muted/85`})})}function xG({size:e=18}){return(0,L.jsx)(_G,{size:e,children:(0,L.jsx)(ch,{size:Math.round(e*10/15),className:`text-muted/75`})})}function SG({kind:e}){return e===`needs-input`?(0,L.jsx)(yG,{}):e===`stalled`?(0,L.jsx)(_G,{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)(vG,{}):e===`limit`?(0,L.jsx)(_G,{tone:`border-accent/90`,children:(0,L.jsx)(ch,{size:12,className:`text-accent`})}):e===`snoozed`||e===`timer`?(0,L.jsx)(xG,{}):e===`done`||e===`archived`?(0,L.jsx)(bG,{}):(0,L.jsx)(_G,{})}var CG=76,wG=10;function TG({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:CG},children:[(0,L.jsx)(Jm,{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:CG},children:[(0,L.jsx)(Fm,{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)<wG||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 EG({t:e,last:t,openSwipe:n,onOpenSwipe:r}){let i=en(RT).snoozePreset,a=WE(),o=yE(e),s=$T(e),c=e.runtime===`running`||e.runtime===`spawning`||o===`working`||o===`background`?null:jE(s,a),l=e.lastFence?.kind===`awaiting`?_W(e.lastFence.hints):null,u=DD(e.subAgents??[],`rail`);return(0,L.jsxs)(`div`,{className:o===`snoozed`?`opacity-60`:void 0,children:[(0,L.jsx)(TG,{open:n,onOpenChange:r,snoozeLabel:bT(i),onSnooze:async()=>{try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:CT(i),prompt:null}),Z(`Snoozed · ${bT(i)}`)}catch(e){Z(e instanceof Error?e.message.slice(0,100):`Snooze failed`)}},onDone:async()=>{xW(e.id);try{let t=await Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:!1});if(t.needsConfirmation){SW(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){SW(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:()=>Wp(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)(SG,{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:[HT(e),(0,L.jsx)(gH,{backend:e.backend,model:e.model,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)(AD,{kind:`AGENT`,label:t.label,state:t.state,density:`rail`,depth:t.depth,startedAt:t.startedAt,parentSlug:e.id,onOpen:()=>Hp(e.id,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}),onDismiss:DM(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 DG({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 OG({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 kG={open:{cls:`bg-live`,word:`connected`},connecting:{cls:`bg-accent`,word:`connecting…`},closed:{cls:`bg-red-500`,word:`disconnected`}};function AG({connection:e,onClose:t}){let n=kG[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)(PH,{})]}),(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)(Mh,{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)(Rm,{size:17,className:`shrink-0 text-muted/45`})]})})})]})]})}function jG(){let e=en(X),t=fw(),[n,r]=(0,I.useState)(`queue`),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(null),c=TW(HU(mw(t?.threads??[]))),l=en(RT).queueOrder,u=(0,I.useMemo)(()=>TE(c,l),[c,l]),d=(0,I.useMemo)(()=>{let e=u.active.filter(XT),t=u.active.filter(e=>!XT(e));return[...u.pinned,...e,...t]},[u.pinned,u.active]),f=d.filter(XT).length,p=n===`queue`?d:n===`snoozed`?u.snoozed:u.inactive,m=e.view.startsWith(`status:`)?e.view.slice(7):null,h=fG(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)(Lm,{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)(Xm,{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)(mG,{status:m})}):p.length===0?(0,L.jsx)(DG,{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)(EG,{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)(Dh,{size:24,strokeWidth:2.2})}),i?(0,L.jsx)(AG,{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)(OG,{active:n===`queue`,label:`Queue`,count:f>0?f:d.length,asks:f>0,onClick:()=>r(`queue`),icon:(0,L.jsx)(vG,{size:hG})}),(0,L.jsx)(OG,{active:n===`snoozed`,label:`Snoozed`,count:u.snoozed.length,onClick:()=>r(`snoozed`),icon:(0,L.jsx)(xG,{size:hG})}),(0,L.jsx)(OG,{active:n===`done`,label:`Done`,count:u.inactive.length,onClick:()=>r(`done`),icon:(0,L.jsx)(bG,{size:hG})})]})})]})}var MG=`(max-width: 700px)`,NG=new Set,PG=null;function FG(e){return typeof window>`u`?()=>{}:(PG||(PG=window.matchMedia(MG),PG.addEventListener(`change`,()=>NG.forEach(e=>e()))),NG.add(e),()=>NG.delete(e))}function IG(){return PG?PG.matches:typeof window<`u`&&window.matchMedia(MG).matches}function LG(){return(0,I.useSyncExternalStore)(FG,IG,()=>!1)}var RG={schedule:(e,t)=>window.setTimeout(e,t),cancel:e=>window.clearTimeout(e)},zG=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??RG,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 BG(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var VG=BG();function HG(e){VG=e}var UG={exec:()=>null};function WG(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(GG.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var GG={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`)},KG=/^(?:[ \t]*(?:\n|$))+/,qG=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,JG=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,YG=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,XG=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,ZG=/(?:[*+-]|\d{1,9}[.)])/,QG=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,$G=WG(QG).replace(/bull/g,ZG).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(),eK=WG(QG).replace(/bull/g,ZG).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(),tK=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,nK=/^[^\n]+/,rK=/(?!\s*\])(?:\\.|[^\[\]\\])+/,iK=WG(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,rK).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),aK=WG(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,ZG).getRegex(),oK=`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`,sK=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,cK=WG(`^ {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`,sK).replace(`tag`,oK).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),lK=WG(tK).replace(`hr`,YG).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`,oK).getRegex(),uK={blockquote:WG(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,lK).getRegex(),code:qG,def:iK,fences:JG,heading:XG,hr:YG,html:cK,lheading:$G,list:aK,newline:KG,paragraph:lK,table:UG,text:nK},dK=WG(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,YG).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`,oK).getRegex(),fK={...uK,lheading:eK,table:dK,paragraph:WG(tK).replace(`hr`,YG).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,dK).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`,oK).getRegex()},pK={...uK,html:WG(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,sK).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:UG,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:WG(tK).replace(`hr`,YG).replace(`heading`,` *#{1,6} *[^
209
- ]`).replace(`lheading`,$G).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},mK=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,hK=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,gK=/^( {2,}|\\)\n(?!\s*$)/,_K=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,vK=/[\p{P}\p{S}]/u,yK=/[\s\p{P}\p{S}]/u,bK=/[^\s\p{P}\p{S}]/u,xK=WG(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,yK).getRegex(),SK=/(?!~)[\p{P}\p{S}]/u,CK=/(?!~)[\s\p{P}\p{S}]/u,wK=/(?:[^\s\p{P}\p{S}]|~)/u,TK=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,EK=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,DK=WG(EK,`u`).replace(/punct/g,vK).getRegex(),OK=WG(EK,`u`).replace(/punct/g,SK).getRegex(),kK=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,AK=WG(kK,`gu`).replace(/notPunctSpace/g,bK).replace(/punctSpace/g,yK).replace(/punct/g,vK).getRegex(),jK=WG(kK,`gu`).replace(/notPunctSpace/g,wK).replace(/punctSpace/g,CK).replace(/punct/g,SK).getRegex(),MK=WG(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,bK).replace(/punctSpace/g,yK).replace(/punct/g,vK).getRegex(),NK=WG(/\\(punct)/,`gu`).replace(/punct/g,vK).getRegex(),PK=WG(/^<(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(),FK=WG(sK).replace(`(?:-->|$)`,`-->`).getRegex(),IK=WG(`^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`,FK).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),LK=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,RK=WG(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,LK).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),zK=WG(/^!?\[(label)\]\[(ref)\]/).replace(`label`,LK).replace(`ref`,rK).getRegex(),BK=WG(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,rK).getRegex(),VK={_backpedal:UG,anyPunctuation:NK,autolink:PK,blockSkip:TK,br:gK,code:hK,del:UG,emStrongLDelim:DK,emStrongRDelimAst:AK,emStrongRDelimUnd:MK,escape:mK,link:RK,nolink:BK,punctuation:xK,reflink:zK,reflinkSearch:WG(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,zK).replace(`nolink`,BK).getRegex(),tag:IK,text:_K,url:UG},HK={...VK,link:WG(/^!?\[(label)\]\((.*?)\)/).replace(`label`,LK).getRegex(),reflink:WG(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,LK).getRegex()},UK={...VK,emStrongRDelimAst:jK,emStrongLDelim:OK,url:WG(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},WK={...UK,br:WG(gK).replace(`{2,}`,`*`).getRegex(),text:WG(UK.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},GK={normal:uK,gfm:fK,pedantic:pK},KK={normal:VK,gfm:UK,breaks:WK,pedantic:HK},qK={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},JK=e=>qK[e];function YK(e,t){if(t){if(GG.escapeTest.test(e))return e.replace(GG.escapeReplace,JK)}else if(GG.escapeTestNoEncode.test(e))return e.replace(GG.escapeReplaceNoEncode,JK);return e}function XK(e){try{e=encodeURI(e).replace(GG.percentDecode,`%`)}catch{return null}return e}function ZK(e,t){let n=e.replace(GG.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(GG.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(GG.slashPipe,`|`);return n}function QK(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 $K(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 eq(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 tq(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
208
+ `)}var lG=(0,L.jsx)(hG,{children:(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-rail-dot`,"data-running-indicator":`thread-background`})}),uG=9,dG=(0,L.jsx)(hG,{children:(0,L.jsx)(sh,{size:uG,className:`text-muted/70`,style:{transform:`translateX(${uG/24}px)`}})}),fG=(0,L.jsx)(hG,{children:(0,L.jsx)(ch,{size:9,className:`text-muted/70`})});function pG(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 ${dD(n-t)}`:`firing…`}function mG(e){let t=kE(e);if(t===`archived`)return{node:(0,L.jsx)(hG,{children:(0,L.jsx)(Fm,{size:10,strokeWidth:3,className:`text-muted/75`})}),tip:`Done`};if(t===`needs-input`)return{node:(0,L.jsx)(hG,{children:(0,L.jsx)(gG,{ch:`?`,muted:!0})}),tip:`Needs your input`};if(t===`working`)return{node:(0,L.jsx)(tD,{}),tip:`Working`};if(t===`background`)return{node:lG,tip:rG(e,e.lastFence?.kind===`awaiting`&&wW(e.lastFence.hints)!==null?`At rest`:`At rest — a background shell is still running`)};if(t===`done`)return{node:(0,L.jsx)(hG,{children:(0,L.jsx)(Fm,{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)(hG,{accent:!0,children:(0,L.jsx)(gG,{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)(hG,{accent:!0,children:(0,L.jsx)(ch,{size:9,className:`text-accent`})}),tip:`Paused by the ${t?.backend===`codex`?`Codex`:`Claude`} ${n} — ${r}`}}if(t===`pr`)return{node:dG,tip:rG(e,`At rest`)};if(t===`timer`)return{node:fG,tip:rG(e,e.lastFence?.kind===`awaiting`&&wW(e.lastFence.hints)!==null?`At rest`:`At rest — waiting on a timer`,pG(e))};if(t===`snoozed`){let t=fG,n=dG,r=DE(e)?n:t,i=bE(e);if(i){let t=HT(i,e.snoozePrompt)??`Snoozed until a scheduled check`;return{node:r,tip:rG(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:DE(e)?n:lG,tip:a}:{node:t,tip:(typeof e.revalidate==`string`?UT(e.revalidate):null)??`Auto-snoozed until a scheduled check`};let o=e.lastFence.hints.find(e=>e.kind===`pr`||e.kind===`issue`||e.kind===`shell`||e.kind===`agent`||e.kind===`timer`)?.kind;return{node:DE(e)?n:o===`shell`||o===`agent`?lG:t,tip:rG(e,a??`Snoozed`,o===`timer`?pG(e):null)}}return{node:(0,L.jsx)(hG,{children:(0,L.jsx)(Xm,{size:11,className:`text-muted/70`})}),tip:rG(e,`At rest`)}}function hG({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 gG({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 _G(e){if(e.runtime===`running`||e.runtime===`spawning`||e.runtime===`perm-prompt`)return{node:(0,L.jsx)(vG,{}),tip:`Working`};let t=(e.subAgents??[]).some(e=>e.state===`running`);return e.runtime===`turn-idle`&&t&&!e.humanBlocked?{node:(0,L.jsx)(vG,{}),tip:`Working`}:oE(e)?{node:(0,L.jsx)(yG,{}),tip:`Needs your input`}:e.status===`needs-human`?{node:(0,L.jsx)(bG,{}),tip:`Awaiting you — open to read & reply`}:e.status===`blocked`&&e.mechanism===`timer`?{node:(0,L.jsx)(zh,{size:8,className:`text-muted/70`}),tip:`Waiting on a timer`}:e.status===`blocked`&&e.mechanism===`threads`?{node:(0,L.jsx)(Um,{size:8,className:`text-muted/70`}),tip:`Waiting on other work`}:{node:(0,L.jsx)(xG,{}),tip:null}}function vG(){return(0,L.jsx)(`span`,{className:`block rounded-full border border-muted/70 border-t-transparent animate-spin`,style:{width:8,height:8}})}function yG(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-sky-400`,style:{width:aG,height:aG}})}function bG(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-yellow-400`,style:{width:aG,height:aG}})}function xG(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-muted/30`,style:{width:aG,height:aG}})}function SG(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 CG={planning:`Being designed`,planned:`Roadmap`,active:`Active`,"needs-human":`Awaiting you`,blocked:`Blocked`,done:`Done`,dismissed:`Dismissed`,archived:`Done`};function wG({status:e}){let t=uE(Cw(xw()?.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:CG[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:()=>Vp(`thread`,e.id),children:[(0,L.jsx)(`div`,{className:`leading-snug`,children:QT(e)}),e.statusText&&(0,L.jsx)(`div`,{className:`text-[11px] text-muted mt-0.5`,children:e.statusText})]},e.id))]})]})}var TG=21,EG=4/15;function DG({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*EG},children:e})}function OG({size:e=18}){return(0,L.jsx)(DG,{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 kG({size:e=18}){return(0,L.jsx)(DG,{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 AG({size:e=18}){return(0,L.jsx)(DG,{size:e,tone:`border-muted/40`,children:(0,L.jsx)(Fm,{size:Math.round(e*10/15),strokeWidth:3,className:`text-muted/85`})})}function jG({size:e=18}){return(0,L.jsx)(DG,{size:e,children:(0,L.jsx)(ch,{size:Math.round(e*10/15),className:`text-muted/75`})})}function MG({kind:e}){return e===`needs-input`?(0,L.jsx)(kG,{}):e===`stalled`?(0,L.jsx)(DG,{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)(OG,{}):e===`limit`?(0,L.jsx)(DG,{tone:`border-accent/90`,children:(0,L.jsx)(ch,{size:12,className:`text-accent`})}):e===`snoozed`||e===`timer`?(0,L.jsx)(jG,{}):e===`done`||e===`archived`?(0,L.jsx)(AG,{}):(0,L.jsx)(DG,{})}var NG=76,PG=10;function FG({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:NG},children:[(0,L.jsx)(Jm,{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:NG},children:[(0,L.jsx)(Fm,{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)<PG||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 IG({t:e,last:t,openSwipe:n,onOpenSwipe:r}){let i=en(JT).snoozePreset,a=eD(),o=kE(e),s=lE(e),c=e.runtime===`running`||e.runtime===`spawning`||o===`working`||o===`background`?null:VE(s,a),l=e.lastFence?.kind===`awaiting`?DW(e.lastFence.hints):null,u=LD(e.subAgents??[],`rail`);return(0,L.jsxs)(`div`,{className:o===`snoozed`?`opacity-60`:void 0,children:[(0,L.jsx)(FG,{open:n,onOpenChange:r,snoozeLabel:AT(i),onSnooze:async()=>{try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:NT(i),prompt:null}),Z(`Snoozed · ${AT(i)}`)}catch(e){Z(e instanceof Error?e.message.slice(0,100):`Snooze failed`)}},onDone:async()=>{jW(e.id);try{let t=await Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:!1});if(t.needsConfirmation){MW(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){MW(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:()=>Wp(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)(MG,{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:[QT(e),(0,L.jsx)(EH,{backend:e.backend,model:e.model,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)(BD,{kind:`AGENT`,label:t.label,state:t.state,density:`rail`,depth:t.depth,startedAt:t.startedAt,parentSlug:e.id,onOpen:()=>Hp(e.id,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}),onDismiss:LM(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 LG({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 RG({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 zG={open:{cls:`bg-live`,word:`connected`},connecting:{cls:`bg-accent`,word:`connecting…`},closed:{cls:`bg-red-500`,word:`disconnected`}};function BG({connection:e,onClose:t}){let n=zG[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)(WH,{})]}),(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)(Mh,{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)(Rm,{size:17,className:`shrink-0 text-muted/45`})]})})})]})]})}function VG(){let e=en(X),t=xw(),[n,r]=(0,I.useState)(`queue`),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(null),c=FW(QU(Cw(t?.threads??[]))),l=en(JT).queueOrder,u=(0,I.useMemo)(()=>FE(c,l),[c,l]),d=(0,I.useMemo)(()=>{let e=u.active.filter(oE),t=u.active.filter(e=>!oE(e));return[...u.pinned,...e,...t]},[u.pinned,u.active]),f=d.filter(oE).length,p=n===`queue`?d:n===`snoozed`?u.snoozed:u.inactive,m=e.view.startsWith(`status:`)?e.view.slice(7):null,h=SG(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)(Lm,{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)(Xm,{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)(wG,{status:m})}):p.length===0?(0,L.jsx)(LG,{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)(IG,{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)(Dh,{size:24,strokeWidth:2.2})}),i?(0,L.jsx)(BG,{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)(RG,{active:n===`queue`,label:`Queue`,count:f>0?f:d.length,asks:f>0,onClick:()=>r(`queue`),icon:(0,L.jsx)(OG,{size:TG})}),(0,L.jsx)(RG,{active:n===`snoozed`,label:`Snoozed`,count:u.snoozed.length,onClick:()=>r(`snoozed`),icon:(0,L.jsx)(jG,{size:TG})}),(0,L.jsx)(RG,{active:n===`done`,label:`Done`,count:u.inactive.length,onClick:()=>r(`done`),icon:(0,L.jsx)(AG,{size:TG})})]})})]})}var HG=`(max-width: 700px)`,UG=new Set,WG=null;function GG(e){return typeof window>`u`?()=>{}:(WG||(WG=window.matchMedia(HG),WG.addEventListener(`change`,()=>UG.forEach(e=>e()))),UG.add(e),()=>UG.delete(e))}function KG(){return WG?WG.matches:typeof window<`u`&&window.matchMedia(HG).matches}function qG(){return(0,I.useSyncExternalStore)(GG,KG,()=>!1)}var JG={schedule:(e,t)=>window.setTimeout(e,t),cancel:e=>window.clearTimeout(e)},YG=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??JG,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 XG(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var ZG=XG();function QG(e){ZG=e}var $G={exec:()=>null};function eK(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(tK.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var tK={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`)},nK=/^(?:[ \t]*(?:\n|$))+/,rK=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,iK=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,aK=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,oK=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,sK=/(?:[*+-]|\d{1,9}[.)])/,cK=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,lK=eK(cK).replace(/bull/g,sK).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(),uK=eK(cK).replace(/bull/g,sK).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(),dK=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,fK=/^[^\n]+/,pK=/(?!\s*\])(?:\\.|[^\[\]\\])+/,mK=eK(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,pK).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),hK=eK(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,sK).getRegex(),gK=`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`,_K=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,vK=eK(`^ {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`,_K).replace(`tag`,gK).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),yK=eK(dK).replace(`hr`,aK).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`,gK).getRegex(),bK={blockquote:eK(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,yK).getRegex(),code:rK,def:mK,fences:iK,heading:oK,hr:aK,html:vK,lheading:lK,list:hK,newline:nK,paragraph:yK,table:$G,text:fK},xK=eK(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,aK).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`,gK).getRegex(),SK={...bK,lheading:uK,table:xK,paragraph:eK(dK).replace(`hr`,aK).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,xK).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`,gK).getRegex()},CK={...bK,html:eK(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,_K).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:$G,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:eK(dK).replace(`hr`,aK).replace(`heading`,` *#{1,6} *[^
209
+ ]`).replace(`lheading`,lK).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},wK=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,TK=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,EK=/^( {2,}|\\)\n(?!\s*$)/,DK=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,OK=/[\p{P}\p{S}]/u,kK=/[\s\p{P}\p{S}]/u,AK=/[^\s\p{P}\p{S}]/u,jK=eK(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,kK).getRegex(),MK=/(?!~)[\p{P}\p{S}]/u,NK=/(?!~)[\s\p{P}\p{S}]/u,PK=/(?:[^\s\p{P}\p{S}]|~)/u,FK=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,IK=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,LK=eK(IK,`u`).replace(/punct/g,OK).getRegex(),RK=eK(IK,`u`).replace(/punct/g,MK).getRegex(),zK=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,BK=eK(zK,`gu`).replace(/notPunctSpace/g,AK).replace(/punctSpace/g,kK).replace(/punct/g,OK).getRegex(),VK=eK(zK,`gu`).replace(/notPunctSpace/g,PK).replace(/punctSpace/g,NK).replace(/punct/g,MK).getRegex(),HK=eK(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,AK).replace(/punctSpace/g,kK).replace(/punct/g,OK).getRegex(),UK=eK(/\\(punct)/,`gu`).replace(/punct/g,OK).getRegex(),WK=eK(/^<(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(),GK=eK(_K).replace(`(?:-->|$)`,`-->`).getRegex(),KK=eK(`^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`,GK).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),qK=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,JK=eK(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,qK).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),YK=eK(/^!?\[(label)\]\[(ref)\]/).replace(`label`,qK).replace(`ref`,pK).getRegex(),XK=eK(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,pK).getRegex(),ZK={_backpedal:$G,anyPunctuation:UK,autolink:WK,blockSkip:FK,br:EK,code:TK,del:$G,emStrongLDelim:LK,emStrongRDelimAst:BK,emStrongRDelimUnd:HK,escape:wK,link:JK,nolink:XK,punctuation:jK,reflink:YK,reflinkSearch:eK(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,YK).replace(`nolink`,XK).getRegex(),tag:KK,text:DK,url:$G},QK={...ZK,link:eK(/^!?\[(label)\]\((.*?)\)/).replace(`label`,qK).getRegex(),reflink:eK(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,qK).getRegex()},$K={...ZK,emStrongRDelimAst:VK,emStrongLDelim:RK,url:eK(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},eq={...$K,br:eK(EK).replace(`{2,}`,`*`).getRegex(),text:eK($K.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},tq={normal:bK,gfm:SK,pedantic:CK},nq={normal:ZK,gfm:$K,breaks:eq,pedantic:QK},rq={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},iq=e=>rq[e];function aq(e,t){if(t){if(tK.escapeTest.test(e))return e.replace(tK.escapeReplace,iq)}else if(tK.escapeTestNoEncode.test(e))return e.replace(tK.escapeReplaceNoEncode,iq);return e}function oq(e){try{e=encodeURI(e).replace(tK.percentDecode,`%`)}catch{return null}return e}function sq(e,t){let n=e.replace(tK.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(tK.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(tK.slashPipe,`|`);return n}function cq(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 lq(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 uq(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 dq(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 nq=class{options;rules;lexer;constructor(e){this.options=e||VG}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:QK(e,`
212
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=tq(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=QK(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:QK(t[0],`
213
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=QK(t[0],`
211
+ `)}var fq=class{options;rules;lexer;constructor(e){this.options=e||ZG}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:cq(e,`
212
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=dq(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=cq(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:cq(t[0],`
213
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=cq(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=ZK(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(ZK(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=QK(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=$K(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)),eq(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 eq(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}}}},rq=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||VG,this.options.tokenizer=this.options.tokenizer||new nq,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:GG,block:GK.normal,inline:KK.normal};this.options.pedantic?(t.block=GK.pedantic,t.inline=KK.pedantic):this.options.gfm&&(t.block=GK.gfm,this.options.breaks?t.inline=KK.breaks:t.inline=KK.gfm),this.tokenizer.rules=t}static get rules(){return{block:GK,inline:KK}}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(GG.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(GG.tabCharGlobal,` `).replace(GG.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=sq(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(sq(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=cq(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=lq(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)),uq(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 uq(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}}}},pq=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||ZG,this.options.tokenizer=this.options.tokenizer||new fq,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:tK,block:tq.normal,inline:nq.normal};this.options.pedantic?(t.block=tq.pedantic,t.inline=nq.pedantic):this.options.gfm&&(t.block=tq.gfm,this.options.breaks?t.inline=nq.breaks:t.inline=nq.gfm),this.tokenizer.rules=t}static get rules(){return{block:tq,inline:nq}}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(tK.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(tK.tabCharGlobal,` `).replace(tK.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}},iq=class{options;parser;constructor(e){this.options=e||VG}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(GG.notSpaceStart)?.[0],i=e.replace(GG.endingNewline,``)+`
244
- `;return r?`<pre><code class="language-`+YK(r)+`">`+(n?i:YK(i,!0))+`</code></pre>
245
- `:`<pre><code>`+(n?i:YK(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}},mq=class{options;parser;constructor(e){this.options=e||ZG}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(tK.notSpaceStart)?.[0],i=e.replace(tK.endingNewline,``)+`
244
+ `;return r?`<pre><code class="language-`+aq(r)+`">`+(n?i:aq(i,!0))+`</code></pre>
245
+ `:`<pre><code>`+(n?i:aq(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+` `+YK(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+` `+aq(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>${YK(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=XK(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+YK(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=XK(e);if(i===null)return YK(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${YK(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:YK(e.text)}},aq=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``}},oq=class e{options;renderer;textRenderer;constructor(e){this.options=e||VG,this.options.renderer=this.options.renderer||new iq,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new aq}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}},sq=class{options;block;constructor(e){this.options=e||VG}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?rq.lex:rq.lexInline}provideParser(){return this.block?oq.parse:oq.parseInline}},cq=class{defaults=BG();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=oq;Renderer=iq;TextRenderer=aq;Lexer=rq;Tokenizer=nq;Hooks=sq;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 iq(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 nq(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 sq;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];sq.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 rq.lex(e,t??this.defaults)}parser(e,t){return oq.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?rq.lex:rq.lexInline,s=i.hooks?i.hooks.provideParser():e?oq.parse:oq.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>`+YK(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},lq=new cq;function uq(e,t){return lq.parse(e,t)}uq.options=uq.setOptions=function(e){return lq.setOptions(e),uq.defaults=lq.defaults,HG(uq.defaults),uq},uq.getDefaults=BG,uq.defaults=VG,uq.use=function(...e){return lq.use(...e),uq.defaults=lq.defaults,HG(uq.defaults),uq},uq.walkTokens=function(e,t){return lq.walkTokens(e,t)},uq.parseInline=lq.parseInline,uq.Parser=oq,uq.parser=oq.parse,uq.Renderer=iq,uq.TextRenderer=aq,uq.Lexer=rq,uq.lexer=rq.lex,uq.Tokenizer=nq,uq.Hooks=sq,uq.parse=uq,uq.options,uq.setOptions,uq.use,uq.walkTokens,uq.parseInline,oq.parse,rq.lex;function dq({header:e,caption:t,children:n}){return(0,L.jsxs)(`figure`,{className:fq,children:[e,(0,L.jsx)(`div`,{className:pq,children:n}),t]})}var fq=`frizz-bash max-w-full`,pq=`flex justify-center bg-panel-2 p-1.5`,mq=`block max-h-[420px] max-w-full w-auto rounded-md object-contain`,hq=/^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,gq={del(e){let t=hq.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}},_q=/^:?-+:?$/,vq=/^ {0,3}$/,yq=/^[ \t]*$/;function bq(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||!vq.test(t[0])||!yq.test(t.at(-1))?null:t.slice(1,-1).map(e=>e.trim())}function xq(e){let t=[],n=0;for(let r of e.split(`
264
- `)){let e=bq(r);if(!e)break;if(e.every(e=>_q.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 Sq={name:`headerlessTable`,level:`block`,start(e){let t=0;for(let n of e.split(`
265
- `)){if(n.includes(`|`)&&xq(e.slice(t)))return t;t+=n.length+1}},tokenizer(e){let t=xq(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`}},Cq=/^\[([ xX/\-?])\](?:[ \t]+|[ \t]*$)/,wq={" ":{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`}},Tq={name:`frizzTaskStatus`,level:`inline`,tokenizer(){},renderer(e){let{status:t}=e,n=wq[t];return`<span class="md-task${n.className?` ${n.className}`:``}" title="${n.label}"></span> `}},Eq={name:`frizzTaskText`,level:`inline`,tokenizer(){},renderer(e){return`<span class="md-task-text">${this.parser.parseInline(e.tokens)}</span>`}};function Dq(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=Cq.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 Oq={breaks:!0,extensions:[Sq,Tq,Eq],tokenizer:gq,hooks:{processAllTokens(e){return wf(e),e}},walkTokens(e){e.type===`list_item`&&Dq(e)},renderer:{code:({text:e,lang:t})=>eC(e,t)}},kq=new cq(Oq),Aq=new cq({...Oq,breaks:!1});function jq(e,t){return e.trim()?zq((t?.document?Aq:kq).parse(e,{async:!1}),{block:!0,baseDir:t?.baseDir,homeDir:t?.homeDir}):``}function Mq(e,t){if(!e.trim())return``;let{baseDir:n,homeDir:r}=t??{};return zq(kq.parseInline(e,{async:!1}),{baseDir:n,homeDir:r})}function Nq(e){let t=e.match(/^?---\r?\n[\s\S]*?\r?\n---\r?\n?/);return t?e.slice(t[0].length):e}var Pq=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(`.`)),Fq=new Set([`href`,`src`,`alt`,`title`,`type`,`class`,`data-local-path`,`data-local-image`]),Iq=RegExp(`^(?:hljs(?:-[a-z0-9_-]+)?|language-[a-z0-9-]+|md-task(?:-(?:checked|in-progress|cancelled|blocked|text))?|${YS})$`),Lq={ol:{start:/^\d{1,9}$/},th:{align:/^(?:left|center|right)$/},td:{align:/^(?:left|center|right)$/}},Rq=new Set([`script`,`style`,`textarea`,`title`,`xmp`,`iframe`,`frame`,`frameset`,`object`,`embed`,`applet`,`noscript`,`template`,`svg`,`math`]);function zq(e,{block:t=!1,baseDir:n,homeDir:r}={}){let i=document.createElement(`template`);return i.innerHTML=e,Bq(i.content,{block:t,baseDir:n,homeDir:r}),i.innerHTML}function Bq(e,t){let{block:n}=t;for(let r of Array.from(e.children)){let e=r.tagName.toLowerCase();if(!Pq.has(e)){Rq.has(e)?r.remove():Uq(r,t);continue}if((e===`a`||e===`img`)&&Vq(r,e===`a`?`href`:`src`,t),e===`a`){let e=ef(r.getAttribute(`href`));e&&r.setAttribute(`href`,e);let t=pC(r.getAttribute(`href`));if(t){let e=gC(t);if(e)r.setAttribute(`href`,e),r.setAttribute(`title`,t.display),r.setAttribute(`data-local-path`,t.filePath),r.setAttribute(`data-local-image`,`true`);else{let e=t.filePath&&vC(t.filePath),n=document.createElement(`button`);for(n.type=`button`,n.className=`local-file-action`,n.title=e?`Read ${t.display}`:t.display,t.filePath&&n.setAttribute(`data-local-path`,t.filePath);r.firstChild;)n.append(r.firstChild);r.replaceWith(n);continue}}}if(e===`img`){let e=pC(r.getAttribute(`src`)),t=e&&gC(e);if(!t){r.remove();continue}r.setAttribute(`src`,t),r.setAttribute(`title`,e.display),r.setAttribute(`data-local-path`,e.filePath),r.setAttribute(`data-local-image`,`true`),r.getAttribute(`alt`)||r.setAttribute(`alt`,e.display),n&&Hq(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=>Iq.test(e));e.length>0?r.setAttribute(`class`,e.join(` `)):r.removeAttribute(t.name);continue}let i=Lq[e]?.[n];if(i){i.test(t.value)||r.removeAttribute(t.name);continue}if(!Fq.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=hf(r.getAttribute(`href`));e&&r.setAttribute(`data-gh-ref`,e)}Bq(r,t)}}function Vq(e,t,{baseDir:n,homeDir:r}){if(!n&&!r)return;let i=yC(e.getAttribute(t),n??``,r);i&&e.setAttribute(t,i)}function Hq(e){let t=e.ownerDocument,n=t.createElement(`span`);n.className=`${fq} md-image-frame`;let r=t.createElement(`span`);r.className=pq,e.replaceWith(n),n.append(r),r.append(e),e.setAttribute(`class`,mq)}function Uq(e,t){let n=e.ownerDocument.createDocumentFragment();for(;e.firstChild;)n.append(e.firstChild);Bq(n,t),e.replaceWith(n)}function Wq(){return(0,I.useSyncExternalStore)(ff,df,df)}function Gq(){return(0,I.useSyncExternalStore)(sp,op,op)}function Kq(e,t){let n=Wq(),r=Gq(),{baseDir:i,asDocument:a}=t??{},o=i??r.dir,s=(0,I.useMemo)(()=>jq(e,{baseDir:o,homeDir:r.home,document:a}),[e,o,r.home,a,n]);return qq(s),s}function qq(e){let t=(0,I.useMemo)(()=>Yf(e),[e]);(0,I.useEffect)(()=>{t.length>0&&Xf(t)},[t])}function Jq(e){let t=Wq(),n=Gq(),r=(0,I.useMemo)(()=>Mq(e,{baseDir:n.dir,homeDir:n.home}),[e,n.dir,n.home,t]);return qq(r),r}var Yq=e=>new Set(e.split(/\s+/).filter(Boolean)),Xq=Yq(`
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>${aq(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=oq(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+aq(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=oq(e);if(i===null)return aq(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${aq(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:aq(e.text)}},hq=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``}},gq=class e{options;renderer;textRenderer;constructor(e){this.options=e||ZG,this.options.renderer=this.options.renderer||new mq,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new hq}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}},_q=class{options;block;constructor(e){this.options=e||ZG}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?pq.lex:pq.lexInline}provideParser(){return this.block?gq.parse:gq.parseInline}},vq=class{defaults=XG();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=gq;Renderer=mq;TextRenderer=hq;Lexer=pq;Tokenizer=fq;Hooks=_q;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 mq(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 fq(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 _q;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];_q.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 pq.lex(e,t??this.defaults)}parser(e,t){return gq.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?pq.lex:pq.lexInline,s=i.hooks?i.hooks.provideParser():e?gq.parse:gq.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>`+aq(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},yq=new vq;function bq(e,t){return yq.parse(e,t)}bq.options=bq.setOptions=function(e){return yq.setOptions(e),bq.defaults=yq.defaults,QG(bq.defaults),bq},bq.getDefaults=XG,bq.defaults=ZG,bq.use=function(...e){return yq.use(...e),bq.defaults=yq.defaults,QG(bq.defaults),bq},bq.walkTokens=function(e,t){return yq.walkTokens(e,t)},bq.parseInline=yq.parseInline,bq.Parser=gq,bq.parser=gq.parse,bq.Renderer=mq,bq.TextRenderer=hq,bq.Lexer=pq,bq.lexer=pq.lex,bq.Tokenizer=fq,bq.Hooks=_q,bq.parse=bq,bq.options,bq.setOptions,bq.use,bq.walkTokens,bq.parseInline,gq.parse,pq.lex;function xq({header:e,caption:t,children:n}){return(0,L.jsxs)(`figure`,{className:Sq,children:[e,(0,L.jsx)(`div`,{className:Cq,children:n}),t]})}var Sq=`frizz-bash max-w-full`,Cq=`flex justify-center bg-panel-2 p-1.5`,wq=`block max-h-[420px] max-w-full w-auto rounded-md object-contain`,Tq=/^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,Eq={del(e){let t=Tq.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}},Dq=/^:?-+:?$/,Oq=/^ {0,3}$/,kq=/^[ \t]*$/;function Aq(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||!Oq.test(t[0])||!kq.test(t.at(-1))?null:t.slice(1,-1).map(e=>e.trim())}function jq(e){let t=[],n=0;for(let r of e.split(`
264
+ `)){let e=Aq(r);if(!e)break;if(e.every(e=>Dq.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 Mq={name:`headerlessTable`,level:`block`,start(e){let t=0;for(let n of e.split(`
265
+ `)){if(n.includes(`|`)&&jq(e.slice(t)))return t;t+=n.length+1}},tokenizer(e){let t=jq(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`}},Nq=/^\[([ xX/\-?])\](?:[ \t]+|[ \t]*$)/,Pq={" ":{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`}},Fq={name:`frizzTaskStatus`,level:`inline`,tokenizer(){},renderer(e){let{status:t}=e,n=Pq[t];return`<span class="md-task${n.className?` ${n.className}`:``}" title="${n.label}"></span> `}},Iq={name:`frizzTaskText`,level:`inline`,tokenizer(){},renderer(e){return`<span class="md-task-text">${this.parser.parseInline(e.tokens)}</span>`}};function Lq(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=Nq.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 Rq={breaks:!0,extensions:[Mq,Fq,Iq],tokenizer:Eq,hooks:{processAllTokens(e){return wf(e),e}},walkTokens(e){e.type===`list_item`&&Lq(e)},renderer:{code:({text:e,lang:t})=>eC(e,t)}},zq=new vq(Rq),Bq=new vq({...Rq,breaks:!1});function Vq(e,t){return e.trim()?Yq((t?.document?Bq:zq).parse(e,{async:!1}),{block:!0,baseDir:t?.baseDir,homeDir:t?.homeDir}):``}function Hq(e,t){if(!e.trim())return``;let{baseDir:n,homeDir:r}=t??{};return Yq(zq.parseInline(e,{async:!1}),{baseDir:n,homeDir:r})}function Uq(e){let t=e.match(/^?---\r?\n[\s\S]*?\r?\n---\r?\n?/);return t?e.slice(t[0].length):e}var Wq=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(`.`)),Gq=new Set([`href`,`src`,`alt`,`title`,`type`,`class`,`data-local-path`,`data-local-image`]),Kq=RegExp(`^(?:hljs(?:-[a-z0-9_-]+)?|language-[a-z0-9-]+|md-task(?:-(?:checked|in-progress|cancelled|blocked|text))?|${YS})$`),qq={ol:{start:/^\d{1,9}$/},th:{align:/^(?:left|center|right)$/},td:{align:/^(?:left|center|right)$/}},Jq=new Set([`script`,`style`,`textarea`,`title`,`xmp`,`iframe`,`frame`,`frameset`,`object`,`embed`,`applet`,`noscript`,`template`,`svg`,`math`]);function Yq(e,{block:t=!1,baseDir:n,homeDir:r}={}){let i=document.createElement(`template`);return i.innerHTML=e,Xq(i.content,{block:t,baseDir:n,homeDir:r}),i.innerHTML}function Xq(e,t){let{block:n}=t;for(let r of Array.from(e.children)){let e=r.tagName.toLowerCase();if(!Wq.has(e)){Jq.has(e)?r.remove():$q(r,t);continue}if((e===`a`||e===`img`)&&Zq(r,e===`a`?`href`:`src`,t),e===`a`){let e=ef(r.getAttribute(`href`));e&&r.setAttribute(`href`,e);let t=pC(r.getAttribute(`href`));if(t){let e=gC(t);if(e)r.setAttribute(`href`,e),r.setAttribute(`title`,t.display),r.setAttribute(`data-local-path`,t.filePath),r.setAttribute(`data-local-image`,`true`);else{let e=t.filePath&&vC(t.filePath),n=document.createElement(`button`);for(n.type=`button`,n.className=`local-file-action`,n.title=e?`Read ${t.display}`:t.display,t.filePath&&n.setAttribute(`data-local-path`,t.filePath);r.firstChild;)n.append(r.firstChild);r.replaceWith(n);continue}}}if(e===`img`){let e=pC(r.getAttribute(`src`)),t=e&&gC(e);if(!t){r.remove();continue}r.setAttribute(`src`,t),r.setAttribute(`title`,e.display),r.setAttribute(`data-local-path`,e.filePath),r.setAttribute(`data-local-image`,`true`),r.getAttribute(`alt`)||r.setAttribute(`alt`,e.display),n&&Qq(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=>Kq.test(e));e.length>0?r.setAttribute(`class`,e.join(` `)):r.removeAttribute(t.name);continue}let i=qq[e]?.[n];if(i){i.test(t.value)||r.removeAttribute(t.name);continue}if(!Gq.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=hf(r.getAttribute(`href`));e&&r.setAttribute(`data-gh-ref`,e)}Xq(r,t)}}function Zq(e,t,{baseDir:n,homeDir:r}){if(!n&&!r)return;let i=yC(e.getAttribute(t),n??``,r);i&&e.setAttribute(t,i)}function Qq(e){let t=e.ownerDocument,n=t.createElement(`span`);n.className=`${Sq} md-image-frame`;let r=t.createElement(`span`);r.className=Cq,e.replaceWith(n),n.append(r),r.append(e),e.setAttribute(`class`,wq)}function $q(e,t){let n=e.ownerDocument.createDocumentFragment();for(;e.firstChild;)n.append(e.firstChild);Xq(n,t),e.replaceWith(n)}function eJ(){return(0,I.useSyncExternalStore)(ff,df,df)}function tJ(){return(0,I.useSyncExternalStore)(sp,op,op)}function nJ(e,t){let n=eJ(),r=tJ(),{baseDir:i,asDocument:a}=t??{},o=i??r.dir,s=(0,I.useMemo)(()=>Vq(e,{baseDir:o,homeDir:r.home,document:a}),[e,o,r.home,a,n]);return rJ(s),s}function rJ(e){let t=(0,I.useMemo)(()=>Yf(e),[e]);(0,I.useEffect)(()=>{t.length>0&&Xf(t)},[t])}function iJ(e){let t=eJ(),n=tJ(),r=(0,I.useMemo)(()=>Hq(e,{baseDir:n.dir,homeDir:n.home}),[e,n.dir,n.home,t]);return rJ(r),r}var aJ=e=>new Set(e.split(/\s+/).filter(Boolean)),oJ=aJ(`
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
- `),Zq=Yq(`
273
+ `),sJ=aJ(`
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
- `),Qq={typescript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:Xq,types:Zq},javascript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:Xq,types:Zq},go:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:Xq,types:Zq},rust:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:Xq,types:Zq},java:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:Xq,types:Zq},c:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:Xq,types:Zq},cpp:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:Xq,types:Zq},css:{line:null,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:Yq(`important media supports keyframes import from to`),types:new Set},json:{line:null,block:null,quotes:[`"`],keywords:Yq(`true false null`),types:new Set},python:{line:`#`,block:null,quotes:[`"`,`'`],keywords:Yq(`
278
+ `),cJ={typescript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:oJ,types:sJ},javascript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:oJ,types:sJ},go:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:oJ,types:sJ},rust:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:oJ,types:sJ},java:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:oJ,types:sJ},c:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:oJ,types:sJ},cpp:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:oJ,types:sJ},css:{line:null,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:aJ(`important media supports keyframes import from to`),types:new Set},json:{line:null,block:null,quotes:[`"`],keywords:aJ(`true false null`),types:new Set},python:{line:`#`,block:null,quotes:[`"`,`'`],keywords:aJ(`
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:Yq(`int float str bool list dict set tuple bytes object`)},shell:{line:`#`,block:null,quotes:[`"`,`'`],keywords:Yq(`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:Yq(`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:Yq(`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}},$q=(e,t)=>{let n=e.indexOf(`
282
- `,t);return n===-1?e.length:n},eJ=(e,t)=>{let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;return e[n]??``},tJ=new Set(Object.keys(Qq)),nJ=e=>/[A-Za-z_$]/.test(e),rJ=e=>/[A-Za-z0-9_$]/.test(e),iJ=e=>e>=`0`&&e<=`9`,aJ=new Set(`{}()[];,.`),oJ=new Set(`+-*/%=<>!&|^~?:@`);function sJ(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,$q(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:aJ(`int float str bool list dict set tuple bytes object`)},shell:{line:`#`,block:null,quotes:[`"`,`'`],keywords:aJ(`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:aJ(`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:aJ(`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}},lJ=(e,t)=>{let n=e.indexOf(`
282
+ `,t);return n===-1?e.length:n},uJ=(e,t)=>{let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;return e[n]??``},dJ=new Set(Object.keys(cJ)),fJ=e=>/[A-Za-z_$]/.test(e),pJ=e=>/[A-Za-z0-9_$]/.test(e),mJ=e=>e>=`0`&&e<=`9`,hJ=new Set(`{}()[];,.`),gJ=new Set(`+-*/%=<>!&|^~?:@`);function _J(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,lJ(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(iJ(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(nJ(n)){let n=a+1;for(;n<r&&rJ(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(eJ(e,n))?`key`:e[n]===`(`?`fn`:`plain`),a=n;continue}if(aJ.has(n)){i(n,`punct`),a++;continue}if(oJ.has(n)){let t=a+1;for(;t<r&&oJ.has(e[t]);)t++;i(e.slice(a,t),`op`),a=t;continue}let o=a+1;for(;o<r&&!nJ(e[o])&&!iJ(e[o])&&!t.quotes.includes(e[o])&&!aJ.has(e[o])&&!oJ.has(e[o])&&!(t.line&&e.startsWith(t.line,o));)o++;i(e.slice(a,o),`plain`),a=o}return n}function cJ(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 lJ(e,t){if(e===``)return[];let n=Qq[t];return n?cJ(sJ(e,n)):e.split(`
287
- `).map(e=>e?[{text:e,kind:`plain`}]:[])}var uJ={".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`},dJ={Dockerfile:`shell`,Makefile:`shell`,".gitignore":`shell`,".env":`shell`,".bashrc":`shell`,".zshrc":`shell`};function fJ(e){let t=_p(e),n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=dJ[t]??uJ[r]??`text`;return tJ.has(i)?i:`text`}function pJ(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 mJ(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(...pJ(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 hJ=3,gJ=e=>e===``?[]:e.split(`
288
- `);function _J(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 vJ(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]-hJ),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+hJ),!(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-hJ)))}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 yJ(e,t,n){let r=fJ(n),i=lJ(e,r),a=lJ(t,r),o=gJ(e),s=gJ(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=mJ(o,s).map(e=>_J(e,i,a)),u=l.filter(e=>e.type===`add`).length,d=l.filter(e=>e.type===`del`).length,{hunks:f,collapsedAfter:p}=vJ(l);return{file:n,lang:r,status:c,hunks:f,collapsedAfter:p,additions:u,deletions:d}}function bJ(){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(),SJ(n,t.dataset.localImage===`true`))};document.addEventListener(`click`,e);let t=xJ();return document.addEventListener(`error`,t,!0),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`error`,t,!0)}}function xJ(){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 SJ(e,t=!1){if(!t&&vC(e)){Qp(e);return}if(!t&&X.splitFileViewer){em(e);return}CJ(e,t)}async function CJ(e,t){try{let n=await Y.openLocalFile({path:e,...t?{image:!0}:{}});n.action===`copy`&&(await bV(n.path),Z(`Copied local path`))}catch(e){Z(`Could not open local file: ${e.message.slice(0,100)}`)}}var wJ=`a, button, input, select, textarea, summary, label, [role="button"], [role="link"]`;function TJ(e){let t=e;return typeof t?.closest==`function`&&t.closest(wJ)!=null}function EJ({children:e,className:t,controls:n,expanded:r,label:i,meta:a,onToggle:o,chevronSize:s=12}){function c(e){if(TJ(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)(Rm,{"aria-hidden":!0,size:s,className:`relative -top-px shrink-0 transition-transform ${r?`rotate-90`:``}`}))))}function DJ({path:e,className:t=``,children:n}){return(0,L.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),SJ(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 OJ({edits:e,meta:t}){let{compactDiffs:n}=en(RT),r=(0,I.useId)(),i=e[0].file,a=(0,I.useMemo)(()=>e.map(e=>yJ(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)(EJ,{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)(DJ,{path:i,className:`text-inherit no-underline`,children:_p(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)(kJ,{hunks:e.hunks,collapsedAfter:e.collapsedAfter})},t))})]})}function kJ({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)(AJ,{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)(AJ,{n:t},`safter`)),(0,L.jsx)(L.Fragment,{children:r})}function AJ({n:e}){return(0,L.jsxs)(`div`,{className:`frizz-diff-sep`,children:[e,` unchanged line`,e===1?``:`s`]})}function jJ(e){return(0,I.useMemo)(()=>({__html:e}),[e])}var MJ=/^[\w.@+-]+\.[a-z][a-z0-9]{0,7}$/i,NJ=/^(?:[A-Za-z]:\\|\\\\)?[\w.@+~-]+(?:\\[\w.@+~-]+)*(?::\d+(?::\d+)?)?$/;function PJ(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(`\\`)&&NJ.test(t)?!0:MJ.test(t)}var FJ=new Map,IJ=new Set,LJ=0,RJ=new Set,zJ=e=>(RJ.add(e),()=>{RJ.delete(e)}),BJ=()=>LJ,VJ=128;async function HJ(e){let t=[...new Set(e)].filter(e=>!FJ.has(e)&&!IJ.has(e));if(!t.length)return;for(let e of t)IJ.add(e);let n=[];for(let e=0;e<t.length;e+=VJ)n.push(t.slice(e,e+VJ));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)FJ.has(t.input)||(FJ.set(t.input,t.path),i=!0);for(let e of t)IJ.delete(e);if(i){LJ+=1;for(let e of RJ)e()}}function UJ(e,t){e.setAttribute(`data-local-path`,t),e.setAttribute(`title`,`Open ${t}`),e.classList.add(`local-file-code`)}function WJ(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(!PJ(t))continue;let r=FJ.get(t);r===void 0?n.push(t):r&&UJ(e,r)}n.length&&HJ(n)},[e,t,(0,I.useSyncExternalStore)(zJ,BJ,BJ)])}function GJ({as:e=`div`,className:t,html:n}){let r=jJ(n),i=(0,I.useRef)(null);return WJ(i,n),(0,I.createElement)(e,{ref:i,className:t,dangerouslySetInnerHTML:r})}function KJ({text:e,language:t,className:n=``,...r}){let i=jJ((0,I.useMemo)(()=>cC(e,t),[e,t]));return(0,L.jsx)(`pre`,{...r,className:`hljs ${n}`,dangerouslySetInnerHTML:i})}var qJ=`Todos`,JJ={pending:{Icon:Rh,className:`text-muted/50`},in_progress:{Icon:Ih,className:`text-accent`},completed:{Icon:Fh,className:`text-muted/75`}},YJ={pending:`text-fg/75`,in_progress:`text-fg`,completed:`text-muted/70`};function XJ({status:e}){let{Icon:t,className:n}=JJ[e];return(0,L.jsx)(t,{"aria-hidden":`true`,size:`1em`,strokeWidth:2,className:`frizz-todo-mark shrink-0 ${n}`})}var ZJ={pending:`to do`,in_progress:`in progress`,completed:`done`};function QJ({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`} `:``}${qJ}${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:qJ}),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)(XJ,{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)(Rm,{"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)(XJ,{status:e.status}),(0,L.jsx)(`span`,{className:`min-w-0 ${YJ[e.status]}`,children:e.text}),(0,L.jsx)(`span`,{className:`sr-only`,children:` — ${ZJ[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 $J=/^```question(?:[ \t]+([A-Za-z][^\r\n]*?))?[ \t]*\r?\n(?:([\s\S]*?)\r?\n)??```[ \t]*$/gm,eY=/^qst_[a-z0-9]+$/;function tY(e){let t=(e??``).toLowerCase().split(/\s+/).filter(Boolean),n=e=>t.includes(e),r=t.find(e=>eY.test(e));return{kind:n(`multi`)?`multi`:`question`,danger:n(`danger`),...r?{registeredId:r}:{}}}function nY(e){let t=[],n=Ac(e),r=0;$J.lastIndex=0;for(let i=$J.exec(e);i!==null;i=$J.exec(e)){if(n(i.index)){$J.lastIndex=i.index+1;continue}let{kind:a,danger:o,registeredId:s}=tY(i[1]);if(i[2]===void 0&&!s){$J.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}),rY(t)}function rY(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=hY(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=vY(i.options[i.options.length-1]);if(!/^([A-Z]|\d+)$/.test(e))continue;a=e}let o=iY(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(mJ(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(fJ(n)){let n=a+1;for(;n<r&&pJ(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(uJ(e,n))?`key`:e[n]===`(`?`fn`:`plain`),a=n;continue}if(hJ.has(n)){i(n,`punct`),a++;continue}if(gJ.has(n)){let t=a+1;for(;t<r&&gJ.has(e[t]);)t++;i(e.slice(a,t),`op`),a=t;continue}let o=a+1;for(;o<r&&!fJ(e[o])&&!mJ(e[o])&&!t.quotes.includes(e[o])&&!hJ.has(e[o])&&!gJ.has(e[o])&&!(t.line&&e.startsWith(t.line,o));)o++;i(e.slice(a,o),`plain`),a=o}return n}function vJ(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 yJ(e,t){if(e===``)return[];let n=cJ[t];return n?vJ(_J(e,n)):e.split(`
287
+ `).map(e=>e?[{text:e,kind:`plain`}]:[])}var bJ={".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`},xJ={Dockerfile:`shell`,Makefile:`shell`,".gitignore":`shell`,".env":`shell`,".bashrc":`shell`,".zshrc":`shell`};function SJ(e){let t=_p(e),n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=xJ[t]??bJ[r]??`text`;return dJ.has(i)?i:`text`}function CJ(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 wJ(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(...CJ(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 TJ=3,EJ=e=>e===``?[]:e.split(`
288
+ `);function DJ(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 OJ(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]-TJ),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+TJ),!(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-TJ)))}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 kJ(e,t,n){let r=SJ(n),i=yJ(e,r),a=yJ(t,r),o=EJ(e),s=EJ(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=wJ(o,s).map(e=>DJ(e,i,a)),u=l.filter(e=>e.type===`add`).length,d=l.filter(e=>e.type===`del`).length,{hunks:f,collapsedAfter:p}=OJ(l);return{file:n,lang:r,status:c,hunks:f,collapsedAfter:p,additions:u,deletions:d}}function AJ(){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(),MJ(n,t.dataset.localImage===`true`))};document.addEventListener(`click`,e);let t=jJ();return document.addEventListener(`error`,t,!0),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`error`,t,!0)}}function jJ(){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 MJ(e,t=!1){if(!t&&vC(e)){Qp(e);return}if(!t&&X.splitFileViewer){em(e);return}NJ(e,t)}async function NJ(e,t){try{let n=await Y.openLocalFile({path:e,...t?{image:!0}:{}});n.action===`copy`&&(await AV(n.path),Z(`Copied local path`))}catch(e){Z(`Could not open local file: ${e.message.slice(0,100)}`)}}var PJ=`a, button, input, select, textarea, summary, label, [role="button"], [role="link"]`;function FJ(e){let t=e;return typeof t?.closest==`function`&&t.closest(PJ)!=null}function IJ({children:e,className:t,controls:n,expanded:r,label:i,meta:a,onToggle:o,chevronSize:s=12}){function c(e){if(FJ(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)(Rm,{"aria-hidden":!0,size:s,className:`relative -top-px shrink-0 transition-transform ${r?`rotate-90`:``}`}))))}function LJ({path:e,className:t=``,children:n}){return(0,L.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),MJ(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 RJ({edits:e,meta:t}){let{compactDiffs:n}=en(JT),r=(0,I.useId)(),i=e[0].file,a=(0,I.useMemo)(()=>e.map(e=>kJ(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)(IJ,{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)(LJ,{path:i,className:`text-inherit no-underline`,children:_p(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)(zJ,{hunks:e.hunks,collapsedAfter:e.collapsedAfter})},t))})]})}function zJ({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)(BJ,{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)(BJ,{n:t},`safter`)),(0,L.jsx)(L.Fragment,{children:r})}function BJ({n:e}){return(0,L.jsxs)(`div`,{className:`frizz-diff-sep`,children:[e,` unchanged line`,e===1?``:`s`]})}function VJ(e){return(0,I.useMemo)(()=>({__html:e}),[e])}var HJ=/^[\w.@+-]+\.[a-z][a-z0-9]{0,7}$/i,UJ=/^(?:[A-Za-z]:\\|\\\\)?[\w.@+~-]+(?:\\[\w.@+~-]+)*(?::\d+(?::\d+)?)?$/;function WJ(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(`\\`)&&UJ.test(t)?!0:HJ.test(t)}var GJ=new Map,KJ=new Set,qJ=0,JJ=new Set,YJ=e=>(JJ.add(e),()=>{JJ.delete(e)}),XJ=()=>qJ,ZJ=128;async function QJ(e){let t=[...new Set(e)].filter(e=>!GJ.has(e)&&!KJ.has(e));if(!t.length)return;for(let e of t)KJ.add(e);let n=[];for(let e=0;e<t.length;e+=ZJ)n.push(t.slice(e,e+ZJ));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)GJ.has(t.input)||(GJ.set(t.input,t.path),i=!0);for(let e of t)KJ.delete(e);if(i){qJ+=1;for(let e of JJ)e()}}function $J(e,t){e.setAttribute(`data-local-path`,t),e.setAttribute(`title`,`Open ${t}`),e.classList.add(`local-file-code`)}function eY(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(!WJ(t))continue;let r=GJ.get(t);r===void 0?n.push(t):r&&$J(e,r)}n.length&&QJ(n)},[e,t,(0,I.useSyncExternalStore)(YJ,XJ,XJ)])}function tY({as:e=`div`,className:t,html:n}){let r=VJ(n),i=(0,I.useRef)(null);return eY(i,n),(0,I.createElement)(e,{ref:i,className:t,dangerouslySetInnerHTML:r})}function nY({text:e,language:t,className:n=``,...r}){let i=VJ((0,I.useMemo)(()=>cC(e,t),[e,t]));return(0,L.jsx)(`pre`,{...r,className:`hljs ${n}`,dangerouslySetInnerHTML:i})}var rY=`Todos`,iY={pending:{Icon:Rh,className:`text-muted/50`},in_progress:{Icon:Ih,className:`text-accent`},completed:{Icon:Fh,className:`text-muted/75`}},aY={pending:`text-fg/75`,in_progress:`text-fg`,completed:`text-muted/70`};function oY({status:e}){let{Icon:t,className:n}=iY[e];return(0,L.jsx)(t,{"aria-hidden":`true`,size:`1em`,strokeWidth:2,className:`frizz-todo-mark shrink-0 ${n}`})}var sY={pending:`to do`,in_progress:`in progress`,completed:`done`};function cY({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`} `:``}${rY}${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:rY}),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)(oY,{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)(Rm,{"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)(oY,{status:e.status}),(0,L.jsx)(`span`,{className:`min-w-0 ${aY[e.status]}`,children:e.text}),(0,L.jsx)(`span`,{className:`sr-only`,children:` — ${sY[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 lY=/^```question(?:[ \t]+([A-Za-z][^\r\n]*?))?[ \t]*\r?\n(?:([\s\S]*?)\r?\n)??```[ \t]*$/gm,uY=/^qst_[a-z0-9]+$/;function dY(e){let t=(e??``).toLowerCase().split(/\s+/).filter(Boolean),n=e=>t.includes(e),r=t.find(e=>uY.test(e));return{kind:n(`multi`)?`multi`:`question`,danger:n(`danger`),...r?{registeredId:r}:{}}}function fY(e){let t=[],n=Ac(e),r=0;lY.lastIndex=0;for(let i=lY.exec(e);i!==null;i=lY.exec(e)){if(n(i.index)){lY.lastIndex=i.index+1;continue}let{kind:a,danger:o,registeredId:s}=dY(i[1]);if(i[2]===void 0&&!s){lY.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}),pY(t)}function pY(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=TY(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=OY(i.options[i.options.length-1]);if(!/^([A-Z]|\d+)$/.test(e))continue;a=e}let o=mY(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 iY(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||!oY.test(n[r]))return null;let i=lY(n[r]);if(t===null?!dY(i):!uY(t,i))return null;let a=r,o=i;for(let e=r+1;e<n.length;e++){let t=n[e];if(oY.test(t)){if(!uY(o,lY(t)))break;o=lY(t),a=e;continue}if(t.trim()===``)continue;if(sY.test(t)){a=e;break}let r=n.findIndex((t,n)=>n>e&&oY.test(t));if(r===-1||!uY(o,lY(n[r])))break}let s=n.slice(r,a+1);return s.filter(e=>oY.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 mY(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||!gY.test(n[r]))return null;let i=yY(n[r]);if(t===null?!xY(i):!bY(t,i))return null;let a=r,o=i;for(let e=r+1;e<n.length;e++){let t=n[e];if(gY.test(t)){if(!bY(o,yY(t)))break;o=yY(t),a=e;continue}if(t.trim()===``)continue;if(_Y.test(t)){a=e;break}let r=n.findIndex((t,n)=>n>e&&gY.test(t));if(r===-1||!bY(o,yY(n[r])))break}let s=n.slice(r,a+1);return s.filter(e=>gY.test(e)).length<(t===null?2:1)?null:{run:s.join(`
292
292
  `),rest:n.slice(a+1).join(`
293
- `)}}function aY(e){return e.includes("```question")&&nY(e).some(e=>e.kind===`question`)}var oY=/^\s*(?:[-*+]\s+)?([A-Z]|\d+)[.)]\s+\S/,sY=/^\s*recommendation\b/i;function cY(e){return e.trim().replace(/^[-*+]\s+/,``)}function lY(e){return cY(e).match(/^([A-Za-z]|\d+)[.)]/)?.[1].toUpperCase()??``}function uY(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 dY=e=>e===`A`||e===`1`,fY=/(^|[^a-z])recommended([^a-z]|$)/i;function pY(e){return e.replace(/\s{2,}/g,` `).trim()}function mY(e){if(!fY.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:pY(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:pY(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:pY(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=pY((i[1]??``)+e.slice(i[0].length));if(t)return{label:t,recommended:!0}}return{label:e,recommended:!1}}function hY(e,t,n=!1){let r=e.split(`
294
- `).map(e=>e.replace(/\r$/,``)),i=e=>r.findIndex((t,n)=>n>e&&oY.test(t)),a=e=>{let t=[];for(let n=e;n<r.length;n++){if(oY.test(r[n])){t.push(n);continue}if(t.length===0||r[n].trim()===``)continue;if(sY.test(r[n]))break;let e=i(n);if(e===-1||!uY(lY(r[t[t.length-1]]),lY(r[e])))break}return t},o=e=>{for(let t=e.length-1;t>0;t--)if(!uY(lY(r[e[t-1]]),lY(r[e[t]])))return dY(lY(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}=mY(cY(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 hY(e){return e.includes("```question")&&fY(e).some(e=>e.kind===`question`)}var gY=/^\s*(?:[-*+]\s+)?([A-Z]|\d+)[.)]\s+\S/,_Y=/^\s*recommendation\b/i;function vY(e){return e.trim().replace(/^[-*+]\s+/,``)}function yY(e){return vY(e).match(/^([A-Za-z]|\d+)[.)]/)?.[1].toUpperCase()??``}function bY(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 xY=e=>e===`A`||e===`1`,SY=/(^|[^a-z])recommended([^a-z]|$)/i;function CY(e){return e.replace(/\s{2,}/g,` `).trim()}function wY(e){if(!SY.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:CY(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:CY(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:CY(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=CY((i[1]??``)+e.slice(i[0].length));if(t)return{label:t,recommended:!0}}return{label:e,recommended:!1}}function TY(e,t,n=!1){let r=e.split(`
294
+ `).map(e=>e.replace(/\r$/,``)),i=e=>r.findIndex((t,n)=>n>e&&gY.test(t)),a=e=>{let t=[];for(let n=e;n<r.length;n++){if(gY.test(r[n])){t.push(n);continue}if(t.length===0||r[n].trim()===``)continue;if(_Y.test(r[n]))break;let e=i(n);if(e===-1||!bY(yY(r[t[t.length-1]]),yY(r[e])))break}return t},o=e=>{for(let t=e.length-1;t>0;t--)if(!bY(yY(r[e[t-1]]),yY(r[e[t]])))return xY(yY(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}=wY(vY(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&&sY.test(e)?g=e.trim():_.push(e);let v=m(_).join(`
297
- `)||void 0;return d===null&&g&&(d=_Y(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 gY=/^[*_`~\s]+/;function _Y(e,t){if(!e)return null;let n=e.replace(/^\s*recommendation\s*:?\s*/i,``).replace(gY,``).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(gY,``).match(/^([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase()===r:!1});return i===-1?null:i}function vY(e){let t=e.match(/^\s*([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase():e.trim()}function yY(e,t){let n=t.text.trim();if(e.kind===`multi`){let r=(t.chosenSet??[]).slice().sort((e,t)=>e-t).map(t=>vY(e.options[t]??``)).filter(Boolean).join(`, `);return r&&n?`${r} — ${n}`:r||n}return t.chosen==null?n:e.options[t.chosen]??``}var bY=/^```(done|awaiting)[ \t]*\r?\n([\s\S]*?)\r?\n```[ \t]*$/gm;function xY(e,t){return t===`done`?{body:e.trim(),hints:[]}:vl(e)}function SY(e){let t=[],n=Ac(e),r=0;bY.lastIndex=0;for(let i=bY.exec(e);i!==null;i=bY.exec(e)){if(n(i.index)){bY.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}=xY(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 CY(e,t){let n=e?.lastFence;return!(!n||n.kind!==`done`||n.registered!==!0||t&&SY(t).some(e=>e.kind===`fence`&&e.fenceKind===`done`))}var wY=`[overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`,TY=`rounded-xl`,EY=`rounded-t-xl`,DY=`rounded-b-[calc(var(--block-radius)_-_1px)]`,OY={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`}},kY=`card-icon-offset`;function AY({icon:e,label:t,head:n=OY.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 ${kY} ${n}`})]})}function jY({children:e}){return(0,L.jsx)(`div`,{className:`card-md mt-1 min-w-0 text-fg/75`,children:e})}function MY({tone:e=`neutral`,icon:t,label:n,aside:r,children:i,className:a=``,...o}){let{border:s,head:c}=OY[e];return(0,L.jsxs)(`div`,{...o,className:`min-w-0 ${TY} border ${s} bg-panel-2 p-4 ${a}`,children:[(0,L.jsx)(AY,{icon:t,label:n,head:c,aside:r}),i!=null&&(0,L.jsx)(jY,{children:i})]})}var NY=`block min-w-0 text-[13px] leading-5 text-fg/75`;function PY({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 FY=`min-w-0 flex-1 text-[11px] leading-snug text-muted/70`,IY=`text-accent underline underline-offset-2 decoration-accent/40 hover:decoration-accent`,LY=`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 RY(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||SY(t).some(e=>e.kind===`fence`)||aY(t))}function zY({thread:e}){return e.crashed===!0?(0,L.jsx)(MY,{"data-rested-card":`stalled`,icon:Bh,label:`Stalled`,children:(0,L.jsx)(`p`,{className:NY,children:`The agent's process exited mid-turn. Retry, in the header, re-sends the last message.`})}):(0,L.jsx)(MY,{"data-rested-card":`bare`,icon:Um,label:`Rested without a sign-off`,children:(0,L.jsx)(`p`,{className:NY,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 BY(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 VY({error:e}){return(0,L.jsxs)(MY,{"data-codex-error":e.code??`unknown`,tone:e.retrying?`caution`:`danger`,icon:Bh,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:`${NY} 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 HY=/^(\d+)\.\s+(.*)$/;function UY(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&&_Y.test(e)?g=e.trim():_.push(e);let v=m(_).join(`
297
+ `)||void 0;return d===null&&g&&(d=DY(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 EY=/^[*_`~\s]+/;function DY(e,t){if(!e)return null;let n=e.replace(/^\s*recommendation\s*:?\s*/i,``).replace(EY,``).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(EY,``).match(/^([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase()===r:!1});return i===-1?null:i}function OY(e){let t=e.match(/^\s*([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase():e.trim()}function kY(e,t){let n=t.text.trim();if(e.kind===`multi`){let r=(t.chosenSet??[]).slice().sort((e,t)=>e-t).map(t=>OY(e.options[t]??``)).filter(Boolean).join(`, `);return r&&n?`${r} — ${n}`:r||n}return t.chosen==null?n:e.options[t.chosen]??``}var AY=/^```(done|awaiting)[ \t]*\r?\n([\s\S]*?)\r?\n```[ \t]*$/gm;function jY(e,t){return t===`done`?{body:e.trim(),hints:[]}:vl(e)}function MY(e){let t=[],n=Ac(e),r=0;AY.lastIndex=0;for(let i=AY.exec(e);i!==null;i=AY.exec(e)){if(n(i.index)){AY.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}=jY(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 NY(e,t){let n=e?.lastFence;return!(!n||n.kind!==`done`||n.registered!==!0||t&&MY(t).some(e=>e.kind===`fence`&&e.fenceKind===`done`))}var PY=`[overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`,FY=`rounded-xl`,IY=`rounded-t-xl`,LY=`rounded-b-[calc(var(--block-radius)_-_1px)]`,RY={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`}},zY=`card-icon-offset`;function BY({icon:e,label:t,head:n=RY.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 ${zY} ${n}`})]})}function VY({children:e}){return(0,L.jsx)(`div`,{className:`card-md mt-1 min-w-0 text-fg/75`,children:e})}function HY({tone:e=`neutral`,icon:t,label:n,aside:r,children:i,className:a=``,...o}){let{border:s,head:c}=RY[e];return(0,L.jsxs)(`div`,{...o,className:`min-w-0 ${FY} border ${s} bg-panel-2 p-4 ${a}`,children:[(0,L.jsx)(BY,{icon:t,label:n,head:c,aside:r}),i!=null&&(0,L.jsx)(VY,{children:i})]})}var UY=`block min-w-0 text-[13px] leading-5 text-fg/75`;function WY({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 GY=`min-w-0 flex-1 text-[11px] leading-snug text-muted/70`,KY=`text-accent underline underline-offset-2 decoration-accent/40 hover:decoration-accent`,qY=`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 JY(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||MY(t).some(e=>e.kind===`fence`)||hY(t))}function YY({thread:e}){return e.crashed===!0?(0,L.jsx)(HY,{"data-rested-card":`stalled`,icon:Bh,label:`Stalled`,children:(0,L.jsx)(`p`,{className:UY,children:`The agent's process exited mid-turn. Retry, in the header, re-sends the last message.`})}):(0,L.jsx)(HY,{"data-rested-card":`bare`,icon:Um,label:`Rested without a sign-off`,children:(0,L.jsx)(`p`,{className:UY,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 XY(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 ZY({error:e}){return(0,L.jsxs)(HY,{"data-codex-error":e.code??`unknown`,tone:e.retrying?`caution`:`danger`,icon:Bh,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:`${UY} 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 QY=/^(\d+)\.\s+(.*)$/;function $Y(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(HY);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 WY=hu,GY=RegExp(`^(\\d+)\\.\\s+(⤷\\s+)?[“"](.*?)[”"]\\s+→\\s+(.*)$`);function KY(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(QY);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 eX=hu,tX=RegExp(`^(\\d+)\\.\\s+(⤷\\s+)?[“"](.*?)[”"]\\s+→\\s+(.*)$`);function nX(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()!==WY)return null;n++;let r=[];for(;n<t.length;n++){let e=t[n],i=e.match(GY);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 qY(e){return KY(e)??UY(e)}var JY=e=>e.displayText??e.text;function YY(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`?!1:qY(JY(e))!==null}var XY=e=>`${e.question??``}${e.answer}`;function ZY(e,t){let n=t?qY(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 qY(JY(t))??[])r.add(XY(e));if(r.size===0)return n;let i=n.filter(e=>!r.has(XY(e)));return i.length>0?i:null}function QY(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=nY(t.text).filter(e=>e.kind===`question`);if(r.length>0)return r}return null}var $Y=e=>e.kind===`question`?hY(e.text,e.questionKind,e.danger).contextMd.trim():``;function eX(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=hY(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 tX(e,t){let n=e[t];if(!n||n.role!==`user`||n.kind===`event`)return null;let r=JY(n),i=KY(r);if(i)return i;let a=UY(r),o=QY(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=$Y(o[e.n-1]);return t?{...e,question:t}:{...e}}):o?eX(r,o):null}function nX(e){return e.map((t,n)=>tX(e,n))}function rX(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function iX(e){for(let t=e.length-1;t>=0;t--){if(e[t].role===`assistant`)return!0;if(rX(e[t]))return!1}return!1}function aX(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(!rX(r))continue;let i=r.at?Date.parse(r.at):NaN;if(!(!Number.isFinite(i)||i<=n))return t-1}return r}function oX(e,t,n={}){if(n.atRest&&t.length>0&&iX(e))return new Map([[e.length-1,[...t]]]);let r=new Map;for(let n of t){let t=aX(e,n.askedAt),i=r.get(t);i?i.push(n):r.set(t,[n])}return r}function sX(e,t){for(let n=t;n>=0;n--)if(cX(e[n]))return n+1;return 0}function cX(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function lX(e,t){let n=new Map;for(let[r,i]of oX(e,t))for(let t=sX(e,r);t<e.length;t++){if(cX(e[t]))continue;let r=n.get(t);r?r.push(...i):n.set(t,[...i])}return n}var uX=12;function dX(e){return e.replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[*_~`]/g,``).replace(/\s+/g,` `).trim().toLowerCase()}function fX(e){let t=e.indexOf(`?`);return t===-1?void 0:e.slice(0,t+1)}function pX(e,t){if(t.length===0)return!1;let n=dX(hY(e,`question`).contextMd);if(n.length<uX)return!1;let r=fX(n);return t.some(({spec:e})=>{let t=dX(e.question);if(t.length<uX)return!1;if(n.includes(t)||t.startsWith(n))return!0;let i=fX(t);return i!==void 0&&i.length>=uX&&n.includes(i)?!0:r!==void 0&&r.length>=uX&&t.includes(r)})}function mX(e,t){if(t.length===0||!e.includes("```question"))return!1;let n=nY(e).filter(e=>e.kind===`question`);return n.length>0&&n.every(e=>e.kind===`question`&&hX(e,t)!==void 0)}function hX(e,t){return e.registeredId?t.find(t=>t.id.toLowerCase()===e.registeredId):t.find(t=>pX(e.text,[t]))}function gX(e){return e.includes("```question")?nY(e).flatMap(e=>e.kind===`question`&&e.registeredId&&e.text.trim()===``?[e.registeredId]:[]):[]}function _X(e,t,n={}){let r=new Map,i=new Set;if(t.length===0)return{placed:r,placedIds:i};let a=new Map,o=t=>{let n=a.get(t);if(n===void 0){let r=e[t];n=r.role===`assistant`&&r.text?gX(r.text):[],a.set(t,n)}return n};for(let[a,s]of oX(e,t,n))for(let t of s){let n=t.id.toLowerCase(),s=-1;for(let t=sX(e,a);t<e.length;t++)cX(e[t])||o(t).includes(n)&&(s=t);if(s<0)continue;let c=r.get(s);c?c.push(t):r.set(s,[t]),i.add(t.id)}return{placed:r,placedIds:i}}function vX({h:e=14}){return(0,L.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0`,style:{height:e}})}function yX({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:xX}),t,(0,L.jsx)(bX,{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 bX({at:e}){let t=NE(e,WE());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:PE(e)??void 0,className:`shrink-0 tabular-nums`,children:t})]}):null}var xX=`shrink-0 translate-y-[0.04em]`;function SX(e,t,n){return e===1?n?`New ${t} from @${n}`:`New ${t}`:`${e} new items`}var CX=`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 wX({steer:e,text:t,sourceId:n,at:r,wrap:i}){let a=Bl(t);if(a)return(0,L.jsx)(MX,{wake:a,sourceId:n,at:r});let o=Hl(t);if(o)return(0,L.jsx)(EX,{wake:o,sourceId:n});let s=Kl(t);if(s)return(0,L.jsx)(AX,{window:s.window,sourceId:n,at:r});let c=Wl(t);if(c)return(0,L.jsx)(jX,{capped:c.capped,to:c.to,sourceId:n,at:r});let l=Xl(t);if(l)return(0,L.jsx)(OX,{wake:l,sourceId:n,at:r});let u=Ql(t);if(u)return(0,L.jsx)(kX,{watchRef:u.ref,sourceId:n,at:r});let d=_u(t);if(d)return(0,L.jsx)(DX,{count:d.count,sourceId:n,at:r});let f=ud(t),p=cd(t),m=e??rd(f||p?t.split(`
301
+ `),n=0;for(;n<t.length&&!t[n].trim();)n++;if(n>=t.length||t[n].trim()!==eX)return null;n++;let r=[];for(;n<t.length;n++){let e=t[n],i=e.match(tX);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 rX(e){return nX(e)??$Y(e)}var iX=e=>e.displayText??e.text;function aX(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`?!1:rX(iX(e))!==null}var oX=e=>`${e.question??``}${e.answer}`;function sX(e,t){let n=t?rX(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 rX(iX(t))??[])r.add(oX(e));if(r.size===0)return n;let i=n.filter(e=>!r.has(oX(e)));return i.length>0?i:null}function cX(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=fY(t.text).filter(e=>e.kind===`question`);if(r.length>0)return r}return null}var lX=e=>e.kind===`question`?TY(e.text,e.questionKind,e.danger).contextMd.trim():``;function uX(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=TY(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 dX(e,t){let n=e[t];if(!n||n.role!==`user`||n.kind===`event`)return null;let r=iX(n),i=nX(r);if(i)return i;let a=$Y(r),o=cX(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=lX(o[e.n-1]);return t?{...e,question:t}:{...e}}):o?uX(r,o):null}function fX(e){return e.map((t,n)=>dX(e,n))}function pX(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function mX(e){for(let t=e.length-1;t>=0;t--){if(e[t].role===`assistant`)return!0;if(pX(e[t]))return!1}return!1}function hX(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(!pX(r))continue;let i=r.at?Date.parse(r.at):NaN;if(!(!Number.isFinite(i)||i<=n))return t-1}return r}function gX(e,t,n={}){if(n.atRest&&t.length>0&&mX(e))return new Map([[e.length-1,[...t]]]);let r=new Map;for(let n of t){let t=hX(e,n.askedAt),i=r.get(t);i?i.push(n):r.set(t,[n])}return r}function _X(e,t){for(let n=t;n>=0;n--)if(vX(e[n]))return n+1;return 0}function vX(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function yX(e,t){let n=new Map;for(let[r,i]of gX(e,t))for(let t=_X(e,r);t<e.length;t++){if(vX(e[t]))continue;let r=n.get(t);r?r.push(...i):n.set(t,[...i])}return n}var bX=12;function xX(e){return e.replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[*_~`]/g,``).replace(/\s+/g,` `).trim().toLowerCase()}function SX(e){let t=e.indexOf(`?`);return t===-1?void 0:e.slice(0,t+1)}function CX(e,t){if(t.length===0)return!1;let n=xX(TY(e,`question`).contextMd);if(n.length<bX)return!1;let r=SX(n);return t.some(({spec:e})=>{let t=xX(e.question);if(t.length<bX)return!1;if(n.includes(t)||t.startsWith(n))return!0;let i=SX(t);return i!==void 0&&i.length>=bX&&n.includes(i)?!0:r!==void 0&&r.length>=bX&&t.includes(r)})}function wX(e,t){if(t.length===0||!e.includes("```question"))return!1;let n=fY(e).filter(e=>e.kind===`question`);return n.length>0&&n.every(e=>e.kind===`question`&&TX(e,t)!==void 0)}function TX(e,t){return e.registeredId?t.find(t=>t.id.toLowerCase()===e.registeredId):t.find(t=>CX(e.text,[t]))}function EX(e){return e.includes("```question")?fY(e).flatMap(e=>e.kind===`question`&&e.registeredId&&e.text.trim()===``?[e.registeredId]:[]):[]}function DX(e,t,n={}){let r=new Map,i=new Set;if(t.length===0)return{placed:r,placedIds:i};let a=new Map,o=t=>{let n=a.get(t);if(n===void 0){let r=e[t];n=r.role===`assistant`&&r.text?EX(r.text):[],a.set(t,n)}return n};for(let[a,s]of gX(e,t,n))for(let t of s){let n=t.id.toLowerCase(),s=-1;for(let t=_X(e,a);t<e.length;t++)vX(e[t])||o(t).includes(n)&&(s=t);if(s<0)continue;let c=r.get(s);c?c.push(t):r.set(s,[t]),i.add(t.id)}return{placed:r,placedIds:i}}function OX({h:e=14}){return(0,L.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0`,style:{height:e}})}function kX({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:jX}),t,(0,L.jsx)(AX,{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 AX({at:e}){let t=UE(e,eD());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:WE(e)??void 0,className:`shrink-0 tabular-nums`,children:t})]}):null}var jX=`shrink-0 translate-y-[0.04em]`;function MX(e,t,n){return e===1?n?`New ${t} from @${n}`:`New ${t}`:`${e} new items`}var NX=`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 PX({steer:e,text:t,sourceId:n,at:r,wrap:i}){let a=Bl(t);if(a)return(0,L.jsx)(HX,{wake:a,sourceId:n,at:r});let o=Hl(t);if(o)return(0,L.jsx)(IX,{wake:o,sourceId:n});let s=Kl(t);if(s)return(0,L.jsx)(BX,{window:s.window,sourceId:n,at:r});let c=Wl(t);if(c)return(0,L.jsx)(VX,{capped:c.capped,to:c.to,sourceId:n,at:r});let l=Xl(t);if(l)return(0,L.jsx)(RX,{wake:l,sourceId:n,at:r});let u=Ql(t);if(u)return(0,L.jsx)(zX,{watchRef:u.ref,sourceId:n,at:r});let d=_u(t);if(d)return(0,L.jsx)(LX,{count:d.count,sourceId:n,at:r});let f=ud(t),p=cd(t),m=e??rd(f||p?t.split(`
302
302
  `).filter(e=>!ud(e)&&!cd(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)(MY,{icon:Mm,label:`Frizz`,children:(0,L.jsx)(TX,{text:Vu(t),wrap:i})})}):f||p?(0,L.jsxs)(`div`,{"data-frizz-wake":!0,className:`flex flex-col`,children:[f&&(0,L.jsx)(NX,{wake:f,sourceId:n,at:r}),p&&(0,L.jsxs)(L.Fragment,{children:[f&&(0,L.jsx)(vX,{}),(0,L.jsx)(PX,{wake:p,sourceId:f?void 0:n,at:r})]}),m&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(vX,{}),(0,L.jsx)(FX,{steer:m,text:t,at:r})]})]}):(0,L.jsx)(FX,{steer:m,text:t,sourceId:n,at:r})}function TX({text:e,wrap:t}){let n=jJ(Kq(e));return(0,L.jsx)(`div`,{className:`md-body [overflow-wrap:anywhere]${t?` ${wY}`:``}`,dangerouslySetInnerHTML:n})}function EX({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)(yX,{icon:Om,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 DX({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)(yX,{icon:_h,sourceId:t,marker:`event`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function OX({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)(yX,{icon:ch,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)(yX,{icon:ch,sourceId:t,marker:`event`,ariaLabel:o,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:o})})}function kX({watchRef:e,sourceId:t,at:n}){let r=rW(e);return(0,L.jsx)(yX,{icon:sh,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:CX,children:e}):e,` `,`expired`]})})}function AX({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)(yX,{icon:ch,sourceId:t,marker:`limit-resume`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function jX({capped:e,to:t,sourceId:n,at:r}){let i=`${e} limit — switched to ${t}`;return(0,L.jsx)(yX,{icon:ch,sourceId:n,marker:`limit-model-switch`,ariaLabel:i,at:r,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:i})})}function MX({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)(yX,{icon:Lh,sourceId:t,marker:`event`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function NX({wake:e,sourceId:t,at:n}){let r=rW(e.ref),i=r?(0,L.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:CX,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)(yX,{icon:sh,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 PX({wake:e,sourceId:t,at:n}){let r=rW(e.ref),i=r?(0,L.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:CX,children:e.ref}):(0,L.jsx)(`span`,{children:e.ref});return(0,L.jsx)(yX,{icon:sh,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 FX({steer:e,text:t,sourceId:n,at:r}){let i=rW(e.ref),a=e.items.length+e.omitted,o=Zu(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`:SX(a,e.items[0]?.label??`item`,s?.actor),u=c?(0,L.jsx)(`a`,{href:c,target:`_blank`,rel:`noreferrer noopener`,className:CX,children:e.ref}):(0,L.jsx)(`span`,{children:e.ref});return(0,L.jsx)(yX,{icon:sh,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 IX({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)(yX,{icon:Ph,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)(yX,{icon:r?zh:kh,sourceId:t,marker:r?`schedule`:`rest`,ariaLabel:i,at:n,children:i})}var LX=/(^|[^\w/.@-])(https?:\/\/[^\s<>`]+|www\.[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:[^\s<>`]*)?)/gi,RX=new Set([`.`,`,`,`:`,`;`,`!`,`?`,`*`,`_`,`~`,`'`,`"`]),zX={")":`(`,"]":`[`,"}":`{`};function BX(e){let t=e;for(;;){let e=t[t.length-1];if(e!==void 0&&RX.has(e)){t=t.slice(0,-1);continue}let n=e===void 0?void 0:zX[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 VX(e,t){if(t===``)return;let n=0;for(let r of bf(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:hf(r.href)}),n=r.start+r.text.length;n<t.length&&e.push({kind:`text`,text:t.slice(n)})}function HX(e){let t=[],n=0;LX.lastIndex=0;for(let r=LX.exec(e);r;r=LX.exec(e)){let[,i,a]=r,o=BX(a);if(/^https?:\/\/$/i.test(o)||o===``)continue;let s=r.index+i.length;LX.lastIndex=s+o.length;let c=/^www\./i.test(o)?`http://${o}`:o;s>n&&VX(t,e.slice(n,s)),t.push({kind:`link`,text:o,href:c,ghRef:hf(c)}),n=s+o.length}return n<e.length&&VX(t,e.slice(n)),t}function UX({text:e}){let t=(0,I.useMemo)(()=>HX(e),[e,Wq()]),n=(0,I.useMemo)(()=>t.flatMap(e=>e.kind===`link`&&e.ghRef?[e.ghRef]:[]),[t]);return(0,I.useEffect)(()=>{n.length>0&&Xf(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 WX({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 ${TY} rounded-br-sm border border-border-strong bg-elevated p-4`,children:[(0,L.jsx)(AY,{icon:mh,label:`Answers`}),(0,L.jsx)(jY,{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)(UX,{text:e.answer})})]})]},t))})})]})})}function GX(e){return e.sourceId??`legacy-${tZ(e.text)}`}function KX(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 qX=e=>nY(e).filter(e=>e.kind===`question`).map(e=>e.kind===`question`?hY(e.text,e.questionKind,e.danger):hY(``,`question`));function JX(){let e=new Set;return(t,n)=>{let r=GX(t);return e.has(r)&&(r=`${r}#${n}`),e.add(r),r}}function YX(e){let t=KX(e),n=JX(),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=qX(a.text);o.length>0&&r.push({idx:i,identity:n(a,i),blocks:o,isLive:i===t})}return r}function XX(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())&&qX(n.text).length>0)return t}}return-1}function ZX(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)(HY,{icon:Mm,label:`Frizz`,children:(0,L.jsx)(FX,{text:Vu(t),wrap:i})})}):f||p?(0,L.jsxs)(`div`,{"data-frizz-wake":!0,className:`flex flex-col`,children:[f&&(0,L.jsx)(UX,{wake:f,sourceId:n,at:r}),p&&(0,L.jsxs)(L.Fragment,{children:[f&&(0,L.jsx)(OX,{}),(0,L.jsx)(WX,{wake:p,sourceId:f?void 0:n,at:r})]}),m&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(OX,{}),(0,L.jsx)(GX,{steer:m,text:t,at:r})]})]}):(0,L.jsx)(GX,{steer:m,text:t,sourceId:n,at:r})}function FX({text:e,wrap:t}){let n=VJ(nJ(e));return(0,L.jsx)(`div`,{className:`md-body [overflow-wrap:anywhere]${t?` ${PY}`:``}`,dangerouslySetInnerHTML:n})}function IX({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)(kX,{icon:Om,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 LX({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)(kX,{icon:_h,sourceId:t,marker:`event`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function RX({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)(kX,{icon:ch,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)(kX,{icon:ch,sourceId:t,marker:`event`,ariaLabel:o,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:o})})}function zX({watchRef:e,sourceId:t,at:n}){let r=pW(e);return(0,L.jsx)(kX,{icon:sh,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:NX,children:e}):e,` `,`expired`]})})}function BX({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)(kX,{icon:ch,sourceId:t,marker:`limit-resume`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function VX({capped:e,to:t,sourceId:n,at:r}){let i=`${e} limit — switched to ${t}`;return(0,L.jsx)(kX,{icon:ch,sourceId:n,marker:`limit-model-switch`,ariaLabel:i,at:r,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:i})})}function HX({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)(kX,{icon:Lh,sourceId:t,marker:`event`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function UX({wake:e,sourceId:t,at:n}){let r=pW(e.ref),i=r?(0,L.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:NX,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)(kX,{icon:sh,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 WX({wake:e,sourceId:t,at:n}){let r=pW(e.ref),i=r?(0,L.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:NX,children:e.ref}):(0,L.jsx)(`span`,{children:e.ref});return(0,L.jsx)(kX,{icon:sh,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 GX({steer:e,text:t,sourceId:n,at:r}){let i=pW(e.ref),a=e.items.length+e.omitted,o=Zu(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`:MX(a,e.items[0]?.label??`item`,s?.actor),u=c?(0,L.jsx)(`a`,{href:c,target:`_blank`,rel:`noreferrer noopener`,className:NX,children:e.ref}):(0,L.jsx)(`span`,{children:e.ref});return(0,L.jsx)(kX,{icon:sh,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 KX({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)(kX,{icon:Ph,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)(kX,{icon:r?zh:kh,sourceId:t,marker:r?`schedule`:`rest`,ariaLabel:i,at:n,children:i})}var qX=/(^|[^\w/.@-])(https?:\/\/[^\s<>`]+|www\.[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:[^\s<>`]*)?)/gi,JX=new Set([`.`,`,`,`:`,`;`,`!`,`?`,`*`,`_`,`~`,`'`,`"`]),YX={")":`(`,"]":`[`,"}":`{`};function XX(e){let t=e;for(;;){let e=t[t.length-1];if(e!==void 0&&JX.has(e)){t=t.slice(0,-1);continue}let n=e===void 0?void 0:YX[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 ZX(e,t){if(t===``)return;let n=0;for(let r of bf(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:hf(r.href)}),n=r.start+r.text.length;n<t.length&&e.push({kind:`text`,text:t.slice(n)})}function QX(e){let t=[],n=0;qX.lastIndex=0;for(let r=qX.exec(e);r;r=qX.exec(e)){let[,i,a]=r,o=XX(a);if(/^https?:\/\/$/i.test(o)||o===``)continue;let s=r.index+i.length;qX.lastIndex=s+o.length;let c=/^www\./i.test(o)?`http://${o}`:o;s>n&&ZX(t,e.slice(n,s)),t.push({kind:`link`,text:o,href:c,ghRef:hf(c)}),n=s+o.length}return n<e.length&&ZX(t,e.slice(n)),t}function $X({text:e}){let t=(0,I.useMemo)(()=>QX(e),[e,eJ()]),n=(0,I.useMemo)(()=>t.flatMap(e=>e.kind===`link`&&e.ghRef?[e.ghRef]:[]),[t]);return(0,I.useEffect)(()=>{n.length>0&&Xf(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 eZ({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 ${FY} rounded-br-sm border border-border-strong bg-elevated p-4`,children:[(0,L.jsx)(BY,{icon:mh,label:`Answers`}),(0,L.jsx)(VY,{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)($X,{text:e.answer})})]})]},t))})})]})})}function tZ(e){return e.sourceId??`legacy-${dZ(e.text)}`}function nZ(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 rZ=e=>fY(e).filter(e=>e.kind===`question`).map(e=>e.kind===`question`?TY(e.text,e.questionKind,e.danger):TY(``,`question`));function iZ(){let e=new Set;return(t,n)=>{let r=tZ(t);return e.has(r)&&(r=`${r}#${n}`),e.add(r),r}}function aZ(e){let t=nZ(e),n=iZ(),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=rZ(a.text);o.length>0&&r.push({idx:i,identity:n(a,i),blocks:o,isLive:i===t})}return r}function oZ(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())&&rZ(n.text).length>0)return t}}return-1}function sZ(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
  `)}`:`${hu}\n${t.map((e,t)=>`${t+1}. “${e.question}” → ${e.answer}`).join(`
306
- `)}`}function QX(e,t,n,r={}){let i=tW(e),[a,o]=(0,I.useState)({}),s=(0,I.useMemo)(()=>YX(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)(()=>XX(t)!==-1,[t]),u=iH(),d=aH(e),f=(0,I.useCallback)((t,n)=>rH.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=sH(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];tH.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)=>yY(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)=>yY(e.blocks[t],_(e.identity,t)),l=n.flatMap(e=>e.blocks.map((t,n)=>({ask:e,bi:n,question:eZ(t),answer:c(e,n)})).filter(e=>e.answer!==``));if(l.length===0)return;let u=n.find(e=>e.isLive),d=ZX({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,tH.get(e)]);C(d,{onOptimistic:()=>{r.forEach(e=>tH.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&&!tH.get(e)&&tH.set(e,t)})}})},[a,s,_,C,p,f]),T=(0,I.useCallback)(e=>{let t=v.get(GX(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)=>yY(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 $X(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 eZ(e){return $X(e.contextMd)||$X(e.options.join(` / `))||`earlier question`}function tZ(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 nZ({raw:e,question:t,questionKind:n,danger:r,interactive:i,wrap:a,aside:o,label:s,settled:c}){let l=(0,I.useMemo)(()=>t??hY(e??``,n??`question`,r),[t,e,n,r]),u=Kq(l.contextMd),d=Kq(l.trailingMd??``),f=l.recommendedIdx,p=Jq(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)(MY,{tone:h?`risk`:`neutral`,icon:h?Bh:void 0,label:s??(m?`Select multiple`:`Question`),aside:o,children:[u&&(0,L.jsx)(`div`,{className:`text-fg`,children:(0,L.jsx)(GJ,{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||SR({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)(rZ,{md:l.optionHeadings[t],wrap:a}),(0,L.jsx)(aZ,{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}SR({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?`${iZ(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)(GJ,{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)(GJ,{className:`md-inline mt-1.5 text-[11px] text-muted/70`,html:p})]})}function rZ({md:e,wrap:t}){let n=Jq(e.split(`
308
- `).join(` `));return(0,L.jsx)(`div`,{className:`mt-1 text-fg`,children:(0,L.jsx)(GJ,{className:`md-body${t?` ${wY}`:``}`,html:n})})}function iZ(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 aZ({label:e,bodyMd:t,wrap:n,selected:r,settledPick:i,disabled:a,multi:o,recommended:s,recTitle:c,onClick:l}){let u=Jq(e),d=Kq(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)(Fm,{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)(GJ,{as:`span`,className:`md-inline`,html:u})]}),t!==void 0&&(0,L.jsx)(GJ,{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 oZ({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,lt.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)(Hh,{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)(nZ,{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 sZ(e){return(0,I.useSyncExternalStore)(e=>Zt(X,e),()=>e?cZ(e)!==`codex`:!1,()=>!1)}function cZ(e){return hm(X.board,e)?.backend}function lZ(e,t,n,r){let i=rH.followUp(e,t,n),a=tH.get(i),o=a?`${r}\n\n${a}`:r;return tH.set(i,o),i}function uZ(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 dZ(e){let t=Ve(),n=iH(),[r,i]=(0,I.useState)(!1);return{unqueue:(0,I.useCallback)(a=>{if(!e||r)return;let o=hm(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}jw(t,e,a.rawText,a.deliveryId),lZ(n,e,o,a.text),uZ(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 fZ(e){return(0,I.useSyncExternalStore)(e=>Zt(X,e),()=>{if(!e)return!1;let t=hm(X.board,e);return t?.backend!==`codex`&&t?.runtime===`running`},()=>!1)}function pZ(e){let[t,n]=(0,I.useState)(!1);return{deliverNow:(0,I.useCallback)(()=>{if(!e||t)return;let r=hm(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 mZ(e){return e.displayText??e.text}function hZ(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 gZ(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&&!YY(n)))return t}return 0}function _Z(e,t){if(e.kind===`event`||e.kind===`reasoning`||e.role!==`user`)return!1;let n=mZ(e).replace(/\r\n?/g,`
309
- `);return(t===void 0?qY(n):t)?!0:!(e.wake||e.peerFrom)}function vZ(e,t){return _Z(e,t)?`bubble`:`prose`}var yZ=`icon-label-nudge`,bZ=new Set([`planning`,`planned`,`active`,`needs-human`,`blocked`]);function xZ(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&&bZ.has(e.status))}var SZ=`sticky top-0 z-10 flex min-w-0 shrink-0 items-center gap-2.5 border-b border-border bg-panel px-3 ${Uh} 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`,CZ=`min-w-0 flex-1 pl-1 max-[640px]:basis-full`,wZ=`flex shrink-0 items-center max-[640px]:w-full max-[640px]:justify-between`;function TZ(e){return e?.trim()?{kind:`profile-error`,message:`Profile controls unavailable: ${e.trim().slice(0,160)}`}:null}function EZ(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`||e.backend===`acp`)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 DZ(e){return e.permissionChangePending===!0||e.permissionPending!==void 0||e.profileChangePending===!0||e.runtimeControlPending===!0}function OZ(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 kZ(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 AZ(e){let t=en(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=st({mutationFn:t=>Y.setThreadProfile({slug:e,model:t.model,...t.effort?{effort:t.effort}:{}})}),i=st({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||DZ(t),s=t.model?.trim(),c=t.effort?.trim(),l=t.backend===`codex`?`codex`:t.backend===`acp`?`acp`:`claude`,u=nt({queryKey:[`acpAgents`],queryFn:()=>Y.acpAgents(),enabled:l===`acp`}),d=l===`acp`?el(s):void 0,f=l===`acp`?tl(s):void 0,p=r.isPending?r.variables:void 0,m=t.profilePendingModel??p?.model,h=t.profilePendingEffort??p?.effort,g=l===`acp`&&p?tl(p.model):void 0,_=n.data?.options??[],{modelSelectable:v}=kZ(_,s,c,t.runtime===`exited`),y=n.data!==void 0,b=u.data?.find(e=>e.id===d)?.label??d,x=[{id:l,label:l===`codex`?`Codex`:`Claude Code`,options:_}],S=TZ(n.isError?n.error.message:void 0),C=t.permissionMode?NV(t.permissionMode):`auto`,w=jV.some(e=>e.value===C)?C:`auto`,T=i.isPending?i.variables:w,E=EZ(t);function D(e){e!==w&&i.mutate(e,{onSuccess:e=>Z(OZ(e.effect,`claude`)),onError:e=>Z(`Permission change failed: ${e.message.slice(0,120)}`)})}function O(e){r.mutate(e,{onSuccess:e=>Z(l===`acp`?e.effect===`next-resume`?`Model saved for the next resume`:`Model applied`: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:[l!==`acp`&&(0,L.jsx)(sV,{groups:x,value:{provider:l,model:s,effort:c},pending:m||h?{provider:l,model:m,effort:h}:void 0,onValueChange:({model:e,effort:t})=>O({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:v?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||!y||!v||n.isError,compact:!0,side:`top`,className:`min-w-0 max-w-[min(72%,20rem)] px-1.5 py-0.5`}),l===`acp`&&d&&(0,L.jsx)(yV,{agentId:d,agentLabel:b??d,modelId:g??f,onValueChange:e=>O({model:Qc(d,e),effort:``}),disabled:o,side:`top`,className:`min-w-0 max-w-[min(72%,20rem)] px-1.5 py-0.5`}),l===`claude`&&(0,L.jsx)(vV,{variant:`readout`,side:`top`,value:T,onValueChange:e=>D(e),options:jV,ariaLabel:`Thread permission mode`,title:E?`${E} — changing permissions restarts this thread's worker process`:T===`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||E!==null,className:`shrink-0`}),m&&h&&(0,L.jsxs)(`span`,{className:`min-w-0 truncate text-[9px] text-muted/50`,children:[`→ `,m,` · `,h,` pending`]})]}),status:S?(0,L.jsx)(`div`,{"data-thread-control-error":``,className:`px-1 pt-1 text-[9.5px] leading-tight text-muted/65`,children:S.message}):null}}var jZ=new Map;function MZ(e){let t=jZ.get(e);if(t)return t;let n=Y.threadSkills({slug:e}).then(e=>e.skills,()=>(jZ.delete(e),[]));return jZ.set(e,n),n}function NZ({slug:e,surface:t,placeholder:n,className:r,id:i,ops:a,submitOverride:o}){let s=en(X),c=s.board?.threads.find(t=>t.id===e),l=iH(),u=rH.followUp(l,e,c?.sessionId),[d,f,p]=oH(u),m=AZ(e),h=tW(e),[g,_]=(0,I.useState)(null),v=(0,I.useMemo)(()=>()=>MZ(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}=tR(d),r=t.filter(e=>sR(n,e.token));r.length!==t.length&&(X.composerContext[e]=r)},[e,d,x]);let C=!o&&c?.runtime===`running`&&c.backend!==`codex`&&c.backend!==`acp`;function w(t=!1){let n=d.trim();if(!n)return;let r=wV(n);if(r){if(p(),c?.backend===`acp`){Z(`An ACP agent signs in through its own CLI — Frizz holds no account for it`);return}let e=c?.backend===`codex`?`codex`:`claude`;r===`login`?_(e):b(e);return}let i=im(e),a=gR(n,i,l),s={onOptimistic:p,onRollback:()=>{tH.get(u)||f(d),am(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)(IR,{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)(EV,{backend:g,onClose:()=>_(null),onAuthed:()=>_(null)}),y&&(0,L.jsx)(DV,{backend:y,onClose:()=>b(null)})]})}function PZ({slug:e,ops:t}){let n=en(X).board?.threads.find(t=>t.id===e);return n?(0,L.jsx)(NZ,{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 FZ({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)(wM,{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:VD,children:(0,L.jsx)(Eh,{size:14,strokeWidth:2})})})}function IZ(e,t){return new Promise(n=>{eW(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 LZ(){return iU(mU().data??null)}function RZ({thread:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return!LZ()||e.kind!==`session`||e.foreign||e.backend===`codex`||e.backend===`acp`||e.runtime===`exited`?null:(0,L.jsx)(wM,{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),IZ(t,e.id).finally(()=>r(!1))},className:`${VD} mx-[2px]`,children:n?(0,L.jsx)(hh,{size:14,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(Oh,{size:14,strokeWidth:2})})})}function zZ({slug:e,label:t=`Exit fullscreen`}){let n=BD(e)??Pw(`/`);function r(e){af(e)&&(e.preventDefault(),zw(n,{viewTransition:!Dp()}))}return(0,L.jsx)(wM,{label:t,children:(0,L.jsx)(`a`,{href:n,"aria-label":t,"data-standalone-return":!0,onMouseDown:e=>e.preventDefault(),onClick:r,className:VD,children:(0,L.jsx)(bh,{size:14})})})}function BZ({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)(HZ,{label:o?`Expand`:`Collapse`,icon:o?Bm:zm,size:13,onClick:a}),(0,L.jsx)(FZ,{thread:e}),(0,L.jsx)(RZ,{thread:e}),r&&(0,L.jsx)(HZ,{label:`Frizz document`,icon:$m,size:14,onClick:r}),t&&(0,L.jsx)(TM,{slug:e.id}),n&&(0,L.jsx)(zZ,{slug:e.id}),d?bE(e)?(0,L.jsx)(VZ,{slug:e.id}):null:(0,L.jsx)(`div`,{className:`ml-1`,children:(0,L.jsx)(mL,{slug:e.id,onDone:i,doneBusy:s,onMutateStart:c,onApplied:l,onFailed:u})})]})}function VZ({slug:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return(0,L.jsx)(wM,{label:`Retry — resume this session where it left off`,children:(0,L.jsxs)(`button`,{onClick:()=>{r(!0),nW(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)(hh,{size:12,className:`animate-spin`}):(0,L.jsx)(Ah,{size:12}),`Retry`]})})}function HZ({label:e,icon:t,size:n,busy:r,...i}){return(0,L.jsx)(wM,{label:e,children:(0,L.jsx)(`button`,{...i,"aria-label":e,onMouseDown:e=>e.preventDefault(),className:VD,children:r?(0,L.jsx)(hh,{size:n,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(t,{size:n,strokeWidth:2})})})}function UZ(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 WZ(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=>ol(e)&&t(e))||e.bgShells?.some(t))}function GZ(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=[KZ(`agent`,`sub-agent`,e.subAgents,e.subAgentCount),KZ(`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 KZ(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 qZ({open:e,onOpenChange:t,title:n,children:r,footer:i,className:a=`w-[640px] max-w-[92vw] max-h-[82vh]`,onOpenAutoFocus:o}){return(0,L.jsx)(bL,{open:e,onOpenChange:t,children:(0,L.jsxs)(EL,{children:[(0,L.jsx)(OL,{className:`overlay-in fixed inset-0 z-[200] bg-black/55 backdrop-blur-[1px]`}),(0,L.jsxs)(ML,{"aria-modal":`true`,onEscapeKeyDown:cz,onOpenAutoFocus:o,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)(LL,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:n}),(0,L.jsx)(VL,{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)(Hh,{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 JZ({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=uE(e),g=en(RT).snoozePreset,_=bT(g),v=ST(g),y=(0,I.useMemo)(()=>TT(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`} · ${DT(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){RT.snoozePreset=e,b(CT(e))}function S(){s(TT(new Date(h??CT(g)))),l(e.snoozePrompt??``),d(``),a(!0)}function C(){let e=ET(o);if(!e.ok){d(e.message);return}let t=c.trim();if(t.length>4e3){d(`Prompt is too long (${t.length}/${Sl})`);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 · ${DT(h)}`:v,onClick:()=>void b(h?null:CT(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)(hh,{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)(lL,{children:[(0,L.jsx)(uL,{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)(Im,{size:12})})}),(0,L.jsxs)(dL,{align:`end`,children:[_T.map(e=>(0,L.jsx)(fL,{onSelect:()=>x(e.value),icon:(0,L.jsx)(Jm,{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)(pL,{}),(0,L.jsx)(fL,{onSelect:S,children:`Custom time & prompt…`}),h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(pL,{}),(0,L.jsx)(fL,{onSelect:()=>void b(null),children:`Wake now`})]})]})]})]}),(0,L.jsx)(qZ,{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)(hh,{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:Sl,placeholder:`e.g. Check whether CI went green and land it if so.`,value:c,onChange:e=>{l(e.target.value),d(``)},onKeyDown:e=>{SR({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 YZ=1.25,XZ=7.5-YZ/2,ZZ=2*Math.PI*XZ;function QZ(e,t){return Math.max(0,Math.min(100,Math.floor(e/t*100)))}function $Z({thread:e}){let t=e.context;if(!t||t.window<=0)return null;let n=QZ(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)(wM,{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:XZ,fill:`none`,stroke:`currentColor`,strokeOpacity:.3,strokeWidth:YZ}),(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:XZ,fill:`none`,stroke:`currentColor`,strokeWidth:YZ,strokeDasharray:`${ZZ*r} ${ZZ}`})]})})})}var eQ={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 tQ({checked:e,onChange:t,disabled:n,label:r,size:i=`sm`,testId:a}){let o=eQ[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 nQ({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 rQ({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),iQ)}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)(rV,{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 ${DR}`,children:(0,L.jsx)(nQ,{size:12,className:o?`text-amber-400/90`:`text-muted/60 hover:text-muted`})})}),t===`preview`?(0,L.jsx)(iV,{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)(aQ,{armed:a})}):(0,L.jsx)(iV,{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)(hQ,{thread:e,armed:a,close:()=>n(`closed`)})})]})}var iQ=260;function aQ({armed:e}){let t=e?.prompt?.trim(),n=e?mQ({stopHook:e.stopHook===!0,heartbeat:e.heartbeat===!0,postCompaction:e.postCompaction===!0,seconds:e.intervalSeconds??cQ}):[];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 oQ=1,sQ=1440,cQ=600;function lQ(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(sQ,Math.max(oQ,n))*60:t}var uQ=null;function dQ(e){return{prompt:e.text.trim(),stopHook:e.stopHook,heartbeat:e.heartbeat,postCompaction:e.postCompaction,seconds:e.seconds}}function fQ(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 pQ(e,t){return!e.archived&&!t}function mQ(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 hQ({thread:e,armed:t,close:n}){let r=pQ(e,t)?Dl:``,i=uQ?.slug===e.id?uQ.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??cQ),h=s||l||d,[g,_]=(0,I.useState)(String(Math.round((i?.seconds??t?.intervalSeconds??cQ)/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??cQ}),b=e=>({text:a,stopHook:s,heartbeat:l,postCompaction:d,seconds:lQ(g,p),...e}),x=(0,I.useRef)(b());x.current=b(),(0,I.useEffect)(()=>()=>{let n=x.current;if(fQ(n,y.current)){uQ?.slug===e.id&&(uQ=null);return}if(n.text.trim()===``&&!t){uQ={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?uQ?.slug===e.id&&(uQ=null):uQ={slug:e.id,draft:t},n});return S.current=n,n}async function w(t){let n=t.text.trim()||null;if(fQ(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={...dQ(t),prompt:n??``};let r=mQ(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(fQ(b(),y.current)||a.trim()===``&&!t){n();return}C(b()).then(e=>{e&&n()})}function E(){let e=lQ(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 ${sD(O.at)}`:`Last sent ${O.how} ${sD(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:wl,onChange:e=>o(e.target.value),onKeyDown:e=>{SR({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)(tQ,{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)(tQ,{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:oQ,max:sQ,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)(tQ,{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 gQ({thread:e,sticky:t=!1,safeArea:n=!1,onArchived:r,onDismissCancel:i,onSnoozed:a}){let o=UZ(e);return o.footer?(0,L.jsxs)(`footer`,{"aria-label":`Thread lifecycle actions`,"data-thread-lifecycle-footer":!0,className:`${t?`z-20`:DY} flex min-h-10 shrink-0 flex-wrap items-center justify-end ${TR} 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 ${TR}`,children:[(0,L.jsx)($Z,{thread:e}),(0,L.jsx)(vQ,{thread:e}),(0,L.jsx)(rQ,{thread:e})]}),o.done?(0,L.jsx)(_Q,{}):(0,L.jsxs)(L.Fragment,{children:[o.snooze&&(0,L.jsx)(JZ,{thread:e,onSnoozed:a}),(0,L.jsx)(yQ,{thread:e,onArchived:r,onDismissCancel:i})]})]}):null}function _Q(){let e=`Marked done — send a message to reopen it`;return(0,L.jsx)(wM,{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)(Fm,{size:12}),`Done`]})})}function vQ({thread:e}){let t=uE(e);if(!t)return null;let n=e.snoozePrompt?.trim(),r=n?`Bumps ${DT(t)}\n${n}`:`Snoozed until ${DT(t)}`;return(0,L.jsx)(wM,{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 ${ER}`,children:(0,L.jsx)(ch,{size:12})})})}function yQ({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||WZ(e))&&xW(e.id),Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:r}).then(r=>{if(r.needsConfirmation){SW(e.id),i&&n?.(),u(r.hold),c(!0),o(!1);return}c(!1),Z(`Done`),i||t?.()}).catch(t=>{SW(e.id),i&&n?.(),Z(`Couldn’t finish: ${t.message.slice(0,80)}`),o(!1)})},f=!!t&&!!n&&WZ(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)(Fm,{size:12,className:i}),`Mark as done`]}),(0,L.jsx)(qZ,{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)(hh,{size:12,className:`animate-spin`}),l?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,L.jsx)(bQ,{hold:l})})]})}function bQ({hold:e}){let t=GZ(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:lD,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 xQ(e,t){let n=e.trim();if(!(!n||n===t.trim()))return n}function SQ(e,t){let n=e.trim();return!n||n===t||n===`Untitled thread`||n===`Spinning up a thread…`?``:n}function CQ(e){return e.kind!==`session`||e.foreign||e.backend===`codex`||e.backend===`acp`||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`}}function wQ({thread:e,hidden:t=!1}){let n=st({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=CQ(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)(wM,{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)(hh,{size:12,className:`animate-spin`}):(0,L.jsx)(jh,{size:12})})})}function TQ({thread:e,className:t=``}){let n=e.id,r=st({mutationFn:e=>Y.renameThread({slug:n,title:e})}),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(``),c=(0,I.useRef)(null);(0,I.useEffect)(()=>{if(!i)return;let e=requestAnimationFrame(()=>{c.current?.focus(),c.current?.select()});return()=>cancelAnimationFrame(e)},[i]),(0,I.useEffect)(()=>{a(!1),s(``)},[n]);let l=e.kind===`session`&&e.foreign!==!0,u=HT(e);function d(){a(!1),s(``)}function f(){let e=xQ(o,u);if(a(!1),!e){s(``);return}r.mutate(e,{onSuccess:()=>{s(``),Z(`Thread renamed`)},onError:t=>{s(e),a(!0),Z(t instanceof Error?t.message:`Could not rename thread`)}})}return(0,L.jsxs)(`div`,{className:`group/thread-title flex min-w-0 items-center gap-2`,children:[i?(0,L.jsx)(`input`,{ref:c,"aria-label":`Thread title`,value:o,maxLength:200,onChange:e=>s(e.target.value),onBlur:f,"data-claims-escape":!0,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),f()):e.key===`Escape`&&(e.preventDefault(),d())},className:`min-w-0 flex-1 -mx-1.5 -my-px rounded-md border border-border bg-elevated px-1.5 py-0 font-semibold text-[15px] text-fg outline-none focus:border-accent ${t}`}):l?(0,L.jsx)(`button`,{type:`button`,title:`Edit title`,"aria-label":`Edit thread title: ${u}`,disabled:r.isPending,onClick:()=>{s(SQ(u,n)),a(!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 ${t}`,children:u}):(0,L.jsx)(`div`,{className:`min-w-0 max-w-full shrink truncate px-0.5 -mx-0.5 font-semibold text-[15px] ${t}`,title:u,children:u}),(0,L.jsx)(wQ,{thread:e,hidden:i})]})}var EQ=new Set([`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]);function DQ(e,t){let n=e.lastIndexOf(t);if(n<=0)return{model:e};let r=e.slice(n+1);return EQ.has(r)?{model:e.slice(0,n),effort:r}:{model:e}}function OQ(e){let t=e?.trim();if(!t)return`Profile unknown`;if(t.startsWith(`frizz:`)){let{model:e,effort:n}=DQ(t.slice(6).replace(/^frizz-/,``),`-`);return n?`${e} › ${n}`:e}let n=t.split(/\s+/),{model:r,effort:i}=DQ(n.at(-1)??t,`/`);if(!i)return t;let a=n.slice(0,-1).join(` `);return`${a?`${a} · `:``}${r} › ${i}`}function kQ(e){return e?.trim()?OQ(e):void 0}function AQ(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 jQ={completed:`finished`,killed:`stopped`,failed:`failed`};function MQ(e){let t=jQ[e.agentStatus??`completed`],n=e.agentElapsedMs===void 0?void 0:iD(e.agentElapsedMs);return{outcome:t,tail:`${t}${n?` · ${n}`:``}`}}var NQ=e=>e===void 0?void 0:$E(e),PQ=e=>{if(e!==void 0)return iD(e)||void 0};function FQ(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=NQ(n);return{label:t===`completed`?void 0:jQ[t],duration:PQ(n),tone:r?`failed`:`muted`,title:`${e?`Stopped`:r?`Failed`:`Ran for`}${e||r?` after`:``} ${i??`an unknown time`}`}}if(r){let e=NQ(i);return{label:void 0,duration:PQ(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=NQ(o);return{label:c?jQ.killed:s?jQ.failed:void 0,duration:PQ(o),tone:s?`failed`:`muted`,title:`${c?`Stopped after`:s?`Failed after`:`Ran for`} ${l??`an unknown time`}`}}var IQ=`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`,LQ=`${dD} -mt-[1em] self-baseline`,RQ=`h-[1em] w-[1em] shrink-0 translate-y-[calc(0.5em_-_0.5cap)] text-muted/45`;function zQ({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:lD,children:`⤷`}),(0,L.jsx)(`span`,{className:LQ,children:(0,L.jsx)(t?Zm:$m,{"aria-hidden":!0,className:RQ})}),(0,L.jsx)(`span`,{"data-link-kind":!0,className:uD,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:IQ,onClick:e=>e.stopPropagation(),children:n},e.id):(0,L.jsx)(`button`,{"data-thread-link":e.id,type:`button`,title:e.target,className:`${IQ} cursor-pointer`,onClick:t=>{t.stopPropagation(),SJ(e.target)},children:n},e.id)})}):null}function BQ({at:e,host:t}){let n=ME(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 VQ({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)(BQ,{at:e,host:t})]})}var HQ=`text-[14px] leading-5 text-muted`,UQ=`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 WQ(e){return`${UQ} ${e?`-mx-[0.208em] rotate-90`:`-mx-[0.333em]`}`}var $=I.createElement;function GQ({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,$(KQ,{label:`Redacted command preview`,text:e.command.preview}),e.command.actions?$(qQ,{actions:e.command.actions}):null,e.capabilities?$(YQ,{capabilities:e.capabilities}):null):e.kind===`file-approval`?$(I.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},$Q(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?$(KQ,{label:`Plain-text diff preview`,text:e.diffPreview}):null,e.changes?$(JQ,{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?$(YQ,{capabilities:e.capabilities}):null)}function KQ({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 qQ({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`},QQ(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,$(KQ,{label:`${QQ(e.kind)} command detail`,text:e.commandPreview})))))}function JQ({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`},$Q(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?$(KQ,{label:`${$Q(e.operation)} plain-text diff`,text:e.diffPreview}):null))))}function YQ({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`},$(XQ,{capability:e})))))}function XQ({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?$(ZQ,{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),$(ZQ,{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`),$(ZQ,{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`),$(ZQ,{label:`Hosts`,values:e.hosts}))}function ZQ({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 QQ(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 $Q(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 e$(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 t$={semantic:`approve`,label:`Approve once`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`},n$={semantic:`approve`,label:`Approve for session`,order:20,tone:`primary`,durable:!0,scope:`Persists for later matching requests in this thread session.`},r$={semantic:`approve`,label:`Grant for turn`,order:10,tone:`primary`,durable:!1,scope:`Applies to this turn only.`},i$={semantic:`approve`,label:`Grant for session`,order:20,tone:`primary`,durable:!0,scope:`Persists until this thread session ends.`},a$={semantic:`deny`,label:`Deny`,order:70,tone:`danger`,durable:!1,scope:`Rejects this request.`},o$={semantic:`decline`,label:`Decline`,order:70,tone:`danger`,durable:!1,scope:`Declines this request.`},s$={semantic:`cancel`,label:`Cancel request`,order:80,tone:`neutral`,durable:!1,scope:`Cancels this pending request.`};function c$(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`?t$:n===`acceptForSession`&&r===`approve`?n$:(n===`decline`||n===`deny`)&&r===`deny`?a$:n===`cancel`&&r===`cancel`?s$:void 0;if(e.kind===`permission-approval`)return n===`grant-turn`&&r===`approve`?r$:n===`grant-session`&&r===`approve`?i$:(n===`deny`||n===`decline`)&&r===`deny`?a$:n===`cancel`&&r===`cancel`?s$: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`?o$:n===`cancel`&&r===`cancel`?s$: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 o$;if(n===`cancel`&&r===`cancel`)return s$}function l$(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=c$(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 u$(e){switch(e){case`claude`:return`Claude`;case`codex`:return`Codex`;case`acp`:return`ACP agent`;case`frizz`:return`Frizz`}}function d$(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 f$(e,t){let n=e.options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t));return n<0?``:String(n)}function p$(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?``:f$(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 m$(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 h$(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=lc(i,a);e?r[i.id]=`Value ${e}.`:n[i.id]=a}}if(Object.keys(r).length>0)return{errors:r};let i=Cc.safeParse(n);return i.success?{errors:r,values:i.data}:{errors:r,formError:`The response is too large or contains invalid values.`}}function g$(e,t){return JSON.stringify([e,t??null])}function _$(e,t){try{let n=new URL(e,t);return n.protocol===`http:`||n.protocol===`https:`?n.toString():null}catch{return null}}function v$(e,t){let n=e.getAttribute(`href`);if(!n)return!1;let r=_$(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 y$(e=()=>location.href){return t=>{if(t.defaultPrevented||t.button!==0)return;let n=x$(t);n&&v$(n,e())}}function b$(){let e=y$();return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)}function x$(e){let t=typeof e.composedPath==`function`?e.composedPath():[];for(let e of t)if(S$(e))return e;let n=e.target?.closest?.(`a[href]`);return S$(n)?n:null}function S$(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 C$(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 w$(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)=>`${C$(t)} ${e.label}`),recommendedIdx:null},...e?{optionFieldId:e.id}:{},optionValues:r.map(e=>e.value),...t?{notesFieldId:t.id}:{}}}function T$(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=w$(r,a);if(!e)return null;n.push(e)}else if(r.input===`text`||r.input===`multiline`){let e=w$(void 0,r);if(!e)return null;n.push(e)}else return null}return n.length>0?n:null}function E$(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)=>`${C$(t)} ${e.label}${e.description?` — ${e.description}`:``}`),recommendedIdx:null},chosenIdxs:n,text:r}}function D$(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 O$(e){let t=e instanceof Error?e.message:`The request could not be updated.`;return t.length>240?`${t.slice(0,239)}…`:t}function k$(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`frizz-response-${Date.now()}-${Math.random().toString(36).slice(2)}`}function A$({thread:e,className:t=``,autoFocusFirst:n=!1}){let r=_w(e),i=yw(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:`${TY} 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:O$(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)(M$,{record:e,autoFocus:n&&t===0},e.id))}):null}function j$({record:e,questions:t,autoFocus:n}){let r=Ve(),i=(0,I.useRef)(null),a=(0,I.useRef)(new Map),o=iH(),s=e$(e.delivery?.effect),c=(0,I.useMemo)(()=>l$(e).find(e=>e.semantic===`answer`),[e]),l=sH(t.flatMap(t=>t.notesFieldId?[rH.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(rH.interaction(o,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId))??``:``})),p=D$(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=st({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),_x(r,t.interaction),r.invalidateQueries({queryKey:hx(e.owner.threadSlug,e.owner.sessionId)}),r.invalidateQueries({queryKey:gx(e.owner.threadSlug,e.owner.sessionId,e.id)})},onError:t=>{vx(r,e),h(O$(t))}}),y=()=>{if(!c||!p||v.isPending||g||!s.actionsEnabled)return;h(void 0);let e=g$(c.id,p),t=a.current.get(e)??k$();a.current.set(e,t),v.mutate({decisionId:c.id,values:p,responseId:t})},b=(t,n)=>{t.notesFieldId&&tH.set(rH.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)(nZ,{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 M$({record:e,autoFocus:t=!1}){let n=(0,I.useMemo)(()=>T$(e),[e]);return n?(0,L.jsx)(j$,{record:e,questions:n,autoFocus:t}):(0,L.jsx)(N$,{record:e,autoFocus:t})}function N$({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=iH(),l=o.filter(e=>!e.secret&&(e.input===`text`||e.input===`multiline`)).map(t=>rH.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.id)),u=sH(l),[d,f]=(0,I.useState)(()=>p$(o)),p=(0,I.useMemo)(()=>{let t={...d};return o.forEach(n=>{if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=rH.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=e$(e.delivery?.effect),D=(0,I.useMemo)(()=>l$(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`&&tH.set(rH.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=st({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(g$(r.decision.id,r.values)),_(void 0),C(void 0),T(!1),x(!0),l.forEach(e=>tH.clear(e)),y(t.waitingForProvider?`Response sent. Waiting for the provider to acknowledge it…`:`Request completed.`),_x(n,t.interaction),n.setQueryData(gx(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t.interaction}),n.invalidateQueries({queryKey:hx(e.owner.threadSlug,e.owner.sessionId),exact:!0}),t.waitingForProvider&&window.setTimeout(()=>{n.invalidateQueries({queryKey:hx(e.owner.threadSlug,e.owner.sessionId),exact:!0})},1e3)},onError:t=>{y(void 0),_(O$(t)),vx(n,e),Y.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{_x(n,t),n.setQueryData(gx(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:hx(e.owner.threadSlug,e.owner.sessionId),exact:!0})),n.invalidateQueries({queryKey:hx(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}});function j(e){if(!e.requiresValues){h({});return}let t=h$(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=g$(e.id,n),i=a.current.get(r)??k$();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 ${TY} 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)(Nh,{"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||SR({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)(F$,{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)(fh,{"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)(Bh,{"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:P$(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}`))]}),!I$.has(e.payload.kind)&&(0,L.jsx)(z$,{record:e})]})})]})}function P$(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 F$({record:e,instanceId:t,draft:n,setDraft:r,errors:i,autoFocus:a}){let o=e.payload,s=(e,t)=>r(m$(n,e,t)),c;return c=o.kind===`command-approval`||o.kind===`file-approval`||o.kind===`permission-approval`?(0,L.jsx)(GQ,{payload:o}):o.kind===`mcp-elicitation-url`?(0,L.jsx)(R$,{url:o.url}):(0,L.jsx)(B$,{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)(L$,{text:o.message}),(0,L.jsx)(`div`,{className:`message`in o&&o.message?`mt-3`:``,children:c})]})}var I$=new Set([`command-approval`,`file-approval`,`permission-approval`]);function L$({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 R$({url:e}){let t=_$(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)(Zm,{"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 z$({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:u$(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:d$(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 B$({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)(V$,{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 V$({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 H$(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 U$(e,t){let n=t.description?.trim(),r=n&&!n.includes(`
306
+ `)}`}function cZ(e,t,n,r={}){let i=dW(e),[a,o]=(0,I.useState)({}),s=(0,I.useMemo)(()=>aZ(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)(()=>oZ(t)!==-1,[t]),u=mH(),d=hH(e),f=(0,I.useCallback)((t,n)=>pH.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=_H(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];dH.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)=>kY(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)=>kY(e.blocks[t],_(e.identity,t)),l=n.flatMap(e=>e.blocks.map((t,n)=>({ask:e,bi:n,question:uZ(t),answer:c(e,n)})).filter(e=>e.answer!==``));if(l.length===0)return;let u=n.find(e=>e.isLive),d=sZ({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,dH.get(e)]);C(d,{onOptimistic:()=>{r.forEach(e=>dH.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&&!dH.get(e)&&dH.set(e,t)})}})},[a,s,_,C,p,f]),T=(0,I.useCallback)(e=>{let t=v.get(tZ(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)=>kY(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 lZ(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 uZ(e){return lZ(e.contextMd)||lZ(e.options.join(` / `))||`earlier question`}function dZ(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 fZ({raw:e,question:t,questionKind:n,danger:r,interactive:i,wrap:a,aside:o,label:s,settled:c}){let l=(0,I.useMemo)(()=>t??TY(e??``,n??`question`,r),[t,e,n,r]),u=nJ(l.contextMd),d=nJ(l.trailingMd??``),f=l.recommendedIdx,p=iJ(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)(HY,{tone:h?`risk`:`neutral`,icon:h?Bh:void 0,label:s??(m?`Select multiple`:`Question`),aside:o,children:[u&&(0,L.jsx)(`div`,{className:`text-fg`,children:(0,L.jsx)(tY,{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||MR({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)(pZ,{md:l.optionHeadings[t],wrap:a}),(0,L.jsx)(hZ,{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}MR({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?`${mZ(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)(tY,{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)(tY,{className:`md-inline mt-1.5 text-[11px] text-muted/70`,html:p})]})}function pZ({md:e,wrap:t}){let n=iJ(e.split(`
308
+ `).join(` `));return(0,L.jsx)(`div`,{className:`mt-1 text-fg`,children:(0,L.jsx)(tY,{className:`md-body${t?` ${PY}`:``}`,html:n})})}function mZ(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 hZ({label:e,bodyMd:t,wrap:n,selected:r,settledPick:i,disabled:a,multi:o,recommended:s,recTitle:c,onClick:l}){let u=iJ(e),d=nJ(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)(Fm,{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)(tY,{as:`span`,className:`md-inline`,html:u})]}),t!==void 0&&(0,L.jsx)(tY,{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 gZ({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,lt.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)(Hh,{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)(fZ,{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 _Z(e){return(0,I.useSyncExternalStore)(e=>Zt(X,e),()=>e?vZ(e)!==`codex`:!1,()=>!1)}function vZ(e){return hm(X.board,e)?.backend}function yZ(e,t,n,r){let i=pH.followUp(e,t,n),a=dH.get(i),o=a?`${r}\n\n${a}`:r;return dH.set(i,o),i}function bZ(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 xZ(e){let t=Ve(),n=mH(),[r,i]=(0,I.useState)(!1);return{unqueue:(0,I.useCallback)(a=>{if(!e||r)return;let o=hm(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}Vw(t,e,a.rawText,a.deliveryId),yZ(n,e,o,a.text),bZ(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 SZ(e){return(0,I.useSyncExternalStore)(e=>Zt(X,e),()=>{if(!e)return!1;let t=hm(X.board,e);return t?.backend!==`codex`&&t?.runtime===`running`},()=>!1)}function CZ(e){let[t,n]=(0,I.useState)(!1);return{deliverNow:(0,I.useCallback)(()=>{if(!e||t)return;let r=hm(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 wZ(e){return e.displayText??e.text}function TZ(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 EZ(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&&!aX(n)))return t}return 0}function DZ(e,t){if(e.kind===`event`||e.kind===`reasoning`||e.role!==`user`)return!1;let n=wZ(e).replace(/\r\n?/g,`
309
+ `);return(t===void 0?rX(n):t)?!0:!(e.wake||e.peerFrom)}function OZ(e,t){return DZ(e,t)?`bubble`:`prose`}var kZ=`icon-label-nudge`,AZ=new Set([`planning`,`planned`,`active`,`needs-human`,`blocked`]);function jZ(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&&AZ.has(e.status))}var MZ=`sticky top-0 z-10 flex min-w-0 shrink-0 items-center gap-2.5 border-b border-border bg-panel px-3 ${Uh} 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`,NZ=`min-w-0 flex-1 pl-1 max-[640px]:basis-full`,PZ=`flex shrink-0 items-center max-[640px]:w-full max-[640px]:justify-between`;function FZ(e){return e?.trim()?{kind:`profile-error`,message:`Profile controls unavailable: ${e.trim().slice(0,160)}`}:null}function IZ(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`||e.backend===`acp`)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 LZ(e){return e.permissionChangePending===!0||e.permissionPending!==void 0||e.profileChangePending===!0||e.runtimeControlPending===!0}function RZ(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 zZ(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 BZ(e){let t=en(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=st({mutationFn:t=>Y.setThreadProfile({slug:e,model:t.model,...t.effort?{effort:t.effort}:{}})}),i=st({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||LZ(t),s=t.model?.trim(),c=t.effort?.trim(),l=t.backend===`codex`?`codex`:t.backend===`acp`?`acp`:`claude`,u=nt({queryKey:[`acpAgents`],queryFn:()=>Y.acpAgents(),enabled:l===`acp`}),d=l===`acp`?el(s):void 0,f=l===`acp`?tl(s):void 0,p=r.isPending?r.variables:void 0,m=t.profilePendingModel??p?.model,h=t.profilePendingEffort??p?.effort,g=l===`acp`&&p?tl(p.model):void 0,_=n.data?.options??[],{modelSelectable:v}=zZ(_,s,c,t.runtime===`exited`),y=n.data!==void 0,b=u.data?.find(e=>e.id===d)?.label??d,x=[{id:l,label:l===`codex`?`Codex`:`Claude Code`,options:_}],S=FZ(n.isError?n.error.message:void 0),C=t.permissionMode?UV(t.permissionMode):`auto`,w=VV.some(e=>e.value===C)?C:`auto`,T=i.isPending?i.variables:w,E=IZ(t);function D(e){e!==w&&i.mutate(e,{onSuccess:e=>Z(RZ(e.effect,`claude`)),onError:e=>Z(`Permission change failed: ${e.message.slice(0,120)}`)})}function O(e){r.mutate(e,{onSuccess:e=>Z(l===`acp`?e.effect===`next-resume`?`Model saved for the next resume`:`Model applied`: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:[l!==`acp`&&(0,L.jsx)(_V,{groups:x,value:{provider:l,model:s,effort:c},pending:m||h?{provider:l,model:m,effort:h}:void 0,onValueChange:({model:e,effort:t})=>O({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:v?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||!y||!v||n.isError,compact:!0,side:`top`,className:`min-w-0 max-w-[min(72%,20rem)] px-1.5 py-0.5`}),l===`acp`&&d&&(0,L.jsx)(kV,{agentId:d,agentLabel:b??d,modelId:g??f,onValueChange:e=>O({model:Qc(d,e),effort:``}),disabled:o,side:`top`,className:`min-w-0 max-w-[min(72%,20rem)] px-1.5 py-0.5`}),l===`claude`&&(0,L.jsx)(OV,{variant:`readout`,side:`top`,value:T,onValueChange:e=>D(e),options:VV,ariaLabel:`Thread permission mode`,title:E?`${E} — changing permissions restarts this thread's worker process`:T===`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||E!==null,className:`shrink-0`}),m&&h&&(0,L.jsxs)(`span`,{className:`min-w-0 truncate text-[9px] text-muted/50`,children:[`→ `,m,` · `,h,` pending`]})]}),status:S?(0,L.jsx)(`div`,{"data-thread-control-error":``,className:`px-1 pt-1 text-[9.5px] leading-tight text-muted/65`,children:S.message}):null}}var VZ=new Map;function HZ(e){let t=VZ.get(e);if(t)return t;let n=Y.threadSkills({slug:e}).then(e=>e.skills,()=>(VZ.delete(e),[]));return VZ.set(e,n),n}function UZ({slug:e,surface:t,placeholder:n,className:r,id:i,ops:a,submitOverride:o}){let s=en(X),c=s.board?.threads.find(t=>t.id===e),l=mH(),u=pH.followUp(l,e,c?.sessionId),[d,f,p]=gH(u),m=BZ(e),h=dW(e),[g,_]=(0,I.useState)(null),v=(0,I.useMemo)(()=>()=>HZ(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}=dR(d),r=t.filter(e=>_R(n,e.token));r.length!==t.length&&(X.composerContext[e]=r)},[e,d,x]);let C=!o&&c?.runtime===`running`&&c.backend!==`codex`&&c.backend!==`acp`;function w(t=!1){let n=d.trim();if(!n)return;let r=PV(n);if(r){if(p(),c?.backend===`acp`){Z(`An ACP agent signs in through its own CLI — Frizz holds no account for it`);return}let e=c?.backend===`codex`?`codex`:`claude`;r===`login`?_(e):b(e);return}let i=im(e),a=ER(n,i,l),s={onOptimistic:p,onRollback:()=>{dH.get(u)||f(d),am(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)(KR,{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)(IV,{backend:g,onClose:()=>_(null),onAuthed:()=>_(null)}),y&&(0,L.jsx)(LV,{backend:y,onClose:()=>b(null)})]})}function WZ({slug:e,ops:t}){let n=en(X).board?.threads.find(t=>t.id===e);return n?(0,L.jsx)(UZ,{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 GZ({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)(PM,{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:ZD,children:(0,L.jsx)(Eh,{size:14,strokeWidth:2})})})}function KZ(e,t){return new Promise(n=>{uW(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 qZ(){return mU(wU().data??null)}function JZ({thread:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return!qZ()||e.kind!==`session`||e.foreign||e.backend===`codex`||e.backend===`acp`||e.runtime===`exited`?null:(0,L.jsx)(PM,{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),KZ(t,e.id).finally(()=>r(!1))},className:`${ZD} mx-[2px]`,children:n?(0,L.jsx)(hh,{size:14,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(Oh,{size:14,strokeWidth:2})})})}function YZ({slug:e,label:t=`Exit fullscreen`}){let n=XD(e)??Ww(`/`);function r(e){af(e)&&(e.preventDefault(),Yw(n,{viewTransition:!Dp()}))}return(0,L.jsx)(PM,{label:t,children:(0,L.jsx)(`a`,{href:n,"aria-label":t,"data-standalone-return":!0,onMouseDown:e=>e.preventDefault(),onClick:r,className:ZD,children:(0,L.jsx)(bh,{size:14})})})}function XZ({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)(QZ,{label:o?`Expand`:`Collapse`,icon:o?Bm:zm,size:13,onClick:a}),(0,L.jsx)(GZ,{thread:e}),(0,L.jsx)(JZ,{thread:e}),r&&(0,L.jsx)(QZ,{label:`Frizz document`,icon:$m,size:14,onClick:r}),t&&(0,L.jsx)(FM,{slug:e.id}),n&&(0,L.jsx)(YZ,{slug:e.id}),d?AE(e)?(0,L.jsx)(ZZ,{slug:e.id}):null:(0,L.jsx)(`div`,{className:`ml-1`,children:(0,L.jsx)(wL,{slug:e.id,onDone:i,doneBusy:s,onMutateStart:c,onApplied:l,onFailed:u})})]})}function ZZ({slug:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return(0,L.jsx)(PM,{label:`Retry — resume this session where it left off`,children:(0,L.jsxs)(`button`,{onClick:()=>{r(!0),fW(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)(hh,{size:12,className:`animate-spin`}):(0,L.jsx)(Ah,{size:12}),`Retry`]})})}function QZ({label:e,icon:t,size:n,busy:r,...i}){return(0,L.jsx)(PM,{label:e,children:(0,L.jsx)(`button`,{...i,"aria-label":e,onMouseDown:e=>e.preventDefault(),className:ZD,children:r?(0,L.jsx)(hh,{size:n,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(t,{size:n,strokeWidth:2})})})}function $Z(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 eQ(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=>ol(e)&&t(e))||e.bgShells?.some(t))}function tQ(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=[nQ(`agent`,`sub-agent`,e.subAgents,e.subAgentCount),nQ(`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 nQ(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 rQ({open:e,onOpenChange:t,title:n,children:r,footer:i,className:a=`w-[640px] max-w-[92vw] max-h-[82vh]`,onOpenAutoFocus:o}){return(0,L.jsx)(AL,{open:e,onOpenChange:t,children:(0,L.jsxs)(IL,{children:[(0,L.jsx)(RL,{className:`overlay-in fixed inset-0 z-[200] bg-black/55 backdrop-blur-[1px]`}),(0,L.jsxs)(HL,{"aria-modal":`true`,onEscapeKeyDown:vz,onOpenAutoFocus:o,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)(qL,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:n}),(0,L.jsx)(ZL,{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)(Hh,{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 iQ({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=bE(e),g=en(JT).snoozePreset,_=AT(g),v=MT(g),y=(0,I.useMemo)(()=>FT(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`} · ${LT(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){JT.snoozePreset=e,b(NT(e))}function S(){s(FT(new Date(h??NT(g)))),l(e.snoozePrompt??``),d(``),a(!0)}function C(){let e=IT(o);if(!e.ok){d(e.message);return}let t=c.trim();if(t.length>4e3){d(`Prompt is too long (${t.length}/${Sl})`);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 · ${LT(h)}`:v,onClick:()=>void b(h?null:NT(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)(hh,{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)(yL,{children:[(0,L.jsx)(bL,{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)(Im,{size:12})})}),(0,L.jsxs)(xL,{align:`end`,children:[DT.map(e=>(0,L.jsx)(SL,{onSelect:()=>x(e.value),icon:(0,L.jsx)(Jm,{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)(CL,{}),(0,L.jsx)(SL,{onSelect:S,children:`Custom time & prompt…`}),h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(CL,{}),(0,L.jsx)(SL,{onSelect:()=>void b(null),children:`Wake now`})]})]})]})]}),(0,L.jsx)(rQ,{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)(hh,{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:Sl,placeholder:`e.g. Check whether CI went green and land it if so.`,value:c,onChange:e=>{l(e.target.value),d(``)},onKeyDown:e=>{MR({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 aQ=1.25,oQ=7.5-aQ/2,sQ=2*Math.PI*oQ;function cQ(e,t){return Math.max(0,Math.min(100,Math.floor(e/t*100)))}function lQ({thread:e}){let t=e.context;if(!t||t.window<=0)return null;let n=cQ(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)(PM,{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:oQ,fill:`none`,stroke:`currentColor`,strokeOpacity:.3,strokeWidth:aQ}),(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:oQ,fill:`none`,stroke:`currentColor`,strokeWidth:aQ,strokeDasharray:`${sQ*r} ${sQ}`})]})})})}var uQ={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 dQ({checked:e,onChange:t,disabled:n,label:r,size:i=`sm`,testId:a}){let o=uQ[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 fQ({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 pQ({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),mQ)}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)(pV,{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 ${LR}`,children:(0,L.jsx)(fQ,{size:12,className:o?`text-amber-400/90`:`text-muted/60 hover:text-muted`})})}),t===`preview`?(0,L.jsx)(mV,{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)(hQ,{armed:a})}):(0,L.jsx)(mV,{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)(TQ,{thread:e,armed:a,close:()=>n(`closed`)})})]})}var mQ=260;function hQ({armed:e}){let t=e?.prompt?.trim(),n=e?wQ({stopHook:e.stopHook===!0,heartbeat:e.heartbeat===!0,postCompaction:e.postCompaction===!0,seconds:e.intervalSeconds??vQ}):[];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 gQ=1,_Q=1440,vQ=600;function yQ(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(_Q,Math.max(gQ,n))*60:t}var bQ=null;function xQ(e){return{prompt:e.text.trim(),stopHook:e.stopHook,heartbeat:e.heartbeat,postCompaction:e.postCompaction,seconds:e.seconds}}function SQ(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 CQ(e,t){return!e.archived&&!t}function wQ(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 TQ({thread:e,armed:t,close:n}){let r=CQ(e,t)?Dl:``,i=bQ?.slug===e.id?bQ.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??vQ),h=s||l||d,[g,_]=(0,I.useState)(String(Math.round((i?.seconds??t?.intervalSeconds??vQ)/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??vQ}),b=e=>({text:a,stopHook:s,heartbeat:l,postCompaction:d,seconds:yQ(g,p),...e}),x=(0,I.useRef)(b());x.current=b(),(0,I.useEffect)(()=>()=>{let n=x.current;if(SQ(n,y.current)){bQ?.slug===e.id&&(bQ=null);return}if(n.text.trim()===``&&!t){bQ={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?bQ?.slug===e.id&&(bQ=null):bQ={slug:e.id,draft:t},n});return S.current=n,n}async function w(t){let n=t.text.trim()||null;if(SQ(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={...xQ(t),prompt:n??``};let r=wQ(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(SQ(b(),y.current)||a.trim()===``&&!t){n();return}C(b()).then(e=>{e&&n()})}function E(){let e=yQ(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 ${_D(O.at)}`:`Last sent ${O.how} ${_D(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:wl,onChange:e=>o(e.target.value),onKeyDown:e=>{MR({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)(dQ,{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)(dQ,{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:gQ,max:_Q,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)(dQ,{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 EQ({thread:e,sticky:t=!1,safeArea:n=!1,onArchived:r,onDismissCancel:i,onSnoozed:a}){let o=$Z(e);return o.footer?(0,L.jsxs)(`footer`,{"aria-label":`Thread lifecycle actions`,"data-thread-lifecycle-footer":!0,className:`${t?`z-20`:LY} flex min-h-10 shrink-0 flex-wrap items-center justify-end ${FR} 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 ${FR}`,children:[(0,L.jsx)(lQ,{thread:e}),(0,L.jsx)(OQ,{thread:e}),(0,L.jsx)(pQ,{thread:e})]}),o.done?(0,L.jsx)(DQ,{}):(0,L.jsxs)(L.Fragment,{children:[o.snooze&&(0,L.jsx)(iQ,{thread:e,onSnoozed:a}),(0,L.jsx)(kQ,{thread:e,onArchived:r,onDismissCancel:i})]})]}):null}function DQ(){let e=`Marked done — send a message to reopen it`;return(0,L.jsx)(PM,{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)(Fm,{size:12}),`Done`]})})}function OQ({thread:e}){let t=bE(e);if(!t)return null;let n=e.snoozePrompt?.trim(),r=n?`Bumps ${LT(t)}\n${n}`:`Snoozed until ${LT(t)}`;return(0,L.jsx)(PM,{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)(ch,{size:12})})})}function kQ({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||eQ(e))&&jW(e.id),Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:r}).then(r=>{if(r.needsConfirmation){MW(e.id),i&&n?.(),u(r.hold),c(!0),o(!1);return}c(!1),Z(`Done`),i||t?.()}).catch(t=>{MW(e.id),i&&n?.(),Z(`Couldn’t finish: ${t.message.slice(0,80)}`),o(!1)})},f=!!t&&!!n&&eQ(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)(Fm,{size:12,className:i}),`Mark as done`]}),(0,L.jsx)(rQ,{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)(hh,{size:12,className:`animate-spin`}),l?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,L.jsx)(AQ,{hold:l})})]})}function AQ({hold:e}){let t=tQ(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:yD,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 jQ(e,t){let n=e.trim();if(!(!n||n===t.trim()))return n}function MQ(e,t){let n=e.trim();return!n||n===t||n===`Untitled thread`||n===`Spinning up a thread…`?``:n}function NQ(e){return e.kind!==`session`||e.foreign||e.backend===`codex`||e.backend===`acp`||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`}}function PQ({thread:e,hidden:t=!1}){let n=st({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=NQ(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)(PM,{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)(hh,{size:12,className:`animate-spin`}):(0,L.jsx)(jh,{size:12})})})}function FQ({thread:e,className:t=``}){let n=e.id,r=st({mutationFn:e=>Y.renameThread({slug:n,title:e})}),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(``),c=(0,I.useRef)(null);(0,I.useEffect)(()=>{if(!i)return;let e=requestAnimationFrame(()=>{c.current?.focus(),c.current?.select()});return()=>cancelAnimationFrame(e)},[i]),(0,I.useEffect)(()=>{a(!1),s(``)},[n]);let l=e.kind===`session`&&e.foreign!==!0,u=QT(e);function d(){a(!1),s(``)}function f(){let e=jQ(o,u);if(a(!1),!e){s(``);return}r.mutate(e,{onSuccess:()=>{s(``),Z(`Thread renamed`)},onError:t=>{s(e),a(!0),Z(t instanceof Error?t.message:`Could not rename thread`)}})}return(0,L.jsxs)(`div`,{className:`group/thread-title flex min-w-0 items-center gap-2`,children:[i?(0,L.jsx)(`input`,{ref:c,"aria-label":`Thread title`,value:o,maxLength:200,onChange:e=>s(e.target.value),onBlur:f,"data-claims-escape":!0,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),f()):e.key===`Escape`&&(e.preventDefault(),d())},className:`min-w-0 flex-1 -mx-1.5 -my-px rounded-md border border-border bg-elevated px-1.5 py-0 font-semibold text-[15px] text-fg outline-none focus:border-accent ${t}`}):l?(0,L.jsx)(`button`,{type:`button`,title:`Edit title`,"aria-label":`Edit thread title: ${u}`,disabled:r.isPending,onClick:()=>{s(MQ(u,n)),a(!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 ${t}`,children:u}):(0,L.jsx)(`div`,{className:`min-w-0 max-w-full shrink truncate px-0.5 -mx-0.5 font-semibold text-[15px] ${t}`,title:u,children:u}),(0,L.jsx)(PQ,{thread:e,hidden:i})]})}var IQ=new Set([`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]);function LQ(e,t){let n=e.lastIndexOf(t);if(n<=0)return{model:e};let r=e.slice(n+1);return IQ.has(r)?{model:e.slice(0,n),effort:r}:{model:e}}function RQ(e){let t=e?.trim();if(!t)return`Profile unknown`;if(t.startsWith(`frizz:`)){let{model:e,effort:n}=LQ(t.slice(6).replace(/^frizz-/,``),`-`);return n?`${e} › ${n}`:e}let n=t.split(/\s+/),{model:r,effort:i}=LQ(n.at(-1)??t,`/`);if(!i)return t;let a=n.slice(0,-1).join(` `);return`${a?`${a} · `:``}${r} › ${i}`}function zQ(e){return e?.trim()?RQ(e):void 0}function BQ(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 VQ={completed:`finished`,killed:`stopped`,failed:`failed`};function HQ(e){let t=VQ[e.agentStatus??`completed`],n=e.agentElapsedMs===void 0?void 0:mD(e.agentElapsedMs);return{outcome:t,tail:`${t}${n?` · ${n}`:``}`}}var UQ=e=>e===void 0?void 0:lD(e),WQ=e=>{if(e!==void 0)return mD(e)||void 0};function GQ(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=UQ(n);return{label:t===`completed`?void 0:VQ[t],duration:WQ(n),tone:r?`failed`:`muted`,title:`${e?`Stopped`:r?`Failed`:`Ran for`}${e||r?` after`:``} ${i??`an unknown time`}`}}if(r){let e=UQ(i);return{label:void 0,duration:WQ(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=UQ(o);return{label:c?VQ.killed:s?VQ.failed:void 0,duration:WQ(o),tone:s?`failed`:`muted`,title:`${c?`Stopped after`:s?`Failed after`:`Ran for`} ${l??`an unknown time`}`}}var KQ=`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`,qQ=`${xD} -mt-[1em] self-baseline`,JQ=`h-[1em] w-[1em] shrink-0 translate-y-[calc(0.5em_-_0.5cap)] text-muted/45`;function YQ({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:yD,children:`⤷`}),(0,L.jsx)(`span`,{className:qQ,children:(0,L.jsx)(t?Zm:$m,{"aria-hidden":!0,className:JQ})}),(0,L.jsx)(`span`,{"data-link-kind":!0,className:bD,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:KQ,onClick:e=>e.stopPropagation(),children:n},e.id):(0,L.jsx)(`button`,{"data-thread-link":e.id,type:`button`,title:e.target,className:`${KQ} cursor-pointer`,onClick:t=>{t.stopPropagation(),MJ(e.target)},children:n},e.id)})}):null}function XQ({at:e,host:t}){let n=HE(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 ZQ({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)(XQ,{at:e,host:t})]})}var QQ=`text-[14px] leading-5 text-muted`,$Q=`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 e$(e){return`${$Q} ${e?`-mx-[0.208em] rotate-90`:`-mx-[0.333em]`}`}var $=I.createElement;function t$({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,$(n$,{label:`Redacted command preview`,text:e.command.preview}),e.command.actions?$(r$,{actions:e.command.actions}):null,e.capabilities?$(a$,{capabilities:e.capabilities}):null):e.kind===`file-approval`?$(I.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},l$(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?$(n$,{label:`Plain-text diff preview`,text:e.diffPreview}):null,e.changes?$(i$,{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?$(a$,{capabilities:e.capabilities}):null)}function n$({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 r$({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`},c$(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,$(n$,{label:`${c$(e.kind)} command detail`,text:e.commandPreview})))))}function i$({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`},l$(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?$(n$,{label:`${l$(e.operation)} plain-text diff`,text:e.diffPreview}):null))))}function a$({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`},$(o$,{capability:e})))))}function o$({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?$(s$,{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),$(s$,{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`),$(s$,{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`),$(s$,{label:`Hosts`,values:e.hosts}))}function s$({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 c$(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 l$(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 u$(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 d$={semantic:`approve`,label:`Approve once`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`},f$={semantic:`approve`,label:`Approve for session`,order:20,tone:`primary`,durable:!0,scope:`Persists for later matching requests in this thread session.`},p$={semantic:`approve`,label:`Grant for turn`,order:10,tone:`primary`,durable:!1,scope:`Applies to this turn only.`},m$={semantic:`approve`,label:`Grant for session`,order:20,tone:`primary`,durable:!0,scope:`Persists until this thread session ends.`},h$={semantic:`deny`,label:`Deny`,order:70,tone:`danger`,durable:!1,scope:`Rejects this request.`},g$={semantic:`decline`,label:`Decline`,order:70,tone:`danger`,durable:!1,scope:`Declines this request.`},_$={semantic:`cancel`,label:`Cancel request`,order:80,tone:`neutral`,durable:!1,scope:`Cancels this pending request.`};function v$(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`?d$:n===`acceptForSession`&&r===`approve`?f$:(n===`decline`||n===`deny`)&&r===`deny`?h$:n===`cancel`&&r===`cancel`?_$:void 0;if(e.kind===`permission-approval`)return n===`grant-turn`&&r===`approve`?p$:n===`grant-session`&&r===`approve`?m$:(n===`deny`||n===`decline`)&&r===`deny`?h$:n===`cancel`&&r===`cancel`?_$: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`?g$:n===`cancel`&&r===`cancel`?_$: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 g$;if(n===`cancel`&&r===`cancel`)return _$}function y$(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=v$(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 b$(e){switch(e){case`claude`:return`Claude`;case`codex`:return`Codex`;case`acp`:return`ACP agent`;case`frizz`:return`Frizz`}}function x$(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 S$(e,t){let n=e.options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t));return n<0?``:String(n)}function C$(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?``:S$(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 w$(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 T$(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=lc(i,a);e?r[i.id]=`Value ${e}.`:n[i.id]=a}}if(Object.keys(r).length>0)return{errors:r};let i=Cc.safeParse(n);return i.success?{errors:r,values:i.data}:{errors:r,formError:`The response is too large or contains invalid values.`}}function E$(e,t){return JSON.stringify([e,t??null])}function D$(e,t){try{let n=new URL(e,t);return n.protocol===`http:`||n.protocol===`https:`?n.toString():null}catch{return null}}function O$(e,t){let n=e.getAttribute(`href`);if(!n)return!1;let r=D$(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 k$(e=()=>location.href){return t=>{if(t.defaultPrevented||t.button!==0)return;let n=j$(t);n&&O$(n,e())}}function A$(){let e=k$();return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)}function j$(e){let t=typeof e.composedPath==`function`?e.composedPath():[];for(let e of t)if(M$(e))return e;let n=e.target?.closest?.(`a[href]`);return M$(n)?n:null}function M$(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 N$(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 P$(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)=>`${N$(t)} ${e.label}`),recommendedIdx:null},...e?{optionFieldId:e.id}:{},optionValues:r.map(e=>e.value),...t?{notesFieldId:t.id}:{}}}function F$(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=P$(r,a);if(!e)return null;n.push(e)}else if(r.input===`text`||r.input===`multiline`){let e=P$(void 0,r);if(!e)return null;n.push(e)}else return null}return n.length>0?n:null}function I$(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)=>`${N$(t)} ${e.label}${e.description?` — ${e.description}`:``}`),recommendedIdx:null},chosenIdxs:n,text:r}}function L$(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 R$(e){let t=e instanceof Error?e.message:`The request could not be updated.`;return t.length>240?`${t.slice(0,239)}…`:t}function z$(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`frizz-response-${Date.now()}-${Math.random().toString(36).slice(2)}`}function B$({thread:e,className:t=``,autoFocusFirst:n=!1}){let r=Ew(e),i=Ow(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:`${FY} 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:R$(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)(H$,{record:e,autoFocus:n&&t===0},e.id))}):null}function V$({record:e,questions:t,autoFocus:n}){let r=Ve(),i=(0,I.useRef)(null),a=(0,I.useRef)(new Map),o=mH(),s=u$(e.delivery?.effect),c=(0,I.useMemo)(()=>y$(e).find(e=>e.semantic===`answer`),[e]),l=_H(t.flatMap(t=>t.notesFieldId?[pH.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(pH.interaction(o,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId))??``:``})),p=L$(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=st({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),_x(r,t.interaction),r.invalidateQueries({queryKey:hx(e.owner.threadSlug,e.owner.sessionId)}),r.invalidateQueries({queryKey:gx(e.owner.threadSlug,e.owner.sessionId,e.id)})},onError:t=>{vx(r,e),h(R$(t))}}),y=()=>{if(!c||!p||v.isPending||g||!s.actionsEnabled)return;h(void 0);let e=E$(c.id,p),t=a.current.get(e)??z$();a.current.set(e,t),v.mutate({decisionId:c.id,values:p,responseId:t})},b=(t,n)=>{t.notesFieldId&&dH.set(pH.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)(fZ,{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 H$({record:e,autoFocus:t=!1}){let n=(0,I.useMemo)(()=>F$(e),[e]);return n?(0,L.jsx)(V$,{record:e,questions:n,autoFocus:t}):(0,L.jsx)(U$,{record:e,autoFocus:t})}function U$({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=mH(),l=o.filter(e=>!e.secret&&(e.input===`text`||e.input===`multiline`)).map(t=>pH.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.id)),u=_H(l),[d,f]=(0,I.useState)(()=>C$(o)),p=(0,I.useMemo)(()=>{let t={...d};return o.forEach(n=>{if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=pH.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=u$(e.delivery?.effect),D=(0,I.useMemo)(()=>y$(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`&&dH.set(pH.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=st({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(E$(r.decision.id,r.values)),_(void 0),C(void 0),T(!1),x(!0),l.forEach(e=>dH.clear(e)),y(t.waitingForProvider?`Response sent. Waiting for the provider to acknowledge it…`:`Request completed.`),_x(n,t.interaction),n.setQueryData(gx(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t.interaction}),n.invalidateQueries({queryKey:hx(e.owner.threadSlug,e.owner.sessionId),exact:!0}),t.waitingForProvider&&window.setTimeout(()=>{n.invalidateQueries({queryKey:hx(e.owner.threadSlug,e.owner.sessionId),exact:!0})},1e3)},onError:t=>{y(void 0),_(R$(t)),vx(n,e),Y.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{_x(n,t),n.setQueryData(gx(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:hx(e.owner.threadSlug,e.owner.sessionId),exact:!0})),n.invalidateQueries({queryKey:hx(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}});function j(e){if(!e.requiresValues){h({});return}let t=T$(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=E$(e.id,n),i=a.current.get(r)??z$();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 ${FY} 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)(Nh,{"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||MR({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)(G$,{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)(fh,{"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)(Bh,{"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:W$(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}`))]}),!K$.has(e.payload.kind)&&(0,L.jsx)(Y$,{record:e})]})})]})}function W$(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 G$({record:e,instanceId:t,draft:n,setDraft:r,errors:i,autoFocus:a}){let o=e.payload,s=(e,t)=>r(w$(n,e,t)),c;return c=o.kind===`command-approval`||o.kind===`file-approval`||o.kind===`permission-approval`?(0,L.jsx)(t$,{payload:o}):o.kind===`mcp-elicitation-url`?(0,L.jsx)(J$,{url:o.url}):(0,L.jsx)(X$,{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)(q$,{text:o.message}),(0,L.jsx)(`div`,{className:`message`in o&&o.message?`mt-3`:``,children:c})]})}var K$=new Set([`command-approval`,`file-approval`,`permission-approval`]);function q$({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 J$({url:e}){let t=D$(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)(Zm,{"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 Y$({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:b$(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:x$(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 X$({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)(Z$,{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 Z$({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 Q$(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 $$(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:`${H$(e)} ${t.label}${r?` — ${r}`:``}`,...i?{body:i}:{}}}var W$=`root`;function G$(e,t,n){return`${e}/${t}.${n}`}function K$(e){let t=e.options??[],n=t.findIndex(e=>e.recommended),r=t.map((e,t)=>U$(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 q$(e,t){return!t||e.kind===`multi`?null:t.chosen}function J$(e,t){let n=[],r=(e,i,a)=>{let{question:o,optionLabels:s}=K$(e);n.push({path:i,spec:e,question:o,optionLabels:s,depth:a});let c=q$(e,t.get(i));c!==null&&(e.options?.[c]?.followUps??[]).forEach((e,t)=>r(e,G$(i,c,t),a+1))};return r(e,W$,1),n}function Y$(e,t){return t?t.text.trim()?!0:e.kind===`multi`?(t.chosenSet??[]).length>0:t.chosen!==null:!1}function X$(e,t){if(!Y$(e.spec,t.get(`root`)))return;let n=(r,i)=>{let a=t.get(i),o=(r.options??[]).map(e=>e.label),s=q$(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,G$(i,s,t)));return{questionId:e.id,question:r.question,chosen:c,...l?{text:l}:{},...u.length>0?{followUps:u}:{}}};return n(e.spec,W$)}function Z$(e){let t=e instanceof Error?e.message:`The answer could not be sent.`;return t.length>240?`${t.slice(0,239)}…`:t}var Q$=(e,t)=>`${e}|${t}`,$$=(0,I.createContext)(null);function e1(e){let t=e?.id,n=e?.questions??[],r=iH(),[i,a]=(0,I.useState)(()=>new Map),[o,s]=(0,I.useState)(),c=(0,I.useContext)(C2),l=sH((0,I.useMemo)(()=>t?n.flatMap(e=>i1(e).map(n=>rH.question(r,t,e.id,n))):[],[r,t,n])),u=(e,n)=>{let a=i.get(Q$(e.id,n));return{chosen:a?.chosen??null,chosenSet:a?.chosenSet??[],text:(t?l.get(rH.question(r,t,e.id,n)):void 0)??``}},d=e=>new Map(i1(e).map(t=>[t,u(e,t)])),f=n.flatMap(e=>{let t=X$(e,d(e));return t?[t]:[]}),p=st({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 i1(e))tH.set(rH.question(r,t,e.id,n),``)}},onError:e=>{c?.cancel(),s(Z$(e))}}),m=st({mutationFn:async e=>Y.dismissQuestions({slug:t,ids:[e]}),onError:e=>s(Z$(e))});return{slug:t,answerFor:u,answersOf:d,onChip:(e,t,n,r)=>{a(i=>{let a=new Map(i),o=Q$(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&&(tH.set(rH.question(r,t,e.id,n),o),i||a(t=>{let r=Q$(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 t1({thread:e,children:t}){let n=e1(e);return(0,L.jsx)($$.Provider,{value:n,children:t})}function n1({q:e,answering:t}){let n=(0,I.useContext)($$),r=t??n;if(!r||!r.slug)return null;let i=J$(e.spec,r.answersOf(e)),a=t=>(0,L.jsx)(nZ,{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)(Hh,{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 r1({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=e1(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)(WX,{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)(n1,{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 i1(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,W$),t}function a1(e){return(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).length}function o1(e,t={}){let n=(e.subAgents??[]).filter(e=>ol(e)&&e.state===`running`).length,r=(e.bgShells??[]).filter(e=>e.state===`running`).length,i=t.watchers===!1?0:a1(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 s1(e){return(e.subAgents??[]).some(e=>ol(e)&&e.state===`running`)}function c1(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length}function l1(e){return s1(e)||c1(e)>0}function u1(e,t){return bl(t)??(d1(e)?`Background shells running`:`Awaiting`)}function d1(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length>0&&!s1(e)&&a1(e)===0&&f1(e).length===0}function f1(e){return(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`)}var p1={id:``,subAgents:[],bgShells:[],watches:[]},m1=[];function h1(e,t){let n=new Set((e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).map(e=>e.target));return aW(t).filter(e=>!n.has(e.ref))}function g1({watch:e}){return(0,I.useEffect)(()=>{e.url&&Xf([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:`${IY} text-[12px]`,children:e.ref}):(0,L.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.ref})}var _1={mergeable:`no conflicts`,blocked:`merge blocked`,conflicting:`has conflicts`,unknown:null};function v1(e){return e.state!==`open`||e.merge===`blocked`&&e.checks!==`passing`&&e.checks!==`none`?null:_1[e.merge]}var y1=`shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`;function b1({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 ${y1}`})}function x1(){return(0,L.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 16 16`,width:12,height:12,fill:`none`,stroke:`currentColor`,overflow:`visible`,className:y1,style:{color:cD.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 S1({status:e}){return e?e.state===`merged`?(0,L.jsx)(rh,{size:12,className:y1,style:{color:cD.fgDone}}):e.state===`closed`?(0,L.jsx)(ih,{size:12,className:y1,style:{color:cD.fgDanger}}):e.checks===`failing`?(0,L.jsx)(qm,{size:12,className:y1,style:{color:cD.fgDanger}}):e.checks===`passing`?(0,L.jsx)(Hm,{size:12,className:y1,style:{color:cD.fgSuccess}}):e.gated>0&&e.running===0?(0,L.jsx)(Vm,{size:12,className:y1,style:{color:cD.fgAttention}}):e.checks===`running`?(0,L.jsx)(x1,{}):(0,L.jsx)(Um,{size:12,className:`${y1} text-muted/60`}):(0,L.jsx)(Um,{size:12,className:`${y1} text-muted/60`})}function C1(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 w1(e){if(!e)return`Checking…`;if(e.state===`merged`)return`Merged`;if(e.state===`closed`)return`Closed`;let t=C1(e),n=v1(e);return[t||`No checks`,n].filter(e=>e!==null).join(` · `)}var T1=`group relative col-span-4 grid grid-cols-subgrid items-baseline rounded-sm text-[12px] leading-5`,E1=`group relative col-span-4 flex items-baseline rounded-sm text-[12px] leading-5`,D1=`ml-1.5 min-w-0 truncate font-medium text-fg/90`,O1=`ml-3 min-w-0 truncate text-right text-muted/70`,k1=`outline-none after:absolute after:inset-0 after:rounded-sm focus-visible:after:ring-1 focus-visible:after:ring-fg/60`;function A1(){return(0,L.jsx)(Rm,{size:13,"aria-hidden":!0,className:`${y1} ml-[3px] -mr-[4px] text-muted/35 transition-colors group-hover:text-muted/70`})}function j1({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?`${D1} flex-1`:D1,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} ${k1} 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} ${k1} 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?E1:T1} ${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:O1,children:n}),m?(0,L.jsx)(A1,{}):(0,L.jsx)(`span`,{})]})}function M1({status:e}){return e?e.state===`closed`?e.stateReason===`not_planned`||e.stateReason===`duplicate`?(0,L.jsx)(Km,{size:12,className:`${y1} text-muted`}):(0,L.jsx)(Hm,{size:12,className:y1,style:{color:cD.fgDone}}):(0,L.jsx)(Wm,{size:12,className:y1,style:{color:cD.fgSuccess}}):(0,L.jsx)(Um,{size:12,className:`${y1} text-muted/60`})}function N1(e){if(!e)return`Checking…`;if(e.state===`closed`){let t=e.stateReason===`not_planned`?`not planned`:e.stateReason===`duplicate`?`duplicate`:null;return t?`Closed as ${t}`:`Closed`}return`Open · ${e.comments} comment${e.comments===1?``:`s`}`}function P1({watch:e}){if(e.subject===`issue`)return(0,L.jsx)(F1,{watch:e});let t=e.github,n=rW(e.target);return(0,I.useEffect)(()=>{n&&Xf([e.target])},[n,e.target]),(0,L.jsx)(j1,{testKind:`github`,testId:e.target,mark:(0,L.jsx)(S1,{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:[w1(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 F1({watch:e}){let t=e.issue,n=rW(e.target,`issue`);return(0,I.useEffect)(()=>{n&&Xf([e.target])},[n,e.target]),(0,L.jsx)(j1,{testKind:`github`,testId:`issue:${e.target}`,mark:(0,L.jsx)(M1,{status:t}),name:t?.title?`${e.target} ${t.title}`:e.target,href:n??void 0,ghRef:n?e.target:void 0,title:n?`Open ${e.target} on GitHub`:e.target,status:N1(t)})}function I1(e,t){return(e.bgShells??[]).find(e=>e.id===t||e.taskId===t||e.label===t)}function L1(e){return(e.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`)}function R1({watch:e,thread:t,slug:n,now:r}){let i=I1(t,e.target);if(i)return(0,L.jsx)(z1,{shell:i,slug:n,now:r,testId:e.target});let a=rD(e.createdAt,r);return(0,L.jsx)(j1,{testKind:`shell`,testId:e.target,mark:(0,L.jsx)(Lh,{size:12,className:`${y1} text-shell`}),name:e.target,title:e.target,status:a?`running · ${a}`:`running`})}function z1({shell:e,slug:t,now:n,testId:r}){let i=rD(e.startedAt,n),a=e.id&&!e.outputUnavailable;return(0,L.jsx)(j1,{testKind:`shell`,testId:r??e.id??e.label,mark:(0,L.jsx)(Lh,{size:12,className:`${y1} text-shell`}),name:e.label,onOpen:a?()=>Up(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 B1({watch:e,now:t}){let n=Date.parse(e.timer?.fireAt??``),r=Number.isFinite(n)?n>t?`fires in ${tD(n-t)}`:`firing…`:`armed`;return(0,L.jsx)(j1,{testKind:`timer`,testId:e.target,mark:(0,L.jsx)(Jm,{size:12,className:`${y1} 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 V1(e){return(e.subAgents??[]).filter(e=>ol(e)&&e.state===`running`)}function H1({agent:e,slug:t,now:n}){let r=rD(e.startedAt,n),i=e.subagentType?.replace(/^frizz:/,``);return(0,L.jsx)(j1,{testKind:`agent`,testId:e.id??e.label,mark:(0,L.jsx)(b1,{tone:`border-accent`}),name:e.label,onOpen:e.id?()=>Hp(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 U1(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=I1(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 W1(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=i.filter(e=>e.subject!==`issue`),o=i.filter(e=>e.subject===`issue`),s=L1(e).filter(t=>r(I1(e,t.target)?.startedAt??t.createdAt));return{prs:a,issues:o,shells:[...s,...U1(e,t.hints??[],s)],agents:V1(e).filter(e=>r(e.startedAt)),timers:f1(e).filter(e=>r(e.createdAt))}}function G1(e,t={}){let n=W1(e,t);return n.prs.length+n.issues.length+n.shells.length+n.agents.length+n.timers.length>0}function K1(e,t,n={}){let{prs:r,issues:i,shells:a,agents:o,timers:s}=W1(e,n);return[{head:`Sub-agents`,rows:o.map(n=>(0,L.jsx)(H1,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:a.map(n=>(0,L.jsx)(R1,{watch:n,thread:e,slug:e.id,now:t},n.id))},{head:`Pull requests`,rows:r.map(e=>(0,L.jsx)(P1,{watch:e},e.id))},{head:`Issues`,rows:i.map(e=>(0,L.jsx)(P1,{watch:e},e.id))},{head:`Timers`,rows:s.map(e=>(0,L.jsx)(B1,{watch:e,now:t},e.id))}].filter(e=>e.rows.length>0)}function q1({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)(Rm,{size:10,"aria-hidden":!0,className:`${y1} ml-[5px] transition-transform ${e.collapsed?``:`rotate-90`}`})]}):(0,L.jsx)(`div`,{className:n,children:e.head})}function J1({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)(q1,{group:e,first:t===0}),!e.collapsed&&e.rows]},e.head))})]})}function Y1(e){return e?.awaitingBackground===!0&&e.runtime===`turn-idle`&&e.bgSnoozed!==!0}var X1=`Hides card until new activity is detected`;function Z1({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:X1,className:`disabled:opacity-45 ${LY}`,children:[(0,L.jsx)(ch,{size:12,className:yZ}),`Snooze`]}),(0,L.jsx)(`span`,{className:FY,children:X1})]})}function Q1({thread:e,fence:t,onSnooze:n,onSnoozeFailed:r,notAfter:i}){let a=e??p1,o=t??(e?.lastFence?.kind===`awaiting`?e.lastFence:void 0),s=o?.hints??m1,c=s1(a),l=dW(o?.body),u=Kq(l??``),d=K1(a,WE(),{hints:s,notAfter:i}),f=h1(a,s),p=i===void 0&&e!==void 0&&Y1(e)&&UZ(e).snooze;return(0,L.jsxs)(MY,{"data-awaiting-background":!0,icon:d1(a)?Lh:ch,label:(0,L.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:u1(a,s)}),aside:f.length===1?(0,L.jsx)(g1,{watch:f[0]}):void 0,className:p?`pb-0`:``,children:[l?(0,L.jsx)(GJ,{className:`md-body ${wY}`,html:u}):d.length===0&&!l1(a)?(0,L.jsx)(`p`,{className:NY,children:iW}):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)(g1,{watch:e},e.ref))}),d.length===0&&l1(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 `,o1(a,{watchers:!1}),` it dispatched. It returns to the queue on its own when the work comes back.`]}):(0,L.jsxs)(L.Fragment,{children:[o1(a,{watchers:!1}),` `,c1(a)===1?`is`:`are`,` still running. It resumes on its own when`,` `,c1(a)===1?`it finishes`:`one of them finishes`,`.`]})}),(0,L.jsx)(J1,{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 ${DY}`,children:(0,L.jsx)(Z1,{thread:e,onSnooze:n,onSnoozeFailed:r})}):null]})}function $1(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 e0(e,t=Date.now()){return e!==void 0&&uE(e,t)!==void 0}function t0(){let[e,t]=(0,I.useState)(()=>Date.now());return(0,I.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function n0({thread:e}){let t=t0(),[n,r]=(0,I.useState)(!1),i=uE(e,t);if(!i)return null;let a=Date.parse(i),o=DT(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)(MY,{"data-snooze-card":!0,icon:ch,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:aD(a-t)}),(0,L.jsx)(`p`,{className:NY,children:s?(0,L.jsxs)(L.Fragment,{children:[`Resumes `,o,` and sends: “`,jT(s),`”`]}):(0,L.jsxs)(L.Fragment,{children:[`Returns to the queue `,o,`.`]})}),e.foreign!==!0&&(0,L.jsx)(PY,{children:(0,L.jsx)(`button`,{type:`button`,"data-snooze-wake-now":!0,disabled:n,onClick:()=>void c(),className:`${LY} disabled:cursor-not-allowed disabled:opacity-45`,children:`Wake now`})})]})}function r0({at:e,fallbackAt:t,className:n=``}){let r=WE(),i=EE(e,t),a=DE(i,r);return!a||!i?null:(0,L.jsx)(`time`,{dateTime:i,className:n,children:a})}var i0=1500;function a0(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},i0),a},fail(t){t===n&&(i(),e(!1))},dispose(){n++,i()}}}var o0=`Could not copy terminal command`,s0={attach:`Attach command copied`,resume:`Resume command copied`},c0={attach:`Copy command to attach to this thread's live terminal`,resume:`Copy command to resume this thread in a new terminal`},l0=e=>[`terminalCommand`,e];function u0(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 d0(e){let t=u0(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 bV(n),r}function f0(e){let t=st({mutationFn:()=>d0(e)});return e=>t.mutate(void 0,{onSuccess:t=>{e?.onSuccess?.(),Z(s0[t])},onError:t=>{e?.onError?.(),Z(t instanceof Error?`${o0}: ${t.message}`:o0,{duration:7e3})}})}function p0({slug:e}){let[t,n]=(0,I.useState)(!1),r=(0,I.useRef)(null);r.current||=a0(n,{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)});let i=Ve(),a=f0(e);(0,I.useEffect)(()=>()=>r.current?.dispose(),[]);function o(){i.prefetchQuery({queryKey:l0(e),queryFn:()=>u0(e),staleTime:15e3})}function s(){let t=i.getQueryData(l0(e));if(t){bV(t.command).then(()=>{r.current?.begin(),Z(s0[t.mode])},()=>Z(o0,{duration:7e3}));return}a({onSuccess:()=>r.current?.begin()})}let c=i.getQueryData(l0(e)),l=t?c?s0[c.mode]:`Terminal command copied`:c?c0[c.mode]:`Copy terminal command`;return(0,L.jsx)(wM,{label:l,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":l,title:l,onClick:s,onPointerEnter:o,onFocus:o,className:VD,children:t?(0,L.jsx)(Fm,{size:14,strokeWidth:2.2,className:`text-fg`}):(0,L.jsx)(Lh,{size:14,strokeWidth:1.8})})})}function m0(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 h0(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 g0(e){return`legacy:${e.role}:${e.kind??`message`}:${e.at??``}:${e.text}`}function _0(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??g0(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 v0(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 y0(e,t){let n=e.map(e=>e.message);return e.filter((e,r)=>!v0(n,r,t))}var b0=new Set([`agent`,`follow up`,`interrupt`,`send message`,`spawn agent`,`wait for agents`]),x0=new Set([`poll process`,`wait`]);function S0(e){return(e.split(`__`).pop()||e).replaceAll(`_`,` `).trim()}function C0(e){return S0(e).toLowerCase()}function w0(e){return e.prompt!==void 0||e.agentId!==void 0||e.sendTo!==void 0||e.sendBody!==void 0||e.backgroundState!==void 0&&!O0(e)&&!T0(e)||D0(e)||E0(e)||b0.has(C0(e.name))}function T0(e){return e.backgroundState===`background`&&R0(e)}function E0(e){return e.ask!==void 0&&e.ask.length>0&&e.status!==void 0&&e.status!==`pending`}function D0(e){return e.outputImage!==void 0||e.sentImages!==void 0&&e.sentImages.length>0}function O0(e){return e.backgroundState===`unknown`&&x0.has(C0(e.name))}function k0(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=>!w0(e))?t:null}return e.text.trim()||e.tools.length===0?null:e.tools.every(e=>!w0(e))?e.tools:null}function A0(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 j0(e){if(e.role!==`assistant`||e.kind||e.queued)return null;if(!e.parts?.length)return M0(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 M0(n.tools)}return null}function M0(e){let t=[];for(let n=e.length-1;n>=0&&!w0(e[n]);n--)t.unshift(e[n]);return t.length>0?t:null}function N0(e){if(e.role!==`assistant`||e.kind||e.queued)return null;let t=[],n=e=>{for(let n of e){if(w0(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 P0(e,t){return F0(e,new Set(t))}function F0(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 I0(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 L0(e){let t=[],n=null;return e.forEach((e,r)=>{if(A0(e))return;if(e.queued){t.push({message:e,messageIndex:r});return}let i=k0(e);if(i&&n){n.message=I0(n.message,i,e.at);return}let a=n?N0(e):null,o=a?P0(e,a):e;a&&n&&(n.message=I0(n.message,a,e.at));let s={message:o,messageIndex:r};t.push(s),j0(o)?(s.runStartedAt=o.at,n=s):n=null}),t}function R0(e){return e.status===`completed`||e.status===`failed`||e.status===`cancelled`}function z0(e){let t=B0(e);if(!t)return;let n=t.tools.filter(e=>!T0(e));return n.some(e=>!R0(e))?n.at(-1):void 0}function B0(e){let t=V0(e);if(!t)return;let n=j0(t.message);return n?{tools:n,at:t.message.at}:void 0}function V0(e){for(let t=e.length-1;t>=0;t--)if(!e[t].message.queued)return e[t]}function H0(e){let t=V0(e);if(t)return j0(t.message)?t.runStartedAt??t.message.at:t.message.at}function U0(e){return e.runStartedAt??e.message.at}function W0(e){let t=j0(e);return t?F0(e,new Set(t)):e}function G0(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].message;if(!r.queued){j0(r)&&(t=r);break}}if(!t)return[...e];let n=[];for(let r of e){let e=r.message===t?W0(r.message):r.message;A0(e)||n.push(e===r.message?r:{...r,message:e})}return n}function K0(e){return e.detail?.trim()||void 0}var q0={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 J0(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=q0[i.toLowerCase()];return a?a+(r===-1?``:n.slice(r)):n.charAt(0).toUpperCase()+n.slice(1)}function Y0(e,t,n){let r=t?.trim().replace(/[\\/]+$/,``);if(!r||!fp(r))return e;let i=bp(r);return i?Sp(e.replace(i,``),n?.trim().replace(/[\\/]+$/,``)||/^([A-Za-z]:[\\/]Users[\\/][^\\/]+|\/(?:Users|home)\/[^/]+)(?=[\\/]|$)/.exec(r)?.[1]):e}function X0(e,t,n=op().home){return Y0(Z0(e),t,n)}function Z0(e){let t=C0(e.name),n=K0(e),r=n?` ${n}`:``;return t===`bash`||t===`exec`||t===`run command`?J0(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 ${S0(e.name)||`a tool`}`}var Q0=new Set([`edit`,`multiedit`,`write`,`apply patch`]);function $0(e){let t=new Set;for(let n of e){for(let e of n.edits??(n.edit?[n.edit]:[])){let n=e.file.trim();n&&!e2.test(n)&&t.add(n)}if(n.edit||n.edits?.length)continue;let e=n.detail?.trim();e&&!e2.test(e)&&Q0.has(C0(n.name))&&t.add(e)}return t.size}var e2=/\$\{/;function t2(e,t=0){let n=`Ran ${e} tool ${e===1?`call`:`calls`}`;return t===0?n:`${n}, edited ${t} file${t===1?``:`s`}`}function n2(e){return e>0?`${t2(e)}. Thinking…`:`Thinking…`}function r2(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function i2(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function a2(e,t){let n=r2(e,t);if(n)try{let e=new URL(n);return e.protocol===`https:`||e.protocol===`http:`?e.href:void 0}catch{return}}function o2({directive:e,icon:t,title:n,meta:r,children:i}){return(0,L.jsxs)(`section`,{"data-codex-directive":e.name,className:`min-w-0 ${TY} 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 s2({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 c2({directive:e}){let t=e.attrs,n=r2(t,`display_name`)??r2(t,`skill_name`)??`Artifact template`,r=r2(t,`artifact_kind`),i=r2(t,`skill_name`),a=r2(t,`skill_directory`),[o,s]=(0,I.useState)(!!a);return(0,L.jsxs)(o2,{directive:e,icon:(0,L.jsx)(ph,{size:15}),title:n,meta:r?`${r} template`:`Template`,children:[i&&(0,L.jsx)(s2,{mono:!0,children:i.startsWith(`$`)?i:`$${i}`}),o&&a&&(0,L.jsx)(`img`,{src:mC(`${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 l2({directive:e}){let t=e.attrs,n=r2(t,`file`),r=i2(t,`start`),i=i2(t,`end`)??r,a=i2(t,`priority`),o=n?`${n}${r?`:${r}${i&&i!==r?`-${i}`:``}`:``}`:`Code location unavailable`;return(0,L.jsxs)(o2,{directive:e,icon:(0,L.jsx)(vh,{size:15}),title:r2(t,`title`)??`Review finding`,meta:a===void 0?void 0:`P${a}`,children:[r2(t,`body`)&&(0,L.jsx)(s2,{children:r2(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)(s2,{mono:!0,children:o})]})}var u2={"git-stage":[Sh,`Changes staged`],"git-commit":[nh,`Commit created`],"git-create-branch":[th,`Branch created`],"git-push":[Vh,`Branch pushed`],"git-create-pr":[oh,`Pull request created`]};function d2({directive:e}){let[t,n]=u2[e.name],r=r2(e.attrs,`branch`),i=a2(e.attrs,`url`),a=`${n}${e.attrs.isDraft===!0?` as draft`:``}`;return(0,L.jsx)(o2,{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 f2({directive:e}){let t=r2(e.attrs,`threadId`),n=r2(e.attrs,`pendingWorktreeId`);return(0,L.jsx)(o2,{directive:e,icon:(0,L.jsx)(xh,{size:15}),title:n?`Thread setup queued`:`Thread created`,meta:(t||n)&&(0,L.jsx)(`span`,{className:`font-mono-keep`,children:t??n})})}function p2({directive:e}){let t=r2(e.attrs,`reason`);return(0,L.jsx)(o2,{directive:e,icon:(0,L.jsx)(km,{size:15}),title:`Archive suggested`,meta:t})}function m2(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 h2({directive:e}){let t=e.attrs,n=r2(t,`mode`),r=r2(t,`name`)??`Automation`,i=m2(t.rrule),a=[r,n,r2(t,`status`),i].filter(Boolean).join(` · `);return(0,L.jsx)(o2,{directive:e,icon:(0,L.jsx)(Pm,{size:15}),title:`Automation suggested`,meta:a,children:r2(t,`prompt`)&&(0,L.jsx)(s2,{children:r2(t,`prompt`)})})}function g2({directive:e}){return e.name===`artifact-template`?(0,L.jsx)(c2,{directive:e}):e.name===`code-comment`?(0,L.jsx)(l2,{directive:e}):e.name.startsWith(`git-`)?(0,L.jsx)(d2,{directive:e}):e.name===`created-thread`?(0,L.jsx)(f2,{directive:e}):e.name===`archive`||e.name===`archive-thread`?(0,L.jsx)(p2,{directive:e}):(0,L.jsx)(h2,{directive:e})}var _2;function v2(){return _2??=Cb(async()=>{let{default:e}=await import(`./mermaid.core-Dpi4Z-WK.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)),_2}function y2({source:e}){let t=(0,I.useId)(),[n,r]=(0,I.useState)({}),i=jJ(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 v2().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:`${TY} 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 ${TY} 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 ${TY} bg-panel-2`})}var b2=(0,I.createContext)(null),x2=(0,I.createContext)(null);function S2(){let e=(0,I.useContext)(b2),t=(0,I.useContext)(x2);return e??t}var C2=(0,I.createContext)(null);function w2(e){return e.status===`pending`&&e.backgroundState===`background`}function T2(e){let t=[];for(let n of e)for(let e of n.tools)w2(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 E2(e){return e.map(e=>{if(!e.tools.some(w2))return e;let t=e.tools.filter(e=>!w2(e)),n=e.parts?.map(e=>e.kind===`tools`?{...e,tools:e.tools.filter(e=>!w2(e))}:e).filter(e=>e.kind!==`tools`||e.tools.length>0);return{...e,tools:t,parts:n}})}function D2({slug:e,onStatusApplied:t,onClose:n,virtualized:r=!1,showReturnToQueue:i=!1}){let a=hm(fw(),e);return(0,L.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,L.jsx)(z2,{slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:i}),(0,L.jsx)(O2,{slug:e,virtualized:r}),a&&(0,L.jsx)(gQ,{thread:a,sticky:!0,safeArea:!0,onArchived:t})]})}function O2({slug:e,virtualized:t}){let n=fw(),r=hm(n,e),i=r?.runtime===`running`||r?.runtime===`spawning`,a=f0(e),o=Ew(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)(()=>T2(p),[p]),h=(0,I.useMemo)(()=>E2(p),[p]),g=(0,I.useMemo)(()=>$2(h),[h]),_=(0,I.useMemo)(()=>i?$1(h):void 0,[i,h]),v=_&&_.index>=0?_.index:g,y=(0,I.useMemo)(()=>L0(h),[h]),b=i?B0(y):void 0,x=i?z0(y):void 0,S=x?X0(x,n?.projectDir):void 0,C=i?H0(y):void 0,w=Y1(r),T=(0,I.useMemo)(()=>{let e=i?G0(y):y;return y0(e,e4(e,v,w))},[y,i,v,w]),E=i,D=(0,I.useMemo)(()=>nX(p),[p]),O=(0,I.useMemo)(()=>ZY(p,r?.answersInFlight),[p,r?.answersInFlight]),k=(0,I.useMemo)(()=>hZ(p),[p]),A={thread:r,showWorking:E,registeredDone:CY(r,g>=0?h[g]?.text:void 0),restedCard:RY(r,g>=0?h[g]?.text:void 0),errorVisible:BY(h,r?.providerError)},{answeringForMessage:j}=QX(e,p),M=(0,I.useMemo)(()=>lX(p,r?.questions??[]),[p,r?.questions]),N=(0,I.useMemo)(()=>_X(p,r?.questions??[],{atRest:!i}),[p,i,r?.questions]),P=lu(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],Zx(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)(b2.Provider,{value:e,children:(0,L.jsx)(t1,{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)(L2,{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)(A$,{thread:r,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(r1,{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)(Bh,{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; it refreshes over HTTP each time the thread moves.`:`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)(i3,{}),` Loading…`]}):i?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(i3,{}),` Session starting…`]}):xZ(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:[i4(T.map(e=>e.message),(e,t)=>{let n=T[t].messageIndex;return(0,L.jsx)(z4,{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&&P2(A)!==null&&(0,L.jsx)(vX,{h:F2(A,T.map(e=>e.message))}),re&&(0,L.jsx)(I2,{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)(X4,{policy:r.permPolicy,denies:r.permDenies})}):null,p.some(e=>e.queued)&&(0,L.jsx)(vX,{}),(0,L.jsx)(`div`,{className:`flex flex-col gap-3.5`,children:p.map((e,t)=>e.queued?(0,L.jsx)(z4,{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)(PZ,{slug:e,onTerminal:a,ops:(0,L.jsx)(Z4,{slug:e,transcriptShells:m,className:`px-1 pt-1.5`})})})]})})})}var k2=700,A2=250,j2=(()=>{try{return localStorage.getItem(`frizz.debugScroll`)===`1`}catch{return!1}})();function M2(e){return e?.pendingInteraction===!0}function N2(e){return M2(e)?void 0:e?.pendingAsk}function P2({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`:N2(e)?`pending-ask`:e?.runtime===`perm-prompt`&&!M2(e)?`perm-prompt`:t?`working`:e?.providerError?i?null:`provider-error`:e0(e)?`snooze`:Y1(e)?`resting`:n?`registered-done`:r?`rested`:null}function F2(e,t){return P2(e)===`working`?r4(t):14}function I2({state:e,slug:t,retryText:n,onTerminal:r,liveRuntimeStart:i,liveActivityLabel:a,liveToolRun:o}){let s=e.thread;switch(P2(e)){case`provider-fault`:return(0,L.jsx)(q4,{slug:t,sessionId:s.sessionId,fault:s.providerFault,retryText:n});case`provider-error`:return(0,L.jsx)(VY,{error:s.providerError});case`limit-pause`:return(0,L.jsx)(J4,{slug:t,sessionId:s.sessionId,pause:s.limitPause});case`pending-ask`:return(0,L.jsx)(Q4,{ask:N2(s),onTerminal:r});case`perm-prompt`:return(0,L.jsx)(Y4,{onTerminal:r});case`working`:return(0,L.jsx)(a3,{since:s?.lastUserAt,startedAt:i,activityLabel:a,run:o});case`snooze`:return(0,L.jsx)(n0,{thread:s});case`resting`:return(0,L.jsx)(Q1,{thread:s});case`registered-done`:return(0,L.jsx)(K4,{fenceKind:`done`,body:s.lastFence.body,hints:[]});case`rested`:return(0,L.jsx)(zY,{thread:s});default:return null}}function L2({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=pw(),C=(0,I.useMemo)(()=>L0(r),[r]),w=u?B0(C):void 0,T=u?z0(C):void 0,E=T?X0(T,S):void 0,D=u?H0(C):void 0,O=(0,I.useMemo)(()=>$2(r),[r]),k=(0,I.useMemo)(()=>u?$1(r):void 0,[u,r]),A=k&&k.index>=0?k.index:O,j=Y1(l),M=(0,I.useMemo)(()=>{let e=u?G0(C):C;return y0(e,e4(e,A,j))},[C,u,A,j]),N=u,P=(0,I.useMemo)(()=>_0(M.map(e=>e.message),e4(M,A,j),Z2).map(e=>{let t=M[e.messageIndex];return{...e,messageIndex:t.messageIndex,stampAt:U0(t)}}),[M,A,j]),ee=(0,I.useMemo)(()=>hZ(r),[r]),F=CY(l,O>=0?r[O]?.text:void 0),te=RY(l,O>=0?r[O]?.text:void 0),ne=BY(r,l?.providerError),re={thread:l,showWorking:N,registeredDone:F,restedCard:te,errorVisible:ne},ie=P2(re)!==null,ae=(0,I.useMemo)(()=>F2({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 oX(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)(()=>lX(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=mT({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=LD(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()+A2;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=m0({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),j2&&!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=h0({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()+k2,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)(A$,{thread:l,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(r1,{thread:l,questions:oe.tail,inFlight:a,showSend:s.placedIds.size>0,className:`px-6 pt-5`})]}):n.kind===`questions`?(0,L.jsx)(r1,{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 ${TY} 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)(Bh,{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; it refreshes over HTTP each time the thread moves.`:`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)(hh,{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)(VQ,{at:n.stampAt,host:vZ(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(z4,{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)(I2,{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)(X4,{policy:l.permPolicy,denies:l.permDenies})}):null]}):(0,L.jsx)(VQ,{at:n.message.at,host:vZ(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(z4,{m:n.message,paired:i[n.messageIndex]})})},n.key):null}),(0,L.jsx)(R2,{overlay:x,hidden:ue,onJump:()=>le.scrollToEnd({behavior:`smooth`})})]})}function R2({overlay:e,hidden:t,onJump:n}){return!e||t?null:(0,lt.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)(Am,{size:12}),`Jump to latest`]}),e)}function z2({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1}){let i=hm(fw(),e),a=st({mutationFn:()=>Y.markComplete({slug:e})}),o=Nq(nt({queryKey:[`threadBody`,e],queryFn:()=>Y.threadBody({slug:e})}).data?.markdown??``).trim().length>0;if(!i)return null;let s=i.kind===`session`&&i.foreign!==!0;return(0,L.jsxs)(`header`,{"data-thread-header":!0,className:SZ,children:[(0,L.jsx)(`div`,{className:CZ,children:(0,L.jsxs)(`div`,{className:`min-w-0 leading-tight`,children:[(0,L.jsx)(TQ,{thread:i}),(0,L.jsx)(r0,{at:$T(i),fallbackAt:i.spawnedAt,className:`mt-0.5 block truncate text-[11px] leading-tight text-muted/75`})]})}),(0,L.jsxs)(`div`,{className:wZ,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[s&&(0,L.jsx)(p0,{slug:e}),(0,L.jsx)(BZ,{thread:i,collapse:r,onDoc:o?()=>Vp(`doc`,i.id):void 0,onDone:()=>a.mutate(void 0,{onSuccess:t}),doneBusy:a.isPending,onStatusApplied:t}),n&&(0,L.jsx)(TM,{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)(Hh,{size:15})})]})]})}function B2(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||AQ(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 V2(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||AQ(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 H2(e){return B2(e)!==null}function U2(e){return V2(e)!==null}function W2(e){return e.kind===`event`&&!e.boundary||e.kind===`reasoning`}function G2(e){return W2(e)||H2(e)}function K2(e){return W2(e)||U2(e)}function q2(e){if(W2(e))return!0;let t=B2(e);return t!==null&&!w0(t[t.length-1])}function J2(e){if(W2(e))return!0;let t=V2(e);return t!==null&&!w0(t[0])}function Y2(e){let t=B2(e);return t!==null&&D0(t[t.length-1])}function X2(e){let t=V2(e);return t!==null&&D0(t[0])}function Z2(e,t){let n=Y2(e)||X2(t),r=!n&&G2(e)&&K2(t)&&!(q2(e)&&J2(t));return(n?22:r?6:14)+(e.role===`user`&&t.role!==`user`?3:0)}function Q2(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:t4(e,n.text,t)):(e.tools?.length??0)===0&&t4(e,e.text,t)}function $2(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`&&e[t].kind!==`event`)return t;return-1}function e4(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=>Q2(e,r.has(e))}function t4(e,t,n){return!e.fenceRefused&&!n?!t.trim():SY(t).every(e=>e.kind===`fence`&&e.fenceKind===`awaiting`)}function n4(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`&&!t4(e,n.text,t)):typeof e.text==`string`&&!t4(e,e.text,t)}function r4(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.queued||Q2(n)))return Y2(n)?22:G2(n)&&!q2(n)?6:14+(n.role===`user`?3:0)}return 0}function i4(e,t,n){let r=[],i=null;return e.forEach((e,a)=>{n?.(e,a)||Q2(e)||(i!==null&&r.push((0,L.jsx)(vX,{h:Z2(i,e)},`s${a}`)),r.push(t(e,a)),i=e)}),r}function a4(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 o4(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)(vX,{h:typeof t==`number`?t:t(n)},`vs${n}`)),r.push(e)}),r}var s4={head:!1,tail:!1};function c4(e,t){return n=>e[n-1]?.tail||e[n]?.head?22:t}function l4(e){return{head:D0(e[0]),tail:D0(e[e.length-1])}}function u4(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}):E0(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 d4(e){return e.split(`__`).pop()||e}function f4(e){let t=X.board?.projectDir;return t&&e.startsWith(t+`/`)?e.slice(t.length+1):e}function p4({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=t2(a,$0(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 ${HQ}`,children:[(0,L.jsx)(`span`,{"data-tool-activity-label":!0,title:o,className:`min-w-0 truncate text-muted`,children:o}),(0,L.jsx)(Rm,{"data-tool-activity-chevron":!0,"aria-hidden":`true`,size:13,className:WQ(n)})]}),n&&(0,L.jsx)(`div`,{id:i,className:`mt-1.5 flex flex-col`,children:o4(e.map((e,n)=>(0,L.jsx)(h4,{t:e,startedAt:t},n)),6)}),!n&&(0,L.jsx)(`div`,{id:i,hidden:!0})]})}function m4({tools:e,at:t}){let n=[];for(let t of e){let e=w0(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:o4(n.map((e,n)=>e.exceptional?(0,L.jsx)(`div`,{className:`flex flex-col`,children:o4(e.tools.map((e,n)=>(0,L.jsx)(h4,{t:e,startedAt:t},n)),c4(e.tools.map(e=>l4([e])),6))},`exceptions-${n}`):(0,L.jsx)(p4,{tools:e.tools,at:t},`activity-${n}`)),c4(n.map(e=>l4(e.tools)),6))})}function h4({t:e,startedAt:t}){let n=(0,I.useContext)(b2),r=fw(),i=QE(e,(n?hm(r,n):void 0)?.bgShells??[]);return e.edits&&e.status!==`failed`&&e.status!==`cancelled`?(0,L.jsx)(OJ,{edits:e.edits,meta:(0,L.jsx)(b4,{status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,durationMs:e.durationMs})}):e.command?(0,L.jsx)(O4,{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)(T4,{name:e.name,detail:e.detail,outputImage:e.outputImage,output:e.output,status:e.status,durationMs:e.durationMs}):e.read?(0,L.jsx)(A4,{detail:e.detail,read:e.read,status:e.status,durationMs:e.durationMs}):e.prompt||e.agentId?(0,L.jsx)(M4,{detail:e.detail,prompt:e.prompt,subagentType:e.subagentType,agentId:e.agentId,agentStatus:e.agentStatus,agentElapsedMs:e.agentElapsedMs,status:e.status,durationMs:e.durationMs}):e.sendTo!==void 0||e.sendBody!==void 0?(0,L.jsx)(P4,{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)(E4,{images:e.sentImages??[],files:e.sentFiles??[],caption:e.caption,status:e.status,durationMs:e.durationMs}):e.todos?(0,L.jsx)(QJ,{todos:e.todos,note:e.input,meta:(0,L.jsx)(b4,{status:e.status,durationMs:e.durationMs})}):E0(e)?(0,L.jsx)(g4,{ask:e.ask??[],askAnswers:e.askAnswers}):e.input||e.output?(0,L.jsx)(O4,{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)(w4,{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 g4({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=E$(e,t?.[n]);return(0,L.jsx)(nZ,{question:r.question,settled:{chosenIdxs:r.chosenIdxs,text:r.text}},n)})})}function _4({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 v4(e,t,n){let[r,i]=(0,I.useState)(()=>Date.now()),a=YE(e,t),o=XE(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(JE-(Date.now()-e),0));return()=>clearTimeout(t)},[a,o,n]),o}function y4({status:e,backgroundState:t,liveBackgroundState:n,startedAt:r}){let i=v4(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:gD}):qE(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 b4({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:$E(i),c=[o,s].filter(Boolean).join(` · `);return(0,L.jsx)(_4,{tone:e===`failed`?`frizz-tool-failed`:e===`cancelled`?`text-amber-400`:`text-muted/55`,title:c,label:a,duration:s})}function x4(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 S4(e,t,n){let r=t&&t!==X.board?.projectDir?`in ${f4(t)}`:void 0;return[e,t?r:n!==void 0&&!e?.includes(String(n))?`session ${n}`:void 0].filter(Boolean).join(` · `)||void 0}function C4(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.includes(`…`)}function w4({name:e,detail:t,count:n,status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,cwd:s,sessionId:c,durationMs:l,startedAt:u}){let d=S4(t,s,c),f=d?f4(d):void 0,p=t&&C4(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)(y4,{status:r,backgroundState:i,liveBackgroundState:a,startedAt:u}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:d4(e)}),f&&(p?(0,L.jsx)(`span`,{className:`min-w-0 truncate`,onClick:e=>e.stopPropagation(),children:(0,L.jsx)(DJ,{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)(b4,{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 T4({name:e,detail:t,outputImage:n,output:r,status:i,durationMs:a}){let o=t?f4(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:d4(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)(b4,{status:i,durationMs:a})})]});return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(V4,{path:n,hideCaption:!0,altText:o?`${d4(e)}: ${o}`:d4(e),header:s}),r&&(0,L.jsx)(`pre`,{className:`frizz-bash frizz-bash-body frizz-bash-output-body mt-1.5`,children:r})]})}function E4({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)(b4,{status:r,durationMs:i}),(0,L.jsx)(Rm,{"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)(V4,{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)(H4,{path:e},`f${t}`))}),n&&(0,L.jsx)(`div`,{className:`max-w-[65%] text-[12px] leading-snug text-muted`,children:n})]})})]})}var D4=16;function O4({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=x4(i,d,l),b=(0,I.useMemo)(()=>e.split(`
314
- `).length,[e]),x=b>D4,S=(0,I.useMemo)(()=>n?n.split(`
315
- `).length:0,[n]),C=S>D4,w=S4(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`} `:``}${d4(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)(y4,{status:i,backgroundState:a,liveBackgroundState:o,startedAt:d}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:d4(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)(b4,{status:i,backgroundState:a,liveBackgroundState:o,exitCode:s,durationMs:y}),T&&(0,L.jsx)(Rm,{"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)(KJ,{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 k4=16;function A4({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>k4,d=e?f4(e):void 0,f=e&&C4(e)?e:void 0;return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(EJ,{className:`frizz-bash-header`,controls:c,expanded:i,label:`${i?`Collapse`:`Expand`} Read${e?`: ${e}`:``}`,onToggle:()=>a(e=>!e),meta:(0,L.jsx)(b4,{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)(DJ,{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)(KJ,{text:t,language:KS(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 j4=16;function M4({detail:e,prompt:t,subagentType:n,agentId:r,agentStatus:i,agentElapsedMs:a,status:o,durationMs:s}){let[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(!1),f=(0,I.useId)(),p=t||`Initial prompt unavailable.`,m=(0,I.useMemo)(()=>p?p.split(`
317
- `).length:0,[p]),h=m>j4,g=S2(),_=fw(),v=g?hm(_,g):void 0,y=!i&&r?(v?.subAgents??[]).find(e=>e.id===r):void 0,b=y?.state===`running`,x=!!(g&&r),S=e??`sub-agent`,C=kQ(n),w=WE(),T=FQ({agentStatus:i,agentElapsedMs:a,liveState:y?.state,liveElapsedMs:y?.startedAt?Math.max(w-Date.parse(y.startedAt),0):void 0,status:o,durationMs:s}),E=b?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--agent`,"data-running-indicator":`subagent-disclosure`}):y?.state===`stale`?(0,L.jsx)(`span`,{className:fD,title:pD}):y?.state===`rested`?(0,L.jsx)(`span`,{className:mD,title:hD}):null;function D(){!g||!r||Hp(g,r,{label:S,subagentType:n,startedAt:y?.startedAt})}return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(EJ,{className:`frizz-bash-header`,controls:f,expanded:c,label:`${c?`Collapse`:`Expand`} Agent dispatch: ${S}`,onToggle:()=>l(e=>!e),meta:(C||T)&&(0,L.jsxs)(L.Fragment,{children:[C&&(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: ${C}`,children:C}),C&&T&&(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:`·`}),T&&(0,L.jsx)(_4,{tone:T.tone===`failed`?`frizz-tool-failed`:`text-muted/55`,title:T.title,label:T.label,duration:T.duration})]}),children:[E&&(0,L.jsx)(`span`,{className:`frizz-tool-mark -mr-1 flex w-[9px] shrink-0 justify-center`,children:E}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Agent`}),x?(0,L.jsx)(`button`,{type:`button`,"aria-label":`Open sub-agent transcript: ${S}`,title:`Open sub-agent transcript`,onClick:D,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:S}):(0,L.jsx)(`span`,{className:`min-w-[4rem] flex-1 truncate text-[11.5px] text-muted`,title:S,children:S})]}),(0,L.jsx)(`div`,{id:f,hidden:!c,children:c&&(0,L.jsxs)(L.Fragment,{children:[p&&(0,L.jsx)(`pre`,{className:`frizz-bash-body${h&&!u?` frizz-bash-clamp`:``}`,children:p}),h&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:u?`Collapse`:`Show all ${m} lines`})]})})]})}function N4(e,t){return t===`shutdown_request`?`Shutdown`:t===`codex_followup`?`Followed up`:e===`main`?`Reported`:`Steered`}function P4({to:e,summary:t,body:n,type:r,dispatchId:i,targetLabel:a,status:o,durationMs:s,at:c}){return(0,I.useContext)(b2)===null?(0,L.jsx)(I4,{to:e,summary:t,body:n,type:r,status:o,durationMs:s}):(0,L.jsx)(t3,{to:e,type:r,dispatchId:i,targetLabel:a,at:c})}var F4=16;function I4({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=jJ(Kq(n)),f=(0,I.useMemo)(()=>n.split(`
318
- `).length,[n]),p=f>F4,m=!!n.trim(),h=N4(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)(b4,{status:i,durationMs:a}),m&&(0,L.jsx)(Rm,{"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 L4({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)(()=>dR(e,[...i.keys()]),[e,i]).map((e,t)=>{let a=e.token?i.get(e.token):void 0;if(!a)return(0,L.jsx)(UX,{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:iR(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 R4({text:e,rawText:t,queued:n,deliveryUnconfirmed:r,deliveryId:i,sourceId:a}){let o=(0,I.useContext)(b2),s=sZ(o),{unqueue:c,pending:l}=dZ(o),u=!!(n&&i&&o&&s),d=fZ(n?o:null),{deliverNow:f,pending:p}=pZ(o),m=!!(n&&o&&d),{prose:h,attachments:g}=(0,I.useMemo)(()=>tR(e),[e]),_=(0,I.useMemo)(()=>vR(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)(L4,{body:_.body,items:_.items}):(0,L.jsx)(UX,{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)(hh,{size:15,strokeWidth:2.2,className:`animate-spin`}):(0,L.jsx)(jm,{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)(V4,{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)(H4,{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 z4=(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=LG(),[p,m]=(0,I.useState)(!1);if(e.providerError)return(0,L.jsx)(VY,{error:e.providerError});if(e.kind===`event`)return(0,L.jsx)(n3,{text:e.text,boundary:e.boundary,sourceId:e.sourceId,at:e.at});if(e.kind===`reasoning`)return(0,L.jsx)(r3,{text:e.text,sourceId:e.sourceId});let h=AQ(e);if(h)return(0,L.jsx)($4,{call:h,sourceId:e.sourceId,at:e.at});if(e.role===`user`){let t=mZ(e).replace(/\r\n?/g,`
319
- `),i=r===void 0?qY(t):r;if(i)return(0,L.jsx)(WX,{answers:i,queued:e.queued,sourceId:e.sourceId});let a=e.wake?jl(t):void 0;return a?(0,L.jsx)(IX,{bump:a,sourceId:e.sourceId,at:e.at}):e.wake?(0,L.jsx)(wX,{steer:e.wakeSteer,text:t,sourceId:e.sourceId,at:e.at,wrap:n}):e.peerFrom?(0,L.jsx)(e3,{from:e.peerFrom,unnamed:e.peerUnnamed,dispatchId:e.peerDispatchId,sourceId:e.sourceId,at:e.at}):(0,L.jsx)(R4,{text:t,rawText:e.text,queued:e.queued,deliveryUnconfirmed:e.deliveryState===`unconfirmed`,deliveryId:e.deliveryId,sourceId:e.sourceId})}let g=[],_=[],v=(e,t=s4)=>{g.push(e),_.push(t)},y={n:-1},b={drawn:!1},x=[],S=new Set,C=(r,i)=>{for(let[a,l]of SY(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)(K4,{fenceKind:l.fenceKind,body:l.body,hints:l.hints,wrap:n,notAfter:d},`${i}-f${a}`));continue}for(let[e,r]of nY(l.text).entries()){if(r.kind===`prose`){for(let[t,o]of eR(r.text).entries()){let r=`${i}-${a}-p${e}-${t}`;v(o.kind===`image`?(0,L.jsx)(V4,{path:o.path},r):o.kind===`file`?(0,L.jsx)(H4,{path:o.path},r):o.kind===`visualization`?(0,L.jsx)(G4,{file:o.file},r):o.kind===`directive`?(0,L.jsx)(g2,{directive:o.directive},r):o.kind===`mermaid`?(0,L.jsx)(y2,{source:o.source},r):(0,L.jsx)(B4,{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)(n1,{q:l},`${i}-${a}-q${e}`));continue}if(s&&hX(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)(nZ,{raw:r.text,questionKind:r.questionKind,danger:r.danger,interactive:u,wrap:n},`${i}-${a}-q${e}`))}}};if(e.parts&&e.parts.length>0)a4(e.parts).forEach((t,r)=>{if(t.kind===`tools`){if(i)return;let a=u4(t.tools);a.length&&v((0,L.jsx)(m4,{tools:a,dense:n,at:e.at},`t${r}`),l4(a))}else C(t.text,`x${r}`)});else{if(!i){let t=u4(e.tools);t.length>0&&v((0,L.jsx)(m4,{tools:t,dense:n,at:e.at},`tools`),l4(t))}C(e.text,`leg`)}return d!==void 0&&l&&!b.drawn&&!e.fenceRefused&&G1(l,{notAfter:d})&&v((0,L.jsx)(Q1,{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:[o4(g,c4(_,14)),p&&t&&x.length>0?(0,L.jsx)(oZ,{blocks:x,answering:t,onClose:()=>m(!1)}):null]}))});function B4({md:e,wrap:t}){let n=Kq(e),r=jJ(n),i=(0,I.useRef)(null);return WJ(i,n),n?(0,L.jsx)(`div`,{ref:i,className:`md-body${t?` ${wY}`:``}`,dangerouslySetInnerHTML:r}):null}function V4({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=_p(e);return(0,L.jsx)(dq,{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:mC(e),alt:n??o,"data-local-path":e,"data-local-image":`true`,onError:()=>a(!0),className:`cursor-pointer ${mq}`})})}function H4({path:e}){let t=_p(e);return(0,L.jsxs)(`button`,{type:`button`,className:`local-file-action inline-flex max-w-full items-center gap-1.5 ${TY} 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)($m,{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 U4={"--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 W4(){let e=getComputedStyle(document.documentElement),t=Object.fromEntries(Object.entries(U4).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 G4({file:e}){let t=(0,I.useContext)(b2),n=(0,I.useRef)(null),[r,i]=(0,I.useState)(360),[a,o]=(0,I.useState)(null),s=t?`${tf()}/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:`${TY} 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 ${TY} 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(W4(),`*`),className:`block w-full border-0 bg-transparent`,style:{height:r}})}function K4({fenceKind:e,body:t,hints:n,wrap:r,notAfter:i}){let a=Kq(t),o=(0,I.useContext)(b2),s=(0,I.useContext)(C2),c=fw(),l=o?hm(c,o):void 0,u=l?UZ(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)(MY,{icon:Fm,label:`Done`,children:[a&&(0,L.jsx)(GJ,{className:`md-body${r?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:a}),p&&(0,L.jsx)(PY,{children:(0,L.jsx)(yQ,{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&&Y1(l)?null:(0,L.jsx)(Q1,{thread:l,fence:{body:t,hints:n},notAfter:i})}function q4({slug:e,sessionId:t,fault:n,retryText:r}){let[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(!1),c=Ve(),l=CV[n.backend],u=t=>{s(!0),eW(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)(MY,{"data-provider-fault":!0,tone:`danger`,icon:fh,label:`${l} sign-in required`,children:[(0,L.jsx)(`span`,{className:NY,children:`The provider rejected this session's credential. Sign in, then retry.`}),(0,L.jsxs)(PY,{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:LY,children:`Sign in`})]}),i&&(0,L.jsx)(EV,{backend:n.backend,onClose:()=>a(!1),onAuthed:()=>a(!1)})]})}function J4({slug:e,sessionId:t,pause:n}){let r=n.backend===`acp`?`The agent`:CV[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)(MY,{"data-limit-pause":!0,tone:`caution`,icon:ch,label:`Paused by the ${r} ${i}`,children:[(0,L.jsx)(`span`,{className:NY,children:n.autoResume?n.resumesAt?`Continuing automatically at ${FE(n.resumesAt)}.`:`Continuing automatically once the window resets.`:`Continue it whenever you have capacity again.`}),(0,L.jsx)(PY,{children:(0,L.jsx)(`button`,{onClick:()=>{o(!0),eW(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 ${LY}`,children:`Continue now`})})]})}function Y4({onTerminal:e}){return(0,L.jsxs)(MY,{tone:`attention`,icon:fh,label:`Permission approval`,children:[(0,L.jsx)(`span`,{className:NY,children:`The agent is waiting on your approval — respond in your external terminal.`}),(0,L.jsx)(PY,{children:(0,L.jsx)(`button`,{onClick:()=>e(),onMouseDown:e=>e.preventDefault(),className:LY,children:`Copy terminal command`})})]})}function X4({policy:e,denies:t}){let n=[e.tool,e.command].filter(Boolean).join(`: `);return(0,L.jsxs)(MY,{tone:`caution`,icon:Bh,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:NY,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 Z4({slug:e,className:t=`px-4 pb-2 pt-1`,includeAgents:n=!0,transcriptShells:r=[],parentAgentId:i}){let a=hm(fw(),e),o=a?.subAgents??[],s=n?i?TD(o,i):o:[],c=i?[...r]:kD(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=kw(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:[DD(s,`sheet`).map((t,n)=>(0,L.jsx)(AD,{kind:`AGENT`,label:t.label,state:t.state,density:`sheet`,depth:t.displayDepth??t.depth,startedAt:t.startedAt,onOpen:t.id?()=>Hp(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:DM(e,t)},`a${n}`)),DD(c,`sheet`).map((t,n)=>(0,L.jsx)(AD,{kind:`SHELL`,label:t.label,state:t.state,density:`sheet`,startedAt:t.startedAt,counter:t.id?vD(h.get(t.id)):void 0,counterTitle:`Lines of output so far — open the row to read them`,onOpen:t.id&&!t.outputUnavailable?()=>Up(e,t.id,{label:t.label,startedAt:t.startedAt}):void 0,onDismiss:DM(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)(AD,{kind:`GITHUB`,label:e.target,state:`running`,density:`sheet`,startedAt:e.createdAt,counter:e.subject===`issue`?bD(e.issue):yD(e.github),counterTone:e.github?.checks===`failing`?`danger`:void 0,counterTitle:e.subject===`issue`?e.issue?`${e.target} — ${N1(e.issue)}`:void 0:e.github?`${e.target} — ${w1(e.github)}`:void 0,onOpen:()=>window.open(rW(e.target,e.subject===`issue`?`issue`:`pull`)??`https://github.com/${e.target.replace(`#`,e.subject===`issue`?`/issues/`:`/pull/`)}`,`_blank`,`noreferrer,noopener`)},e.id)),(0,L.jsx)(zQ,{links:u})]})}function Q4({ask:e,onTerminal:t}){return(0,L.jsxs)(MY,{tone:`attention`,icon:Gm,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)(PY,{children:(0,L.jsxs)(`button`,{onClick:()=>t(),onMouseDown:e=>e.preventDefault(),className:LY,children:[(0,L.jsx)(fh,{size:12,className:`shrink-0 ${yZ}`}),`Copy terminal command`]})})]})}function $4({call:e,sourceId:t,at:n}){let r=S2(),i=e.detail??`sub-agent`,{tail:a}=MQ(e),o=!!(r&&e.agentId);return(0,L.jsxs)(yX,{icon:Nm,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:_D.AGENT,"aria-label":`${_D.AGENT}: ${i}`,onClick:()=>Hp(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 e3({from:e,unnamed:t,dispatchId:n,sourceId:r,at:i}){let a=S2(),o=!!(a&&n),s=t?void 0:e,c=t&&e?`${_D.AGENT} — ${e}`:_D.AGENT;return s===void 0?(0,L.jsx)(yX,{icon:Nm,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":`${_D.AGENT}${e?`: ${e}`:``}`,onClick:()=>Hp(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)(yX,{icon:Nm,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:_D.AGENT,"aria-label":`${_D.AGENT}: ${s}`,onClick:()=>Hp(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 t3({to:e,type:t,dispatchId:n,targetLabel:r,sourceId:i,at:a}){let o=S2(),s=N4(e,t),c=e===`main`?void 0:r??e,l=!!(o&&n);return(0,L.jsxs)(yX,{icon:Nm,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:_D.AGENT,"aria-label":`${_D.AGENT}: ${c}`,onClick:()=>Hp(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 n3({text:e,boundary:t,sourceId:n,at:r}){return t?(0,L.jsx)(yX,{icon:t===`wake`?Lh: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:HQ,children:e})}function r3({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:`${HQ} 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)(Rm,{"aria-hidden":`true`,size:13,className:WQ(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)(B4,{md:e,wrap:!0})})]})}function i3(){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 a3({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=nD(Math.max(0,o-a)),f=(0,I.useMemo)(()=>u4([...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 ${HQ}`,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??n2(p)}),m&&(0,L.jsx)(Rm,{"data-working-chevron":!0,"aria-hidden":`true`,size:13,className:WQ(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:o4(f.map((e,t)=>(0,L.jsx)(h4,{t:e,startedAt:r?.at},t)),6)}),m&&!c&&(0,L.jsx)(`div`,{id:u,hidden:!0})]})}function o3(){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 s3({id:e,slug:t,depth:n,widthDepth:r,initiallyOpen:i}){let{shown:a,close:o,closingRef:s}=gm(e,i===!0),[c,l]=(0,I.useState)(i===!0),u=(0,I.useRef)(null),d=(0,I.useRef)(null),f=en(X),p=[...f.drawers].reverse().find(e=>!e.closing)?.id===e,m=o3(),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 _=fw(),v=Wd(_,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 zG({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)(()=>(Ld(e,()=>{(u.current?.querySelector(`[data-dialog-initial-focus]`)??u.current)?.focus({preventScroll:!0})}),()=>Ld(e,null)),[e]),(0,L.jsx)(bL,{modal:m,open:!0,onOpenChange:e=>{e||o()},children:(0,L.jsxs)(EL,{children:[(0,L.jsx)(OL,{className:`${Cp} ${a?`opacity-100`:`opacity-0`}`,style:{zIndex:50+n*2}}),(0,L.jsxs)(ML,{ref:u,"aria-modal":m||void 0,"aria-describedby":void 0,tabIndex:-1,onEscapeKeyDown:t=>{if(t.target instanceof Element&&t.target.closest(`[data-claims-escape]`)){t.preventDefault();return}if(X.drawers.at(-1)?.id!==e){t.preventDefault();return}cz(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 ${wp} ${a?`translate-x-0`:`translate-x-full`}`,style:{zIndex:51+n*2,width:Ep(r),viewTransitionName:f.vtReturnTarget===t?`thread-chat`:void 0},children:[(0,L.jsx)(LL,{className:`sr-only`,children:v.kind===`found`?`Thread: ${HT(v.thread)}`:`Thread: ${t}`}),c&&v.kind===`found`?(0,L.jsx)(D2,{slug:t,onStatusApplied:o,onClose:o,virtualized:!0}):c&&v.kind===`missing`?(0,L.jsx)(c3,{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 c3({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 ${Uh} 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 l3({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=Dw(t,n),f=pw(),p=(0,I.useMemo)(()=>d.data?.messages??[],[d.data]),m=d.data?.state,h=m===`running`,g=(0,I.useMemo)(()=>T2(p),[p]),_=(0,I.useMemo)(()=>E2(p),[p]),v=(0,I.useMemo)(()=>L0(_),[_]),y=h?B0(v):void 0,b=h?z0(v):void 0,x=b?X0(b,f):void 0,S=h?H0(v):void 0,C=(0,I.useMemo)(()=>h?G0(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)(bm,{id:e,depth:o,widthDepth:s,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Wh,{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)(x2.Provider,{value:t,children:(0,L.jsxs)(`div`,{"data-transcript-column":!0,className:`flex flex-col px-6 py-5`,children:[i4(C.map(e=>e.message),(e,t)=>(0,L.jsx)(z4,{m:e},t)),w&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(vX,{h:r4(C.map(e=>e.message))}),(0,L.jsx)(a3,{since:a,startedAt:S,activityLabel:x,run:y})]})]})})}),(0,L.jsx)(u3,{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)(Z4,{slug:t,parentAgentId:n,transcriptShells:g,className:e})})]})})}function u3({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)(d3,{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)(IR,{value:c,onChange:l,onSubmit:h,surface:`subAgentComposer`,placeholder:`Steer this sub-agent…`,busy:u||f,footer:(0,L.jsx)(d3,{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)(d3,{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 d3({subagentType:e}){let t=OQ(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 ${VR}`,children:(0,L.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 truncate`,children:t})})}var f3=`font-mono-keep overflow-x-auto whitespace-pre-wrap break-words ${TY} border border-border bg-bg/75 px-4 py-2.5 text-[12px] leading-relaxed text-fg/85`;function p3({id:e,slug:t,shellId:n,label:r,startedAt:i,depth:a,widthDepth:o}){let s=(0,I.useRef)(null),c=Ow(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=oD(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 bV(u),Z(`Command copied`)}catch{Z(`Could not copy command`)}}return(0,L.jsx)(bm,{id:e,depth:a,widthDepth:o,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Wh,{title:r,icon:(0,L.jsx)(Lh,{"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)(Ym,{"aria-hidden":!0,size:11}),` Copy`]})]}),u?(0,L.jsx)(KJ,{"data-background-shell-command":!0,text:u,language:`bash`,className:f3}):(0,L.jsx)(`pre`,{"data-background-shell-command":!0,className:f3,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 ${TY} 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 ${TY} 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 m3(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 h3={paddingBottom:`max(0.75rem, env(safe-area-inset-bottom))`};function g3({path:e}){return(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{Y.openLocalFile({path:e}).then(async e=>{e.action===`copy`&&(await bV(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)(Zm,{size:12,"aria-hidden":`true`}),` Open`]})}function _3({source:e}){return(0,L.jsx)(KJ,{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 v3({id:e,path:t,title:n,depth:r,widthDepth:i}){let a=hw(t),o=nt({...SC(t),refetchInterval:a?!1:CC}),s=o.data?.path??t,{front:c,body:l}=m3(o.data?.markdown??``),u=Kq(l,{baseDir:bC(s),asDocument:!0}),d=jJ(u),f=(0,I.useRef)(null);return WJ(f,u),(0,L.jsx)(bm,{id:e,depth:r,widthDepth:i,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Wh,{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)(_3,{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:h3,children:(0,L.jsx)(g3,{path:s})})]})})}function y3({id:e,slug:t,title:n,depth:r,widthDepth:i}){let a=nt({queryKey:[`threadBody`,t],queryFn:()=>Y.threadBody({slug:t})}),o=en(X);(0,I.useEffect)(()=>{a.refetch()},[o.board]);let s=xZ(hm(o.board,t)),c=iH(),l=rH.adopt(c,t),[u,d,f]=oH(l),p=st({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)=>{tH.get(l)||d(t),Z(`Start failed: ${e.message.slice(0,80)}`)}}),m=Kq(Nq(a.data?.markdown??``)),h=jJ(m);return(0,L.jsx)(bm,{id:e,depth:r,widthDepth:i,widthOffset:1,subagentParent:t,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Wh,{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)(IR,{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 b3(){let e=en(X),t=fw();(0,I.useEffect)(()=>{function e(e){if(e.key===`Escape`&&!(e.target instanceof Element&&e.target.closest(`.xterm`))){if(sz()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(X.showPalette)X.showPalette=!1;else if(X.showNewThread)X.showNewThread=!1;else if(X.showGithubPicker)Pp();else if(X.showSettings)Md()||(X.showSettings=!1);else if(X.drawers.length>0){let e=X.drawers[X.drawers.length-1];Id(e.id)||X.drawers.pop()}else X.filePanels.length>0&&tm()}}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)(s3,{id:e.id,slug:e.slug,depth:r,widthDepth:i,initiallyOpen:e.routed},e.id):e.kind===`subagent`?(0,L.jsx)(l3,{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)(p3,{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)(v3,{id:e.id,path:e.path??e.slug,title:e.label??e.slug,depth:r,widthDepth:i},e.id):(0,L.jsx)(y3,{id:e.id,slug:e.slug,depth:r,widthDepth:i,title:(()=>{let n=hm(t,e.slug);return n?HT(n):e.slug})()},e.id);return(0,L.jsx)(Kh,{label:`this drawer`,resetKeys:[e.kind,e.slug,e.subId,e.path],fallback:(t,n)=>(0,L.jsx)(Zh,{id:e.id,depth:r,widthDepth:i,error:t,onRetry:n}),children:a},e.id)})})}function x3(e){return(e.tools??[]).some(e=>e.name===`mcp__frizz__done`&&e.status===`completed`)}function S3(e){let t=nY(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 C3(e){let t=new Map,n=[];for(let r=0;r<e.length;r++){let i=S3(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 w3(e,t,n){return aY(e.text)?!n.has(t):x3(e)?!0:e.wake===!0}function T3(e){return e.wake===!0}function E3(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 D3(e){return e.open<0||e.tools<1&&e.steps<1?!1:e.resumed||e.open!==e.close}function O3(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 k3(e){return DD(e,`card`).length>0}function A3({slug:e,subAgents:t,className:n=`px-1 pt-1.5`}){let r=DD(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)(AD,{kind:`AGENT`,label:t.label,state:t.state,density:`card`,depth:t.depth,startedAt:t.startedAt,parentSlug:e,onOpen:t.id?()=>Hp(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:DM(e,t)},t.id??`${t.startedAt}-${n}`))})}var j3=320;function M3(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 N3(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 P3=0,F3=``;function I3(){P3++===0&&(F3=document.documentElement.style.overflowAnchor,document.documentElement.style.overflowAnchor=`none`)}function L3(){P3>0&&--P3===0&&(document.documentElement.style.overflowAnchor=F3)}function R3({thread:e,onSnooze:t,onSnoozeFailed:n}){return(0,L.jsx)(Q1,{thread:e,onSnooze:t,onSnoozeFailed:n})}function z3(){let e=fw(),t=nE(mw(e?.threads??[]).filter(rE),en(RT).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=BU(),b=e=>v(e.id)||zU(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=N3(e);h.current=t?{kind:`top`,slug:t}:null}else{let t=M3(e);h.current=t?{kind:`hold`,...t}:null}f.current.add(e),d.current.delete(e),_(e=>e+1)},j3);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}I3();let n=()=>{let t=jp(e.slug);t!==null&&Math.abs(zd()-t)>.5&&window.scrollTo({top:t,left:0,behavior:`auto`})};n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n(),L3()})})},[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)(B3,{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)(H3,{slug:e.id,leaving:v(e.id),children:(0,L.jsx)(G3,{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)(NU,{}),(0,L.jsx)(cH,{autoFocus:!0})]}):x.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-2 pt-2`,children:[(0,L.jsx)(dh,{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 B3({board:e}){let t=e?.errorItems??[],n=e?.errors??[];return t.length===0&&n.length===0?null:(0,L.jsxs)(`div`,{className:`mb-6 ${TY} 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)(V3,{file:e.file})]},t)):n.slice(0,3).map((e,t)=>(0,L.jsx)(`div`,{className:`truncate`,title:e,children:e},t))]})}function V3({file:e}){let t=st({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 H3({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 U3({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)(yX,{icon:Bm,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 W3({toolCount:e,onExpand:t}){let n=e>0?`${e} tool call${e===1?``:`s`}`:``;return(0,L.jsxs)(yX,{icon:Bm,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 G3=(0,I.memo)(function({thread:e,leaving:t,frozen:n,onResolve:r,onUnresolve:i}){let a=en(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=f0(e.id),T=Ew(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)(()=>$2(A),[A]),M=e=>j>=0&&e<j,N=Y1(e),P=e=>M(e)||e===j&&N,ee=(0,I.useMemo)(()=>nX(A),[A]),F=(0,I.useMemo)(()=>gZ(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`||Q2(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)(()=>C3(A),[A]),ie=(0,I.useMemo)(()=>A.map((e,t)=>{if(!e||e.queued||Q2(e,P(t)))return{skip:!0};if(e.boundary===`rest`)return{skip:!0,closes:!0};let n=AQ(e),r=n?0:e.tools.length;return{text:n4(e,P(t)),tools:r,countable:n4(e,P(t))||r>0||n!==void 0||e.kind!==void 0,survives:w3(e,t,re),opens:T3(e),completion:e.boundary===`wake`||n!==void 0}}),[A,re]),ae=(0,I.useMemo)(()=>E3(ie,F+1),[ie,F]),{kept:oe,middle:se}=(0,I.useMemo)(()=>O3(ae),[ae]),ce=(0,I.useMemo)(()=>oe.filter(D3),[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=qx(A,f,F),fe=(0,I.useMemo)(()=>A.slice(de),[A,de]),pe=(0,I.useMemo)(()=>L0(fe).map(e=>({...e,messageIndex:e.messageIndex+de})),[fe,de]),me=e.runtime!==`running`&&e.runtime!==`spawning`,he=(0,I.useMemo)(()=>_X(A,e?.questions??[],{atRest:me}),[me,A,e?.questions]),ge=(0,I.useMemo)(()=>{let t=[],n=new Map,r=A.length-1,i=(e?.questions??[]).filter(e=>!he.placedIds.has(e.id));for(let[e,a]of oX(A,i,{atRest:me})){if(e>=r){t.push(...a);continue}let i=n.get(e);i?i.push(...a):n.set(e,[...a])}return{byAnchor:n,tail:t}},[me,A,he.placedIds,e?.questions]),_e=lu(e.spawnedAt),ve=(0,I.useMemo)(()=>lX(A,e?.questions??[]),[A,e?.questions]),ye=(0,I.useMemo)(()=>ZY(A,e.answersInFlight),[A,e.answersInFlight]),be=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=()=>{eS(t,e.anchor,e=>{e!==0&&window.scrollBy({top:e,left:0,behavior:`auto`})});let n=0;return eS(t,e.anchor,e=>{n=e}),n},r=n();if(tS({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,L3())})}))},[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,L3()))},[D?.transcriptKey]),(0,I.useEffect)(()=>()=>{b.current&&(b.current=!1,L3())},[]);let xe=e=>{let t=Qx(v.current);!e||!t||(b.current||(b.current=!0,I3()),y.current={anchor:t,targetStartId:e})},Se=async()=>{if(m||!be)return;let t=Kx(A,de),n=t!==null&&A[t]?.role===`user`?t:null;if(n!==null){let e=A[n].sourceId;xe(e),p(e??null);return}let r=D?.beforeCursor;if(!r){if(de>0){let e=A[0]?.sourceId;xe(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;xe(a);let o=Zx(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)}}},Ce=st({mutationFn:()=>Y.markComplete({slug:e.id})}),{answeringForMessage:we,answerable:Te,anyAnswered:Ee,sendAnswers:De,sendMessage:Oe}=QX(e.id,A,()=>{document.activeElement?.blur(),r(e.id)},{scrollToBottom:!1,onSendFailed:()=>i(e.id)}),ke=(0,I.useMemo)(()=>{let e=XX(A);return e!==-1&&mX(A[e].text,ve.get(e)??[])},[A,ve]),Ae=_e&&(Te&&!ke||Ee),je=(0,I.useCallback)(()=>r(e.id),[r,e.id]),Me=(0,I.useCallback)(()=>i(e.id),[i,e.id]),Ne=(0,I.useMemo)(()=>({dismiss:je,cancel:Me}),[je,Me]);return(0,L.jsx)(b2.Provider,{value:e.id,children:(0,L.jsx)(C2.Provider,{value:Ne,children:(0,L.jsx)(t1,{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(!Ee)return;let t=e.target;t instanceof HTMLButtonElement||t instanceof HTMLAnchorElement||t instanceof HTMLTextAreaElement&&t.value.trim()||SR({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(),De())},"data-vt-chat":!0,className:`flex flex-col min-w-0 max-w-full ${TY} 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?TY:`${EY} border-b border-border/60`}`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(TQ,{thread:e,className:`leading-snug`}),(0,L.jsx)(r0,{at:$T(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)(p0,{slug:e.id}),(0,L.jsx)(BZ,{thread:e,collapsed:o,onCollapse:()=>s(e=>!e),expand:!0,onDone:()=>Ce.mutate(void 0,{onSuccess:()=>r(e.id),onError:()=>d(!1)}),doneBusy:Ce.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 ${Ae?`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:[be&&(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 Se(),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=[...ge.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)(vX,{h:14},`qa-space-${t}`)),n.push((0,L.jsx)(r1,{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||Q2(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)(vX,{h:14},`middle-runs-space`)),n.push((0,L.jsx)(U3,{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&&!aY(t.text)&&!x3(t)&&w3(t,i,re);if(d!==void 0&&i===d.waker){r!==null&&n.push((0,L.jsx)(vX,{h:r&&K2(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)(z4,{m:t,dense:!0})},e)),r=G2(t);return}if(f&&!h){if(!p&&!m&&!w3(t,i,re)||(!p&&u!==void 0&&!o.has(u)&&(r!==null&&n.push((0,L.jsx)(vX,{h:14},`im-space-${u}`)),n.push((0,L.jsx)(W3,{toolCount:d.tools,onExpand:()=>l(!0)},`intermediate-summary-${u}`)),r=!1,o.add(u)),!n4(t,P(i))))return;r!==null&&n.push((0,L.jsx)(vX,{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)(z4,{m:t,dense:!0,textOnly:!0,answering:_e?we(t):void 0,paired:ee[i],staleAwaiting:M(i),restingCardShown:i===j&&N,shadowedBy:ve.get(i),placed:he.placed.get(i),thread:e})},s)),r=!1,a(i);return}r!==null&&n.push((0,L.jsx)(vX,{h:r&&K2(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)(z4,{m:t,dense:!0,staleAwaiting:M(i),restingCardShown:i===j&&N,answering:_e?we(t):void 0,paired:ee[i],shadowedBy:ve.get(i),placed:he.placed.get(i),thread:e})},g)),r=G2(t),a(i)}),fe.forEach((e,r)=>{e.queued&&(n.push((0,L.jsx)(vX,{},`qs${r}`)),n.push((0,L.jsx)(z4,{m:e,dense:!0,paired:ee[t+r]},`q${t+r}`)))}),n})()]}),!T.isLoading&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(A$,{thread:e,className:`mt-4`}),e.pendingInteraction?null:e.pendingAsk?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(Q4,{ask:e.pendingAsk,onTerminal:w})}):e.runtime===`perm-prompt`?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(Y4,{onTerminal:w})}):null,e.permPolicy?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(X4,{policy:e.permPolicy,denies:e.permDenies})}):null]}),!T.isLoading&&Y1(e)&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(R3,{thread:e,onSnooze:je,onSnoozeFailed:Me})}),!T.isLoading&&CY(e,j>=0?A[j]?.text:void 0)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(vX,{}),(0,L.jsx)(K4,{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)(J4,{slug:e.id,sessionId:e.sessionId,pause:e.limitPause})}),!T.isLoading&&RY(e,j>=0?A[j]?.text:void 0)&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(zY,{thread:e})})]}),(0,L.jsx)(r1,{thread:e,questions:ge.tail,inFlight:ye,showSend:he.placedIds.size>0,className:`shrink-0 px-5 pb-4 pt-0`}),Ae&&(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:!Ee,onClick:()=>De(),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)(NZ,{slug:e.id,surface:`queueComposer`,className:`shrink-0 px-5 pb-3 pt-0`,placeholder:Te||(e.questions?.length??0)>0?`Or skip the questions and reply…`:`Reply to the agent…`,submitOverride:Oe,ops:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(A3,{slug:e.id,subAgents:e.subAgents??[],className:`px-1 pt-1.5`}),(0,L.jsx)(Z4,{slug:e.id,includeAgents:!1,className:`px-1 ${k3(e.subAgents??[])?`pt-0.5`:`pt-1.5`}`})]})})]})]}),(0,L.jsx)(gQ,{thread:e,onArchived:()=>r(e.id),onDismissCancel:()=>i(e.id),onSnoozed:()=>r(e.id)})]})})})})},K3);function K3(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 q3(e,t,n=[]){if(e.backend===`acp`){let t=n.find(t=>t.id===el(e.model));return t?t.available?void 0:`${t.label} is not installed on this machine`:`ACP agent ${e.model} is not in the catalogue`}if(!e.effort)return`Reasoning level is required for ${e.model}`;if(e.backend===`claude`)return MV.some(t=>t.value===e.model)?LV(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 r=t.find(t=>t.slug===e.model);if(!r)return`Codex model ${e.model} is no longer available`;if(!r.efforts.includes(e.effort))return`Reasoning level ${e.effort} is not available for ${e.model}`}function J3(e,t){return{items:t.map(e=>({...e})),backend:e.backend,model:e.model,effort:e.effort}}function Y3({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 X3=30;function Z3({onClose:e}){let t=RR(),{resolved:n,codexList:r,acpList:i,loadError:a,saveProfile:o}=GV(),s=it({mutationKey:[`contextWindowSet`]})>0,[c,l]=(0,I.useState)(`issues`),[u,d]=(0,I.useState)(`recent`),[f,p]=(0,I.useState)(1),[m,h]=(0,I.useState)(()=>new Set),[g,_]=(0,I.useState)(null),v=nt({queryKey:[`githubList`,c,u,f],queryFn:()=>Y.githubList({kind:c,sort:u,page:f,perPage:X3}),placeholderData:ee}),y=v.data?.items??[],b=v.data?.page??f,x=v.data?.pageCount??1,S=v.data?.total??0,C=(0,I.useRef)(null);(0,I.useEffect)(()=>{C.current&&(C.current.scrollTop=0)},[f,c,u]);let w=st({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 T(e){e!==c&&(l(e),p(1),h(new Set),_(null))}function E(e){e!==u&&(d(e),p(1),h(new Set),_(null))}function D(e,t){let n=Y3({keys:y.map(e=>e.number),key:e,shiftKey:t,anchor:g,selected:m});h(n.selected),_(n.anchor)}function O(){h(new Set),_(null)}let k=t.data?.nameWithOwner??`this repo`,A=m.size,j=(0,I.useMemo)(()=>UV(r,i),[r,i]),M=n?.acpAgentId?i.find(e=>e.id===n.acpAgentId):void 0,N=n?{backend:n.backend,model:n.model,effort:n.effort||void 0}:void 0,P=N?q3(N,r,i):a?`Could not load the model catalogue — reopen once it loads`:void 0,F=P??(s?`Saving context window…`:N?void 0:`Loading the model catalogue…`);function te(){if(!N||F){Z(F??`Choose a model and reasoning level`);return}w.mutate(J3(N,[...m].map(e=>({kind:c===`issues`?`issue`:`pr`,number:e}))))}return(0,L.jsx)(uH,{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)(sh,{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:k})]}),(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,L.jsx)($3,{value:c,onChange:e=>T(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)($3,{value:u,onChange:E,options:[{value:`recent`,label:`Recent`},{value:`reactions`,label:`Reactions`}]})]})]}),(0,L.jsx)(`div`,{ref:C,className:`min-h-[240px] flex-1 overflow-y-auto rounded-lg border border-border/70 bg-bg/40 transition-opacity ${v.isPlaceholderData?`opacity-40`:``}`,children:v.isLoading?(0,L.jsx)(c6,{}):v.isError?(0,L.jsxs)(l6,{children:[(0,L.jsxs)(`span`,{className:`text-[12.5px] text-muted/80`,children:[`Couldn't load `,c===`issues`?`issues`:`pull requests`,`.`]}),(0,L.jsx)(`span`,{className:`max-w-[80%] text-center text-[11px] text-muted/45`,children:v.error.message.slice(0,140)})]}):y.length===0?(0,L.jsxs)(l6,{children:[(0,L.jsx)(dh,{size:28,strokeWidth:1.25,className:`text-muted/30`}),(0,L.jsxs)(`span`,{className:`text-[12.5px] text-muted/60`,children:[`No open `,c===`issues`?`issues`:`pull requests`]})]}):y.map(e=>(0,L.jsx)(n6,{item:e,checked:m.has(e.number),onActivate:t=>D(e.number,t)},e.number))}),!v.isLoading&&!v.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:[S,` open `,c===`issues`?S===1?`issue`:`issues`:S===1?`pull request`:`pull requests`]}),A>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:[A,` selected`]}),(0,L.jsx)(`button`,{onClick:O,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`})]})]}),x>1&&(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,L.jsx)(Q3,{label:`Previous page`,disabled:b<=1,onClick:()=>p(Math.max(1,b-1)),children:(0,L.jsx)(Lm,{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 `,x,` of `,x]}),(0,L.jsxs)(`span`,{className:`absolute inset-0`,children:[`Page `,b,` of `,x]})]}),(0,L.jsx)(Q3,{label:`Next page`,disabled:b>=x,onClick:()=>p(Math.min(x,b+1)),children:(0,L.jsx)(Rm,{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.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-0.5`,children:[(0,L.jsx)(sV,{groups:j,contextWindows:!0,value:n?{provider:n.backend,model:n.pickerModel,effort:n.effort}:void 0,onValueChange:e=>o({field:`profile`,backend:e.provider,model:e.model,effort:e.effort}),placeholder:a?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort`,title:F??`Model and reasoning effort for every thread this batch starts`,disabled:!n,side:`top`,menuZClass:xM,className:`max-w-[min(21rem,60vw)]`}),M&&(0,L.jsx)(yV,{agentId:M.id,agentLabel:M.label,modelId:n?.acpModelId,onValueChange:e=>o({field:`model`,backend:`acp`,value:Qc(M.id,e)}),side:`top`,menuZClass:`z-[250]`,className:`max-w-[min(14rem,30vw)] px-2 py-1`})]}),P&&(0,L.jsx)(`p`,{className:`mt-1 max-w-[430px] text-[10.5px] text-red-400`,children:P})]}),(0,L.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,L.jsxs)(`button`,{disabled:A===0||w.isPending||!!F,onClick:te,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:[w.isPending&&(0,L.jsx)(hh,{size:13,className:`animate-spin`}),A<=1?`Start investigation`:`Start ${A} investigations`]})})]})]})})}function Q3({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 $3({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 e6({item:e}){let t=(e.state??`OPEN`).toUpperCase();return e.kind===`pr`?t===`MERGED`?(0,L.jsx)(rh,{size:15,className:`shrink-0`,style:{color:cD.fgDone}}):t===`CLOSED`?(0,L.jsx)(ih,{size:15,className:`shrink-0`,style:{color:cD.fgDanger}}):e.isDraft?(0,L.jsx)(ah,{size:15,className:`shrink-0`,style:{color:cD.fgNeutral}}):(0,L.jsx)(oh,{size:15,className:`shrink-0`,style:{color:cD.fgSuccess}}):t===`CLOSED`?(0,L.jsx)(Hm,{size:15,className:`shrink-0`,style:{color:cD.fgDone}}):(0,L.jsx)(Wm,{size:15,className:`shrink-0`,style:{color:cD.fgSuccess}})}function t6({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 n6({item:e,checked:t,onActivate:n}){let r=NE(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)(r6,{checked:t})}),(0,L.jsx)(`span`,{className:`mt-px`,children:(0,L.jsx)(e6,{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)(t6,{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)(o6,{prs:e.linkedPrs}):null,e.comments?(0,L.jsx)(s6,{icon:yh,n:e.comments,label:`comments`}):null,e.reactions?(0,L.jsx)(s6,{emoji:`👍`,n:e.reactions,label:`reactions`}):null]})]})}function r6({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)(Fm,{size:11,strokeWidth:3,className:`text-bg`})})}var i6={octicon:`-0.1em`,stroke:`-0.112em`};function a6({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(${i6.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 o6({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)(a6,{size:12}),e.count]})}function s6({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(${i6.stroke})`},children:(0,L.jsx)(e,{size:12,strokeWidth:2})}):null,n]})}function c6(){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 l6({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 u6={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.`,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 d6(){return typeof Notification>`u`?`unsupported`:Notification.permission}var f6=500,p6=1600,m6=2e3,h6=6;function g6(){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=>{Q7.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`),p6))}).catch(i=>{--a.current,t(`error`),!(n.current||!jf(i)||s.current>=h6)&&(s.current+=1,n.current=e,r.current=window.setTimeout(c.current,m6))}))},[]);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,f6)},[l]);return(0,I.useEffect)(()=>()=>{l(),o.current!==void 0&&window.clearTimeout(o.current)},[l]),{state:e,queue:u,flush:l}}function _6(){let e=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()}),[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(d6()),{state:a,queue:o,flush:s}=g6(),[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)(()=>(jd(p),()=>jd(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,Dp()?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:`${Cp} z-50 flex justify-end ${c?`opacity-100`:`opacity-0`}`,onMouseDown:e=>e.target===e.currentTarget&&p(),children:(0,L.jsxs)(`div`,{className:`${wp} w-[560px] max-w-[94vw] ${c?`translate-x-0`:`translate-x-full`}`,children:[(0,L.jsx)(Wh,{title:`Settings`,actions:(0,L.jsx)(v6,{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)(b6,{label:`Font`,help:u6.font,children:(0,L.jsx)(O6,{value:t.font??`mono`,onChange:e=>f({...t,font:e})})}),(0,L.jsx)(b6,{label:`Project sidebar`,help:u6.projectRail,children:(0,L.jsx)(vV,{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)(b6,{label:`Local file links`,help:u6.localFileOpener,children:(0,L.jsx)(vV,{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)(b6,{label:`Density`,help:u6.density,children:(0,L.jsx)(A6,{})}),(0,L.jsx)(b6,{label:`Queue order`,help:u6.queueOrder,children:(0,L.jsx)(j6,{})}),(0,L.jsxs)(b6,{label:`Desktop notifications`,help:u6.notifications,children:[(0,L.jsx)(k6,{value:t.notifications,onChange:m}),t.notifications&&(0,L.jsx)(M6,{perm:r})]}),(0,L.jsx)(C6,{draft:t,setDraft:f}),(0,L.jsx)(w6,{draft:t,setDraft:f})]}):(0,L.jsx)(`div`,{className:`p-4 text-[13px] text-muted`,children:`Loading…`})]})})}function v6({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 y6({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)(wM,{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)(Gm,{size:12})})})]})}function b6({label:e,help:t,children:n}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(y6,{label:e,help:t}),n]})}var x6=[{token:`repo`,gloss:`repository`},{token:`n`,gloss:`number`},{token:`title`,gloss:`title`},{token:`url`,gloss:`link`},{token:`labels`,gloss:`labels`},{token:`body`,gloss:`description`}],S6=[{value:`auto`,label:`Automatic (default)`},{value:`5m`,label:`5 minutes`},{value:`1h`,label:`1 hour`}];function C6({draft:e,setDraft:t}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(T6,{label:`Claude`}),(0,L.jsx)(b6,{label:`Permissions`,help:u6.permissionMode,children:(0,L.jsx)(vV,{variant:`bordered`,value:e.permissionMode===`bypassPermissions`?`bypassPermissions`:`auto`,onValueChange:n=>t({...e,permissionMode:n}),options:jV,indicatorPosition:`right`,ariaLabel:`Claude permission mode`})}),(0,L.jsx)(b6,{label:`Prompt cache tier`,help:u6.promptCacheTtl,children:(0,L.jsx)(vV,{variant:`bordered`,value:e.promptCacheTtl??`auto`,onValueChange:n=>t({...e,promptCacheTtl:n}),options:S6,indicatorPosition:`right`,ariaLabel:`Claude prompt cache tier`})})]})}function w6({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)(T6,{label:`Prompts`}),n.data?(0,L.jsx)(D6,{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 T6({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 E6(){let[e,t]=(0,I.useState)(!1);return(0,L.jsxs)(tV,{open:e,onOpenChange:t,children:[(0,L.jsx)(nV,{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)(iV,{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:x6.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 D6({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)(y6,{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)(E6,{})]})]}),(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 O6({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 k6({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 A6(){let{compactDiffs:e}=en(RT);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:()=>RT.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 j6(){let{queueOrder:e}=en(RT);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:()=>RT.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 M6({perm:e}){return e===`denied`?(0,L.jsx)(P6,{}):(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 N6(){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 P6(){let e=(0,I.useMemo)(N6,[]),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)(I6,{url:n,hint:`Paste this into a new tab, set Notifications → Allow:`}):e===`safari`?(0,L.jsxs)(`span`,{children:[`Safari → Settings → Websites → Notifications → allow `,F6(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 F6(e){try{return new URL(e).host}catch{return e}}function I6({url:e,hint:t}){let[n,r]=(0,I.useState)(!1);async function i(){try{await bV(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)(Fm,{size:11,className:`text-live`}):(0,L.jsx)(Ym,{size:11})})]})]})}var L6=1,R6=.9,z6=.8,B6=.17,V6=.1,H6=.999,U6=.9999,W6=.99,G6=/[\\\/_+.#"@\[\(\{&]/,K6=/[\\\/_+.#"@\[\(\{&]/g,q6=/[\s-]/,J6=/[\s-]/g;function Y6(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?L6:W6;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=Y6(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=L6:G6.test(e.charAt(l-1))?(d*=z6,p=e.slice(i,l-1).match(K6),p&&i>0&&(d*=H6**+p.length)):q6.test(e.charAt(l-1))?(d*=R6,m=e.slice(i,l-1).match(J6),m&&i>0&&(d*=H6**+m.length)):(d*=B6,i>0&&(d*=H6**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=U6)),(d<V6&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=Y6(e,t,n,r,l+1,a+2,o),f*V6>d&&(d=f*V6)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function X6(e){return e.toLowerCase().replace(J6,` `)}function Z6(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,Y6(e,t,X6(e),X6(t),0,0,{})}var Q6=`[cmdk-group=""]`,$6=`[cmdk-group-items=""]`,e8=`[cmdk-group-heading=""]`,t8=`[cmdk-item=""]`,n8=`${t8}:not([aria-disabled="true"])`,r8=`cmdk-item-select`,i8=`data-value`,a8=(e,t,n)=>Z6(e,t,n),o8=I.createContext(void 0),s8=()=>I.useContext(o8),c8=I.createContext(void 0),l8=()=>I.useContext(c8),u8=I.createContext(void 0),d8=I.forwardRef((e,t)=>{let n=T8(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=T8(()=>new Set),i=T8(()=>new Map),a=T8(()=>new Map),o=T8(()=>new Set),s=C8(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=AO(),y=AO(),b=AO(),x=I.useRef(null),S=O8();w8(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),w8(()=>{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??a8;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($6);t?t.appendChild(e.parentElement===t?e:e.closest(`${$6} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${$6} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${Q6}[${i8}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(i8);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(Q6)?.querySelector(e8))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${t8}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(n8)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(i8))}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(i8))}function P(e){let t=A()?.closest(Q6),n;for(;t&&!n;)t=e>0?x8(t,Q6):S8(t,Q6),n=t?.querySelector(n8);n?C.setState(`value`,n.getAttribute(i8)):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(sO.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(r8);t.dispatchEvent(e)}}}}},I.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:j8},c),A8(e,e=>I.createElement(c8.Provider,{value:C},I.createElement(o8.Provider,{value:w},e))))}),f8=I.forwardRef((e,t)=>{let n=AO(),r=I.useRef(null),i=I.useContext(u8),a=s8(),o=C8(e),s=o.current?.forceMount??i?.forceMount;w8(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=D8(n,r,[e.value,e.children,r],e.keywords),l=l8(),u=E8(e=>e.value&&e.value===c.current),d=E8(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(r8,f),()=>t.removeEventListener(r8,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(sO.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)}),p8=I.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=AO(),s=I.useRef(null),c=I.useRef(null),l=AO(),u=s8(),d=E8(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);w8(()=>u.group(o),[]),D8(o,s,[e.value,e.heading,c]);let f=I.useMemo(()=>({id:o,forceMount:i}),[i]);return I.createElement(sO.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),A8(e,e=>I.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},I.createElement(u8.Provider,{value:f},e))))}),m8=I.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=I.useRef(null),a=E8(e=>!e.search);return!n&&!a?null:I.createElement(sO.div,{ref:WD(i,t),...r,"cmdk-separator":``,role:`separator`})}),h8=I.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=l8(),o=E8(e=>e.search),s=E8(e=>e.selectedItemId),c=s8();return I.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),I.createElement(sO.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)}})}),g8=I.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=I.useRef(null),o=I.useRef(null),s=E8(e=>e.selectedItemId),c=s8();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(sO.div,{ref:WD(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},A8(e,e=>I.createElement(`div`,{ref:WD(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),_8=I.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return I.createElement(bL,{open:n,onOpenChange:r},I.createElement(EL,{container:o},I.createElement(OL,{"cmdk-overlay":``,className:i}),I.createElement(ML,{"aria-label":e.label,"cmdk-dialog":``,className:a},I.createElement(d8,{ref:t,...s}))))}),v8=I.forwardRef((e,t)=>E8(e=>e.filtered.count===0)?I.createElement(sO.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),y8=I.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return I.createElement(sO.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},A8(e,e=>I.createElement(`div`,{"aria-hidden":!0},e)))}),b8=Object.assign(d8,{List:g8,Item:f8,Input:h8,Group:p8,Separator:m8,Dialog:_8,Empty:v8,Loading:y8});function x8(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function S8(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function C8(e){let t=I.useRef(e);return w8(()=>{t.current=e}),t}var w8=typeof window>`u`?I.useEffect:I.useLayoutEffect;function T8(e){let t=I.useRef();return t.current===void 0&&(t.current=e()),t}function E8(e){let t=l8(),n=()=>e(t.snapshot());return I.useSyncExternalStore(t.subscribe,n,n)}function D8(e,t,n,r=[]){let i=I.useRef(),a=s8();return w8(()=>{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(i8,s),i.current=s}),i}var O8=()=>{let[e,t]=I.useState(),n=T8(()=>new Map);return w8(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function k8(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function A8({asChild:e,children:t},n){return e&&I.isValidElement(t)?I.cloneElement(k8(t),{ref:t.ref},n(t.props.children)):n(t)}var j8={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function M8(){let e=en(X),t=fw(),[n,r]=(0,I.useState)(``);if((0,I.useEffect)(()=>{e.showPalette&&r(``)},[e.showPalette]),!e.showPalette)return null;let i=eE(mw(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){Wp(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)(b8,{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)(b8.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)(b8.List,{className:`max-h-[52vh] overflow-y-auto py-1.5`,children:[(0,L.jsx)(b8.Empty,{className:`px-4 py-6 text-center text-sm text-muted`,children:`No matches.`}),(0,L.jsxs)(b8.Group,{heading:`Actions`,className:`cmdk-group`,children:[(0,L.jsx)(N8,{value:`new thread create home`,onSelect:()=>c(()=>Mp()),children:`New thread`}),(0,L.jsx)(N8,{value:`queue todos inbox pending`,onSelect:()=>c(()=>{lm(X.drawers.map(e=>e.id)),X.view=`todos`}),children:`Queue`}),(0,L.jsx)(N8,{value:`open settings preferences`,onSelect:()=>c(()=>X.showSettings=!0),children:`Open settings`}),o&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(N8,{value:`open details drawer doc ${HT(o)}`,onSelect:()=>c(()=>{let e=um();e&&Vp(`doc`,e)}),children:`Open thread details`}),(0,L.jsxs)(N8,{value:`mark complete done ${HT(o)}`,onSelect:()=>c(()=>Y.markComplete({slug:o.id}).catch(()=>{})),children:[`Mark “`,HT(o),`” complete`]}),(0,L.jsxs)(N8,{value:`mark read ${HT(o)}`,onSelect:()=>c(()=>Y.markRead({slug:o.id}).catch(()=>{})),children:[`Mark “`,HT(o),`” read`]})]})]}),i.length>0&&(0,L.jsx)(b8.Group,{heading:`Threads`,className:`cmdk-group`,children:i.map(e=>(0,L.jsxs)(N8,{value:`${HT(e)} ${e.id}`,onSelect:()=>c(()=>l(e.id)),children:[(0,L.jsx)(`span`,{className:`truncate`,children:HT(e)}),(0,L.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted/70`,children:e.id})]},e.id))})]})]})})}function N8({value:e,onSelect:t,children:n}){return(0,L.jsx)(b8.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 P8=`Updating and restarting Frizz`,F8=`This may take a moment while the new build is being prepared. All of your threads will continue running normally.`,I8=`Frizz did not come back`;function L8(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 R8(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 z8({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=>{R8(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)(Bh,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,L.jsx)(`h2`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:I8}),(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)(Hh,{"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:L8(r)})]})});let c=t?.trim()?t.trim():null;return(0,L.jsx)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":P8,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)(Oh,{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:P8}),(0,L.jsx)(`p`,{className:`mt-2 text-[12.5px] leading-relaxed text-muted`,children:F8}),c&&(0,L.jsx)(`p`,{"aria-live":`polite`,className:`mt-2 text-[11.5px] leading-relaxed text-muted/80`,children:c})]})})}var B8=!1;function V8(){B8||(B8=!0,Z("Sign in to the GitHub CLI (`gh auth login`) to dispatch from issues/PRs.",{duration:6e3}))}function H8(){let e=en(X),t=(0,I.useRef)({projectDir:null,hasBeenVisible:!1});(0,I.useEffect)(()=>{Y.board().then(pm).catch(()=>{})},[]);let n=xy();(0,I.useEffect)(()=>Bw((e,t)=>n(e,t)),[n]);let{data:r,dataUpdatedAt:i}=mU(),a=(0,I.useRef)(null),[o,s]=(0,I.useState)(XH),c=(0,I.useRef)(null),l=(0,I.useRef)(!1);(0,I.useEffect)(()=>{let e=r;if(e){let t=$H({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=qH(e))}if(s(t=>ZH(t,{restarting:X.controlPlaneState===`restarting`,answered:e!=null,at:Date.now()})),!e||l.current)return;let t=sessionStorage.getItem(UH);if(tU({state:X.controlPlaneState,message:X.controlPlaneMessage,attempt:X.controlPlaneRestartAttempt},e)){if(t){sessionStorage.removeItem(UH),sessionStorage.removeItem(WH),l.current=!0,window.location.replace(t);return}if(JH(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(UH),sessionStorage.removeItem(WH),a.current!==e.message&&(a.current=e.message??`Update & Restart failed`,Z(`Update & Restart failed — ${KH(GH(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 Ud(),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,Ud()??e)}},[u]);let d=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()});(0,I.useEffect)(()=>{X.notificationsEnabled=d.data?.notifications??!1},[d.data?.notifications]);let f=RR();(0,I.useEffect)(()=>{f.data?.inRepo&&!f.data.authed&&V8()},[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=om(),n=um();t?.kind===`doc`?(e.preventDefault(),Id(t.id)||X.drawers.pop()):n&&(e.preventDefault(),Vp(`doc`,n))}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let p=fw(),m=LG();(0,I.useEffect)(()=>{Gp()},[p,e.routeThreadSlug]),t.current=Vw(t.current,p);let h=p!==null&&t.current.hasBeenVisible,g=p===null&&Uw(Yd()),_=t.current.hasBeenVisible;(0,I.useEffect)(()=>{p!==null&&Ww(Yd(),_)},[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)(z8,{open:e.controlPlaneState===`restarting`,message:e.controlPlaneMessage,stalled:o.stalled,silentFor:o.silentSince===null?void 0:tD(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)(jG,{}):(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)(Kh,{label:`the sidebar`,children:(0,L.jsx)(MW,{})}),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)(Kh,{label:`the queue`,resetKeys:[e.view],children:[e.view.startsWith(`status:`)&&(0,L.jsx)(mG,{status:e.view.slice(7)}),e.view===`todos`&&(0,L.jsx)(z3,{})]}):(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)(b3,{}),e.showSettings&&(0,L.jsx)(_6,{}),e.showNewThread&&(0,L.jsx)(lH,{onClose:()=>{X.showNewThread=!1}}),e.showGithubPicker&&(0,L.jsx)(Z3,{onClose:Pp}),(0,L.jsx)(M8,{})]})]})}function U8(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 W8(e,t,n,r=48){let i=Math.round(t/r);return Math.max(0,Math.min(n-1,e+i))}function G8(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 K8(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 q8=`w-[57px]`,J8=`max-[800px]:pl-0 pl-[57px]`;function Y8(e){let t=0;for(let n=0;n<e.length;n++)t=(t*31+e.charCodeAt(n))%360;return t}function X8(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 Z8(e){let t=e.iconVersion?`&v=${encodeURIComponent(e.iconVersion)}`:``;return`/_frizz/project-icon?id=${encodeURIComponent(e.id)}${t}`}function Q8({project:e,size:t}){let[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(!1),o=Y8(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:X8(e.name)})}),s&&!c&&(0,L.jsx)(`img`,{src:Z8(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 $8=40;function e5({project:e,current:t,count:n,index:r,drag:i,onPointerDown:a,onKeyDown:o}){let s=i?.fromIndex===r,c=i?s?i.deltaY:G8(r,i.fromIndex,i.toIndex):0;return(0,L.jsx)(wM,{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)(Yb,{to:Xd(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||i5())&&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)(Q8,{project:e,size:$8})}),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 t5({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=st({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=st({mutationFn:()=>Y.projectIconClear({id:e.id}),onSuccess:()=>void i(),onError:a}),c=st({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:wd.map(e=>`.${e}`).join(`,`),className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&o.mutate(t)}}),(0,L.jsxs)(QI,{children:[(0,L.jsx)($I,{asChild:!0,children:t}),(0,L.jsx)(eL,{children:(0,L.jsxs)(tL,{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)(iL,{className:l,onSelect:()=>c.mutate(),children:o.isPending?`Uploading…`:`Choose an icon…`}),(0,L.jsx)(iL,{className:l,onSelect:()=>s.mutate(),children:e.iconIsCustom?`Use the detected icon`:`Look for an icon again`})]})})]})]})}var n5=4,r5=0;function i5(){return Date.now()-r5<250}function a5(e,t){let n=nt({queryKey:[`projectsQueueCounts`],queryFn:()=>Y.projectsQueueCounts(),refetchInterval:5e3}),r=en(X).board,i=e!==void 0&&r?mw(r.threads).filter(rE).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 o5(){let e=Ve(),{data:t}=nt({queryKey:[`projectsList`],queryFn:()=>Y.projectsList()}),n=Yd(),[r,i]=(0,I.useState)(!1),a=xy(),[o,s]=(0,I.useState)(null),[c,l]=(0,I.useState)(null),u=(0,I.useRef)(null),d=st({mutationFn:()=>Y.projectPick({}),onSuccess:e=>{e.kind===`picked`?a(Xd(e.project.slug)):e.kind===`unavailable`&&a(`/`)},onSettled:()=>i(!1)}),f=st({mutationFn:e=>Y.projectsReorder({ids:e}),onSuccess:async()=>{await e.invalidateQueries({queryKey:[`projectsList`]}),l(null)},onError:()=>l(null)}),p=c??t??[],m=a5(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=K8(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:W8(t,c,i.length),deltaY:c},s(o)},m=0,h=e=>{if(!a){if(Math.abs(e.clientY-r)<n5)return;a=!0,n.setPointerCapture(e.pointerId)}e.preventDefault();let t=e.clientY;cancelAnimationFrame(c);let i=()=>{d(t),u.current&&K8(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;r5=Date.now();let e=U8(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=U8(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 ${q8}`,children:[(0,L.jsx)(wM,{side:`right`,label:`All projects`,children:(0,L.jsx)(Yb,{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)(lh,{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)(e5,{project:e,index:t,current:e.slug===n,count:m(e),drag:o,onPointerDown:_,onKeyDown:v},e.id))}),(0,L.jsx)(wM,{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)(Dh,{size:16})})})]})}var s5=76;function c5(e,t){return t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}var l5=`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`,u5=`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`,d5=38;function f5({project:e,home:t}){let n=OE(e.lastOpenedAt),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(!1);return(0,L.jsxs)(`div`,{className:`group/card relative`,children:[(0,L.jsxs)(Yb,{to:Xd(e.slug),className:`${l5} ${u5} 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)(Q8,{project:e,size:d5})}),(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:c5(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)(t5,{project:e,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":`Change the icon for ${e.name}`,style:{width:d5,height:d5},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)(uh,{size:16,strokeWidth:1.75})})}),(0,L.jsx)(p5,{onRename:()=>o(!0),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)(Xm,{size:15})})}),a?(0,L.jsx)(h5,{project:e,home:t,onClose:()=>o(!1)}):null,r?(0,L.jsx)(g5,{project:e,home:t,onClose:()=>i(!1)}):null]})}function p5({onRename:e,onDelete:t,children:n}){return(0,L.jsxs)(QI,{children:[(0,L.jsx)($I,{asChild:!0,children:n}),(0,L.jsx)(eL,{children:(0,L.jsxs)(tL,{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)(iL,{className:`cursor-default rounded px-2 py-1.5 text-[12.5px] text-fg outline-none data-[highlighted]:bg-panel-2`,onSelect:e,children:`Rename…`}),(0,L.jsx)(iL,{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:t,children:`Delete project…`})]})})]})}function m5(e){return e.split(/[\\/]/u).filter(Boolean).pop()??e}function h5({project:e,home:t,onClose:n}){let[r,i]=(0,I.useState)(e.name),[a,o]=(0,I.useState)(!1),s=(0,I.useRef)(null),c=Ve(),l=st({mutationFn:()=>Y.projectRename({id:e.id,name:r.trim(),renameDirectory:a}),onSuccess:t=>{c.invalidateQueries({queryKey:[`projectsList`]}),Z(`Renamed ${e.name} to ${t.name}`),n()}}),u=l.error instanceof Error?l.error.message:l.error?String(l.error):null,d=r.trim(),f=m5(e.path),p=e.path.slice(0,e.path.length-f.length),m=f===e.name&&d.length>0&&d!==f,h=Ns(d);return(0,L.jsx)(qZ,{open:!0,onOpenChange:e=>{!e&&!l.isPending&&n()},title:`Rename ${e.name}`,className:`w-[440px] max-w-[92vw]`,onOpenAutoFocus:e=>{e.preventDefault(),s.current?.focus(),s.current?.select()},footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,onClick:n,disabled:l.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:`submit`,form:`rename-project`,disabled:l.isPending||d.length===0,className:`flex items-center gap-1.5 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:[l.isPending&&(0,L.jsx)(hh,{size:12,className:`animate-spin`}),m&&a?`Rename project and folder`:`Rename project`]})]}),children:(0,L.jsxs)(`form`,{id:`rename-project`,onSubmit:e=>{e.preventDefault(),!l.isPending&&d.length>0&&l.mutate()},className:`flex flex-col gap-3 p-4 text-[12.5px] leading-relaxed text-muted`,children:[(0,L.jsx)(`input`,{ref:s,value:r,onChange:e=>i(e.target.value),spellCheck:!1,"aria-label":`Project name`,className:`w-full rounded-md border bg-bg px-2.5 py-2 text-[12.5px] text-fg outline-none placeholder:text-muted/50 focus-visible:ring-1 focus-visible:ring-fg/60 ${u?`border-red-500/60`:`border-border-strong`}`}),(0,L.jsxs)(`p`,{children:[`Its address becomes`,` `,(0,L.jsxs)(`span`,{className:`font-mono text-[11.5px] text-fg/80`,children:[`/project/`,h]}),h===e.slug?`.`:(0,L.jsxs)(L.Fragment,{children:[` — links to `,(0,L.jsxs)(`span`,{className:`font-mono text-[11.5px]`,children:[`/project/`,e.slug]}),` stop working.`]})]}),m?(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:a,onChange:e=>o(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 rename the folder`}),(0,L.jsx)(`span`,{className:`text-[11.5px] text-muted/80`,children:a?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`font-mono text-[11px]`,children:c5(e.path,t)}),` becomes `,(0,L.jsx)(`span`,{className:`font-mono text-[11px]`,children:c5(p+d,t)}),`. Running workers keep going.`]}):`Left off, the folder keeps its name and only what Frizz calls it changes.`})]})]}):null,u?(0,L.jsx)(`p`,{className:`text-[11.5px] text-red-400`,children:u}):null]})})}function g5({project:e,home:t,onClose:n}){let[r,i]=(0,I.useState)(!1),a=Ve(),o=st({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)(qZ,{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)(hh,{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:c5(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 _5({hero:e,pending:t,onClick:n}){return(0,L.jsxs)(`button`,{type:`button`,onClick:n,disabled:t,className:`${l5} 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 v5({reason:e,proposed:t,onClose:n}){let[r,i]=(0,I.useState)(t??``),a=xy(),o=Ve(),s=st({mutationFn:e=>Y.projectAdd({path:e}),onSuccess:e=>{o.invalidateQueries({queryKey:[`projectsList`]}),a(Xd(e.slug))}}),c=s.error instanceof Error?s.error.message:s.error?String(s.error):null;return(0,L.jsx)(bL,{open:!0,onOpenChange:e=>{!e&&!s.isPending&&n()},children:(0,L.jsxs)(EL,{children:[(0,L.jsx)(OL,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(ML,{"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)(LL,{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 y5(){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=xy(),i=Ve(),a=st({mutationFn:()=>Y.projectPick({}),onSuccess:e=>{if(e.kind!==`cancelled`){if(e.kind===`unavailable`){n({reason:e.reason});return}i.invalidateQueries({queryKey:[`projectsList`]}),r(Xd(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:s5,height:s5,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)(f5,{project:e,home:l},e.id)),(0,L.jsx)(_5,{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)(v5,{reason:t.reason,proposed:e,onClose:()=>n(null)}):null]})}function b5(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 x5(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 S5({slug:e,path:t,active:n}){let r=vC(t),i=hw(t),a=nt({...SC(t),refetchInterval:i?!1:CC}),o=a.data?.path??t,s=a.data?.markdown??``,{front:c,body:l}=m3(r?s:``),[u,d]=(0,I.useState)(r?`rendered`:`source`),f=Kq(l,{baseDir:bC(o),asDocument:!0}),p=jJ(f),m=jJ((0,I.useMemo)(()=>u===`source`?EC(o,s):``,[s,o,u])),h=(0,I.useRef)(null),g=(0,I.useRef)(null),_=(0,I.useRef)(null);WJ(h,f);let v=_p(o),y=iH(),b=aH(e);return(0,I.useEffect)(()=>{if(!n)return;let t=()=>document.querySelector(`main[data-standalone-thread] textarea`);function r(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 i(n){if(!(n.metaKey||n.ctrlKey)||n.altKey||n.shiftKey||n.key.toLowerCase()!==`i`)return;let i=_.current,a=window.getSelection(),c=a&&!a.isCollapsed&&a.rangeCount>0?a.getRangeAt(0):null,l=!!(i&&c&&i.contains(c.commonAncestorContainer)),u=l?a.toString():``;if(!l||!u.trim()){n.preventDefault(),n.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}n.preventDefault(),n.stopPropagation();let d=null,f=g.current;if(f&&f.contains(c.commonAncestorContainer)){let e=b5(f,c.startContainer,c.startOffset),t=b5(f,c.endContainer,c.endOffset);e!==null&&t!==null&&(d={startLine:x5(s,Math.min(e,t)),endLine:x5(s,Math.max(0,Math.max(e,t)-1))})}else d=fR(s,u);let p=t(),m=rH.followUp(y,e,b),{prose:h,attachments:v}=tR(tH.get(m)),x=lR(rR({path:o,...d??{}}),X.composerContext[e]??[],h),S=uR(h,r(p,h),x);tH.set(m,nR(S.prose,v.map(e=>e.path))),rm(e,{token:x,path:o,text:u,...d??{}}),a.removeAllRanges(),requestAnimationFrame(()=>{let e=t();e&&(e.setSelectionRange(S.caret,S.caret),e.focus())})}return window.addEventListener(`keydown`,i,!0),()=>window.removeEventListener(`keydown`,i,!0)},[n,e,o,s,y,b]),(0,L.jsxs)(`div`,{ref:_,"data-file-viewer-panel":!0,className:`flex h-full min-h-0 flex-col`,children:[(0,L.jsx)(Wh,{title:v,subtitle:o,onClose:tm,actions:r?(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:()=>d(e),"aria-pressed":u===e,className:`rounded px-2 py-0.5 transition-colors ${u===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:[a.isLoading?(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):a.error?(0,L.jsxs)(`div`,{className:`text-[13px] text-red-400/90`,children:[`Couldn’t read this file: `,a.error.message]}):u===`source`?s?(0,L.jsx)(`pre`,{ref:g,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:m}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):f?(0,L.jsxs)(L.Fragment,{children:[c&&(0,L.jsx)(_3,{source:c}),(0,L.jsx)(`div`,{ref:h,className:`md-body`,dangerouslySetInnerHTML:p})]}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!a.isLoading&&!a.error&&a.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:h3,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)(g3,{path:o})]})]})}function C5(){return{dirs:new Map,files:new Map}}function w5(e,t){let n=e.replace(/[\\/]+$/,``);if(t){let e=xp(t,n);if(e!==null)return dp(e)}let r=dp(n);return/^[\\/]/.test(n)?[`/`,...r]:r}var T5=(e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`,numeric:!0});function E5(e,t){let n=[];for(let r of[...e.dirs.keys()].sort(T5)){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:E5(i,t+1)})}for(let r of[...e.files.keys()].sort(T5))n.push({kind:`file`,name:r,depth:t,file:e.files.get(r)});return n}function D5(e,t){let n=C5();for(let r of e){let e=w5(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=C5(),i.dirs.set(t,e)),i=e}i.files.set(e[e.length-1],r)}return E5(n,0)}function O5(e){let t=[],n=e=>{for(let r of e)t.push(r),r.kind===`dir`&&n(r.children)};return n(e),t}var k5=10;function A5({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*k5},children:[(0,L.jsx)(`span`,{className:`flex shrink-0`,children:(0,L.jsx)(eh,{size:12,className:`${y1} text-muted/45`})}),(0,L.jsx)(`span`,{className:`ml-[5px] min-w-0 truncate`,title:e,children:e})]})}function j5({files:e}){return(0,L.jsx)(`div`,{"data-edited-file-tree":!0,className:`col-span-4 flex flex-col gap-y-px`,children:O5(D5(e,pw())).map(e=>e.kind===`dir`?(0,L.jsx)(A5,{name:e.name,depth:e.depth},`d:${e.depth}:${e.name}`):(0,L.jsx)(M5,{file:e.file,name:e.name,depth:e.depth},e.file.path))})}function M5({file:e,name:t,depth:n}){let r=Ve();return(0,L.jsx)(j1,{testKind:`file`,testId:e.path,mark:(0,L.jsx)(Qm,{size:12,className:`${y1} -mr-[2px] text-muted/60`}),name:t,indent:n*k5,onOpen:()=>SJ(e.path),onPrewarm:()=>OC(r,e.path),title:e.path,status:(0,L.jsxs)(L.Fragment,{children:[(e.added??0)>0&&(0,L.jsxs)(`span`,{style:{color:cD.fgSuccess},children:[`+`,e.added]}),(e.added??0)>0&&(e.removed??0)>0&&` `,(e.removed??0)>0&&(0,L.jsxs)(`span`,{style:{color:cD.fgDanger},children:[`−`,e.removed]})]})})}function N5({thread:e}){let t=WE(),n=Ew(e.id,{poll:!1}).data?.editedFiles??[],r=V1(e),i=(e.bgShells??[]).filter(e=>e.state===`running`),a=(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`),o=a.filter(e=>e.subject!==`issue`),s=a.filter(e=>e.subject===`issue`),c=(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`),{railFilesCollapsed:l}=en(RT),u=[{head:`Sub-agents`,rows:r.map(n=>(0,L.jsx)(H1,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:i.map(n=>(0,L.jsx)(z1,{shell:n,slug:e.id,now:t},n.id??n.label))},{head:`Pull requests`,rows:o.map(e=>(0,L.jsx)(P1,{watch:e},e.id))},{head:`Issues`,rows:s.map(e=>(0,L.jsx)(P1,{watch:e},e.id))},{head:`Timers`,rows:c.map(e=>(0,L.jsx)(B1,{watch:e,now:t},e.id))},{head:`Edited files`,rows:n.length>0?[(0,L.jsx)(j5,{files:n},`tree`)]:[],count:n.length,collapsed:l,onToggle:()=>RT.railFilesCollapsed=!RT.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:u.length===0?(0,L.jsx)(`div`,{className:`text-[11.5px] text-muted/50`,children:`Nothing running, watched or edited yet.`}):(0,L.jsx)(J1,{groups:u,divider:!1})})})}function P5(){let e=en(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)(hh,{size:13,className:`animate-spin text-muted`}),t.text,t.link&&(0,L.jsx)(`button`,{onClick:()=>{Vp(`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 F5=`max(50%, calc(100% - 720px))`,I5={"--full-thread":`min(720px, ${F5})`,"--full-thread-narrow":`min(720px, 100%)`,"--full-pane":F5,"--full-gutter":`max(0px, calc((100% - min(720px, ${F5}) - 340px) / 2))`};function L5(e,t){return`${Xd(e)}${nf(t,`/`)}`}function R5({slug:e}){let t=en(X).filePanels.some(e=>!e.closing),n=fw(),r=Wd(n,e),i=r.kind===`found`?r.thread:void 0;n?.projectDir,(0,I.useEffect)(()=>{Y.board().then(pm).catch(()=>{})},[]),(0,I.useEffect)(()=>{let e=window.matchMedia(`(min-width: ${Tp}px)`),t=()=>{X.splitFileViewer=e.matches};return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),X.splitFileViewer=!1,X.filePanels=[]}},[]);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?HT(i):e;document.title=t?`${r} · ${t} — Frizz`:`${r} · Frizz`},[n?.projectLabel,n?.projectName,e,i]),(0,L.jsx)(CM,{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:{...I5,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)(V5,{slug:e}):(0,L.jsx)(D2,{slug:e,virtualized:!0,showReturnToQueue:!0})}),i?(0,L.jsx)(z5,{slug:e,thread:i}):(0,L.jsx)(`div`,{className:`hidden w-[var(--full-pane)] shrink-0 split:block`,"aria-hidden":`true`})]})}),(0,L.jsx)(b3,{}),(0,L.jsx)(P5,{})]})})}function z5({slug:e,thread:t}){let n=en(X);return(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.filePanels.length>0?!0:void 0,className:`h-full min-h-0`,children:(0,L.jsx)(N5,{thread:t})}),n.filePanels.map((t,r)=>(0,L.jsx)(B5,{slug:e,path:t.path,closing:!!t.closing,active:r===n.filePanels.length-1&&!t.closing&&n.splitFileViewer},t.id))]})}function B5({slug:e,path:t,closing:n,active:r}){let[i,a]=(0,I.useState)(!1),o=(0,I.useRef)(null);return(0,I.useLayoutEffect)(()=>{o.current?.getBoundingClientRect();let e=()=>a(!0),t=requestAnimationFrame(e),n=window.setTimeout(e,120);return()=>{cancelAnimationFrame(t),window.clearTimeout(n)}},[]),(0,I.useEffect)(()=>{r&&o.current?.focus({preventScroll:!0})},[r]),(0,L.jsx)(`aside`,{ref:o,tabIndex:-1,"data-file-viewer-slot":!0,"aria-hidden":!r,inert:!r,className:`absolute inset-0 outline-none transition-[translate,opacity] duration-200 ease-out motion-reduce:transition-none ${i&&!n?`translate-x-0 opacity-100`:`translate-x-full opacity-0`}`,children:(0,L.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-panel`,children:(0,L.jsx)(S5,{slug:e,path:t,active:r})})})}function V5({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(L5(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:L5(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 H5={OPEN_ISSUE:{bg:cD.bgSuccessEmphasis,icon:Wm,label:`Open`},CLOSED_ISSUE:{bg:cD.bgDoneEmphasis,icon:Hm,label:`Closed`},NOT_PLANNED:{bg:cD.bgNeutralEmphasis,icon:Km,label:`Closed as not planned`},OPEN_PR:{bg:cD.bgSuccessEmphasis,icon:oh,label:`Open`},DRAFT:{bg:cD.bgNeutralEmphasis,icon:ah,label:`Draft`},MERGED:{bg:cD.bgDoneEmphasis,icon:rh,label:`Merged`},CLOSED_PR:{bg:cD.bgDangerEmphasis,icon:ih,label:`Closed`}};function U5(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 W5(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 G5(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 ${W5(e,t)}`:NE(e,t)??``:``}function K5(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 q5={add:cD.fgSuccess,del:cD.fgDanger},J5={add:{backgroundColor:cD.bgSuccessEmphasis,borderColor:cD.bgSuccessEmphasis},del:{backgroundColor:cD.bgDangerEmphasis,borderColor:cD.bgDangerEmphasis},none:{backgroundColor:`${cD.bgNeutralEmphasis}33`,borderColor:`#3d444d`}};function Y5({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:q5.add},children:[`+`,e.toLocaleString()]}),(0,L.jsxs)(`span`,{"data-gh-del":!0,style:{color:q5.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:K5(e,t).map((e,t)=>(0,L.jsx)(`span`,{className:`size-[8px] rounded-[2px] border`,style:J5[e]},t))})]})}function X5({card:e}){let t=U5(e),n=t?H5[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 Z5({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 Q5=/`([^`\n]+)`/g;function $5(e,t){if(!t)return[e];let n=[],r=0;for(let t of e.matchAll(Q5))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 e7({text:e,code:t,className:n}){return(0,L.jsx)(`div`,{className:n,children:$5(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 t7=new Set([`avatars.githubusercontent.com`,`camo.githubusercontent.com`]);function n7(e){if(e)try{let t=new URL(e);return t.protocol===`https:`&&t7.has(t.hostname)?e:void 0}catch{return}}function r7({card:e,nowMs:t}){let n=n7(e.authorAvatar),r=e.authorLogin??e.authorName??`Someone`,i=e.kind===`commit`?`committed`:e.kind===`pr`?`opened this pull request`:`opened this issue`,a=G5(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 i7=`w-[360px] max-w-[min(360px,calc(100vw-24px))] leading-normal`;function a7({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:i7,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)(nh,{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)(e7,{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)(Y5,{additions:e.additions,deletions:e.deletions})}):null]})]}),(0,L.jsx)(r7,{card:e,nowMs:t})]});let r=e.ref.slice(e.ref.indexOf(`#`));return(0,L.jsxs)(`div`,{className:i7,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 ${W5(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)(X5,{card:e}),n?(0,L.jsx)(Y5,{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)(e7,{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)(Z5,{name:e.name,color:e.color},e.name))}):null]}):null,(0,L.jsx)(r7,{card:e,nowMs:t})]})}var o7=250,s7=180;function c7(e){let t=e.getClientRects()[0]??e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}}function l7(){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)},s7)},[]);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),Xf([o]),n.current=setTimeout(()=>t({ref:o,rect:c7(a)}),o7)))},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)(rV,{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)(iV,{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)(u7,{refKey:e.ref})}):null]})}function u7({refKey:e}){let t=(0,I.useSyncExternalStore)(Gf,()=>Kf(e),()=>Kf(e));return(0,I.useEffect)(()=>{qf(Kf(e))&&ep(e)},[e]),t?.card?(0,L.jsx)(a7,{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 d7=`frizz-project-rail`;function f7(){try{return localStorage.getItem(d7)===`shown`}catch{return!1}}function p7(e){try{localStorage.setItem(d7,e?`shown`:`hidden`)}catch{}}function m7(){yy();let e=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet(),placeholderData:ee}).data?.projectRail;return(0,I.useEffect)(()=>{e!==void 0&&p7(e===!0)},[e]),e===void 0?f7():e===!0}var h7=`/project/:slug`;function g7(){x7();let e=m7();return(0,L.jsxs)(CM,{children:[e?(0,L.jsx)(o5,{}):null,(0,L.jsx)(`div`,{className:e?J8:void 0,children:(0,L.jsx)(tb,{})}),(0,L.jsx)(P5,{}),(0,L.jsx)(l7,{})]})}function _7(e){(0,I.useEffect)(()=>{qC(e)||(fm(),uw())},[e])}function v7(){let{slug:e,thread:t}=Ty();return _7(e),b7(),(0,I.useState)(()=>Jp(t)),(0,L.jsx)(H8,{},e??`__launching__`)}function y7(){return(0,L.jsx)(y5,{})}function b7(){let e=yy();(0,I.useEffect)(()=>{Fw(Qd(e.pathname))},[e.pathname])}function x7(){let e=xy();(0,I.useEffect)(()=>(Rw((t,n)=>e(t,n)),()=>Rw(null)),[e])}function S7(){let{thread:e,slug:t}=Ty();return x7(),_7(t),(0,I.useState)(()=>{X.drawers.length>0&&(X.drawers=[])}),qp(e),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(R5,{slug:e}),(0,L.jsx)(P5,{})]})}var C7=[{index:!0,element:(0,L.jsx)(v7,{})},{path:`thread/:thread`,element:(0,L.jsx)(v7,{})},{path:`status/:status`,element:(0,L.jsx)(v7,{})}],w7=Gb([{path:`/thread/:thread/full`,element:(0,L.jsx)(S7,{})},{path:`${h7}/thread/:thread/full`,element:(0,L.jsx)(S7,{})},{element:(0,L.jsx)(g7,{}),children:[{path:`/`,element:(0,L.jsx)(y7,{})},{path:`/thread/:thread`,element:(0,L.jsx)(v7,{})},{path:`/status/:status`,element:(0,L.jsx)(v7,{})},{path:h7,children:C7},{path:`*`,element:(0,L.jsx)(v7,{})}]}]),T7=24,E7=6,D7=700,O7=new Map,k7=null,A7=null;function j7(e){return!Array.isArray(e)||e.length!==2?null:e[0]===`transcript`&&typeof e[1]==`string`?e[1]:null}function M7(e){return X.board?.threads.find(t=>t.id===e)?.lastActivityAt}function N7(){let e=[...O7.entries()].filter(([,e])=>e.observers>0),t=new Set(e.slice(-24).map(([e])=>e));for(let[e,n]of O7){if(n.observers<=0){n.live&&(n.live=!1,ow(e)),O7.delete(e);continue}t.has(e)?!n.live&&!n.queued&&(n.queued=!0):(n.queued=!1,n.live&&(n.live=!1,ow(e)))}P7()}function P7(){A7||[...O7.values()].some(e=>e.queued)&&(A7=setTimeout(()=>{A7=null;let e=0,t=[...O7.values()].filter(e=>e.live).length;for(let[n,r]of O7){if(e>=E7||t>=T7)break;r.queued&&(r.queued=!1,!(r.observers<=0||r.live)&&(r.live=!0,t++,r.lastActivityAt=M7(n),aw(n),e++))}P7()},D7))}function F7(){if(k7)for(let[e,t]of O7){if(t.observers<=0)continue;let n=M7(e);if(n===t.lastActivityAt)continue;t.lastActivityAt=n;let r=X.socketTranscriptFallbacks[e];t.live&&X.socketTranscripts&&!r||r&&r.kind!==`payload-too-large`||k7.refetchQueries({queryKey:[`transcript`,e],exact:!0,type:`active`})}}function I7(e){k7||(k7=e,e.getQueryCache().subscribe(e=>{let t=j7(e.query.queryKey);if(!t||e.type!==`observerAdded`&&e.type!==`observerRemoved`)return;let n=e.query.getObserversCount(),r=O7.get(t);e.type===`observerAdded`?(O7.delete(t),O7.set(t,{observers:n,live:r?.live??!1,queued:r?.queued??!1,lastActivityAt:r?r.lastActivityAt:M7(t)})):r&&(r.observers=n),N7()}),Zt(X,F7))}var L7=`ui-monospace, "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Mono", Consolas, Menlo, "DejaVu Sans Mono", monospace`,R7=`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;function z7(e){let t=e===`mono`?`mono`:`sans`;document.documentElement.dataset.font=t,document.body&&(document.body.style.fontFamily=t===`sans`?R7:L7);try{localStorage.setItem(`frizz-font`,t)}catch{}}function B7(e){let t=e.getQueryData([`settingsGet`]);t&&z7(t.font),Y.settingsGet().then(e=>z7(e.font)).catch(()=>{}),e.getQueryCache().subscribe(()=>{let t=e.getQueryData([`settingsGet`]);t&&z7(t.font)})}function V7(){let e=e=>{if(e.button!==0||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`.${XS}`):null;t&&(e.preventDefault(),e.stopPropagation(),U7(t))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)}function H7(e){return e.closest(`.md-code`)?.querySelector(`pre code`)??null}async function U7(e){let t=H7(e);if(!t)return;let n=(t.textContent??``).replace(/\n$/,``);if(n){try{await bV(n)}catch(e){Z(`Could not copy code: ${e.message.slice(0,100)}`,{duration:7e3});return}G7(e)}}var W7=new WeakMap;function G7(e){e.classList.add(ZS),e.title=`Copied`;let t=W7.get(e);t!==void 0&&window.clearTimeout(t),W7.set(e,window.setTimeout(()=>{e.classList.remove(ZS),e.title=QS,W7.delete(e)},i0))}var K7=/^\/thread\/([a-z0-9][a-z0-9-]*)\/?$/;function q7(){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=Yd(n);if(r&&r!==Yd())return;let i=K7.exec(Qd(n));i&&(e.preventDefault(),e.stopPropagation(),Wp(i[1]))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)}var J7=new Set([`projectsList`,`projectsQueueCounts`,`threadLocate`,`dispatchPreferencesGet`,`supervisorStatus`]);function Y7(e){let t=e[0];return typeof t==`string`&&J7.has(t)?T(e):T([`project:${Yd()??``}`,...e])}var X7=typeof window<`u`&&window.location.pathname.endsWith(`/settings-formatting-fixture.html`),Z7=typeof window<`u`?rf(Qd()):null;!X7&&!Z7&&Iw();var Q7=new Le({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,queryKeyHashFn:Y7}}});X7||(dw(Q7),I7(Q7),gU(Q7),B7(Q7),b$(),bJ(),V7(),q7()),X7||(0,ct.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(He,{client:Q7,children:(0,L.jsx)(Xh,{children:(0,L.jsx)(Zy,{router:w7})})}));export{a as i,tf as n,ze as r,Cb as t};
313
+ `)||void 0;return{line:`${Q$(e)} ${t.label}${r?` — ${r}`:``}`,...i?{body:i}:{}}}var e1=`root`;function t1(e,t,n){return`${e}/${t}.${n}`}function n1(e){let t=e.options??[],n=t.findIndex(e=>e.recommended),r=t.map((e,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 r1(e,t){return!t||e.kind===`multi`?null:t.chosen}function i1(e,t){let n=[],r=(e,i,a)=>{let{question:o,optionLabels:s}=n1(e);n.push({path:i,spec:e,question:o,optionLabels:s,depth:a});let c=r1(e,t.get(i));c!==null&&(e.options?.[c]?.followUps??[]).forEach((e,t)=>r(e,t1(i,c,t),a+1))};return r(e,e1,1),n}function a1(e,t){return t?t.text.trim()?!0:e.kind===`multi`?(t.chosenSet??[]).length>0:t.chosen!==null:!1}function o1(e,t){if(!a1(e.spec,t.get(`root`)))return;let n=(r,i)=>{let a=t.get(i),o=(r.options??[]).map(e=>e.label),s=r1(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,t1(i,s,t)));return{questionId:e.id,question:r.question,chosen:c,...l?{text:l}:{},...u.length>0?{followUps:u}:{}}};return n(e.spec,e1)}function s1(e){let t=e instanceof Error?e.message:`The answer could not be sent.`;return t.length>240?`${t.slice(0,239)}…`:t}var c1=(e,t)=>`${e}|${t}`,l1=(0,I.createContext)(null);function u1(e){let t=e?.id,n=e?.questions??[],r=mH(),[i,a]=(0,I.useState)(()=>new Map),[o,s]=(0,I.useState)(),c=(0,I.useContext)(N2),l=_H((0,I.useMemo)(()=>t?n.flatMap(e=>m1(e).map(n=>pH.question(r,t,e.id,n))):[],[r,t,n])),u=(e,n)=>{let a=i.get(c1(e.id,n));return{chosen:a?.chosen??null,chosenSet:a?.chosenSet??[],text:(t?l.get(pH.question(r,t,e.id,n)):void 0)??``}},d=e=>new Map(m1(e).map(t=>[t,u(e,t)])),f=n.flatMap(e=>{let t=o1(e,d(e));return t?[t]:[]}),p=st({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 m1(e))dH.set(pH.question(r,t,e.id,n),``)}},onError:e=>{c?.cancel(),s(s1(e))}}),m=st({mutationFn:async e=>Y.dismissQuestions({slug:t,ids:[e]}),onError:e=>s(s1(e))});return{slug:t,answerFor:u,answersOf:d,onChip:(e,t,n,r)=>{a(i=>{let a=new Map(i),o=c1(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&&(dH.set(pH.question(r,t,e.id,n),o),i||a(t=>{let r=c1(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 d1({thread:e,children:t}){let n=u1(e);return(0,L.jsx)(l1.Provider,{value:n,children:t})}function f1({q:e,answering:t}){let n=(0,I.useContext)(l1),r=t??n;if(!r||!r.slug)return null;let i=i1(e.spec,r.answersOf(e)),a=t=>(0,L.jsx)(fZ,{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)(Hh,{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 p1({thread:e,questions:t,inFlight:n=null,showSend:r=!1,className:i=``}){let a=e?.id,o=t??e?.questions??[],s=(0,I.useContext)(l1),c=u1(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)(eZ,{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)(f1,{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 m1(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,e1),t}function h1(e){return(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).length}function g1(e,t={}){let n=(e.subAgents??[]).filter(e=>ol(e)&&e.state===`running`).length,r=(e.bgShells??[]).filter(e=>e.state===`running`).length,i=t.watchers===!1?0:h1(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 _1(e){return(e.subAgents??[]).some(e=>ol(e)&&e.state===`running`)}function v1(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length}function y1(e){return _1(e)||v1(e)>0}function b1(e,t){return bl(t)??(x1(e)?`Background shells running`:`Awaiting`)}function x1(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length>0&&!_1(e)&&h1(e)===0&&S1(e).length===0}function S1(e){return(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`)}var C1={id:``,subAgents:[],bgShells:[],watches:[]},w1=[];function T1(e,t){let n=new Set((e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).map(e=>e.target));return hW(t).filter(e=>!n.has(e.ref))}function E1({watch:e}){return(0,I.useEffect)(()=>{e.url&&Xf([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:`${KY} text-[12px]`,children:e.ref}):(0,L.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.ref})}var D1={mergeable:`no conflicts`,blocked:`merge blocked`,conflicting:`has conflicts`,unknown:null};function O1(e){return e.state!==`open`||e.merge===`blocked`&&e.checks!==`passing`&&e.checks!==`none`?null:D1[e.merge]}var k1=`shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`;function A1({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 ${k1}`})}function j1(){return(0,L.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 16 16`,width:12,height:12,fill:`none`,stroke:`currentColor`,overflow:`visible`,className:k1,style:{color:vD.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 M1({status:e}){return e?e.state===`merged`?(0,L.jsx)(rh,{size:12,className:k1,style:{color:vD.fgDone}}):e.state===`closed`?(0,L.jsx)(ih,{size:12,className:k1,style:{color:vD.fgDanger}}):e.checks===`failing`?(0,L.jsx)(qm,{size:12,className:k1,style:{color:vD.fgDanger}}):e.checks===`passing`?(0,L.jsx)(Hm,{size:12,className:k1,style:{color:vD.fgSuccess}}):e.gated>0&&e.running===0?(0,L.jsx)(Vm,{size:12,className:k1,style:{color:vD.fgAttention}}):e.checks===`running`?(0,L.jsx)(j1,{}):(0,L.jsx)(Um,{size:12,className:`${k1} text-muted/60`}):(0,L.jsx)(Um,{size:12,className:`${k1} text-muted/60`})}function N1(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 P1(e){if(!e)return`Checking…`;if(e.state===`merged`)return`Merged`;if(e.state===`closed`)return`Closed`;let t=N1(e),n=O1(e);return[t||`No checks`,n].filter(e=>e!==null).join(` · `)}var F1=`group relative col-span-4 grid grid-cols-subgrid items-baseline rounded-sm text-[12px] leading-5`,I1=`group relative col-span-4 flex items-baseline rounded-sm text-[12px] leading-5`,L1=`ml-1.5 min-w-0 truncate font-medium text-fg/90`,R1=`ml-3 min-w-0 truncate text-right text-muted/70`,z1=`outline-none after:absolute after:inset-0 after:rounded-sm focus-visible:after:ring-1 focus-visible:after:ring-fg/60`;function B1(){return(0,L.jsx)(Rm,{size:13,"aria-hidden":!0,className:`${k1} ml-[3px] -mr-[4px] text-muted/35 transition-colors group-hover:text-muted/70`})}function V1({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?`${L1} flex-1`:L1,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} ${z1} 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} ${z1} 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?I1:F1} ${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:R1,children:n}),m?(0,L.jsx)(B1,{}):(0,L.jsx)(`span`,{})]})}function H1({status:e}){return e?e.state===`closed`?e.stateReason===`not_planned`||e.stateReason===`duplicate`?(0,L.jsx)(Km,{size:12,className:`${k1} text-muted`}):(0,L.jsx)(Hm,{size:12,className:k1,style:{color:vD.fgDone}}):(0,L.jsx)(Wm,{size:12,className:k1,style:{color:vD.fgSuccess}}):(0,L.jsx)(Um,{size:12,className:`${k1} text-muted/60`})}function U1(e){if(!e)return`Checking…`;if(e.state===`closed`){let t=e.stateReason===`not_planned`?`not planned`:e.stateReason===`duplicate`?`duplicate`:null;return t?`Closed as ${t}`:`Closed`}return`Open · ${e.comments} comment${e.comments===1?``:`s`}`}function W1({watch:e}){if(e.subject===`issue`)return(0,L.jsx)(G1,{watch:e});let t=e.github,n=pW(e.target);return(0,I.useEffect)(()=>{n&&Xf([e.target])},[n,e.target]),(0,L.jsx)(V1,{testKind:`github`,testId:e.target,mark:(0,L.jsx)(M1,{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:[P1(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 G1({watch:e}){let t=e.issue,n=pW(e.target,`issue`);return(0,I.useEffect)(()=>{n&&Xf([e.target])},[n,e.target]),(0,L.jsx)(V1,{testKind:`github`,testId:`issue:${e.target}`,mark:(0,L.jsx)(H1,{status:t}),name:t?.title?`${e.target} ${t.title}`:e.target,href:n??void 0,ghRef:n?e.target:void 0,title:n?`Open ${e.target} on GitHub`:e.target,status:U1(t)})}function K1(e,t){return(e.bgShells??[]).find(e=>e.id===t||e.taskId===t||e.label===t)}function q1(e){return(e.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`)}function J1({watch:e,thread:t,slug:n,now:r}){let i=K1(t,e.target);if(i)return(0,L.jsx)(Y1,{shell:i,slug:n,now:r,testId:e.target});let a=pD(e.createdAt,r);return(0,L.jsx)(V1,{testKind:`shell`,testId:e.target,mark:(0,L.jsx)(Lh,{size:12,className:`${k1} text-shell`}),name:e.target,title:e.target,status:a?`running · ${a}`:`running`})}function Y1({shell:e,slug:t,now:n,testId:r}){let i=pD(e.startedAt,n),a=e.id&&!e.outputUnavailable;return(0,L.jsx)(V1,{testKind:`shell`,testId:r??e.id??e.label,mark:(0,L.jsx)(Lh,{size:12,className:`${k1} text-shell`}),name:e.label,onOpen:a?()=>Up(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 X1({watch:e,now:t}){let n=Date.parse(e.timer?.fireAt??``),r=Number.isFinite(n)?n>t?`fires in ${dD(n-t)}`:`firing…`:`armed`;return(0,L.jsx)(V1,{testKind:`timer`,testId:e.target,mark:(0,L.jsx)(Jm,{size:12,className:`${k1} 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 Z1(e){return(e.subAgents??[]).filter(e=>ol(e)&&e.state===`running`)}function Q1({agent:e,slug:t,now:n}){let r=pD(e.startedAt,n),i=e.subagentType?.replace(/^frizz:/,``);return(0,L.jsx)(V1,{testKind:`agent`,testId:e.id??e.label,mark:(0,L.jsx)(A1,{tone:`border-accent`}),name:e.label,onOpen:e.id?()=>Hp(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 $1(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=K1(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 e0(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=i.filter(e=>e.subject!==`issue`),o=i.filter(e=>e.subject===`issue`),s=q1(e).filter(t=>r(K1(e,t.target)?.startedAt??t.createdAt));return{prs:a,issues:o,shells:[...s,...$1(e,t.hints??[],s)],agents:Z1(e).filter(e=>r(e.startedAt)),timers:S1(e).filter(e=>r(e.createdAt))}}function t0(e,t={}){let n=e0(e,t);return n.prs.length+n.issues.length+n.shells.length+n.agents.length+n.timers.length>0}function n0(e,t,n={}){let{prs:r,issues:i,shells:a,agents:o,timers:s}=e0(e,n);return[{head:`Sub-agents`,rows:o.map(n=>(0,L.jsx)(Q1,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:a.map(n=>(0,L.jsx)(J1,{watch:n,thread:e,slug:e.id,now:t},n.id))},{head:`Pull requests`,rows:r.map(e=>(0,L.jsx)(W1,{watch:e},e.id))},{head:`Issues`,rows:i.map(e=>(0,L.jsx)(W1,{watch:e},e.id))},{head:`Timers`,rows:s.map(e=>(0,L.jsx)(X1,{watch:e,now:t},e.id))}].filter(e=>e.rows.length>0)}function r0({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)(Rm,{size:10,"aria-hidden":!0,className:`${k1} ml-[5px] transition-transform ${e.collapsed?``:`rotate-90`}`})]}):(0,L.jsx)(`div`,{className:n,children:e.head})}function i0({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)(r0,{group:e,first:t===0}),!e.collapsed&&e.rows]},e.head))})]})}function a0(e){return e?.awaitingBackground===!0&&e.runtime===`turn-idle`&&e.bgSnoozed!==!0}var o0=`Hides card until new activity is detected`;function s0({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:o0,className:`disabled:opacity-45 ${qY}`,children:[(0,L.jsx)(ch,{size:12,className:kZ}),`Snooze`]}),(0,L.jsx)(`span`,{className:GY,children:o0})]})}function c0({thread:e,fence:t,onSnooze:n,onSnoozeFailed:r,notAfter:i}){let a=e??C1,o=t??(e?.lastFence?.kind===`awaiting`?e.lastFence:void 0),s=o?.hints??w1,c=_1(a),l=xW(o?.body),u=nJ(l??``),d=n0(a,eD(),{hints:s,notAfter:i}),f=T1(a,s),p=i===void 0&&e!==void 0&&a0(e)&&$Z(e).snooze;return(0,L.jsxs)(HY,{"data-awaiting-background":!0,icon:x1(a)?Lh:ch,label:(0,L.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:b1(a,s)}),aside:f.length===1?(0,L.jsx)(E1,{watch:f[0]}):void 0,className:p?`pb-0`:``,children:[l?(0,L.jsx)(tY,{className:`md-body ${PY}`,html:u}):d.length===0&&!y1(a)?(0,L.jsx)(`p`,{className:UY,children:mW}):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)(E1,{watch:e},e.ref))}),d.length===0&&y1(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 `,g1(a,{watchers:!1}),` it dispatched. It returns to the queue on its own when the work comes back.`]}):(0,L.jsxs)(L.Fragment,{children:[g1(a,{watchers:!1}),` `,v1(a)===1?`is`:`are`,` still running. It resumes on its own when`,` `,v1(a)===1?`it finishes`:`one of them finishes`,`.`]})}),(0,L.jsx)(i0,{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 ${LY}`,children:(0,L.jsx)(s0,{thread:e,onSnooze:n,onSnoozeFailed:r})}):null]})}function l0(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 u0(e,t=Date.now()){return e!==void 0&&bE(e,t)!==void 0}function d0(){let[e,t]=(0,I.useState)(()=>Date.now());return(0,I.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function f0({thread:e}){let t=d0(),[n,r]=(0,I.useState)(!1),i=bE(e,t);if(!i)return null;let a=Date.parse(i),o=LT(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)(HY,{"data-snooze-card":!0,icon:ch,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:hD(a-t)}),(0,L.jsx)(`p`,{className:UY,children:s?(0,L.jsxs)(L.Fragment,{children:[`Resumes `,o,` and sends: “`,VT(s),`”`]}):(0,L.jsxs)(L.Fragment,{children:[`Returns to the queue `,o,`.`]})}),e.foreign!==!0&&(0,L.jsx)(WY,{children:(0,L.jsx)(`button`,{type:`button`,"data-snooze-wake-now":!0,disabled:n,onClick:()=>void c(),className:`${qY} disabled:cursor-not-allowed disabled:opacity-45`,children:`Wake now`})})]})}function p0({at:e,fallbackAt:t,className:n=``}){let r=eD(),i=IE(e,t),a=LE(i,r);return!a||!i?null:(0,L.jsx)(`time`,{dateTime:i,className:n,children:a})}var m0=1500;function h0(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},m0),a},fail(t){t===n&&(i(),e(!1))},dispose(){n++,i()}}}var g0=`Could not copy terminal command`,_0={attach:`Attach command copied`,resume:`Resume command copied`},v0={attach:`Copy command to attach to this thread's live terminal`,resume:`Copy command to resume this thread in a new terminal`},y0=e=>[`terminalCommand`,e];function b0(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 x0(e){let t=b0(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 AV(n),r}function S0(e){let t=st({mutationFn:()=>x0(e)});return e=>t.mutate(void 0,{onSuccess:t=>{e?.onSuccess?.(),Z(_0[t])},onError:t=>{e?.onError?.(),Z(t instanceof Error?`${g0}: ${t.message}`:g0,{duration:7e3})}})}function C0({slug:e}){let[t,n]=(0,I.useState)(!1),r=(0,I.useRef)(null);r.current||=h0(n,{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)});let i=Ve(),a=S0(e);(0,I.useEffect)(()=>()=>r.current?.dispose(),[]);function o(){i.prefetchQuery({queryKey:y0(e),queryFn:()=>b0(e),staleTime:15e3})}function s(){let t=i.getQueryData(y0(e));if(t){AV(t.command).then(()=>{r.current?.begin(),Z(_0[t.mode])},()=>Z(g0,{duration:7e3}));return}a({onSuccess:()=>r.current?.begin()})}let c=i.getQueryData(y0(e)),l=t?c?_0[c.mode]:`Terminal command copied`:c?v0[c.mode]:`Copy terminal command`;return(0,L.jsx)(PM,{label:l,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":l,title:l,onClick:s,onPointerEnter:o,onFocus:o,className:ZD,children:t?(0,L.jsx)(Fm,{size:14,strokeWidth:2.2,className:`text-fg`}):(0,L.jsx)(Lh,{size:14,strokeWidth:1.8})})})}function w0(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 T0(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 E0(e){return`legacy:${e.role}:${e.kind??`message`}:${e.at??``}:${e.text}`}function D0(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??E0(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 O0(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 k0(e,t){let n=e.map(e=>e.message);return e.filter((e,r)=>!O0(n,r,t))}var A0=new Set([`agent`,`follow up`,`interrupt`,`send message`,`spawn agent`,`wait for agents`]),j0=new Set([`poll process`,`wait`]);function M0(e){return(e.split(`__`).pop()||e).replaceAll(`_`,` `).trim()}function N0(e){return M0(e).toLowerCase()}function P0(e){return e.prompt!==void 0||e.agentId!==void 0||e.sendTo!==void 0||e.sendBody!==void 0||e.backgroundState!==void 0&&!R0(e)&&!F0(e)||L0(e)||I0(e)||A0.has(N0(e.name))}function F0(e){return e.backgroundState===`background`&&J0(e)}function I0(e){return e.ask!==void 0&&e.ask.length>0&&e.status!==void 0&&e.status!==`pending`}function L0(e){return e.outputImage!==void 0||e.sentImages!==void 0&&e.sentImages.length>0}function R0(e){return e.backgroundState===`unknown`&&j0.has(N0(e.name))}function z0(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=>!P0(e))?t:null}return e.text.trim()||e.tools.length===0?null:e.tools.every(e=>!P0(e))?e.tools:null}function B0(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 V0(e){if(e.role!==`assistant`||e.kind||e.queued)return null;if(!e.parts?.length)return H0(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 H0(n.tools)}return null}function H0(e){let t=[];for(let n=e.length-1;n>=0&&!P0(e[n]);n--)t.unshift(e[n]);return t.length>0?t:null}function U0(e){if(e.role!==`assistant`||e.kind||e.queued)return null;let t=[],n=e=>{for(let n of e){if(P0(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 W0(e,t){return G0(e,new Set(t))}function G0(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 K0(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 q0(e){let t=[],n=null;return e.forEach((e,r)=>{if(B0(e))return;if(e.queued){t.push({message:e,messageIndex:r});return}let i=z0(e);if(i&&n){n.message=K0(n.message,i,e.at);return}let a=n?U0(e):null,o=a?W0(e,a):e;a&&n&&(n.message=K0(n.message,a,e.at));let s={message:o,messageIndex:r};t.push(s),V0(o)?(s.runStartedAt=o.at,n=s):n=null}),t}function J0(e){return e.status===`completed`||e.status===`failed`||e.status===`cancelled`}function Y0(e){let t=X0(e);if(!t)return;let n=t.tools.filter(e=>!F0(e));return n.some(e=>!J0(e))?n.at(-1):void 0}function X0(e){let t=Z0(e);if(!t)return;let n=V0(t.message);return n?{tools:n,at:t.message.at}:void 0}function Z0(e){for(let t=e.length-1;t>=0;t--)if(!e[t].message.queued)return e[t]}function Q0(e){let t=Z0(e);if(t)return V0(t.message)?t.runStartedAt??t.message.at:t.message.at}function $0(e){return e.runStartedAt??e.message.at}function e2(e){let t=V0(e);return t?G0(e,new Set(t)):e}function t2(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].message;if(!r.queued){V0(r)&&(t=r);break}}if(!t)return[...e];let n=[];for(let r of e){let e=r.message===t?e2(r.message):r.message;B0(e)||n.push(e===r.message?r:{...r,message:e})}return n}function n2(e){return e.detail?.trim()||void 0}var r2={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 i2(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=r2[i.toLowerCase()];return a?a+(r===-1?``:n.slice(r)):n.charAt(0).toUpperCase()+n.slice(1)}function a2(e,t,n){let r=t?.trim().replace(/[\\/]+$/,``);if(!r||!fp(r))return e;let i=bp(r);return i?Sp(e.replace(i,``),n?.trim().replace(/[\\/]+$/,``)||/^([A-Za-z]:[\\/]Users[\\/][^\\/]+|\/(?:Users|home)\/[^/]+)(?=[\\/]|$)/.exec(r)?.[1]):e}function o2(e,t,n=op().home){return a2(s2(e),t,n)}function s2(e){let t=N0(e.name),n=n2(e),r=n?` ${n}`:``;return t===`bash`||t===`exec`||t===`run command`?i2(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 ${M0(e.name)||`a tool`}`}var c2=new Set([`edit`,`multiedit`,`write`,`apply patch`]);function l2(e){let t=new Set;for(let n of e){for(let e of n.edits??(n.edit?[n.edit]:[])){let n=e.file.trim();n&&!u2.test(n)&&t.add(n)}if(n.edit||n.edits?.length)continue;let e=n.detail?.trim();e&&!u2.test(e)&&c2.has(N0(n.name))&&t.add(e)}return t.size}var u2=/\$\{/;function d2(e,t=0){let n=`Ran ${e} tool ${e===1?`call`:`calls`}`;return t===0?n:`${n}, edited ${t} file${t===1?``:`s`}`}function f2(e){return e>0?`${d2(e)}. Thinking…`:`Thinking…`}function p2(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function m2(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function h2(e,t){let n=p2(e,t);if(n)try{let e=new URL(n);return e.protocol===`https:`||e.protocol===`http:`?e.href:void 0}catch{return}}function g2({directive:e,icon:t,title:n,meta:r,children:i}){return(0,L.jsxs)(`section`,{"data-codex-directive":e.name,className:`min-w-0 ${FY} 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 _2({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 v2({directive:e}){let t=e.attrs,n=p2(t,`display_name`)??p2(t,`skill_name`)??`Artifact template`,r=p2(t,`artifact_kind`),i=p2(t,`skill_name`),a=p2(t,`skill_directory`),[o,s]=(0,I.useState)(!!a);return(0,L.jsxs)(g2,{directive:e,icon:(0,L.jsx)(ph,{size:15}),title:n,meta:r?`${r} template`:`Template`,children:[i&&(0,L.jsx)(_2,{mono:!0,children:i.startsWith(`$`)?i:`$${i}`}),o&&a&&(0,L.jsx)(`img`,{src:mC(`${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 y2({directive:e}){let t=e.attrs,n=p2(t,`file`),r=m2(t,`start`),i=m2(t,`end`)??r,a=m2(t,`priority`),o=n?`${n}${r?`:${r}${i&&i!==r?`-${i}`:``}`:``}`:`Code location unavailable`;return(0,L.jsxs)(g2,{directive:e,icon:(0,L.jsx)(vh,{size:15}),title:p2(t,`title`)??`Review finding`,meta:a===void 0?void 0:`P${a}`,children:[p2(t,`body`)&&(0,L.jsx)(_2,{children:p2(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)(_2,{mono:!0,children:o})]})}var b2={"git-stage":[Sh,`Changes staged`],"git-commit":[nh,`Commit created`],"git-create-branch":[th,`Branch created`],"git-push":[Vh,`Branch pushed`],"git-create-pr":[oh,`Pull request created`]};function x2({directive:e}){let[t,n]=b2[e.name],r=p2(e.attrs,`branch`),i=h2(e.attrs,`url`),a=`${n}${e.attrs.isDraft===!0?` as draft`:``}`;return(0,L.jsx)(g2,{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 S2({directive:e}){let t=p2(e.attrs,`threadId`),n=p2(e.attrs,`pendingWorktreeId`);return(0,L.jsx)(g2,{directive:e,icon:(0,L.jsx)(xh,{size:15}),title:n?`Thread setup queued`:`Thread created`,meta:(t||n)&&(0,L.jsx)(`span`,{className:`font-mono-keep`,children:t??n})})}function C2({directive:e}){let t=p2(e.attrs,`reason`);return(0,L.jsx)(g2,{directive:e,icon:(0,L.jsx)(km,{size:15}),title:`Archive suggested`,meta:t})}function w2(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 T2({directive:e}){let t=e.attrs,n=p2(t,`mode`),r=p2(t,`name`)??`Automation`,i=w2(t.rrule),a=[r,n,p2(t,`status`),i].filter(Boolean).join(` · `);return(0,L.jsx)(g2,{directive:e,icon:(0,L.jsx)(Pm,{size:15}),title:`Automation suggested`,meta:a,children:p2(t,`prompt`)&&(0,L.jsx)(_2,{children:p2(t,`prompt`)})})}function E2({directive:e}){return e.name===`artifact-template`?(0,L.jsx)(v2,{directive:e}):e.name===`code-comment`?(0,L.jsx)(y2,{directive:e}):e.name.startsWith(`git-`)?(0,L.jsx)(x2,{directive:e}):e.name===`created-thread`?(0,L.jsx)(S2,{directive:e}):e.name===`archive`||e.name===`archive-thread`?(0,L.jsx)(C2,{directive:e}):(0,L.jsx)(T2,{directive:e})}var D2;function O2(){return D2??=Cb(async()=>{let{default:e}=await import(`./mermaid.core-BtNCexa9.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)),D2}function k2({source:e}){let t=(0,I.useId)(),[n,r]=(0,I.useState)({}),i=VJ(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 O2().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:`${FY} 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 ${FY} 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 ${FY} bg-panel-2`})}var A2=(0,I.createContext)(null),j2=(0,I.createContext)(null);function M2(){let e=(0,I.useContext)(A2),t=(0,I.useContext)(j2);return e??t}var N2=(0,I.createContext)(null);function P2(e){return e.status===`pending`&&e.backgroundState===`background`}function F2(e){let t=[];for(let n of e)for(let e of n.tools)P2(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 I2(e){return e.map(e=>{if(!e.tools.some(P2))return e;let t=e.tools.filter(e=>!P2(e)),n=e.parts?.map(e=>e.kind===`tools`?{...e,tools:e.tools.filter(e=>!P2(e))}:e).filter(e=>e.kind!==`tools`||e.tools.length>0);return{...e,tools:t,parts:n}})}function L2({slug:e,onStatusApplied:t,onClose:n,virtualized:r=!1,showReturnToQueue:i=!1}){let a=hm(xw(),e);return(0,L.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,L.jsx)(Y2,{slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:i}),(0,L.jsx)(R2,{slug:e,virtualized:r}),a&&(0,L.jsx)(EQ,{thread:a,sticky:!0,safeArea:!0,onArchived:t})]})}function R2({slug:e,virtualized:t}){let n=xw(),r=hm(n,e),i=r?.runtime===`running`||r?.runtime===`spawning`,a=S0(e),o=Iw(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)(()=>F2(p),[p]),h=(0,I.useMemo)(()=>I2(p),[p]),g=(0,I.useMemo)(()=>l4(h),[h]),_=(0,I.useMemo)(()=>i?l0(h):void 0,[i,h]),v=_&&_.index>=0?_.index:g,y=(0,I.useMemo)(()=>q0(h),[h]),b=i?X0(y):void 0,x=i?Y0(y):void 0,S=x?o2(x,n?.projectDir):void 0,C=i?Q0(y):void 0,w=a0(r),T=(0,I.useMemo)(()=>{let e=i?t2(y):y;return k0(e,u4(e,v,w))},[y,i,v,w]),E=i,D=(0,I.useMemo)(()=>fX(p),[p]),O=(0,I.useMemo)(()=>sX(p,r?.answersInFlight),[p,r?.answersInFlight]),k=(0,I.useMemo)(()=>TZ(p),[p]),A={thread:r,showWorking:E,registeredDone:NY(r,g>=0?h[g]?.text:void 0),restedCard:JY(r,g>=0?h[g]?.text:void 0),errorVisible:XY(h,r?.providerError)},{answeringForMessage:j}=cZ(e,p),M=(0,I.useMemo)(()=>yX(p,r?.questions??[]),[p,r?.questions]),N=(0,I.useMemo)(()=>DX(p,r?.questions??[],{atRest:!i}),[p,i,r?.questions]),P=lu(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],Zx(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)(A2.Provider,{value:e,children:(0,L.jsx)(d1,{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)(q2,{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)(B$,{thread:r,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(p1,{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)(Bh,{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; it refreshes over HTTP each time the thread moves.`:`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)(m3,{}),` Loading…`]}):i?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(m3,{}),` Session starting…`]}):jZ(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:[m4(T.map(e=>e.message),(e,t)=>{let n=T[t].messageIndex;return(0,L.jsx)(Y4,{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&&W2(A)!==null&&(0,L.jsx)(OX,{h:G2(A,T.map(e=>e.message))}),re&&(0,L.jsx)(K2,{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)(o3,{policy:r.permPolicy,denies:r.permDenies})}):null,p.some(e=>e.queued)&&(0,L.jsx)(OX,{}),(0,L.jsx)(`div`,{className:`flex flex-col gap-3.5`,children:p.map((e,t)=>e.queued?(0,L.jsx)(Y4,{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)(WZ,{slug:e,onTerminal:a,ops:(0,L.jsx)(s3,{slug:e,transcriptShells:m,className:`px-1 pt-1.5`})})})]})})})}var z2=700,B2=250,V2=(()=>{try{return localStorage.getItem(`frizz.debugScroll`)===`1`}catch{return!1}})();function H2(e){return e?.pendingInteraction===!0}function U2(e){return H2(e)?void 0:e?.pendingAsk}function W2({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`:U2(e)?`pending-ask`:e?.runtime===`perm-prompt`&&!H2(e)?`perm-prompt`:t?`working`:e?.providerError?i?null:`provider-error`:u0(e)?`snooze`:a0(e)?`resting`:n?`registered-done`:r?`rested`:null}function G2(e,t){return W2(e)===`working`?p4(t):14}function K2({state:e,slug:t,retryText:n,onTerminal:r,liveRuntimeStart:i,liveActivityLabel:a,liveToolRun:o}){let s=e.thread;switch(W2(e)){case`provider-fault`:return(0,L.jsx)(r3,{slug:t,sessionId:s.sessionId,fault:s.providerFault,retryText:n});case`provider-error`:return(0,L.jsx)(ZY,{error:s.providerError});case`limit-pause`:return(0,L.jsx)(i3,{slug:t,sessionId:s.sessionId,pause:s.limitPause});case`pending-ask`:return(0,L.jsx)(c3,{ask:U2(s),onTerminal:r});case`perm-prompt`:return(0,L.jsx)(a3,{onTerminal:r});case`working`:return(0,L.jsx)(h3,{since:s?.lastUserAt,startedAt:i,activityLabel:a,run:o});case`snooze`:return(0,L.jsx)(f0,{thread:s});case`resting`:return(0,L.jsx)(c0,{thread:s});case`registered-done`:return(0,L.jsx)(n3,{fenceKind:`done`,body:s.lastFence.body,hints:[]});case`rested`:return(0,L.jsx)(YY,{thread:s});default:return null}}function q2({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=Sw(),C=(0,I.useMemo)(()=>q0(r),[r]),w=u?X0(C):void 0,T=u?Y0(C):void 0,E=T?o2(T,S):void 0,D=u?Q0(C):void 0,O=(0,I.useMemo)(()=>l4(r),[r]),k=(0,I.useMemo)(()=>u?l0(r):void 0,[u,r]),A=k&&k.index>=0?k.index:O,j=a0(l),M=(0,I.useMemo)(()=>{let e=u?t2(C):C;return k0(e,u4(e,A,j))},[C,u,A,j]),N=u,P=(0,I.useMemo)(()=>D0(M.map(e=>e.message),u4(M,A,j),s4).map(e=>{let t=M[e.messageIndex];return{...e,messageIndex:t.messageIndex,stampAt:$0(t)}}),[M,A,j]),ee=(0,I.useMemo)(()=>TZ(r),[r]),F=NY(l,O>=0?r[O]?.text:void 0),te=JY(l,O>=0?r[O]?.text:void 0),ne=XY(r,l?.providerError),re={thread:l,showWorking:N,registeredDone:F,restedCard:te,errorVisible:ne},ie=W2(re)!==null,ae=(0,I.useMemo)(()=>G2({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 gX(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)(()=>yX(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=wT({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=qD(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()+B2;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=w0({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),V2&&!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=T0({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()+z2,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)(B$,{thread:l,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(p1,{thread:l,questions:oe.tail,inFlight:a,showSend:s.placedIds.size>0,className:`px-6 pt-5`})]}):n.kind===`questions`?(0,L.jsx)(p1,{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 ${FY} 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)(Bh,{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; it refreshes over HTTP each time the thread moves.`:`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)(hh,{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)(ZQ,{at:n.stampAt,host:OZ(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(Y4,{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)(K2,{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)(o3,{policy:l.permPolicy,denies:l.permDenies})}):null]}):(0,L.jsx)(ZQ,{at:n.message.at,host:OZ(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(Y4,{m:n.message,paired:i[n.messageIndex]})})},n.key):null}),(0,L.jsx)(J2,{overlay:x,hidden:ue,onJump:()=>le.scrollToEnd({behavior:`smooth`})})]})}function J2({overlay:e,hidden:t,onJump:n}){return!e||t?null:(0,lt.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)(Am,{size:12}),`Jump to latest`]}),e)}function Y2({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1}){let i=hm(xw(),e),a=st({mutationFn:()=>Y.markComplete({slug:e})}),o=Uq(nt({queryKey:[`threadBody`,e],queryFn:()=>Y.threadBody({slug:e})}).data?.markdown??``).trim().length>0;if(!i)return null;let s=i.kind===`session`&&i.foreign!==!0;return(0,L.jsxs)(`header`,{"data-thread-header":!0,className:MZ,children:[(0,L.jsx)(`div`,{className:NZ,children:(0,L.jsxs)(`div`,{className:`min-w-0 leading-tight`,children:[(0,L.jsx)(FQ,{thread:i}),(0,L.jsx)(p0,{at:lE(i),fallbackAt:i.spawnedAt,className:`mt-0.5 block truncate text-[11px] leading-tight text-muted/75`})]})}),(0,L.jsxs)(`div`,{className:PZ,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[s&&(0,L.jsx)(C0,{slug:e}),(0,L.jsx)(XZ,{thread:i,collapse:r,onDoc:o?()=>Vp(`doc`,i.id):void 0,onDone:()=>a.mutate(void 0,{onSuccess:t}),doneBusy:a.isPending,onStatusApplied:t}),n&&(0,L.jsx)(FM,{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)(Hh,{size:15})})]})]})}function X2(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||BQ(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 Z2(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||BQ(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 Q2(e){return X2(e)!==null}function $2(e){return Z2(e)!==null}function e4(e){return e.kind===`event`&&!e.boundary||e.kind===`reasoning`}function t4(e){return e4(e)||Q2(e)}function n4(e){return e4(e)||$2(e)}function r4(e){if(e4(e))return!0;let t=X2(e);return t!==null&&!P0(t[t.length-1])}function i4(e){if(e4(e))return!0;let t=Z2(e);return t!==null&&!P0(t[0])}function a4(e){let t=X2(e);return t!==null&&L0(t[t.length-1])}function o4(e){let t=Z2(e);return t!==null&&L0(t[0])}function s4(e,t){let n=a4(e)||o4(t),r=!n&&t4(e)&&n4(t)&&!(r4(e)&&i4(t));return(n?22:r?6:14)+(e.role===`user`&&t.role!==`user`?3:0)}function c4(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:d4(e,n.text,t)):(e.tools?.length??0)===0&&d4(e,e.text,t)}function l4(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`&&e[t].kind!==`event`)return t;return-1}function u4(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=>c4(e,r.has(e))}function d4(e,t,n){return!e.fenceRefused&&!n?!t.trim():MY(t).every(e=>e.kind===`fence`&&e.fenceKind===`awaiting`)}function f4(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`&&!d4(e,n.text,t)):typeof e.text==`string`&&!d4(e,e.text,t)}function p4(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.queued||c4(n)))return a4(n)?22:t4(n)&&!r4(n)?6:14+(n.role===`user`?3:0)}return 0}function m4(e,t,n){let r=[],i=null;return e.forEach((e,a)=>{n?.(e,a)||c4(e)||(i!==null&&r.push((0,L.jsx)(OX,{h:s4(i,e)},`s${a}`)),r.push(t(e,a)),i=e)}),r}function h4(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 g4(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)(OX,{h:typeof t==`number`?t:t(n)},`vs${n}`)),r.push(e)}),r}var _4={head:!1,tail:!1};function v4(e,t){return n=>e[n-1]?.tail||e[n]?.head?22:t}function y4(e){return{head:L0(e[0]),tail:L0(e[e.length-1])}}function b4(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}):I0(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 x4(e){return e.split(`__`).pop()||e}function S4(e){let t=X.board?.projectDir;return t&&e.startsWith(t+`/`)?e.slice(t.length+1):e}function C4({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=d2(a,l2(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 ${QQ}`,children:[(0,L.jsx)(`span`,{"data-tool-activity-label":!0,title:o,className:`min-w-0 truncate text-muted`,children:o}),(0,L.jsx)(Rm,{"data-tool-activity-chevron":!0,"aria-hidden":`true`,size:13,className:e$(n)})]}),n&&(0,L.jsx)(`div`,{id:i,className:`mt-1.5 flex flex-col`,children:g4(e.map((e,n)=>(0,L.jsx)(T4,{t:e,startedAt:t},n)),6)}),!n&&(0,L.jsx)(`div`,{id:i,hidden:!0})]})}function w4({tools:e,at:t}){let n=[];for(let t of e){let e=P0(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:g4(n.map((e,n)=>e.exceptional?(0,L.jsx)(`div`,{className:`flex flex-col`,children:g4(e.tools.map((e,n)=>(0,L.jsx)(T4,{t:e,startedAt:t},n)),v4(e.tools.map(e=>y4([e])),6))},`exceptions-${n}`):(0,L.jsx)(C4,{tools:e.tools,at:t},`activity-${n}`)),v4(n.map(e=>y4(e.tools)),6))})}function T4({t:e,startedAt:t}){let n=(0,I.useContext)(A2),r=xw(),i=cD(e,(n?hm(r,n):void 0)?.bgShells??[]);return e.edits&&e.status!==`failed`&&e.status!==`cancelled`?(0,L.jsx)(RJ,{edits:e.edits,meta:(0,L.jsx)(A4,{status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,durationMs:e.durationMs})}):e.command?(0,L.jsx)(R4,{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)(F4,{name:e.name,detail:e.detail,outputImage:e.outputImage,output:e.output,status:e.status,durationMs:e.durationMs}):e.read?(0,L.jsx)(B4,{detail:e.detail,read:e.read,status:e.status,durationMs:e.durationMs}):e.prompt||e.agentId?(0,L.jsx)(H4,{detail:e.detail,prompt:e.prompt,subagentType:e.subagentType,agentId:e.agentId,agentStatus:e.agentStatus,agentElapsedMs:e.agentElapsedMs,status:e.status,durationMs:e.durationMs}):e.sendTo!==void 0||e.sendBody!==void 0?(0,L.jsx)(W4,{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)(I4,{images:e.sentImages??[],files:e.sentFiles??[],caption:e.caption,status:e.status,durationMs:e.durationMs}):e.todos?(0,L.jsx)(cY,{todos:e.todos,note:e.input,meta:(0,L.jsx)(A4,{status:e.status,durationMs:e.durationMs})}):I0(e)?(0,L.jsx)(E4,{ask:e.ask??[],askAnswers:e.askAnswers}):e.input||e.output?(0,L.jsx)(R4,{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)(P4,{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 E4({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=I$(e,t?.[n]);return(0,L.jsx)(fZ,{question:r.question,settled:{chosenIdxs:r.chosenIdxs,text:r.text}},n)})})}function D4({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 O4(e,t,n){let[r,i]=(0,I.useState)(()=>Date.now()),a=aD(e,t),o=oD(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(iD-(Date.now()-e),0));return()=>clearTimeout(t)},[a,o,n]),o}function k4({status:e,backgroundState:t,liveBackgroundState:n,startedAt:r}){let i=O4(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:ED}):rD(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 A4({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:lD(i),c=[o,s].filter(Boolean).join(` · `);return(0,L.jsx)(D4,{tone:e===`failed`?`frizz-tool-failed`:e===`cancelled`?`text-amber-400`:`text-muted/55`,title:c,label:a,duration:s})}function j4(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 M4(e,t,n){let r=t&&t!==X.board?.projectDir?`in ${S4(t)}`:void 0;return[e,t?r:n!==void 0&&!e?.includes(String(n))?`session ${n}`:void 0].filter(Boolean).join(` · `)||void 0}function N4(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.includes(`…`)}function P4({name:e,detail:t,count:n,status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,cwd:s,sessionId:c,durationMs:l,startedAt:u}){let d=M4(t,s,c),f=d?S4(d):void 0,p=t&&N4(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)(k4,{status:r,backgroundState:i,liveBackgroundState:a,startedAt:u}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:x4(e)}),f&&(p?(0,L.jsx)(`span`,{className:`min-w-0 truncate`,onClick:e=>e.stopPropagation(),children:(0,L.jsx)(LJ,{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)(A4,{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 F4({name:e,detail:t,outputImage:n,output:r,status:i,durationMs:a}){let o=t?S4(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:x4(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)(A4,{status:i,durationMs:a})})]});return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(Z4,{path:n,hideCaption:!0,altText:o?`${x4(e)}: ${o}`:x4(e),header:s}),r&&(0,L.jsx)(`pre`,{className:`frizz-bash frizz-bash-body frizz-bash-output-body mt-1.5`,children:r})]})}function I4({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)(A4,{status:r,durationMs:i}),(0,L.jsx)(Rm,{"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)(Z4,{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)(Q4,{path:e},`f${t}`))}),n&&(0,L.jsx)(`div`,{className:`max-w-[65%] text-[12px] leading-snug text-muted`,children:n})]})})]})}var L4=16;function R4({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=j4(i,d,l),b=(0,I.useMemo)(()=>e.split(`
314
+ `).length,[e]),x=b>L4,S=(0,I.useMemo)(()=>n?n.split(`
315
+ `).length:0,[n]),C=S>L4,w=M4(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`} `:``}${x4(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)(k4,{status:i,backgroundState:a,liveBackgroundState:o,startedAt:d}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:x4(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)(A4,{status:i,backgroundState:a,liveBackgroundState:o,exitCode:s,durationMs:y}),T&&(0,L.jsx)(Rm,{"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)(nY,{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 z4=16;function B4({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>z4,d=e?S4(e):void 0,f=e&&N4(e)?e:void 0;return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(IJ,{className:`frizz-bash-header`,controls:c,expanded:i,label:`${i?`Collapse`:`Expand`} Read${e?`: ${e}`:``}`,onToggle:()=>a(e=>!e),meta:(0,L.jsx)(A4,{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)(LJ,{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)(nY,{text:t,language:KS(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 V4=16;function H4({detail:e,prompt:t,subagentType:n,agentId:r,agentStatus:i,agentElapsedMs:a,status:o,durationMs:s}){let[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(!1),f=(0,I.useId)(),p=t||`Initial prompt unavailable.`,m=(0,I.useMemo)(()=>p?p.split(`
317
+ `).length:0,[p]),h=m>V4,g=M2(),_=xw(),v=g?hm(_,g):void 0,y=!i&&r?(v?.subAgents??[]).find(e=>e.id===r):void 0,b=y?.state===`running`,x=!!(g&&r),S=e??`sub-agent`,C=zQ(n),w=eD(),T=GQ({agentStatus:i,agentElapsedMs:a,liveState:y?.state,liveElapsedMs:y?.startedAt?Math.max(w-Date.parse(y.startedAt),0):void 0,status:o,durationMs:s}),E=b?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--agent`,"data-running-indicator":`subagent-disclosure`}):y?.state===`stale`?(0,L.jsx)(`span`,{className:SD,title:CD}):y?.state===`rested`?(0,L.jsx)(`span`,{className:wD,title:TD}):null;function D(){!g||!r||Hp(g,r,{label:S,subagentType:n,startedAt:y?.startedAt})}return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(IJ,{className:`frizz-bash-header`,controls:f,expanded:c,label:`${c?`Collapse`:`Expand`} Agent dispatch: ${S}`,onToggle:()=>l(e=>!e),meta:(C||T)&&(0,L.jsxs)(L.Fragment,{children:[C&&(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: ${C}`,children:C}),C&&T&&(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:`·`}),T&&(0,L.jsx)(D4,{tone:T.tone===`failed`?`frizz-tool-failed`:`text-muted/55`,title:T.title,label:T.label,duration:T.duration})]}),children:[E&&(0,L.jsx)(`span`,{className:`frizz-tool-mark -mr-1 flex w-[9px] shrink-0 justify-center`,children:E}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Agent`}),x?(0,L.jsx)(`button`,{type:`button`,"aria-label":`Open sub-agent transcript: ${S}`,title:`Open sub-agent transcript`,onClick:D,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:S}):(0,L.jsx)(`span`,{className:`min-w-[4rem] flex-1 truncate text-[11.5px] text-muted`,title:S,children:S})]}),(0,L.jsx)(`div`,{id:f,hidden:!c,children:c&&(0,L.jsxs)(L.Fragment,{children:[p&&(0,L.jsx)(`pre`,{className:`frizz-bash-body${h&&!u?` frizz-bash-clamp`:``}`,children:p}),h&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:u?`Collapse`:`Show all ${m} lines`})]})})]})}function U4(e,t){return t===`shutdown_request`?`Shutdown`:t===`codex_followup`?`Followed up`:e===`main`?`Reported`:`Steered`}function W4({to:e,summary:t,body:n,type:r,dispatchId:i,targetLabel:a,status:o,durationMs:s,at:c}){return(0,I.useContext)(A2)===null?(0,L.jsx)(K4,{to:e,summary:t,body:n,type:r,status:o,durationMs:s}):(0,L.jsx)(d3,{to:e,type:r,dispatchId:i,targetLabel:a,at:c})}var G4=16;function K4({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=VJ(nJ(n)),f=(0,I.useMemo)(()=>n.split(`
318
+ `).length,[n]),p=f>G4,m=!!n.trim(),h=U4(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)(A4,{status:i,durationMs:a}),m&&(0,L.jsx)(Rm,{"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 q4({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)(()=>xR(e,[...i.keys()]),[e,i]).map((e,t)=>{let a=e.token?i.get(e.token):void 0;if(!a)return(0,L.jsx)($X,{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:mR(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 J4({text:e,rawText:t,queued:n,deliveryUnconfirmed:r,deliveryId:i,sourceId:a}){let o=(0,I.useContext)(A2),s=_Z(o),{unqueue:c,pending:l}=xZ(o),u=!!(n&&i&&o&&s),d=SZ(n?o:null),{deliverNow:f,pending:p}=CZ(o),m=!!(n&&o&&d),{prose:h,attachments:g}=(0,I.useMemo)(()=>dR(e),[e]),_=(0,I.useMemo)(()=>OR(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)(q4,{body:_.body,items:_.items}):(0,L.jsx)($X,{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)(hh,{size:15,strokeWidth:2.2,className:`animate-spin`}):(0,L.jsx)(jm,{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)(Z4,{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)(Q4,{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 Y4=(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=qG(),[p,m]=(0,I.useState)(!1);if(e.providerError)return(0,L.jsx)(ZY,{error:e.providerError});if(e.kind===`event`)return(0,L.jsx)(f3,{text:e.text,boundary:e.boundary,sourceId:e.sourceId,at:e.at});if(e.kind===`reasoning`)return(0,L.jsx)(p3,{text:e.text,sourceId:e.sourceId});let h=BQ(e);if(h)return(0,L.jsx)(l3,{call:h,sourceId:e.sourceId,at:e.at});if(e.role===`user`){let t=wZ(e).replace(/\r\n?/g,`
319
+ `),i=r===void 0?rX(t):r;if(i)return(0,L.jsx)(eZ,{answers:i,queued:e.queued,sourceId:e.sourceId});let a=e.wake?jl(t):void 0;return a?(0,L.jsx)(KX,{bump:a,sourceId:e.sourceId,at:e.at}):e.wake?(0,L.jsx)(PX,{steer:e.wakeSteer,text:t,sourceId:e.sourceId,at:e.at,wrap:n}):e.peerFrom?(0,L.jsx)(u3,{from:e.peerFrom,unnamed:e.peerUnnamed,dispatchId:e.peerDispatchId,sourceId:e.sourceId,at:e.at}):(0,L.jsx)(J4,{text:t,rawText:e.text,queued:e.queued,deliveryUnconfirmed:e.deliveryState===`unconfirmed`,deliveryId:e.deliveryId,sourceId:e.sourceId})}let g=[],_=[],v=(e,t=_4)=>{g.push(e),_.push(t)},y={n:-1},b={drawn:!1},x=[],S=new Set,C=(r,i)=>{for(let[a,l]of MY(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)(n3,{fenceKind:l.fenceKind,body:l.body,hints:l.hints,wrap:n,notAfter:d},`${i}-f${a}`));continue}for(let[e,r]of fY(l.text).entries()){if(r.kind===`prose`){for(let[t,o]of uR(r.text).entries()){let r=`${i}-${a}-p${e}-${t}`;v(o.kind===`image`?(0,L.jsx)(Z4,{path:o.path},r):o.kind===`file`?(0,L.jsx)(Q4,{path:o.path},r):o.kind===`visualization`?(0,L.jsx)(t3,{file:o.file},r):o.kind===`directive`?(0,L.jsx)(E2,{directive:o.directive},r):o.kind===`mermaid`?(0,L.jsx)(k2,{source:o.source},r):(0,L.jsx)(X4,{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)(f1,{q:l},`${i}-${a}-q${e}`));continue}if(s&&TX(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)(fZ,{raw:r.text,questionKind:r.questionKind,danger:r.danger,interactive:u,wrap:n},`${i}-${a}-q${e}`))}}};if(e.parts&&e.parts.length>0)h4(e.parts).forEach((t,r)=>{if(t.kind===`tools`){if(i)return;let a=b4(t.tools);a.length&&v((0,L.jsx)(w4,{tools:a,dense:n,at:e.at},`t${r}`),y4(a))}else C(t.text,`x${r}`)});else{if(!i){let t=b4(e.tools);t.length>0&&v((0,L.jsx)(w4,{tools:t,dense:n,at:e.at},`tools`),y4(t))}C(e.text,`leg`)}return d!==void 0&&l&&!b.drawn&&!e.fenceRefused&&t0(l,{notAfter:d})&&v((0,L.jsx)(c0,{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:[g4(g,v4(_,14)),p&&t&&x.length>0?(0,L.jsx)(gZ,{blocks:x,answering:t,onClose:()=>m(!1)}):null]}))});function X4({md:e,wrap:t}){let n=nJ(e),r=VJ(n),i=(0,I.useRef)(null);return eY(i,n),n?(0,L.jsx)(`div`,{ref:i,className:`md-body${t?` ${PY}`:``}`,dangerouslySetInnerHTML:r}):null}function Z4({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=_p(e);return(0,L.jsx)(xq,{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:mC(e),alt:n??o,"data-local-path":e,"data-local-image":`true`,onError:()=>a(!0),className:`cursor-pointer ${wq}`})})}function Q4({path:e}){let t=_p(e);return(0,L.jsxs)(`button`,{type:`button`,className:`local-file-action inline-flex max-w-full items-center gap-1.5 ${FY} 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)($m,{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 $4={"--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 e3(){let e=getComputedStyle(document.documentElement),t=Object.fromEntries(Object.entries($4).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 t3({file:e}){let t=(0,I.useContext)(A2),n=(0,I.useRef)(null),[r,i]=(0,I.useState)(360),[a,o]=(0,I.useState)(null),s=t?`${tf()}/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:`${FY} 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 ${FY} 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(e3(),`*`),className:`block w-full border-0 bg-transparent`,style:{height:r}})}function n3({fenceKind:e,body:t,hints:n,wrap:r,notAfter:i}){let a=nJ(t),o=(0,I.useContext)(A2),s=(0,I.useContext)(N2),c=xw(),l=o?hm(c,o):void 0,u=l?$Z(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)(HY,{icon:Fm,label:`Done`,children:[a&&(0,L.jsx)(tY,{className:`md-body${r?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:a}),p&&(0,L.jsx)(WY,{children:(0,L.jsx)(kQ,{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&&a0(l)?null:(0,L.jsx)(c0,{thread:l,fence:{body:t,hints:n},notAfter:i})}function r3({slug:e,sessionId:t,fault:n,retryText:r}){let[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(!1),c=Ve(),l=NV[n.backend],u=t=>{s(!0),uW(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)(HY,{"data-provider-fault":!0,tone:`danger`,icon:fh,label:`${l} sign-in required`,children:[(0,L.jsx)(`span`,{className:UY,children:`The provider rejected this session's credential. Sign in, then retry.`}),(0,L.jsxs)(WY,{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:qY,children:`Sign in`})]}),i&&(0,L.jsx)(IV,{backend:n.backend,onClose:()=>a(!1),onAuthed:()=>a(!1)})]})}function i3({slug:e,sessionId:t,pause:n}){let r=n.backend===`acp`?`The agent`:NV[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)(HY,{"data-limit-pause":!0,tone:`caution`,icon:ch,label:`Paused by the ${r} ${i}`,children:[(0,L.jsx)(`span`,{className:UY,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)(WY,{children:(0,L.jsx)(`button`,{onClick:()=>{o(!0),uW(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 ${qY}`,children:`Continue now`})})]})}function a3({onTerminal:e}){return(0,L.jsxs)(HY,{tone:`attention`,icon:fh,label:`Permission approval`,children:[(0,L.jsx)(`span`,{className:UY,children:`The agent is waiting on your approval — respond in your external terminal.`}),(0,L.jsx)(WY,{children:(0,L.jsx)(`button`,{onClick:()=>e(),onMouseDown:e=>e.preventDefault(),className:qY,children:`Copy terminal command`})})]})}function o3({policy:e,denies:t}){let n=[e.tool,e.command].filter(Boolean).join(`: `);return(0,L.jsxs)(HY,{tone:`caution`,icon:Bh,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:UY,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 s3({slug:e,className:t=`px-4 pb-2 pt-1`,includeAgents:n=!0,transcriptShells:r=[],parentAgentId:i}){let a=hm(xw(),e),o=a?.subAgents??[],s=n?i?FD(o,i):o:[],c=i?[...r]:zD(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=zw(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:[LD(s,`sheet`).map((t,n)=>(0,L.jsx)(BD,{kind:`AGENT`,label:t.label,state:t.state,density:`sheet`,depth:t.displayDepth??t.depth,startedAt:t.startedAt,onOpen:t.id?()=>Hp(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:LM(e,t)},`a${n}`)),LD(c,`sheet`).map((t,n)=>(0,L.jsx)(BD,{kind:`SHELL`,label:t.label,state:t.state,density:`sheet`,startedAt:t.startedAt,counter:t.id?OD(h.get(t.id)):void 0,counterTitle:`Lines of output so far — open the row to read them`,onOpen:t.id&&!t.outputUnavailable?()=>Up(e,t.id,{label:t.label,startedAt:t.startedAt}):void 0,onDismiss:LM(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)(BD,{kind:`GITHUB`,label:e.target,state:`running`,density:`sheet`,startedAt:e.createdAt,counter:e.subject===`issue`?AD(e.issue):kD(e.github),counterTone:e.github?.checks===`failing`?`danger`:void 0,counterTitle:e.subject===`issue`?e.issue?`${e.target} — ${U1(e.issue)}`:void 0:e.github?`${e.target} — ${P1(e.github)}`:void 0,onOpen:()=>window.open(pW(e.target,e.subject===`issue`?`issue`:`pull`)??`https://github.com/${e.target.replace(`#`,e.subject===`issue`?`/issues/`:`/pull/`)}`,`_blank`,`noreferrer,noopener`)},e.id)),(0,L.jsx)(YQ,{links:u})]})}function c3({ask:e,onTerminal:t}){return(0,L.jsxs)(HY,{tone:`attention`,icon:Gm,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)(WY,{children:(0,L.jsxs)(`button`,{onClick:()=>t(),onMouseDown:e=>e.preventDefault(),className:qY,children:[(0,L.jsx)(fh,{size:12,className:`shrink-0 ${kZ}`}),`Copy terminal command`]})})]})}function l3({call:e,sourceId:t,at:n}){let r=M2(),i=e.detail??`sub-agent`,{tail:a}=HQ(e),o=!!(r&&e.agentId);return(0,L.jsxs)(kX,{icon:Nm,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:DD.AGENT,"aria-label":`${DD.AGENT}: ${i}`,onClick:()=>Hp(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 u3({from:e,unnamed:t,dispatchId:n,sourceId:r,at:i}){let a=M2(),o=!!(a&&n),s=t?void 0:e,c=t&&e?`${DD.AGENT} — ${e}`:DD.AGENT;return s===void 0?(0,L.jsx)(kX,{icon:Nm,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":`${DD.AGENT}${e?`: ${e}`:``}`,onClick:()=>Hp(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)(kX,{icon:Nm,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:DD.AGENT,"aria-label":`${DD.AGENT}: ${s}`,onClick:()=>Hp(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 d3({to:e,type:t,dispatchId:n,targetLabel:r,sourceId:i,at:a}){let o=M2(),s=U4(e,t),c=e===`main`?void 0:r??e,l=!!(o&&n);return(0,L.jsxs)(kX,{icon:Nm,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:DD.AGENT,"aria-label":`${DD.AGENT}: ${c}`,onClick:()=>Hp(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 f3({text:e,boundary:t,sourceId:n,at:r}){return t?(0,L.jsx)(kX,{icon:t===`wake`?Lh: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:QQ,children:e})}function p3({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:`${QQ} 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)(Rm,{"aria-hidden":`true`,size:13,className:e$(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)(X4,{md:e,wrap:!0})})]})}function m3(){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 h3({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=fD(Math.max(0,o-a)),f=(0,I.useMemo)(()=>b4([...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 ${QQ}`,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??f2(p)}),m&&(0,L.jsx)(Rm,{"data-working-chevron":!0,"aria-hidden":`true`,size:13,className:e$(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:g4(f.map((e,t)=>(0,L.jsx)(T4,{t:e,startedAt:r?.at},t)),6)}),m&&!c&&(0,L.jsx)(`div`,{id:u,hidden:!0})]})}function g3(){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 _3({id:e,slug:t,depth:n,widthDepth:r,initiallyOpen:i}){let{shown:a,close:o,closingRef:s}=gm(e,i===!0),[c,l]=(0,I.useState)(i===!0),u=(0,I.useRef)(null),d=(0,I.useRef)(null),f=en(X),p=[...f.drawers].reverse().find(e=>!e.closing)?.id===e,m=g3(),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 _=xw(),v=Wd(_,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 YG({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)(()=>(Ld(e,()=>{(u.current?.querySelector(`[data-dialog-initial-focus]`)??u.current)?.focus({preventScroll:!0})}),()=>Ld(e,null)),[e]),(0,L.jsx)(AL,{modal:m,open:!0,onOpenChange:e=>{e||o()},children:(0,L.jsxs)(IL,{children:[(0,L.jsx)(RL,{className:`${Cp} ${a?`opacity-100`:`opacity-0`}`,style:{zIndex:50+n*2}}),(0,L.jsxs)(HL,{ref:u,"aria-modal":m||void 0,"aria-describedby":void 0,tabIndex:-1,onEscapeKeyDown:t=>{if(t.target instanceof Element&&t.target.closest(`[data-claims-escape]`)){t.preventDefault();return}if(X.drawers.at(-1)?.id!==e){t.preventDefault();return}vz(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 ${wp} ${a?`translate-x-0`:`translate-x-full`}`,style:{zIndex:51+n*2,width:Ep(r),viewTransitionName:f.vtReturnTarget===t?`thread-chat`:void 0},children:[(0,L.jsx)(qL,{className:`sr-only`,children:v.kind===`found`?`Thread: ${QT(v.thread)}`:`Thread: ${t}`}),c&&v.kind===`found`?(0,L.jsx)(L2,{slug:t,onStatusApplied:o,onClose:o,virtualized:!0}):c&&v.kind===`missing`?(0,L.jsx)(v3,{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 v3({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 ${Uh} 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 y3({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=Lw(t,n),f=Sw(),p=(0,I.useMemo)(()=>d.data?.messages??[],[d.data]),m=d.data?.state,h=m===`running`,g=(0,I.useMemo)(()=>F2(p),[p]),_=(0,I.useMemo)(()=>I2(p),[p]),v=(0,I.useMemo)(()=>q0(_),[_]),y=h?X0(v):void 0,b=h?Y0(v):void 0,x=b?o2(b,f):void 0,S=h?Q0(v):void 0,C=(0,I.useMemo)(()=>h?t2(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)(bm,{id:e,depth:o,widthDepth:s,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Wh,{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)(j2.Provider,{value:t,children:(0,L.jsxs)(`div`,{"data-transcript-column":!0,className:`flex flex-col px-6 py-5`,children:[m4(C.map(e=>e.message),(e,t)=>(0,L.jsx)(Y4,{m:e},t)),w&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(OX,{h:p4(C.map(e=>e.message))}),(0,L.jsx)(h3,{since:a,startedAt:S,activityLabel:x,run:y})]})]})})}),(0,L.jsx)(b3,{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)(s3,{slug:t,parentAgentId:n,transcriptShells:g,className:e})})]})})}function b3({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)(x3,{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)(KR,{value:c,onChange:l,onSubmit:h,surface:`subAgentComposer`,placeholder:`Steer this sub-agent…`,busy:u||f,footer:(0,L.jsx)(x3,{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)(x3,{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 x3({subagentType:e}){let t=RQ(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 ${ZR}`,children:(0,L.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 truncate`,children:t})})}var S3=`font-mono-keep overflow-x-auto whitespace-pre-wrap break-words ${FY} border border-border bg-bg/75 px-4 py-2.5 text-[12px] leading-relaxed text-fg/85`;function C3({id:e,slug:t,shellId:n,label:r,startedAt:i,depth:a,widthDepth:o}){let s=(0,I.useRef)(null),c=Rw(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=gD(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 AV(u),Z(`Command copied`)}catch{Z(`Could not copy command`)}}return(0,L.jsx)(bm,{id:e,depth:a,widthDepth:o,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Wh,{title:r,icon:(0,L.jsx)(Lh,{"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)(Ym,{"aria-hidden":!0,size:11}),` Copy`]})]}),u?(0,L.jsx)(nY,{"data-background-shell-command":!0,text:u,language:`bash`,className:S3}):(0,L.jsx)(`pre`,{"data-background-shell-command":!0,className:S3,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 ${FY} 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 ${FY} 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 w3(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 T3={paddingBottom:`max(0.75rem, env(safe-area-inset-bottom))`};function E3({path:e}){return(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{Y.openLocalFile({path:e}).then(async e=>{e.action===`copy`&&(await AV(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)(Zm,{size:12,"aria-hidden":`true`}),` Open`]})}function D3({source:e}){return(0,L.jsx)(nY,{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 O3({id:e,path:t,title:n,depth:r,widthDepth:i}){let a=ww(t),o=nt({...SC(t),refetchInterval:a?!1:CC}),s=o.data?.path??t,{front:c,body:l}=w3(o.data?.markdown??``),u=nJ(l,{baseDir:bC(s),asDocument:!0}),d=VJ(u),f=(0,I.useRef)(null);return eY(f,u),(0,L.jsx)(bm,{id:e,depth:r,widthDepth:i,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Wh,{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)(D3,{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:T3,children:(0,L.jsx)(E3,{path:s})})]})})}function k3({id:e,slug:t,title:n,depth:r,widthDepth:i}){let a=nt({queryKey:[`threadBody`,t],queryFn:()=>Y.threadBody({slug:t})}),o=en(X);(0,I.useEffect)(()=>{a.refetch()},[o.board]);let s=jZ(hm(o.board,t)),c=mH(),l=pH.adopt(c,t),[u,d,f]=gH(l),p=st({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)=>{dH.get(l)||d(t),Z(`Start failed: ${e.message.slice(0,80)}`)}}),m=nJ(Uq(a.data?.markdown??``)),h=VJ(m);return(0,L.jsx)(bm,{id:e,depth:r,widthDepth:i,widthOffset:1,subagentParent:t,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Wh,{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)(KR,{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 A3(){let e=en(X),t=xw();(0,I.useEffect)(()=>{function e(e){if(e.key===`Escape`&&!(e.target instanceof Element&&e.target.closest(`.xterm`))){if(_z()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(X.showPalette)X.showPalette=!1;else if(X.showNewThread)X.showNewThread=!1;else if(X.showGithubPicker)Pp();else if(X.showSettings)Md()||(X.showSettings=!1);else if(X.drawers.length>0){let e=X.drawers[X.drawers.length-1];Id(e.id)||X.drawers.pop()}else X.filePanels.length>0&&tm()}}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)(_3,{id:e.id,slug:e.slug,depth:r,widthDepth:i,initiallyOpen:e.routed},e.id):e.kind===`subagent`?(0,L.jsx)(y3,{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)(C3,{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)(O3,{id:e.id,path:e.path??e.slug,title:e.label??e.slug,depth:r,widthDepth:i},e.id):(0,L.jsx)(k3,{id:e.id,slug:e.slug,depth:r,widthDepth:i,title:(()=>{let n=hm(t,e.slug);return n?QT(n):e.slug})()},e.id);return(0,L.jsx)(Kh,{label:`this drawer`,resetKeys:[e.kind,e.slug,e.subId,e.path],fallback:(t,n)=>(0,L.jsx)(Zh,{id:e.id,depth:r,widthDepth:i,error:t,onRetry:n}),children:a},e.id)})})}function j3(e){return(e.tools??[]).some(e=>e.name===`mcp__frizz__done`&&e.status===`completed`)}function M3(e){let t=fY(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 N3(e){let t=new Map,n=[];for(let r=0;r<e.length;r++){let i=M3(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 P3(e,t,n){return hY(e.text)?!n.has(t):j3(e)?!0:e.wake===!0}function F3(e){return e.wake===!0}function I3(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 L3(e){return e.open<0||e.tools<1&&e.steps<1?!1:e.resumed||e.open!==e.close}function R3(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 z3(e){return LD(e,`card`).length>0}function B3({slug:e,subAgents:t,className:n=`px-1 pt-1.5`}){let r=LD(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)(BD,{kind:`AGENT`,label:t.label,state:t.state,density:`card`,depth:t.depth,startedAt:t.startedAt,parentSlug:e,onOpen:t.id?()=>Hp(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:LM(e,t)},t.id??`${t.startedAt}-${n}`))})}var V3=320;function H3(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 U3(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 W3=0,G3=``;function K3(){W3++===0&&(G3=document.documentElement.style.overflowAnchor,document.documentElement.style.overflowAnchor=`none`)}function q3(){W3>0&&--W3===0&&(document.documentElement.style.overflowAnchor=G3)}function J3({thread:e,onSnooze:t,onSnoozeFailed:n}){return(0,L.jsx)(c0,{thread:e,onSnooze:t,onSnoozeFailed:n})}function Y3(){let e=xw(),t=fE(Cw(e?.threads??[]).filter(pE),en(JT).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=XU(),b=e=>v(e.id)||YU(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=U3(e);h.current=t?{kind:`top`,slug:t}:null}else{let t=H3(e);h.current=t?{kind:`hold`,...t}:null}f.current.add(e),d.current.delete(e),_(e=>e+1)},V3);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}K3();let n=()=>{let t=jp(e.slug);t!==null&&Math.abs(zd()-t)>.5&&window.scrollTo({top:t,left:0,behavior:`auto`})};n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n(),q3()})})},[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)(X3,{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)(Q3,{slug:e.id,leaving:v(e.id),children:(0,L.jsx)(t6,{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)(UU,{}),(0,L.jsx)(vH,{autoFocus:!0})]}):x.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-2 pt-2`,children:[(0,L.jsx)(dh,{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 X3({board:e}){let t=e?.errorItems??[],n=e?.errors??[];return t.length===0&&n.length===0?null:(0,L.jsxs)(`div`,{className:`mb-6 ${FY} 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)(Z3,{file:e.file})]},t)):n.slice(0,3).map((e,t)=>(0,L.jsx)(`div`,{className:`truncate`,title:e,children:e},t))]})}function Z3({file:e}){let t=st({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 Q3({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 $3({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)(kX,{icon:Bm,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 e6({toolCount:e,onExpand:t}){let n=e>0?`${e} tool call${e===1?``:`s`}`:``;return(0,L.jsxs)(kX,{icon:Bm,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 t6=(0,I.memo)(function({thread:e,leaving:t,frozen:n,onResolve:r,onUnresolve:i}){let a=en(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=S0(e.id),T=Iw(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)(()=>l4(A),[A]),M=e=>j>=0&&e<j,N=a0(e),P=e=>M(e)||e===j&&N,ee=(0,I.useMemo)(()=>fX(A),[A]),F=(0,I.useMemo)(()=>EZ(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`||c4(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)(()=>N3(A),[A]),ie=(0,I.useMemo)(()=>A.map((e,t)=>{if(!e||e.queued||c4(e,P(t)))return{skip:!0};if(e.boundary===`rest`)return{skip:!0,closes:!0};let n=BQ(e),r=n?0:e.tools.length;return{text:f4(e,P(t)),tools:r,countable:f4(e,P(t))||r>0||n!==void 0||e.kind!==void 0,survives:P3(e,t,re),opens:F3(e),completion:e.boundary===`wake`||n!==void 0}}),[A,re]),ae=(0,I.useMemo)(()=>I3(ie,F+1),[ie,F]),{kept:oe,middle:se}=(0,I.useMemo)(()=>R3(ae),[ae]),ce=(0,I.useMemo)(()=>oe.filter(L3),[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=qx(A,f,F),fe=(0,I.useMemo)(()=>A.slice(de),[A,de]),pe=(0,I.useMemo)(()=>q0(fe).map(e=>({...e,messageIndex:e.messageIndex+de})),[fe,de]),me=e.runtime!==`running`&&e.runtime!==`spawning`,he=(0,I.useMemo)(()=>DX(A,e?.questions??[],{atRest:me}),[me,A,e?.questions]),ge=(0,I.useMemo)(()=>{let t=[],n=new Map,r=A.length-1,i=(e?.questions??[]).filter(e=>!he.placedIds.has(e.id));for(let[e,a]of gX(A,i,{atRest:me})){if(e>=r){t.push(...a);continue}let i=n.get(e);i?i.push(...a):n.set(e,[...a])}return{byAnchor:n,tail:t}},[me,A,he.placedIds,e?.questions]),_e=lu(e.spawnedAt),ve=(0,I.useMemo)(()=>yX(A,e?.questions??[]),[A,e?.questions]),ye=(0,I.useMemo)(()=>sX(A,e.answersInFlight),[A,e.answersInFlight]),be=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=()=>{eS(t,e.anchor,e=>{e!==0&&window.scrollBy({top:e,left:0,behavior:`auto`})});let n=0;return eS(t,e.anchor,e=>{n=e}),n},r=n();if(tS({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,q3())})}))},[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,q3()))},[D?.transcriptKey]),(0,I.useEffect)(()=>()=>{b.current&&(b.current=!1,q3())},[]);let xe=e=>{let t=Qx(v.current);!e||!t||(b.current||(b.current=!0,K3()),y.current={anchor:t,targetStartId:e})},Se=async()=>{if(m||!be)return;let t=Kx(A,de),n=t!==null&&A[t]?.role===`user`?t:null;if(n!==null){let e=A[n].sourceId;xe(e),p(e??null);return}let r=D?.beforeCursor;if(!r){if(de>0){let e=A[0]?.sourceId;xe(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;xe(a);let o=Zx(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)}}},Ce=st({mutationFn:()=>Y.markComplete({slug:e.id})}),{answeringForMessage:we,answerable:Te,anyAnswered:Ee,sendAnswers:De,sendMessage:Oe}=cZ(e.id,A,()=>{document.activeElement?.blur(),r(e.id)},{scrollToBottom:!1,onSendFailed:()=>i(e.id)}),ke=(0,I.useMemo)(()=>{let e=oZ(A);return e!==-1&&wX(A[e].text,ve.get(e)??[])},[A,ve]),Ae=_e&&(Te&&!ke||Ee),je=(0,I.useCallback)(()=>r(e.id),[r,e.id]),Me=(0,I.useCallback)(()=>i(e.id),[i,e.id]),Ne=(0,I.useMemo)(()=>({dismiss:je,cancel:Me}),[je,Me]);return(0,L.jsx)(A2.Provider,{value:e.id,children:(0,L.jsx)(N2.Provider,{value:Ne,children:(0,L.jsx)(d1,{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(!Ee)return;let t=e.target;t instanceof HTMLButtonElement||t instanceof HTMLAnchorElement||t instanceof HTMLTextAreaElement&&t.value.trim()||MR({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(),De())},"data-vt-chat":!0,className:`flex flex-col min-w-0 max-w-full ${FY} 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?FY:`${IY} border-b border-border/60`}`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(FQ,{thread:e,className:`leading-snug`}),(0,L.jsx)(p0,{at:lE(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)(C0,{slug:e.id}),(0,L.jsx)(XZ,{thread:e,collapsed:o,onCollapse:()=>s(e=>!e),expand:!0,onDone:()=>Ce.mutate(void 0,{onSuccess:()=>r(e.id),onError:()=>d(!1)}),doneBusy:Ce.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 ${Ae?`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:[be&&(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 Se(),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=[...ge.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)(OX,{h:14},`qa-space-${t}`)),n.push((0,L.jsx)(p1,{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||c4(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)(OX,{h:14},`middle-runs-space`)),n.push((0,L.jsx)($3,{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&&!hY(t.text)&&!j3(t)&&P3(t,i,re);if(d!==void 0&&i===d.waker){r!==null&&n.push((0,L.jsx)(OX,{h:r&&n4(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)(Y4,{m:t,dense:!0})},e)),r=t4(t);return}if(f&&!h){if(!p&&!m&&!P3(t,i,re)||(!p&&u!==void 0&&!o.has(u)&&(r!==null&&n.push((0,L.jsx)(OX,{h:14},`im-space-${u}`)),n.push((0,L.jsx)(e6,{toolCount:d.tools,onExpand:()=>l(!0)},`intermediate-summary-${u}`)),r=!1,o.add(u)),!f4(t,P(i))))return;r!==null&&n.push((0,L.jsx)(OX,{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)(Y4,{m:t,dense:!0,textOnly:!0,answering:_e?we(t):void 0,paired:ee[i],staleAwaiting:M(i),restingCardShown:i===j&&N,shadowedBy:ve.get(i),placed:he.placed.get(i),thread:e})},s)),r=!1,a(i);return}r!==null&&n.push((0,L.jsx)(OX,{h:r&&n4(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)(Y4,{m:t,dense:!0,staleAwaiting:M(i),restingCardShown:i===j&&N,answering:_e?we(t):void 0,paired:ee[i],shadowedBy:ve.get(i),placed:he.placed.get(i),thread:e})},g)),r=t4(t),a(i)}),fe.forEach((e,r)=>{e.queued&&(n.push((0,L.jsx)(OX,{},`qs${r}`)),n.push((0,L.jsx)(Y4,{m:e,dense:!0,paired:ee[t+r]},`q${t+r}`)))}),n})()]}),!T.isLoading&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B$,{thread:e,className:`mt-4`}),e.pendingInteraction?null:e.pendingAsk?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(c3,{ask:e.pendingAsk,onTerminal:w})}):e.runtime===`perm-prompt`?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(a3,{onTerminal:w})}):null,e.permPolicy?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(o3,{policy:e.permPolicy,denies:e.permDenies})}):null]}),!T.isLoading&&a0(e)&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(J3,{thread:e,onSnooze:je,onSnoozeFailed:Me})}),!T.isLoading&&NY(e,j>=0?A[j]?.text:void 0)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(OX,{}),(0,L.jsx)(n3,{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)(i3,{slug:e.id,sessionId:e.sessionId,pause:e.limitPause})}),!T.isLoading&&JY(e,j>=0?A[j]?.text:void 0)&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(YY,{thread:e})})]}),(0,L.jsx)(p1,{thread:e,questions:ge.tail,inFlight:ye,showSend:he.placedIds.size>0,className:`shrink-0 px-5 pb-4 pt-0`}),Ae&&(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:!Ee,onClick:()=>De(),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)(UZ,{slug:e.id,surface:`queueComposer`,className:`shrink-0 px-5 pb-3 pt-0`,placeholder:Te||(e.questions?.length??0)>0?`Or skip the questions and reply…`:`Reply to the agent…`,submitOverride:Oe,ops:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(B3,{slug:e.id,subAgents:e.subAgents??[],className:`px-1 pt-1.5`}),(0,L.jsx)(s3,{slug:e.id,includeAgents:!1,className:`px-1 ${z3(e.subAgents??[])?`pt-0.5`:`pt-1.5`}`})]})})]})]}),(0,L.jsx)(EQ,{thread:e,onArchived:()=>r(e.id),onDismissCancel:()=>i(e.id),onSnoozed:()=>r(e.id)})]})})})})},n6);function n6(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 r6(e,t,n=[]){if(e.backend===`acp`){let t=n.find(t=>t.id===el(e.model));return t?t.available?void 0:`${t.label} is not installed on this machine`:`ACP agent ${e.model} is not in the catalogue`}if(!e.effort)return`Reasoning level is required for ${e.model}`;if(e.backend===`claude`)return HV.some(t=>t.value===e.model)?qV(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 r=t.find(t=>t.slug===e.model);if(!r)return`Codex model ${e.model} is no longer available`;if(!r.efforts.includes(e.effort))return`Reasoning level ${e.effort} is not available for ${e.model}`}function i6(e,t){return{items:t.map(e=>({...e})),backend:e.backend,model:e.model,effort:e.effort}}function a6({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 o6=30;function s6({onClose:e}){let t=JR(),{resolved:n,codexList:r,acpList:i,loadError:a,saveProfile:o}=tH(),s=it({mutationKey:[`contextWindowSet`]})>0,[c,l]=(0,I.useState)(`issues`),[u,d]=(0,I.useState)(`recent`),[f,p]=(0,I.useState)(1),[m,h]=(0,I.useState)(()=>new Set),[g,_]=(0,I.useState)(null),v=nt({queryKey:[`githubList`,c,u,f],queryFn:()=>Y.githubList({kind:c,sort:u,page:f,perPage:o6}),placeholderData:ee}),y=v.data?.items??[],b=v.data?.page??f,x=v.data?.pageCount??1,S=v.data?.total??0,C=(0,I.useRef)(null);(0,I.useEffect)(()=>{C.current&&(C.current.scrollTop=0)},[f,c,u]);let w=st({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 T(e){e!==c&&(l(e),p(1),h(new Set),_(null))}function E(e){e!==u&&(d(e),p(1),h(new Set),_(null))}function D(e,t){let n=a6({keys:y.map(e=>e.number),key:e,shiftKey:t,anchor:g,selected:m});h(n.selected),_(n.anchor)}function O(){h(new Set),_(null)}let k=t.data?.nameWithOwner??`this repo`,A=m.size,j=(0,I.useMemo)(()=>$V(r,i),[r,i]),M=n?.acpAgentId?i.find(e=>e.id===n.acpAgentId):void 0,N=n?{backend:n.backend,model:n.model,effort:n.effort||void 0}:void 0,P=N?r6(N,r,i):a?`Could not load the model catalogue — reopen once it loads`:void 0,F=P??(s?`Saving context window…`:N?void 0:`Loading the model catalogue…`);function te(){if(!N||F){Z(F??`Choose a model and reasoning level`);return}w.mutate(i6(N,[...m].map(e=>({kind:c===`issues`?`issue`:`pr`,number:e}))))}return(0,L.jsx)(bH,{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)(sh,{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:k})]}),(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,L.jsx)(l6,{value:c,onChange:e=>T(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)(l6,{value:u,onChange:E,options:[{value:`recent`,label:`Recent`},{value:`reactions`,label:`Reactions`}]})]})]}),(0,L.jsx)(`div`,{ref:C,className:`min-h-[240px] flex-1 overflow-y-auto rounded-lg border border-border/70 bg-bg/40 transition-opacity ${v.isPlaceholderData?`opacity-40`:``}`,children:v.isLoading?(0,L.jsx)(v6,{}):v.isError?(0,L.jsxs)(y6,{children:[(0,L.jsxs)(`span`,{className:`text-[12.5px] text-muted/80`,children:[`Couldn't load `,c===`issues`?`issues`:`pull requests`,`.`]}),(0,L.jsx)(`span`,{className:`max-w-[80%] text-center text-[11px] text-muted/45`,children:v.error.message.slice(0,140)})]}):y.length===0?(0,L.jsxs)(y6,{children:[(0,L.jsx)(dh,{size:28,strokeWidth:1.25,className:`text-muted/30`}),(0,L.jsxs)(`span`,{className:`text-[12.5px] text-muted/60`,children:[`No open `,c===`issues`?`issues`:`pull requests`]})]}):y.map(e=>(0,L.jsx)(f6,{item:e,checked:m.has(e.number),onActivate:t=>D(e.number,t)},e.number))}),!v.isLoading&&!v.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:[S,` open `,c===`issues`?S===1?`issue`:`issues`:S===1?`pull request`:`pull requests`]}),A>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:[A,` selected`]}),(0,L.jsx)(`button`,{onClick:O,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`})]})]}),x>1&&(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,L.jsx)(c6,{label:`Previous page`,disabled:b<=1,onClick:()=>p(Math.max(1,b-1)),children:(0,L.jsx)(Lm,{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 `,x,` of `,x]}),(0,L.jsxs)(`span`,{className:`absolute inset-0`,children:[`Page `,b,` of `,x]})]}),(0,L.jsx)(c6,{label:`Next page`,disabled:b>=x,onClick:()=>p(Math.min(x,b+1)),children:(0,L.jsx)(Rm,{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.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-0.5`,children:[(0,L.jsx)(_V,{groups:j,contextWindows:!0,value:n?{provider:n.backend,model:n.pickerModel,effort:n.effort}:void 0,onValueChange:e=>o({field:`profile`,backend:e.provider,model:e.model,effort:e.effort}),placeholder:a?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort`,title:F??`Model and reasoning effort for every thread this batch starts`,disabled:!n,side:`top`,menuZClass:jM,className:`max-w-[min(21rem,60vw)]`}),M&&(0,L.jsx)(kV,{agentId:M.id,agentLabel:M.label,modelId:n?.acpModelId,onValueChange:e=>o({field:`model`,backend:`acp`,value:Qc(M.id,e)}),side:`top`,menuZClass:`z-[250]`,className:`max-w-[min(14rem,30vw)] px-2 py-1`})]}),P&&(0,L.jsx)(`p`,{className:`mt-1 max-w-[430px] text-[10.5px] text-red-400`,children:P})]}),(0,L.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,L.jsxs)(`button`,{disabled:A===0||w.isPending||!!F,onClick:te,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:[w.isPending&&(0,L.jsx)(hh,{size:13,className:`animate-spin`}),A<=1?`Start investigation`:`Start ${A} investigations`]})})]})]})})}function c6({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 l6({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 u6({item:e}){let t=(e.state??`OPEN`).toUpperCase();return e.kind===`pr`?t===`MERGED`?(0,L.jsx)(rh,{size:15,className:`shrink-0`,style:{color:vD.fgDone}}):t===`CLOSED`?(0,L.jsx)(ih,{size:15,className:`shrink-0`,style:{color:vD.fgDanger}}):e.isDraft?(0,L.jsx)(ah,{size:15,className:`shrink-0`,style:{color:vD.fgNeutral}}):(0,L.jsx)(oh,{size:15,className:`shrink-0`,style:{color:vD.fgSuccess}}):t===`CLOSED`?(0,L.jsx)(Hm,{size:15,className:`shrink-0`,style:{color:vD.fgDone}}):(0,L.jsx)(Wm,{size:15,className:`shrink-0`,style:{color:vD.fgSuccess}})}function d6({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 f6({item:e,checked:t,onActivate:n}){let r=UE(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)(p6,{checked:t})}),(0,L.jsx)(`span`,{className:`mt-px`,children:(0,L.jsx)(u6,{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)(d6,{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)(g6,{prs:e.linkedPrs}):null,e.comments?(0,L.jsx)(_6,{icon:yh,n:e.comments,label:`comments`}):null,e.reactions?(0,L.jsx)(_6,{emoji:`👍`,n:e.reactions,label:`reactions`}):null]})]})}function p6({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)(Fm,{size:11,strokeWidth:3,className:`text-bg`})})}var m6={octicon:`-0.1em`,stroke:`-0.112em`};function h6({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(${m6.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 g6({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)(h6,{size:12}),e.count]})}function _6({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(${m6.stroke})`},children:(0,L.jsx)(e,{size:12,strokeWidth:2})}):null,n]})}function v6(){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 y6({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 b6={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.`,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 x6(){return typeof Notification>`u`?`unsupported`:Notification.permission}var S6=500,C6=1600,w6=2e3,T6=6;function E6(){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=>{c9.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`),C6))}).catch(i=>{--a.current,t(`error`),!(n.current||!jf(i)||s.current>=T6)&&(s.current+=1,n.current=e,r.current=window.setTimeout(c.current,w6))}))},[]);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,S6)},[l]);return(0,I.useEffect)(()=>()=>{l(),o.current!==void 0&&window.clearTimeout(o.current)},[l]),{state:e,queue:u,flush:l}}function D6(){let e=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()}),[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(x6()),{state:a,queue:o,flush:s}=E6(),[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)(()=>(jd(p),()=>jd(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,Dp()?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:`${Cp} z-50 flex justify-end ${c?`opacity-100`:`opacity-0`}`,onMouseDown:e=>e.target===e.currentTarget&&p(),children:(0,L.jsxs)(`div`,{className:`${wp} w-[560px] max-w-[94vw] ${c?`translate-x-0`:`translate-x-full`}`,children:[(0,L.jsx)(Wh,{title:`Settings`,actions:(0,L.jsx)(O6,{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)(A6,{label:`Font`,help:b6.font,children:(0,L.jsx)(R6,{value:t.font??`mono`,onChange:e=>f({...t,font:e})})}),(0,L.jsx)(A6,{label:`Project sidebar`,help:b6.projectRail,children:(0,L.jsx)(OV,{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)(A6,{label:`Local file links`,help:b6.localFileOpener,children:(0,L.jsx)(OV,{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)(A6,{label:`Density`,help:b6.density,children:(0,L.jsx)(B6,{})}),(0,L.jsx)(A6,{label:`Queue order`,help:b6.queueOrder,children:(0,L.jsx)(V6,{})}),(0,L.jsxs)(A6,{label:`Desktop notifications`,help:b6.notifications,children:[(0,L.jsx)(z6,{value:t.notifications,onChange:m}),t.notifications&&(0,L.jsx)(H6,{perm:r})]}),(0,L.jsx)(N6,{draft:t,setDraft:f}),(0,L.jsx)(P6,{draft:t,setDraft:f})]}):(0,L.jsx)(`div`,{className:`p-4 text-[13px] text-muted`,children:`Loading…`})]})})}function O6({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 k6({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)(PM,{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)(Gm,{size:12})})})]})}function A6({label:e,help:t,children:n}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(k6,{label:e,help:t}),n]})}var j6=[{token:`repo`,gloss:`repository`},{token:`n`,gloss:`number`},{token:`title`,gloss:`title`},{token:`url`,gloss:`link`},{token:`labels`,gloss:`labels`},{token:`body`,gloss:`description`}],M6=[{value:`auto`,label:`Automatic (default)`},{value:`5m`,label:`5 minutes`},{value:`1h`,label:`1 hour`}];function N6({draft:e,setDraft:t}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(F6,{label:`Claude`}),(0,L.jsx)(A6,{label:`Permissions`,help:b6.permissionMode,children:(0,L.jsx)(OV,{variant:`bordered`,value:e.permissionMode===`bypassPermissions`?`bypassPermissions`:`auto`,onValueChange:n=>t({...e,permissionMode:n}),options:VV,indicatorPosition:`right`,ariaLabel:`Claude permission mode`})}),(0,L.jsx)(A6,{label:`Prompt cache tier`,help:b6.promptCacheTtl,children:(0,L.jsx)(OV,{variant:`bordered`,value:e.promptCacheTtl??`auto`,onValueChange:n=>t({...e,promptCacheTtl:n}),options:M6,indicatorPosition:`right`,ariaLabel:`Claude prompt cache tier`})})]})}function P6({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)(F6,{label:`Prompts`}),n.data?(0,L.jsx)(L6,{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 F6({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 I6(){let[e,t]=(0,I.useState)(!1);return(0,L.jsxs)(dV,{open:e,onOpenChange:t,children:[(0,L.jsx)(fV,{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)(mV,{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:j6.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 L6({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)(k6,{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)(I6,{})]})]}),(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 R6({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 z6({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 B6(){let{compactDiffs:e}=en(JT);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:()=>JT.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 V6(){let{queueOrder:e}=en(JT);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:()=>JT.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 H6({perm:e}){return e===`denied`?(0,L.jsx)(W6,{}):(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 U6(){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 W6(){let e=(0,I.useMemo)(U6,[]),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)(K6,{url:n,hint:`Paste this into a new tab, set Notifications → Allow:`}):e===`safari`?(0,L.jsxs)(`span`,{children:[`Safari → Settings → Websites → Notifications → allow `,G6(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 G6(e){try{return new URL(e).host}catch{return e}}function K6({url:e,hint:t}){let[n,r]=(0,I.useState)(!1);async function i(){try{await AV(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)(Fm,{size:11,className:`text-live`}):(0,L.jsx)(Ym,{size:11})})]})]})}var q6=1,J6=.9,Y6=.8,X6=.17,Z6=.1,Q6=.999,$6=.9999,e8=.99,t8=/[\\\/_+.#"@\[\(\{&]/,n8=/[\\\/_+.#"@\[\(\{&]/g,r8=/[\s-]/,i8=/[\s-]/g;function a8(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?q6:e8;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=a8(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=q6:t8.test(e.charAt(l-1))?(d*=Y6,p=e.slice(i,l-1).match(n8),p&&i>0&&(d*=Q6**+p.length)):r8.test(e.charAt(l-1))?(d*=J6,m=e.slice(i,l-1).match(i8),m&&i>0&&(d*=Q6**+m.length)):(d*=X6,i>0&&(d*=Q6**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=$6)),(d<Z6&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=a8(e,t,n,r,l+1,a+2,o),f*Z6>d&&(d=f*Z6)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function o8(e){return e.toLowerCase().replace(i8,` `)}function s8(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,a8(e,t,o8(e),o8(t),0,0,{})}var c8=`[cmdk-group=""]`,l8=`[cmdk-group-items=""]`,u8=`[cmdk-group-heading=""]`,d8=`[cmdk-item=""]`,f8=`${d8}:not([aria-disabled="true"])`,p8=`cmdk-item-select`,m8=`data-value`,h8=(e,t,n)=>s8(e,t,n),g8=I.createContext(void 0),_8=()=>I.useContext(g8),v8=I.createContext(void 0),y8=()=>I.useContext(v8),b8=I.createContext(void 0),x8=I.forwardRef((e,t)=>{let n=F8(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=F8(()=>new Set),i=F8(()=>new Map),a=F8(()=>new Map),o=F8(()=>new Set),s=N8(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=BO(),y=BO(),b=BO(),x=I.useRef(null),S=R8();P8(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),P8(()=>{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??h8;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(l8);t?t.appendChild(e.parentElement===t?e:e.closest(`${l8} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${l8} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${c8}[${m8}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(m8);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(c8)?.querySelector(u8))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${d8}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(f8)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(m8))}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(m8))}function P(e){let t=A()?.closest(c8),n;for(;t&&!n;)t=e>0?j8(t,c8):M8(t,c8),n=t?.querySelector(f8);n?C.setState(`value`,n.getAttribute(m8)):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(_O.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(p8);t.dispatchEvent(e)}}}}},I.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:V8},c),B8(e,e=>I.createElement(v8.Provider,{value:C},I.createElement(g8.Provider,{value:w},e))))}),S8=I.forwardRef((e,t)=>{let n=BO(),r=I.useRef(null),i=I.useContext(b8),a=_8(),o=N8(e),s=o.current?.forceMount??i?.forceMount;P8(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=L8(n,r,[e.value,e.children,r],e.keywords),l=y8(),u=I8(e=>e.value&&e.value===c.current),d=I8(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(p8,f),()=>t.removeEventListener(p8,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(_O.div,{ref:eO(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)}),C8=I.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=BO(),s=I.useRef(null),c=I.useRef(null),l=BO(),u=_8(),d=I8(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);P8(()=>u.group(o),[]),L8(o,s,[e.value,e.heading,c]);let f=I.useMemo(()=>({id:o,forceMount:i}),[i]);return I.createElement(_O.div,{ref:eO(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),B8(e,e=>I.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},I.createElement(b8.Provider,{value:f},e))))}),w8=I.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=I.useRef(null),a=I8(e=>!e.search);return!n&&!a?null:I.createElement(_O.div,{ref:eO(i,t),...r,"cmdk-separator":``,role:`separator`})}),T8=I.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=y8(),o=I8(e=>e.search),s=I8(e=>e.selectedItemId),c=_8();return I.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),I.createElement(_O.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)}})}),E8=I.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=I.useRef(null),o=I.useRef(null),s=I8(e=>e.selectedItemId),c=_8();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(_O.div,{ref:eO(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},B8(e,e=>I.createElement(`div`,{ref:eO(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),D8=I.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return I.createElement(AL,{open:n,onOpenChange:r},I.createElement(IL,{container:o},I.createElement(RL,{"cmdk-overlay":``,className:i}),I.createElement(HL,{"aria-label":e.label,"cmdk-dialog":``,className:a},I.createElement(x8,{ref:t,...s}))))}),O8=I.forwardRef((e,t)=>I8(e=>e.filtered.count===0)?I.createElement(_O.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),k8=I.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return I.createElement(_O.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},B8(e,e=>I.createElement(`div`,{"aria-hidden":!0},e)))}),A8=Object.assign(x8,{List:E8,Item:S8,Input:T8,Group:C8,Separator:w8,Dialog:D8,Empty:O8,Loading:k8});function j8(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function M8(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function N8(e){let t=I.useRef(e);return P8(()=>{t.current=e}),t}var P8=typeof window>`u`?I.useEffect:I.useLayoutEffect;function F8(e){let t=I.useRef();return t.current===void 0&&(t.current=e()),t}function I8(e){let t=y8(),n=()=>e(t.snapshot());return I.useSyncExternalStore(t.subscribe,n,n)}function L8(e,t,n,r=[]){let i=I.useRef(),a=_8();return P8(()=>{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(m8,s),i.current=s}),i}var R8=()=>{let[e,t]=I.useState(),n=F8(()=>new Map);return P8(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function z8(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function B8({asChild:e,children:t},n){return e&&I.isValidElement(t)?I.cloneElement(z8(t),{ref:t.ref},n(t.props.children)):n(t)}var V8={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function H8(){let e=en(X),t=xw(),[n,r]=(0,I.useState)(``);if((0,I.useEffect)(()=>{e.showPalette&&r(``)},[e.showPalette]),!e.showPalette)return null;let i=uE(Cw(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){Wp(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)(A8,{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)(A8.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)(A8.List,{className:`max-h-[52vh] overflow-y-auto py-1.5`,children:[(0,L.jsx)(A8.Empty,{className:`px-4 py-6 text-center text-sm text-muted`,children:`No matches.`}),(0,L.jsxs)(A8.Group,{heading:`Actions`,className:`cmdk-group`,children:[(0,L.jsx)(U8,{value:`new thread create home`,onSelect:()=>c(()=>Mp()),children:`New thread`}),(0,L.jsx)(U8,{value:`queue todos inbox pending`,onSelect:()=>c(()=>{lm(X.drawers.map(e=>e.id)),X.view=`todos`}),children:`Queue`}),(0,L.jsx)(U8,{value:`open settings preferences`,onSelect:()=>c(()=>X.showSettings=!0),children:`Open settings`}),o&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(U8,{value:`open details drawer doc ${QT(o)}`,onSelect:()=>c(()=>{let e=um();e&&Vp(`doc`,e)}),children:`Open thread details`}),(0,L.jsxs)(U8,{value:`mark complete done ${QT(o)}`,onSelect:()=>c(()=>Y.markComplete({slug:o.id}).catch(()=>{})),children:[`Mark “`,QT(o),`” complete`]}),(0,L.jsxs)(U8,{value:`mark read ${QT(o)}`,onSelect:()=>c(()=>Y.markRead({slug:o.id}).catch(()=>{})),children:[`Mark “`,QT(o),`” read`]})]})]}),i.length>0&&(0,L.jsx)(A8.Group,{heading:`Threads`,className:`cmdk-group`,children:i.map(e=>(0,L.jsxs)(U8,{value:`${QT(e)} ${e.id}`,onSelect:()=>c(()=>l(e.id)),children:[(0,L.jsx)(`span`,{className:`truncate`,children:QT(e)}),(0,L.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted/70`,children:e.id})]},e.id))})]})]})})}function U8({value:e,onSelect:t,children:n}){return(0,L.jsx)(A8.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 W8=`Updating and restarting Frizz`,G8=`This may take a moment while the new build is being prepared. All of your threads will continue running normally.`,K8=`Frizz did not come back`;function q8(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 J8(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 Y8({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=>{J8(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)(Bh,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,L.jsx)(`h2`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:K8}),(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)(Hh,{"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:q8(r)})]})});let c=t?.trim()?t.trim():null;return(0,L.jsx)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":W8,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)(Oh,{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:W8}),(0,L.jsx)(`p`,{className:`mt-2 text-[12.5px] leading-relaxed text-muted`,children:G8}),c&&(0,L.jsx)(`p`,{"aria-live":`polite`,className:`mt-2 text-[11.5px] leading-relaxed text-muted/80`,children:c})]})})}var X8=!1;function Z8(){X8||(X8=!0,Z("Sign in to the GitHub CLI (`gh auth login`) to dispatch from issues/PRs.",{duration:6e3}))}function Q8(){let e=en(X),t=(0,I.useRef)({projectDir:null,hasBeenVisible:!1});(0,I.useEffect)(()=>{Y.board().then(pm).catch(()=>{})},[]);let n=xy();(0,I.useEffect)(()=>Xw((e,t)=>n(e,t)),[n]);let{data:r,dataUpdatedAt:i}=wU(),a=(0,I.useRef)(null),[o,s]=(0,I.useState)(oU),c=(0,I.useRef)(null),l=(0,I.useRef)(!1);(0,I.useEffect)(()=>{let e=r;if(e){let t=lU({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=rU(e))}if(s(t=>sU(t,{restarting:X.controlPlaneState===`restarting`,answered:e!=null,at:Date.now()})),!e||l.current)return;let t=sessionStorage.getItem($H);if(dU({state:X.controlPlaneState,message:X.controlPlaneMessage,attempt:X.controlPlaneRestartAttempt},e)){if(t){sessionStorage.removeItem($H),sessionStorage.removeItem(eU),l.current=!0,window.location.replace(t);return}if(iU(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($H),sessionStorage.removeItem(eU),a.current!==e.message&&(a.current=e.message??`Update & Restart failed`,Z(`Update & Restart failed — ${nU(tU(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 Ud(),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,Ud()??e)}},[u]);let d=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()});(0,I.useEffect)(()=>{X.notificationsEnabled=d.data?.notifications??!1},[d.data?.notifications]);let f=JR();(0,I.useEffect)(()=>{f.data?.inRepo&&!f.data.authed&&Z8()},[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=om(),n=um();t?.kind===`doc`?(e.preventDefault(),Id(t.id)||X.drawers.pop()):n&&(e.preventDefault(),Vp(`doc`,n))}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let p=xw(),m=qG();(0,I.useEffect)(()=>{Gp()},[p,e.routeThreadSlug]),t.current=Zw(t.current,p);let h=p!==null&&t.current.hasBeenVisible,g=p===null&&$w(Yd()),_=t.current.hasBeenVisible;(0,I.useEffect)(()=>{p!==null&&eT(Yd(),_)},[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)(Y8,{open:e.controlPlaneState===`restarting`,message:e.controlPlaneMessage,stalled:o.stalled,silentFor:o.silentSince===null?void 0:dD(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)(VG,{}):(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)(Kh,{label:`the sidebar`,children:(0,L.jsx)(HW,{})}),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)(Kh,{label:`the queue`,resetKeys:[e.view],children:[e.view.startsWith(`status:`)&&(0,L.jsx)(wG,{status:e.view.slice(7)}),e.view===`todos`&&(0,L.jsx)(Y3,{})]}):(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)(A3,{}),e.showSettings&&(0,L.jsx)(D6,{}),e.showNewThread&&(0,L.jsx)(yH,{onClose:()=>{X.showNewThread=!1}}),e.showGithubPicker&&(0,L.jsx)(s6,{onClose:Pp}),(0,L.jsx)(H8,{})]})]})}function $8(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 e5(e,t,n,r=48){let i=Math.round(t/r);return Math.max(0,Math.min(n-1,e+i))}function t5(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 n5(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 r5=`w-[57px]`,i5=`max-[800px]:pl-0 pl-[57px]`;function a5(e){let t=0;for(let n=0;n<e.length;n++)t=(t*31+e.charCodeAt(n))%360;return t}function o5(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 s5(e){let t=e.iconVersion?`&v=${encodeURIComponent(e.iconVersion)}`:``;return`/_frizz/project-icon?id=${encodeURIComponent(e.id)}${t}`}function c5({project:e,size:t}){let[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(!1),o=a5(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:o5(e.name)})}),s&&!c&&(0,L.jsx)(`img`,{src:s5(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 l5=40;function u5({project:e,current:t,count:n,index:r,drag:i,onPointerDown:a,onKeyDown:o}){let s=i?.fromIndex===r,c=i?s?i.deltaY:t5(r,i.fromIndex,i.toIndex):0;return(0,L.jsx)(PM,{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)(Yb,{to:Xd(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||m5())&&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)(c5,{project:e,size:l5})}),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 d5({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=st({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=st({mutationFn:()=>Y.projectIconClear({id:e.id}),onSuccess:()=>void i(),onError:a}),c=st({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:wd.map(e=>`.${e}`).join(`,`),className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&o.mutate(t)}}),(0,L.jsxs)(cL,{children:[(0,L.jsx)(lL,{asChild:!0,children:t}),(0,L.jsx)(uL,{children:(0,L.jsxs)(dL,{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)(mL,{className:l,onSelect:()=>c.mutate(),children:o.isPending?`Uploading…`:`Choose an icon…`}),(0,L.jsx)(mL,{className:l,onSelect:()=>s.mutate(),children:e.iconIsCustom?`Use the detected icon`:`Look for an icon again`})]})})]})]})}var f5=4,p5=0;function m5(){return Date.now()-p5<250}function h5(e,t){let n=nt({queryKey:[`projectsQueueCounts`],queryFn:()=>Y.projectsQueueCounts(),refetchInterval:5e3}),r=en(X).board,i=e!==void 0&&r?Cw(r.threads).filter(pE).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 g5(){let e=Ve(),{data:t}=nt({queryKey:[`projectsList`],queryFn:()=>Y.projectsList()}),n=Yd(),[r,i]=(0,I.useState)(!1),a=xy(),[o,s]=(0,I.useState)(null),[c,l]=(0,I.useState)(null),u=(0,I.useRef)(null),d=st({mutationFn:()=>Y.projectPick({}),onSuccess:e=>{e.kind===`picked`?a(Xd(e.project.slug)):e.kind===`unavailable`&&a(`/`)},onSettled:()=>i(!1)}),f=st({mutationFn:e=>Y.projectsReorder({ids:e}),onSuccess:async()=>{await e.invalidateQueries({queryKey:[`projectsList`]}),l(null)},onError:()=>l(null)}),p=c??t??[],m=h5(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=n5(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:e5(t,c,i.length),deltaY:c},s(o)},m=0,h=e=>{if(!a){if(Math.abs(e.clientY-r)<f5)return;a=!0,n.setPointerCapture(e.pointerId)}e.preventDefault();let t=e.clientY;cancelAnimationFrame(c);let i=()=>{d(t),u.current&&n5(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;p5=Date.now();let e=$8(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=$8(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 ${r5}`,children:[(0,L.jsx)(PM,{side:`right`,label:`All projects`,children:(0,L.jsx)(Yb,{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)(lh,{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)(u5,{project:e,index:t,current:e.slug===n,count:m(e),drag:o,onPointerDown:_,onKeyDown:v},e.id))}),(0,L.jsx)(PM,{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)(Dh,{size:16})})})]})}var _5=76;function v5(e,t){return t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}var y5=`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`,b5=`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`,x5=38;function S5({project:e,home:t}){let n=RE(e.lastOpenedAt),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(!1);return(0,L.jsxs)(`div`,{className:`group/card relative`,children:[(0,L.jsxs)(Yb,{to:Xd(e.slug),className:`${y5} ${b5} 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)(c5,{project:e,size:x5})}),(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:v5(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)(d5,{project:e,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":`Change the icon for ${e.name}`,style:{width:x5,height:x5},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)(uh,{size:16,strokeWidth:1.75})})}),(0,L.jsx)(C5,{onRename:()=>o(!0),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)(Xm,{size:15})})}),a?(0,L.jsx)(T5,{project:e,home:t,onClose:()=>o(!1)}):null,r?(0,L.jsx)(E5,{project:e,home:t,onClose:()=>i(!1)}):null]})}function C5({onRename:e,onDelete:t,children:n}){return(0,L.jsxs)(cL,{children:[(0,L.jsx)(lL,{asChild:!0,children:n}),(0,L.jsx)(uL,{children:(0,L.jsxs)(dL,{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)(mL,{className:`cursor-default rounded px-2 py-1.5 text-[12.5px] text-fg outline-none data-[highlighted]:bg-panel-2`,onSelect:e,children:`Rename…`}),(0,L.jsx)(mL,{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:t,children:`Delete project…`})]})})]})}function w5(e){return e.split(/[\\/]/u).filter(Boolean).pop()??e}function T5({project:e,home:t,onClose:n}){let[r,i]=(0,I.useState)(e.name),[a,o]=(0,I.useState)(!1),s=(0,I.useRef)(null),c=Ve(),l=st({mutationFn:()=>Y.projectRename({id:e.id,name:r.trim(),renameDirectory:a}),onSuccess:t=>{c.invalidateQueries({queryKey:[`projectsList`]}),Z(`Renamed ${e.name} to ${t.name}`),n()}}),u=l.error instanceof Error?l.error.message:l.error?String(l.error):null,d=r.trim(),f=w5(e.path),p=e.path.slice(0,e.path.length-f.length),m=f===e.name&&d.length>0&&d!==f,h=Ns(d);return(0,L.jsx)(rQ,{open:!0,onOpenChange:e=>{!e&&!l.isPending&&n()},title:`Rename ${e.name}`,className:`w-[440px] max-w-[92vw]`,onOpenAutoFocus:e=>{e.preventDefault(),s.current?.focus(),s.current?.select()},footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,onClick:n,disabled:l.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:`submit`,form:`rename-project`,disabled:l.isPending||d.length===0,className:`flex items-center gap-1.5 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:[l.isPending&&(0,L.jsx)(hh,{size:12,className:`animate-spin`}),m&&a?`Rename project and folder`:`Rename project`]})]}),children:(0,L.jsxs)(`form`,{id:`rename-project`,onSubmit:e=>{e.preventDefault(),!l.isPending&&d.length>0&&l.mutate()},className:`flex flex-col gap-3 p-4 text-[12.5px] leading-relaxed text-muted`,children:[(0,L.jsx)(`input`,{ref:s,value:r,onChange:e=>i(e.target.value),spellCheck:!1,"aria-label":`Project name`,className:`w-full rounded-md border bg-bg px-2.5 py-2 text-[12.5px] text-fg outline-none placeholder:text-muted/50 focus-visible:ring-1 focus-visible:ring-fg/60 ${u?`border-red-500/60`:`border-border-strong`}`}),(0,L.jsxs)(`p`,{children:[`Its address becomes`,` `,(0,L.jsxs)(`span`,{className:`font-mono text-[11.5px] text-fg/80`,children:[`/project/`,h]}),h===e.slug?`.`:(0,L.jsxs)(L.Fragment,{children:[` — links to `,(0,L.jsxs)(`span`,{className:`font-mono text-[11.5px]`,children:[`/project/`,e.slug]}),` stop working.`]})]}),m?(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:a,onChange:e=>o(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 rename the folder`}),(0,L.jsx)(`span`,{className:`text-[11.5px] text-muted/80`,children:a?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`span`,{className:`font-mono text-[11px]`,children:v5(e.path,t)}),` becomes `,(0,L.jsx)(`span`,{className:`font-mono text-[11px]`,children:v5(p+d,t)}),`. Running workers keep going.`]}):`Left off, the folder keeps its name and only what Frizz calls it changes.`})]})]}):null,u?(0,L.jsx)(`p`,{className:`text-[11.5px] text-red-400`,children:u}):null]})})}function E5({project:e,home:t,onClose:n}){let[r,i]=(0,I.useState)(!1),a=Ve(),o=st({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)(rQ,{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)(hh,{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:v5(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 D5({hero:e,pending:t,onClick:n}){return(0,L.jsxs)(`button`,{type:`button`,onClick:n,disabled:t,className:`${y5} 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 O5({reason:e,proposed:t,onClose:n}){let[r,i]=(0,I.useState)(t??``),a=xy(),o=Ve(),s=st({mutationFn:e=>Y.projectAdd({path:e}),onSuccess:e=>{o.invalidateQueries({queryKey:[`projectsList`]}),a(Xd(e.slug))}}),c=s.error instanceof Error?s.error.message:s.error?String(s.error):null;return(0,L.jsx)(AL,{open:!0,onOpenChange:e=>{!e&&!s.isPending&&n()},children:(0,L.jsxs)(IL,{children:[(0,L.jsx)(RL,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(HL,{"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)(qL,{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 k5(){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=xy(),i=Ve(),a=st({mutationFn:()=>Y.projectPick({}),onSuccess:e=>{if(e.kind!==`cancelled`){if(e.kind===`unavailable`){n({reason:e.reason});return}i.invalidateQueries({queryKey:[`projectsList`]}),r(Xd(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:_5,height:_5,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)(S5,{project:e,home:l},e.id)),(0,L.jsx)(D5,{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)(O5,{reason:t.reason,proposed:e,onClose:()=>n(null)}):null]})}function A5(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 j5(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 M5({slug:e,path:t,active:n}){let r=vC(t),i=ww(t),a=nt({...SC(t),refetchInterval:i?!1:CC}),o=a.data?.path??t,s=a.data?.markdown??``,{front:c,body:l}=w3(r?s:``),[u,d]=(0,I.useState)(r?`rendered`:`source`),f=nJ(l,{baseDir:bC(o),asDocument:!0}),p=VJ(f),m=VJ((0,I.useMemo)(()=>u===`source`?EC(o,s):``,[s,o,u])),h=(0,I.useRef)(null),g=(0,I.useRef)(null),_=(0,I.useRef)(null);eY(h,f);let v=_p(o),y=mH(),b=hH(e);return(0,I.useEffect)(()=>{if(!n)return;let t=()=>document.querySelector(`main[data-standalone-thread] textarea`);function r(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 i(n){if(!(n.metaKey||n.ctrlKey)||n.altKey||n.shiftKey||n.key.toLowerCase()!==`i`)return;let i=_.current,a=window.getSelection(),c=a&&!a.isCollapsed&&a.rangeCount>0?a.getRangeAt(0):null,l=!!(i&&c&&i.contains(c.commonAncestorContainer)),u=l?a.toString():``;if(!l||!u.trim()){n.preventDefault(),n.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}n.preventDefault(),n.stopPropagation();let d=null,f=g.current;if(f&&f.contains(c.commonAncestorContainer)){let e=A5(f,c.startContainer,c.startOffset),t=A5(f,c.endContainer,c.endOffset);e!==null&&t!==null&&(d={startLine:j5(s,Math.min(e,t)),endLine:j5(s,Math.max(0,Math.max(e,t)-1))})}else d=SR(s,u);let p=t(),m=pH.followUp(y,e,b),{prose:h,attachments:v}=dR(dH.get(m)),x=yR(pR({path:o,...d??{}}),X.composerContext[e]??[],h),S=bR(h,r(p,h),x);dH.set(m,fR(S.prose,v.map(e=>e.path))),rm(e,{token:x,path:o,text:u,...d??{}}),a.removeAllRanges(),requestAnimationFrame(()=>{let e=t();e&&(e.setSelectionRange(S.caret,S.caret),e.focus())})}return window.addEventListener(`keydown`,i,!0),()=>window.removeEventListener(`keydown`,i,!0)},[n,e,o,s,y,b]),(0,L.jsxs)(`div`,{ref:_,"data-file-viewer-panel":!0,className:`flex h-full min-h-0 flex-col`,children:[(0,L.jsx)(Wh,{title:v,subtitle:o,onClose:tm,actions:r?(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:()=>d(e),"aria-pressed":u===e,className:`rounded px-2 py-0.5 transition-colors ${u===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:[a.isLoading?(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):a.error?(0,L.jsxs)(`div`,{className:`text-[13px] text-red-400/90`,children:[`Couldn’t read this file: `,a.error.message]}):u===`source`?s?(0,L.jsx)(`pre`,{ref:g,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:m}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):f?(0,L.jsxs)(L.Fragment,{children:[c&&(0,L.jsx)(D3,{source:c}),(0,L.jsx)(`div`,{ref:h,className:`md-body`,dangerouslySetInnerHTML:p})]}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!a.isLoading&&!a.error&&a.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:T3,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)(E3,{path:o})]})]})}function N5(){return{dirs:new Map,files:new Map}}function P5(e,t){let n=e.replace(/[\\/]+$/,``);if(t){let e=xp(t,n);if(e!==null)return dp(e)}let r=dp(n);return/^[\\/]/.test(n)?[`/`,...r]:r}var F5=(e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`,numeric:!0});function I5(e,t){let n=[];for(let r of[...e.dirs.keys()].sort(F5)){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:I5(i,t+1)})}for(let r of[...e.files.keys()].sort(F5))n.push({kind:`file`,name:r,depth:t,file:e.files.get(r)});return n}function L5(e,t){let n=N5();for(let r of e){let e=P5(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=N5(),i.dirs.set(t,e)),i=e}i.files.set(e[e.length-1],r)}return I5(n,0)}function R5(e){let t=[],n=e=>{for(let r of e)t.push(r),r.kind===`dir`&&n(r.children)};return n(e),t}var z5=10;function B5({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*z5},children:[(0,L.jsx)(`span`,{className:`flex shrink-0`,children:(0,L.jsx)(eh,{size:12,className:`${k1} text-muted/45`})}),(0,L.jsx)(`span`,{className:`ml-[5px] min-w-0 truncate`,title:e,children:e})]})}function V5({files:e}){return(0,L.jsx)(`div`,{"data-edited-file-tree":!0,className:`col-span-4 flex flex-col gap-y-px`,children:R5(L5(e,Sw())).map(e=>e.kind===`dir`?(0,L.jsx)(B5,{name:e.name,depth:e.depth},`d:${e.depth}:${e.name}`):(0,L.jsx)(H5,{file:e.file,name:e.name,depth:e.depth},e.file.path))})}function H5({file:e,name:t,depth:n}){let r=Ve();return(0,L.jsx)(V1,{testKind:`file`,testId:e.path,mark:(0,L.jsx)(Qm,{size:12,className:`${k1} -mr-[2px] text-muted/60`}),name:t,indent:n*z5,onOpen:()=>MJ(e.path),onPrewarm:()=>OC(r,e.path),title:e.path,status:(0,L.jsxs)(L.Fragment,{children:[(e.added??0)>0&&(0,L.jsxs)(`span`,{style:{color:vD.fgSuccess},children:[`+`,e.added]}),(e.added??0)>0&&(e.removed??0)>0&&` `,(e.removed??0)>0&&(0,L.jsxs)(`span`,{style:{color:vD.fgDanger},children:[`−`,e.removed]})]})})}function U5({thread:e}){let t=eD(),n=Iw(e.id,{poll:!1}).data?.editedFiles??[],r=Z1(e),i=(e.bgShells??[]).filter(e=>e.state===`running`),a=(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`),o=a.filter(e=>e.subject!==`issue`),s=a.filter(e=>e.subject===`issue`),c=(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`),{railFilesCollapsed:l}=en(JT),u=[{head:`Sub-agents`,rows:r.map(n=>(0,L.jsx)(Q1,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:i.map(n=>(0,L.jsx)(Y1,{shell:n,slug:e.id,now:t},n.id??n.label))},{head:`Pull requests`,rows:o.map(e=>(0,L.jsx)(W1,{watch:e},e.id))},{head:`Issues`,rows:s.map(e=>(0,L.jsx)(W1,{watch:e},e.id))},{head:`Timers`,rows:c.map(e=>(0,L.jsx)(X1,{watch:e,now:t},e.id))},{head:`Edited files`,rows:n.length>0?[(0,L.jsx)(V5,{files:n},`tree`)]:[],count:n.length,collapsed:l,onToggle:()=>JT.railFilesCollapsed=!JT.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:u.length===0?(0,L.jsx)(`div`,{className:`text-[11.5px] text-muted/50`,children:`Nothing running, watched or edited yet.`}):(0,L.jsx)(i0,{groups:u,divider:!1})})})}function W5(){let e=en(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)(hh,{size:13,className:`animate-spin text-muted`}),t.text,t.link&&(0,L.jsx)(`button`,{onClick:()=>{Vp(`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 G5=`max(50%, calc(100% - 720px))`,K5={"--full-thread":`min(720px, ${G5})`,"--full-thread-narrow":`min(720px, 100%)`,"--full-pane":G5,"--full-gutter":`max(0px, calc((100% - min(720px, ${G5}) - 340px) / 2))`};function q5(e,t){return`${Xd(e)}${nf(t,`/`)}`}function J5({slug:e}){let t=en(X).filePanels.some(e=>!e.closing),n=xw(),r=Wd(n,e),i=r.kind===`found`?r.thread:void 0;n?.projectDir,(0,I.useEffect)(()=>{Y.board().then(pm).catch(()=>{})},[]),(0,I.useEffect)(()=>{let e=window.matchMedia(`(min-width: ${Tp}px)`),t=()=>{X.splitFileViewer=e.matches};return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),X.splitFileViewer=!1,X.filePanels=[]}},[]);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?QT(i):e;document.title=t?`${r} · ${t} — Frizz`:`${r} · Frizz`},[n?.projectLabel,n?.projectName,e,i]),(0,L.jsx)(NM,{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:{...K5,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)(Z5,{slug:e}):(0,L.jsx)(L2,{slug:e,virtualized:!0,showReturnToQueue:!0})}),i?(0,L.jsx)(Y5,{slug:e,thread:i}):(0,L.jsx)(`div`,{className:`hidden w-[var(--full-pane)] shrink-0 split:block`,"aria-hidden":`true`})]})}),(0,L.jsx)(A3,{}),(0,L.jsx)(W5,{})]})})}function Y5({slug:e,thread:t}){let n=en(X);return(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.filePanels.length>0?!0:void 0,className:`h-full min-h-0`,children:(0,L.jsx)(U5,{thread:t})}),n.filePanels.map((t,r)=>(0,L.jsx)(X5,{slug:e,path:t.path,closing:!!t.closing,active:r===n.filePanels.length-1&&!t.closing&&n.splitFileViewer},t.id))]})}function X5({slug:e,path:t,closing:n,active:r}){let[i,a]=(0,I.useState)(!1),o=(0,I.useRef)(null);return(0,I.useLayoutEffect)(()=>{o.current?.getBoundingClientRect();let e=()=>a(!0),t=requestAnimationFrame(e),n=window.setTimeout(e,120);return()=>{cancelAnimationFrame(t),window.clearTimeout(n)}},[]),(0,I.useEffect)(()=>{r&&o.current?.focus({preventScroll:!0})},[r]),(0,L.jsx)(`aside`,{ref:o,tabIndex:-1,"data-file-viewer-slot":!0,"aria-hidden":!r,inert:!r,className:`absolute inset-0 outline-none transition-[translate,opacity] duration-200 ease-out motion-reduce:transition-none ${i&&!n?`translate-x-0 opacity-100`:`translate-x-full opacity-0`}`,children:(0,L.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-panel`,children:(0,L.jsx)(M5,{slug:e,path:t,active:r})})})}function Z5({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(q5(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:q5(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 Q5={OPEN_ISSUE:{bg:vD.bgSuccessEmphasis,icon:Wm,label:`Open`},CLOSED_ISSUE:{bg:vD.bgDoneEmphasis,icon:Hm,label:`Closed`},NOT_PLANNED:{bg:vD.bgNeutralEmphasis,icon:Km,label:`Closed as not planned`},OPEN_PR:{bg:vD.bgSuccessEmphasis,icon:oh,label:`Open`},DRAFT:{bg:vD.bgNeutralEmphasis,icon:ah,label:`Draft`},MERGED:{bg:vD.bgDoneEmphasis,icon:rh,label:`Merged`},CLOSED_PR:{bg:vD.bgDangerEmphasis,icon:ih,label:`Closed`}};function $5(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 e7(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 t7(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 ${e7(e,t)}`:UE(e,t)??``:``}function n7(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 r7={add:vD.fgSuccess,del:vD.fgDanger},i7={add:{backgroundColor:vD.bgSuccessEmphasis,borderColor:vD.bgSuccessEmphasis},del:{backgroundColor:vD.bgDangerEmphasis,borderColor:vD.bgDangerEmphasis},none:{backgroundColor:`${vD.bgNeutralEmphasis}33`,borderColor:`#3d444d`}};function a7({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:r7.add},children:[`+`,e.toLocaleString()]}),(0,L.jsxs)(`span`,{"data-gh-del":!0,style:{color:r7.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:n7(e,t).map((e,t)=>(0,L.jsx)(`span`,{className:`size-[8px] rounded-[2px] border`,style:i7[e]},t))})]})}function o7({card:e}){let t=$5(e),n=t?Q5[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 s7({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 c7=/`([^`\n]+)`/g;function l7(e,t){if(!t)return[e];let n=[],r=0;for(let t of e.matchAll(c7))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 u7({text:e,code:t,className:n}){return(0,L.jsx)(`div`,{className:n,children:l7(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 d7=new Set([`avatars.githubusercontent.com`,`camo.githubusercontent.com`]);function f7(e){if(e)try{let t=new URL(e);return t.protocol===`https:`&&d7.has(t.hostname)?e:void 0}catch{return}}function p7({card:e,nowMs:t}){let n=f7(e.authorAvatar),r=e.authorLogin??e.authorName??`Someone`,i=e.kind===`commit`?`committed`:e.kind===`pr`?`opened this pull request`:`opened this issue`,a=t7(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 m7=`w-[360px] max-w-[min(360px,calc(100vw-24px))] leading-normal`;function h7({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:m7,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)(nh,{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)(u7,{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)(a7,{additions:e.additions,deletions:e.deletions})}):null]})]}),(0,L.jsx)(p7,{card:e,nowMs:t})]});let r=e.ref.slice(e.ref.indexOf(`#`));return(0,L.jsxs)(`div`,{className:m7,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 ${e7(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)(o7,{card:e}),n?(0,L.jsx)(a7,{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)(u7,{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)(s7,{name:e.name,color:e.color},e.name))}):null]}):null,(0,L.jsx)(p7,{card:e,nowMs:t})]})}var g7=250,_7=180;function v7(e){let t=e.getClientRects()[0]??e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}}function y7(){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)},_7)},[]);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),Xf([o]),n.current=setTimeout(()=>t({ref:o,rect:v7(a)}),g7)))},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)(pV,{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)(mV,{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)(b7,{refKey:e.ref})}):null]})}function b7({refKey:e}){let t=(0,I.useSyncExternalStore)(Gf,()=>Kf(e),()=>Kf(e));return(0,I.useEffect)(()=>{qf(Kf(e))&&ep(e)},[e]),t?.card?(0,L.jsx)(h7,{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 x7=`frizz-project-rail`;function S7(){try{return localStorage.getItem(x7)===`shown`}catch{return!1}}function C7(e){try{localStorage.setItem(x7,e?`shown`:`hidden`)}catch{}}function w7(){yy();let e=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet(),placeholderData:ee}).data?.projectRail;return(0,I.useEffect)(()=>{e!==void 0&&C7(e===!0)},[e]),e===void 0?S7():e===!0}var T7=`/project/:slug`;function E7(){j7();let e=w7();return(0,L.jsxs)(NM,{children:[e?(0,L.jsx)(g5,{}):null,(0,L.jsx)(`div`,{className:e?i5:void 0,children:(0,L.jsx)(tb,{})}),(0,L.jsx)(W5,{}),(0,L.jsx)(y7,{})]})}function D7(e){(0,I.useEffect)(()=>{qC(e)||(fm(),yw())},[e])}function O7(){let{slug:e,thread:t}=Ty();return D7(e),A7(),(0,I.useState)(()=>Jp(t)),(0,L.jsx)(Q8,{},e??`__launching__`)}function k7(){return(0,L.jsx)(k5,{})}function A7(){let e=yy();(0,I.useEffect)(()=>{Gw(Qd(e.pathname))},[e.pathname])}function j7(){let e=xy();(0,I.useEffect)(()=>(Jw((t,n)=>e(t,n)),()=>Jw(null)),[e])}function M7(){let{thread:e,slug:t}=Ty();return j7(),D7(t),(0,I.useState)(()=>{X.drawers.length>0&&(X.drawers=[])}),qp(e),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(J5,{slug:e}),(0,L.jsx)(W5,{})]})}var N7=[{index:!0,element:(0,L.jsx)(O7,{})},{path:`thread/:thread`,element:(0,L.jsx)(O7,{})},{path:`status/:status`,element:(0,L.jsx)(O7,{})}],P7=Gb([{path:`/thread/:thread/full`,element:(0,L.jsx)(M7,{})},{path:`${T7}/thread/:thread/full`,element:(0,L.jsx)(M7,{})},{element:(0,L.jsx)(E7,{}),children:[{path:`/`,element:(0,L.jsx)(k7,{})},{path:`/thread/:thread`,element:(0,L.jsx)(O7,{})},{path:`/status/:status`,element:(0,L.jsx)(O7,{})},{path:T7,children:N7},{path:`*`,element:(0,L.jsx)(O7,{})}]}]),F7=24,I7=6,L7=700,R7=new Map,z7=null,B7=null;function V7(e){return!Array.isArray(e)||e.length!==2?null:e[0]===`transcript`&&typeof e[1]==`string`?e[1]:null}function H7(e){return X.board?.threads.find(t=>t.id===e)?.lastActivityAt}function U7(){let e=[...R7.entries()].filter(([,e])=>e.observers>0),t=new Set(e.slice(-24).map(([e])=>e));for(let[e,n]of R7){if(n.observers<=0){n.live&&(n.live=!1,lw(e)),R7.delete(e);continue}t.has(e)?!n.live&&!n.queued&&(n.queued=!0):(n.queued=!1,n.live&&(n.live=!1,lw(e)))}W7()}function W7(){B7||[...R7.values()].some(e=>e.queued)&&(B7=setTimeout(()=>{B7=null;let e=0,t=[...R7.values()].filter(e=>e.live).length;for(let[n,r]of R7){if(e>=I7||t>=F7)break;r.queued&&(r.queued=!1,!(r.observers<=0||r.live)&&(r.live=!0,t++,r.lastActivityAt=H7(n),cw(n),e++))}W7()},L7))}function G7(){if(z7)for(let[e,t]of R7){if(t.observers<=0)continue;let n=H7(e);if(n===t.lastActivityAt)continue;t.lastActivityAt=n;let r=X.socketTranscriptFallbacks[e];t.live&&X.socketTranscripts&&!r||z7.refetchQueries({queryKey:[`transcript`,e],exact:!0,type:`active`})}}function K7(e){z7||(z7=e,e.getQueryCache().subscribe(e=>{let t=V7(e.query.queryKey);if(!t||e.type!==`observerAdded`&&e.type!==`observerRemoved`)return;let n=e.query.getObserversCount(),r=R7.get(t);e.type===`observerAdded`?(R7.delete(t),R7.set(t,{observers:n,live:r?.live??!1,queued:r?.queued??!1,lastActivityAt:r?r.lastActivityAt:H7(t)})):r&&(r.observers=n),U7()}),Zt(X,G7))}var q7=`ui-monospace, "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Mono", Consolas, Menlo, "DejaVu Sans Mono", monospace`,J7=`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;function Y7(e){let t=e===`mono`?`mono`:`sans`;document.documentElement.dataset.font=t,document.body&&(document.body.style.fontFamily=t===`sans`?J7:q7);try{localStorage.setItem(`frizz-font`,t)}catch{}}function X7(e){let t=e.getQueryData([`settingsGet`]);t&&Y7(t.font),Y.settingsGet().then(e=>Y7(e.font)).catch(()=>{}),e.getQueryCache().subscribe(()=>{let t=e.getQueryData([`settingsGet`]);t&&Y7(t.font)})}function Z7(){let e=e=>{if(e.button!==0||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`.${XS}`):null;t&&(e.preventDefault(),e.stopPropagation(),$7(t))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)}function Q7(e){return e.closest(`.md-code`)?.querySelector(`pre code`)??null}async function $7(e){let t=Q7(e);if(!t)return;let n=(t.textContent??``).replace(/\n$/,``);if(n){try{await AV(n)}catch(e){Z(`Could not copy code: ${e.message.slice(0,100)}`,{duration:7e3});return}t9(e)}}var e9=new WeakMap;function t9(e){e.classList.add(ZS),e.title=`Copied`;let t=e9.get(e);t!==void 0&&window.clearTimeout(t),e9.set(e,window.setTimeout(()=>{e.classList.remove(ZS),e.title=QS,e9.delete(e)},m0))}var n9=/^\/thread\/([a-z0-9][a-z0-9-]*)\/?$/;function r9(){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=Yd(n);if(r&&r!==Yd())return;let i=n9.exec(Qd(n));i&&(e.preventDefault(),e.stopPropagation(),Wp(i[1]))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)}var i9=new Set([`projectsList`,`projectsQueueCounts`,`threadLocate`,`dispatchPreferencesGet`,`supervisorStatus`]);function a9(e){let t=e[0];return typeof t==`string`&&i9.has(t)?T(e):T([`project:${Yd()??``}`,...e])}var o9=typeof window<`u`&&window.location.pathname.endsWith(`/settings-formatting-fixture.html`),s9=typeof window<`u`?rf(Qd()):null;!o9&&!s9&&Kw();var c9=new Le({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,queryKeyHashFn:a9}}});o9||(bw(c9),K7(c9),EU(c9),X7(c9),A$(),AJ(),Z7(),r9()),o9||(0,ct.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(He,{client:c9,children:(0,L.jsx)(Xh,{children:(0,L.jsx)(Zy,{router:P7})})}));export{a as i,tf as n,ze as r,Cb as t};