frizz 0.12.5 → 0.12.7

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 +1911 -1910
  2. package/dist/dev-child.js +2 -2
  3. package/package.json +1 -1
  4. package/web-dist/assets/{TerminalPane-PMq5oyOr.js → TerminalPane-CDk5zKv9.js} +1 -1
  5. package/web-dist/assets/{abnfDiagram-VRR7QNED-Buzu9wC_.js → abnfDiagram-VRR7QNED-DmkK2qjk.js} +1 -1
  6. package/web-dist/assets/architecture-TIHT7OUA-c0q2ebfx.js +1 -0
  7. package/web-dist/assets/{architectureDiagram-ZJ3FMSHR-D02SYSuj.js → architectureDiagram-ZJ3FMSHR-BFbA3OG6.js} +1 -1
  8. package/web-dist/assets/{blockDiagram-677ZJIJ3-BrvpZDHp.js → blockDiagram-677ZJIJ3-DTslTfq9.js} +1 -1
  9. package/web-dist/assets/{c4Diagram-LMCZKHZV-B-0cp5_F.js → c4Diagram-LMCZKHZV-Dmugni-f.js} +1 -1
  10. package/web-dist/assets/channel-CZ15urUA.js +1 -0
  11. package/web-dist/assets/{chunk-32BRIVSS-DIhtnTI3.js → chunk-32BRIVSS-DS7QIaUB.js} +1 -1
  12. package/web-dist/assets/{chunk-52WLFC77-BDsrIC5O.js → chunk-52WLFC77-CnnFIjVe.js} +1 -1
  13. package/web-dist/assets/{chunk-C7G6YPKG-Dvi27VdS.js → chunk-C7G6YPKG-BZxNdEVe.js} +1 -1
  14. package/web-dist/assets/{chunk-EX3LRPZG-D5l4eCPE.js → chunk-EX3LRPZG-Zv7RLgbb.js} +1 -1
  15. package/web-dist/assets/{chunk-FWX5IMBZ-NQ92LXeo.js → chunk-FWX5IMBZ-6-Zb5eo-.js} +2 -2
  16. package/web-dist/assets/{chunk-HOUHSVGY-nsgiwhWv.js → chunk-HOUHSVGY-J5Ui6IxH.js} +1 -1
  17. package/web-dist/assets/{chunk-ICXQ74PX-DE0wby7_.js → chunk-ICXQ74PX-DH6GE_Om.js} +1 -1
  18. package/web-dist/assets/{chunk-MOJQB5TN-BX7BpiS0.js → chunk-MOJQB5TN-Bjd1ChDq.js} +1 -1
  19. package/web-dist/assets/{chunk-OGEWGWER-Bv41bF82.js → chunk-OGEWGWER-BNvzjYRM.js} +1 -1
  20. package/web-dist/assets/{chunk-PUDLZKDR-B60KaMhk.js → chunk-PUDLZKDR-CdtfylsO.js} +1 -1
  21. package/web-dist/assets/{chunk-Q4XR5HBZ-CV-8_gBi.js → chunk-Q4XR5HBZ-C7N3sKog.js} +1 -1
  22. package/web-dist/assets/{chunk-V7JOEXUC-DP_fCRpB.js → chunk-V7JOEXUC-vX-c4OzH.js} +1 -1
  23. package/web-dist/assets/{chunk-VAUOI2AC-BG-Cmv38.js → chunk-VAUOI2AC-DtbheJmZ.js} +1 -1
  24. package/web-dist/assets/{chunk-VR4S4FIN-hvR8qINa.js → chunk-VR4S4FIN-BpE1AOJR.js} +1 -1
  25. package/web-dist/assets/{chunk-WYO6CB5R-Bcwb5mAM.js → chunk-WYO6CB5R-BupZRR1a.js} +1 -1
  26. package/web-dist/assets/{chunk-ZGVPDNZ5-BotZNl6-.js → chunk-ZGVPDNZ5-XoWDM-02.js} +1 -1
  27. package/web-dist/assets/classDiagram-OUVF2IWQ-DFxJiEZ1.js +1 -0
  28. package/web-dist/assets/classDiagram-v2-EOCWNBFH-DFxJiEZ1.js +1 -0
  29. package/web-dist/assets/{cynefin-VYW2F7L2-CyOxl50N.js → cynefin-VYW2F7L2-DOIzVENe.js} +1 -1
  30. package/web-dist/assets/{cynefinDiagram-TSTJHNR4-DkIgD3tV.js → cynefinDiagram-TSTJHNR4-DGq-kl_q.js} +1 -1
  31. package/web-dist/assets/{dagre-VKFMJZFB-Bft-Uqug.js → dagre-VKFMJZFB-Brs6wxcd.js} +1 -1
  32. package/web-dist/assets/{diagram-FQU43EPY-CHOHuWxY.js → diagram-FQU43EPY-BrQd5FEw.js} +1 -1
  33. package/web-dist/assets/{diagram-G47NLZAW-Br6RKCjL.js → diagram-G47NLZAW-B-DN7aQk.js} +1 -1
  34. package/web-dist/assets/{diagram-NH7WQ7WH-yB6WZ2Z_.js → diagram-NH7WQ7WH-DB-NFs3X.js} +1 -1
  35. package/web-dist/assets/{diagram-OA4YK3LP-D5c8OQKK.js → diagram-OA4YK3LP-DsrBhvMB.js} +1 -1
  36. package/web-dist/assets/{diagram-WEI45ONY-B2VsIZfh.js → diagram-WEI45ONY-DYctq6PN.js} +1 -1
  37. package/web-dist/assets/{ebnfDiagram-CCIWWBDH-zCELOOIj.js → ebnfDiagram-CCIWWBDH-C6ghRrJP.js} +1 -1
  38. package/web-dist/assets/{erDiagram-Q63AITRT-PiVO0dn6.js → erDiagram-Q63AITRT-C_iK-Ja6.js} +1 -1
  39. package/web-dist/assets/eventmodeling-45OFAUF4-BdXQ9Pv4.js +1 -0
  40. package/web-dist/assets/flowDiagram-23GEKE2U-rTXtf38R.js +1 -0
  41. package/web-dist/assets/{ganttDiagram-NO4QXBWP-DV7ZZP3p.js → ganttDiagram-NO4QXBWP-Y9GZAgbA.js} +1 -1
  42. package/web-dist/assets/{gitGraph-TEB2WS4Q-DFTA_fK1.js → gitGraph-TEB2WS4Q-BgqW4vt7.js} +1 -1
  43. package/web-dist/assets/{gitGraphDiagram-IHSO6WYX-OVJu-b5a.js → gitGraphDiagram-IHSO6WYX-eImStPZ8.js} +1 -1
  44. package/web-dist/assets/{index-C2rIimvp.js → index-BOACK0Xu.js} +79 -79
  45. package/web-dist/assets/{info-DKCQHKI2-C06Wjqu-.js → info-DKCQHKI2-BtbNWkY3.js} +1 -1
  46. package/web-dist/assets/{infoDiagram-FWYZ7A6U-DwqIxBIw.js → infoDiagram-FWYZ7A6U-DMIPEeRd.js} +1 -1
  47. package/web-dist/assets/{ishikawaDiagram-FXEZZL3T-GLlaEA8x.js → ishikawaDiagram-FXEZZL3T-08_raW8G.js} +1 -1
  48. package/web-dist/assets/{journeyDiagram-5HDEW3XC-BtPio3yW.js → journeyDiagram-5HDEW3XC-hPkkufFj.js} +1 -1
  49. package/web-dist/assets/{kanban-definition-HUTT4EX6-DplkqhKW.js → kanban-definition-HUTT4EX6-CDBcUNEE.js} +1 -1
  50. package/web-dist/assets/{line-kSkAw79f.js → line-Njg200Gq.js} +1 -1
  51. package/web-dist/assets/{mermaid-parser.core-Ds2HoE58.js → mermaid-parser.core-1A-yH2Ql.js} +3 -3
  52. package/web-dist/assets/{mermaid.core-CuxdqC2S.js → mermaid.core-D5Mvu4fo.js} +3 -3
  53. package/web-dist/assets/{mindmap-definition-LN4V7U3C-BDh65Pp4.js → mindmap-definition-LN4V7U3C-r-0LqhPG.js} +1 -1
  54. package/web-dist/assets/{packet-7NZHBO7P-CeKDY8cM.js → packet-7NZHBO7P-Dj8tWs_Q.js} +1 -1
  55. package/web-dist/assets/{pegDiagram-2B236MQR-Ynedj-CN.js → pegDiagram-2B236MQR-BHoUQUjJ.js} +1 -1
  56. package/web-dist/assets/{pie-RZYD4A2V-oPE5BxF3.js → pie-RZYD4A2V-GZmPkAjn.js} +1 -1
  57. package/web-dist/assets/{pieDiagram-ENE6RG2P-BJdzHH98.js → pieDiagram-ENE6RG2P-CL0ZHN1y.js} +1 -1
  58. package/web-dist/assets/{quadrantDiagram-ABIIQ3AL-BGCH-Lqc.js → quadrantDiagram-ABIIQ3AL-vZJzUcfC.js} +1 -1
  59. package/web-dist/assets/{radar-I7S5WNFK-CIj2i3bC.js → radar-I7S5WNFK-D3x_tyhl.js} +1 -1
  60. package/web-dist/assets/{railroad-3IZDKUUU-sYkCdkuK.js → railroad-3IZDKUUU-HVHtGCKZ.js} +1 -1
  61. package/web-dist/assets/railroad-abnf-AHOZXSZD-BD2umz4T.js +1 -0
  62. package/web-dist/assets/railroad-ebnf-EBAXGLYW-C1IGySZs.js +1 -0
  63. package/web-dist/assets/railroad-peg-LSFZ7HO6-BVCH7yeK.js +1 -0
  64. package/web-dist/assets/{railroadDiagram-RFXS5EU6-AhZXW611.js → railroadDiagram-RFXS5EU6-Dfw0JONh.js} +1 -1
  65. package/web-dist/assets/{requirementDiagram-TGXJPOKE-prk9Slgr.js → requirementDiagram-TGXJPOKE-DLM4etHl.js} +1 -1
  66. package/web-dist/assets/{sankeyDiagram-HTMAVEWB-SCoBTH2A.js → sankeyDiagram-HTMAVEWB-2nsrE-nL.js} +1 -1
  67. package/web-dist/assets/{sequenceDiagram-DBY2YBRQ-BrGw3SSP.js → sequenceDiagram-DBY2YBRQ-VkpQVaPX.js} +1 -1
  68. package/web-dist/assets/{stateDiagram-2N3HPSRC-CLd9B67a.js → stateDiagram-2N3HPSRC-xvBH0825.js} +1 -1
  69. package/web-dist/assets/stateDiagram-v2-6OUMAXLB-B3bLucl6.js +1 -0
  70. package/web-dist/assets/{swimlanes-5IMT3BWC-CSj8B56G.js → swimlanes-5IMT3BWC-DA8H4qPO.js} +1 -1
  71. package/web-dist/assets/swimlanesDiagram-G3AALYLV-cYXAfa4Q.js +8 -0
  72. package/web-dist/assets/{timeline-definition-FHXFAJF6-Nwo-Ei0t.js → timeline-definition-FHXFAJF6-npL1KNyH.js} +1 -1
  73. package/web-dist/assets/{treeView-QDETBFTQ-DOdXAE02.js → treeView-QDETBFTQ-Cea7MDUV.js} +1 -1
  74. package/web-dist/assets/{treemap-6X3UGDF4-iLXYkTae.js → treemap-6X3UGDF4-CGHINewA.js} +1 -1
  75. package/web-dist/assets/{vennDiagram-L72KCM5P-DeaMbppe.js → vennDiagram-L72KCM5P-D-RIigY2.js} +1 -1
  76. package/web-dist/assets/{wardley-OPB4EBWU-Dua8Pcgn.js → wardley-OPB4EBWU-BXdXDctR.js} +1 -1
  77. package/web-dist/assets/{wardleyDiagram-EHGQE667-DdoJgL5e.js → wardleyDiagram-EHGQE667-tLo8yxD2.js} +1 -1
  78. package/web-dist/assets/{xychartDiagram-FW5EYKEG-BWpJEQki.js → xychartDiagram-FW5EYKEG-I4H6c-9Q.js} +1 -1
  79. package/web-dist/index.html +1 -1
  80. package/web-dist/assets/architecture-TIHT7OUA-BA7zvXi9.js +0 -1
  81. package/web-dist/assets/channel-DpG-J81n.js +0 -1
  82. package/web-dist/assets/classDiagram-OUVF2IWQ-BtWQH2f8.js +0 -1
  83. package/web-dist/assets/classDiagram-v2-EOCWNBFH-BtWQH2f8.js +0 -1
  84. package/web-dist/assets/eventmodeling-45OFAUF4-B5mW3Fg6.js +0 -1
  85. package/web-dist/assets/flowDiagram-23GEKE2U-DUzaEkcD.js +0 -1
  86. package/web-dist/assets/railroad-abnf-AHOZXSZD-Doy_kNvp.js +0 -1
  87. package/web-dist/assets/railroad-ebnf-EBAXGLYW-BBq_aMtI.js +0 -1
  88. package/web-dist/assets/railroad-peg-LSFZ7HO6-DRmnTreC.js +0 -1
  89. package/web-dist/assets/stateDiagram-v2-6OUMAXLB-I87khM0f.js +0 -1
  90. package/web-dist/assets/swimlanesDiagram-G3AALYLV-CTyGaVXS.js +0 -8
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPane-PMq5oyOr.js","assets/rolldown-runtime-Bh1tDfsg.js","assets/mermaid.core-CuxdqC2S.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-C4XfhTaE.js","assets/chunk-WYO6CB5R-Bcwb5mAM.js","assets/chunk-ICXQ74PX-DE0wby7_.js","assets/dist-DoH_9pyS.js","assets/chunk-VAUOI2AC-BG-Cmv38.js","assets/chunk-HOUHSVGY-nsgiwhWv.js","assets/chunk-Q4XR5HBZ-CV-8_gBi.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-Bv41bF82.js","assets/chunk-C7G6YPKG-Dvi27VdS.js","assets/chunk-ZGVPDNZ5-BotZNl6-.js","assets/rough.esm-CSKSodPl.js","assets/chunk-52WLFC77-BDsrIC5O.js","assets/line-kSkAw79f.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-FWX5IMBZ-NQ92LXeo.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-CDk5zKv9.js","assets/rolldown-runtime-Bh1tDfsg.js","assets/mermaid.core-D5Mvu4fo.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-C4XfhTaE.js","assets/chunk-WYO6CB5R-BupZRR1a.js","assets/chunk-ICXQ74PX-DH6GE_Om.js","assets/dist-DoH_9pyS.js","assets/chunk-VAUOI2AC-DtbheJmZ.js","assets/chunk-HOUHSVGY-J5Ui6IxH.js","assets/chunk-Q4XR5HBZ-C7N3sKog.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-BNvzjYRM.js","assets/chunk-C7G6YPKG-BZxNdEVe.js","assets/chunk-ZGVPDNZ5-XoWDM-02.js","assets/rough.esm-CSKSodPl.js","assets/chunk-52WLFC77-CnnFIjVe.js","assets/line-Njg200Gq.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-FWX5IMBZ-6-Zb5eo-.js","assets/chunk-ZIRB5QZD-C6fEPe3t.js"])))=>i.map(i=>d[i]);
2
2
  import{n as e,t}from"./rolldown-runtime-Bh1tDfsg.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var n=t((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m)if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&j(x,t.startTime-e)}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&j(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,A=k.port2;k.port1.onmessage=D,O=function(){A.postMessage(null)}}else O=function(){_(D,0)};function j(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,j(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),r=t(((e,t)=>{t.exports=n()})),i=t((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.iterator;function m(e){return typeof e!=`object`||!e?null:(e=p&&e[p]||e[`@@iterator`],typeof e==`function`?e:null)}var h={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},g=Object.assign,_={};function v(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}v.prototype.isReactComponent={},v.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},v.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function y(){}y.prototype=v.prototype;function b(e,t,n){this.props=e,this.context=t,this.refs=_,this.updater=n||h}var x=b.prototype=new y;x.constructor=b,g(x,v.prototype),x.isPureReactComponent=!0;var S=Array.isArray;function C(){}var w={H:null,A:null,T:null,S:null},T=Object.prototype.hasOwnProperty;function E(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function D(e,t){return E(e.type,t,e.props)}function O(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function k(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?k(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(C,C):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,S(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(O(o)&&(o=D(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(S(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=m(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function P(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function ee(e){if(e._status===-1){var t=e._result;t=t(),t.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t)},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t)}),e._status===-1&&(e._status=0,e._result=t)}if(e._status===1)return e._result.default;throw e._result}var F=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},te={map:P,forEach:function(e,t,n){P(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return P(e,function(){t++}),t},toArray:function(e){return P(e,function(e){return e})||[]},only:function(e){if(!O(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=te,e.Component=v,e.Fragment=r,e.Profiler=a,e.PureComponent=b,e.StrictMode=i,e.Suspense=l,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=w,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return w.H.useMemoCache(e)}},e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=g({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!T.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return E(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)T.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return E(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=O,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:ee}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=function(e){var t=w.T,n={};w.T=n;try{var r=e(),i=w.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(C,F)}catch(e){F(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),w.T=t}},e.unstable_useCacheRefresh=function(){return w.H.useCacheRefresh()},e.use=function(e){return w.H.use(e)},e.useActionState=function(e,t,n){return w.H.useActionState(e,t,n)},e.useCallback=function(e,t){return w.H.useCallback(e,t)},e.useContext=function(e){return w.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return w.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return w.H.useEffect(e,t)},e.useEffectEvent=function(e){return w.H.useEffectEvent(e)},e.useId=function(){return w.H.useId()},e.useImperativeHandle=function(e,t,n){return w.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return w.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return w.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return w.H.useMemo(e,t)},e.useOptimistic=function(e,t){return w.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return w.H.useReducer(e,t,n)},e.useRef=function(e){return w.H.useRef(e)},e.useState=function(e){return w.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return w.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return w.H.useTransition()},e.version=`19.2.7`})),a=t(((e,t)=>{t.exports=i()})),o=t((e=>{var t=a();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},o=Symbol.for(`react.portal`);function s(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:o,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var c=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function l(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return s(e,t,null,r)},e.flushSync=function(e){var t=c.T,n=i.p;try{if(c.T=null,i.p=2,e)return e()}finally{c.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`)if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=l(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0})}}else t??i.d.M(e)},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=l(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`)if(t){var n=l(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0})}else i.d.m(e)},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return c.H.useFormState(e,t,n)},e.useFormStatus=function(){return c.H.useHostTransitionStatus()},e.version=`19.2.7`})),s=t(((e,t)=>{function n(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>`u`||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=`function`))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=o()})),c=t((e=>{var t=r(),n=a(),i=s();function o(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function c(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function l(e){var t=e,n=e;if(e.alternate)for(;t.return;)t=t.return;else{e=t;do t=e,t.flags&4098&&(n=t.return),e=t.return;while(e)}return t.tag===3?n:null}function u(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function d(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function f(e){if(l(e)!==e)throw Error(o(188))}function p(e){var t=e.alternate;if(!t){if(t=l(e),t===null)throw Error(o(188));return t===e?e:null}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var a=i.alternate;if(a===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===a.child){for(a=i.child;a;){if(a===n)return f(i),e;if(a===r)return f(i),t;a=a.sibling}throw Error(o(188))}if(n.return!==r.return)n=i,r=a;else{for(var s=!1,c=i.child;c;){if(c===n){s=!0,n=i,r=a;break}if(c===r){s=!0,r=i,n=a;break}c=c.sibling}if(!s){for(c=a.child;c;){if(c===n){s=!0,n=a,r=i;break}if(c===r){s=!0,r=a,n=i;break}c=c.sibling}if(!s)throw Error(o(189))}}if(n.alternate!==r)throw Error(o(190))}if(n.tag!==3)throw Error(o(188));return n.stateNode.current===n?e:t}function m(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=m(e),t!==null)return t;e=e.sibling}return null}var h=Object.assign,g=Symbol.for(`react.element`),_=Symbol.for(`react.transitional.element`),v=Symbol.for(`react.portal`),y=Symbol.for(`react.fragment`),b=Symbol.for(`react.strict_mode`),x=Symbol.for(`react.profiler`),S=Symbol.for(`react.consumer`),C=Symbol.for(`react.context`),w=Symbol.for(`react.forward_ref`),T=Symbol.for(`react.suspense`),E=Symbol.for(`react.suspense_list`),D=Symbol.for(`react.memo`),O=Symbol.for(`react.lazy`),k=Symbol.for(`react.activity`),A=Symbol.for(`react.memo_cache_sentinel`),j=Symbol.iterator;function M(e){return typeof e!=`object`||!e?null:(e=j&&e[j]||e[`@@iterator`],typeof e==`function`?e:null)}var N=Symbol.for(`react.client.reference`);function P(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===N?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case y:return`Fragment`;case x:return`Profiler`;case b:return`StrictMode`;case T:return`Suspense`;case E:return`SuspenseList`;case k:return`Activity`}if(typeof e==`object`)switch(e.$$typeof){case v:return`Portal`;case C:return e.displayName||`Context`;case S:return(e._context.displayName||`Context`)+`.Consumer`;case w:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case D:return t=e.displayName||null,t===null?P(e.type)||`Memo`:t;case O:t=e._payload,e=e._init;try{return P(e(t))}catch{}}return null}var ee=Array.isArray,F=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=i.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ne={pending:!1,data:null,method:null,action:null},re=[],ie=-1;function ae(e){return{current:e}}function oe(e){0>ie||(e.current=re[ie],re[ie]=null,ie--)}function se(e,t){ie++,re[ie]=e.current,e.current=t}var ce=ae(null),le=ae(null),ue=ae(null),de=ae(null);function fe(e,t){switch(se(ue,t),se(le,e),se(ce,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?Kd(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=Kd(t),e=qd(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}oe(ce),se(ce,e)}function pe(){oe(ce),oe(le),oe(ue)}function me(e){e.memoizedState!==null&&se(de,e);var t=ce.current,n=qd(t,e.type);t!==n&&(se(le,e),se(ce,n))}function he(e){le.current===e&&(oe(ce),oe(le)),de.current===e&&(oe(de),ep._currentValue=ne)}var ge,_e;function ve(e){if(ge===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);ge=t&&t[1]||``,_e=-1<e.stack.indexOf(`
3
3
  at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
4
4
  `+ge+e+_e}var ye=!1;function be(e,t){if(!e||ye)return``;ye=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}e.call(n.prototype)}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
@@ -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 bS=/^(\s*\d+\t)([\s\S]*)$/,xS=/^\s*\d+$/;function SS(e){let t=0,n=0,r=0;for(let i of e)i.trim()&&(t++,bS.test(i)?(n++,r++):xS.test(i)&&n++);return t>0&&n===t&&r>0}function CS(e){return e.replace(/[&<>"']/g,e=>e===`&`?`&amp;`:e===`<`?`&lt;`:e===`>`?`&gt;`:e===`"`?`&quot;`:`&#39;`)}var wS=`frizz-code-gutter`;function TS(e,t){let n=e.split(`
136
136
  `);if(!SS(n))return gS(e,t);let r=[],i=[];for(let e of n){let t=bS.exec(e);t?(r.push(t[1]),i.push(t[2])):e.trim()&&xS.test(e)?(r.push(e),i.push(``)):(r.push(``),i.push(e))}let a=yS(gS(i.join(`
137
137
  `),t));return r.map((e,t)=>(e?`<span class="${wS}">${CS(e)}</span>`:``)+(a[t]??``)).join(`
138
- `)}var ES=/^[a-zA-Z]:[\\/]/,DS=/^(?:cursor|vscode|vscode-insiders|windsurf):\/\/file\/(.*)$/i;function OS(e){try{return decodeURIComponent(e)}catch{return e}}function kS(e){if(e===`/`||e.startsWith(`/?`)||e.startsWith(`/#`))return!0;let t=e.replace(/[?#].*$/u,``);if(Dd(t))return!0;let n=Ad(t).split(`/`)[1]??``;return Cd.has(n)}function AS(e){let t=e?.trim();if(!t)return null;let n=OS(t);if(ES.test(n))return{display:n};if(n.startsWith(`/`)&&!n.startsWith(`//`)&&!kS(n)){let e=n;return{display:e,posixPath:e}}let r=DS.exec(t);if(r){let e=OS(r[1].replace(/[?#].*$/u,``)).replace(/^\/+/,``);if(!e)return null;if(ES.test(e))return{display:e};let t=`/${e}`;return{display:t,posixPath:t}}if(!/^file:/i.test(t))return null;try{let e=new URL(t);if(e.protocol!==`file:`)return null;if(e.hostname&&e.hostname!==`localhost`)return{display:t};let n=OS(e.pathname);return{display:n,posixPath:n}}catch{return{display:t}}}function jS(e){return`${Nd()}/local-image?path=${encodeURIComponent(e)}`}var MS=/\.(?:png|jpe?g|gif|webp)$/i;function NS(e){return e.posixPath&&MS.test(e.posixPath)?jS(e.posixPath):null}var PS=/\.(?:md|mdx|markdown)$/i;function FS(e){return PS.test(e.trim().replace(/:\d+(?::\d+)?$/,``))}function IS(e,t,n){let r=e?.trim();if(!r||/^[a-z][a-z0-9+.-]*:/i.test(r)||r.startsWith(`/`)||r.startsWith(`#`)||r.startsWith(`?`))return null;let i=OS(r.replace(/[?#].*$/u,``));if(!i)return null;let a=i===`~`||i.startsWith(`~/`);if(a&&!n?.startsWith(`/`))return null;let o=a?n:t;if(!o.startsWith(`/`))return null;let s=`${o}/${a?i.slice(1):i}`.split(`/`),c=[];for(let e of s)!e||e===`.`||(e===`..`?c.pop():c.push(e));return`/${c.join(`/`)}`}function LS(e){let t=e.lastIndexOf(`/`);return t>0?e.slice(0,t):`/`}function RS(e){return[FS(e)?`localMarkdown`:`localFile`,e]}function zS(e){let t=FS(e);return{queryKey:RS(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 BS=2e3,VS=new Map,HS=12;function US(e,t){let n=VS.get(e);if(n&&n.raw===t)return n.html;let r=TS(t,lS(e));if(VS.set(e,{raw:t,html:r}),VS.size>HS){let e=VS.keys().next();e.done||VS.delete(e.value)}return r}function WS(e){let t=globalThis.requestIdleCallback;t?t(e,{timeout:500}):setTimeout(e,0)}function GS(e,t){e.prefetchQuery(zS(t)).then(()=>{let n=e.getQueryData(zS(t).queryKey);!n?.markdown||FS(t)||WS(()=>US(n.path,n.markdown))}).catch(()=>{})}var KS=null,qS=null,JS=null,YS=null,XS=0,ZS=0,QS=!1,$S=!1,eC=!1,tC=new Map,nC=new Map,rC=0,iC=new Ab(()=>hC(),e=>{qS&&Ib(qS,e)}),aC=35e3;function oC(){return`${location.origin.replace(/^http/,`ws`)}${Nd()}/ws`}var sC,cC=!1;function lC(){sC=Dd(),cC=!0}function uC(e){return cC&&sC===e}function dC(){if(KS||eC)return;X.connection!==`open`&&(X.connection=`connecting`),lC();let e=new WebSocket(oC()),t=Dd();KS=e,QS=!1,ZS=Date.now(),e.onopen=()=>{$S=!0,ZS=Date.now(),X.connection=`open`,X.socketTranscripts=!0,JS&&=(clearTimeout(JS),null)},e.onmessage=n=>{if(!(KS!==e||t!==Dd())){ZS=Date.now();try{let e=JSON.parse(n.data),t=yC(e);t&&(XS=0),t&&e.t===`event`&&e.event.type===`board`&&(QS=!0,rC++,xC())}catch(e){console.error(`bad /ws message`,e)}}},e.onerror=()=>{},e.onclose=()=>{KS===e&&(KS=null,pC())},gC()}function fC(){let e=KS;if(KS=null,QS=!1,e){e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close()}catch{}}}function pC(){if(iC.reset(),!$S){vC();return}XS++,X.connection=XS>3?`closed`:`connecting`,mC()}function mC(e=!1){if(JS){if(!e)return;clearTimeout(JS),JS=null}let t=e?0:Math.min(1e3*2**Math.min(XS-1,4),15e3);JS=setTimeout(()=>{JS=null,dC()},t)}function hC(){iC.reset(),fC(),dC()}function gC(){if(YS)return;YS=setInterval(()=>{KS&&Date.now()-ZS>aC&&_C()},1e4);let e=()=>{eC||(!KS||Date.now()-ZS>aC)&&_C(!0)};window.addEventListener(`focus`,e),window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,()=>{document.hidden||e()})}function _C(e=!1){if(!eC){if(fC(),iC.reset(),!$S){vC();return}XS++,X.connection=XS>3?`closed`:`connecting`,mC(e)}}function vC(e){eC||(eC=!0,e&&(X.socketBoardFallback=e,X.socketTranscriptFallbacks={}),fC(),X.socketTranscripts=!1,Yb(qS??void 0))}function yC(e){switch(e.t){case`event`:return iC.handle(e.event),e.event.type===`board`&&(X.socketBoardFallback=null),!0;case`transcript`:return qS?.setQueryData([`transcript`,e.slug],t=>{let n=px(t,e.messages);return{...n,messages:ox(t?.messages,$b(t?.messages,n.messages))}}),delete X.socketTranscriptFallbacks[e.slug],!0;case`file-changed`:return qS?.invalidateQueries({queryKey:RS(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}),vC({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 bC(e){QS&&KS&&KS.readyState===WebSocket.OPEN&&KS.send(JSON.stringify(e))}function xC(){for(let e of tC.keys())X.socketTranscriptFallbacks[e]||bC({t:`sub`,topic:`transcript`,slug:e});for(let e of nC.keys())bC({t:`sub`,topic:`file`,path:e}),rC>1&&qS?.invalidateQueries({queryKey:RS(e)})}function SC(e){let t=(tC.get(e)??0)+1;tC.set(e,t),t===1&&!X.socketTranscriptFallbacks[e]&&bC({t:`sub`,topic:`transcript`,slug:e})}function CC(e){let t=(tC.get(e)??0)-1;t<=0?(tC.delete(e),bC({t:`unsub`,topic:`transcript`,slug:e})):tC.set(e,t)}function wC(e){let t=(nC.get(e)??0)+1;nC.set(e,t),t===1&&bC({t:`sub`,topic:`file`,path:e})}function TC(e){let t=(nC.get(e)??0)-1;t<=0?(nC.delete(e),bC({t:`unsub`,topic:`file`,path:e})):nC.set(e,t)}function EC(e){X.socketTranscriptFallbacks[e]&&(delete X.socketTranscriptFallbacks[e],tC.has(e)&&bC({t:`sub`,topic:`transcript`,slug:e}))}function DC(){tC.clear(),nC.clear(),iC.reset(),fC(),X.connection=`connecting`,lC(),eC?Jb():dC()}function OC(e){qS=e,lC();let t=()=>dC();document.readyState===`complete`?t():window.addEventListener(`load`,t,{once:!0})}function kC(){return Zt(X).board}function AC(){return Zt(X).board?.projectDir}function jC(e){return e}function MC(e){let t=Zt(X).socketTranscripts;return(0,I.useEffect)(()=>(wC(e),()=>TC(e)),[e]),t}function NC(e){if(!(!e||e.kind!==`session`||e.foreign||!e.sessionId))return{slug:e.id,sessionId:e.sessionId}}function PC(e){let t=NC(e);if(!(!t||e?.pendingInteraction===!1))return t}function FC(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 IC(e){let t=PC(e);return nt({queryKey:t?Mb(t.slug,t.sessionId):[`interactions`,`pending`,`unowned`],queryFn:()=>Y.pendingInteractions(t),enabled:t!==void 0,refetchInterval:e=>FC(e.state.data?.interactions??[]),refetchOnReconnect:!0,refetchOnWindowFocus:!0})}var LC=7e3,RC=5e3,zC=3,BC=15e3,VC=30*6e4;function HC(e,t,n){let r=Dp(e,t)?.lastActivityAt;if(!r)return 0;let i=Date.parse(r);return Number.isFinite(i)?i>n?0:BC:0}function UC(e,t){let n=Ve(),r=Zt(X),i=r.socketTranscripts,a=r.socketTranscriptFallbacks[e],o=nt({queryKey:[`transcript`,e],queryFn:async()=>{let t=await Y.threadTranscript({slug:e}),r=n.getQueryData([`transcript`,e]),i=fx(r,t);return{...i,messages:ox(r?.messages,$b(r?.messages,i.messages))}},refetchInterval:t.poll&&!i&&!a?1500:!1,refetchOnWindowFocus:!a,staleTime:t=>HC(X.board,e,t.state.dataUpdatedAt),gcTime:VC});return(0,I.useEffect)(()=>{if(!t.poll&&!i||a)return;let r=!1,s=0,c,l=setInterval(()=>{if(r)return;let t=Dp(X.board,e)?.lastActivityAt,a=cx(n.getQueryData([`transcript`,e])?.messages);if(!sx(t,a,RC)){s=0;return}if(a!==c&&(s=0),s>=zC)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&&(CC(e),SC(e)),r=!0,o.refetch().finally(()=>{r=!1})},LC);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:()=>EC(e)}}function WC(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 GC(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 KC(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 qC(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 JC(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 YC(){let e=Sp();return e?`/thread/${encodeURIComponent(e)}`:X.routeThreadSlug?`/thread/${encodeURIComponent(X.routeThreadSlug)}`:X.view.startsWith(`status:`)?`/status/${encodeURIComponent(X.view.slice(7))}`:`/`}function XC(e){try{return decodeURIComponent(e)}catch{return null}}function ZC(e,t=X.board?.projectSlug){let n=jd(e);return n===`/`&&t?Od(t):n}function QC(e){let t=e.match(/^\/thread\/([^/]+)$/);if(t){let e=XC(t[1]);if(e===null){X.routeThreadSlug=null,xp(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,xp(X.drawers.slice(n+1).map(e=>e.id));return}X.routeThreadSlug=e;return}let n=e.match(/^\/status\/([^/]+)$/);if(n){X.routeThreadSlug=null,xp(X.drawers.map(e=>e.id));let e=XC(n[1]);X.view=e===null?`todos`:`status:${e}`;return}X.routeThreadSlug=null,xp(X.drawers.map(e=>e.id)),X.view=`todos`}function $C(e=location.pathname){QC(Ad(e))}var ew=null;function tw(e){ew=e}function nw(e,t){ew?ew(e,t):typeof location<`u`&&location.assign(e)}function rw(e){return $C(),Jt(X,()=>{if(Fd(Ad())!==null)return;let t=ZC(YC());t!==location.pathname&&e(t,{replace:!YC().startsWith(`/thread/`)})})}function iw(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 aw=`frizz-sidebar-seen:`;function ow(e){try{return localStorage.getItem(aw+(e??``))===`1`}catch{return!1}}function sw(e,t){try{localStorage.setItem(aw+(e??``),t?`1`:`0`)}catch{}}function cw(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 lw(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 uw(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var dw=(e,t)=>Math.abs(e-t)<1.01,fw=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},pw,mw=()=>{if(pw!==void 0)return pw;if(typeof navigator>`u`)return pw=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return pw=!0;let e=navigator.maxTouchPoints;return pw=navigator.platform===`MacIntel`&&e!==void 0&&e>0},hw=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},gw=e=>e,_w=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},vw=(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(hw(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(hw(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},yw={passive:!0},bw=typeof window>`u`?!0:`onscrollend`in window,xw=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&bw,o=0,s=a?null:fw(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,yw),a&&r.addEventListener(`scrollend`,u,yw),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},Sw=(e,t)=>xw(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),Cw=(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`]},ww=(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})},Tw=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:gw,rangeExtractor:_w,onChange:()=>{},measureElement:Cw,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=lw(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!mw()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,yw),e.addEventListener(`touchend`,n,yw),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(mw()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=lw(()=>[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=lw(()=>[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=cw(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=lw(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=Ow(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=lw(()=>{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=lw(()=>[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 uw(t[Ew(0,t.length-1,r?e=>n[e*2]:e=>uw(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){e!==0&&(mw()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&dw(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()}},Ew=(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 Dw(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 Ow(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=Dw(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=Ew(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 kw=typeof document<`u`?I.useLayoutEffect:I.useEffect;function Aw({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=I.useReducer(e=>e+1,0)[1],a=I.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}let r=!!e.options.horizontal,i=t.mode===`transform`,o=r?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let n of c){let a=n.start-s,c=e.elementsCache.get(n.key);c&&t.lastPositions.get(c)!==a&&(t.lastPositions.set(c,a),i?c.style.transform=r?`translate3d(${a}px, 0, 0)`:`translate3d(0, ${a}px, 0)`:c.style[o]=`${a}px`)}},s={...r,onChange:(t,n)=>{var s;let c=a.current,l=!0;if(c.enabled){o(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,ot.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[c]=I.useState(()=>{let e=new Tw(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),kw(()=>c._didMount(),[]),kw(()=>c._willUpdate()),kw(()=>{o(c)}),c}function jw(e){return Aw({observeElementRect:vw,observeElementOffset:Sw,scrollToFn:ww,...e})}var Mw=3600*1e3,Nw=24*Mw,Pw=[{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`}],Fw=new Set(Pw.map(e=>e.value));function Iw(e){return typeof e==`string`&&Fw.has(e)}function Lw(e){return Rw(e).label}function Rw(e){return Pw.find(t=>t.value===e)??Pw[2]}function zw(e){let t=Rw(e);return t.kind===`calendar`?`Snooze until ${t.label}`:`Snooze ${t.label}`}function Bw(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`?Mw:e===`1d`?Nw:e===`3d`?3*Nw:7*Nw)).toISOString()}function Vw(e){return String(e).padStart(2,`0`)}function Hw(e){return`${e.getFullYear()}-${Vw(e.getMonth()+1)}-${Vw(e.getDate())}T${Vw(e.getHours())}:${Vw(e.getMinutes())}`}function Uw(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 Ww(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)/Nw),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 Gw(e,t){if(!Number.isFinite(Date.parse(e)))return null;let n=Ww(e,t);return n?n.replace(/^(Today|Tomorrow)/,e=>e.toLowerCase()):null}function Kw(e,t=Date.now()){let n=Gw(e,t);return n?`Snoozed until ${n}`:null}var qw=120;function Jw(e,t=qw){let n=e.trim().replace(/\s+/g,` `);return n.length>t?`${n.slice(0,t-1)}…`:n}function Yw(e,t,n=Date.now()){let r=t?.trim();if(!r)return Kw(e,n);let i=Xw(e,n);return i?`${i} — then: ${Jw(r)}`:null}function Xw(e,t=Date.now()){let n=Gw(e,t);return n?`Auto-snoozed until ${n}`:null}var Zw=`frizz.prefs.v1`;function Qw(e,t){return e===`fifo`||e===`lifo`?e:t}function $w(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:Iw(n.snoozePreset)?n.snoozePreset:t.snoozePreset,queueOrder:Qw(n.queueOrder,t.queueOrder),railFilesCollapsed:typeof n.railFilesCollapsed==`boolean`?n.railFilesCollapsed:t.railFilesCollapsed}}catch{return t}}function eT(){try{return $w(typeof localStorage>`u`?null:localStorage.getItem(Zw))}catch{return $w(null)}}var tT=qt(eT());Jt(tT,()=>{try{typeof localStorage<`u`&&localStorage.setItem(Zw,JSON.stringify(tT))}catch{}});function nT(e){return e.kind===`session`&&e.foreign!==!0&&e.runtime===`exited`}var rT=Uc.options,iT={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 aT(e){return e.foreign===!0&&e.title.trim()?e.title.trim():fT(e)?cT:e.aiTitle?.trim()&&!oT(e)?sT(e.aiTitle):e.backend===`codex`&&e.titleAuto===!0&&!e.aiTitle?.trim()?lT:e.titleAuto===!1&&e.title.trim()?e.title:e.title.trim()&&!(e.titleAuto===!0&&e.title.trim()===e.id)?e.titleAuto===!0?sT(e.title):e.title.trim():e.titleAuto===!0?lT:e.id}function oT(e){return e.titleLocked??e.titleAuto===!1}function sT(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 cT=`Spinning up a thread…`,lT=`Untitled thread`,uT=6e4,dT=15e3;function fT(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<dT}let t=Date.parse(e.spawnedAt??``);return Number.isFinite(t)&&Date.now()-t<uT}function pT(e){return e.status===`done`||e.status===`dismissed`||DT(e)!==void 0&&OT(e)?!1:!!(e.runtime===`perm-prompt`||e.pendingAsk||e.humanBlocked&&e.runtime!==`none`&&e.runtime!==`running`&&e.runtime!==`spawning`||e.pendingQuestion&&e.runtime!==`running`&&e.runtime!==`spawning`||(e.questions?.length??0)>0&&e.runtime!==`running`&&e.runtime!==`spawning`||(e.status===`active`||e.status===`planning`)&&(e.runtime===`exited`||e.runtime===`none`)&&e.spawnedAt&&!e.archived)}function mT(e){let t=Date.parse(e.lastUserAt??``),n=Date.parse(e.spawnedAt??``),r=Math.max(Number.isFinite(t)?t:-1/0,Number.isFinite(n)?n:-1/0);return Number.isFinite(r)?r:0}function hT(e){if(kT(e))return mT(e);let t=Date.parse(e.lastAssistantAt??``);return Number.isFinite(t)?t:mT(e)}function gT(e){return kT(e)?e.lastActivityAt??e.spawnedAt:e.lastAssistantAt??e.lastActivityAt??e.spawnedAt}function _T(e){return[...e].sort((e,t)=>{let n=pT(e);if(n!==pT(t))return n?-1:1;let r=hT(t)-hT(e);return r===0?e.id.localeCompare(t.id):r})}function vT(e){return[...e].sort((e,t)=>{let n=hT(t)-hT(e);return n===0?e.id.localeCompare(t.id):n})}function yT(e,t=`fifo`){let n=t===`lifo`?-1:1;return[...e].sort((e,t)=>{let r=(hT(e)-hT(t))*n;return r===0?e.id.localeCompare(t.id):r})}function bT(e){return cu(e)}function xT(e){return e.filter(e=>e.kind===`session`&&e.foreign===!0)}function ST(e){return e.kind===`session`&&e.foreign!==!0&&typeof e.pinnedAt==`string`}function CT(e){return e.runtime===`turn-idle`||e.runtime===`exited`}function wT(e){return(e.subAgents??[]).some(e=>Xc(e)&&e.state===`running`)}function TT(e){return wT(e)?!0:e.awaitingBackground===!0&&!ET(e)}function ET(e){if(e.awaitingBackground!==!0)return!1;let t=e.watches??[];return!t.some(e=>e.kind===`timer`&&e.state===`armed`)||wT(e)||(e.bgShells??[]).some(e=>e.state===`running`)?!1:!t.some(e=>e.kind===`github`&&e.state===`armed`)}function DT(e,t=Date.now()){let n=Date.parse(e.snoozedUntil??``);return Number.isFinite(n)&&n>t?e.snoozedUntil:void 0}function OT(e,t=Date.now()){let n=DT(e,t)!==void 0;if(e.state===`archived`)return!1;let r=e.bgSnoozed===!0&&e.runtime===`turn-idle`;if(wT(e)||TT(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`||!CT(e))return!1;if(r)return!0;let i=e.lastFence?.kind===`awaiting`;return n||i}function kT(e){return e.runtime===`running`||e.runtime===`spawning`?!0:e.runtime===`turn-idle`&&TT(e)}function AT(e){return e.needsYou===!0&&CT(e)}function jT(e){return e.runtime===`turn-idle`&&e.awaitingBackground===!0&&!wT(e)}function MT(e){return jT(e)?(e.bgShells??[]).some(e=>e.state===`running`)||(e.watches??[]).some(e=>e.kind===`timer`&&e.state===`armed`)?!0:(e.watches??[]).some(e=>e.kind===`github`&&e.state===`armed`&&e.github?.checks===`running`&&e.github.state===`open`):!1}function NT(e){return e.runtime===`turn-idle`?PT(e):!1}function PT(e){return(e.watches??[]).some(e=>e.kind===`github`&&e.state===`armed`)?!0:e.lastFence?.kind===`awaiting`&&e.lastFence.hints.some(e=>e.kind===`pr`&&e.value.trim()!==``)}function FT(e){let t=kT(e);return e.state===`archived`&&!t?`archived`:DT(e)!==void 0&&OT(e)?`snoozed`:e.actionableInteraction||e.pendingAsk||e.pendingQuestion||e.runtime===`perm-prompt`||e.humanBlocked||e.status===`needs-human`?`needs-input`:t&&!AT(e)&&!jT(e)?`working`:(e.questions?.length??0)>0?`needs-input`:OT(e)?`snoozed`:e.limitPause&&e.foreign!==!0?`limit`:e.lastFence?.kind===`done`&&CT(e)?`done`:NT(e)?`pr`:MT(e)?`background`:nT(e)?`stalled`:`rest`}function IT(e){let t=FT(e);return t===`stalled`||t===`limit`}function LT(e){return e.kind===`session`?e.state===`archived`&&!kT(e)?`inactive`:OT(e)?`snoozed`:`active`:null}function RT(e,t=`fifo`){let n=e.filter(zT);return[...yT(e.filter(e=>!zT(e)),t),...vT(n)]}function zT(e){return e.needsYou!==!0}function BT(e){return{running:e.filter(zT),rested:e.filter(e=>!zT(e))}}function VT(e,t=`fifo`){let n={pinned:[],active:[],snoozed:[],inactive:[]};for(let t of e){if(t.kind===`session`&&t.foreign===!0)continue;if(ST(t)){n.pinned.push(t);continue}let e=LT(t);e&&n[e].push(t)}return n.pinned.sort((e,t)=>(e.pinnedAt??``).localeCompare(t.pinnedAt??``)||e.id.localeCompare(t.id)),n.active=RT(n.active,t),n.snoozed=vT(n.snoozed),n.inactive=vT(n.inactive),n}function HT(e,t){for(let n of[e,t])if(n&&Number.isFinite(Date.parse(n)))return n}function UT(e,t=Date.now()){let n=WT(e,t);return n&&`Last active ${n}`}function WT(e,t=Date.now()){let n=qT(e,t);return n===null||n===GT?n:`${n} ago`}var GT=`just now`;function KT(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 qT(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?GT:KT(r)}function JT(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 YT(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?GT:`${KT(r)} ago`}function XT(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 ZT(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 QT=3e4,$T=new Set,eE=Date.now(),tE;function nE(){eE=Date.now();for(let e of $T)e();rE()}function rE(){if($T.size===0)return;let e=QT-eE%QT;tE=setTimeout(nE,e||QT)}function iE(e){return $T.add(e),$T.size===1&&(eE=Date.now(),rE()),()=>{$T.delete(e),$T.size===0&&tE&&(clearTimeout(tE),tE=void 0)}}function aE(){return eE}function oE(){return(0,I.useSyncExternalStore)(iE,aE,aE)}function sE({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 cE(e){return e===`running`}function lE(e,t){return e===`pending`&&t===`background`}var uE=2e3;function dE(e,t){return e===`pending`&&t===void 0}function fE(e,t,n,r){if(!dE(e,t))return!1;let i=n?Date.parse(n):NaN;return Number.isFinite(i)?r-i>=uE:!0}function pE(e){return e?.split(`
139
- `).find(e=>e.trim())?.trim().replace(/\s+/g,` `)||void 0}function mE(e,t){if(e.name===`Interrupt process`||e.status===`cancelled`||e.backgroundState!==`background`)return;let n=new Set([pE(e.desc),pE(e.detail),pE(e.command)].filter(e=>!!e));if(n.size===0)return;let r=t.filter(e=>n.has(pE(e.label)??``));return r.some(e=>e.state===`running`)?`running`:r.some(e=>e.state===`stale`)?`stale`:void 0}function hE(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 gE(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 _E(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 vE(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 yE(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?_E(t-n):``}function bE(e){if(!Number.isFinite(e)||e<0)return``;let t=Math.floor(e/6e4);return t<1?`<1m`:gE(t)}function xE(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 SE(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?gE(Math.floor((t-n)/6e4)):``}function CE(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`:`${gE(r)} ago`}var wE={fgSuccess:`#3fb950`,bgSuccessEmphasis:`#238636`,fgDanger:`#f85149`,bgDangerEmphasis:`#da3633`,fgDone:`#ab7df8`,bgDoneEmphasis:`#8957e5`,fgAttention:`#d29922`,fgNeutral:`#9198a1`,bgNeutralEmphasis:`#656c76`},TE=`shrink-0 text-[11px] leading-none text-muted/45`,EE=`block h-1.5 w-1.5 rounded-full bg-muted/30`,DE=`stale — no recent output`,OE=`block h-1.5 w-1.5 rounded-full border border-muted/45`,kE=`rested — it stopped, but the work it launched is still running`,AE=`running — no recent output`,jE={AGENT:`Open sub-agent transcript`,SHELL:`Open background shell output`,GITHUB:`Open this pull request on GitHub`};function ME(e){if(!(typeof e!=`number`||!Number.isFinite(e)||e<0))return e===1?`1 line`:`${PE(e)??`0`} lines`}function NE(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 PE(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 FE={running:`Stop — end this operation and everything it spawned, then clear the row`,settled:`Clear — stop tracking this finished operation`},IE={running:`Stop`,settled:`Clear`},LE={AGENT:`sub-agent`,SHELL:`background shell`,GITHUB:`PR watcher`};function RE(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 zE=e=>e.state===`running`||e.state===`stale`||e.state===`rested`;function BE(e,t){return t===`card`?e.filter(zE):t===`rail`?e.filter(e=>!!e.id&&zE(e)):e}var VE=e=>{let t=e.launchId??e.id;return[...t?[`id:${t}`]:[],...e.command?[`cmd:${e.command}`]:[],`launch:${e.label}\u0000${e.startedAt??``}`]};function HE(e,t){let n=[...e],r=new Set(n.flatMap(VE));for(let e of t)VE(e).some(e=>r.has(e))||n.push(e);return n}function UE({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=cE(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=yE(a,oE()),b=Math.min(Math.max((i??1)-1,0),4)*13,x=p?`running`:`settled`,S=jE[e],C=f??(g?S:void 0),w=n===`rested`?(0,L.jsx)(`span`,{className:OE,title:kE}):(0,L.jsx)(`span`,{className:EE,title:DE}),T=_?(0,L.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:p?(0,L.jsx)(sE,{size:12}):w}):(0,L.jsx)(`span`,{className:`frizz-op-dot-slot flex w-[9px] shrink-0 justify-center`,children:p?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot ${m[e]}`,"data-running-indicator":r===`card`?`queue-subagent`:`operation`}):e===`SHELL`?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot-quiet frizz-live-dot-quiet--shell`,"data-running-indicator":`operation-quiet`,title:AE}):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:wE.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:TE,children:`⤷`}),T,v&&(0,L.jsx)(`span`,{className:`petite-caps shrink-0 text-[9.5px] text-muted/45`,children:h[e]}),(0,L.jsx)(`span`,{className:`min-w-0 truncate text-muted/70 ${_?`leading-[16px]`:g?`group-hover:text-fg/80 group-hover:underline`:``}`,children:t})]}),O=_?`group flex min-w-0 items-center gap-2 pl-[26px] text-left outline-none`:`group flex min-w-0 max-w-[60%] items-center gap-1.5 overflow-hidden text-left text-[11.5px] ${g?`cursor-pointer rounded-sm outline-none transition-colors focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/60`:``}`,k=_&&b>0?{paddingLeft:26+b}:void 0,A=g?(0,L.jsx)(`button`,{type:`button`,style:k,onClick:u,onMouseDown:v?e=>e.stopPropagation():void 0,title:C,"aria-label":`${S}: ${t}`,className:O,children:D}):(0,L.jsx)(`div`,{style:k,title:C,className:O,children:D});return(0,L.jsxs)(`div`,{className:_?`flex w-full min-w-0 items-center gap-1.5 rounded-md py-0.5 pr-1.5 text-[11.5px] transition-colors hover:bg-white/[0.04]`:`flex min-w-0 items-center gap-1.5 text-[11.5px]`,style:!_&&b>0?{marginLeft:b}:void 0,"data-op-row":d?``:void 0,"data-subagent-depth":i&&i>1?i:void 0,"data-subagent-parent":l,children:[A,d&&(0,L.jsx)(`button`,{type:`button`,onClick:d,onMouseDown:e=>e.stopPropagation(),title:FE[x],"aria-label":`${IE[x]} ${LE[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)(ah,{size:11})}),E]})}var WE=null,GE=5e3,KE=6;function qE(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 JE(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>=KE)))break;return n}function YE(e,t){if(WE=null,!e||typeof window>`u`)return;let n=[...e.querySelectorAll(`[data-transcript-source-id]`)];if(n.length===0)return;let r=qE(n[0],e),i=JE(n.map(e=>{let t=e.getBoundingClientRect();return{sourceId:e.dataset.transcriptSourceId,top:t.top,bottom:t.bottom}}),r);i.length!==0&&(WE={slug:t,candidates:i,at:performance.now()})}function XE(e){let t=WE;return!t||(WE=null,t.slug!==e||performance.now()-t.at>GE)?null:t}var ZE=null;function QE(e,t){/\/full\/?$/.test(t)||(ZE={slug:e,path:t})}function $E(e){return ZE&&ZE.slug===e?ZE.path:null}var eD=`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 tD(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function nD(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function rD(...e){return t=>{let n=!1,r=e.map(e=>{let r=nD(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():nD(e[t],null)}}}}function iD(...e){return I.useCallback(rD(...e),e)}function aD(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,oD(i,...t)]}function oD(...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 sD(e){let t=I.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];hD(r)&&typeof yD==`function`&&(r=yD(r._payload)),I.Children.forEach(r,e=>{if(pD(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;hD(n)&&typeof yD==`function`&&(n=yD(n._payload)),a=uD(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?fD(a):void 0,l=iD(n,c);if(!a){if(r||r===0)throw Error(o?vD(e):_D(e));return r}let u=dD(i,a.props??{});return a.type!==I.Fragment&&(u.ref=n?l:c),I.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}var cD=Symbol.for(`radix.slottable`);function lD(e){let t=e=>`child`in e?e.children(e.child):e.children;return t.displayName=`${e}.Slottable`,t.__radixId=cD,t}var uD=(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 dD(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 fD(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function pD(e){return I.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===cD}var mD=Symbol.for(`react.lazy`);function hD(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===mD&&`_payload`in e&&gD(e._payload)}function gD(e){return typeof e==`object`&&!!e&&`then`in e}var _D=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,vD=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,yD=I.use,bD=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=sD(`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 xD(e,t){e&&ot.flushSync(()=>e.dispatchEvent(t))}function SD(e){let t=I.useRef(e);return I.useEffect(()=>{t.current=e}),I.useMemo(()=>((...e)=>t.current?.(...e)),[])}var CD=globalThis?.document?I.useLayoutEffect:()=>{},wD=I.useEffectEvent,TD=I.useInsertionEffect;function ED(e){if(typeof wD==`function`)return wD(e);let t=I.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof TD==`function`?TD(()=>{t.current=e}):CD(()=>{t.current=e}),I.useMemo(()=>((...e)=>t.current?.(...e)),[])}var DD=`DismissableLayer`,OD=`dismissableLayer.update`,kD=`dismissableLayer.pointerDownOutside`,AD=`dismissableLayer.focusOutside`,jD,MD=I.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),ND=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(MD),[d,f]=I.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=I.useState({}),h=iD(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=LD(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=RD(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=ED(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&&(jD=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),zD(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=jD))}},[d,p,n,u]),I.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),zD())},[d,u]),I.useEffect(()=>{let e=()=>m({});return document.addEventListener(OD,e),()=>document.removeEventListener(OD,e)},[]),(0,L.jsx)(bD.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:tD(e.onFocusCapture,w.onFocusCapture),onBlurCapture:tD(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:tD(e.onPointerDownCapture,C.onPointerDownCapture)})});ND.displayName=DD;var PD=`DismissableLayerBranch`,FD=I.forwardRef((e,t)=>{let n=I.useContext(MD),r=I.useRef(null),i=iD(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)(bD.div,{...e,ref:i})});FD.displayName=PD;function ID(){let e=I.useContext(MD),[t,n]=I.useState(null);return I.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}function LD(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a}=t,o=SD(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||BD(kD,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 RD(e,t=globalThis?.document){let n=SD(e),r=I.useRef(!1);return I.useEffect(()=>{let e=e=>{e.target&&!r.current&&BD(AD,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 zD(){let e=new CustomEvent(OD);document.dispatchEvent(e)}function BD(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?xD(i,a):i.dispatchEvent(a)}var VD=I.useId||(()=>void 0),HD=0;function UD(e){let[t,n]=I.useState(VD());return CD(()=>{e||n(e=>e??String(HD++))},[e]),e||(t?`radix-${t}`:``)}var WD=[`top`,`right`,`bottom`,`left`],GD=Math.min,KD=Math.max,qD=Math.round,JD=Math.floor,YD=e=>({x:e,y:e}),XD={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function ZD(e,t,n){return KD(e,GD(t,n))}function QD(e,t){return typeof e==`function`?e(t):e}function $D(e){return e.split(`-`)[0]}function eO(e){return e.split(`-`)[1]}function tO(e){return e===`x`?`y`:`x`}function nO(e){return e===`y`?`height`:`width`}function rO(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function iO(e){return tO(rO(e))}function aO(e,t,n){n===void 0&&(n=!1);let r=eO(e),i=iO(e),a=nO(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=mO(o)),[o,mO(o)]}function oO(e){let t=mO(e);return[sO(e),t,sO(t)]}function sO(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var cO=[`left`,`right`],lO=[`right`,`left`],uO=[`top`,`bottom`],dO=[`bottom`,`top`];function fO(e,t,n){switch(e){case`top`:case`bottom`:return n?t?lO:cO:t?cO:lO;case`left`:case`right`:return t?uO:dO;default:return[]}}function pO(e,t,n,r){let i=eO(e),a=fO($D(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(sO)))),a}function mO(e){let t=$D(e);return XD[t]+e.slice(t.length)}function hO(e){return{top:0,right:0,bottom:0,left:0,...e}}function gO(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:hO(e)}function _O(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 vO(e,t,n){let{reference:r,floating:i}=e,a=rO(t),o=iO(t),s=nO(o),c=$D(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(eO(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 yO(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}=QD(t,e),p=gO(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=_O(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=_O(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 bO=50,xO=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:yO},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=vO(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<bO&&(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}=vO(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},SO=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}=QD(e,t)||{};if(l==null)return{};let d=gO(u),f={x:n,y:r},p=iO(i),m=nO(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=GD(d[_],T),D=GD(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=ZD(O,A,k),M=!c.arrow&&eO(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}}}),CO=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}=QD(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=$D(r),_=rO(o),v=$D(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[mO(o)]:oO(o)),x=p!==`none`;!d&&x&&b.push(...pO(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=aO(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`&&_!==rO(t))||T.every(e=>rO(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=rO(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 wO(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function TO(e){return WD.some(t=>e[t]>=0)}var EO=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=QD(e,t);switch(i){case`referenceHidden`:{let e=wO(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:TO(e)}}}case`escaped`:{let e=wO(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:TO(e)}}}default:return{}}}}},DO=new Set([`left`,`top`]);async function OO(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=$D(n),s=eO(n),c=rO(n)===`y`,l=DO.has(o)?-1:1,u=a&&c?-1:1,d=QD(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 kO=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 OO(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}}}}},AO=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}=QD(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=rO($D(i)),p=tO(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=ZD(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=ZD(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}}}}}},jO=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}=QD(e,t),u={x:n,y:r},d=rO(i),f=tO(d),p=u[f],m=u[d],h=QD(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=DO.has($D(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}}}},MO=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}=QD(e,t),u=await o.detectOverflow(t,l),d=$D(i),f=eO(i),p=rO(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=GD(h-u[g],v),x=GD(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=KD(u.left,0),t=KD(u.right,0),n=KD(u.top,0),r=KD(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:KD(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:KD(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 NO(){return typeof window<`u`}function PO(e){return LO(e)?(e.nodeName||``).toLowerCase():`#document`}function FO(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function IO(e){return((LO(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function LO(e){return NO()?e instanceof Node||e instanceof FO(e).Node:!1}function RO(e){return NO()?e instanceof Element||e instanceof FO(e).Element:!1}function zO(e){return NO()?e instanceof HTMLElement||e instanceof FO(e).HTMLElement:!1}function BO(e){return!NO()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof FO(e).ShadowRoot}function VO(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=QO(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function HO(e){return/^(table|td|th)$/.test(PO(e))}function UO(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var WO=/transform|translate|scale|rotate|perspective|filter/,GO=/paint|layout|strict|content/,KO=e=>!!e&&e!==`none`,qO;function JO(e){let t=RO(e)?QO(e):e;return KO(t.transform)||KO(t.translate)||KO(t.scale)||KO(t.rotate)||KO(t.perspective)||!XO()&&(KO(t.backdropFilter)||KO(t.filter))||WO.test(t.willChange||``)||GO.test(t.contain||``)}function YO(e){let t=ek(e);for(;zO(t)&&!ZO(t);){if(JO(t))return t;if(UO(t))return null;t=ek(t)}return null}function XO(){return qO??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),qO}function ZO(e){return/^(html|body|#document)$/.test(PO(e))}function QO(e){return FO(e).getComputedStyle(e)}function $O(e){return RO(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function ek(e){if(PO(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||BO(e)&&e.host||IO(e);return BO(t)?t.host:t}function tk(e){let t=ek(e);return ZO(t)?e.ownerDocument?e.ownerDocument.body:e.body:zO(t)&&VO(t)?t:tk(t)}function nk(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=tk(e),i=r===e.ownerDocument?.body,a=FO(r);if(i){let e=rk(a);return t.concat(a,a.visualViewport||[],VO(r)?r:[],e&&n?nk(e):[])}else return t.concat(r,nk(r,[],n))}function rk(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ik(e){let t=QO(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=zO(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=qD(n)!==a||qD(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function ak(e){return RO(e)?e:e.contextElement}function ok(e){let t=ak(e);if(!zO(t))return YD(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=ik(t),o=(a?qD(n.width):n.width)/r,s=(a?qD(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var sk=YD(0);function ck(e){let t=FO(e);return!XO()||!t.visualViewport?sk:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function lk(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==FO(e)?!1:t}function uk(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=ak(e),o=YD(1);t&&(r?RO(r)&&(o=ok(r)):o=ok(e));let s=lk(a,n,r)?ck(a):YD(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=FO(a),t=r&&RO(r)?FO(r):r,n=e,i=rk(n);for(;i&&r&&t!==n;){let e=ok(i),t=i.getBoundingClientRect(),r=QO(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=FO(i),i=rk(n)}}return _O({width:u,height:d,x:c,y:l})}function dk(e,t){let n=$O(e).scrollLeft;return t?t.left+n:uk(IO(e)).left+n}function fk(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-dk(e,n),y:n.top+t.scrollTop}}function pk(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=IO(r),s=t?UO(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=YD(1),u=YD(0),d=zO(r);if((d||!d&&!a)&&((PO(r)!==`body`||VO(o))&&(c=$O(r)),d)){let e=uk(r);l=ok(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?fk(o,c):YD(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 mk(e){return Array.from(e.getClientRects())}function hk(e){let t=IO(e),n=$O(e),r=e.ownerDocument.body,i=KD(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=KD(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+dk(e),s=-n.scrollTop;return QO(r).direction===`rtl`&&(o+=KD(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var gk=25;function _k(e,t){let n=FO(e),r=IO(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=XO();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=dk(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<=gk&&(a-=o)}else l<=gk&&(a+=l);return{width:a,height:o,x:s,y:c}}function vk(e,t){let n=uk(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=zO(e)?ok(e):YD(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function yk(e,t,n){let r;if(t===`viewport`)r=_k(e,n);else if(t===`document`)r=hk(IO(e));else if(RO(t))r=vk(t,n);else{let n=ck(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return _O(r)}function bk(e,t){let n=ek(e);return n===t||!RO(n)||ZO(n)?!1:QO(n).position===`fixed`||bk(n,t)}function xk(e,t){let n=t.get(e);if(n)return n;let r=nk(e,[],!1).filter(e=>RO(e)&&PO(e)!==`body`),i=null,a=QO(e).position===`fixed`,o=a?ek(e):e;for(;RO(o)&&!ZO(o);){let t=QO(o),n=JO(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||VO(o)&&!n&&bk(e,o))?r=r.filter(e=>e!==o):i=t,o=ek(o)}return t.set(e,r),r}function Sk(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?UO(t)?[]:xk(t,this._c):[].concat(n),r],o=yk(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=yk(t,a[e],i);s=KD(n.top,s),c=GD(n.right,c),l=GD(n.bottom,l),u=KD(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function Ck(e){let{width:t,height:n}=ik(e);return{width:t,height:n}}function wk(e,t,n){let r=zO(t),i=IO(t),a=n===`fixed`,o=uk(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=YD(0);function l(){c.x=dk(i)}if(r||!r&&!a)if((PO(t)!==`body`||VO(i))&&(s=$O(t)),r){let e=uk(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?fk(i,s):YD(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 Tk(e){return QO(e).position===`static`}function Ek(e,t){if(!zO(e)||QO(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return IO(e)===n&&(n=n.ownerDocument.body),n}function Dk(e,t){let n=FO(e);if(UO(e))return n;if(!zO(e)){let t=ek(e);for(;t&&!ZO(t);){if(RO(t)&&!Tk(t))return t;t=ek(t)}return n}let r=Ek(e,t);for(;r&&HO(r)&&Tk(r);)r=Ek(r,t);return r&&ZO(r)&&Tk(r)&&!JO(r)?n:r||YO(e)||n}var Ok=async function(e){let t=this.getOffsetParent||Dk,n=this.getDimensions,r=await n(e.floating);return{reference:wk(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function kk(e){return QO(e).direction===`rtl`}var Ak={convertOffsetParentRelativeRectToViewportRelativeRect:pk,getDocumentElement:IO,getClippingRect:Sk,getOffsetParent:Dk,getElementRects:Ok,getClientRects:mk,getDimensions:Ck,getScale:ok,isElement:RO,isRTL:kk};function jk(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Mk(e,t){let n=null,r,i=IO(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=JD(d),h=JD(i.clientWidth-(u+f)),g=JD(i.clientHeight-(d+p)),_=JD(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:KD(0,GD(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&&!jk(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 Nk(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=ak(e),u=i||a?[...l?nk(l):[],...t?nk(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Mk(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?uk(e):null;c&&g();function g(){let t=uk(e);h&&!jk(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 Pk=kO,Fk=AO,Ik=CO,Lk=MO,Rk=EO,zk=SO,Bk=jO,Vk=(e,t,n)=>{let r=new Map,i={platform:Ak,...n},a={...i.platform,_c:r};return xO(e,t,{...i,platform:a})},Hk=typeof document<`u`?I.useLayoutEffect:function(){};function Uk(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(!Uk(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)&&!Uk(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Wk(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Gk(e,t){let n=Wk(e);return Math.round(t*n)/n}function Kk(e){let t=I.useRef(e);return Hk(()=>{t.current=e}),t}function qk(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);Uk(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=Kk(c),D=Kk(i),O=Kk(l),k=I.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Vk(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!Uk(w.current,t)&&(w.current=t,ot.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);Hk(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=I.useRef(!1);Hk(()=>(A.current=!0,()=>{A.current=!1}),[]),Hk(()=>{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=Gk(M.floating,u.x),r=Gk(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Wk(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 Jk=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?{}:zk({element:r.current,padding:i}).fn(n):r?zk({element:r,padding:i}).fn(n):{}}}},Yk=(e,t)=>{let n=Pk(e);return{name:n.name,fn:n.fn,options:[e,t]}},Xk=(e,t)=>{let n=Fk(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zk=(e,t)=>({fn:Bk(e).fn,options:[e,t]}),Qk=(e,t)=>{let n=Ik(e);return{name:n.name,fn:n.fn,options:[e,t]}},$k=(e,t)=>{let n=Lk(e);return{name:n.name,fn:n.fn,options:[e,t]}},eA=(e,t)=>{let n=Rk(e);return{name:n.name,fn:n.fn,options:[e,t]}},tA=(e,t)=>{let n=Jk(e);return{name:n.name,fn:n.fn,options:[e,t]}},nA=`Arrow`,rA=I.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,L.jsx)(bD.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`})})});rA.displayName=nA;var iA=rA;function aA(e){let[t,n]=I.useState(void 0);return CD(()=>{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 oA=`Popper`,[sA,cA]=aD(oA),[lA,uA]=sA(oA),dA=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null),[a,o]=I.useState(void 0);return(0,L.jsx)(lA,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};dA.displayName=oA;var fA=`PopperAnchor`,pA=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=uA(fA,n),o=I.useRef(null),s=a.onAnchorChange,c=iD(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&&CA(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,L.jsx)(bD.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})});pA.displayName=fA;var mA=`PopperContent`,[hA,gA]=sA(mA),_A=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=uA(mA,n),[_,v]=I.useState(null),y=iD(t,v),[b,x]=I.useState(null),S=aA(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(xA),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=qk({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>Nk(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[Yk({mainAxis:i+w,alignmentAxis:o}),c&&Xk({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Zk():void 0,...k}),c&&Qk({...k}),$k({...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&&tA({element:b,padding:s}),SA({arrowWidth:C,arrowHeight:w}),f&&eA({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ee=g.setPlacementState;CD(()=>(ee(M),()=>{ee(void 0)}),[M,ee]);let[F,te]=CA(M),ne=SD(m);CD(()=>{N&&ne?.()},[N,ne]);let re=P.arrow?.x,ie=P.arrow?.y,ae=P.arrow?.centerOffset!==0,[oe,se]=I.useState();return CD(()=>{_&&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)(hA,{scope:n,placedSide:F,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,L.jsx)(bD.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});_A.displayName=mA;var vA=`PopperArrow`,yA={top:`bottom`,right:`left`,bottom:`top`,left:`right`},bA=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=gA(vA,n),a=yA[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)(iA,{...r,ref:t,style:{...r.style,display:`block`}})})});bA.displayName=vA;function xA(e){return e!==null}var SA=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]=CA(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 CA(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var wA=dA,TA=pA,EA=_A,DA=bA,OA=`Portal`,kA=I.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=I.useState(!1);CD(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?ot.createPortal((0,L.jsx)(bD.div,{...r,ref:t}),o):null});kA.displayName=OA;function AA(e,t){return I.useReducer((e,n)=>t[e][n]??e,e)}var jA=e=>{let{present:t,children:n}=e,r=MA(t),i=typeof n==`function`?n({present:r.isPresent}):I.Children.only(n),a=PA(r.ref,IA(i));return typeof n==`function`||r.isPresent?I.cloneElement(i,{ref:a}):null};jA.displayName=`Presence`;function MA(e){let[t,n]=I.useState(),r=I.useRef(null),i=I.useRef(e),a=I.useRef(`none`),[o,s]=AA(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return I.useEffect(()=>{let e=FA(r.current);a.current=o===`mounted`?e:`none`},[o]),CD(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=FA(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),CD(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=FA(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=FA(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 NA(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function PA(...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=NA(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():NA(n[e],null)}}},[])}function FA(e){return e?.animationName||`none`}function IA(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 LA=I.useInsertionEffect||CD;function RA({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=zA({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=BA(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function zA({defaultProp:e,onChange:t}){let[n,r]=I.useState(e),i=I.useRef(n),a=I.useRef(t);return LA(()=>{a.current=t},[t]),I.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function BA(e){return typeof e==`function`}var VA=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`}),HA=`VisuallyHidden`,UA=I.forwardRef((e,t)=>(0,L.jsx)(bD.span,{...e,ref:t,style:{...VA,...e.style}}));UA.displayName=HA;var WA=UA,[GA,KA]=aD(`Tooltip`,[cA]),qA=cA(),JA=`TooltipProvider`,YA=700,XA=`tooltip.open`,[ZA,QA]=GA(JA),$A=e=>{let{__scopeTooltip:t,delayDuration:n=YA,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)(ZA,{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})};$A.displayName=JA;var ej=`Tooltip`,[tj,nj]=GA(ej),rj=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=QA(ej,e.__scopeTooltip),l=qA(t),[u,d]=I.useState(null),f=UD(),p=I.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=I.useRef(!1),[_,v]=RA({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(XA))):c.onClose(),a?.(e)},caller:ej}),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)(wA,{...l,children:(0,L.jsx)(tj,{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})})};rj.displayName=ej;var ij=`TooltipTrigger`,aj=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=nj(ij,n),a=QA(ij,n),o=qA(n),s=iD(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)(TA,{asChild:!0,...o,children:(0,L.jsx)(bD.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:tD(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:tD(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:tD(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:tD(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:tD(e.onBlur,i.onClose),onClick:tD(e.onClick,i.onClose)})})});aj.displayName=ij;var oj=`TooltipPortal`,[sj,cj]=GA(oj,{forceMount:void 0}),lj=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=nj(oj,t);return(0,L.jsx)(sj,{scope:t,forceMount:n,children:(0,L.jsx)(jA,{present:n||a.open,children:(0,L.jsx)(kA,{asChild:!0,container:i,children:r})})})};lj.displayName=oj;var uj=`TooltipContent`,dj=I.forwardRef((e,t)=>{let n=cj(uj,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=nj(uj,e.__scopeTooltip);return(0,L.jsx)(jA,{present:r||o.open,children:o.disableHoverableContent?(0,L.jsx)(gj,{side:i,...a,ref:t}):(0,L.jsx)(fj,{side:i,...a,ref:t})})}),fj=I.forwardRef((e,t)=>{let n=nj(uj,e.__scopeTooltip),r=QA(uj,e.__scopeTooltip),i=I.useRef(null),a=iD(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=bj(r,yj(r,n.getBoundingClientRect())),a=xj(t.getBoundingClientRect()),o=Cj([...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=!Sj(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,L.jsx)(gj,{...e,ref:a})}),[pj,mj]=GA(ej,{isInside:!1}),hj=lD(`TooltipContent`),gj=I.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=nj(uj,n),l=qA(n),{onClose:u}=c;return I.useEffect(()=>(document.addEventListener(XA,u),()=>document.removeEventListener(XA,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)(ND,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,L.jsxs)(EA,{"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)(hj,{children:r}),(0,L.jsx)(pj,{scope:n,isInside:!0,children:(0,L.jsx)(WA,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});dj.displayName=uj;var _j=`TooltipArrow`,vj=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=qA(n);return mj(_j,n).isInside?null:(0,L.jsx)(DA,{...i,...r,ref:t})});vj.displayName=_j;function yj(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 bj(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 xj(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 Sj(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 Cj(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)),wj(t)}function wj(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 Tj=$A,Ej=rj,Dj=aj,Oj=lj,kj=dj,Aj=vj,jj=`isolate bg-elevated opacity-100 border border-border shadow-2xl shadow-black/40`,Mj=`z-[110]`,Nj=`${Mj} ${jj}`,Pj=`z-[250]`,Fj=`z-[250]`;function Ij({children:e}){return(0,L.jsx)(Tj,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!0,children:e})}function Lj({label:e,children:t,side:n=`top`,clickable:r=!1,multiline:i=!1,disabled:a=!1}){let o=i?`whitespace-pre-line`:`whitespace-normal`,[s,c]=(0,I.useState)(!1),l=(0,I.useId)(),u=r&&(0,I.isValidElement)(t)?t:null,d=u?(0,I.cloneElement)(u,{"aria-describedby":l}):t,f=(0,I.useRef)(null);if(u){let t=f.current?.getBoundingClientRect(),n=t?Math.min(Math.max(12,t.right+8),window.innerWidth-364):12,r=t?Math.min(Math.max(12,t.top-6),window.innerHeight-96):12;return(0,L.jsxs)(`span`,{ref:f,className:`inline-flex`,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocus:()=>c(!0),onBlur:()=>c(!1),onClick:()=>c(e=>!e),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),c(!1))},children:[d,s&&(0,ot.createPortal)((0,L.jsx)(`span`,{id:l,role:`tooltip`,className:`z-[250] max-w-[min(22rem,calc(100vw-1.5rem))] rounded-md border border-border bg-elevated px-3 py-2 text-[11px] leading-relaxed text-fg shadow-md shadow-black/40 break-words ${o}`,style:{position:`fixed`,left:n,top:r},children:e}),document.body)]})}return(0,L.jsxs)(Ej,{open:s&&!a,onOpenChange:c,children:[(0,L.jsx)(Dj,{asChild:!0,children:d}),(0,L.jsx)(Oj,{children:(0,L.jsxs)(kj,{id:l,side:n,sideOffset:5,collisionPadding:12,className:`${Fj} 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)(Aj,{className:`fill-elevated`})]})})]})}function Rj({slug:e,size:t=14,className:n,label:r=`Open fullscreen`}){let i=Pd(e);function a(t){if(t.stopPropagation(),!Id(t))return;t.preventDefault();let n=!Mp(),r=t.currentTarget.closest(`[data-vt-chat]`);YE(r,e),typeof location<`u`&&QE(e,location.pathname),n&&r&&(r.style.viewTransitionName=`thread-chat`),nw(i,{viewTransition:n})}return(0,L.jsx)(Lj,{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)(Nm,{size:t})})})}function zj(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 Bj(e,t,n=`AGENT`){if(!t.id||!Xc(t)||t.state===`running`&&!t.stoppable)return;let r=t.id;return()=>zj(e,r,n)}function Vj(e){let t=e+`CollectionProvider`,[n,r]=aD(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=sD(s),l=I.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=iD(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=sD(u),p=I.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=I.useRef(null),s=iD(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 Hj=I.createContext(void 0);function Uj(e){let t=I.useContext(Hj);return e||t||`ltr`}var Wj=0,Gj=null;function Kj(){I.useEffect(()=>{Gj||={start:qj(),end:qj()};let{start:e,end:t}=Gj;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),Wj++,()=>{Wj===1&&(Gj?.start.remove(),Gj?.end.remove(),Gj=null),Wj=Math.max(0,Wj-1)}},[])}function qj(){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 Jj=`focusScope.autoFocusOnMount`,Yj=`focusScope.autoFocusOnUnmount`,Xj={bubbles:!1,cancelable:!0},Zj=`FocusScope`,Qj=I.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=I.useState(null),l=SD(i),u=SD(a),d=I.useRef(null),f=iD(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:aM(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||aM(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&aM(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){oM.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Jj,Xj);s.addEventListener(Jj,l),s.dispatchEvent(t),t.defaultPrevented||($j(lM(tM(s)),{select:!0}),document.activeElement===e&&aM(s))}return()=>{s.removeEventListener(Jj,l),setTimeout(()=>{let t=new CustomEvent(Yj,Xj);s.addEventListener(Yj,u),s.dispatchEvent(t),t.defaultPrevented||aM(e??document.body,{select:!0}),s.removeEventListener(Yj,u),oM.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]=eM(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&aM(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&aM(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,L.jsx)(bD.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});Qj.displayName=Zj;function $j(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(aM(r,{select:t}),document.activeElement!==n)return}function eM(e){let t=tM(e);return[nM(t,e),nM(t.reverse(),e)]}function tM(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 nM(e,t){for(let n of e)if(!rM(n,{upTo:t}))return n}function rM(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 iM(e){return e instanceof HTMLInputElement&&`select`in e}function aM(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&iM(e)&&t&&e.select()}}var oM=sM();function sM(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=cM(e,t),e.unshift(t)},remove(t){e=cM(e,t),e[0]?.resume()}}}function cM(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function lM(e){return e.filter(e=>e.tagName!==`A`)}var uM=`rovingFocusGroup.onEntryFocus`,dM={bubbles:!1,cancelable:!0},fM=`RovingFocusGroup`,[pM,mM,hM]=Vj(fM),[gM,_M]=aD(fM,[hM]),[vM,yM]=gM(fM),bM=I.forwardRef((e,t)=>(0,L.jsx)(pM.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,L.jsx)(pM.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,L.jsx)(xM,{...e,ref:t})})}));bM.displayName=fM;var xM=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=iD(t,f),m=Uj(a),[h,g]=RA({prop:o,defaultProp:s??null,onChange:c,caller:fM}),[_,v]=I.useState(!1),y=SD(l),b=mM(n),x=I.useRef(!1),[S,C]=I.useState(0);return I.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(uM,y),()=>e.removeEventListener(uM,y)},[y]),(0,L.jsx)(vM,{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)(bD.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:tD(e.onMouseDown,()=>{x.current=!0}),onFocus:tD(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(uM,dM);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);DM([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:tD(e.onBlur,()=>v(!1))})})}),SM=`RovingFocusGroupItem`,CM=I.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=UD(),l=a||c,u=yM(SM,n),d=u.currentTabStopId===l,f=mM(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return I.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,L.jsx)(pM.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,L.jsx)(bD.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:tD(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:tD(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:tD(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=EM(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?OM(n,r+1):n.slice(r+1)}setTimeout(()=>DM(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});CM.displayName=SM;var wM={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function TM(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function EM(e,t,n){let r=TM(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return wM[r]}function DM(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function OM(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var kM=bM,AM=CM,jM=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},MM=new WeakMap,NM=new WeakMap,PM={},FM=0,IM=function(e){return e&&(e.host||IM(e.parentNode))},LM=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=IM(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})},RM=function(e,t,n,r){var i=LM(t,Array.isArray(e)?e:[e]);PM[n]||(PM[n]=new WeakMap);var a=PM[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=(MM.get(e)||0)+1,l=(a.get(e)||0)+1;MM.set(e,c),a.set(e,l),o.push(e),c===1&&i&&NM.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(),FM++,function(){o.forEach(function(e){var t=MM.get(e)-1,i=a.get(e)-1;MM.set(e,t),a.set(e,i),t||(NM.has(e)||e.removeAttribute(r),NM.delete(e)),i||e.removeAttribute(n)}),FM--,FM||(MM=new WeakMap,MM=new WeakMap,NM=new WeakMap,PM={})}},zM=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||jM(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),RM(r,i,n,`aria-hidden`)):function(){return null}},BM=function(){return BM=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},BM.apply(this,arguments)};function VM(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 HM(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 UM=`right-scroll-bar-position`,WM=`width-before-scroll-bar`,GM=`with-scroll-bars-hidden`,KM=`--removed-body-scroll-bar-size`;function qM(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function JM(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 YM=typeof window<`u`?I.useLayoutEffect:I.useEffect,XM=new WeakMap;function ZM(e,t){var n=JM(t||null,function(t){return e.forEach(function(e){return qM(e,t)})});return YM(function(){var t=XM.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||qM(e,null)}),i.forEach(function(e){r.has(e)||qM(e,a)})}XM.set(n,e)},[e]),n}function QM(e){return e}function $M(e,t){t===void 0&&(t=QM);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 eN(e){e===void 0&&(e={});var t=$M(null);return t.options=BM({async:!0,ssr:!1},e),t}var tN=function(e){var t=e.sideCar,n=VM(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,BM({},n))};tN.isSideCarExport=!0;function nN(e,t){return e.useMedium(t),tN}var rN=eN(),iN=function(){},aN=I.forwardRef(function(e,t){var n=I.useRef(null),r=I.useState({onScrollCapture:iN,onWheelCapture:iN,onTouchMoveCapture:iN}),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=VM(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=ZM([n,t]),C=BM(BM({},b),i);return I.createElement(I.Fragment,null,u&&I.createElement(x,{sideCar:rN,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),BM(BM({},C),{ref:S})):I.createElement(v,BM({},C,{className:c,ref:S}),s))});aN.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},aN.classNames={fullWidth:WM,zeroRight:UM};var oN,sN=function(){if(oN)return oN;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function cN(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=sN();return t&&e.setAttribute(`nonce`,t),e}function lN(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function uN(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var dN=function(){var e=0,t=null;return{add:function(n){e==0&&(t=cN())&&(lN(t,n),uN(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},fN=function(){var e=dN();return function(t,n){I.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},pN=function(){var e=fN();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},mN={left:0,top:0,right:0,gap:0},hN=function(e){return parseInt(e||``,10)||0},gN=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[hN(n),hN(r),hN(i)]},_N=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return mN;var t=gN(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])}},vN=pN(),yN=`data-scroll-locked`,bN=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
- .${GM} {
138
+ `)}var ES=/^[a-zA-Z]:[\\/]/,DS=/^(?:cursor|vscode|vscode-insiders|windsurf):\/\/file\/(.*)$/i;function OS(e){try{return decodeURIComponent(e)}catch{return e}}function kS(e){if(e===`/`||e.startsWith(`/?`)||e.startsWith(`/#`))return!0;let t=e.replace(/[?#].*$/u,``);if(Dd(t))return!0;let n=Ad(t).split(`/`)[1]??``;return Cd.has(n)}function AS(e){let t=e?.trim();if(!t)return null;let n=OS(t);if(ES.test(n))return{display:n};if(n.startsWith(`/`)&&!n.startsWith(`//`)&&!kS(n)){let e=n;return{display:e,posixPath:e}}let r=DS.exec(t);if(r){let e=OS(r[1].replace(/[?#].*$/u,``)).replace(/^\/+/,``);if(!e)return null;if(ES.test(e))return{display:e};let t=`/${e}`;return{display:t,posixPath:t}}if(!/^file:/i.test(t))return null;try{let e=new URL(t);if(e.protocol!==`file:`)return null;if(e.hostname&&e.hostname!==`localhost`)return{display:t};let n=OS(e.pathname);return{display:n,posixPath:n}}catch{return{display:t}}}function jS(e){return`${Nd()}/local-image?path=${encodeURIComponent(e)}`}var MS=/\.(?:png|jpe?g|gif|webp)$/i;function NS(e){return e.posixPath&&MS.test(e.posixPath)?jS(e.posixPath):null}var PS=/\.(?:md|mdx|markdown)$/i;function FS(e){return PS.test(e.trim().replace(/:\d+(?::\d+)?$/,``))}function IS(e,t,n){let r=e?.trim();if(!r||/^[a-z][a-z0-9+.-]*:/i.test(r)||r.startsWith(`/`)||r.startsWith(`#`)||r.startsWith(`?`))return null;let i=OS(r.replace(/[?#].*$/u,``));if(!i)return null;let a=i===`~`||i.startsWith(`~/`);if(a&&!n?.startsWith(`/`))return null;let o=a?n:t;if(!o.startsWith(`/`))return null;let s=`${o}/${a?i.slice(1):i}`.split(`/`),c=[];for(let e of s)!e||e===`.`||(e===`..`?c.pop():c.push(e));return`/${c.join(`/`)}`}function LS(e){let t=e.lastIndexOf(`/`);return t>0?e.slice(0,t):`/`}function RS(e){return[FS(e)?`localMarkdown`:`localFile`,e]}function zS(e){let t=FS(e);return{queryKey:RS(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 BS=2e3,VS=new Map,HS=12;function US(e,t){let n=VS.get(e);if(n&&n.raw===t)return n.html;let r=TS(t,lS(e));if(VS.set(e,{raw:t,html:r}),VS.size>HS){let e=VS.keys().next();e.done||VS.delete(e.value)}return r}function WS(e){let t=globalThis.requestIdleCallback;t?t(e,{timeout:500}):setTimeout(e,0)}function GS(e,t){e.prefetchQuery(zS(t)).then(()=>{let n=e.getQueryData(zS(t).queryKey);!n?.markdown||FS(t)||WS(()=>US(n.path,n.markdown))}).catch(()=>{})}var KS=null,qS=null,JS=null,YS=null,XS=0,ZS=0,QS=!1,$S=!1,eC=!1,tC=new Map,nC=new Map,rC=0,iC=new Ab(()=>hC(),e=>{qS&&Ib(qS,e)}),aC=35e3;function oC(){return`${location.origin.replace(/^http/,`ws`)}${Nd()}/ws`}var sC,cC=!1;function lC(){sC=Dd(),cC=!0}function uC(e){return cC&&sC===e}function dC(){if(KS||eC)return;X.connection!==`open`&&(X.connection=`connecting`),lC();let e=new WebSocket(oC()),t=Dd();KS=e,QS=!1,ZS=Date.now(),e.onopen=()=>{$S=!0,ZS=Date.now(),X.connection=`open`,X.socketTranscripts=!0,JS&&=(clearTimeout(JS),null)},e.onmessage=n=>{if(!(KS!==e||t!==Dd())){ZS=Date.now();try{let e=JSON.parse(n.data),t=yC(e);t&&(XS=0),t&&e.t===`event`&&e.event.type===`board`&&(QS=!0,rC++,xC())}catch(e){console.error(`bad /ws message`,e)}}},e.onerror=()=>{},e.onclose=()=>{KS===e&&(KS=null,pC())},gC()}function fC(){let e=KS;if(KS=null,QS=!1,e){e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close()}catch{}}}function pC(){if(iC.reset(),!$S){vC();return}XS++,X.connection=XS>3?`closed`:`connecting`,mC()}function mC(e=!1){if(JS){if(!e)return;clearTimeout(JS),JS=null}let t=e?0:Math.min(1e3*2**Math.min(XS-1,4),15e3);JS=setTimeout(()=>{JS=null,dC()},t)}function hC(){iC.reset(),fC(),dC()}function gC(){if(YS)return;YS=setInterval(()=>{KS&&Date.now()-ZS>aC&&_C()},1e4);let e=()=>{eC||(!KS||Date.now()-ZS>aC)&&_C(!0)};window.addEventListener(`focus`,e),window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,()=>{document.hidden||e()})}function _C(e=!1){if(!eC){if(fC(),iC.reset(),!$S){vC();return}XS++,X.connection=XS>3?`closed`:`connecting`,mC(e)}}function vC(e){eC||(eC=!0,e&&(X.socketBoardFallback=e,X.socketTranscriptFallbacks={}),fC(),X.socketTranscripts=!1,Yb(qS??void 0))}function yC(e){switch(e.t){case`event`:return iC.handle(e.event),e.event.type===`board`&&(X.socketBoardFallback=null),!0;case`transcript`:return qS?.setQueryData([`transcript`,e.slug],t=>{let n=px(t,e.messages);return{...n,messages:ox(t?.messages,$b(t?.messages,n.messages))}}),delete X.socketTranscriptFallbacks[e.slug],!0;case`file-changed`:return qS?.invalidateQueries({queryKey:RS(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}),vC({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 bC(e){QS&&KS&&KS.readyState===WebSocket.OPEN&&KS.send(JSON.stringify(e))}function xC(){for(let e of tC.keys())X.socketTranscriptFallbacks[e]||bC({t:`sub`,topic:`transcript`,slug:e});for(let e of nC.keys())bC({t:`sub`,topic:`file`,path:e}),rC>1&&qS?.invalidateQueries({queryKey:RS(e)})}function SC(e){let t=(tC.get(e)??0)+1;tC.set(e,t),t===1&&!X.socketTranscriptFallbacks[e]&&bC({t:`sub`,topic:`transcript`,slug:e})}function CC(e){let t=(tC.get(e)??0)-1;t<=0?(tC.delete(e),bC({t:`unsub`,topic:`transcript`,slug:e})):tC.set(e,t)}function wC(e){let t=(nC.get(e)??0)+1;nC.set(e,t),t===1&&bC({t:`sub`,topic:`file`,path:e})}function TC(e){let t=(nC.get(e)??0)-1;t<=0?(nC.delete(e),bC({t:`unsub`,topic:`file`,path:e})):nC.set(e,t)}function EC(e){X.socketTranscriptFallbacks[e]&&(delete X.socketTranscriptFallbacks[e],tC.has(e)&&bC({t:`sub`,topic:`transcript`,slug:e}))}function DC(){tC.clear(),nC.clear(),iC.reset(),fC(),X.connection=`connecting`,lC(),eC?Jb():dC()}function OC(e){qS=e,lC();let t=()=>dC();document.readyState===`complete`?t():window.addEventListener(`load`,t,{once:!0})}function kC(){return Zt(X).board}function AC(){return Zt(X).board?.projectDir}function jC(e){return e}function MC(e){let t=Zt(X).socketTranscripts;return(0,I.useEffect)(()=>(wC(e),()=>TC(e)),[e]),t}function NC(e){if(!(!e||e.kind!==`session`||e.foreign||!e.sessionId))return{slug:e.id,sessionId:e.sessionId}}function PC(e){let t=NC(e);if(!(!t||e?.pendingInteraction===!1))return t}function FC(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 IC(e){let t=PC(e);return nt({queryKey:t?Mb(t.slug,t.sessionId):[`interactions`,`pending`,`unowned`],queryFn:()=>Y.pendingInteractions(t),enabled:t!==void 0,refetchInterval:e=>FC(e.state.data?.interactions??[]),refetchOnReconnect:!0,refetchOnWindowFocus:!0})}var LC=7e3,RC=5e3,zC=3,BC=15e3,VC=30*6e4;function HC(e,t,n){let r=Dp(e,t)?.lastActivityAt;if(!r)return 0;let i=Date.parse(r);return Number.isFinite(i)?i>n?0:BC:0}function UC(e,t){let n=Ve(),r=Zt(X),i=r.socketTranscripts,a=r.socketTranscriptFallbacks[e],o=nt({queryKey:[`transcript`,e],queryFn:async()=>{let t=await Y.threadTranscript({slug:e}),r=n.getQueryData([`transcript`,e]),i=fx(r,t);return{...i,messages:ox(r?.messages,$b(r?.messages,i.messages))}},refetchInterval:t.poll&&!i&&!a?1500:!1,refetchOnWindowFocus:!a,staleTime:t=>HC(X.board,e,t.state.dataUpdatedAt),gcTime:VC});return(0,I.useEffect)(()=>{if(!t.poll&&!i||a)return;let r=!1,s=0,c,l=setInterval(()=>{if(r)return;let t=Dp(X.board,e)?.lastActivityAt,a=cx(n.getQueryData([`transcript`,e])?.messages);if(!sx(t,a,RC)){s=0;return}if(a!==c&&(s=0),s>=zC)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&&(CC(e),SC(e)),r=!0,o.refetch().finally(()=>{r=!1})},LC);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:()=>EC(e)}}function WC(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 GC(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 KC(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 qC(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 JC(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 YC(){let e=Sp();return e?`/thread/${encodeURIComponent(e)}`:X.routeThreadSlug?`/thread/${encodeURIComponent(X.routeThreadSlug)}`:X.view.startsWith(`status:`)?`/status/${encodeURIComponent(X.view.slice(7))}`:`/`}function XC(e){try{return decodeURIComponent(e)}catch{return null}}function ZC(e,t=X.board?.projectSlug){let n=jd(e);return n===`/`&&t?Od(t):n}function QC(e){let t=e.match(/^\/thread\/([^/]+)$/);if(t){let e=XC(t[1]);if(e===null){X.routeThreadSlug=null,xp(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,xp(X.drawers.slice(n+1).map(e=>e.id));return}X.routeThreadSlug=e;return}let n=e.match(/^\/status\/([^/]+)$/);if(n){X.routeThreadSlug=null,xp(X.drawers.map(e=>e.id));let e=XC(n[1]);X.view=e===null?`todos`:`status:${e}`;return}X.routeThreadSlug=null,xp(X.drawers.map(e=>e.id)),X.view=`todos`}function $C(e=location.pathname){QC(Ad(e))}var ew=null;function tw(e){ew=e}function nw(e,t){ew?ew(e,t):typeof location<`u`&&location.assign(e)}function rw(e){return $C(),Jt(X,()=>{if(Fd(Ad())!==null)return;let t=ZC(YC());t!==location.pathname&&e(t,{replace:!YC().startsWith(`/thread/`)})})}function iw(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 aw=`frizz-sidebar-seen:`;function ow(e){try{return localStorage.getItem(aw+(e??``))===`1`}catch{return!1}}function sw(e,t){try{localStorage.setItem(aw+(e??``),t?`1`:`0`)}catch{}}function cw(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 lw(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 uw(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var dw=(e,t)=>Math.abs(e-t)<1.01,fw=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},pw,mw=()=>{if(pw!==void 0)return pw;if(typeof navigator>`u`)return pw=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return pw=!0;let e=navigator.maxTouchPoints;return pw=navigator.platform===`MacIntel`&&e!==void 0&&e>0},hw=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},gw=e=>e,_w=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},vw=(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(hw(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(hw(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},yw={passive:!0},bw=typeof window>`u`?!0:`onscrollend`in window,xw=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&bw,o=0,s=a?null:fw(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,yw),a&&r.addEventListener(`scrollend`,u,yw),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},Sw=(e,t)=>xw(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),Cw=(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`]},ww=(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})},Tw=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:gw,rangeExtractor:_w,onChange:()=>{},measureElement:Cw,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=lw(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{if(t&&this._intendedScrollOffset===null&&e===this.scrollOffset)return;this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0;let n=this.getScrollOffset();this.scrollDirection=t?n===e?this.scrollDirection:n<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!mw()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,yw),e.addEventListener(`touchend`,n,yw),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}let t=this.pendingScrollAnchor;if(this.pendingScrollAnchor=null,t&&this.scrollElement&&this.options.enabled){let[e,n,r,i]=t;e!==null&&!r&&(mw()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?i!==0&&(this._iosDeferredAdjustment+=i):this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})),r&&this.scrollToEnd({behavior:r})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;if(this._iosDeferredAdjustment<0&&e>=t-1){this._iosDeferredAdjustment=0;return}let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getMeasurementOptions=lw(()=>[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=lw(()=>[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=cw(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=lw(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=Ow(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=lw(()=>{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=lw(()=>[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 uw(t[Ew(0,t.length-1,r?e=>n[e*2]:e=>uw(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getVirtualDistanceFromEnd=()=>Math.max(this.getTotalSize()-this.getSize()-this.getScrollOffset(),0),this.getDistanceFromEnd=()=>Math.max(this.getMaxScrollOffset()-this.getScrollOffset(),0),this.isAtEnd=(e=this.options.scrollEndThreshold)=>this.getDistanceFromEnd()<=e,this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0;let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{this._iosDeferredAdjustment=0,e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.scrollToEnd=({behavior:e=`auto`}={})=>{if(this.options.count>0){this.scrollToIndex(this.options.count-1,{align:`end`,behavior:e});return}this.scrollToOffset(Math.max(this.getTotalSize()-this.getSize(),0),{behavior:e})},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}applyScrollAdjustment(e,t){e!==0&&(mw()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=e:(this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=e,behavior:t}),this.scrollOffset!==null&&(this.scrollOffset+=this.scrollAdjustments,this.scrollOffset<0&&(this.scrollOffset=0),this.scrollAdjustments=0)))}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&dw(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()}},Ew=(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 Dw(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 Ow(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=Dw(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=Ew(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 kw=typeof document<`u`?I.useLayoutEffect:I.useEffect;function Aw({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=I.useReducer(e=>e+1,0)[1],a=I.useRef({enabled:t,mode:n,container:null,lastSize:null,lastPositions:new WeakMap,prevRange:null});a.current.enabled=t,a.current.mode=n;let o=e=>{let t=a.current;if(!t.enabled||!t.container)return;let n=e.getTotalSize();if(n!==t.lastSize){t.lastSize=n;let r=e.options.horizontal?`width`:`height`;t.container.style[r]=`${n}px`}let r=!!e.options.horizontal,i=t.mode===`transform`,o=r?`left`:`top`,s=e.options.scrollMargin,c=e.getVirtualItems();for(let n of c){let a=n.start-s,c=e.elementsCache.get(n.key);c&&t.lastPositions.get(c)!==a&&(t.lastPositions.set(c,a),i?c.style.transform=r?`translate3d(${a}px, 0, 0)`:`translate3d(0, ${a}px, 0)`:c.style[o]=`${a}px`)}},s={...r,onChange:(t,n)=>{var s;let c=a.current,l=!0;if(c.enabled){o(t);let e=t.range,n=c.prevRange;l=!n||n.isScrolling!==t.isScrolling||n.startIndex!==e?.startIndex||n.endIndex!==e?.endIndex,l&&(c.prevRange=e?{startIndex:e.startIndex,endIndex:e.endIndex,isScrolling:t.isScrolling}:null)}l&&(e&&n?(0,ot.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[c]=I.useState(()=>{let e=new Tw(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),kw(()=>c._didMount(),[]),kw(()=>c._willUpdate()),kw(()=>{o(c)}),c}function jw(e){return Aw({observeElementRect:vw,observeElementOffset:Sw,scrollToFn:ww,...e})}var Mw=3600*1e3,Nw=24*Mw,Pw=[{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`}],Fw=new Set(Pw.map(e=>e.value));function Iw(e){return typeof e==`string`&&Fw.has(e)}function Lw(e){return Rw(e).label}function Rw(e){return Pw.find(t=>t.value===e)??Pw[2]}function zw(e){let t=Rw(e);return t.kind===`calendar`?`Snooze until ${t.label}`:`Snooze ${t.label}`}function Bw(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`?Mw:e===`1d`?Nw:e===`3d`?3*Nw:7*Nw)).toISOString()}function Vw(e){return String(e).padStart(2,`0`)}function Hw(e){return`${e.getFullYear()}-${Vw(e.getMonth()+1)}-${Vw(e.getDate())}T${Vw(e.getHours())}:${Vw(e.getMinutes())}`}function Uw(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 Ww(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)/Nw),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 Gw(e,t){if(!Number.isFinite(Date.parse(e)))return null;let n=Ww(e,t);return n?n.replace(/^(Today|Tomorrow)/,e=>e.toLowerCase()):null}function Kw(e,t=Date.now()){let n=Gw(e,t);return n?`Snoozed until ${n}`:null}var qw=120;function Jw(e,t=qw){let n=e.trim().replace(/\s+/g,` `);return n.length>t?`${n.slice(0,t-1)}…`:n}function Yw(e,t,n=Date.now()){let r=t?.trim();if(!r)return Kw(e,n);let i=Xw(e,n);return i?`${i} — then: ${Jw(r)}`:null}function Xw(e,t=Date.now()){let n=Gw(e,t);return n?`Auto-snoozed until ${n}`:null}var Zw=`frizz.prefs.v1`;function Qw(e,t){return e===`fifo`||e===`lifo`?e:t}function $w(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:Iw(n.snoozePreset)?n.snoozePreset:t.snoozePreset,queueOrder:Qw(n.queueOrder,t.queueOrder),railFilesCollapsed:typeof n.railFilesCollapsed==`boolean`?n.railFilesCollapsed:t.railFilesCollapsed}}catch{return t}}function eT(){try{return $w(typeof localStorage>`u`?null:localStorage.getItem(Zw))}catch{return $w(null)}}var tT=qt(eT());Jt(tT,()=>{try{typeof localStorage<`u`&&localStorage.setItem(Zw,JSON.stringify(tT))}catch{}});function nT(e){return e.kind===`session`&&e.foreign!==!0&&e.runtime===`exited`}var rT=Uc.options,iT={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 aT(e){return e.foreign===!0&&e.title.trim()?e.title.trim():fT(e)?cT:e.aiTitle?.trim()&&!oT(e)?sT(e.aiTitle):e.backend===`codex`&&e.titleAuto===!0&&!e.aiTitle?.trim()?lT:e.titleAuto===!1&&e.title.trim()?e.title:e.title.trim()&&!(e.titleAuto===!0&&e.title.trim()===e.id)?e.titleAuto===!0?sT(e.title):e.title.trim():e.titleAuto===!0?lT:e.id}function oT(e){return e.titleLocked??e.titleAuto===!1}function sT(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 cT=`Spinning up a thread…`,lT=`Untitled thread`,uT=6e4,dT=15e3;function fT(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<dT}let t=Date.parse(e.spawnedAt??``);return Number.isFinite(t)&&Date.now()-t<uT}function pT(e){return e.status===`done`||e.status===`dismissed`||DT(e)!==void 0&&OT(e)?!1:!!(e.runtime===`perm-prompt`||e.pendingAsk||e.humanBlocked&&e.runtime!==`none`&&e.runtime!==`running`&&e.runtime!==`spawning`||e.pendingQuestion&&e.runtime!==`running`&&e.runtime!==`spawning`||(e.questions?.length??0)>0&&e.runtime!==`running`&&e.runtime!==`spawning`||(e.status===`active`||e.status===`planning`)&&(e.runtime===`exited`||e.runtime===`none`)&&e.spawnedAt&&!e.archived)}function mT(e){let t=Date.parse(e.lastUserAt??``),n=Date.parse(e.spawnedAt??``),r=Math.max(Number.isFinite(t)?t:-1/0,Number.isFinite(n)?n:-1/0);return Number.isFinite(r)?r:0}function hT(e){if(kT(e))return mT(e);let t=Date.parse(e.lastAssistantAt??``);return Number.isFinite(t)?t:mT(e)}function gT(e){return kT(e)?e.lastActivityAt??e.spawnedAt:e.lastAssistantAt??e.lastActivityAt??e.spawnedAt}function _T(e){return[...e].sort((e,t)=>{let n=pT(e);if(n!==pT(t))return n?-1:1;let r=hT(t)-hT(e);return r===0?e.id.localeCompare(t.id):r})}function vT(e){return[...e].sort((e,t)=>{let n=hT(t)-hT(e);return n===0?e.id.localeCompare(t.id):n})}function yT(e,t=`fifo`){let n=t===`lifo`?-1:1;return[...e].sort((e,t)=>{let r=(hT(e)-hT(t))*n;return r===0?e.id.localeCompare(t.id):r})}function bT(e){return cu(e)}function xT(e){return e.filter(e=>e.kind===`session`&&e.foreign===!0)}function ST(e){return e.kind===`session`&&e.foreign!==!0&&typeof e.pinnedAt==`string`}function CT(e){return e.runtime===`turn-idle`||e.runtime===`exited`}function wT(e){return(e.subAgents??[]).some(e=>Xc(e)&&e.state===`running`)}function TT(e){return wT(e)?!0:e.awaitingBackground===!0&&!ET(e)}function ET(e){if(e.awaitingBackground!==!0)return!1;let t=e.watches??[];return!t.some(e=>e.kind===`timer`&&e.state===`armed`)||wT(e)||(e.bgShells??[]).some(e=>e.state===`running`)?!1:!t.some(e=>e.kind===`github`&&e.state===`armed`)}function DT(e,t=Date.now()){let n=Date.parse(e.snoozedUntil??``);return Number.isFinite(n)&&n>t?e.snoozedUntil:void 0}function OT(e,t=Date.now()){let n=DT(e,t)!==void 0;if(e.state===`archived`)return!1;let r=e.bgSnoozed===!0&&e.runtime===`turn-idle`;if(wT(e)||TT(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`||!CT(e))return!1;if(r)return!0;let i=e.lastFence?.kind===`awaiting`;return n||i}function kT(e){return e.runtime===`running`||e.runtime===`spawning`?!0:e.runtime===`turn-idle`&&TT(e)}function AT(e){return e.needsYou===!0&&CT(e)}function jT(e){return e.runtime===`turn-idle`&&e.awaitingBackground===!0&&!wT(e)}function MT(e){return jT(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 NT(e){return e.runtime===`turn-idle`?PT(e):!1}function PT(e){return(e.watches??[]).some(e=>e.kind===`github`&&e.state===`armed`)?!0:e.lastFence?.kind===`awaiting`&&e.lastFence.hints.some(e=>e.kind===`pr`&&e.value.trim()!==``)}function FT(e){return e.runtime===`turn-idle`?(e.watches??[]).some(e=>e.kind===`timer`&&e.state===`armed`):!1}function IT(e){let t=kT(e);return e.state===`archived`&&!t?`archived`:DT(e)!==void 0&&OT(e)?`snoozed`:e.actionableInteraction||e.pendingAsk||e.pendingQuestion||e.runtime===`perm-prompt`||e.humanBlocked||e.status===`needs-human`?`needs-input`:t&&!AT(e)&&!jT(e)?`working`:(e.questions?.length??0)>0?`needs-input`:OT(e)?`snoozed`:e.limitPause&&e.foreign!==!0?`limit`:e.lastFence?.kind===`done`&&CT(e)?`done`:NT(e)?`pr`:FT(e)?`timer`:MT(e)?`background`:nT(e)?`stalled`:`rest`}function LT(e){let t=IT(e);return t===`stalled`||t===`limit`}function RT(e){return e.kind===`session`?e.state===`archived`&&!kT(e)?`inactive`:OT(e)?`snoozed`:`active`:null}function zT(e,t=`fifo`){let n=e.filter(BT);return[...yT(e.filter(e=>!BT(e)),t),...vT(n)]}function BT(e){return e.needsYou!==!0}function VT(e){return{running:e.filter(BT),rested:e.filter(e=>!BT(e))}}function HT(e,t=`fifo`){let n={pinned:[],active:[],snoozed:[],inactive:[]};for(let t of e){if(t.kind===`session`&&t.foreign===!0)continue;if(ST(t)){n.pinned.push(t);continue}let e=RT(t);e&&n[e].push(t)}return n.pinned.sort((e,t)=>(e.pinnedAt??``).localeCompare(t.pinnedAt??``)||e.id.localeCompare(t.id)),n.active=zT(n.active,t),n.snoozed=vT(n.snoozed),n.inactive=vT(n.inactive),n}function UT(e,t){for(let n of[e,t])if(n&&Number.isFinite(Date.parse(n)))return n}function WT(e,t=Date.now()){let n=GT(e,t);return n&&`Last active ${n}`}function GT(e,t=Date.now()){let n=JT(e,t);return n===null||n===KT?n:`${n} ago`}var KT=`just now`;function qT(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 JT(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?KT:qT(r)}function YT(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 XT(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?KT:`${qT(r)} ago`}function ZT(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 QT(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 $T=3e4,eE=new Set,tE=Date.now(),nE;function rE(){tE=Date.now();for(let e of eE)e();iE()}function iE(){if(eE.size===0)return;let e=$T-tE%$T;nE=setTimeout(rE,e||$T)}function aE(e){return eE.add(e),eE.size===1&&(tE=Date.now(),iE()),()=>{eE.delete(e),eE.size===0&&nE&&(clearTimeout(nE),nE=void 0)}}function oE(){return tE}function sE(){return(0,I.useSyncExternalStore)(aE,oE,oE)}function cE({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 lE(e){return e===`running`}function uE(e,t){return e===`pending`&&t===`background`}var dE=2e3;function fE(e,t){return e===`pending`&&t===void 0}function pE(e,t,n,r){if(!fE(e,t))return!1;let i=n?Date.parse(n):NaN;return Number.isFinite(i)?r-i>=dE:!0}function mE(e){return e?.split(`
139
+ `).find(e=>e.trim())?.trim().replace(/\s+/g,` `)||void 0}function hE(e,t){if(e.name===`Interrupt process`||e.status===`cancelled`||e.backgroundState!==`background`)return;let n=new Set([mE(e.desc),mE(e.detail),mE(e.command)].filter(e=>!!e));if(n.size===0)return;let r=t.filter(e=>n.has(mE(e.label)??``));return r.some(e=>e.state===`running`)?`running`:r.some(e=>e.state===`stale`)?`stale`:void 0}function gE(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 _E(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 vE(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 yE(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 bE(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?vE(t-n):``}function xE(e){if(!Number.isFinite(e)||e<0)return``;let t=Math.floor(e/6e4);return t<1?`<1m`:_E(t)}function SE(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 CE(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?_E(Math.floor((t-n)/6e4)):``}function wE(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`:`${_E(r)} ago`}var TE={fgSuccess:`#3fb950`,bgSuccessEmphasis:`#238636`,fgDanger:`#f85149`,bgDangerEmphasis:`#da3633`,fgDone:`#ab7df8`,bgDoneEmphasis:`#8957e5`,fgAttention:`#d29922`,fgNeutral:`#9198a1`,bgNeutralEmphasis:`#656c76`},EE=`shrink-0 text-[11px] leading-none text-muted/45`,DE=`block h-1.5 w-1.5 rounded-full bg-muted/30`,OE=`stale — no recent output`,kE=`block h-1.5 w-1.5 rounded-full border border-muted/45`,AE=`rested — it stopped, but the work it launched is still running`,jE=`running — no recent output`,ME={AGENT:`Open sub-agent transcript`,SHELL:`Open background shell output`,GITHUB:`Open this pull request on GitHub`};function NE(e){if(!(typeof e!=`number`||!Number.isFinite(e)||e<0))return e===1?`1 line`:`${FE(e)??`0`} lines`}function PE(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 FE(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 IE={running:`Stop — end this operation and everything it spawned, then clear the row`,settled:`Clear — stop tracking this finished operation`},LE={running:`Stop`,settled:`Clear`},RE={AGENT:`sub-agent`,SHELL:`background shell`,GITHUB:`PR watcher`};function zE(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 BE=e=>e.state===`running`||e.state===`stale`||e.state===`rested`;function VE(e,t){return t===`card`?e.filter(BE):t===`rail`?e.filter(e=>!!e.id&&BE(e)):e}var HE=e=>{let t=e.launchId??e.id;return[...t?[`id:${t}`]:[],...e.command?[`cmd:${e.command}`]:[],`launch:${e.label}\u0000${e.startedAt??``}`]};function UE(e,t){let n=[...e],r=new Set(n.flatMap(HE));for(let e of t)HE(e).some(e=>r.has(e))||n.push(e);return n}function WE({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=lE(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=bE(a,sE()),b=Math.min(Math.max((i??1)-1,0),4)*13,x=p?`running`:`settled`,S=ME[e],C=f??(g?S:void 0),w=n===`rested`?(0,L.jsx)(`span`,{className:kE,title:AE}):(0,L.jsx)(`span`,{className:DE,title:OE}),T=_?(0,L.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:p?(0,L.jsx)(cE,{size:12}):w}):(0,L.jsx)(`span`,{className:`frizz-op-dot-slot flex w-[9px] shrink-0 justify-center`,children:p?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot ${m[e]}`,"data-running-indicator":r===`card`?`queue-subagent`:`operation`}):e===`SHELL`?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot-quiet frizz-live-dot-quiet--shell`,"data-running-indicator":`operation-quiet`,title:jE}):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:TE.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:EE,children:`⤷`}),T,v&&(0,L.jsx)(`span`,{className:`petite-caps shrink-0 text-[9.5px] text-muted/45`,children:h[e]}),(0,L.jsx)(`span`,{className:`min-w-0 truncate text-muted/70 ${_?`leading-[16px]`:g?`group-hover:text-fg/80 group-hover:underline`:``}`,children:t})]}),O=_?`group flex min-w-0 items-center gap-2 pl-[26px] text-left outline-none`:`group flex min-w-0 max-w-[60%] items-center gap-1.5 overflow-hidden text-left text-[11.5px] ${g?`cursor-pointer rounded-sm outline-none transition-colors focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/60`:``}`,k=_&&b>0?{paddingLeft:26+b}:void 0,A=g?(0,L.jsx)(`button`,{type:`button`,style:k,onClick:u,onMouseDown:v?e=>e.stopPropagation():void 0,title:C,"aria-label":`${S}: ${t}`,className:O,children:D}):(0,L.jsx)(`div`,{style:k,title:C,className:O,children:D});return(0,L.jsxs)(`div`,{className:_?`flex w-full min-w-0 items-center gap-1.5 rounded-md py-0.5 pr-1.5 text-[11.5px] transition-colors hover:bg-white/[0.04]`:`flex min-w-0 items-center gap-1.5 text-[11.5px]`,style:!_&&b>0?{marginLeft:b}:void 0,"data-op-row":d?``:void 0,"data-subagent-depth":i&&i>1?i:void 0,"data-subagent-parent":l,children:[A,d&&(0,L.jsx)(`button`,{type:`button`,onClick:d,onMouseDown:e=>e.stopPropagation(),title:IE[x],"aria-label":`${LE[x]} ${RE[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)(ah,{size:11})}),E]})}var GE=null,KE=5e3,qE=6;function JE(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 YE(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>=qE)))break;return n}function XE(e,t){if(GE=null,!e||typeof window>`u`)return;let n=[...e.querySelectorAll(`[data-transcript-source-id]`)];if(n.length===0)return;let r=JE(n[0],e),i=YE(n.map(e=>{let t=e.getBoundingClientRect();return{sourceId:e.dataset.transcriptSourceId,top:t.top,bottom:t.bottom}}),r);i.length!==0&&(GE={slug:t,candidates:i,at:performance.now()})}function ZE(e){let t=GE;return!t||(GE=null,t.slug!==e||performance.now()-t.at>KE)?null:t}var QE=null;function $E(e,t){/\/full\/?$/.test(t)||(QE={slug:e,path:t})}function eD(e){return QE&&QE.slug===e?QE.path:null}var tD=`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 nD(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r.defaultPrevented)return t?.(r)}}function rD(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function iD(...e){return t=>{let n=!1,r=e.map(e=>{let r=rD(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():rD(e[t],null)}}}}function aD(...e){return I.useCallback(iD(...e),e)}function oD(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,sD(i,...t)]}function sD(...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 cD(e){let t=I.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];gD(r)&&typeof bD==`function`&&(r=bD(r._payload)),I.Children.forEach(r,e=>{if(mD(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;gD(n)&&typeof bD==`function`&&(n=bD(n._payload)),a=dD(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?pD(a):void 0,l=aD(n,c);if(!a){if(r||r===0)throw Error(o?yD(e):vD(e));return r}let u=fD(i,a.props??{});return a.type!==I.Fragment&&(u.ref=n?l:c),I.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}var lD=Symbol.for(`radix.slottable`);function uD(e){let t=e=>`child`in e?e.children(e.child):e.children;return t.displayName=`${e}.Slottable`,t.__radixId=lD,t}var dD=(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 fD(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 pD(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}function mD(e){return I.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===lD}var hD=Symbol.for(`react.lazy`);function gD(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===hD&&`_payload`in e&&_D(e._payload)}function _D(e){return typeof e==`object`&&!!e&&`then`in e}var vD=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,yD=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,bD=I.use,xD=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=cD(`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 SD(e,t){e&&ot.flushSync(()=>e.dispatchEvent(t))}function CD(e){let t=I.useRef(e);return I.useEffect(()=>{t.current=e}),I.useMemo(()=>((...e)=>t.current?.(...e)),[])}var wD=globalThis?.document?I.useLayoutEffect:()=>{},TD=I.useEffectEvent,ED=I.useInsertionEffect;function DD(e){if(typeof TD==`function`)return TD(e);let t=I.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof ED==`function`?ED(()=>{t.current=e}):wD(()=>{t.current=e}),I.useMemo(()=>((...e)=>t.current?.(...e)),[])}var OD=`DismissableLayer`,kD=`dismissableLayer.update`,AD=`dismissableLayer.pointerDownOutside`,jD=`dismissableLayer.focusOutside`,MD,ND=I.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),PD=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(ND),[d,f]=I.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=I.useState({}),h=aD(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=g.indexOf(_),y=d?g.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,S=I.useRef(!1),C=RD(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=zD(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=DD(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&&(MD=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),BD(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=MD))}},[d,p,n,u]),I.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),BD())},[d,u]),I.useEffect(()=>{let e=()=>m({});return document.addEventListener(kD,e),()=>document.removeEventListener(kD,e)},[]),(0,L.jsx)(xD.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:nD(e.onFocusCapture,w.onFocusCapture),onBlurCapture:nD(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:nD(e.onPointerDownCapture,C.onPointerDownCapture)})});PD.displayName=OD;var FD=`DismissableLayerBranch`,ID=I.forwardRef((e,t)=>{let n=I.useContext(ND),r=I.useRef(null),i=aD(t,r);return I.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,L.jsx)(xD.div,{...e,ref:i})});ID.displayName=FD;function LD(){let e=I.useContext(ND),[t,n]=I.useState(null);return I.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}function RD(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a}=t,o=CD(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||VD(AD,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 zD(e,t=globalThis?.document){let n=CD(e),r=I.useRef(!1);return I.useEffect(()=>{let e=e=>{e.target&&!r.current&&VD(jD,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 BD(){let e=new CustomEvent(kD);document.dispatchEvent(e)}function VD(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?SD(i,a):i.dispatchEvent(a)}var HD=I.useId||(()=>void 0),UD=0;function WD(e){let[t,n]=I.useState(HD());return wD(()=>{e||n(e=>e??String(UD++))},[e]),e||(t?`radix-${t}`:``)}var GD=[`top`,`right`,`bottom`,`left`],KD=Math.min,qD=Math.max,JD=Math.round,YD=Math.floor,XD=e=>({x:e,y:e}),ZD={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function QD(e,t,n){return qD(e,KD(t,n))}function $D(e,t){return typeof e==`function`?e(t):e}function eO(e){return e.split(`-`)[0]}function tO(e){return e.split(`-`)[1]}function nO(e){return e===`x`?`y`:`x`}function rO(e){return e===`y`?`height`:`width`}function iO(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function aO(e){return nO(iO(e))}function oO(e,t,n){n===void 0&&(n=!1);let r=tO(e),i=aO(e),a=rO(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=hO(o)),[o,hO(o)]}function sO(e){let t=hO(e);return[cO(e),t,cO(t)]}function cO(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var lO=[`left`,`right`],uO=[`right`,`left`],dO=[`top`,`bottom`],fO=[`bottom`,`top`];function pO(e,t,n){switch(e){case`top`:case`bottom`:return n?t?uO:lO:t?lO:uO;case`left`:case`right`:return t?dO:fO;default:return[]}}function mO(e,t,n,r){let i=tO(e),a=pO(eO(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(cO)))),a}function hO(e){let t=eO(e);return ZD[t]+e.slice(t.length)}function gO(e){return{top:0,right:0,bottom:0,left:0,...e}}function _O(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:gO(e)}function vO(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 yO(e,t,n){let{reference:r,floating:i}=e,a=iO(t),o=aO(t),s=rO(o),c=eO(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(tO(t)){case`start`:p[o]-=f*(n&&l?-1:1);break;case`end`:p[o]+=f*(n&&l?-1:1);break}return p}async function bO(e,t){t===void 0&&(t={});let{x:n,y:r,platform:i,rects:a,elements:o,strategy:s}=e,{boundary:c=`clippingAncestors`,rootBoundary:l=`viewport`,elementContext:u=`floating`,altBoundary:d=!1,padding:f=0}=$D(t,e),p=_O(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=vO(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=vO(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 xO=50,SO=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:bO},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=yO(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<xO&&(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}=yO(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},CO=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}=$D(e,t)||{};if(l==null)return{};let d=_O(u),f={x:n,y:r},p=aO(i),m=rO(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=KD(d[_],T),D=KD(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=QD(O,A,k),M=!c.arrow&&tO(i)!=null&&A!==j&&a.reference[m]/2-(A<O?E:D)-h[m]/2<0,N=M?A<O?A-O:A-k:0;return{[p]:f[p]+N,data:{[p]:j,centerOffset:A-j-N,...M&&{alignmentOffset:N}},reset:M}}}),wO=function(e){return e===void 0&&(e={}),{name:`flip`,options:e,async fn(t){var n;let{placement:r,middlewareData:i,rects:a,initialPlacement:o,platform:s,elements:c}=t,{mainAxis:l=!0,crossAxis:u=!0,fallbackPlacements:d,fallbackStrategy:f=`bestFit`,fallbackAxisSideDirection:p=`none`,flipAlignment:m=!0,...h}=$D(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=eO(r),_=iO(o),v=eO(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[hO(o)]:sO(o)),x=p!==`none`;!d&&x&&b.push(...mO(o,m,p,y));let S=[o,...b],C=await s.detectOverflow(t,h),w=[],T=i.flip?.overflows||[];if(l&&w.push(C[g]),u){let e=oO(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`&&_!==iO(t))||T.every(e=>iO(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=iO(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 TO(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function EO(e){return GD.some(t=>e[t]>=0)}var DO=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=$D(e,t);switch(i){case`referenceHidden`:{let e=TO(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:EO(e)}}}case`escaped`:{let e=TO(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:EO(e)}}}default:return{}}}}},OO=new Set([`left`,`top`]);async function kO(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=eO(n),s=tO(n),c=iO(n)===`y`,l=OO.has(o)?-1:1,u=a&&c?-1:1,d=$D(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 AO=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 kO(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}}}}},jO=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}=$D(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=iO(eO(i)),p=nO(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=QD(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=QD(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}}}}}},MO=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}=$D(e,t),u={x:n,y:r},d=iO(i),f=nO(d),p=u[f],m=u[d],h=$D(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=OO.has(eO(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}}}},NO=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}=$D(e,t),u=await o.detectOverflow(t,l),d=eO(i),f=tO(i),p=iO(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=KD(h-u[g],v),x=KD(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=qD(u.left,0),t=qD(u.right,0),n=qD(u.top,0),r=qD(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:qD(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:qD(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 PO(){return typeof window<`u`}function FO(e){return RO(e)?(e.nodeName||``).toLowerCase():`#document`}function IO(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function LO(e){return((RO(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function RO(e){return PO()?e instanceof Node||e instanceof IO(e).Node:!1}function zO(e){return PO()?e instanceof Element||e instanceof IO(e).Element:!1}function BO(e){return PO()?e instanceof HTMLElement||e instanceof IO(e).HTMLElement:!1}function VO(e){return!PO()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof IO(e).ShadowRoot}function HO(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=$O(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function UO(e){return/^(table|td|th)$/.test(FO(e))}function WO(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var GO=/transform|translate|scale|rotate|perspective|filter/,KO=/paint|layout|strict|content/,qO=e=>!!e&&e!==`none`,JO;function YO(e){let t=zO(e)?$O(e):e;return qO(t.transform)||qO(t.translate)||qO(t.scale)||qO(t.rotate)||qO(t.perspective)||!ZO()&&(qO(t.backdropFilter)||qO(t.filter))||GO.test(t.willChange||``)||KO.test(t.contain||``)}function XO(e){let t=tk(e);for(;BO(t)&&!QO(t);){if(YO(t))return t;if(WO(t))return null;t=tk(t)}return null}function ZO(){return JO??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),JO}function QO(e){return/^(html|body|#document)$/.test(FO(e))}function $O(e){return IO(e).getComputedStyle(e)}function ek(e){return zO(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function tk(e){if(FO(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||VO(e)&&e.host||LO(e);return VO(t)?t.host:t}function nk(e){let t=tk(e);return QO(t)?e.ownerDocument?e.ownerDocument.body:e.body:BO(t)&&HO(t)?t:nk(t)}function rk(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=nk(e),i=r===e.ownerDocument?.body,a=IO(r);if(i){let e=ik(a);return t.concat(a,a.visualViewport||[],HO(r)?r:[],e&&n?rk(e):[])}else return t.concat(r,rk(r,[],n))}function ik(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function ak(e){let t=$O(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=BO(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=JD(n)!==a||JD(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function ok(e){return zO(e)?e:e.contextElement}function sk(e){let t=ok(e);if(!BO(t))return XD(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=ak(t),o=(a?JD(n.width):n.width)/r,s=(a?JD(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var ck=XD(0);function lk(e){let t=IO(e);return!ZO()||!t.visualViewport?ck:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function uk(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==IO(e)?!1:t}function dk(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=ok(e),o=XD(1);t&&(r?zO(r)&&(o=sk(r)):o=sk(e));let s=uk(a,n,r)?lk(a):XD(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=IO(a),t=r&&zO(r)?IO(r):r,n=e,i=ik(n);for(;i&&r&&t!==n;){let e=sk(i),t=i.getBoundingClientRect(),r=$O(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=IO(i),i=ik(n)}}return vO({width:u,height:d,x:c,y:l})}function fk(e,t){let n=ek(e).scrollLeft;return t?t.left+n:dk(LO(e)).left+n}function pk(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-fk(e,n),y:n.top+t.scrollTop}}function mk(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=LO(r),s=t?WO(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=XD(1),u=XD(0),d=BO(r);if((d||!d&&!a)&&((FO(r)!==`body`||HO(o))&&(c=ek(r)),d)){let e=dk(r);l=sk(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?pk(o,c):XD(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 hk(e){return Array.from(e.getClientRects())}function gk(e){let t=LO(e),n=ek(e),r=e.ownerDocument.body,i=qD(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=qD(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+fk(e),s=-n.scrollTop;return $O(r).direction===`rtl`&&(o+=qD(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var _k=25;function vk(e,t){let n=IO(e),r=LO(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=ZO();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=fk(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<=_k&&(a-=o)}else l<=_k&&(a+=l);return{width:a,height:o,x:s,y:c}}function yk(e,t){let n=dk(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=BO(e)?sk(e):XD(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function bk(e,t,n){let r;if(t===`viewport`)r=vk(e,n);else if(t===`document`)r=gk(LO(e));else if(zO(t))r=yk(t,n);else{let n=lk(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return vO(r)}function xk(e,t){let n=tk(e);return n===t||!zO(n)||QO(n)?!1:$O(n).position===`fixed`||xk(n,t)}function Sk(e,t){let n=t.get(e);if(n)return n;let r=rk(e,[],!1).filter(e=>zO(e)&&FO(e)!==`body`),i=null,a=$O(e).position===`fixed`,o=a?tk(e):e;for(;zO(o)&&!QO(o);){let t=$O(o),n=YO(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||HO(o)&&!n&&xk(e,o))?r=r.filter(e=>e!==o):i=t,o=tk(o)}return t.set(e,r),r}function Ck(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?WO(t)?[]:Sk(t,this._c):[].concat(n),r],o=bk(t,a[0],i),s=o.top,c=o.right,l=o.bottom,u=o.left;for(let e=1;e<a.length;e++){let n=bk(t,a[e],i);s=qD(n.top,s),c=KD(n.right,c),l=KD(n.bottom,l),u=qD(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function wk(e){let{width:t,height:n}=ak(e);return{width:t,height:n}}function Tk(e,t,n){let r=BO(t),i=LO(t),a=n===`fixed`,o=dk(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=XD(0);function l(){c.x=fk(i)}if(r||!r&&!a)if((FO(t)!==`body`||HO(i))&&(s=ek(t)),r){let e=dk(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?pk(i,s):XD(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 Ek(e){return $O(e).position===`static`}function Dk(e,t){if(!BO(e)||$O(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return LO(e)===n&&(n=n.ownerDocument.body),n}function Ok(e,t){let n=IO(e);if(WO(e))return n;if(!BO(e)){let t=tk(e);for(;t&&!QO(t);){if(zO(t)&&!Ek(t))return t;t=tk(t)}return n}let r=Dk(e,t);for(;r&&UO(r)&&Ek(r);)r=Dk(r,t);return r&&QO(r)&&Ek(r)&&!YO(r)?n:r||XO(e)||n}var kk=async function(e){let t=this.getOffsetParent||Ok,n=this.getDimensions,r=await n(e.floating);return{reference:Tk(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Ak(e){return $O(e).direction===`rtl`}var jk={convertOffsetParentRelativeRectToViewportRelativeRect:mk,getDocumentElement:LO,getClippingRect:Ck,getOffsetParent:Ok,getElementRects:kk,getClientRects:hk,getDimensions:wk,getScale:sk,isElement:zO,isRTL:Ak};function Mk(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Nk(e,t){let n=null,r,i=LO(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=YD(d),h=YD(i.clientWidth-(u+f)),g=YD(i.clientHeight-(d+p)),_=YD(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:qD(0,KD(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&&!Mk(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 Pk(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=ok(e),u=i||a?[...l?rk(l):[],...t?rk(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?Nk(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?dk(e):null;c&&g();function g(){let t=dk(e);h&&!Mk(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 Fk=AO,Ik=jO,Lk=wO,Rk=NO,zk=DO,Bk=CO,Vk=MO,Hk=(e,t,n)=>{let r=new Map,i={platform:jk,...n},a={...i.platform,_c:r};return SO(e,t,{...i,platform:a})},Uk=typeof document<`u`?I.useLayoutEffect:function(){};function Wk(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(!Wk(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)&&!Wk(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function Gk(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function Kk(e,t){let n=Gk(e);return Math.round(t*n)/n}function qk(e){let t=I.useRef(e);return Uk(()=>{t.current=e}),t}function Jk(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);Wk(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=qk(c),D=qk(i),O=qk(l),k=I.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),Hk(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!Wk(w.current,t)&&(w.current=t,ot.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);Uk(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=I.useRef(!1);Uk(()=>(A.current=!0,()=>{A.current=!1}),[]),Uk(()=>{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=Kk(M.floating,u.x),r=Kk(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...Gk(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 Yk=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?{}:Bk({element:r.current,padding:i}).fn(n):r?Bk({element:r,padding:i}).fn(n):{}}}},Xk=(e,t)=>{let n=Fk(e);return{name:n.name,fn:n.fn,options:[e,t]}},Zk=(e,t)=>{let n=Ik(e);return{name:n.name,fn:n.fn,options:[e,t]}},Qk=(e,t)=>({fn:Vk(e).fn,options:[e,t]}),$k=(e,t)=>{let n=Lk(e);return{name:n.name,fn:n.fn,options:[e,t]}},eA=(e,t)=>{let n=Rk(e);return{name:n.name,fn:n.fn,options:[e,t]}},tA=(e,t)=>{let n=zk(e);return{name:n.name,fn:n.fn,options:[e,t]}},nA=(e,t)=>{let n=Yk(e);return{name:n.name,fn:n.fn,options:[e,t]}},rA=`Arrow`,iA=I.forwardRef((e,t)=>{let{children:n,width:r=10,height:i=5,...a}=e;return(0,L.jsx)(xD.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`})})});iA.displayName=rA;var aA=iA;function oA(e){let[t,n]=I.useState(void 0);return wD(()=>{if(e){n({width:e.offsetWidth,height:e.offsetHeight});let t=new ResizeObserver(t=>{if(!Array.isArray(t)||!t.length)return;let r=t[0],i,a;if(`borderBoxSize`in r){let e=r.borderBoxSize,t=Array.isArray(e)?e[0]:e;i=t.inlineSize,a=t.blockSize}else i=e.offsetWidth,a=e.offsetHeight;n({width:i,height:a})});return t.observe(e,{box:`border-box`}),()=>t.unobserve(e)}else n(void 0)},[e]),t}var sA=`Popper`,[cA,lA]=oD(sA),[uA,dA]=cA(sA),fA=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null),[a,o]=I.useState(void 0);return(0,L.jsx)(uA,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};fA.displayName=sA;var pA=`PopperAnchor`,mA=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=dA(pA,n),o=I.useRef(null),s=a.onAnchorChange,c=aD(t,I.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=I.useRef(null);I.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&wA(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,L.jsx)(xD.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})});mA.displayName=pA;var hA=`PopperContent`,[gA,_A]=cA(hA),vA=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=dA(hA,n),[_,v]=I.useState(null),y=aD(t,v),[b,x]=I.useState(null),S=oA(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(SA),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=Jk({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>Pk(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[Xk({mainAxis:i+w,alignmentAxis:o}),c&&Zk({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Qk():void 0,...k}),c&&$k({...k}),eA({...k,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&nA({element:b,padding:s}),CA({arrowWidth:C,arrowHeight:w}),f&&tA({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ee=g.setPlacementState;wD(()=>(ee(M),()=>{ee(void 0)}),[M,ee]);let[F,te]=wA(M),ne=CD(m);wD(()=>{N&&ne?.()},[N,ne]);let re=P.arrow?.x,ie=P.arrow?.y,ae=P.arrow?.centerOffset!==0,[oe,se]=I.useState();return wD(()=>{_&&se(window.getComputedStyle(_).zIndex)},[_]),(0,L.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:N?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,L.jsx)(gA,{scope:n,placedSide:F,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,L.jsx)(xD.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});vA.displayName=hA;var yA=`PopperArrow`,bA={top:`bottom`,right:`left`,bottom:`top`,left:`right`},xA=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=_A(yA,n),a=bA[i.placedSide];return(0,L.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,L.jsx)(aA,{...r,ref:t,style:{...r.style,display:`block`}})})});xA.displayName=yA;function SA(e){return e!==null}var CA=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=wA(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function wA(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var TA=fA,EA=mA,DA=vA,OA=xA,kA=`Portal`,AA=I.forwardRef((e,t)=>{let{container:n,...r}=e,[i,a]=I.useState(!1);wD(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?ot.createPortal((0,L.jsx)(xD.div,{...r,ref:t}),o):null});AA.displayName=kA;function jA(e,t){return I.useReducer((e,n)=>t[e][n]??e,e)}var MA=e=>{let{present:t,children:n}=e,r=NA(t),i=typeof n==`function`?n({present:r.isPresent}):I.Children.only(n),a=FA(r.ref,LA(i));return typeof n==`function`||r.isPresent?I.cloneElement(i,{ref:a}):null};MA.displayName=`Presence`;function NA(e){let[t,n]=I.useState(),r=I.useRef(null),i=I.useRef(e),a=I.useRef(`none`),[o,s]=jA(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return I.useEffect(()=>{let e=IA(r.current);a.current=o===`mounted`?e:`none`},[o]),wD(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,o=IA(t);e?s(`MOUNT`):o===`none`||t?.display===`none`?s(`UNMOUNT`):s(n&&r!==o?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,s]),wD(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=IA(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=IA(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 PA(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function FA(...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=PA(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():PA(n[e],null)}}},[])}function IA(e){return e?.animationName||`none`}function LA(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 RA=I.useInsertionEffect||wD;function zA({prop:e,defaultProp:t,onChange:n=()=>{},caller:r}){let[i,a,o]=BA({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=VA(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}function BA({defaultProp:e,onChange:t}){let[n,r]=I.useState(e),i=I.useRef(n),a=I.useRef(t);return RA(()=>{a.current=t},[t]),I.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}function VA(e){return typeof e==`function`}var HA=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`}),UA=`VisuallyHidden`,WA=I.forwardRef((e,t)=>(0,L.jsx)(xD.span,{...e,ref:t,style:{...HA,...e.style}}));WA.displayName=UA;var GA=WA,[KA,qA]=oD(`Tooltip`,[lA]),JA=lA(),YA=`TooltipProvider`,XA=700,ZA=`tooltip.open`,[QA,$A]=KA(YA),ej=e=>{let{__scopeTooltip:t,delayDuration:n=XA,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)(QA,{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})};ej.displayName=YA;var tj=`Tooltip`,[nj,rj]=KA(tj),ij=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=$A(tj,e.__scopeTooltip),l=JA(t),[u,d]=I.useState(null),f=WD(),p=I.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=I.useRef(!1),[_,v]=zA({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(ZA))):c.onClose(),a?.(e)},caller:tj}),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)(TA,{...l,children:(0,L.jsx)(nj,{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})})};ij.displayName=tj;var aj=`TooltipTrigger`,oj=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=rj(aj,n),a=$A(aj,n),o=JA(n),s=aD(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)(EA,{asChild:!0,...o,children:(0,L.jsx)(xD.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:nD(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:nD(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:nD(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:nD(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:nD(e.onBlur,i.onClose),onClick:nD(e.onClick,i.onClose)})})});oj.displayName=aj;var sj=`TooltipPortal`,[cj,lj]=KA(sj,{forceMount:void 0}),uj=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=rj(sj,t);return(0,L.jsx)(cj,{scope:t,forceMount:n,children:(0,L.jsx)(MA,{present:n||a.open,children:(0,L.jsx)(AA,{asChild:!0,container:i,children:r})})})};uj.displayName=sj;var dj=`TooltipContent`,fj=I.forwardRef((e,t)=>{let n=lj(dj,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=rj(dj,e.__scopeTooltip);return(0,L.jsx)(MA,{present:r||o.open,children:o.disableHoverableContent?(0,L.jsx)(_j,{side:i,...a,ref:t}):(0,L.jsx)(pj,{side:i,...a,ref:t})})}),pj=I.forwardRef((e,t)=>{let n=rj(dj,e.__scopeTooltip),r=$A(dj,e.__scopeTooltip),i=I.useRef(null),a=aD(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=xj(r,bj(r,n.getBoundingClientRect())),a=Sj(t.getBoundingClientRect()),o=wj([...i,...a]);s(o),d(!0)},[d]);return I.useEffect(()=>()=>f(),[f]),I.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),I.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Cj(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,L.jsx)(_j,{...e,ref:a})}),[mj,hj]=KA(tj,{isInside:!1}),gj=uD(`TooltipContent`),_j=I.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=rj(dj,n),l=JA(n),{onClose:u}=c;return I.useEffect(()=>(document.addEventListener(ZA,u),()=>document.removeEventListener(ZA,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)(PD,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,L.jsxs)(DA,{"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)(gj,{children:r}),(0,L.jsx)(mj,{scope:n,isInside:!0,children:(0,L.jsx)(GA,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});fj.displayName=dj;var vj=`TooltipArrow`,yj=I.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=JA(n);return hj(vj,n).isInside?null:(0,L.jsx)(OA,{...i,...r,ref:t})});yj.displayName=vj;function bj(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function xj(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 Sj(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 Cj(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function wj(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Tj(t)}function Tj(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 Ej=ej,Dj=ij,Oj=oj,kj=uj,Aj=fj,jj=yj,Mj=`isolate bg-elevated opacity-100 border border-border shadow-2xl shadow-black/40`,Nj=`z-[110]`,Pj=`${Nj} ${Mj}`,Fj=`z-[250]`,Ij=`z-[250]`;function Lj({children:e}){return(0,L.jsx)(Ej,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!0,children:e})}function Rj({label:e,children:t,side:n=`top`,clickable:r=!1,multiline:i=!1,disabled:a=!1}){let o=i?`whitespace-pre-line`:`whitespace-normal`,[s,c]=(0,I.useState)(!1),l=(0,I.useId)(),u=r&&(0,I.isValidElement)(t)?t:null,d=u?(0,I.cloneElement)(u,{"aria-describedby":l}):t,f=(0,I.useRef)(null);if(u){let t=f.current?.getBoundingClientRect(),n=t?Math.min(Math.max(12,t.right+8),window.innerWidth-364):12,r=t?Math.min(Math.max(12,t.top-6),window.innerHeight-96):12;return(0,L.jsxs)(`span`,{ref:f,className:`inline-flex`,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onFocus:()=>c(!0),onBlur:()=>c(!1),onClick:()=>c(e=>!e),onKeyDown:e=>{e.key===`Escape`&&(e.stopPropagation(),c(!1))},children:[d,s&&(0,ot.createPortal)((0,L.jsx)(`span`,{id:l,role:`tooltip`,className:`z-[250] max-w-[min(22rem,calc(100vw-1.5rem))] rounded-md border border-border bg-elevated px-3 py-2 text-[11px] leading-relaxed text-fg shadow-md shadow-black/40 break-words ${o}`,style:{position:`fixed`,left:n,top:r},children:e}),document.body)]})}return(0,L.jsxs)(Dj,{open:s&&!a,onOpenChange:c,children:[(0,L.jsx)(Oj,{asChild:!0,children:d}),(0,L.jsx)(kj,{children:(0,L.jsxs)(Aj,{id:l,side:n,sideOffset:5,collisionPadding:12,className:`${Ij} 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)(jj,{className:`fill-elevated`})]})})]})}function zj({slug:e,size:t=14,className:n,label:r=`Open fullscreen`}){let i=Pd(e);function a(t){if(t.stopPropagation(),!Id(t))return;t.preventDefault();let n=!Mp(),r=t.currentTarget.closest(`[data-vt-chat]`);XE(r,e),typeof location<`u`&&$E(e,location.pathname),n&&r&&(r.style.viewTransitionName=`thread-chat`),nw(i,{viewTransition:n})}return(0,L.jsx)(Rj,{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)(Nm,{size:t})})})}function Bj(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 Vj(e,t,n=`AGENT`){if(!t.id||!Xc(t)||t.state===`running`&&!t.stoppable)return;let r=t.id;return()=>Bj(e,r,n)}function Hj(e){let t=e+`CollectionProvider`,[n,r]=oD(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=cD(s),l=I.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=aD(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=cD(u),p=I.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=I.useRef(null),s=aD(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 Uj=I.createContext(void 0);function Wj(e){let t=I.useContext(Uj);return e||t||`ltr`}var Gj=0,Kj=null;function qj(){I.useEffect(()=>{Kj||={start:Jj(),end:Jj()};let{start:e,end:t}=Kj;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),Gj++,()=>{Gj===1&&(Kj?.start.remove(),Kj?.end.remove(),Kj=null),Gj=Math.max(0,Gj-1)}},[])}function Jj(){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 Yj=`focusScope.autoFocusOnMount`,Xj=`focusScope.autoFocusOnUnmount`,Zj={bubbles:!1,cancelable:!0},Qj=`FocusScope`,$j=I.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=I.useState(null),l=CD(i),u=CD(a),d=I.useRef(null),f=aD(t,c),p=I.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;I.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:oM(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||oM(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&oM(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){sM.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Yj,Zj);s.addEventListener(Yj,l),s.dispatchEvent(t),t.defaultPrevented||(eM(uM(nM(s)),{select:!0}),document.activeElement===e&&oM(s))}return()=>{s.removeEventListener(Yj,l),setTimeout(()=>{let t=new CustomEvent(Xj,Zj);s.addEventListener(Xj,u),s.dispatchEvent(t),t.defaultPrevented||oM(e??document.body,{select:!0}),s.removeEventListener(Xj,u),sM.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]=tM(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&oM(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&oM(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,L.jsx)(xD.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});$j.displayName=Qj;function eM(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(oM(r,{select:t}),document.activeElement!==n)return}function tM(e){let t=nM(e);return[rM(t,e),rM(t.reverse(),e)]}function nM(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 rM(e,t){for(let n of e)if(!iM(n,{upTo:t}))return n}function iM(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 aM(e){return e instanceof HTMLInputElement&&`select`in e}function oM(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&aM(e)&&t&&e.select()}}var sM=cM();function cM(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=lM(e,t),e.unshift(t)},remove(t){e=lM(e,t),e[0]?.resume()}}}function lM(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function uM(e){return e.filter(e=>e.tagName!==`A`)}var dM=`rovingFocusGroup.onEntryFocus`,fM={bubbles:!1,cancelable:!0},pM=`RovingFocusGroup`,[mM,hM,gM]=Hj(pM),[_M,vM]=oD(pM,[gM]),[yM,bM]=_M(pM),xM=I.forwardRef((e,t)=>(0,L.jsx)(mM.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,L.jsx)(mM.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,L.jsx)(SM,{...e,ref:t})})}));xM.displayName=pM;var SM=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=aD(t,f),m=Wj(a),[h,g]=zA({prop:o,defaultProp:s??null,onChange:c,caller:pM}),[_,v]=I.useState(!1),y=CD(l),b=hM(n),x=I.useRef(!1),[S,C]=I.useState(0);return I.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(dM,y),()=>e.removeEventListener(dM,y)},[y]),(0,L.jsx)(yM,{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)(xD.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:nD(e.onMouseDown,()=>{x.current=!0}),onFocus:nD(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(dM,fM);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);OM([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:nD(e.onBlur,()=>v(!1))})})}),CM=`RovingFocusGroupItem`,wM=I.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=WD(),l=a||c,u=bM(CM,n),d=u.currentTabStopId===l,f=hM(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u;return I.useEffect(()=>{if(r)return p(),()=>m()},[r,p,m]),(0,L.jsx)(mM.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,L.jsx)(xD.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:nD(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:nD(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:nD(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=DM(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?kM(n,r+1):n.slice(r+1)}setTimeout(()=>OM(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})});wM.displayName=CM;var TM={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function EM(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function DM(e,t,n){let r=EM(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return TM[r]}function OM(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function kM(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var AM=xM,jM=wM,MM=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},NM=new WeakMap,PM=new WeakMap,FM={},IM=0,LM=function(e){return e&&(e.host||LM(e.parentNode))},RM=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=LM(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})},zM=function(e,t,n,r){var i=RM(t,Array.isArray(e)?e:[e]);FM[n]||(FM[n]=new WeakMap);var a=FM[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=(NM.get(e)||0)+1,l=(a.get(e)||0)+1;NM.set(e,c),a.set(e,l),o.push(e),c===1&&i&&PM.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(),IM++,function(){o.forEach(function(e){var t=NM.get(e)-1,i=a.get(e)-1;NM.set(e,t),a.set(e,i),t||(PM.has(e)||e.removeAttribute(r),PM.delete(e)),i||e.removeAttribute(n)}),IM--,IM||(NM=new WeakMap,NM=new WeakMap,PM=new WeakMap,FM={})}},BM=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||MM(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),zM(r,i,n,`aria-hidden`)):function(){return null}},VM=function(){return VM=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},VM.apply(this,arguments)};function HM(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 UM(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 WM=`right-scroll-bar-position`,GM=`width-before-scroll-bar`,KM=`with-scroll-bars-hidden`,qM=`--removed-body-scroll-bar-size`;function JM(e,t){return typeof e==`function`?e(t):e&&(e.current=t),e}function YM(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 XM=typeof window<`u`?I.useLayoutEffect:I.useEffect,ZM=new WeakMap;function QM(e,t){var n=YM(t||null,function(t){return e.forEach(function(e){return JM(e,t)})});return XM(function(){var t=ZM.get(n);if(t){var r=new Set(t),i=new Set(e),a=n.current;r.forEach(function(e){i.has(e)||JM(e,null)}),i.forEach(function(e){r.has(e)||JM(e,a)})}ZM.set(n,e)},[e]),n}function $M(e){return e}function eN(e,t){t===void 0&&(t=$M);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 tN(e){e===void 0&&(e={});var t=eN(null);return t.options=VM({async:!0,ssr:!1},e),t}var nN=function(e){var t=e.sideCar,n=HM(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,VM({},n))};nN.isSideCarExport=!0;function rN(e,t){return e.useMedium(t),nN}var iN=tN(),aN=function(){},oN=I.forwardRef(function(e,t){var n=I.useRef(null),r=I.useState({onScrollCapture:aN,onWheelCapture:aN,onTouchMoveCapture:aN}),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=HM(e,[`forwardProps`,`children`,`className`,`removeScrollBar`,`enabled`,`shards`,`sideCar`,`noRelative`,`noIsolation`,`inert`,`allowPinchZoom`,`as`,`gapMode`]),x=f,S=QM([n,t]),C=VM(VM({},b),i);return I.createElement(I.Fragment,null,u&&I.createElement(x,{sideCar:iN,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),VM(VM({},C),{ref:S})):I.createElement(v,VM({},C,{className:c,ref:S}),s))});oN.defaultProps={enabled:!0,removeScrollBar:!0,inert:!1},oN.classNames={fullWidth:GM,zeroRight:WM};var sN,cN=function(){if(sN)return sN;if(typeof __webpack_nonce__<`u`)return __webpack_nonce__};function lN(){if(!document)return null;var e=document.createElement(`style`);e.type=`text/css`;var t=cN();return t&&e.setAttribute(`nonce`,t),e}function uN(e,t){e.styleSheet?e.styleSheet.cssText=t:e.appendChild(document.createTextNode(t))}function dN(e){(document.head||document.getElementsByTagName(`head`)[0]).appendChild(e)}var fN=function(){var e=0,t=null;return{add:function(n){e==0&&(t=lN())&&(uN(t,n),dN(t)),e++},remove:function(){e--,!e&&t&&(t.parentNode&&t.parentNode.removeChild(t),t=null)}}},pN=function(){var e=fN();return function(t,n){I.useEffect(function(){return e.add(t),function(){e.remove()}},[t&&n])}},mN=function(){var e=pN();return function(t){var n=t.styles,r=t.dynamic;return e(n,r),null}},hN={left:0,top:0,right:0,gap:0},gN=function(e){return parseInt(e||``,10)||0},_N=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[gN(n),gN(r),gN(i)]},vN=function(e){if(e===void 0&&(e=`margin`),typeof window>`u`)return hN;var t=_N(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])}},yN=mN(),bN=`data-scroll-locked`,xN=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
+ .${KM} {
141
141
  overflow: hidden ${r};
142
142
  padding-right: ${s}px ${r};
143
143
  }
144
- body[${yN}] {
144
+ body[${bN}] {
145
145
  overflow: hidden ${r};
146
146
  overscroll-behavior: contain;
147
147
  ${[t&&`position: relative ${r};`,n===`margin`&&`
@@ -154,63 +154,63 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
154
154
  `,n===`padding`&&`padding-right: ${s}px ${r};`].filter(Boolean).join(``)}
155
155
  }
156
156
 
157
- .${UM} {
157
+ .${WM} {
158
158
  right: ${s}px ${r};
159
159
  }
160
160
 
161
- .${WM} {
161
+ .${GM} {
162
162
  margin-right: ${s}px ${r};
163
163
  }
164
164
 
165
- .${UM} .${UM} {
165
+ .${WM} .${WM} {
166
166
  right: 0 ${r};
167
167
  }
168
168
 
169
- .${WM} .${WM} {
169
+ .${GM} .${GM} {
170
170
  margin-right: 0 ${r};
171
171
  }
172
172
 
173
- body[${yN}] {
174
- ${KM}: ${s}px;
173
+ body[${bN}] {
174
+ ${qM}: ${s}px;
175
175
  }
176
- `},xN=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},SN=function(){I.useEffect(function(){return document.body.setAttribute(yN,(xN()+1).toString()),function(){var e=xN()-1;e<=0?document.body.removeAttribute(yN):document.body.setAttribute(yN,e.toString())}},[])},CN=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;SN();var a=I.useMemo(function(){return _N(i)},[i]);return I.createElement(vN,{styles:bN(a,!t,i,n?``:`!important`)})},wN=!1;if(typeof window<`u`)try{var TN=Object.defineProperty({},"passive",{get:function(){return wN=!0,!0}});window.addEventListener(`test`,TN,TN),window.removeEventListener(`test`,TN,TN)}catch{wN=!1}var EN=wN?{passive:!1}:!1,DN=function(e){return e.tagName===`TEXTAREA`},ON=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!DN(e)&&n[t]===`visible`)},kN=function(e){return ON(e,`overflowY`)},AN=function(e){return ON(e,`overflowX`)},jN=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),PN(e,r)){var i=FN(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},MN=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},NN=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},PN=function(e,t){return e===`v`?kN(t):AN(t)},FN=function(e,t){return e===`v`?MN(t):NN(t)},IN=function(e,t){return e===`h`&&t===`rtl`?-1:1},LN=function(e,t,n,r,i){var a=IN(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=FN(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&PN(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},RN=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},zN=function(e){return[e.deltaX,e.deltaY]},BN=function(e){return e&&`current`in e?e.current:e},VN=function(e,t){return e[0]===t[0]&&e[1]===t[1]},HN=function(e){return`
176
+ `},SN=function(){var e=parseInt(document.body.getAttribute(`data-scroll-locked`)||`0`,10);return isFinite(e)?e:0},CN=function(){I.useEffect(function(){return document.body.setAttribute(bN,(SN()+1).toString()),function(){var e=SN()-1;e<=0?document.body.removeAttribute(bN):document.body.setAttribute(bN,e.toString())}},[])},wN=function(e){var t=e.noRelative,n=e.noImportant,r=e.gapMode,i=r===void 0?`margin`:r;CN();var a=I.useMemo(function(){return vN(i)},[i]);return I.createElement(yN,{styles:xN(a,!t,i,n?``:`!important`)})},TN=!1;if(typeof window<`u`)try{var EN=Object.defineProperty({},"passive",{get:function(){return TN=!0,!0}});window.addEventListener(`test`,EN,EN),window.removeEventListener(`test`,EN,EN)}catch{TN=!1}var DN=TN?{passive:!1}:!1,ON=function(e){return e.tagName===`TEXTAREA`},kN=function(e,t){if(!(e instanceof Element))return!1;var n=window.getComputedStyle(e);return n[t]!==`hidden`&&!(n.overflowY===n.overflowX&&!ON(e)&&n[t]===`visible`)},AN=function(e){return kN(e,`overflowY`)},jN=function(e){return kN(e,`overflowX`)},MN=function(e,t){var n=t.ownerDocument,r=t;do{if(typeof ShadowRoot<`u`&&r instanceof ShadowRoot&&(r=r.host),FN(e,r)){var i=IN(e,r);if(i[1]>i[2])return!0}r=r.parentNode}while(r&&r!==n.body);return!1},NN=function(e){return[e.scrollTop,e.scrollHeight,e.clientHeight]},PN=function(e){return[e.scrollLeft,e.scrollWidth,e.clientWidth]},FN=function(e,t){return e===`v`?AN(t):jN(t)},IN=function(e,t){return e===`v`?NN(t):PN(t)},LN=function(e,t){return e===`h`&&t===`rtl`?-1:1},RN=function(e,t,n,r,i){var a=LN(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=IN(e,s),m=p[0],h=p[1]-p[2]-a*m;(m||h)&&FN(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},zN=function(e){return`changedTouches`in e?[e.changedTouches[0].clientX,e.changedTouches[0].clientY]:[0,0]},BN=function(e){return[e.deltaX,e.deltaY]},VN=function(e){return e&&`current`in e?e.current:e},HN=function(e,t){return e[0]===t[0]&&e[1]===t[1]},UN=function(e){return`
177
177
  .block-interactivity-${e} {pointer-events: none;}
178
178
  .allow-interactivity-${e} {pointer-events: all;}
179
- `},UN=0,WN=[];function GN(e){var t=I.useRef([]),n=I.useRef([0,0]),r=I.useRef(),i=I.useState(UN++)[0],a=I.useState(pN)[0],o=I.useRef(e);I.useEffect(function(){o.current=e},[e]),I.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=HM([e.lockRef.current],(e.shards||[]).map(BN),!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=RN(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=jN(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=jN(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 LN(h,t,e,h===`h`?s:c,!0)},[]),c=I.useCallback(function(e){var n=e;if(!(!WN.length||WN[WN.length-1]!==a)){var r=`deltaY`in n?zN(n):RN(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&VN(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(BN).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:KN(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=RN(e),r.current=void 0},[]),d=I.useCallback(function(t){l(t.type,zN(t),t.target,s(t,e.lockRef.current))},[]),f=I.useCallback(function(t){l(t.type,RN(t),t.target,s(t,e.lockRef.current))},[]);I.useEffect(function(){return WN.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,EN),document.addEventListener(`touchmove`,c,EN),document.addEventListener(`touchstart`,u,EN),function(){WN=WN.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,EN),document.removeEventListener(`touchmove`,c,EN),document.removeEventListener(`touchstart`,u,EN)}},[]);var p=e.removeScrollBar,m=e.inert;return I.createElement(I.Fragment,null,m?I.createElement(a,{styles:HN(i)}):null,p?I.createElement(CN,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function KN(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var qN=nN(rN,GN),JN=I.forwardRef(function(e,t){return I.createElement(aN,BM({},e,{ref:t,sideCar:qN}))});JN.classNames=aN.classNames;var YN=[`Enter`,` `],XN=[`ArrowDown`,`PageUp`,`Home`],ZN=[`ArrowUp`,`PageDown`,`End`],QN=[...XN,...ZN],$N={ltr:[...YN,`ArrowRight`],rtl:[...YN,`ArrowLeft`]},eP={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},tP=`Menu`,[nP,rP,iP]=Vj(tP),[aP,oP]=aD(tP,[iP,cA,_M]),sP=cA(),cP=_M(),[lP,uP]=aP(tP),[dP,fP]=aP(tP),pP=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=sP(t),[c,l]=I.useState(null),u=I.useRef(!1),d=SD(a),f=Uj(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)(wA,{...s,children:(0,L.jsx)(lP,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,L.jsx)(dP,{scope:t,onClose:I.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};pP.displayName=tP;var mP=`MenuAnchor`,hP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=sP(n);return(0,L.jsx)(TA,{...i,...r,ref:t})});hP.displayName=mP;var gP=`MenuPortal`,[_P,vP]=aP(gP,{forceMount:void 0}),yP=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=uP(gP,t);return(0,L.jsx)(_P,{scope:t,forceMount:n,children:(0,L.jsx)(jA,{present:n||a.open,children:(0,L.jsx)(kA,{asChild:!0,container:i,children:r})})})};yP.displayName=gP;var bP=`MenuContent`,[xP,SP]=aP(bP),CP=I.forwardRef((e,t)=>{let n=vP(bP,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=uP(bP,e.__scopeMenu),o=fP(bP,e.__scopeMenu);return(0,L.jsx)(nP.Provider,{scope:e.__scopeMenu,children:(0,L.jsx)(jA,{present:r||a.open,children:(0,L.jsx)(nP.Slot,{scope:e.__scopeMenu,children:o.modal?(0,L.jsx)(wP,{...i,ref:t}):(0,L.jsx)(TP,{...i,ref:t})})})})}),wP=I.forwardRef((e,t)=>{let n=uP(bP,e.__scopeMenu),r=I.useRef(null),i=iD(t,r);return I.useEffect(()=>{let e=r.current;if(e)return zM(e)},[]),(0,L.jsx)(DP,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:tD(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),TP=I.forwardRef((e,t)=>{let n=uP(bP,e.__scopeMenu);return(0,L.jsx)(DP,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),EP=sD(`MenuContent.ScrollLock`),DP=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=uP(bP,n),_=fP(bP,n),v=sP(n),y=cP(n),b=rP(n),[x,S]=I.useState(null),C=I.useRef(null),w=iD(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?JN:I.Fragment,M=m?{as:EP,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=dF(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),[]),Kj();let P=I.useCallback(e=>k.current===O.current?.side&&pF(e,O.current?.area),[]);return(0,L.jsx)(xP,{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)(Qj,{asChild:!0,trapped:i,onMountAutoFocus:tD(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,L.jsx)(ND,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,L.jsx)(kM,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:tD(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,L.jsx)(EA,{role:`menu`,"aria-orientation":`vertical`,"data-state":oF(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:tD(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||!QN.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);ZN.includes(e.key)&&a.reverse(),lF(a)}),onBlur:tD(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:tD(e.onPointerMove,mF(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}}))})})})})})})});CP.displayName=bP;var OP=`MenuGroup`,kP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(bD.div,{role:`group`,...r,ref:t})});kP.displayName=OP;var AP=`MenuLabel`,jP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(bD.div,{...r,ref:t})});jP.displayName=AP;var MP=`MenuItem`,NP=`menu.itemSelect`,PP=I.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=I.useRef(null),o=fP(MP,e.__scopeMenu),s=SP(MP,e.__scopeMenu),c=iD(t,a),l=I.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(NP,{bubbles:!0,cancelable:!0});e.addEventListener(NP,e=>r?.(e),{once:!0}),xD(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,L.jsx)(FP,{...i,ref:c,disabled:n,onClick:tD(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:tD(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:tD(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||YN.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});PP.displayName=MP;var FP=I.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=SP(MP,n),s=cP(n),c=I.useRef(null),l=iD(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)(nP.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,L.jsx)(AM,{asChild:!0,...s,focusable:!r,children:(0,L.jsx)(bD.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:tD(e.onPointerMove,mF(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:tD(e.onPointerLeave,mF(e=>o.onItemLeave(e))),onFocus:tD(e.onFocus,()=>d(!0)),onBlur:tD(e.onBlur,()=>d(!1))})})})}),IP=`MenuCheckboxItem`,LP=I.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,L.jsx)(GP,{scope:e.__scopeMenu,checked:n,children:(0,L.jsx)(PP,{role:`menuitemcheckbox`,"aria-checked":sF(n)?`mixed`:n,...i,ref:t,"data-state":cF(n),onSelect:tD(i.onSelect,()=>r?.(sF(n)?!0:!n),{checkForDefaultPrevented:!1})})})});LP.displayName=IP;var RP=`MenuRadioGroup`,[zP,BP]=aP(RP,{value:void 0,onValueChange:()=>{}}),VP=I.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=SD(r);return(0,L.jsx)(zP,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,L.jsx)(kP,{...i,ref:t})})});VP.displayName=RP;var HP=`MenuRadioItem`,UP=I.forwardRef((e,t)=>{let{value:n,...r}=e,i=BP(HP,e.__scopeMenu),a=n===i.value;return(0,L.jsx)(GP,{scope:e.__scopeMenu,checked:a,children:(0,L.jsx)(PP,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":cF(a),onSelect:tD(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});UP.displayName=HP;var WP=`MenuItemIndicator`,[GP,KP]=aP(WP,{checked:!1}),qP=I.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=KP(WP,n);return(0,L.jsx)(jA,{present:r||sF(a.checked)||a.checked===!0,children:(0,L.jsx)(bD.span,{...i,ref:t,"data-state":cF(a.checked)})})});qP.displayName=WP;var JP=`MenuSeparator`,YP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(bD.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});YP.displayName=JP;var XP=`MenuArrow`,ZP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=sP(n);return(0,L.jsx)(DA,{...i,...r,ref:t})});ZP.displayName=XP;var QP=`MenuSub`,[$P,eF]=aP(QP),tF=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=uP(QP,t),o=sP(t),[s,c]=I.useState(null),[l,u]=I.useState(null),d=SD(i);return I.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,L.jsx)(wA,{...o,children:(0,L.jsx)(lP,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,L.jsx)($P,{scope:t,contentId:UD(),triggerId:UD(),trigger:s,onTriggerChange:c,children:n})})})};tF.displayName=QP;var nF=`MenuSubTrigger`,rF=I.forwardRef((e,t)=>{let n=uP(nF,e.__scopeMenu),r=fP(nF,e.__scopeMenu),i=eF(nF,e.__scopeMenu),a=SP(nF,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=iD(t,i.onTriggerChange);return(0,L.jsx)(hP,{asChild:!0,...l,children:(0,L.jsx)(FP,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":oF(n.open),...e,ref:d,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:tD(e.onPointerMove,mF(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:tD(e.onPointerLeave,mF(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:tD(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||$N[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});rF.displayName=nF;var iF=`MenuSubContent`,aF=I.forwardRef((e,t)=>{let n=vP(bP,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=uP(bP,e.__scopeMenu),s=fP(bP,e.__scopeMenu),c=eF(iF,e.__scopeMenu),l=I.useRef(null),u=iD(t,l);return(0,L.jsx)(nP.Provider,{scope:e.__scopeMenu,children:(0,L.jsx)(jA,{present:r||o.open,children:(0,L.jsx)(nP.Slot,{scope:e.__scopeMenu,children:(0,L.jsx)(DP,{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:tD(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:tD(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:tD(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=eP[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})});aF.displayName=iF;function oF(e){return e?`open`:`closed`}function sF(e){return e===`indeterminate`}function cF(e){return sF(e)?`indeterminate`:e?`checked`:`unchecked`}function lF(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function uF(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function dF(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=uF(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 fF(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function pF(e,t){return t?fF({x:e.clientX,y:e.clientY},t):!1}function mF(e){return t=>t.pointerType===`mouse`?e(t):void 0}var hF=pP,gF=hP,_F=yP,vF=CP,yF=kP,bF=jP,xF=PP,SF=LP,CF=VP,wF=UP,TF=qP,EF=YP,DF=ZP,OF=rF,kF=aF,AF=`DropdownMenu`,[jF,MF]=aD(AF,[oP]),NF=oP(),[PF,FF]=jF(AF),IF=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=NF(t),l=I.useRef(null),[u,d]=RA({prop:i,defaultProp:a??!1,onChange:o,caller:AF});return(0,L.jsx)(PF,{scope:t,triggerId:UD(),triggerRef:l,contentId:UD(),open:u,onOpenChange:d,onOpenToggle:I.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,L.jsx)(hF,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};IF.displayName=AF;var LF=`DropdownMenuTrigger`,RF=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=FF(LF,n),o=NF(n),s=iD(t,a.triggerRef);return(0,L.jsx)(gF,{asChild:!0,...o,children:(0,L.jsx)(bD.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:tD(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:tD(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});RF.displayName=LF;var zF=`DropdownMenuPortal`,BF=e=>{let{__scopeDropdownMenu:t,...n}=e,r=NF(t);return(0,L.jsx)(_F,{...r,...n})};BF.displayName=zF;var VF=`DropdownMenuContent`,HF=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=FF(VF,n),a=NF(n),o=I.useRef(!1);return(0,L.jsx)(vF,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:tD(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:tD(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)`}})});HF.displayName=VF;var UF=`DropdownMenuGroup`,WF=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=NF(n);return(0,L.jsx)(yF,{...i,...r,ref:t})});WF.displayName=UF;var GF=`DropdownMenuLabel`,KF=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=NF(n);return(0,L.jsx)(bF,{...i,...r,ref:t})});KF.displayName=GF;var qF=`DropdownMenuItem`,JF=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=NF(n);return(0,L.jsx)(xF,{...i,...r,ref:t})});JF.displayName=qF;var YF=`DropdownMenuCheckboxItem`,XF=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=NF(n);return(0,L.jsx)(SF,{...i,...r,ref:t})});XF.displayName=YF;var ZF=`DropdownMenuRadioGroup`,QF=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=NF(n);return(0,L.jsx)(CF,{...i,...r,ref:t})});QF.displayName=ZF;var $F=`DropdownMenuRadioItem`,eI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=NF(n);return(0,L.jsx)(wF,{...i,...r,ref:t})});eI.displayName=$F;var tI=`DropdownMenuItemIndicator`,nI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=NF(n);return(0,L.jsx)(TF,{...i,...r,ref:t})});nI.displayName=tI;var rI=`DropdownMenuSeparator`,iI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=NF(n);return(0,L.jsx)(EF,{...i,...r,ref:t})});iI.displayName=rI;var aI=`DropdownMenuArrow`,oI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=NF(n);return(0,L.jsx)(DF,{...i,...r,ref:t})});oI.displayName=aI;var sI=`DropdownMenuSubTrigger`,cI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=NF(n);return(0,L.jsx)(OF,{...i,...r,ref:t})});cI.displayName=sI;var lI=`DropdownMenuSubContent`,uI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=NF(n);return(0,L.jsx)(kF,{...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)`}})});uI.displayName=lI;var dI=IF,fI=RF,pI=BF,mI=HF,hI=WF,gI=KF,_I=JF,vI=QF,yI=eI,bI=nI,xI=iI;function SI({modal:e=!1,...t}){return(0,L.jsx)(dI,{modal:e,...t})}var CI=fI;function wI({children:e,align:t=`end`,sideOffset:n=6}){return(0,L.jsx)(pI,{children:(0,L.jsx)(mI,{align:t,sideOffset:n,className:`${Nj} min-w-[184px] overflow-hidden rounded-lg p-1`,children:e})})}function TI({children:e,onSelect:t,icon:n,danger:r}){return(0,L.jsxs)(_I,{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 EI(){return(0,L.jsx)(xI,{className:`my-1 h-px bg-border`})}var DI=(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)(Mm,{size:p?11:12,className:`animate-spin`}),`Mark as `,s]}),(0,L.jsxs)(SI,{children:[(0,L.jsx)(CI,{"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)($p,{size:p?11:12})}),(0,L.jsx)(wI,{children:rT.map(e=>(0,L.jsxs)(TI,{onSelect:()=>c(e),children:[`Mark as `,e]},e))})]})]})}),OI=`Dialog`,[kI,AI]=aD(OI),[jI,MI]=kI(OI),NI=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]=RA({prop:r,defaultProp:i??!1,onChange:a,caller:OI});return(0,L.jsx)(jI,{scope:t,triggerRef:s,contentRef:c,contentId:UD(),titleId:UD(),descriptionId:UD(),open:l,onOpenChange:u,onOpenToggle:I.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};NI.displayName=OI;var PI=`DialogTrigger`,FI=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=MI(PI,n),a=iD(t,i.triggerRef);return(0,L.jsx)(bD.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":tL(i.open),...r,ref:a,onClick:tD(e.onClick,i.onOpenToggle)})});FI.displayName=PI;var II=`DialogPortal`,[LI,RI]=kI(II,{forceMount:void 0}),zI=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=MI(II,t);return(0,L.jsx)(LI,{scope:t,forceMount:n,children:I.Children.map(r,e=>(0,L.jsx)(jA,{present:n||a.open,children:(0,L.jsx)(kA,{asChild:!0,container:i,children:e})}))})};zI.displayName=II;var BI=`DialogOverlay`,VI=I.forwardRef((e,t)=>{let n=RI(BI,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=MI(BI,e.__scopeDialog);return a.modal?(0,L.jsx)(jA,{present:r||a.open,children:(0,L.jsx)(UI,{...i,ref:t})}):null});VI.displayName=BI;var HI=sD(`DialogOverlay.RemoveScroll`),UI=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=MI(BI,n),a=iD(t,ID());return(0,L.jsx)(JN,{as:HI,allowPinchZoom:!0,shards:[i.contentRef],children:(0,L.jsx)(bD.div,{"data-state":tL(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})}),WI=`DialogContent`,GI=I.forwardRef((e,t)=>{let n=RI(WI,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=MI(WI,e.__scopeDialog);return(0,L.jsx)(jA,{present:r||a.open,children:a.modal?(0,L.jsx)(KI,{...i,ref:t}):(0,L.jsx)(qI,{...i,ref:t})})});GI.displayName=WI;var KI=I.forwardRef((e,t)=>{let n=MI(WI,e.__scopeDialog),r=I.useRef(null),i=iD(t,n.contentRef,r);return I.useEffect(()=>{let e=r.current;if(e)return zM(e)},[]),(0,L.jsx)(JI,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:tD(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:tD(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:tD(e.onFocusOutside,e=>e.preventDefault())})}),qI=I.forwardRef((e,t)=>{let n=MI(WI,e.__scopeDialog),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(JI,{...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()}})}),JI=I.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=MI(WI,n);return Kj(),(0,L.jsx)(L.Fragment,{children:(0,L.jsx)(Qj,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(ND,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":tL(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),YI=`DialogTitle`,XI=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=MI(YI,n);return(0,L.jsx)(bD.h2,{id:i.titleId,...r,ref:t})});XI.displayName=YI;var ZI=`DialogDescription`,QI=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=MI(ZI,n);return(0,L.jsx)(bD.p,{id:i.descriptionId,...r,ref:t})});QI.displayName=ZI;var $I=`DialogClose`,eL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=MI($I,n);return(0,L.jsx)(bD.button,{type:`button`,...r,ref:t,onClick:tD(e.onClick,()=>i.onOpenChange(!1))})});eL.displayName=$I;function tL(e){return e?`open`:`closed`}var nL=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`]),rL=/[a-zA-Z_][a-zA-Z0-9_-]*/y,iL=/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/;function aL(e){let t={},n=0;for(;n<e.length;){for(;/\s/.test(e[n]??``);)n++;if(n>=e.length)break;rL.lastIndex=n;let r=rL.exec(e);if(!r||Object.hasOwn(t,r[0]))return null;let i=r[0];if(n=rL.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(iL.test(a))t[i]=Number(a);else return null}if(n<e.length&&!/\s/.test(e[n]))return null}return t}function oL(e){let t=e.match(/^\s*::([a-z][a-z0-9-]*)\{([^\n]*)\}\s*$/);if(!t||!nL.has(t[1]))return null;let n=aL(t[2]);return n?{name:t[1],attrs:n}:null}var sL=String.raw`(?:[^\s\`]|[ ](?!/))+`,cL=new RegExp(String.raw`^\s*\`?(/${sL}\.(?:png|jpe?g|gif|webp))\`?\s*$`,`i`),lL=new RegExp(String.raw`^\s*\`?(/${sL}\.(?:${Ic.join(`|`)}))\`?\s*$`,`i`),uL=/^\s{0,3}(?:```|~~~)/,dL=/^\s{0,3}(`{3,}|~{3,})\s*mermaid\s*$/i,fL=/^\s*::codex-inline-vis\{file="([a-z0-9][a-z0-9-]{0,127}\.html)"\}\s*$/;function pL(e){let t=e.split(`
179
+ `},WN=0,GN=[];function KN(e){var t=I.useRef([]),n=I.useRef([0,0]),r=I.useRef(),i=I.useState(WN++)[0],a=I.useState(mN)[0],o=I.useRef(e);I.useEffect(function(){o.current=e},[e]),I.useEffect(function(){if(e.inert){document.body.classList.add(`block-interactivity-${i}`);var t=UM([e.lockRef.current],(e.shards||[]).map(VN),!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=zN(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=MN(d,u);if(!m)return!0;if(m?l=d:(l=d===`v`?`h`:`v`,m=MN(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 RN(h,t,e,h===`h`?s:c,!0)},[]),c=I.useCallback(function(e){var n=e;if(!(!GN.length||GN[GN.length-1]!==a)){var r=`deltaY`in n?BN(n):zN(n),i=t.current.filter(function(e){return e.name===n.type&&(e.target===n.target||n.target===e.shadowParent)&&HN(e.delta,r)})[0];if(i&&i.should){n.cancelable&&n.preventDefault();return}if(!i){var c=(o.current.shards||[]).map(VN).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:qN(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=zN(e),r.current=void 0},[]),d=I.useCallback(function(t){l(t.type,BN(t),t.target,s(t,e.lockRef.current))},[]),f=I.useCallback(function(t){l(t.type,zN(t),t.target,s(t,e.lockRef.current))},[]);I.useEffect(function(){return GN.push(a),e.setCallbacks({onScrollCapture:d,onWheelCapture:d,onTouchMoveCapture:f}),document.addEventListener(`wheel`,c,DN),document.addEventListener(`touchmove`,c,DN),document.addEventListener(`touchstart`,u,DN),function(){GN=GN.filter(function(e){return e!==a}),document.removeEventListener(`wheel`,c,DN),document.removeEventListener(`touchmove`,c,DN),document.removeEventListener(`touchstart`,u,DN)}},[]);var p=e.removeScrollBar,m=e.inert;return I.createElement(I.Fragment,null,m?I.createElement(a,{styles:UN(i)}):null,p?I.createElement(wN,{noRelative:e.noRelative,gapMode:e.gapMode}):null)}function qN(e){for(var t=null;e!==null;)e instanceof ShadowRoot&&(t=e.host,e=e.host),e=e.parentNode;return t}var JN=rN(iN,KN),YN=I.forwardRef(function(e,t){return I.createElement(oN,VM({},e,{ref:t,sideCar:JN}))});YN.classNames=oN.classNames;var XN=[`Enter`,` `],ZN=[`ArrowDown`,`PageUp`,`Home`],QN=[`ArrowUp`,`PageDown`,`End`],$N=[...ZN,...QN],eP={ltr:[...XN,`ArrowRight`],rtl:[...XN,`ArrowLeft`]},tP={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},nP=`Menu`,[rP,iP,aP]=Hj(nP),[oP,sP]=oD(nP,[aP,lA,vM]),cP=lA(),lP=vM(),[uP,dP]=oP(nP),[fP,pP]=oP(nP),mP=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=cP(t),[c,l]=I.useState(null),u=I.useRef(!1),d=CD(a),f=Wj(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)(TA,{...s,children:(0,L.jsx)(uP,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,L.jsx)(fP,{scope:t,onClose:I.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};mP.displayName=nP;var hP=`MenuAnchor`,gP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=cP(n);return(0,L.jsx)(EA,{...i,...r,ref:t})});gP.displayName=hP;var _P=`MenuPortal`,[vP,yP]=oP(_P,{forceMount:void 0}),bP=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=dP(_P,t);return(0,L.jsx)(vP,{scope:t,forceMount:n,children:(0,L.jsx)(MA,{present:n||a.open,children:(0,L.jsx)(AA,{asChild:!0,container:i,children:r})})})};bP.displayName=_P;var xP=`MenuContent`,[SP,CP]=oP(xP),wP=I.forwardRef((e,t)=>{let n=yP(xP,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=dP(xP,e.__scopeMenu),o=pP(xP,e.__scopeMenu);return(0,L.jsx)(rP.Provider,{scope:e.__scopeMenu,children:(0,L.jsx)(MA,{present:r||a.open,children:(0,L.jsx)(rP.Slot,{scope:e.__scopeMenu,children:o.modal?(0,L.jsx)(TP,{...i,ref:t}):(0,L.jsx)(EP,{...i,ref:t})})})})}),TP=I.forwardRef((e,t)=>{let n=dP(xP,e.__scopeMenu),r=I.useRef(null),i=aD(t,r);return I.useEffect(()=>{let e=r.current;if(e)return BM(e)},[]),(0,L.jsx)(OP,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:nD(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),EP=I.forwardRef((e,t)=>{let n=dP(xP,e.__scopeMenu);return(0,L.jsx)(OP,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),DP=cD(`MenuContent.ScrollLock`),OP=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=dP(xP,n),_=pP(xP,n),v=cP(n),y=lP(n),b=iP(n),[x,S]=I.useState(null),C=I.useRef(null),w=aD(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?YN:I.Fragment,M=m?{as:DP,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=fF(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),[]),qj();let P=I.useCallback(e=>k.current===O.current?.side&&mF(e,O.current?.area),[]);return(0,L.jsx)(SP,{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)($j,{asChild:!0,trapped:i,onMountAutoFocus:nD(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,L.jsx)(PD,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,L.jsx)(AM,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:nD(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,L.jsx)(DA,{role:`menu`,"aria-orientation":`vertical`,"data-state":sF(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:nD(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||!$N.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);QN.includes(e.key)&&a.reverse(),uF(a)}),onBlur:nD(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:nD(e.onPointerMove,hF(e=>{let t=e.target,n=A.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>A.current?`right`:`left`;k.current=t,A.current=e.clientX}}))})})})})})})});wP.displayName=xP;var kP=`MenuGroup`,AP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(xD.div,{role:`group`,...r,ref:t})});AP.displayName=kP;var jP=`MenuLabel`,MP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(xD.div,{...r,ref:t})});MP.displayName=jP;var NP=`MenuItem`,PP=`menu.itemSelect`,FP=I.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=I.useRef(null),o=pP(NP,e.__scopeMenu),s=CP(NP,e.__scopeMenu),c=aD(t,a),l=I.useRef(!1),u=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(PP,{bubbles:!0,cancelable:!0});e.addEventListener(PP,e=>r?.(e),{once:!0}),SD(e,t),t.defaultPrevented?l.current=!1:o.onClose()}};return(0,L.jsx)(IP,{...i,ref:c,disabled:n,onClick:nD(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:nD(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:nD(e.onKeyDown,e=>{let t=s.searchRef.current!==``;n||t&&e.key===` `||XN.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});FP.displayName=NP;var IP=I.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=CP(NP,n),s=lP(n),c=I.useRef(null),l=aD(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)(rP.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,L.jsx)(jM,{asChild:!0,...s,focusable:!r,children:(0,L.jsx)(xD.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:nD(e.onPointerMove,hF(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:nD(e.onPointerLeave,hF(e=>o.onItemLeave(e))),onFocus:nD(e.onFocus,()=>d(!0)),onBlur:nD(e.onBlur,()=>d(!1))})})})}),LP=`MenuCheckboxItem`,RP=I.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,L.jsx)(KP,{scope:e.__scopeMenu,checked:n,children:(0,L.jsx)(FP,{role:`menuitemcheckbox`,"aria-checked":cF(n)?`mixed`:n,...i,ref:t,"data-state":lF(n),onSelect:nD(i.onSelect,()=>r?.(cF(n)?!0:!n),{checkForDefaultPrevented:!1})})})});RP.displayName=LP;var zP=`MenuRadioGroup`,[BP,VP]=oP(zP,{value:void 0,onValueChange:()=>{}}),HP=I.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=CD(r);return(0,L.jsx)(BP,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,L.jsx)(AP,{...i,ref:t})})});HP.displayName=zP;var UP=`MenuRadioItem`,WP=I.forwardRef((e,t)=>{let{value:n,...r}=e,i=VP(UP,e.__scopeMenu),a=n===i.value;return(0,L.jsx)(KP,{scope:e.__scopeMenu,checked:a,children:(0,L.jsx)(FP,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":lF(a),onSelect:nD(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});WP.displayName=UP;var GP=`MenuItemIndicator`,[KP,qP]=oP(GP,{checked:!1}),JP=I.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,a=qP(GP,n);return(0,L.jsx)(MA,{present:r||cF(a.checked)||a.checked===!0,children:(0,L.jsx)(xD.span,{...i,ref:t,"data-state":lF(a.checked)})})});JP.displayName=GP;var YP=`MenuSeparator`,XP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,L.jsx)(xD.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});XP.displayName=YP;var ZP=`MenuArrow`,QP=I.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=cP(n);return(0,L.jsx)(OA,{...i,...r,ref:t})});QP.displayName=ZP;var $P=`MenuSub`,[eF,tF]=oP($P),nF=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=dP($P,t),o=cP(t),[s,c]=I.useState(null),[l,u]=I.useState(null),d=CD(i);return I.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,L.jsx)(TA,{...o,children:(0,L.jsx)(uP,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,L.jsx)(eF,{scope:t,contentId:WD(),triggerId:WD(),trigger:s,onTriggerChange:c,children:n})})})};nF.displayName=$P;var rF=`MenuSubTrigger`,iF=I.forwardRef((e,t)=>{let n=dP(rF,e.__scopeMenu),r=pP(rF,e.__scopeMenu),i=tF(rF,e.__scopeMenu),a=CP(rF,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=aD(t,i.onTriggerChange);return(0,L.jsx)(gP,{asChild:!0,...l,children:(0,L.jsx)(IP,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":sF(n.open),...e,ref:d,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:nD(e.onPointerMove,hF(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:nD(e.onPointerLeave,hF(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:nD(e.onKeyDown,t=>{let i=a.searchRef.current!==``;e.disabled||i&&t.key===` `||eP[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});iF.displayName=rF;var aF=`MenuSubContent`,oF=I.forwardRef((e,t)=>{let n=yP(xP,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=dP(xP,e.__scopeMenu),s=pP(xP,e.__scopeMenu),c=tF(aF,e.__scopeMenu),l=I.useRef(null),u=aD(t,l);return(0,L.jsx)(rP.Provider,{scope:e.__scopeMenu,children:(0,L.jsx)(MA,{present:r||o.open,children:(0,L.jsx)(rP.Slot,{scope:e.__scopeMenu,children:(0,L.jsx)(OP,{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:nD(e.onFocusOutside,e=>{e.target!==c.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:nD(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:nD(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=tP[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),c.trigger?.focus(),e.preventDefault())})})})})})});oF.displayName=aF;function sF(e){return e?`open`:`closed`}function cF(e){return e===`indeterminate`}function lF(e){return cF(e)?`indeterminate`:e?`checked`:`unchecked`}function uF(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function dF(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function fF(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=dF(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 pF(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function mF(e,t){return t?pF({x:e.clientX,y:e.clientY},t):!1}function hF(e){return t=>t.pointerType===`mouse`?e(t):void 0}var gF=mP,_F=gP,vF=bP,yF=wP,bF=AP,xF=MP,SF=FP,CF=RP,wF=HP,TF=WP,EF=JP,DF=XP,OF=QP,kF=iF,AF=oF,jF=`DropdownMenu`,[MF,NF]=oD(jF,[sP]),PF=sP(),[FF,IF]=MF(jF),LF=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=PF(t),l=I.useRef(null),[u,d]=zA({prop:i,defaultProp:a??!1,onChange:o,caller:jF});return(0,L.jsx)(FF,{scope:t,triggerId:WD(),triggerRef:l,contentId:WD(),open:u,onOpenChange:d,onOpenToggle:I.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,L.jsx)(gF,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})};LF.displayName=jF;var RF=`DropdownMenuTrigger`,zF=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=IF(RF,n),o=PF(n),s=aD(t,a.triggerRef);return(0,L.jsx)(_F,{asChild:!0,...o,children:(0,L.jsx)(xD.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:nD(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:nD(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});zF.displayName=RF;var BF=`DropdownMenuPortal`,VF=e=>{let{__scopeDropdownMenu:t,...n}=e,r=PF(t);return(0,L.jsx)(vF,{...r,...n})};VF.displayName=BF;var HF=`DropdownMenuContent`,UF=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=IF(HF,n),a=PF(n),o=I.useRef(!1);return(0,L.jsx)(yF,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:nD(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:nD(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)`}})});UF.displayName=HF;var WF=`DropdownMenuGroup`,GF=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=PF(n);return(0,L.jsx)(bF,{...i,...r,ref:t})});GF.displayName=WF;var KF=`DropdownMenuLabel`,qF=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=PF(n);return(0,L.jsx)(xF,{...i,...r,ref:t})});qF.displayName=KF;var JF=`DropdownMenuItem`,YF=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=PF(n);return(0,L.jsx)(SF,{...i,...r,ref:t})});YF.displayName=JF;var XF=`DropdownMenuCheckboxItem`,ZF=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=PF(n);return(0,L.jsx)(CF,{...i,...r,ref:t})});ZF.displayName=XF;var QF=`DropdownMenuRadioGroup`,$F=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=PF(n);return(0,L.jsx)(wF,{...i,...r,ref:t})});$F.displayName=QF;var eI=`DropdownMenuRadioItem`,tI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=PF(n);return(0,L.jsx)(TF,{...i,...r,ref:t})});tI.displayName=eI;var nI=`DropdownMenuItemIndicator`,rI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=PF(n);return(0,L.jsx)(EF,{...i,...r,ref:t})});rI.displayName=nI;var iI=`DropdownMenuSeparator`,aI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=PF(n);return(0,L.jsx)(DF,{...i,...r,ref:t})});aI.displayName=iI;var oI=`DropdownMenuArrow`,sI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=PF(n);return(0,L.jsx)(OF,{...i,...r,ref:t})});sI.displayName=oI;var cI=`DropdownMenuSubTrigger`,lI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=PF(n);return(0,L.jsx)(kF,{...i,...r,ref:t})});lI.displayName=cI;var uI=`DropdownMenuSubContent`,dI=I.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=PF(n);return(0,L.jsx)(AF,{...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)`}})});dI.displayName=uI;var fI=LF,pI=zF,mI=VF,hI=UF,gI=GF,_I=qF,vI=YF,yI=$F,bI=tI,xI=rI,SI=aI;function CI({modal:e=!1,...t}){return(0,L.jsx)(fI,{modal:e,...t})}var wI=pI;function TI({children:e,align:t=`end`,sideOffset:n=6}){return(0,L.jsx)(mI,{children:(0,L.jsx)(hI,{align:t,sideOffset:n,className:`${Pj} min-w-[184px] overflow-hidden rounded-lg p-1`,children:e})})}function EI({children:e,onSelect:t,icon:n,danger:r}){return(0,L.jsxs)(vI,{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 DI(){return(0,L.jsx)(SI,{className:`my-1 h-px bg-border`})}var OI=(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)(Mm,{size:p?11:12,className:`animate-spin`}),`Mark as `,s]}),(0,L.jsxs)(CI,{children:[(0,L.jsx)(wI,{"aria-label":`Set status…`,className:`flex items-center border-l border-border-strong bg-panel-2 text-muted outline-none transition-colors hover:bg-elevated hover:text-fg data-[state=open]:bg-elevated data-[state=open]:text-fg ${p?`px-1`:`px-1.5`}`,children:(0,L.jsx)($p,{size:p?11:12})}),(0,L.jsx)(TI,{children:rT.map(e=>(0,L.jsxs)(EI,{onSelect:()=>c(e),children:[`Mark as `,e]},e))})]})]})}),kI=`Dialog`,[AI,jI]=oD(kI),[MI,NI]=AI(kI),PI=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]=zA({prop:r,defaultProp:i??!1,onChange:a,caller:kI});return(0,L.jsx)(MI,{scope:t,triggerRef:s,contentRef:c,contentId:WD(),titleId:WD(),descriptionId:WD(),open:l,onOpenChange:u,onOpenToggle:I.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})};PI.displayName=kI;var FI=`DialogTrigger`,II=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=NI(FI,n),a=aD(t,i.triggerRef);return(0,L.jsx)(xD.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":nL(i.open),...r,ref:a,onClick:nD(e.onClick,i.onOpenToggle)})});II.displayName=FI;var LI=`DialogPortal`,[RI,zI]=AI(LI,{forceMount:void 0}),BI=e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=NI(LI,t);return(0,L.jsx)(RI,{scope:t,forceMount:n,children:I.Children.map(r,e=>(0,L.jsx)(MA,{present:n||a.open,children:(0,L.jsx)(AA,{asChild:!0,container:i,children:e})}))})};BI.displayName=LI;var VI=`DialogOverlay`,HI=I.forwardRef((e,t)=>{let n=zI(VI,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=NI(VI,e.__scopeDialog);return a.modal?(0,L.jsx)(MA,{present:r||a.open,children:(0,L.jsx)(WI,{...i,ref:t})}):null});HI.displayName=VI;var UI=cD(`DialogOverlay.RemoveScroll`),WI=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=NI(VI,n),a=aD(t,LD());return(0,L.jsx)(YN,{as:UI,allowPinchZoom:!0,shards:[i.contentRef],children:(0,L.jsx)(xD.div,{"data-state":nL(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})}),GI=`DialogContent`,KI=I.forwardRef((e,t)=>{let n=zI(GI,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=NI(GI,e.__scopeDialog);return(0,L.jsx)(MA,{present:r||a.open,children:a.modal?(0,L.jsx)(qI,{...i,ref:t}):(0,L.jsx)(JI,{...i,ref:t})})});KI.displayName=GI;var qI=I.forwardRef((e,t)=>{let n=NI(GI,e.__scopeDialog),r=I.useRef(null),i=aD(t,n.contentRef,r);return I.useEffect(()=>{let e=r.current;if(e)return BM(e)},[]),(0,L.jsx)(YI,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:nD(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:nD(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:nD(e.onFocusOutside,e=>e.preventDefault())})}),JI=I.forwardRef((e,t)=>{let n=NI(GI,e.__scopeDialog),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(YI,{...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()}})}),YI=I.forwardRef((e,t)=>{let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=NI(GI,n);return qj(),(0,L.jsx)(L.Fragment,{children:(0,L.jsx)($j,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(PD,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionId,"aria-labelledby":s.titleId,"data-state":nL(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})}),XI=`DialogTitle`,ZI=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=NI(XI,n);return(0,L.jsx)(xD.h2,{id:i.titleId,...r,ref:t})});ZI.displayName=XI;var QI=`DialogDescription`,$I=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=NI(QI,n);return(0,L.jsx)(xD.p,{id:i.descriptionId,...r,ref:t})});$I.displayName=QI;var eL=`DialogClose`,tL=I.forwardRef((e,t)=>{let{__scopeDialog:n,...r}=e,i=NI(eL,n);return(0,L.jsx)(xD.button,{type:`button`,...r,ref:t,onClick:nD(e.onClick,()=>i.onOpenChange(!1))})});tL.displayName=eL;function nL(e){return e?`open`:`closed`}var rL=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`]),iL=/[a-zA-Z_][a-zA-Z0-9_-]*/y,aL=/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/;function oL(e){let t={},n=0;for(;n<e.length;){for(;/\s/.test(e[n]??``);)n++;if(n>=e.length)break;iL.lastIndex=n;let r=iL.exec(e);if(!r||Object.hasOwn(t,r[0]))return null;let i=r[0];if(n=iL.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(aL.test(a))t[i]=Number(a);else return null}if(n<e.length&&!/\s/.test(e[n]))return null}return t}function sL(e){let t=e.match(/^\s*::([a-z][a-z0-9-]*)\{([^\n]*)\}\s*$/);if(!t||!rL.has(t[1]))return null;let n=oL(t[2]);return n?{name:t[1],attrs:n}:null}var cL=String.raw`(?:[^\s\`]|[ ](?!/))+`,lL=new RegExp(String.raw`^\s*\`?(/${cL}\.(?:png|jpe?g|gif|webp))\`?\s*$`,`i`),uL=new RegExp(String.raw`^\s*\`?(/${cL}\.(?:${Ic.join(`|`)}))\`?\s*$`,`i`),dL=/^\s{0,3}(?:```|~~~)/,fL=/^\s{0,3}(`{3,}|~{3,})\s*mermaid\s*$/i,pL=/^\s*::codex-inline-vis\{file="([a-z0-9][a-z0-9-]{0,127}\.html)"\}\s*$/;function mL(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(dL)?.[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(uL.test(o)){i=!i,r.push(o);continue}if(i){r.push(o);continue}let s=o.match(fL);if(s){a(),n.push({kind:`visualization`,file:s[1]});continue}let c=oL(o);if(c){a(),n.push({kind:`directive`,directive:c});continue}let l=o.match(cL);if(l){a(),n.push({kind:`image`,path:l[1]});continue}let u=o.match(lL);if(u){a(),n.push({kind:`file`,path:u[1]});continue}r.push(o)}return a(),n}function mL(e){let t=e.split(`
183
- `),n=Array(t.length),r=!1;for(let e=0;e<t.length;e++)uL.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(cL),r=n?null:e.match(lL);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 hL(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(fL)?.[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(dL.test(o)){i=!i,r.push(o);continue}if(i){r.push(o);continue}let s=o.match(pL);if(s){a(),n.push({kind:`visualization`,file:s[1]});continue}let c=sL(o);if(c){a(),n.push({kind:`directive`,directive:c});continue}let l=o.match(lL);if(l){a(),n.push({kind:`image`,path:l[1]});continue}let u=o.match(uL);if(u){a(),n.push({kind:`file`,path:u[1]});continue}r.push(o)}return a(),n}function hL(e){let t=e.split(`
183
+ `),n=Array(t.length),r=!1;for(let e=0;e<t.length;e++)dL.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(lL),r=n?null:e.match(uL);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 gL(e,t){return t.length?`${e}${e?`
185
185
  `:``}${t.join(`
186
- `)}`:e}function gL(e){let t=e.display??e.path??``,n=t.split(`/`).filter(Boolean).pop()||t;return e.startLine===void 0||e.endLine===void 0?n:e.startLine===e.endLine?`${n}:${e.startLine}`:`${n}:${e.startLine}-${e.endLine}`}function _L(e){return e.startsWith(`@`)?e.slice(1):e}function vL(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var yL=`(?![0-9#]|-\\d)`;function bL(e,t){return new RegExp(vL(t)+yL).test(e)}function xL(e,t){let n=new RegExp(vL(t)+yL).exec(e);return n?n.index:-1}function SL(e,t,n){let r=`@${e}`,i=e=>t.some(t=>t.token===e)||bL(n,e);if(!i(r))return r;for(let e=2;;e++)if(!i(`${r}#${e}`))return`${r}#${e}`}function CL(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 wL(e,t){if(!t.length||!e)return e?[{text:e}]:[];let n=[...new Set(t)].sort((e,t)=>t.length-e.length).map(vL).join(`|`),r=RegExp(`(${n})${yL}`,`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 TL(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 EL(e,t){return t&&e.startsWith(`${t.replace(/\/+$/,``)}/`)?e.slice(t.replace(/\/+$/,``).length+1):e}function DL(e){return e.startLine===void 0||e.endLine===void 0?``:e.startLine===e.endLine?`, line ${e.startLine}`:`, lines ${e.startLine}-${e.endLine}`}function OL(e,t){return e.length?`Selected context:\n\n${e.map(e=>{let n=e.text.replace(/\s+$/,``).split(`
186
+ `)}`:e}function _L(e){let t=e.display??e.path??``,n=t.split(`/`).filter(Boolean).pop()||t;return e.startLine===void 0||e.endLine===void 0?n:e.startLine===e.endLine?`${n}:${e.startLine}`:`${n}:${e.startLine}-${e.endLine}`}function vL(e){return e.startsWith(`@`)?e.slice(1):e}function yL(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var bL=`(?![0-9#]|-\\d)`;function xL(e,t){return new RegExp(yL(t)+bL).test(e)}function SL(e,t){let n=new RegExp(yL(t)+bL).exec(e);return n?n.index:-1}function CL(e,t,n){let r=`@${e}`,i=e=>t.some(t=>t.token===e)||xL(n,e);if(!i(r))return r;for(let e=2;;e++)if(!i(`${r}#${e}`))return`${r}#${e}`}function wL(e,t,n){let r=Math.max(0,Math.min(t,e.length)),i=e.slice(0,r),a=e.slice(r),o=i&&!/\s$/.test(i)?` `:``;return{prose:`${i}${o}${n}${a&&!/^\s/.test(a)?` `:``}${a}`,caret:r+o.length+n.length}}function TL(e,t){if(!t.length||!e)return e?[{text:e}]:[];let n=[...new Set(t)].sort((e,t)=>t.length-e.length).map(yL).join(`|`),r=RegExp(`(${n})${bL}`,`g`),i=[],a=0;for(let t of e.matchAll(r))t.index>a&&i.push({text:e.slice(a,t.index)}),i.push({text:t[0],token:t[0]}),a=t.index+t[0].length;return a<e.length&&i.push({text:e.slice(a)}),i}function EL(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 DL(e,t){return t&&e.startsWith(`${t.replace(/\/+$/,``)}/`)?e.slice(t.replace(/\/+$/,``).length+1):e}function OL(e){return e.startLine===void 0||e.endLine===void 0?``:e.startLine===e.endLine?`, line ${e.startLine}`:`, lines ${e.startLine}-${e.endLine}`}function kL(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} (${EL(e.path,t)}${DL(e)}):\n${n}`}).join(`
189
+ `);return`${e.token} (${DL(e.path,t)}${OL(e)}):\n${n}`}).join(`
190
190
 
191
- `)}`:``}function kL(e,t,n){let{prose:r,attachments:i}=mL(e),a=OL(t.filter(e=>bL(r,e.token)).sort((e,t)=>xL(r,e.token)-xL(r,t.token)),n);return a?hL(r.trimEnd()?`${r.trimEnd()}\n\n${a}`:a,i.map(e=>e.path)):e}var AL=`Selected context:
191
+ `)}`:``}function AL(e,t,n){let{prose:r,attachments:i}=hL(e),a=kL(t.filter(e=>xL(r,e.token)).sort((e,t)=>SL(r,e.token)-SL(r,t.token)),n);return a?gL(r.trimEnd()?`${r.trimEnd()}\n\n${a}`:a,i.map(e=>e.path)):e}var jL=`Selected context:
192
192
 
193
- `;function jL(e){let t=e.lastIndexOf(AL);if(t===-1||t!==0&&e.slice(t-2,t)!==`
193
+ `;function ML(e){let t=e.lastIndexOf(jL);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=>bL(n,e.token))?null:{body:n,items:i}}function ML(e){return e.key===`Enter`&&!e.altKey&&!e.shiftKey&&!e.isComposing&&e.keyCode!==229}function NL(e,t){return t&&ML(e)&&!e.metaKey&&!e.ctrlKey}function PL(e,t){return t&&ML(e)&&(e.metaKey||e.ctrlKey)}function FL(e){return ML(e)}function IL(e){return e.key===`Enter`&&e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing}function LL(e,t,n){return e===`queueComposer`&&t===`Enter`&&n}var RL=`gap-3`,zL=`-mx-1`,BL=`-mx-[3px]`,VL=`right-2`,HL=`right-[71px]`,UL=`right-[44px]`,WL=`pr-[6.6875rem]`,GL=`pr-20`;async function KL(e,t){let n=Nd(),r=await e.arrayBuffer(),i=``,a=new Uint8Array(r);for(let e=0;e<a.length;e+=32768)i+=String.fromCharCode(...a.subarray(e,e+32768));let o=await fetch(`${n}/attach`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t,data:btoa(i)})});return o.ok?(await o.json()).path??null:null}var qL={project:`project`,user:`global`,builtin:`built-in`,plugin:`plugin`};function JL(e,t){e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,t)}px`}function YL({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)(()=>mL(e),[e]),w=C.map(e=>e.path),T=(0,I.useRef)(e);T.current=e;let E=e=>t(hL(e,w)),D=e=>t(hL(S,e));async function O(e){if(!e)return;if(b){Z(`An upload is already in progress — try again in a moment`);return}let n=[...e].map(e=>{let t=e.type.startsWith(`image/`)?e.type.slice(6).toLowerCase():``,n=t===`jpeg`?`jpg`:t===`svg+xml`?`svg`:t;return{file:e,name:e.name||(n?`pasted.${n}`:``)}}).filter(({name:e})=>Vc(e)?!0:(Z(`${e||`File`}: unsupported file type`),!1));if(!n.length)return;let r=n.filter(({file:e,name:t})=>e.size>Rc?(Z(`${t} is too large (max ${Math.floor(Rc/1e6)} MB)`),!1):!0);if(!r.length)return;let i=T.current;x(!0);let a=[];try{for(let{file:e,name:t}of r){let n=await KL(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=mL(T.current);t(hL(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||JL(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=wL(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(qL[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=wL(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(LL(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(NL(i,a)){e.preventDefault(),e.stopPropagation(),n();return}if(PL(i,a)){e.preventDefault(),e.stopPropagation(),(m??n)();return}if(IL(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?qL[e.source]:``})]})]},e.name))}),(0,L.jsxs)(`div`,{className:`relative`,children:[A&&(0,L.jsx)(`div`,{ref:g,"aria-hidden":!0,"data-composer-context-backdrop":!0,className:`pointer-events-none absolute inset-0 select-none overflow-hidden whitespace-pre-wrap [overflow-wrap:break-word] px-3.5 ${u?`py-2.5 pb-3`:`py-2.5 ${fe?`pr-[6.6875rem]`:`pr-20`}`} text-[13px] leading-relaxed text-transparent`,children:A}),(0,L.jsx)(`textarea`,{id:a,ref:h,onScroll:A?j:void 0,"data-surface":r,value:S,autoFocus:c,disabled:l,onChange:e=>E(e.target.value),onKeyDown:pe,onPaste:e=>{let t=[...e.clipboardData.items].filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(Boolean);t.length&&(e.preventDefault(),O(t))},placeholder:i,rows:1,spellCheck:!1,style:{minHeight:o,maxHeight:s},className:`relative block w-full resize-none bg-transparent px-3.5 ${u?`py-2.5 pb-3`:`py-2.5 ${fe?WL:GL}`} 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)(XL,{attachment:e,disabled:l,onRemove:()=>D(w.filter((e,n)=>n!==t))},`${e.path}-${t}`))}),u&&(0,L.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1 pl-1.5 pb-1.5 ${fe?`pr-[6.6875rem]`:`pr-20`}`,children:u}),fe&&(0,L.jsx)(`div`,{className:`absolute bottom-2 right-[43px] flex items-center`,children:fe}),(0,L.jsx)(`input`,{ref:_,type:`file`,multiple:!0,accept:Hc,className:`hidden`,onChange:e=>{O(e.target.files),e.target.value=``}}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>_.current?.click(),disabled:l||b,title:`Attach files`,"aria-label":`Attach files`,className:`absolute bottom-2 ${fe?HL:UL} flex h-7 w-7 items-center justify-center rounded-lg text-muted transition-[color,background-color] enabled:hover:bg-panel-2/70 enabled:hover:text-fg disabled:opacity-50`,children:b?(0,L.jsx)(Mm,{size:15,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(Bm,{size:15,strokeWidth:2})}),(0,L.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:n,disabled:!de||l||b,title:`Send (Enter · ⌘⏎ sends now)`,"aria-label":`Send`,className:`absolute bottom-2 ${VL} flex h-7 w-7 items-center justify-center rounded-lg transition-all ${de&&!l&&!b?`bg-fg text-bg hover:opacity-90 active:scale-95`:`bg-panel-2 text-muted`}`,children:l?(0,L.jsx)(Mm,{size:14,strokeWidth:2.5,className:`animate-spin`}):(0,L.jsx)(Jp,{size:14,strokeWidth:2.5})})]})}function XL({attachment:e,disabled:t,onRemove:n}){let[r,i]=(0,I.useState)(!1),a=e.path.split(`/`).filter(Boolean).pop()||e.path,o=(a.includes(`.`)?a.split(`.`).pop():``).toUpperCase();return(0,L.jsxs)(`div`,{className:`group/att relative h-11 w-11`,title:a,children:[e.kind===`image`&&!r?(0,L.jsx)(`img`,{src:jS(e.path),alt:a,onError:()=>i(!0),className:`h-11 w-11 rounded-md border border-border object-cover`}):(0,L.jsxs)(`div`,{className:`flex h-11 w-11 flex-col items-center justify-center gap-0.5 rounded-md border border-border bg-panel-2 px-1`,children:[(0,L.jsx)(gm,{size:15,strokeWidth:2,className:`shrink-0 text-muted`}),o&&(0,L.jsx)(`span`,{className:`-mx-1 max-w-[calc(100%+0.5rem)] truncate text-[8px] font-medium leading-none text-muted/80`,children:o})]}),(0,L.jsx)(`button`,{type:`button`,onClick:n,disabled:t,title:`Remove ${a}`,"aria-label":`Remove ${a}`,className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full border border-border bg-bg text-muted opacity-0 transition-opacity hover:text-fg focus-visible:opacity-100 group-hover/att:opacity-100 disabled:hidden`,children:(0,L.jsx)(ah,{size:10,strokeWidth:2.5})})]})}function ZL(){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 QL(){let e=ZL();return!!(e.data?.inRepo&&e.data.authed)}function $L({className:e=``}){return QL()?(0,L.jsx)(`button`,{type:`button`,onClick:Gf,onMouseDown:e=>e.preventDefault(),title:`Investigate this issue and make recommendations`,"aria-label":`Investigate this issue and make recommendations`,className:`flex h-7 w-7 items-center justify-center rounded-lg text-muted outline-none transition-[color,background-color,box-shadow] enabled:hover:bg-panel-2/70 enabled:hover:text-fg enabled:focus-visible:bg-panel-2/70 enabled:focus-visible:text-muted enabled:focus-visible:ring-1 enabled:focus-visible:ring-muted/80 enabled:focus-visible:ring-offset-1 enabled:focus-visible:ring-offset-bg enabled:active:bg-elevated enabled:active:text-muted disabled:bg-transparent disabled:text-muted/35 ${e}`,children:(0,L.jsx)(wm,{size:15,strokeWidth:2})}):null}var eR=`prompt-control-type petite-caps`,tR=eR,nR=eR,rR=`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 ${tR} 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 iR(e){return`minmax(6rem, 7rem) repeat(${Math.max(0,e)}, auto)`}var aR=[`ultra`,`ultracode`],oR=[`low`,`medium`,`high`,`xhigh`,`max`,...aR];function sR(e){return[...new Set(e.flatMap(e=>e.options.flatMap(e=>e.efforts)))].sort((e,t)=>{let n=oR.indexOf(e),r=oR.indexOf(t);return n===-1&&r===-1?e.localeCompare(t):n===-1?1:r===-1?-1:n-r})}function cR(e){let t=[];for(let n of sR(e)){let e=aR.includes(n)?t.find(e=>aR.includes(e[0])):void 0;e?e.push(n):t.push([n])}return t}function lR(e){return e.flatMap(e=>e.options.flatMap(t=>t.efforts.map(n=>({provider:e.id,model:t.model,effort:n}))))}function uR(e){return JSON.stringify([e.provider,e.model,e.effort])}function dR(e,t){return lR(e).find(e=>uR(e)===t)}function fR(e,t){return!t?.model||!t.effort?!1:e.some(e=>(!t.provider||e.id===t.provider)&&e.options.some(e=>e.model===t.model&&e.efforts.includes(t.effort)))}function pR(e,t,n=`Profile unknown`){if(!t?.model&&!t?.effort)return n;let r=e.flatMap(e=>e.options).find(e=>e.model===t.model)?.label??t.model??`Model unknown`;return t.effort?`${r} › ${t.effort}`:r}function mR(e,t,n){let r=cR(e),i=e=>r.findIndex(t=>t.includes(e)),a=e.flatMap(e=>e.options.map(t=>({provider:e.id,option:t}))),o=a.findIndex(e=>e.provider===t.provider&&e.option.model===t.model);if(o===-1)return null;let s=a[o],c=s.option.efforts.indexOf(t.effort);if(c===-1)return null;if(n===`Home`||n===`End`||n===`ArrowLeft`||n===`ArrowRight`){let e=n===`Home`?0:n===`End`?s.option.efforts.length-1:c+(n===`ArrowLeft`?-1:1),t=s.option.efforts[e];return t?{provider:s.provider,model:s.option.model,effort:t}:null}let l=a[o+(n===`ArrowUp`?-1:1)];if(!l)return null;let u=i(t.effort),d=l.option.efforts.reduce((e,t)=>e?Math.abs(i(t)-u)<Math.abs(i(e)-u)?t:e:t,void 0);return d?{provider:l.provider,model:l.option.model,effort:d}:null}var hR,gR=!1;function _R(){gR||typeof window>`u`||(gR=!0,window.addEventListener(`keydown`,e=>{e.key!==`Escape`||!hR||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),yR())},{capture:!0}))}function vR(e){_R();let t={dismiss:e};return hR=t,()=>{hR===t&&(hR=void 0)}}function yR(){let e=hR;return e?(hR=void 0,e.dismiss(),!0):!1}function bR(e){yR()&&e.preventDefault(),e.stopPropagation()}function xR(e){return e===`xhigh`?`X-high`:e.charAt(0).toUpperCase()+e.slice(1)}function SR({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=Mj,className:f=``}){let[p,m]=(0,I.useState)(!1),h=(0,I.useRef)(p),g=(0,I.useRef)(c),_=(0,I.useRef)(void 0),v=(0,I.useRef)(new Map),y=(0,I.useRef)(void 0),b=(0,I.useMemo)(()=>cR(e),[e]),x=(0,I.useMemo)(()=>e.flatMap(e=>e.options.flatMap(t=>t.efforts.map(n=>({provider:e.id,model:t.model,effort:n})))),[e]),S=l?nR:tR,C=c?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors hover:border-border hover:bg-panel-2 hover:text-fg`,w=fR(e,t),T=w&&t?.provider&&t.model&&t.effort?uR(t):void 0,E=n?.model||n?.effort?pR(e,n,`Pending profile`):void 0;h.current=p,g.current=c;function D(){h.current=!1,_.current=void 0,m(!1)}(0,I.useLayoutEffect)(()=>{let e=e=>{e.key!==`Escape`||!h.current||g.current||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),_.current?.(),D())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]),(0,I.useLayoutEffect)(()=>{!c||!p||(_.current?.(),D())},[c,p]),(0,I.useLayoutEffect)(()=>()=>_.current?.(),[]),(0,I.useLayoutEffect)(()=>{T===y.current&&(y.current=void 0)},[T]);function O(e){let t=uR(e);y.current!==t&&(y.current=t,r(e))}function k(t,n){if(![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(t.key))return;let r=mR(e,n,t.key);r&&(t.preventDefault(),t.stopPropagation(),v.current.get(uR(r))?.focus())}return(0,L.jsxs)(dI,{modal:!1,open:p,onOpenChange:e=>{_.current?.(),_.current=void 0,h.current=e,m(e),e&&(_.current=vR(D))},children:[(0,L.jsx)(fI,{asChild:!0,disabled:c,children:(0,L.jsxs)(`button`,{type:`button`,"aria-label":a,"aria-invalid":!w&&(t?.model||t?.effort)?!0:void 0,"aria-description":E?`Pending ${E}`:void 0,title:s,"data-profile-known":w?`true`:`false`,"data-profile-pending":E?`true`:void 0,className:`profile-grid-trigger group inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md border border-border/50 bg-transparent px-2 py-1 text-left text-muted outline-none data-[state=open]:border-border data-[state=open]:bg-panel-2 ${C} ${f} ${S}`,children:[(0,L.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 flex-1 truncate text-left ${S}`,children:pR(e,t,i)}),E&&(0,L.jsx)(Mm,{"aria-hidden":`true`,size:l?10:11,className:`shrink-0 animate-spin text-muted/65`}),(0,L.jsx)($p,{"aria-hidden":`true`,size:l?11:13,className:`shrink-0 text-fg/65 transition-transform group-data-[state=open]:rotate-180`})]})}),(0,L.jsx)(pI,{children:(0,L.jsxs)(mI,{"aria-label":o,align:`start`,side:u,sideOffset:5,collisionPadding:8,onEscapeKeyDown:e=>e.stopPropagation(),className:`profile-grid-menu ${d} ${jj} max-h-[min(360px,var(--radix-dropdown-menu-content-available-height))] max-w-[calc(100vw-1rem)] overflow-auto rounded-lg p-1.5 ${S}`,children:[e.map(t=>(0,L.jsxs)(hI,{children:[t.label&&(0,L.jsx)(gI,{className:`px-1.5 pb-1 pt-1 text-left font-medium tracking-[0.07em] text-muted/55 first:pt-0.5`,children:t.label}),(0,L.jsx)(vI,{value:T,onValueChange:t=>{let n=dR(e,t);n&&O(n)},children:t.options.map(e=>(0,L.jsxs)(`div`,{"data-profile-grid-row":e.model,className:`grid w-max items-center gap-1 py-0.5`,style:{gridTemplateColumns:iR(b.length)},children:[(0,L.jsx)(`span`,{className:`profile-grid-model-label min-w-0 max-w-[9.5rem] truncate px-1.5 text-left text-muted ${S}`,title:e.label,children:e.label}),b.map(n=>{let r=n.find(t=>e.efforts.includes(t)),i=n.reduce((e,t)=>xR(t).length>xR(e).length?t:e);if(!r)return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`invisible cursor-default border border-transparent px-1 text-left font-medium ${S}`,children:xR(i)},i);let a={provider:t.id,model:e.model,effort:r},o=uR(a);return(0,L.jsx)(yI,{value:o,ref:e=>{e?v.current.set(o,e):v.current.delete(o)},onKeyDown:e=>k(e,a),onSelect:e=>{e.preventDefault(),O(a),_.current?.(),D()},"aria-label":`${e.label}, ${xR(r)} effort`,title:`${e.label} › ${xR(r)}`,className:rR,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:xR(r)}),(0,L.jsx)(`span`,{className:`col-start-1 row-start-1`,children:xR(r)})]})},r)})]},e.model))}),t!==e.at(-1)&&(0,L.jsx)(xI,{className:`my-1 h-px bg-border`})]},t.id)),x.length===0&&(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-muted/60`,children:`No profiles available`})]})})]})}async function CR(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(!wR(e))throw Error(`the browser blocked clipboard access`)}function wR(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 TR={claude:`claude auth login`,codex:`codex login`},ER={claude:`Claude`,codex:`Codex`};function DR(e){let t=e.trim();return t===`/login`?`login`:t===`/logout`?`logout`:null}var OR=(0,I.lazy)(()=>By(()=>import(`./TerminalPane-PMq5oyOr.js`).then(e=>({default:e.TerminalPane})),__vite__mapDeps([0,1])));function kR({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=TR[e],u=ER[e],d=it({mutationFn:()=>Y.accountLoginStart({backend:e}),onSuccess:e=>{c.current=!1,s(e.attemptId)},onError:e=>Z(`Couldn't start the sign-in terminal: ${e.message.slice(0,80)} — use the command below instead`,{duration:7e3})}),f=nt({queryKey:[`accountLoginStatus`,o],queryFn:()=>Y.accountLoginStatus({attemptId:o}),enabled:!!o,refetchInterval:2e3});(0,I.useEffect)(()=>{if(!o||c.current)return;let t=f.data;if(!(!t||t.state===`running`||t.state===`unknown`)){if(c.current=!0,t.auth!==`signed-out`){r.setQueryData([`authStatus`],n=>n&&{...n,[e]:t.auth}),Z(`Signed in to ${u}`),n();return}Z(`${u} sign-in didn't complete — try again or use the command below`,{duration:7e3}),s(null)}},[o,f.data,e,u]);function p(){o&&!c.current&&Y.accountLoginCancel({attemptId:o}).catch(()=>{})}let m=(0,I.useRef)({attempt:null,settled:!1});m.current={attempt:o,settled:c.current},(0,I.useEffect)(()=>()=>{let{attempt:e,settled:t}=m.current;e&&!t&&Y.accountLoginCancel({attemptId:e}).catch(()=>{})},[]);async function h(){try{await CR(l),a(!0),window.setTimeout(()=>a(!1),1500)}catch{Z(`Couldn't copy — select the command and copy it manually`,{duration:6e3})}}let g=it({mutationFn:()=>Y.authStatus(),onSuccess:t=>{if(r.setQueryData([`authStatus`],t),t[e]===`signed-out`){Z(`Still signed out of ${u} — run the command, then retry`,{duration:6e3});return}n()},onError:()=>n()});return(0,L.jsx)(NI,{open:!0,onOpenChange:e=>{e||(p(),t())},children:(0,L.jsxs)(zI,{children:[(0,L.jsx)(VI,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(GI,{"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)(XI,{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)(OR,{slug:o})})}),(0,L.jsx)(`div`,{className:`flex items-center justify-end gap-2`,children:(0,L.jsx)(`button`,{type:`button`,onClick:()=>{p(),s(null)},className:`rounded-md px-3 py-1.5 text-[12.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg`,children:`Cancel sign-in`})})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`mb-4 text-[12.5px] leading-relaxed text-muted`,children:[`Frizz can't start a `,u,` thread until you're signed in. Sign in here, or run the command in your own terminal and retry:`]}),(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg border border-border bg-panel-2 px-3 py-2`,children:[(0,L.jsx)(`code`,{className:`flex-1 select-all font-mono-keep text-[12.5px] text-fg`,children:l}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,onClick:h,className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted outline-none transition-colors hover:bg-panel hover:text-fg`,children:i?(0,L.jsx)(Qp,{size:14,strokeWidth:2,className:`text-green-400`}):(0,L.jsx)(fm,{size:14,strokeWidth:1.8})})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md px-3 py-1.5 text-[12.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>g.mutate(),disabled:g.isPending,className:`flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-[12.5px] text-fg/90 outline-none transition-colors hover:bg-panel-2 disabled:opacity-60`,children:[g.isPending&&(0,L.jsx)(Mm,{size:13,className:`animate-spin`}),`Retry`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>d.mutate(),disabled:d.isPending,className:`flex items-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-[12.5px] font-medium text-white outline-none transition-opacity hover:opacity-90 disabled:opacity-60`,children:[d.isPending&&(0,L.jsx)(Mm,{size:13,className:`animate-spin`}),`Sign in here`]})]})]})]})]})})}function AR({backend:e,onClose:t}){let n=Ve(),r=ER[e],i=it({mutationFn:()=>Y.accountLogout({backend:e}),onSuccess:i=>{n.setQueryData([`authStatus`],t=>t&&{...t,[e]:i.auth}),i.status===`done`?Z(`Signed out of ${r}`):i.status===`blocked`?Z(`Not signed out — ${i.activeThreads} active ${r} thread${i.activeThreads===1?``:`s`}. Let them finish (or complete them) first.`,{duration:7e3}):Z(`${r} sign-out failed: ${i.detail??`unknown error`}`,{duration:7e3}),t()},onError:e=>{Z(`${r} sign-out failed: ${e.message.slice(0,80)}`,{duration:7e3}),t()}});return(0,L.jsx)(NI,{open:!0,onOpenChange:e=>{!e&&!i.isPending&&t()},children:(0,L.jsxs)(zI,{children:[(0,L.jsx)(VI,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(GI,{"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)(XI,{className:`mb-1 text-[14px] font-medium`,children:[`Sign out of `,r,`?`]}),(0,L.jsxs)(`p`,{className:`mb-4 text-[12.5px] leading-relaxed text-muted`,children:[`New `,r,` threads will be blocked until you sign in again. Running `,r,` threads are left untouched — sign-out is refused while any are active.`]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:t,disabled:i.isPending,className:`rounded-md px-3 py-1.5 text-[12.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:opacity-60`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i.mutate(),disabled:i.isPending,className:`flex items-center gap-1.5 rounded-md bg-red-500/90 px-3 py-1.5 text-[12.5px] font-medium text-white outline-none transition-opacity hover:opacity-90 disabled:opacity-60`,children:[i.isPending&&(0,L.jsx)(Mm,{size:13,className:`animate-spin`}),`Sign out`]})]})]})]})})}var jR=mu.options,MR={auto:`Auto`,default:`Default`,acceptEdits:`Accept edits`,plan:`Plan`,bypassPermissions:`Bypass`},NR={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)`};jR.filter(e=>e!==`plan`).map(e=>({value:e,label:MR[e],title:NR[e]}));var PR=[`auto`,`bypassPermissions`].map(e=>({value:e,label:MR[e],title:NR[e]})),FR=[{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 IR(e){return e===`plan`?`auto`:e}var LR=[`low`,`medium`,`high`,`xhigh`,`max`],RR=`ultracode`,zR=new Set([`fable`,`opus`,`sonnet`]);function BR(e){return e&&zR.has(e)?[...LR,RR]:[...LR]}var VR={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-high`,max:`Max`,ultra:`Ultra`,ultracode:`Ultracode`};function HR(e){return VR[e]??e.charAt(0).toUpperCase()+e.slice(1)}function UR(e,t){let n=BR(e).map(e=>({value:e,label:HR(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function WR(e,t){let n=(e?.efforts??[]).map(e=>({value:e,label:HR(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function GR(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 KR(e){return[{id:`claude`,label:`Claude Code`,options:FR.map(e=>({model:e.value,label:e.label,defaultEffort:`high`,efforts:BR(e.value)}))},{id:`codex`,label:`Codex`,options:e.map(e=>({model:e.slug,label:e.displayName,defaultEffort:e.defaultEffort,efforts:e.efforts}))}]}function qR(e,t){let n=e.backend,r=e[n],i=r.model??(n===`claude`?`opus`:t[0]?.slug??``),a=n===`codex`?t.find(e=>e.slug===i):void 0,o=n===`claude`?FR.some(e=>e.value===i):t.some(e=>e.slug===i),s=n===`claude`?`high`:a?.defaultEffort??``,c=r.effort??s,l=n===`claude`?UR(i,{withDefault:!1}):WR(a,{withDefault:!1}),u=l.some(e=>e.value===c);return{backend:n,model:i,effort:c,codexModel:a,modelAvailable:o,effortAvailable:u,effortOptions:c&&!u?[{value:c,label:`${c} (unavailable)`,title:`Saved reasoning level is not available for this model`},...l]:l}}function JR(){let e=Ve(),t=nt({queryKey:[`dispatchPreferencesGet`],queryFn:()=>Y.dispatchPreferencesGet()}),n=nt({queryKey:[`codexModels`],queryFn:()=>Y.codexModels()}),r=n.data??[],i=it({mutationFn:e=>Y.dispatchPreferenceSet(e),scope:{id:`dispatch-preferences`},onMutate:t=>{let n=e.getQueryData([`dispatchPreferencesGet`]);n&&e.setQueryData([`dispatchPreferencesGet`],GR(n,t))},onError:t=>{e.invalidateQueries({queryKey:[`dispatchPreferencesGet`]}),Z(`Could not save new-thread preference: ${t.message.slice(0,80)}`)}}),a=!!t.data&&!!n.data;return{resolved:(0,I.useMemo)(()=>a?qR(t.data,r):void 0,[a,t.data,r]),codexList:r,loadError:t.isError||n.isError,saveProfile:i.mutate}}var YR=`frizz-drafts:v1`,XR=80,ZR=512*1024,QR=2*1024*1024,$R=new TextEncoder;function ez(e){return $R.encode(e).byteLength}function tz(){return{version:1,entries:{}}}function nz(e){if(!e)return tz();try{let t=JSON.parse(e);if(!t||typeof t!=`object`||t.version!==1)return tz();let n=t.entries;if(!n||typeof n!=`object`||Array.isArray(n))return tz();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||ez(t.value)>ZR||(r[e]={value:t.value,touchedAt:t.touchedAt});return{version:1,entries:r}}catch{return tz()}}function rz(e){let t=Object.entries(e.entries).filter(([,e])=>e.value&&ez(e.value)<=ZR).sort((e,t)=>t[1].touchedAt-e[1].touchedAt),n={};for(let[e,r]of t){if(Object.keys(n).length>=XR)break;n[e]=r,ez(JSON.stringify({version:1,entries:n}))>QR&&delete n[e]}return{version:1,entries:n}}var iz=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=rz(nz(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(YR,JSON.stringify(rz(e)))}catch{}for(let e of this.listeners)e()}};function az(e){return encodeURIComponent(e||`unresolved-project`)}var oz={dispatch:e=>`dispatch:${az(e)}:new`,followUp:(e,t,n)=>`followup:${az(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}`,adopt:(e,t)=>`adopt:${az(e)}:${encodeURIComponent(t)}`,answer:(e,t,n,r,i)=>`answer:${az(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}:${encodeURIComponent(r)}:${i}`,interaction:(e,t,n,r,i,a,o)=>`interaction:${az(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}:${i}:${encodeURIComponent(a)}:${encodeURIComponent(o)}`,question:(e,t,n,r)=>`question:${az(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}`};function sz(){return Zt(X).board?.projectDir}function cz(e){return Zt(X).board?.threads.find(t=>t.id===e)?.sessionId}function lz(e){let t=(0,I.useCallback)(()=>iz.get(e),[e]);return[(0,I.useSyncExternalStore)(iz.subscribe,t,t),(0,I.useCallback)(t=>iz.set(e,t),[e]),(0,I.useCallback)(()=>iz.clear(e),[e])]}function uz(e){let t=(0,I.useCallback)(()=>JSON.stringify(Object.fromEntries(e.map(e=>[e,iz.get(e)]))),[e.join(`\0`)]),n=(0,I.useSyncExternalStore)(iz.subscribe,t,t);return(0,I.useMemo)(()=>new Map(Object.entries(JSON.parse(n))),[n])}function dz({autoFocus:e,onDispatched:t}){let{resolved:n,codexList:r,loadError:i,saveProfile:a}=JR(),o=QL(),s=sz(),[c,l,u]=lz(oz.dispatch(s)),d=oz.dispatch(s),f=(0,I.useRef)(``),[p,m]=(0,I.useState)(null),h=nt({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4}),[g,_]=(0,I.useState)(null),[v,y]=(0,I.useState)(null),b=(0,I.useRef)(null),x=it({mutationFn:e=>Y.dispatch(e),onMutate:()=>Z(`Starting thread…`,{spinner:!0,sticky:!0}),onSuccess:e=>{m(null),t?.(),Z(`Thread started`,{link:{label:`Open thread`,slug:e.slug}})},onError:(e,t)=>{iz.get(d)||l(f.current||t.prompt),m(null);let n=/^AUTH_REQUIRED:(claude|codex)$/.exec(e.message);if(n){b.current=t,_(n[1]),Z(`Signed out of ${n[1]===`claude`?`Claude`:`Codex`}`,{duration:3e3});return}Z(`Dispatch failed: ${e.message.slice(0,80)}`)}});function S(e){f.current=c,u(),m(e.prompt),x.mutate(e)}function C(){if(!c.trim()||!n)return;let e=DR(c);if(e){u(),e===`login`?(b.current=null,_(n.backend)):y(n.backend);return}if(!n.modelAvailable){Z(`Saved model is unavailable — choose a model before starting the thread`);return}if(!n.effortAvailable){Z(`Saved reasoning level is unavailable for this model — choose another level`);return}let t={prompt:c.trim(),model:n.model,backend:n.backend,effort:n.effort};if(h.data?.[n.backend]===`signed-out`){b.current=t,_(n.backend);return}S(t)}let w=(0,I.useMemo)(()=>n?(0,L.jsx)(SR,{groups:KR(r),value:{provider:n.backend,model:n.model,effort:n.effort},onValueChange:e=>a({field:`profile`,backend:e.provider,model:e.model,effort:e.effort}),ariaLabel:`Model and effort`,title:n.modelAvailable&&n.effortAvailable?`Model and reasoning effort`:`Saved model or reasoning effort unavailable — choose a supported pair`,className:`max-w-[min(21rem,72vw)]`}):(0,L.jsx)(SR,{groups:[],value:void 0,onValueChange:()=>{},placeholder:i?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort loading`,disabled:!0}),[n,r,i,a]);return(0,L.jsxs)(`div`,{className:`w-full flex flex-col gap-3`,children:[(0,L.jsx)(YL,{surface:`newComposer`,autoFocus:e,value:c,onChange:l,onSubmit:C,placeholder:`Describe the task…`,minHeight:96,maxHeight:340,busy:x.isPending,footer:w,leftAction:o?(0,L.jsx)($L,{}):void 0}),x.isError&&(0,L.jsx)(`span`,{className:`px-0.5 text-[11px] text-red-400 truncate`,children:x.error.message}),p&&(0,L.jsxs)(`div`,{"data-pending-dispatch":!0,role:`status`,className:`rounded-lg border border-border bg-panel-2 px-3 py-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted`,children:[(0,L.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-accent`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{children:`Starting thread…`})]}),(0,L.jsx)(`p`,{className:`mt-1 line-clamp-2 whitespace-pre-wrap text-[12px] leading-relaxed text-fg`,children:p})]}),g&&(0,L.jsx)(kR,{backend:g,onClose:()=>_(null),onAuthed:()=>{let e=b.current;b.current=null,_(null),e&&S(e)}}),v&&(0,L.jsx)(AR,{backend:v,onClose:()=>y(null)})]})}function fz({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)(NI,{open:!0,onOpenChange:t=>{t||e()},children:(0,L.jsxs)(zI,{children:[(0,L.jsx)(VI,{className:`fixed inset-0 z-50 bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(GI,{ref:t,"aria-modal":`true`,"aria-describedby":void 0,onEscapeKeyDown:bR,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)(XI,{className:`mb-1 text-[14px] font-medium`,children:`New thread`}),(0,L.jsx)(dz,{autoFocus:!0,onDispatched:e})]})]})})}function pz({children:e,onClose:t}){return(0,L.jsx)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center bg-black/30 backdrop-blur-md backdrop-saturate-150`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:e})}var mz=`-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`,hz={claude:`size-[11px] translate-y-px`,codex:`size-[10px]`},gz={claude:{backend:`claude`,label:`Claude Code`},codex:{backend:`codex`,label:`OpenAI Codex`}};function _z(e){return e===`claude`||e===`codex`?gz[e]:void 0}function vz({backend:e,className:t}){let n=_z(e);return n?(0,L.jsx)(`span`,{role:`img`,"aria-label":n.label,className:`inline-flex shrink-0 text-muted/65 ${hz[n.backend]} ${t??``}`,children:n.backend===`codex`?(0,L.jsx)(yz,{}):(0,L.jsx)(bz,{})}):null}function yz(){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 bz(){return(0,L.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,L.jsx)(`path`,{d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`})})}typeof window<`u`&&window.document&&window.document.createElement;function xz(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)}}function Sz(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,Cz(i,...t)]}function Cz(...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 wz=`DismissableLayer`,Tz=`dismissableLayer.update`,Ez=`dismissableLayer.pointerDownOutside`,Dz=`dismissableLayer.focusOutside`,Oz,kz=I.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),Az=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(kz),[d,f]=I.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=I.useState({}),h=iD(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=Pz(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=Fz(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=SD(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&&(Oz=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Iz(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=Oz))}},[d,p,n,u]),I.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Iz())},[d,u]),I.useEffect(()=>{let e=()=>m({});return document.addEventListener(Tz,e),()=>document.removeEventListener(Tz,e)},[]),(0,L.jsx)(bD.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:xz(e.onFocusCapture,w.onFocusCapture),onBlurCapture:xz(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:xz(e.onPointerDownCapture,C.onPointerDownCapture)})});Az.displayName=wz;var jz=`DismissableLayerBranch`,Mz=I.forwardRef((e,t)=>{let n=I.useContext(kz),r=I.useRef(null),i=iD(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)(bD.div,{...e,ref:i})});Mz.displayName=jz;var Nz=()=>!0;function Pz(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Nz}=t,s=SD(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||Lz(Ez,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 Fz(e,t=globalThis?.document){let n=SD(e),r=I.useRef(!1);return I.useEffect(()=>{let e=e=>{e.target&&!r.current&&Lz(Dz,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 Iz(){let e=new CustomEvent(Tz);document.dispatchEvent(e)}function Lz(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?xD(i,a):i.dispatchEvent(a)}var Rz=`focusScope.autoFocusOnMount`,zz=`focusScope.autoFocusOnUnmount`,Bz={bubbles:!1,cancelable:!0},Vz=`FocusScope`,Hz=I.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=I.useState(null),l=SD(i),u=SD(a),d=I.useRef(null),f=iD(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:Yz(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Yz(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Yz(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){Xz.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(Rz,Bz);s.addEventListener(Rz,l),s.dispatchEvent(t),t.defaultPrevented||(Uz($z(Gz(s)),{select:!0}),document.activeElement===e&&Yz(s))}return()=>{s.removeEventListener(Rz,l),setTimeout(()=>{let t=new CustomEvent(zz,Bz);s.addEventListener(zz,u),s.dispatchEvent(t),t.defaultPrevented||Yz(e??document.body,{select:!0}),s.removeEventListener(zz,u),Xz.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]=Wz(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Yz(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Yz(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,L.jsx)(bD.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});Hz.displayName=Vz;function Uz(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Yz(r,{select:t}),document.activeElement!==n)return}function Wz(e){let t=Gz(e);return[Kz(t,e),Kz(t.reverse(),e)]}function Gz(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 Kz(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 Jz(e){return e instanceof HTMLInputElement&&`select`in e}function Yz(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Jz(e)&&t&&e.select()}}var Xz=Zz();function Zz(){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 $z(e){return e.filter(e=>e.tagName!==`A`)}var eB=`Popper`,[tB,nB]=Sz(eB),[rB,iB]=tB(eB),aB=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null),[a,o]=I.useState(void 0);return(0,L.jsx)(rB,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};aB.displayName=eB;var oB=`PopperAnchor`,sB=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=iB(oB,n),o=I.useRef(null),s=a.onAnchorChange,c=iD(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&&_B(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,L.jsx)(bD.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})});sB.displayName=oB;var cB=`PopperContent`,[lB,uB]=tB(cB),dB=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=iB(cB,n),[_,v]=I.useState(null),y=iD(t,v),[b,x]=I.useState(null),S=aA(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(hB),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=qk({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>Nk(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[Yk({mainAxis:i+w,alignmentAxis:o}),c&&Xk({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Zk():void 0,...k}),c&&Qk({...k}),$k({...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&&tA({element:b,padding:s}),gB({arrowWidth:C,arrowHeight:w}),f&&eA({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ee=g.setPlacementState;CD(()=>(ee(M),()=>{ee(void 0)}),[M,ee]);let[F,te]=_B(M),ne=SD(m);CD(()=>{N&&ne?.()},[N,ne]);let re=P.arrow?.x,ie=P.arrow?.y,ae=P.arrow?.centerOffset!==0,[oe,se]=I.useState();return CD(()=>{_&&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)(lB,{scope:n,placedSide:F,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,L.jsx)(bD.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});dB.displayName=cB;var fB=`PopperArrow`,pB={top:`bottom`,right:`left`,bottom:`top`,left:`right`},mB=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=uB(fB,n),a=pB[i.placedSide];return(0,L.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,L.jsx)(iA,{...r,ref:t,style:{...r.style,display:`block`}})})});mB.displayName=fB;function hB(e){return e!==null}var gB=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]=_B(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 _B(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var vB=aB,yB=sB,bB=dB,xB=mB;function SB(e,t){return I.useReducer((e,n)=>t[e][n]??e,e)}var CB=e=>{let{present:t,children:n}=e,r=wB(t),i=typeof n==`function`?n({present:r.isPresent}):I.Children.only(n),a=EB(r.ref,OB(i));return typeof n==`function`||r.isPresent?I.cloneElement(i,{ref:a}):null};CB.displayName=`Presence`;function wB(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]=SB(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??DB(r.current),o.current=void 0):a.current=`none`},[s]),CD(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=DB(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]),CD(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=DB(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=DB(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=DB(t)}else r.current=null;n(e)},[])}}function TB(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function EB(...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=TB(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():TB(n[e],null)}}},[])}function DB(e){return e?.animationName||`none`}function OB(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 kB=`Popover`,[AB,jB]=Sz(kB,[nB]),MB=nB(),[NB,PB]=AB(kB),FB=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=MB(t),c=I.useRef(null),[l,u]=I.useState(!1),[d,f]=RA({prop:r,defaultProp:i??!1,onChange:a,caller:kB});return(0,L.jsx)(vB,{...s,children:(0,L.jsx)(NB,{scope:t,contentId:UD(),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})})};FB.displayName=kB;var IB=`PopoverAnchor`,LB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=PB(IB,n),a=MB(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return I.useEffect(()=>(o(),()=>s()),[o,s]),(0,L.jsx)(yB,{...a,...r,ref:t})});LB.displayName=IB;var RB=`PopoverTrigger`,zB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=PB(RB,n),a=MB(n),o=iD(t,i.triggerRef),s=(0,L.jsx)(bD.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":eV(i.open),...r,ref:o,onClick:xz(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,L.jsx)(yB,{asChild:!0,...a,children:s})});zB.displayName=RB;var BB=`PopoverPortal`,[VB,HB]=AB(BB,{forceMount:void 0}),UB=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=PB(BB,t);return(0,L.jsx)(VB,{scope:t,forceMount:n,children:(0,L.jsx)(CB,{present:n||a.open,children:(0,L.jsx)(kA,{asChild:!0,container:i,children:r})})})};UB.displayName=BB;var WB=`PopoverContent`,GB=I.forwardRef((e,t)=>{let n=HB(WB,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=PB(WB,e.__scopePopover);return(0,L.jsx)(CB,{present:r||a.open,children:a.modal?(0,L.jsx)(qB,{...i,ref:t}):(0,L.jsx)(JB,{...i,ref:t})})});GB.displayName=WB;var KB=sD(`PopoverContent.RemoveScroll`),qB=I.forwardRef((e,t)=>{let n=PB(WB,e.__scopePopover),r=I.useRef(null),i=iD(t,r),a=I.useRef(!1);return I.useEffect(()=>{let e=r.current;if(e)return zM(e)},[]),(0,L.jsx)(JN,{as:KB,allowPinchZoom:!0,children:(0,L.jsx)(YB,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:xz(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:xz(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:xz(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),JB=I.forwardRef((e,t)=>{let n=PB(WB,e.__scopePopover),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(YB,{...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()}})}),YB=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=PB(WB,n),p=MB(n);return Kj(),(0,L.jsx)(Hz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(Az,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,L.jsx)(bB,{"data-state":eV(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)`}})})})}),XB=`PopoverClose`,ZB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=PB(XB,n);return(0,L.jsx)(bD.button,{type:`button`,...r,ref:t,onClick:xz(e.onClick,()=>i.onOpenChange(!1))})});ZB.displayName=XB;var QB=`PopoverArrow`,$B=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=MB(n);return(0,L.jsx)(xB,{...i,...r,ref:t})});$B.displayName=QB;function eV(e){return e?`open`:`closed`}var tV=FB,nV=LB,rV=zB,iV=UB,aV=GB;function oV({modal:e=!1,...t}){return(0,L.jsx)(tV,{modal:e,...t})}var sV=rV,cV=nV;function lV({children:e,side:t=`top`,align:n=`center`,sideOffset:r=6,className:i=``,...a}){return(0,L.jsx)(iV,{children:(0,L.jsx)(aV,{side:t,align:n,sideOffset:r,avoidCollisions:!0,collisionPadding:12,onEscapeKeyDown:e=>e.stopPropagation(),className:`${jj} ${Fj} rounded-lg outline-none ${i}`,...a,children:e})})}var uV=3e4,dV=45e3;function fV(e,t){return t?AbortSignal.any([t,AbortSignal.timeout(e)]):AbortSignal.timeout(e)}var pV=`text-[9px]`,mV={claude:`text-fg/75! size-[14px]! translate-y-0!`,codex:`text-fg/75! size-[12.75px]! translate-y-0!`};function hV(){let e=nt({queryKey:[`quota`],queryFn:()=>Y.quota(),staleTime:1e4}),t=nt({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4});return[`claude`,`codex`].some(n=>gV(e.data?.[n],t.data?.[n],e.isLoading))}function gV(e,t,n){return t===`signed-out`||!e&&n?!1:!!e&&e.status===`ok`&&e.windows.length>0}function _V(){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:fV(uV,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:fV(uV,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:fV(dV)}).then(t=>e.setQueryData([`quota`],t)),e.refetchQueries({queryKey:[`authStatus`]})]).then(()=>{}).catch(()=>{}).finally(()=>{t.current=null,r(!1)});t.current=i};return(0,L.jsxs)(`div`,{"data-quota-bar":!0,className:`flex shrink-0 items-center gap-3 ${pV}`,children:[(0,L.jsx)(vV,{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)(vV,{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 vV({backend:e,quota:t,auth:n,email:r,loading:i,fetching:a,onRecheck:o}){let s=ER[e];if(!gV(t,n,i))return null;let c=yV(100-xV(t.windows).usedPercent);return(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(oV,{onOpenChange:e=>{e&&o()},children:[(0,L.jsx)(sV,{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)(vz,{backend:e,className:mV[e]}),(0,L.jsxs)(`span`,{className:`tabular-nums ${SV(c)}`,children:[c,`%`]})]})}),(0,L.jsxs)(lV,{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)(vz,{backend:e}),(0,L.jsx)(`span`,{children:s}),t?.planType&&(0,L.jsxs)(`span`,{className:`text-muted/70`,children:[`· `,CV(t.planType),` plan`]}),a&&(0,L.jsx)(Mm,{size:11,className:`animate-spin text-muted/60`,"aria-label":`Rechecking`})]}),r&&(0,L.jsx)(`div`,{"data-quota-account":!0,className:`truncate text-muted/70 select-text`,title:r,children:r})]}),(0,L.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[t.windows.map(e=>{let t=yV(100-e.usedPercent),n=wV(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:SV(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 yV(e){return Math.max(0,Math.min(100,Math.round(e)))}var bV=25;function xV(e){return e.find(e=>e.key===`5h`)??e.reduce((e,t)=>t.usedPercent>e.usedPercent?t:e)}function SV(e){return e<=8?`text-red-400`:e<=bV?`text-accent`:`text-fg/70`}function CV(e){return e&&e[0].toUpperCase()+e.slice(1)}function wV(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 TV=`frizz:supervisor-status-wake`;function EV(e){return e!==null}function DV(e){return e?.updateRestart===!0&&e.updateAvailable!==!1}function OV(e){return e?.dev===!0}async function kV(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 AV(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 jV(e=fetch){return AV(`/_frizz/control/restart`,e)}function MV(e=fetch){return AV(`/_frizz/control/update-restart`,e)}var NV=8e3,PV=500,FV=[`supervisorStatus`];function IV(e,t){return e===`restarting`||t?PV:NV}var LV=rt({queryKey:FV,queryFn:()=>kV(),refetchInterval:e=>IV(e.state.data?.state,X.controlPlaneRestartPending),staleTime:e=>IV(e.state.data?.state,X.controlPlaneRestartPending)});function RV(){return nt(LV)}var zV=null;function BV(e){zV||(zV=e,window.addEventListener(TV,()=>{e.refetchQueries({queryKey:FV,exact:!0})}))}var VV=`Install the latest version of Frizz. Your running threads will not be affected.`,HV=`A newer version of Frizz is available. Your running threads will not be affected.`,UV=`Restart Frizz. Your running threads will not be affected.`,WV=`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)]`,GV=`absolute -top-[7px] left-4 h-3 w-3 rotate-45 border-l border-t bg-elevated`,KV=`sm:w-[min(23rem,calc(100vw-1.5rem))]`,qV=`sm:w-[min(34rem,calc(100vw-1.5rem))]`,JV=`rounded-xl bg-elevated p-3.5 shadow-xl shadow-black/45`;function YV({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:`${WV} ${KV} ${JV} border border-border-strong`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${GV} border-border-strong`}),(0,L.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,L.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-fg/10 text-fg`,children:(0,L.jsx)(Gm,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,L.jsx)(`span`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:i}),n&&(0,L.jsx)(`span`,{className:`font-mono text-[11px] leading-snug text-muted`,children:a?`${n} → ${a}`:n})]})]}),(0,L.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:t?a?HV:VV:UV})]})}var XV=`Frizz kept running the previous version, and your threads are unaffected.`;function ZV({update:e,message:t,onDismiss:n}){return(0,L.jsxs)(`div`,{role:`alert`,className:`${WV} ${qV} ${JV} border border-red-500/45`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${GV} border-red-500/45`}),(0,L.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,L.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-red-500/15 text-red-300`,children:(0,L.jsx)(rh,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,L.jsx)(`span`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:e?`Update failed`:`Restart failed`}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,onClick:n,className:`-mr-1 ml-auto flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-border-strong`,children:(0,L.jsx)(ah,{"aria-hidden":`true`,size:14,strokeWidth:2.25})})]}),(0,L.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:XV}),(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 QV({update:e,busy:t,updateVersion:n,onFocus:r,onBlur:i,onClick:a}){return(0,L.jsxs)(`button`,{type:`button`,"aria-describedby":`update-restart-popover`,"aria-label":e?`Update Frizz`:`Restart Frizz`,disabled:t,"aria-busy":t||void 0,className:`relative ${mz}`,onFocus:r,onBlur:i,onClick:a,children:[(0,L.jsx)(Gm,{size:14,"aria-hidden":`true`,className:t?`animate-spin`:void 0}),e&&!t&&n&&(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-[2px] top-[2px] h-[4px] w-[4px] rounded-full bg-accent`})]})}function $V(){let e=Zt(X),[t,n]=(0,I.useState)(!1),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(),[s,c]=(0,I.useState)(),l=(0,I.useRef)(!1),u=(0,I.useRef)(null),d=RV().data??null,f=DV(d),p={version:d?.version,updateVersion:d?.updateVersion};if(!EV(d))return null;let m=l.current&&e.controlPlaneState===`failed`?e.controlPlaneMessage??`Frizz did not become ready`:void 0,h=a??m,g=h&&h!==s?h:void 0,_=async()=>{if(r)return;l.current=!0,n(!1),i(!0),o(void 0),c(void 0);let e=`${window.location.pathname}${window.location.search}${window.location.hash}`;f&&(X.controlPlaneState=`restarting`,X.controlPlaneMessage=null,X.controlPlaneRestartPending=!0);try{f?await MV():await jV(),f?(sessionStorage.setItem(`frizz:reload-after-update-restart`,e),window.dispatchEvent(new Event(TV)),i(!1)):window.location.replace(e)}catch(e){f&&(X.controlPlaneRestartPending=!1,X.controlPlaneState=`ready`,X.controlPlaneMessage=null);let t=e.message.slice(0,140);i(!1),o(t),Z(`${f?`Update & Restart`:`Restart Frizz`} failed`)}};return(0,L.jsxs)(`div`,{ref:u,className:`relative`,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[(0,L.jsx)(QV,{update:f,busy:r,updateVersion:p.updateVersion,onFocus:()=>n(!0),onBlur:()=>n(!1),onClick:()=>void _()}),g&&(0,L.jsx)(ZV,{update:f,message:g,onDismiss:()=>c(g)}),(0,L.jsx)(YV,{open:t&&!g,update:f,version:p.version,updateVersion:p.updateVersion})]})}function eH(){return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px shrink-0 bg-border`})}function tH({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 nH(){let e=kC(),t=NU(e),n=hV(),r=e?.githubRepo??null,i=t.state===`verified`?t.label:t.state===`local`?t.name:null,a=t.state===`verified`?`Project: ${t.label}`:t.state===`local`?`Project: ${t.name}; local repository with no git remote`:t.state===`loading`?`Project identity loading`:`Project identity unavailable`;return(0,L.jsxs)(`div`,{"data-status-row":!0,className:`mb-2.5 flex min-w-0 items-center gap-3 text-[12px]`,children:[(0,L.jsx)(fb,{to:`/`,title:`All projects`,"aria-label":`All projects`,className:`${mz} -ml-px`,children:(0,L.jsx)(Em,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(eH,{}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Settings`,title:`Settings`,className:mz,onClick:()=>X.showSettings=!0,children:(0,L.jsx)(Ym,{size:14,"aria-hidden":`true`})}),(0,L.jsx)($V,{}),n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(eH,{}),(0,L.jsx)(_V,{})]}),(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)(tH,{text:i})}):i?(0,L.jsx)(tH,{text:i,title:i,className:`font-semibold text-fg/90`}):(0,L.jsx)(`span`,{className:`identity-placeholder w-24`,"aria-hidden":`true`})})]})}var rH=qt({at:{}}),iH=12e3,aH=new Map;function oH(e,t=Date.now()){rH.at[e]=t;let n=aH.get(e);n!==void 0&&clearTimeout(n),aH.set(e,setTimeout(()=>{aH.delete(e),delete rH.at[e]},iH))}function sH(e){let t=aH.get(e);t!==void 0&&(clearTimeout(t),aH.delete(e)),delete rH.at[e]}function cH(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 lH(){return Zt(rH).at}function uH(e,t,n=Date.now()){return t===void 0||!cH(e,t,n)?e:{...e,runtime:`running`,needsYou:!1,pendingAsk:void 0,pendingQuestion:!1,actionableInteraction:!1,lastUserAt:new Date(t).toISOString()}}function dH(e){let t=lH();return(0,I.useMemo)(()=>e.map(e=>uH(e,t[e.id])),[e,t])}var fH=0;function pH(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(fH+=1,`browser-${Date.now()}-${fH}`)}function mH({optimistic:e,request:t,success:n,failure:r}){e(),t().then(()=>n?.(),e=>r(e instanceof Error?e:Error(String(e))))}var hH=new Map;function gH(e,t){let n=(hH.get(e)??Promise.resolve()).then(t,t);return hH.set(e,n.then(()=>{},()=>{})),n}var _H=[300,800,1800,3500],vH=12e4,yH=e=>new Promise(t=>{setTimeout(t,e)});async function bH(e,t,n=yH){for(let r=0;;r++){try{await e()}catch(e){if(r>=_H.length||!lf(e))throw e;t(),await n(_H[r]);continue}t();return}}function xH(e,t,n,r,i,a=vH){let o=new AbortController,s=setTimeout(()=>o.abort(Error(`Frizz did not answer this send`)),a);return Y.followUp({slug:e,sessionId:Dp(X.board,e)?.sessionId??``,message:t,deliveryId:n,freshProcess:r,interrupt:i},{signal:o.signal}).finally(()=>clearTimeout(s))}function SH(e,t,n,r,i){return bH(()=>xH(e,t,n,r,i),()=>oH(e))}function CH(e,t,n,r={}){let i=n.trim();if(!i)return!1;let a=pH();return mH({optimistic:()=>{r.onOptimistic?.(),qC(e,t,i,{scrollToBottom:r.scrollToBottom,deliveryId:a}),oH(t),Y.markRead({slug:t}).catch(()=>{})},request:()=>gH(t,()=>SH(t,i,a,r.freshProcess,r.interrupt)),success:()=>r.onSuccess?.(),failure:n=>{JC(e,t,i,a),sH(t),r.onRollback?.(),Z(r.failureToast?.(n.message)??`Steer failed — ${n.message.slice(0,90)}`)}}),!0}function wH(e){let t=Ve(),[n,r]=(0,I.useState)(0);return{submit:(0,I.useCallback)((n,i={})=>CH(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 TH(e,t){return new Promise(n=>{CH(e,t,`Continue exactly where you left off.`,{onSuccess:()=>{Z(`Retrying…`),n()},onRollback:()=>n(),failureToast:e=>`Retry failed: ${e.slice(0,80)}`})||n()})}function EH(e){let t=/^([A-Za-z0-9][\w.-]*)\/([A-Za-z0-9][\w.-]*)#(\d+)$/.exec(e.trim());return t?`https://github.com/${t[1]}/${t[2]}/pull/${t[3]}`:null}var DH=`Waiting for an external update.`;function OH(e){let t=new Set;return e.flatMap(e=>{if(e.kind!==`pr`)return[];let n=e.value.trim();return!n||t.has(n)?[]:(t.add(n),[{ref:n,url:EH(n)}])})}function kH(e){let t=(e.body??``).split(/\n\s*\n/).map(e=>e.trim()).find(Boolean);return t?MH(AH(t.replace(/\s*\n\s*/g,` `))):null}function AH(e){if(e.length<=jH)return e;let t=e.slice(0,jH),n=t.lastIndexOf(` `);return`${(n>jH/2?t.slice(0,n):t).replace(/[.,;:]$/,``)}…`}var jH=240;function MH(e){let t=(e.split(/\s/,1)[0]??``).replace(/[.,:;]+$/,``);return/[^a-zA-Z]/.test(t)||/[A-Z]/.test(t.slice(1))||NH.has(t)?e:e.charAt(0).toUpperCase()+e.slice(1)}var NH=new Set([`npm`,`npx`,`pnpm`,`nub`,`nubx`,`gh`,`git`,`node`,`bun`,`tsc`,`vite`,`curl`,`ssh`]);function PH(e){return e&&IH(e)||null}var FH=new Set([...rl,`shells`,`agents`,`timers`,`prs`,`for`,`title`]);function IH(e){return e.split(`
200
- `).filter(e=>{let t=/^\s*([a-z][a-z-]*):/i.exec(e)?.[1]?.toLowerCase();return!(t&&FH.has(t))}).join(`
201
- `).trim()}function LH(e){let t=t=>e.filter(e=>e.kind===t&&e.value.trim()).length,n=[...OH(e).map(e=>e.ref),RH(t(`shell`),`background shell`,`background shells`),RH(t(`agent`),`sub-agent`,`sub-agents`),RH(t(`timer`),`timer`,`timers`)].filter(e=>e!==null);return n.length>0?`waiting on ${zH(n)}`:null}function RH(e,t,n){return e<=0?null:e===1?`a ${t}`:`${e} ${n}`}function zH(e){return e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function BH(e){let t=e.find(e=>e.kind===`pr`);return t?`PR ${t.value}`:null}var VH=qt({at:{}}),HH=12e3,UH=new Map;function WH(e,t=Date.now()){VH.at[e]=t;let n=UH.get(e);n!==void 0&&clearTimeout(n),UH.set(e,setTimeout(()=>{UH.delete(e),delete VH.at[e]},HH))}function GH(e){let t=UH.get(e);t!==void 0&&(clearTimeout(t),UH.delete(e)),delete VH.at[e]}function KH(){return Zt(VH).at}function qH(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 JH(e){let t=KH();return(0,I.useMemo)(()=>e.map(e=>qH(e,t[e.id])),[e,t])}var YH=.5;function XH(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*YH,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 ZH(e,t,n,r){return!e||e.top<=r&&e.bottom>r?!0:Math.abs(t-n)>1}function QH(e,t,n,r,i=8){return n<e+i?n-e-i:r>t-i?r-t+i:0}var $H=`flex h-[19px] w-[19px] items-center justify-center rounded text-muted/70 outline-none transition-colors hover:bg-panel-2 hover:text-fg`,eU=`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 tU(){let e=Zt(X),t=JH(dH(jC(kC()?.threads??[]))),n=VT(t,Zt(tT).queueOrder),r=vT(xT(t)),i=e.sidebarCollapsed,a=n.active,o=n.snoozed,s=n.inactive,c=(0,I.useRef)(null),[l,u]=(0,I.useState)(null),d=(0,I.useRef)(null),f=(0,I.useCallback)(()=>{let e=[...document.querySelectorAll(`[data-queue-card][data-queue-leaving="false"]`)].map(e=>{let t=e.dataset.queueCard;if(!t)return null;let{top:n,bottom:r}=(e.querySelector(`[data-queue-card-root]`)??e).getBoundingClientRect();return{id:t,top:n,bottom:r}}).filter(e=>e!==null),t=d.current;if(t)if(ZH(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=XH(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=QH(n.top,n.bottom,r.top,r.bottom);Math.abs(i)>.5&&(e.scrollTop+=i)},[l]);let p=(0,I.useCallback)(e=>{d.current={id:e,landedY:Uf(e)??window.scrollY},u(e)},[]);return(0,L.jsx)(`aside`,{className:eU,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)(nH,{}),(0,L.jsx)(dz,{})]}),(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)(lU,{t:e,active:l===e.id,onQueueNavigate:p}),(0,L.jsx)(mU,{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}=BT(a),n=e=>t=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(lU,{t,active:l===t.id,onQueueNavigate:p,restedAge:e}),(0,L.jsx)(mU,{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)(nU,{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)(lU,{t:e,active:l===e.id,onQueueNavigate:p}),(0,L.jsx)(mU,{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)(nU,{label:`Done`,count:s.length,collapsed:i.inactive,onToggle:()=>X.sidebarCollapsed.inactive=!X.sidebarCollapsed.inactive}),!i.inactive&&(0,L.jsx)(aU,{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)(nU,{label:`External`,count:r.length,collapsed:i.external,onToggle:()=>X.sidebarCollapsed.external=!X.sidebarCollapsed.external}),!i.external&&r.map(e=>(0,L.jsx)(lU,{t:e,active:l===e.id,onQueueNavigate:p,restedAge:!0},e.id))]})]})]})})}function nU({label:e,count:t,collapsed:n,onToggle:r}){let i=(0,L.jsxs)(L.Fragment,{children:[r?(0,L.jsx)(tm,{size:11,className:`transition-transform ${n?``:`rotate-90`}`}):(0,L.jsx)(`span`,{className:`w-[11px] shrink-0`,"aria-hidden":!0}),(0,L.jsx)(`span`,{children:e}),(0,L.jsx)(`span`,{className:`ml-1.5 tabular-nums text-muted/60`,children:t})]}),a=`flex w-full items-center gap-1 px-1.5 py-1 text-[11px] uppercase tracking-wide text-muted/70`;return r?(0,L.jsx)(`button`,{onClick:r,className:`${a} transition-colors hover:text-fg`,children:i}):(0,L.jsx)(`div`,{className:a,children:i})}var rU=27,iU=8;function aU({threads:e,railRef:t,activeId:n,onQueueNavigate:r}){let i=(0,I.useRef)(null),[a,o]=(0,I.useState)(0),s=jw({count:e.length,getScrollElement:()=>t.current,getItemKey:t=>e[t]?.id??t,estimateSize:()=>rU,overscan:iU,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)(lU,{t:i,active:n===i.id,onQueueNavigate:r}),(0,L.jsx)(mU,{t:i})]},i.id):null})})}var oU=16,sU=12;function cU({title:e,children:t}){let n=e.trimEnd(),r=n.lastIndexOf(` `)+1,i=n.length-r<=oU?r:n.length-sU;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 lU=(0,I.memo)(function({t:e,legacy:t,active:n=!1,onQueueNavigate:r,restedAge:i=!1}){let a=!t&&e.foreign===!0,o=!t&&OT(e),s=!t&&fT(e),c=!t&&IT(e),l=!t&&ST(e);return(0,L.jsxs)(`div`,{"data-sidebar-item":e.id,className:`group relative flex min-w-0 items-start rounded-md transition-[color,opacity] after:pointer-events-none after:absolute after:inset-0 after:rounded-md after:bg-white/[0.04] after:opacity-0 after:transition-opacity hover:after:opacity-100 ${t?`opacity-80`:o?`opacity-65 hover:opacity-90 focus-within:opacity-90`:``}`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,"data-sidebar-marker-rail":!0,className:`pointer-events-none absolute inset-y-0 left-0 w-5`,children:n&&(0,L.jsx)(`span`,{"data-sidebar-scroll-marker":!0,className:`absolute inset-y-0 left-1 w-[2px] rounded-full bg-accent`})}),(0,L.jsxs)(`button`,{onClick:()=>{if(e.needsYou&&sp(e.id)){r?.(e.id);return}np(e.id)},"aria-current":n?`location`:void 0,className:`min-w-0 flex-1 flex items-start gap-2 pb-1 pl-5 pr-1.5 pt-1 text-left`,children:[(0,L.jsx)(`span`,{className:`w-4 h-[19px] shrink-0 flex items-center justify-center`,children:(0,L.jsx)(yU,{t:e,legacy:t})}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 flex flex-col`,children:(0,L.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-3`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-[13px] leading-[19px] ${s?`text-fg/50`:o?`text-fg/75`:`text-fg/90`}`,children:(0,L.jsxs)(cU,{title:aT(e),children:[!t&&(0,L.jsx)(vz,{backend:e.backend,className:`ml-1`}),a&&(0,L.jsx)(`span`,{className:`petite-caps ml-1.5 inline-block rounded border border-border/60 px-1 align-[2px] text-[9.5px] leading-[14px] text-muted/55`,title:`Read-only — running in an external terminal`,children:`terminal`}),t&&(0,L.jsx)(hU,{status:e.archived?`archived`:e.status})]})}),i&&(0,L.jsx)(uU,{t:e,yieldsToRetry:!0}),l&&!i&&(0,L.jsx)(fU,{})]})})]}),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)(DI,{slug:e.id,size:`sm`})}),!t&&(0,L.jsxs)(`div`,{className:`absolute right-1.5 top-1 hidden items-center gap-0.5 bg-bg group-hover:flex group-focus-within:flex before:pointer-events-none before:absolute before:inset-y-0 before:right-full before:w-3 before:bg-linear-to-r before:from-transparent before:to-bg`,children:[!a&&!l&&(0,L.jsx)(pU,{t:e,className:`-mr-0.5`}),(0,L.jsx)(Rj,{slug:e.id,size:12,className:$H}),c&&(0,L.jsx)(dU,{slug:e.id}),!a&&l&&(0,L.jsx)(pU,{t:e})]})]})});function uU({t:e,yieldsToRetry:t}){let n=oE(),r=gT(e),i=qT(r,n);return!r||!i?null:(0,L.jsx)(`time`,{dateTime:r,"data-rail-rested-age":!0,title:WT(r,n)??void 0,"aria-label":`Rested ${WT(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 dU({slug:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return(0,L.jsx)(Lj,{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),TH(t,e).finally(()=>r(!1))},className:`${$H} disabled:opacity-50`,children:n?(0,L.jsx)(Mm,{size:13,className:`animate-spin`}):(0,L.jsx)(qm,{size:13})})})}function fU(){return(0,L.jsx)(`span`,{"aria-hidden":!0,"data-rail-pin-mark":!0,className:`-ml-1 flex h-[19px] w-[19px] shrink-0 items-center justify-center self-start text-muted/55 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0`,children:(0,L.jsx)(Hm,{size:12,fill:`currentColor`})})}function pU({t:e,className:t=``}){let n=ST(e),[r,i]=(0,I.useState)(!1);return(0,L.jsx)(Lj,{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:`${$H} disabled:opacity-50 ${t}`,children:n?(0,L.jsx)(Vm,{size:12,fill:`currentColor`}):(0,L.jsx)(Hm,{size:12})})})}function mU({t:e}){let t=BE(e.subAgents??[],`rail`);return t.length===0?null:(0,L.jsx)(`div`,{className:`flex flex-col`,children:t.map(t=>(0,L.jsx)(UE,{kind:`AGENT`,label:t.label,state:t.state,density:`rail`,depth:t.depth,startedAt:t.startedAt,parentSlug:e.id,onOpen:()=>ep(e.id,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}),onDismiss:Bj(e.id,t),title:t.subagentType?`[${t.subagentType}] ${t.label}`:t.label},t.id))})}function hU({status:e}){let t=e===`archived`?`Done`:e;return(0,L.jsx)(`span`,{className:`petite-caps ml-1.5 inline-block rounded border px-1 align-[2px] leading-[14px] text-[9.5px] ${iT[e]??`text-muted border-border`}`,children:t})}function gU(e,t){return[[t,LH(e.lastFence?.kind===`awaiting`?e.lastFence.hints:[])].filter(e=>!!e).join(` — `),_U(e)].filter(e=>!!e).join(`
197
+ `)})}return!i.length||!i.every(e=>xL(n,e.token))?null:{body:n,items:i}}function NL(e){return e.key===`Enter`&&!e.altKey&&!e.shiftKey&&!e.isComposing&&e.keyCode!==229}function PL(e,t){return t&&NL(e)&&!e.metaKey&&!e.ctrlKey}function FL(e,t){return t&&NL(e)&&(e.metaKey||e.ctrlKey)}function IL(e){return NL(e)}function LL(e){return e.key===`Enter`&&e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing}function RL(e,t,n){return e===`queueComposer`&&t===`Enter`&&n}var zL=`gap-3`,BL=`-mx-1`,VL=`-mx-[3px]`,HL=`right-2`,UL=`right-[71px]`,WL=`right-[44px]`,GL=`pr-[6.6875rem]`,KL=`pr-20`;async function qL(e,t){let n=Nd(),r=await e.arrayBuffer(),i=``,a=new Uint8Array(r);for(let e=0;e<a.length;e+=32768)i+=String.fromCharCode(...a.subarray(e,e+32768));let o=await fetch(`${n}/attach`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:t,data:btoa(i)})});return o.ok?(await o.json()).path??null:null}var JL={project:`project`,user:`global`,builtin:`built-in`,plugin:`plugin`};function YL(e,t){e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,t)}px`}function XL({value:e,onChange:t,onSubmit:n,surface:r,placeholder:i,id:a,minHeight:o=44,maxHeight:s=220,autoFocus:c,busy:l,footer:u,leftAction:d,contextTokens:f,slashSuggest:p,onInterruptSubmit:m}){let h=(0,I.useRef)(null),g=(0,I.useRef)(null),_=(0,I.useRef)(null),[v,y]=(0,I.useState)(!1),[b,x]=(0,I.useState)(!1),{prose:S,attachments:C}=(0,I.useMemo)(()=>hL(e),[e]),w=C.map(e=>e.path),T=(0,I.useRef)(e);T.current=e;let E=e=>t(gL(e,w)),D=e=>t(gL(S,e));async function O(e){if(!e)return;if(b){Z(`An upload is already in progress — try again in a moment`);return}let n=[...e].map(e=>{let t=e.type.startsWith(`image/`)?e.type.slice(6).toLowerCase():``,n=t===`jpeg`?`jpg`:t===`svg+xml`?`svg`:t;return{file:e,name:e.name||(n?`pasted.${n}`:``)}}).filter(({name:e})=>Vc(e)?!0:(Z(`${e||`File`}: unsupported file type`),!1));if(!n.length)return;let r=n.filter(({file:e,name:t})=>e.size>Rc?(Z(`${t} is too large (max ${Math.floor(Rc/1e6)} MB)`),!1):!0);if(!r.length)return;let i=T.current;x(!0);let a=[];try{for(let{file:e,name:t}of r){let n=await qL(e,t);n?a.push(n):Z(`Could not attach ${t}`)}}finally{x(!1)}if(a.length&&i!==``&&T.current===``){Z(`Attachment discarded — the message was sent before the upload finished`),requestAnimationFrame(()=>h.current?.focus());return}if(a.length){let e=hL(T.current);t(gL(e.prose,[...e.attachments.map(e=>e.path),...a]))}requestAnimationFrame(()=>h.current?.focus())}(0,I.useLayoutEffect)(()=>{let e=!0,t=()=>{let t=h.current;!t||!e||YL(t,s)};t();let n=requestAnimationFrame(t);document.fonts?.ready.then(t);let r=h.current,i=r?.clientWidth??0,a,o=r?new ResizeObserver(([e])=>{let n=Math.round(e.contentRect.width);n!==i&&(i=n,a!==void 0&&cancelAnimationFrame(a),a=requestAnimationFrame(t))}):void 0;return r&&o?.observe(r),()=>{e=!1,cancelAnimationFrame(n),a!==void 0&&cancelAnimationFrame(a),o?.disconnect()}},[e,s,!!u]);let k=(0,I.useMemo)(()=>f??[],[f]),A=(0,I.useMemo)(()=>{if(k.length===0)return null;let e=TL(S,k);return e.some(e=>e.token)?e.map((e,t)=>e.token?(0,L.jsx)(`span`,{className:`rounded bg-panel-2 py-0.5 -mx-0.5 px-0.5 ring-1 ring-inset ring-border`,children:e.text},t):e.text):null},[S,k]),j=()=>{let e=h.current,t=g.current;e&&t&&(t.scrollTop=e.scrollTop)};(0,I.useLayoutEffect)(j);let M=(0,I.useRef)(!1);(0,I.useEffect)(()=>{let e=h.current;if(!e)return;let t=()=>{M.current=e.disabled};return e.addEventListener(`focusout`,t),()=>e.removeEventListener(`focusout`,t)},[]),(0,I.useEffect)(()=>{if(l||!M.current)return;M.current=!1;let e=h.current,t=document.activeElement;e&&(!t||t.contains(e))&&e.focus({preventScroll:!0})},[l]);let[N,P]=(0,I.useState)(null),[ee,F]=(0,I.useState)({prose:``,index:0}),te=ee.prose===S?ee.index:0,ne=e=>F({prose:S,index:typeof e==`function`?e(te):e}),[re,ie]=(0,I.useState)(null),ae=!!p&&/^\/\S*$/.test(S);(0,I.useEffect)(()=>{if(!ae||N!==null)return;let e=!0;return p().then(t=>{e&&P(t)},()=>{e&&P([])}),()=>{e=!1}},[ae,N,p]);let oe=(0,I.useMemo)(()=>{if(!ae||!N||re===S)return[];let e=S.slice(1).toLowerCase(),t=N.filter(t=>t.name.toLowerCase().startsWith(e)),n=N.filter(t=>!t.name.toLowerCase().startsWith(e)&&t.name.toLowerCase().includes(e));return[...t,...n]},[ae,N,re,S]),se=oe.length>0,ce=(0,I.useMemo)(()=>{let e=new Set;for(let t of oe)t.source&&e.add(JL[t.source]);return[...e]},[oe]),le=(0,I.useRef)(null);(0,I.useEffect)(()=>{le.current?.querySelector(`[data-suggest-index="${te}"]`)?.scrollIntoView({block:`nearest`})},[te]);function ue(e){let t=`/${e.name} `;E(t),requestAnimationFrame(()=>h.current?.setSelectionRange(t.length,t.length))}let de=e.trim().length>0,fe=d??null;function pe(e){let t=e.currentTarget,i={key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.keyCode};if(se&&!e.nativeEvent.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),ne(t=>(t+(e.key===`ArrowDown`?1:-1)+oe.length)%oe.length);return}if((e.key===`Enter`||e.key===`Tab`)&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey){e.preventDefault(),e.stopPropagation(),ue(oe[te]??oe[0]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),ie(S);return}}if(e.key===`Backspace`&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&k.length>0&&t.selectionStart===t.selectionEnd){let n=t.selectionStart,r=TL(t.value.slice(0,n),k).at(-1);if(r?.token){e.preventDefault();let i=n-r.text.length;E(t.value.slice(0,i)+t.value.slice(n)),requestAnimationFrame(()=>t.setSelectionRange(i,i));return}}if(RL(r,e.key,e.altKey)){e.preventDefault(),e.stopPropagation();let n=t.selectionStart??t.value.length,r=t.selectionEnd??n;E(t.value.slice(0,n)+`
198
+ `+t.value.slice(r)),requestAnimationFrame(()=>t.setSelectionRange(n+1,n+1));return}let a=de&&!l&&!b;if(PL(i,a)){e.preventDefault(),e.stopPropagation(),n();return}if(FL(i,a)){e.preventDefault(),e.stopPropagation(),(m??n)();return}if(LL(i)){let e=t.value,n=t.selectionStart??e.length,r=t.selectionEnd??n;requestAnimationFrame(()=>{t.value===e&&(E(e.slice(0,n)+`
199
+ `+e.slice(r)),requestAnimationFrame(()=>t.setSelectionRange(n+1,n+1)))})}e.key===`Escape`&&!e.nativeEvent.isComposing&&(e.preventDefault(),e.stopPropagation(),t.blur())}return(0,L.jsxs)(`div`,{className:`group relative rounded-xl border bg-bg transition-colors focus-within:border-accent ${v?`border-dashed border-accent`:`border-border`}`,onDragOver:e=>{[...e.dataTransfer.items].some(e=>e.kind===`file`)&&(e.preventDefault(),y(!0))},onDragLeave:()=>y(!1),onDrop:e=>{e.preventDefault(),y(!1),O(e.dataTransfer.files)},children:[v&&(0,L.jsx)(`div`,{className:`pointer-events-none absolute inset-0 z-10 flex items-center justify-center rounded-xl bg-bg/80 text-[12px] text-muted`,children:`Drop file to attach`}),se&&(0,L.jsx)(`div`,{ref:le,"data-slash-menu":!0,className:`absolute bottom-full left-0 right-0 z-20 mb-1.5 max-h-56 overflow-y-auto rounded-lg border border-border bg-bg py-1 shadow-lg`,children:oe.map((e,t)=>(0,L.jsxs)(`button`,{type:`button`,"data-suggest-index":t,onMouseDown:e=>e.preventDefault(),onClick:()=>ue(e),onMouseEnter:()=>ne(t),className:`flex w-full items-baseline gap-2 px-3.5 py-1.5 text-left ${t===te?`bg-panel-2`:``}`,children:[(0,L.jsxs)(`span`,{className:`shrink-0 text-[12px] font-medium text-fg`,children:[`/`,e.name]}),e.description&&(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-muted`,children:e.description}),ce.length>0&&(0,L.jsxs)(`span`,{className:`ml-auto grid shrink-0 text-[10px]`,children:[ce.map(e=>(0,L.jsx)(`span`,{"aria-hidden":!0,className:`petite-caps invisible col-start-1 row-start-1`,children:e},e)),(0,L.jsx)(`span`,{className:`petite-caps col-start-1 row-start-1 text-right text-muted/70`,children:e.source?JL[e.source]:``})]})]},e.name))}),(0,L.jsxs)(`div`,{className:`relative`,children:[A&&(0,L.jsx)(`div`,{ref:g,"aria-hidden":!0,"data-composer-context-backdrop":!0,className:`pointer-events-none absolute inset-0 select-none overflow-hidden whitespace-pre-wrap [overflow-wrap:break-word] px-3.5 ${u?`py-2.5 pb-3`:`py-2.5 ${fe?`pr-[6.6875rem]`:`pr-20`}`} text-[13px] leading-relaxed text-transparent`,children:A}),(0,L.jsx)(`textarea`,{id:a,ref:h,onScroll:A?j:void 0,"data-surface":r,value:S,autoFocus:c,disabled:l,onChange:e=>E(e.target.value),onKeyDown:pe,onPaste:e=>{let t=[...e.clipboardData.items].filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(Boolean);t.length&&(e.preventDefault(),O(t))},placeholder:i,rows:1,spellCheck:!1,style:{minHeight:o,maxHeight:s},className:`relative block w-full resize-none bg-transparent px-3.5 ${u?`py-2.5 pb-3`:`py-2.5 ${fe?GL:KL}`} text-[13px] leading-relaxed text-fg outline-none placeholder:text-muted scrollbar-none disabled:opacity-60`})]}),C.length>0&&(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-3 pb-2 ${fe?`pr-[6.6875rem]`:`pr-20`}`,children:C.map((e,t)=>(0,L.jsx)(ZL,{attachment:e,disabled:l,onRemove:()=>D(w.filter((e,n)=>n!==t))},`${e.path}-${t}`))}),u&&(0,L.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1 pl-1.5 pb-1.5 ${fe?`pr-[6.6875rem]`:`pr-20`}`,children:u}),fe&&(0,L.jsx)(`div`,{className:`absolute bottom-2 right-[43px] flex items-center`,children:fe}),(0,L.jsx)(`input`,{ref:_,type:`file`,multiple:!0,accept:Hc,className:`hidden`,onChange:e=>{O(e.target.files),e.target.value=``}}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>_.current?.click(),disabled:l||b,title:`Attach files`,"aria-label":`Attach files`,className:`absolute bottom-2 ${fe?UL:WL} flex h-7 w-7 items-center justify-center rounded-lg text-muted transition-[color,background-color] enabled:hover:bg-panel-2/70 enabled:hover:text-fg disabled:opacity-50`,children:b?(0,L.jsx)(Mm,{size:15,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(Bm,{size:15,strokeWidth:2})}),(0,L.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:n,disabled:!de||l||b,title:`Send (Enter · ⌘⏎ sends now)`,"aria-label":`Send`,className:`absolute bottom-2 ${HL} flex h-7 w-7 items-center justify-center rounded-lg transition-all ${de&&!l&&!b?`bg-fg text-bg hover:opacity-90 active:scale-95`:`bg-panel-2 text-muted`}`,children:l?(0,L.jsx)(Mm,{size:14,strokeWidth:2.5,className:`animate-spin`}):(0,L.jsx)(Jp,{size:14,strokeWidth:2.5})})]})}function ZL({attachment:e,disabled:t,onRemove:n}){let[r,i]=(0,I.useState)(!1),a=e.path.split(`/`).filter(Boolean).pop()||e.path,o=(a.includes(`.`)?a.split(`.`).pop():``).toUpperCase();return(0,L.jsxs)(`div`,{className:`group/att relative h-11 w-11`,title:a,children:[e.kind===`image`&&!r?(0,L.jsx)(`img`,{src:jS(e.path),alt:a,onError:()=>i(!0),className:`h-11 w-11 rounded-md border border-border object-cover`}):(0,L.jsxs)(`div`,{className:`flex h-11 w-11 flex-col items-center justify-center gap-0.5 rounded-md border border-border bg-panel-2 px-1`,children:[(0,L.jsx)(gm,{size:15,strokeWidth:2,className:`shrink-0 text-muted`}),o&&(0,L.jsx)(`span`,{className:`-mx-1 max-w-[calc(100%+0.5rem)] truncate text-[8px] font-medium leading-none text-muted/80`,children:o})]}),(0,L.jsx)(`button`,{type:`button`,onClick:n,disabled:t,title:`Remove ${a}`,"aria-label":`Remove ${a}`,className:`absolute -right-1.5 -top-1.5 flex h-4 w-4 items-center justify-center rounded-full border border-border bg-bg text-muted opacity-0 transition-opacity hover:text-fg focus-visible:opacity-100 group-hover/att:opacity-100 disabled:hidden`,children:(0,L.jsx)(ah,{size:10,strokeWidth:2.5})})]})}function QL(){return nt({queryKey:[`githubStatus`],queryFn:()=>Y.githubStatus(),staleTime:3e4,refetchOnWindowFocus:!0,refetchInterval:e=>{let t=e.state.data;return t?.inRepo&&t.authed?!1:6e4}})}function $L(){let e=QL();return!!(e.data?.inRepo&&e.data.authed)}function eR({className:e=``}){return $L()?(0,L.jsx)(`button`,{type:`button`,onClick:Gf,onMouseDown:e=>e.preventDefault(),title:`Investigate this issue and make recommendations`,"aria-label":`Investigate this issue and make recommendations`,className:`flex h-7 w-7 items-center justify-center rounded-lg text-muted outline-none transition-[color,background-color,box-shadow] enabled:hover:bg-panel-2/70 enabled:hover:text-fg enabled:focus-visible:bg-panel-2/70 enabled:focus-visible:text-muted enabled:focus-visible:ring-1 enabled:focus-visible:ring-muted/80 enabled:focus-visible:ring-offset-1 enabled:focus-visible:ring-offset-bg enabled:active:bg-elevated enabled:active:text-muted disabled:bg-transparent disabled:text-muted/35 ${e}`,children:(0,L.jsx)(wm,{size:15,strokeWidth:2})}):null}var tR=`prompt-control-type petite-caps`,nR=tR,rR=tR,iR=`profile-grid-cell relative flex h-6 cursor-pointer select-none items-center justify-start rounded border border-transparent px-1 text-left text-muted outline-none transition-colors ${nR} data-[highlighted]:border-border data-[highlighted]:bg-panel-2 data-[highlighted]:text-fg data-[highlighted]:outline data-[highlighted]:outline-1 data-[highlighted]:outline-offset-1 data-[highlighted]:outline-fg/55 data-[state=checked]:border-accent/70 data-[state=checked]:bg-accent/10 data-[state=checked]:font-medium data-[state=checked]:text-fg data-[state=checked]:ring-1 data-[state=checked]:ring-inset data-[state=checked]:ring-accent/90`;function aR(e){return`minmax(6rem, 7rem) repeat(${Math.max(0,e)}, auto)`}var oR=[`ultra`,`ultracode`],sR=[`low`,`medium`,`high`,`xhigh`,`max`,...oR];function cR(e){return[...new Set(e.flatMap(e=>e.options.flatMap(e=>e.efforts)))].sort((e,t)=>{let n=sR.indexOf(e),r=sR.indexOf(t);return n===-1&&r===-1?e.localeCompare(t):n===-1?1:r===-1?-1:n-r})}function lR(e){let t=[];for(let n of cR(e)){let e=oR.includes(n)?t.find(e=>oR.includes(e[0])):void 0;e?e.push(n):t.push([n])}return t}function uR(e){return e.flatMap(e=>e.options.flatMap(t=>t.efforts.map(n=>({provider:e.id,model:t.model,effort:n}))))}function dR(e){return JSON.stringify([e.provider,e.model,e.effort])}function fR(e,t){return uR(e).find(e=>dR(e)===t)}function pR(e,t){return!t?.model||!t.effort?!1:e.some(e=>(!t.provider||e.id===t.provider)&&e.options.some(e=>e.model===t.model&&e.efforts.includes(t.effort)))}function mR(e,t,n=`Profile unknown`){if(!t?.model&&!t?.effort)return n;let r=e.flatMap(e=>e.options).find(e=>e.model===t.model)?.label??t.model??`Model unknown`;return t.effort?`${r} › ${t.effort}`:r}function hR(e,t,n){let r=lR(e),i=e=>r.findIndex(t=>t.includes(e)),a=e.flatMap(e=>e.options.map(t=>({provider:e.id,option:t}))),o=a.findIndex(e=>e.provider===t.provider&&e.option.model===t.model);if(o===-1)return null;let s=a[o],c=s.option.efforts.indexOf(t.effort);if(c===-1)return null;if(n===`Home`||n===`End`||n===`ArrowLeft`||n===`ArrowRight`){let e=n===`Home`?0:n===`End`?s.option.efforts.length-1:c+(n===`ArrowLeft`?-1:1),t=s.option.efforts[e];return t?{provider:s.provider,model:s.option.model,effort:t}:null}let l=a[o+(n===`ArrowUp`?-1:1)];if(!l)return null;let u=i(t.effort),d=l.option.efforts.reduce((e,t)=>e?Math.abs(i(t)-u)<Math.abs(i(e)-u)?t:e:t,void 0);return d?{provider:l.provider,model:l.option.model,effort:d}:null}var gR,_R=!1;function vR(){_R||typeof window>`u`||(_R=!0,window.addEventListener(`keydown`,e=>{e.key!==`Escape`||!gR||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),bR())},{capture:!0}))}function yR(e){vR();let t={dismiss:e};return gR=t,()=>{gR===t&&(gR=void 0)}}function bR(){let e=gR;return e?(gR=void 0,e.dismiss(),!0):!1}function xR(e){bR()&&e.preventDefault(),e.stopPropagation()}function SR(e){return e===`xhigh`?`X-high`:e.charAt(0).toUpperCase()+e.slice(1)}function CR({groups:e,value:t,pending:n,onValueChange:r,placeholder:i,ariaLabel:a,menuAriaLabel:o=`Choose model and effort`,title:s,disabled:c=!1,compact:l=!1,side:u=`bottom`,menuZClass:d=Nj,className:f=``}){let[p,m]=(0,I.useState)(!1),h=(0,I.useRef)(p),g=(0,I.useRef)(c),_=(0,I.useRef)(void 0),v=(0,I.useRef)(new Map),y=(0,I.useRef)(void 0),b=(0,I.useMemo)(()=>lR(e),[e]),x=(0,I.useMemo)(()=>e.flatMap(e=>e.options.flatMap(t=>t.efforts.map(n=>({provider:e.id,model:t.model,effort:n})))),[e]),S=l?rR:nR,C=c?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors hover:border-border hover:bg-panel-2 hover:text-fg`,w=pR(e,t),T=w&&t?.provider&&t.model&&t.effort?dR(t):void 0,E=n?.model||n?.effort?mR(e,n,`Pending profile`):void 0;h.current=p,g.current=c;function D(){h.current=!1,_.current=void 0,m(!1)}(0,I.useLayoutEffect)(()=>{let e=e=>{e.key!==`Escape`||!h.current||g.current||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),_.current?.(),D())};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]),(0,I.useLayoutEffect)(()=>{!c||!p||(_.current?.(),D())},[c,p]),(0,I.useLayoutEffect)(()=>()=>_.current?.(),[]),(0,I.useLayoutEffect)(()=>{T===y.current&&(y.current=void 0)},[T]);function O(e){let t=dR(e);y.current!==t&&(y.current=t,r(e))}function k(t,n){if(![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(t.key))return;let r=hR(e,n,t.key);r&&(t.preventDefault(),t.stopPropagation(),v.current.get(dR(r))?.focus())}return(0,L.jsxs)(fI,{modal:!1,open:p,onOpenChange:e=>{_.current?.(),_.current=void 0,h.current=e,m(e),e&&(_.current=yR(D))},children:[(0,L.jsx)(pI,{asChild:!0,disabled:c,children:(0,L.jsxs)(`button`,{type:`button`,"aria-label":a,"aria-invalid":!w&&(t?.model||t?.effort)?!0:void 0,"aria-description":E?`Pending ${E}`:void 0,title:s,"data-profile-known":w?`true`:`false`,"data-profile-pending":E?`true`:void 0,className:`profile-grid-trigger group inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md border border-border/50 bg-transparent px-2 py-1 text-left text-muted outline-none data-[state=open]:border-border data-[state=open]:bg-panel-2 ${C} ${f} ${S}`,children:[(0,L.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 flex-1 truncate text-left ${S}`,children:mR(e,t,i)}),E&&(0,L.jsx)(Mm,{"aria-hidden":`true`,size:l?10:11,className:`shrink-0 animate-spin text-muted/65`}),(0,L.jsx)($p,{"aria-hidden":`true`,size:l?11:13,className:`shrink-0 text-fg/65 transition-transform group-data-[state=open]:rotate-180`})]})}),(0,L.jsx)(mI,{children:(0,L.jsxs)(hI,{"aria-label":o,align:`start`,side:u,sideOffset:5,collisionPadding:8,onEscapeKeyDown:e=>e.stopPropagation(),className:`profile-grid-menu ${d} ${Mj} max-h-[min(360px,var(--radix-dropdown-menu-content-available-height))] max-w-[calc(100vw-1rem)] overflow-auto rounded-lg p-1.5 ${S}`,children:[e.map(t=>(0,L.jsxs)(gI,{children:[t.label&&(0,L.jsx)(_I,{className:`px-1.5 pb-1 pt-1 text-left font-medium tracking-[0.07em] text-muted/55 first:pt-0.5`,children:t.label}),(0,L.jsx)(yI,{value:T,onValueChange:t=>{let n=fR(e,t);n&&O(n)},children:t.options.map(e=>(0,L.jsxs)(`div`,{"data-profile-grid-row":e.model,className:`grid w-max items-center gap-1 py-0.5`,style:{gridTemplateColumns:aR(b.length)},children:[(0,L.jsx)(`span`,{className:`profile-grid-model-label min-w-0 max-w-[9.5rem] truncate px-1.5 text-left text-muted ${S}`,title:e.label,children:e.label}),b.map(n=>{let r=n.find(t=>e.efforts.includes(t)),i=n.reduce((e,t)=>SR(t).length>SR(e).length?t:e);if(!r)return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`invisible cursor-default border border-transparent px-1 text-left font-medium ${S}`,children:SR(i)},i);let a={provider:t.id,model:e.model,effort:r},o=dR(a);return(0,L.jsx)(bI,{value:o,ref:e=>{e?v.current.set(o,e):v.current.delete(o)},onKeyDown:e=>k(e,a),onSelect:e=>{e.preventDefault(),O(a),_.current?.(),D()},"aria-label":`${e.label}, ${SR(r)} effort`,title:`${e.label} › ${SR(r)}`,className:iR,children:(0,L.jsxs)(`span`,{className:`grid`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`invisible col-start-1 row-start-1 font-medium`,children:SR(r)}),(0,L.jsx)(`span`,{className:`col-start-1 row-start-1`,children:SR(r)})]})},r)})]},e.model))}),t!==e.at(-1)&&(0,L.jsx)(SI,{className:`my-1 h-px bg-border`})]},t.id)),x.length===0&&(0,L.jsx)(`div`,{className:`px-2 py-1.5 text-muted/60`,children:`No profiles available`})]})})]})}async function wR(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(!TR(e))throw Error(`the browser blocked clipboard access`)}function TR(e){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.top=`0`,t.style.left=`0`,t.style.opacity=`0`,document.body.append(t);let n=document.getSelection(),r=n&&n.rangeCount>0?n.getRangeAt(0):null;t.select(),t.setSelectionRange(0,e.length);let i=!1;try{i=document.execCommand(`copy`)}catch{i=!1}return t.remove(),r&&n&&(n.removeAllRanges(),n.addRange(r)),i}var ER={claude:`claude auth login`,codex:`codex login`},DR={claude:`Claude`,codex:`Codex`};function OR(e){let t=e.trim();return t===`/login`?`login`:t===`/logout`?`logout`:null}var kR=(0,I.lazy)(()=>By(()=>import(`./TerminalPane-CDk5zKv9.js`).then(e=>({default:e.TerminalPane})),__vite__mapDeps([0,1])));function AR({backend:e,onClose:t,onAuthed:n}){let r=Ve(),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(null),c=(0,I.useRef)(!1),l=ER[e],u=DR[e],d=it({mutationFn:()=>Y.accountLoginStart({backend:e}),onSuccess:e=>{c.current=!1,s(e.attemptId)},onError:e=>Z(`Couldn't start the sign-in terminal: ${e.message.slice(0,80)} — use the command below instead`,{duration:7e3})}),f=nt({queryKey:[`accountLoginStatus`,o],queryFn:()=>Y.accountLoginStatus({attemptId:o}),enabled:!!o,refetchInterval:2e3});(0,I.useEffect)(()=>{if(!o||c.current)return;let t=f.data;if(!(!t||t.state===`running`||t.state===`unknown`)){if(c.current=!0,t.auth!==`signed-out`){r.setQueryData([`authStatus`],n=>n&&{...n,[e]:t.auth}),Z(`Signed in to ${u}`),n();return}Z(`${u} sign-in didn't complete — try again or use the command below`,{duration:7e3}),s(null)}},[o,f.data,e,u]);function p(){o&&!c.current&&Y.accountLoginCancel({attemptId:o}).catch(()=>{})}let m=(0,I.useRef)({attempt:null,settled:!1});m.current={attempt:o,settled:c.current},(0,I.useEffect)(()=>()=>{let{attempt:e,settled:t}=m.current;e&&!t&&Y.accountLoginCancel({attemptId:e}).catch(()=>{})},[]);async function h(){try{await wR(l),a(!0),window.setTimeout(()=>a(!1),1500)}catch{Z(`Couldn't copy — select the command and copy it manually`,{duration:6e3})}}let g=it({mutationFn:()=>Y.authStatus(),onSuccess:t=>{if(r.setQueryData([`authStatus`],t),t[e]===`signed-out`){Z(`Still signed out of ${u} — run the command, then retry`,{duration:6e3});return}n()},onError:()=>n()});return(0,L.jsx)(PI,{open:!0,onOpenChange:e=>{e||(p(),t())},children:(0,L.jsxs)(BI,{children:[(0,L.jsx)(HI,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(KI,{"aria-modal":`true`,"aria-describedby":void 0,className:`fixed left-1/2 top-1/2 z-[210] ${o?`w-[680px]`:`w-[440px]`} max-w-[92vw] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-panel p-5 shadow-2xl shadow-black/50 outline-none`,children:[(0,L.jsxs)(ZI,{className:`mb-1 text-[14px] font-medium`,children:[`Signed out of `,u]}),o?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`mb-3 text-[12.5px] leading-relaxed text-muted`,children:[`This terminal is running `,(0,L.jsx)(`code`,{className:`font-mono-keep text-fg/90`,children:l}),` — follow its prompts (it may open your browser). Frizz detects completion automatically.`]}),(0,L.jsx)(`div`,{className:`mb-4 h-[340px] overflow-hidden rounded-lg border border-border bg-[#0d0e10]`,children:(0,L.jsx)(I.Suspense,{fallback:(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center text-[12px] text-muted`,children:`Opening terminal…`}),children:(0,L.jsx)(kR,{slug:o})})}),(0,L.jsx)(`div`,{className:`flex items-center justify-end gap-2`,children:(0,L.jsx)(`button`,{type:`button`,onClick:()=>{p(),s(null)},className:`rounded-md px-3 py-1.5 text-[12.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg`,children:`Cancel sign-in`})})]}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`mb-4 text-[12.5px] leading-relaxed text-muted`,children:[`Frizz can't start a `,u,` thread until you're signed in. Sign in here, or run the command in your own terminal and retry:`]}),(0,L.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg border border-border bg-panel-2 px-3 py-2`,children:[(0,L.jsx)(`code`,{className:`flex-1 select-all font-mono-keep text-[12.5px] text-fg`,children:l}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,onClick:h,className:`flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted outline-none transition-colors hover:bg-panel hover:text-fg`,children:i?(0,L.jsx)(Qp,{size:14,strokeWidth:2,className:`text-green-400`}):(0,L.jsx)(fm,{size:14,strokeWidth:1.8})})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md px-3 py-1.5 text-[12.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>g.mutate(),disabled:g.isPending,className:`flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-[12.5px] text-fg/90 outline-none transition-colors hover:bg-panel-2 disabled:opacity-60`,children:[g.isPending&&(0,L.jsx)(Mm,{size:13,className:`animate-spin`}),`Retry`]}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>d.mutate(),disabled:d.isPending,className:`flex items-center gap-1.5 rounded-md bg-accent px-3 py-1.5 text-[12.5px] font-medium text-white outline-none transition-opacity hover:opacity-90 disabled:opacity-60`,children:[d.isPending&&(0,L.jsx)(Mm,{size:13,className:`animate-spin`}),`Sign in here`]})]})]})]})]})})}function jR({backend:e,onClose:t}){let n=Ve(),r=DR[e],i=it({mutationFn:()=>Y.accountLogout({backend:e}),onSuccess:i=>{n.setQueryData([`authStatus`],t=>t&&{...t,[e]:i.auth}),i.status===`done`?Z(`Signed out of ${r}`):i.status===`blocked`?Z(`Not signed out — ${i.activeThreads} active ${r} thread${i.activeThreads===1?``:`s`}. Let them finish (or complete them) first.`,{duration:7e3}):Z(`${r} sign-out failed: ${i.detail??`unknown error`}`,{duration:7e3}),t()},onError:e=>{Z(`${r} sign-out failed: ${e.message.slice(0,80)}`,{duration:7e3}),t()}});return(0,L.jsx)(PI,{open:!0,onOpenChange:e=>{!e&&!i.isPending&&t()},children:(0,L.jsxs)(BI,{children:[(0,L.jsx)(HI,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(KI,{"aria-modal":`true`,"aria-describedby":void 0,className:`fixed left-1/2 top-1/2 z-[210] w-[420px] max-w-[86vw] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-panel p-5 shadow-2xl shadow-black/50 outline-none`,children:[(0,L.jsxs)(ZI,{className:`mb-1 text-[14px] font-medium`,children:[`Sign out of `,r,`?`]}),(0,L.jsxs)(`p`,{className:`mb-4 text-[12.5px] leading-relaxed text-muted`,children:[`New `,r,` threads will be blocked until you sign in again. Running `,r,` threads are left untouched — sign-out is refused while any are active.`]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:t,disabled:i.isPending,className:`rounded-md px-3 py-1.5 text-[12.5px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:opacity-60`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`button`,onClick:()=>i.mutate(),disabled:i.isPending,className:`flex items-center gap-1.5 rounded-md bg-red-500/90 px-3 py-1.5 text-[12.5px] font-medium text-white outline-none transition-opacity hover:opacity-90 disabled:opacity-60`,children:[i.isPending&&(0,L.jsx)(Mm,{size:13,className:`animate-spin`}),`Sign out`]})]})]})]})})}var MR=mu.options,NR={auto:`Auto`,default:`Default`,acceptEdits:`Accept edits`,plan:`Plan`,bypassPermissions:`Bypass`},PR={auto:`auto — safe actions auto-approved, risky ones prompt`,default:`default — prompt for every permission`,acceptEdits:`accept edits — file edits auto-approved`,plan:`plan — read-only planning, approval before changes`,bypassPermissions:`bypass — never prompt (dangerous)`};MR.filter(e=>e!==`plan`).map(e=>({value:e,label:NR[e],title:PR[e]}));var FR=[`auto`,`bypassPermissions`].map(e=>({value:e,label:NR[e],title:PR[e]})),IR=[{value:`fable`,label:`Fable`},{value:`opus`,label:`Opus`},{value:`sonnet`,label:`Sonnet`},{value:`haiku`,label:`Haiku`}];new Set([{slug:`gpt-6-astra`,displayName:`GPT-6 Astra`,defaultEffort:`low`,efforts:[`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]},{slug:`gpt-5.6-sol`,displayName:`GPT-5.6 Sol`,defaultEffort:`medium`,efforts:[`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]},{slug:`gpt-5.6-terra`,displayName:`GPT-5.6 Terra`,defaultEffort:`medium`,efforts:[`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]},{slug:`gpt-5.6-luna`,displayName:`GPT-5.6 Luna`,defaultEffort:`medium`,efforts:[`low`,`medium`,`high`,`xhigh`,`max`]},{slug:`gpt-5.5`,displayName:`GPT-5.5`,defaultEffort:`medium`,efforts:[`low`,`medium`,`high`,`xhigh`]}].map(e=>e.slug));function LR(e){return e===`plan`?`auto`:e}var RR=[`low`,`medium`,`high`,`xhigh`,`max`],zR=`ultracode`,BR=new Set([`fable`,`opus`,`sonnet`]);function VR(e){return e&&BR.has(e)?[...RR,zR]:[...RR]}var HR={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-high`,max:`Max`,ultra:`Ultra`,ultracode:`Ultracode`};function UR(e){return HR[e]??e.charAt(0).toUpperCase()+e.slice(1)}function WR(e,t){let n=VR(e).map(e=>({value:e,label:UR(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function GR(e,t){let n=(e?.efforts??[]).map(e=>({value:e,label:UR(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function KR(e,t){return t.field===`backend`?{...e,backend:t.value}:t.field===`profile`?{...e,backend:t.backend,[t.backend]:{...e[t.backend],model:t.model,effort:t.effort}}:{...e,...t.field===`model`?{backend:t.backend}:{},[t.backend]:{...e[t.backend],[t.field]:t.value}}}function qR(e){return[{id:`claude`,label:`Claude Code`,options:IR.map(e=>({model:e.value,label:e.label,defaultEffort:`high`,efforts:VR(e.value)}))},{id:`codex`,label:`Codex`,options:e.map(e=>({model:e.slug,label:e.displayName,defaultEffort:e.defaultEffort,efforts:e.efforts}))}]}function JR(e,t){let n=e.backend,r=e[n],i=r.model??(n===`claude`?`opus`:t[0]?.slug??``),a=n===`codex`?t.find(e=>e.slug===i):void 0,o=n===`claude`?IR.some(e=>e.value===i):t.some(e=>e.slug===i),s=n===`claude`?`high`:a?.defaultEffort??``,c=r.effort??s,l=n===`claude`?WR(i,{withDefault:!1}):GR(a,{withDefault:!1}),u=l.some(e=>e.value===c);return{backend:n,model:i,effort:c,codexModel:a,modelAvailable:o,effortAvailable:u,effortOptions:c&&!u?[{value:c,label:`${c} (unavailable)`,title:`Saved reasoning level is not available for this model`},...l]:l}}function YR(){let e=Ve(),t=nt({queryKey:[`dispatchPreferencesGet`],queryFn:()=>Y.dispatchPreferencesGet()}),n=nt({queryKey:[`codexModels`],queryFn:()=>Y.codexModels()}),r=n.data??[],i=it({mutationFn:e=>Y.dispatchPreferenceSet(e),scope:{id:`dispatch-preferences`},onMutate:t=>{let n=e.getQueryData([`dispatchPreferencesGet`]);n&&e.setQueryData([`dispatchPreferencesGet`],KR(n,t))},onError:t=>{e.invalidateQueries({queryKey:[`dispatchPreferencesGet`]}),Z(`Could not save new-thread preference: ${t.message.slice(0,80)}`)}}),a=!!t.data&&!!n.data;return{resolved:(0,I.useMemo)(()=>a?JR(t.data,r):void 0,[a,t.data,r]),codexList:r,loadError:t.isError||n.isError,saveProfile:i.mutate}}var XR=`frizz-drafts:v1`,ZR=80,QR=512*1024,$R=2*1024*1024,ez=new TextEncoder;function tz(e){return ez.encode(e).byteLength}function nz(){return{version:1,entries:{}}}function rz(e){if(!e)return nz();try{let t=JSON.parse(e);if(!t||typeof t!=`object`||t.version!==1)return nz();let n=t.entries;if(!n||typeof n!=`object`||Array.isArray(n))return nz();let r={};for(let[e,t]of Object.entries(n))typeof t?.value!=`string`||typeof t?.touchedAt!=`number`||!Number.isFinite(t.touchedAt)||e.length>512||tz(t.value)>QR||(r[e]={value:t.value,touchedAt:t.touchedAt});return{version:1,entries:r}}catch{return nz()}}function iz(e){let t=Object.entries(e.entries).filter(([,e])=>e.value&&tz(e.value)<=QR).sort((e,t)=>t[1].touchedAt-e[1].touchedAt),n={};for(let[e,r]of t){if(Object.keys(n).length>=ZR)break;n[e]=r,tz(JSON.stringify({version:1,entries:n}))>$R&&delete n[e]}return{version:1,entries:n}}var az=new class{snapshot;listeners=new Set;storage;constructor(e=typeof sessionStorage>`u`?void 0:sessionStorage){this.storage=e;let t=null;try{t=e?.getItem(`frizz-drafts:v1`)??null}catch{}this.snapshot=iz(rz(t))}getSnapshot=()=>this.snapshot;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));get(e){return this.snapshot.entries[e]?.value??``}set(e,t){let n={...this.snapshot.entries};t?n[e]={value:t,touchedAt:Date.now()}:delete n[e],this.commit({version:1,entries:n})}clear(e){this.snapshot.entries[e]&&this.commit({version:1,entries:Object.fromEntries(Object.entries(this.snapshot.entries).filter(([t])=>t!==e))})}commit(e){this.snapshot=e;try{this.storage?.setItem(XR,JSON.stringify(iz(e)))}catch{}for(let e of this.listeners)e()}};function oz(e){return encodeURIComponent(e||`unresolved-project`)}var sz={dispatch:e=>`dispatch:${oz(e)}:new`,followUp:(e,t,n)=>`followup:${oz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}`,adopt:(e,t)=>`adopt:${oz(e)}:${encodeURIComponent(t)}`,answer:(e,t,n,r,i)=>`answer:${oz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}:${encodeURIComponent(r)}:${i}`,interaction:(e,t,n,r,i,a,o)=>`interaction:${oz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}:${i}:${encodeURIComponent(a)}:${encodeURIComponent(o)}`,question:(e,t,n,r)=>`question:${oz(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}`};function cz(){return Zt(X).board?.projectDir}function lz(e){return Zt(X).board?.threads.find(t=>t.id===e)?.sessionId}function uz(e){let t=(0,I.useCallback)(()=>az.get(e),[e]);return[(0,I.useSyncExternalStore)(az.subscribe,t,t),(0,I.useCallback)(t=>az.set(e,t),[e]),(0,I.useCallback)(()=>az.clear(e),[e])]}function dz(e){let t=(0,I.useCallback)(()=>JSON.stringify(Object.fromEntries(e.map(e=>[e,az.get(e)]))),[e.join(`\0`)]),n=(0,I.useSyncExternalStore)(az.subscribe,t,t);return(0,I.useMemo)(()=>new Map(Object.entries(JSON.parse(n))),[n])}function fz({autoFocus:e,onDispatched:t}){let{resolved:n,codexList:r,loadError:i,saveProfile:a}=YR(),o=$L(),s=cz(),[c,l,u]=uz(sz.dispatch(s)),d=sz.dispatch(s),f=(0,I.useRef)(``),[p,m]=(0,I.useState)(null),h=nt({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4}),[g,_]=(0,I.useState)(null),[v,y]=(0,I.useState)(null),b=(0,I.useRef)(null),x=it({mutationFn:e=>Y.dispatch(e),onMutate:()=>Z(`Starting thread…`,{spinner:!0,sticky:!0}),onSuccess:e=>{m(null),t?.(),Z(`Thread started`,{link:{label:`Open thread`,slug:e.slug}})},onError:(e,t)=>{az.get(d)||l(f.current||t.prompt),m(null);let n=/^AUTH_REQUIRED:(claude|codex)$/.exec(e.message);if(n){b.current=t,_(n[1]),Z(`Signed out of ${n[1]===`claude`?`Claude`:`Codex`}`,{duration:3e3});return}Z(`Dispatch failed: ${e.message.slice(0,80)}`)}});function S(e){f.current=c,u(),m(e.prompt),x.mutate(e)}function C(){if(!c.trim()||!n)return;let e=OR(c);if(e){u(),e===`login`?(b.current=null,_(n.backend)):y(n.backend);return}if(!n.modelAvailable){Z(`Saved model is unavailable — choose a model before starting the thread`);return}if(!n.effortAvailable){Z(`Saved reasoning level is unavailable for this model — choose another level`);return}let t={prompt:c.trim(),model:n.model,backend:n.backend,effort:n.effort};if(h.data?.[n.backend]===`signed-out`){b.current=t,_(n.backend);return}S(t)}let w=(0,I.useMemo)(()=>n?(0,L.jsx)(CR,{groups:qR(r),value:{provider:n.backend,model:n.model,effort:n.effort},onValueChange:e=>a({field:`profile`,backend:e.provider,model:e.model,effort:e.effort}),ariaLabel:`Model and effort`,title:n.modelAvailable&&n.effortAvailable?`Model and reasoning effort`:`Saved model or reasoning effort unavailable — choose a supported pair`,className:`max-w-[min(21rem,72vw)]`}):(0,L.jsx)(CR,{groups:[],value:void 0,onValueChange:()=>{},placeholder:i?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort loading`,disabled:!0}),[n,r,i,a]);return(0,L.jsxs)(`div`,{className:`w-full flex flex-col gap-3`,children:[(0,L.jsx)(XL,{surface:`newComposer`,autoFocus:e,value:c,onChange:l,onSubmit:C,placeholder:`Describe the task…`,minHeight:96,maxHeight:340,busy:x.isPending,footer:w,leftAction:o?(0,L.jsx)(eR,{}):void 0}),x.isError&&(0,L.jsx)(`span`,{className:`px-0.5 text-[11px] text-red-400 truncate`,children:x.error.message}),p&&(0,L.jsxs)(`div`,{"data-pending-dispatch":!0,role:`status`,className:`rounded-lg border border-border bg-panel-2 px-3 py-2.5`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted`,children:[(0,L.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-accent`,"aria-hidden":`true`}),(0,L.jsx)(`span`,{children:`Starting thread…`})]}),(0,L.jsx)(`p`,{className:`mt-1 line-clamp-2 whitespace-pre-wrap text-[12px] leading-relaxed text-fg`,children:p})]}),g&&(0,L.jsx)(AR,{backend:g,onClose:()=>_(null),onAuthed:()=>{let e=b.current;b.current=null,_(null),e&&S(e)}}),v&&(0,L.jsx)(jR,{backend:v,onClose:()=>y(null)})]})}function pz({onClose:e}){let t=(0,I.useRef)(null),n=(0,I.useRef)(typeof document<`u`&&document.activeElement instanceof HTMLElement?document.activeElement:null);return(0,I.useEffect)(()=>()=>{let e=n.current;window.setTimeout(()=>{e?.isConnected&&e.focus({preventScroll:!0})},0)},[]),(0,L.jsx)(PI,{open:!0,onOpenChange:t=>{t||e()},children:(0,L.jsxs)(BI,{children:[(0,L.jsx)(HI,{className:`fixed inset-0 z-50 bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(KI,{ref:t,"aria-modal":`true`,"aria-describedby":void 0,onEscapeKeyDown:xR,onCloseAutoFocus:e=>{e.preventDefault();let t=n.current;t?.isConnected&&t.focus({preventScroll:!0})},onOpenAutoFocus:e=>{e.preventDefault(),t.current?.querySelector(`textarea`)?.focus({preventScroll:!0})},className:`fixed left-1/2 top-1/2 z-50 w-[640px] max-w-[86vw] -translate-x-1/2 -translate-y-1/2 rounded-xl border border-border bg-panel p-5 shadow-2xl shadow-black/50 outline-none max-[700px]:top-[calc(env(safe-area-inset-top)+56px)] max-[700px]:w-[calc(100vw-24px)] max-[700px]:max-w-none max-[700px]:translate-y-0`,children:[(0,L.jsx)(ZI,{className:`mb-1 text-[14px] font-medium`,children:`New thread`}),(0,L.jsx)(fz,{autoFocus:!0,onDispatched:e})]})]})})}function mz({children:e,onClose:t}){return(0,L.jsx)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center bg-black/30 backdrop-blur-md backdrop-saturate-150`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:e})}var hz=`-mx-1.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-fg/75 outline-none transition-colors hover:bg-elevated hover:text-fg focus-visible:ring-1 focus-visible:ring-border-strong disabled:opacity-55`,gz={claude:`size-[11px] translate-y-px`,codex:`size-[10px]`},_z={claude:{backend:`claude`,label:`Claude Code`},codex:{backend:`codex`,label:`OpenAI Codex`}};function vz(e){return e===`claude`||e===`codex`?_z[e]:void 0}function yz({backend:e,className:t}){let n=vz(e);return n?(0,L.jsx)(`span`,{role:`img`,"aria-label":n.label,className:`inline-flex shrink-0 text-muted/65 ${gz[n.backend]} ${t??``}`,children:n.backend===`codex`?(0,L.jsx)(bz,{}):(0,L.jsx)(xz,{})}):null}function bz(){return(0,L.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,L.jsx)(`path`,{d:`M22.282 9.821a6 6 0 0 0-.516-4.91a6.05 6.05 0 0 0-6.51-2.9A6.065 6.065 0 0 0 4.981 4.18a6 6 0 0 0-3.998 2.9a6.05 6.05 0 0 0 .743 7.097a5.98 5.98 0 0 0 .51 4.911a6.05 6.05 0 0 0 6.515 2.9A6 6 0 0 0 13.26 24a6.06 6.06 0 0 0 5.772-4.206a6 6 0 0 0 3.997-2.9a6.06 6.06 0 0 0-.747-7.073M13.26 22.43a4.48 4.48 0 0 1-2.876-1.04l.141-.081l4.779-2.758a.8.8 0 0 0 .392-.681v-6.737l2.02 1.168a.07.07 0 0 1 .038.052v5.583a4.504 4.504 0 0 1-4.494 4.494M3.6 18.304a4.47 4.47 0 0 1-.535-3.014l.142.085l4.783 2.759a.77.77 0 0 0 .78 0l5.843-3.369v2.332a.08.08 0 0 1-.033.062L9.74 19.95a4.5 4.5 0 0 1-6.14-1.646M2.34 7.896a4.5 4.5 0 0 1 2.366-1.973V11.6a.77.77 0 0 0 .388.677l5.815 3.354l-2.02 1.168a.08.08 0 0 1-.071 0l-4.83-2.786A4.504 4.504 0 0 1 2.34 7.872zm16.597 3.855l-5.833-3.387L15.119 7.2a.08.08 0 0 1 .071 0l4.83 2.791a4.494 4.494 0 0 1-.676 8.105v-5.678a.79.79 0 0 0-.407-.667m2.01-3.023l-.141-.085l-4.774-2.782a.78.78 0 0 0-.785 0L9.409 9.23V6.897a.07.07 0 0 1 .028-.061l4.83-2.787a4.5 4.5 0 0 1 6.68 4.66zm-12.64 4.135l-2.02-1.164a.08.08 0 0 1-.038-.057V6.075a4.5 4.5 0 0 1 7.375-3.453l-.142.08L8.704 5.46a.8.8 0 0 0-.393.681zm1.097-2.365l2.602-1.5l2.607 1.5v2.999l-2.597 1.5l-2.607-1.5Z`})})}function xz(){return(0,L.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,L.jsx)(`path`,{d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`})})}typeof window<`u`&&window.document&&window.document.createElement;function Sz(e,t,{checkForDefaultPrevented:n=!0}={}){return function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)}}function Cz(e,t=[]){let n=[];function r(t,r){let i=I.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=I.useMemo(()=>o,Object.values(o));return(0,L.jsx)(s.Provider,{value:c,children:r})};o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=I.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return[o,s]}let i=()=>{let t=n.map(e=>I.createContext(e));return function(n){let r=n?.[e]||t;return I.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])}};return i.scopeName=e,[r,wz(i,...t)]}function wz(...e){let t=e[0];if(e.length===1)return t;let n=()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return I.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])}};return n.scopeName=t.scopeName,n}var Tz=`DismissableLayer`,Ez=`dismissableLayer.update`,Dz=`dismissableLayer.pointerDownOutside`,Oz=`dismissableLayer.focusOutside`,kz,Az=I.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),jz=I.forwardRef((e,t)=>{let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=I.useContext(Az),[d,f]=I.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=I.useState({}),h=aD(t,f),g=Array.from(u.layers),[_]=[...u.layersWithOutsidePointerEventsDisabled].slice(-1),v=_?g.indexOf(_):-1,y=d?g.indexOf(d):-1,b=u.layersWithOutsidePointerEventsDisabled.size>0,x=y>=v,S=I.useRef(!1),C=Fz(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:I.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return x&&!t},[u.branches,x])}),w=Iz(e=>{if(r&&S.current)return;let t=e.target;[...u.branches].some(e=>e.contains(t))||(o?.(e),s?.(e),e.defaultPrevented||c?.())},p),T=d?y===g.length-1:!1,E=CD(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return I.useEffect(()=>{if(T)return p.addEventListener(`keydown`,E,{capture:!0}),()=>p.removeEventListener(`keydown`,E,{capture:!0})},[p,T,E]),I.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(kz=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),Lz(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=kz))}},[d,p,n,u]),I.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),Lz())},[d,u]),I.useEffect(()=>{let e=()=>m({});return document.addEventListener(Ez,e),()=>document.removeEventListener(Ez,e)},[]),(0,L.jsx)(xD.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:Sz(e.onFocusCapture,w.onFocusCapture),onBlurCapture:Sz(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:Sz(e.onPointerDownCapture,C.onPointerDownCapture)})});jz.displayName=Tz;var Mz=`DismissableLayerBranch`,Nz=I.forwardRef((e,t)=>{let n=I.useContext(Az),r=I.useRef(null),i=aD(t,r);return I.useEffect(()=>{let e=r.current;if(e)return n.branches.add(e),()=>{n.branches.delete(e)}},[n.branches]),(0,L.jsx)(xD.div,{...e,ref:i})});Nz.displayName=Mz;var Pz=()=>!0;function Fz(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=Pz}=t,s=CD(e),c=I.useRef(!1),l=I.useRef(!1),u=I.useRef(new Map),d=I.useRef(()=>{});return I.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}function t(){return Array.from(u.current.values()).some(Boolean)}function f(e){if(!l.current)return;let t=e.target;t instanceof Node&&[...a].some(e=>e.contains(t))||u.current.set(e.type,!0),e.type===`click`&&window.setTimeout(()=>{l.current&&d.current()},0)}function p(e){l.current&&u.current.set(e.type,!1)}let m=a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||Rz(Dz,s,p,{discrete:!0})};if(!o(a.target)){n.removeEventListener(`click`,d.current),e(),c.current=!1;return}let p={originalEvent:a};l.current=!0,i.current=r&&a.button===0,u.current.clear(),!r||a.button!==0?f():(n.removeEventListener(`click`,d.current),d.current=f,n.addEventListener(`click`,d.current,{once:!0}))}else n.removeEventListener(`click`,d.current),e();c.current=!1},h=[`pointerup`,`mousedown`,`mouseup`,`touchstart`,`touchend`,`click`];for(let e of h)n.addEventListener(e,f,!0),n.addEventListener(e,p);let g=window.setTimeout(()=>{n.addEventListener(`pointerdown`,m)},0);return()=>{window.clearTimeout(g),n.removeEventListener(`pointerdown`,m),n.removeEventListener(`click`,d.current);for(let e of h)n.removeEventListener(e,f,!0),n.removeEventListener(e,p)}},[n,s,r,i,a,o]),{onPointerDownCapture:()=>c.current=!0}}function Iz(e,t=globalThis?.document){let n=CD(e),r=I.useRef(!1);return I.useEffect(()=>{let e=e=>{e.target&&!r.current&&Rz(Oz,n,{originalEvent:e},{discrete:!1})};return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function Lz(){let e=new CustomEvent(Ez);document.dispatchEvent(e)}function Rz(e,t,n,{discrete:r}){let i=n.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:n});t&&i.addEventListener(e,t,{once:!0}),r?SD(i,a):i.dispatchEvent(a)}var zz=`focusScope.autoFocusOnMount`,Bz=`focusScope.autoFocusOnUnmount`,Vz={bubbles:!1,cancelable:!0},Hz=`FocusScope`,Uz=I.forwardRef((e,t)=>{let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=I.useState(null),l=CD(i),u=CD(a),d=I.useRef(null),f=aD(t,c),p=I.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;I.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:Xz(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||Xz(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&Xz(s)};document.addEventListener(`focusin`,e),document.addEventListener(`focusout`,t);let r=new MutationObserver(n);return s&&r.observe(s,{childList:!0,subtree:!0}),()=>{document.removeEventListener(`focusin`,e),document.removeEventListener(`focusout`,t),r.disconnect()}}},[r,s,p.paused]),I.useEffect(()=>{if(s){Zz.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(zz,Vz);s.addEventListener(zz,l),s.dispatchEvent(t),t.defaultPrevented||(Wz(eB(Kz(s)),{select:!0}),document.activeElement===e&&Xz(s))}return()=>{s.removeEventListener(zz,l),setTimeout(()=>{let t=new CustomEvent(Bz,Vz);s.addEventListener(Bz,u),s.dispatchEvent(t),t.defaultPrevented||Xz(e??document.body,{select:!0}),s.removeEventListener(Bz,u),Zz.remove(p)},0)}}},[s,l,u,p]);let m=I.useCallback(e=>{if(!n&&!r||p.paused)return;let t=e.key===`Tab`&&!e.altKey&&!e.ctrlKey&&!e.metaKey,i=document.activeElement;if(t&&i){let t=e.currentTarget,[r,a]=Gz(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&Xz(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&Xz(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,L.jsx)(xD.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})});Uz.displayName=Hz;function Wz(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(Xz(r,{select:t}),document.activeElement!==n)return}function Gz(e){let t=Kz(e);return[qz(t,e),qz(t.reverse(),e)]}function Kz(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:e=>{let t=e.tagName===`INPUT`&&e.type===`hidden`;return e.disabled||e.hidden||t?NodeFilter.FILTER_SKIP:e.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;n.nextNode();)t.push(n.currentNode);return t}function qz(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):Jz(r,{upTo:t})))return r}function Jz(e,{upTo:t}){if(getComputedStyle(e).visibility===`hidden`)return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display===`none`)return!0;e=e.parentElement}return!1}function Yz(e){return e instanceof HTMLInputElement&&`select`in e}function Xz(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&Yz(e)&&t&&e.select()}}var Zz=Qz();function Qz(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=$z(e,t),e.unshift(t)},remove(t){e=$z(e,t),e[0]?.resume()}}}function $z(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}function eB(e){return e.filter(e=>e.tagName!==`A`)}var tB=`Popper`,[nB,rB]=Cz(tB),[iB,aB]=nB(tB),oB=e=>{let{__scopePopper:t,children:n}=e,[r,i]=I.useState(null),[a,o]=I.useState(void 0);return(0,L.jsx)(iB,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})};oB.displayName=tB;var sB=`PopperAnchor`,cB=I.forwardRef((e,t)=>{let{__scopePopper:n,virtualRef:r,...i}=e,a=aB(sB,n),o=I.useRef(null),s=a.onAnchorChange,c=aD(t,I.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=I.useRef(null);I.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&vB(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,L.jsx)(xD.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})});cB.displayName=sB;var lB=`PopperContent`,[uB,dB]=nB(lB),fB=I.forwardRef((e,t)=>{let{__scopePopper:n,side:r=`bottom`,sideOffset:i=0,align:a=`center`,alignOffset:o=0,arrowPadding:s=0,avoidCollisions:c=!0,collisionBoundary:l=[],collisionPadding:u=0,sticky:d=`partial`,hideWhenDetached:f=!1,updatePositionStrategy:p=`optimized`,onPlaced:m,...h}=e,g=aB(lB,n),[_,v]=I.useState(null),y=aD(t,v),[b,x]=I.useState(null),S=oA(b),C=S?.width??0,w=S?.height??0,T=r+(a===`center`?``:`-`+a),E=typeof u==`number`?u:{top:0,right:0,bottom:0,left:0,...u},D=Array.isArray(l)?l:[l],O=D.length>0,k={padding:E,boundary:D.filter(gB),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=Jk({strategy:`fixed`,placement:T,whileElementsMounted:(...e)=>Pk(...e,{animationFrame:p===`always`}),elements:{reference:g.anchor},middleware:[Xk({mainAxis:i+w,alignmentAxis:o}),c&&Zk({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?Qk():void 0,...k}),c&&$k({...k}),eA({...k,apply:({elements:e,rects:t,availableWidth:n,availableHeight:r})=>{let{width:i,height:a}=t.reference,o=e.floating.style;o.setProperty(`--radix-popper-available-width`,`${n}px`),o.setProperty(`--radix-popper-available-height`,`${r}px`),o.setProperty(`--radix-popper-anchor-width`,`${i}px`),o.setProperty(`--radix-popper-anchor-height`,`${a}px`)}}),b&&nA({element:b,padding:s}),_B({arrowWidth:C,arrowHeight:w}),f&&tA({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),ee=g.setPlacementState;wD(()=>(ee(M),()=>{ee(void 0)}),[M,ee]);let[F,te]=vB(M),ne=CD(m);wD(()=>{N&&ne?.()},[N,ne]);let re=P.arrow?.x,ie=P.arrow?.y,ae=P.arrow?.centerOffset!==0,[oe,se]=I.useState();return wD(()=>{_&&se(window.getComputedStyle(_).zIndex)},[_]),(0,L.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:N?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:oe,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,L.jsx)(uB,{scope:n,placedSide:F,placedAlign:te,onArrowChange:x,arrowX:re,arrowY:ie,shouldHideArrow:ae,children:(0,L.jsx)(xD.div,{"data-side":F,"data-align":te,...h,ref:y,style:{...h.style,animation:N?void 0:`none`}})})})});fB.displayName=lB;var pB=`PopperArrow`,mB={top:`bottom`,right:`left`,bottom:`top`,left:`right`},hB=I.forwardRef(function(e,t){let{__scopePopper:n,...r}=e,i=dB(pB,n),a=mB[i.placedSide];return(0,L.jsx)(`span`,{ref:i.onArrowChange,style:{position:`absolute`,left:i.arrowX,top:i.arrowY,[a]:0,transformOrigin:{top:``,right:`0 0`,bottom:`center 0`,left:`100% 0`}[i.placedSide],transform:{top:`translateY(100%)`,right:`translateY(50%) rotate(90deg) translateX(-50%)`,bottom:`rotate(180deg)`,left:`translateY(50%) rotate(-90deg) translateX(50%)`}[i.placedSide],visibility:i.shouldHideArrow?`hidden`:void 0},children:(0,L.jsx)(aA,{...r,ref:t,style:{...r.style,display:`block`}})})});hB.displayName=pB;function gB(e){return e!==null}var _B=e=>({name:`transformOrigin`,options:e,fn(t){let{placement:n,rects:r,middlewareData:i}=t,a=i.arrow?.centerOffset!==0,o=a?0:e.arrowWidth,s=a?0:e.arrowHeight,[c,l]=vB(n),u={start:`0%`,center:`50%`,end:`100%`}[l],d=(i.arrow?.x??0)+o/2,f=(i.arrow?.y??0)+s/2,p=``,m=``;return c===`bottom`?(p=a?u:`${d}px`,m=`${-s}px`):c===`top`?(p=a?u:`${d}px`,m=`${r.floating.height+s}px`):c===`right`?(p=`${-s}px`,m=a?u:`${f}px`):c===`left`&&(p=`${r.floating.width+s}px`,m=a?u:`${f}px`),{data:{x:p,y:m}}}});function vB(e){let[t,n=`center`]=e.split(`-`);return[t,n]}var yB=oB,bB=cB,xB=fB,SB=hB;function CB(e,t){return I.useReducer((e,n)=>t[e][n]??e,e)}var wB=e=>{let{present:t,children:n}=e,r=TB(t),i=typeof n==`function`?n({present:r.isPresent}):I.Children.only(n),a=DB(r.ref,kB(i));return typeof n==`function`||r.isPresent?I.cloneElement(i,{ref:a}):null};wB.displayName=`Presence`;function TB(e){let[t,n]=I.useState(),r=I.useRef(null),i=I.useRef(e),a=I.useRef(`none`),o=I.useRef(void 0),[s,c]=CB(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return I.useEffect(()=>{s===`mounted`?(a.current=o.current??OB(r.current),o.current=void 0):a.current=`none`},[s]),wD(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=OB(t);e?(o.current=s,c(`MOUNT`)):s===`none`||t?.display===`none`?c(`UNMOUNT`):c(n&&r!==s?`ANIMATION_OUT`:`UNMOUNT`),i.current=e}},[e,c]),wD(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=a=>{let o=OB(r.current).includes(CSS.escape(a.animationName));if(a.target===t&&o&&(c(`ANIMATION_END`),!i.current)){let r=t.style.animationFillMode;t.style.animationFillMode=`forwards`,e=n.setTimeout(()=>{t.style.animationFillMode===`forwards`&&(t.style.animationFillMode=r)})}},s=e=>{e.target===t&&(a.current=OB(r.current))};return t.addEventListener(`animationstart`,s),t.addEventListener(`animationcancel`,o),t.addEventListener(`animationend`,o),()=>{n.clearTimeout(e),t.removeEventListener(`animationstart`,s),t.removeEventListener(`animationcancel`,o),t.removeEventListener(`animationend`,o)}}else c(`ANIMATION_END`)},[t,c]),{isPresent:[`mounted`,`unmountSuspended`].includes(s),ref:I.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=OB(t)}else r.current=null;n(e)},[])}}function EB(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function DB(...e){let t=I.useRef(e);return t.current=e,I.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=EB(t,e);return!r&&typeof n==`function`&&(r=!0),n});if(r)return()=>{for(let e=0;e<i.length;e++){let t=i[e];typeof t==`function`?t():EB(n[e],null)}}},[])}function OB(e){return e?.animationName||`none`}function kB(e){let t=Object.getOwnPropertyDescriptor(e.props,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning;return n?e.ref:(t=Object.getOwnPropertyDescriptor(e,`ref`)?.get,n=t&&`isReactWarning`in t&&t.isReactWarning,n?e.props.ref:e.props.ref||e.ref)}var AB=`Popover`,[jB,MB]=Cz(AB,[rB]),NB=rB(),[PB,FB]=jB(AB),IB=e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=NB(t),c=I.useRef(null),[l,u]=I.useState(!1),[d,f]=zA({prop:r,defaultProp:i??!1,onChange:a,caller:AB});return(0,L.jsx)(yB,{...s,children:(0,L.jsx)(PB,{scope:t,contentId:WD(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:I.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:I.useCallback(()=>u(!0),[]),onCustomAnchorRemove:I.useCallback(()=>u(!1),[]),modal:o,children:n})})};IB.displayName=AB;var LB=`PopoverAnchor`,RB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=FB(LB,n),a=NB(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return I.useEffect(()=>(o(),()=>s()),[o,s]),(0,L.jsx)(bB,{...a,...r,ref:t})});RB.displayName=LB;var zB=`PopoverTrigger`,BB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=FB(zB,n),a=NB(n),o=aD(t,i.triggerRef),s=(0,L.jsx)(xD.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":tV(i.open),...r,ref:o,onClick:Sz(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,L.jsx)(bB,{asChild:!0,...a,children:s})});BB.displayName=zB;var VB=`PopoverPortal`,[HB,UB]=jB(VB,{forceMount:void 0}),WB=e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=FB(VB,t);return(0,L.jsx)(HB,{scope:t,forceMount:n,children:(0,L.jsx)(wB,{present:n||a.open,children:(0,L.jsx)(AA,{asChild:!0,container:i,children:r})})})};WB.displayName=VB;var GB=`PopoverContent`,KB=I.forwardRef((e,t)=>{let n=UB(GB,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=FB(GB,e.__scopePopover);return(0,L.jsx)(wB,{present:r||a.open,children:a.modal?(0,L.jsx)(JB,{...i,ref:t}):(0,L.jsx)(YB,{...i,ref:t})})});KB.displayName=GB;var qB=cD(`PopoverContent.RemoveScroll`),JB=I.forwardRef((e,t)=>{let n=FB(GB,e.__scopePopover),r=I.useRef(null),i=aD(t,r),a=I.useRef(!1);return I.useEffect(()=>{let e=r.current;if(e)return BM(e)},[]),(0,L.jsx)(YN,{as:qB,allowPinchZoom:!0,children:(0,L.jsx)(XB,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Sz(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Sz(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;a.current=r},{checkForDefaultPrevented:!1}),onFocusOutside:Sz(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})}),YB=I.forwardRef((e,t)=>{let n=FB(GB,e.__scopePopover),r=I.useRef(!1),i=I.useRef(!1);return(0,L.jsx)(XB,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})}),XB=I.forwardRef((e,t)=>{let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=FB(GB,n),p=NB(n);return qj(),(0,L.jsx)(Uz,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,L.jsx)(jz,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,L.jsx)(xB,{"data-state":tV(f.open),role:`dialog`,id:f.contentId,...p,...d,ref:t,style:{...d.style,"--radix-popover-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-popover-content-available-width":`var(--radix-popper-available-width)`,"--radix-popover-content-available-height":`var(--radix-popper-available-height)`,"--radix-popover-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-popover-trigger-height":`var(--radix-popper-anchor-height)`}})})})}),ZB=`PopoverClose`,QB=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=FB(ZB,n);return(0,L.jsx)(xD.button,{type:`button`,...r,ref:t,onClick:Sz(e.onClick,()=>i.onOpenChange(!1))})});QB.displayName=ZB;var $B=`PopoverArrow`,eV=I.forwardRef((e,t)=>{let{__scopePopover:n,...r}=e,i=NB(n);return(0,L.jsx)(SB,{...i,...r,ref:t})});eV.displayName=$B;function tV(e){return e?`open`:`closed`}var nV=IB,rV=RB,iV=BB,aV=WB,oV=KB;function sV({modal:e=!1,...t}){return(0,L.jsx)(nV,{modal:e,...t})}var cV=iV,lV=rV;function uV({children:e,side:t=`top`,align:n=`center`,sideOffset:r=6,className:i=``,...a}){return(0,L.jsx)(aV,{children:(0,L.jsx)(oV,{side:t,align:n,sideOffset:r,avoidCollisions:!0,collisionPadding:12,onEscapeKeyDown:e=>e.stopPropagation(),className:`${Mj} ${Ij} rounded-lg outline-none ${i}`,...a,children:e})})}var dV=3e4,fV=45e3;function pV(e,t){return t?AbortSignal.any([t,AbortSignal.timeout(e)]):AbortSignal.timeout(e)}var mV=`text-[9px]`,hV={claude:`text-fg/75! size-[14px]! translate-y-0!`,codex:`text-fg/75! size-[12.75px]! translate-y-0!`};function gV(){let e=nt({queryKey:[`quota`],queryFn:()=>Y.quota(),staleTime:1e4}),t=nt({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4});return[`claude`,`codex`].some(n=>_V(e.data?.[n],t.data?.[n],e.isLoading))}function _V(e,t,n){return t===`signed-out`||!e&&n?!1:!!e&&e.status===`ok`&&e.windows.length>0}function vV(){let e=Ve(),t=(0,I.useRef)(null),[n,r]=(0,I.useState)(!1),i=nt({queryKey:[`quota`],queryFn:({signal:e})=>Y.quota(void 0,{signal:pV(dV,e)}),refetchInterval:e=>{let t=e.state.data;return!t||t.claude.status!==`ok`||t.codex.status!==`ok`?15e3:3e4},staleTime:1e4,refetchOnWindowFocus:!0}),a=nt({queryKey:[`authStatus`],queryFn:({signal:e})=>Y.authStatus(void 0,{signal:pV(dV,e)}),refetchInterval:12e4,staleTime:3e4,refetchOnWindowFocus:!0}),o=n=>{if(t.current)return;r(!0);let i=Promise.all([Y.quota({force:n===`claude`},{signal:pV(fV)}).then(t=>e.setQueryData([`quota`],t)),e.refetchQueries({queryKey:[`authStatus`]})]).then(()=>{}).catch(()=>{}).finally(()=>{t.current=null,r(!1)});t.current=i};return(0,L.jsxs)(`div`,{"data-quota-bar":!0,className:`flex shrink-0 items-center gap-3 ${mV}`,children:[(0,L.jsx)(yV,{backend:`claude`,quota:i.data?.claude,auth:a.data?.claude,email:a.data?.emails?.claude,loading:i.isLoading,fetching:i.isFetching||n,onRecheck:()=>o(`claude`)}),(0,L.jsx)(yV,{backend:`codex`,quota:i.data?.codex,auth:a.data?.codex,email:a.data?.emails?.codex,loading:i.isLoading,fetching:i.isFetching||n,onRecheck:()=>o(`codex`)})]})}function yV({backend:e,quota:t,auth:n,email:r,loading:i,fetching:a,onRecheck:o}){let s=DR[e];if(!_V(t,n,i))return null;let c=bV(100-SV(t.windows).usedPercent);return(0,L.jsx)(L.Fragment,{children:(0,L.jsxs)(sV,{onOpenChange:e=>{e&&o()},children:[(0,L.jsx)(cV,{asChild:!0,children:(0,L.jsxs)(`button`,{type:`button`,"aria-label":`${s} quota: ${c}% remaining`,className:`flex items-center gap-1.5 min-w-0 rounded outline-none transition-opacity hover:opacity-80 focus-visible:ring-1 focus-visible:ring-border-strong`,children:[(0,L.jsx)(yz,{backend:e,className:hV[e]}),(0,L.jsxs)(`span`,{className:`tabular-nums ${CV(c)}`,children:[c,`%`]})]})}),(0,L.jsxs)(uV,{side:`bottom`,align:`start`,className:`w-[min(15rem,calc(100vw-1.5rem))] p-3 text-[11px] leading-relaxed text-fg`,children:[(0,L.jsxs)(`div`,{className:`mb-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,L.jsx)(yz,{backend:e}),(0,L.jsx)(`span`,{children:s}),t?.planType&&(0,L.jsxs)(`span`,{className:`text-muted/70`,children:[`· `,wV(t.planType),` plan`]}),a&&(0,L.jsx)(Mm,{size:11,className:`animate-spin text-muted/60`,"aria-label":`Rechecking`})]}),r&&(0,L.jsx)(`div`,{"data-quota-account":!0,className:`truncate text-muted/70 select-text`,title:r,children:r})]}),(0,L.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[t.windows.map(e=>{let t=bV(100-e.usedPercent),n=TV(e);return(0,L.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsx)(`span`,{className:`text-muted/80`,children:e.label}),(0,L.jsxs)(`span`,{className:`flex items-center gap-2 tabular-nums`,children:[(0,L.jsxs)(`span`,{className:CV(t),children:[t,`% left`]}),n&&(0,L.jsxs)(`span`,{className:`text-muted/55`,children:[`resets `,n]})]})]},e.key)}),t.detail&&(0,L.jsx)(`li`,{className:`pt-1 text-muted/55`,children:t.detail})]})]})]})})}function bV(e){return Math.max(0,Math.min(100,Math.round(e)))}var xV=25;function SV(e){return e.find(e=>e.key===`5h`)??e.reduce((e,t)=>t.usedPercent>e.usedPercent?t:e)}function CV(e){return e<=8?`text-red-400`:e<=xV?`text-accent`:`text-fg/70`}function wV(e){return e&&e[0].toUpperCase()+e.slice(1)}function TV(e){if(!e.resetsAt)return null;let t=e.resetsAt*1e3,n=new Date(t);if(Number.isNaN(n.getTime()))return null;let r=t-Date.now();if(r<=0)return null;if(r<24*36e5){let e=n.getHours(),t=n.getMinutes(),r=e>=12?`pm`:`am`;return e=e%12||12,t===0?`${e}${r}`:`${e}:${String(t).padStart(2,`0`)}${r}`}return n.toLocaleDateString(void 0,{weekday:`short`})}var EV=`frizz:supervisor-status-wake`;function DV(e){return e!==null}function OV(e){return e?.updateRestart===!0&&e.updateAvailable!==!1}function kV(e){return e?.dev===!0}async function AV(e=fetch){try{let t=await e(`/_frizz/control/status`,{headers:{"cache-control":`no-store`}});if(!t.ok||!t.headers.get(`content-type`)?.includes(`application/json`))return null;let n=await t.json();return n.protocol===1&&(n.state===`ready`||n.state===`restarting`||n.state===`failed`)?n:null}catch{return null}}async function jV(e,t){let n=await t(e,{method:`POST`,headers:{"cache-control":`no-store`}}),r;try{r=await n.json()}catch{}if(!n.headers.get(`content-type`)?.includes(`application/json`)||!r||r.protocol!==1||r.state!==`ready`&&r.state!==`restarting`&&r.state!==`failed`)throw Error(`Frizz restart controls are unavailable for this server`);if(!n.ok)throw Error(r.message??`Restart request failed (${n.status})`);if(r.state===`failed`)throw Error(r.message??`Frizz did not become ready`);return r}function MV(e=fetch){return jV(`/_frizz/control/restart`,e)}function NV(e=fetch){return jV(`/_frizz/control/update-restart`,e)}var PV=8e3,FV=500,IV=[`supervisorStatus`];function LV(e,t){return e===`restarting`||t?FV:PV}var RV=rt({queryKey:IV,queryFn:()=>AV(),refetchInterval:e=>LV(e.state.data?.state,X.controlPlaneRestartPending),staleTime:e=>LV(e.state.data?.state,X.controlPlaneRestartPending)});function zV(){return nt(RV)}var BV=null;function VV(e){BV||(BV=e,window.addEventListener(EV,()=>{e.refetchQueries({queryKey:IV,exact:!0})}))}var HV=`Install the latest version of Frizz. Your running threads will not be affected.`,UV=`A newer version of Frizz is available. Your running threads will not be affected.`,WV=`Restart Frizz. Your running threads will not be affected.`,GV=`fixed left-3 right-3 top-12 z-50 w-auto text-left font-sans sm:absolute sm:right-auto sm:-left-[17px] sm:top-[calc(100%+0.65rem)]`,KV=`absolute -top-[7px] left-4 h-3 w-3 rotate-45 border-l border-t bg-elevated`,qV=`sm:w-[min(23rem,calc(100vw-1.5rem))]`,JV=`sm:w-[min(34rem,calc(100vw-1.5rem))]`,YV=`rounded-xl bg-elevated p-3.5 shadow-xl shadow-black/45`;function XV({open:e,update:t,version:n,updateVersion:r}){if(!e)return null;let i=t?`Update Frizz`:`Restart Frizz`,a=t?r:void 0;return(0,L.jsxs)(`div`,{id:`update-restart-popover`,role:`tooltip`,"aria-label":i,className:`${GV} ${qV} ${YV} border border-border-strong`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${KV} border-border-strong`}),(0,L.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,L.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-fg/10 text-fg`,children:(0,L.jsx)(Gm,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,L.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,L.jsx)(`span`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:i}),n&&(0,L.jsx)(`span`,{className:`font-mono text-[11px] leading-snug text-muted`,children:a?`${n} → ${a}`:n})]})]}),(0,L.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:t?a?UV:HV:WV})]})}var ZV=`Frizz kept running the previous version, and your threads are unaffected.`;function QV({update:e,message:t,onDismiss:n}){return(0,L.jsxs)(`div`,{role:`alert`,className:`${GV} ${JV} ${YV} border border-red-500/45`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`${KV} border-red-500/45`}),(0,L.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,L.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-red-500/15 text-red-300`,children:(0,L.jsx)(rh,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,L.jsx)(`span`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:e?`Update failed`:`Restart failed`}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,onClick:n,className:`-mr-1 ml-auto flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-border-strong`,children:(0,L.jsx)(ah,{"aria-hidden":`true`,size:14,strokeWidth:2.25})})]}),(0,L.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:ZV}),(0,L.jsx)(`pre`,{className:`relative mt-2.5 max-h-64 overflow-y-auto whitespace-pre-wrap break-words rounded-md border border-border bg-panel px-2.5 py-2 font-mono text-[11px] leading-relaxed text-fg/70`,children:t})]})}function $V({update:e,busy:t,updateVersion:n,onFocus:r,onBlur:i,onClick:a}){return(0,L.jsxs)(`button`,{type:`button`,"aria-describedby":`update-restart-popover`,"aria-label":e?`Update Frizz`:`Restart Frizz`,disabled:t,"aria-busy":t||void 0,className:`relative ${hz}`,onFocus:r,onBlur:i,onClick:a,children:[(0,L.jsx)(Gm,{size:14,"aria-hidden":`true`,className:t?`animate-spin`:void 0}),e&&!t&&n&&(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-[2px] top-[2px] h-[4px] w-[4px] rounded-full bg-accent`})]})}function eH(){let e=Zt(X),[t,n]=(0,I.useState)(!1),[r,i]=(0,I.useState)(!1),[a,o]=(0,I.useState)(),[s,c]=(0,I.useState)(),l=(0,I.useRef)(!1),u=(0,I.useRef)(null),d=zV().data??null,f=OV(d),p={version:d?.version,updateVersion:d?.updateVersion};if(!DV(d))return null;let m=l.current&&e.controlPlaneState===`failed`?e.controlPlaneMessage??`Frizz did not become ready`:void 0,h=a??m,g=h&&h!==s?h:void 0,_=async()=>{if(r)return;l.current=!0,n(!1),i(!0),o(void 0),c(void 0);let e=`${window.location.pathname}${window.location.search}${window.location.hash}`;f&&(X.controlPlaneState=`restarting`,X.controlPlaneMessage=null,X.controlPlaneRestartPending=!0);try{f?await NV():await MV(),f?(sessionStorage.setItem(`frizz:reload-after-update-restart`,e),window.dispatchEvent(new Event(EV)),i(!1)):window.location.replace(e)}catch(e){f&&(X.controlPlaneRestartPending=!1,X.controlPlaneState=`ready`,X.controlPlaneMessage=null);let t=e.message.slice(0,140);i(!1),o(t),Z(`${f?`Update & Restart`:`Restart Frizz`} failed`)}};return(0,L.jsxs)(`div`,{ref:u,className:`relative`,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),children:[(0,L.jsx)($V,{update:f,busy:r,updateVersion:p.updateVersion,onFocus:()=>n(!0),onBlur:()=>n(!1),onClick:()=>void _()}),g&&(0,L.jsx)(QV,{update:f,message:g,onDismiss:()=>c(g)}),(0,L.jsx)(XV,{open:t&&!g,update:f,version:p.version,updateVersion:p.updateVersion})]})}function tH(){return(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px shrink-0 bg-border`})}function nH({text:e,title:t,className:n}){return(0,L.jsx)(`span`,{dir:`rtl`,className:`block min-w-0 overflow-hidden text-ellipsis whitespace-nowrap ${n??``}`,title:t,children:(0,L.jsx)(`span`,{dir:`ltr`,className:`[unicode-bidi:isolate]`,children:e})})}function rH(){let e=kC(),t=IU(e),n=gV(),r=e?.githubRepo??null,i=t.state===`verified`?t.label:t.state===`local`?t.name:null,a=t.state===`verified`?`Project: ${t.label}`:t.state===`local`?`Project: ${t.name}; local repository with no git remote`:t.state===`loading`?`Project identity loading`:`Project identity unavailable`;return(0,L.jsxs)(`div`,{"data-status-row":!0,className:`mb-2.5 flex min-w-0 items-center gap-3 text-[12px]`,children:[(0,L.jsx)(fb,{to:`/`,title:`All projects`,"aria-label":`All projects`,className:`${hz} -ml-px`,children:(0,L.jsx)(Em,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(tH,{}),(0,L.jsx)(`button`,{type:`button`,"aria-label":`Settings`,title:`Settings`,className:hz,onClick:()=>X.showSettings=!0,children:(0,L.jsx)(Ym,{size:14,"aria-hidden":`true`})}),(0,L.jsx)(eH,{}),n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(tH,{}),(0,L.jsx)(vV,{})]}),(0,L.jsx)(`span`,{className:`ml-auto flex min-w-0 items-center`,"data-project-identity-state":t.state,"aria-label":a,"aria-busy":t.state===`loading`||void 0,children:i&&r?(0,L.jsx)(`a`,{href:`https://github.com/${r}`,target:`_blank`,rel:`noopener`,title:`Open ${i} on GitHub`,"aria-label":`Open ${i} on GitHub`,className:`block min-w-0 rounded-sm font-semibold text-fg/90 underline-offset-2 outline-none transition-colors hover:text-fg hover:underline focus-visible:ring-1 focus-visible:ring-border-strong`,children:(0,L.jsx)(nH,{text:i})}):i?(0,L.jsx)(nH,{text:i,title:i,className:`font-semibold text-fg/90`}):(0,L.jsx)(`span`,{className:`identity-placeholder w-24`,"aria-hidden":`true`})})]})}var iH=qt({at:{}}),aH=12e3,oH=new Map;function sH(e,t=Date.now()){iH.at[e]=t;let n=oH.get(e);n!==void 0&&clearTimeout(n),oH.set(e,setTimeout(()=>{oH.delete(e),delete iH.at[e]},aH))}function cH(e){let t=oH.get(e);t!==void 0&&(clearTimeout(t),oH.delete(e)),delete iH.at[e]}function lH(e,t,n=Date.now()){if(t===void 0||n-t>12e3)return!1;let r=e.lastActivityAt?Date.parse(e.lastActivityAt):NaN;return!(Number.isFinite(r)&&r>t)}function uH(){return Zt(iH).at}function dH(e,t,n=Date.now()){return t===void 0||!lH(e,t,n)?e:{...e,runtime:`running`,needsYou:!1,pendingAsk:void 0,pendingQuestion:!1,actionableInteraction:!1,lastUserAt:new Date(t).toISOString()}}function fH(e){let t=uH();return(0,I.useMemo)(()=>e.map(e=>dH(e,t[e.id])),[e,t])}var pH=0;function mH(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(pH+=1,`browser-${Date.now()}-${pH}`)}function hH({optimistic:e,request:t,success:n,failure:r}){e(),t().then(()=>n?.(),e=>r(e instanceof Error?e:Error(String(e))))}var gH=new Map;function _H(e,t){let n=(gH.get(e)??Promise.resolve()).then(t,t);return gH.set(e,n.then(()=>{},()=>{})),n}var vH=[300,800,1800,3500],yH=12e4,bH=e=>new Promise(t=>{setTimeout(t,e)});async function xH(e,t,n=bH){for(let r=0;;r++){try{await e()}catch(e){if(r>=vH.length||!lf(e))throw e;t(),await n(vH[r]);continue}t();return}}function SH(e,t,n,r,i,a=yH){let o=new AbortController,s=setTimeout(()=>o.abort(Error(`Frizz did not answer this send`)),a);return Y.followUp({slug:e,sessionId:Dp(X.board,e)?.sessionId??``,message:t,deliveryId:n,freshProcess:r,interrupt:i},{signal:o.signal}).finally(()=>clearTimeout(s))}function CH(e,t,n,r,i){return xH(()=>SH(e,t,n,r,i),()=>sH(e))}function wH(e,t,n,r={}){let i=n.trim();if(!i)return!1;let a=mH();return hH({optimistic:()=>{r.onOptimistic?.(),qC(e,t,i,{scrollToBottom:r.scrollToBottom,deliveryId:a}),sH(t),Y.markRead({slug:t}).catch(()=>{})},request:()=>_H(t,()=>CH(t,i,a,r.freshProcess,r.interrupt)),success:()=>r.onSuccess?.(),failure:n=>{JC(e,t,i,a),cH(t),r.onRollback?.(),Z(r.failureToast?.(n.message)??`Steer failed — ${n.message.slice(0,90)}`)}}),!0}function TH(e){let t=Ve(),[n,r]=(0,I.useState)(0);return{submit:(0,I.useCallback)((n,i={})=>wH(t,e,n,{...i,onOptimistic:()=>{r(e=>e+1),i.onOptimistic?.()},onSuccess:()=>{r(e=>Math.max(0,e-1)),i.onSuccess?.()},onRollback:()=>{r(e=>Math.max(0,e-1)),i.onRollback?.()}}),[t,e]),pending:n>0}}function EH(e,t){return new Promise(n=>{wH(e,t,`Continue exactly where you left off.`,{onSuccess:()=>{Z(`Retrying…`),n()},onRollback:()=>n(),failureToast:e=>`Retry failed: ${e.slice(0,80)}`})||n()})}function DH(e){let t=/^([A-Za-z0-9][\w.-]*)\/([A-Za-z0-9][\w.-]*)#(\d+)$/.exec(e.trim());return t?`https://github.com/${t[1]}/${t[2]}/pull/${t[3]}`:null}var OH=`Waiting for an external update.`;function kH(e){let t=new Set;return e.flatMap(e=>{if(e.kind!==`pr`)return[];let n=e.value.trim();return!n||t.has(n)?[]:(t.add(n),[{ref:n,url:DH(n)}])})}function AH(e){let t=(e.body??``).split(/\n\s*\n/).map(e=>e.trim()).find(Boolean);return t?NH(jH(t.replace(/\s*\n\s*/g,` `))):null}function jH(e){if(e.length<=MH)return e;let t=e.slice(0,MH),n=t.lastIndexOf(` `);return`${(n>MH/2?t.slice(0,n):t).replace(/[.,;:]$/,``)}…`}var MH=240;function NH(e){let t=(e.split(/\s/,1)[0]??``).replace(/[.,:;]+$/,``);return/[^a-zA-Z]/.test(t)||/[A-Z]/.test(t.slice(1))||PH.has(t)?e:e.charAt(0).toUpperCase()+e.slice(1)}var PH=new Set([`npm`,`npx`,`pnpm`,`nub`,`nubx`,`gh`,`git`,`node`,`bun`,`tsc`,`vite`,`curl`,`ssh`]);function FH(e){return e&&LH(e)||null}var IH=new Set([...rl,`shells`,`agents`,`timers`,`prs`,`for`,`title`]);function LH(e){return e.split(`
200
+ `).filter(e=>{let t=/^\s*([a-z][a-z-]*):/i.exec(e)?.[1]?.toLowerCase();return!(t&&IH.has(t))}).join(`
201
+ `).trim()}function RH(e){let t=t=>e.filter(e=>e.kind===t&&e.value.trim()).length,n=[...kH(e).map(e=>e.ref),zH(t(`shell`),`background shell`,`background shells`),zH(t(`agent`),`sub-agent`,`sub-agents`),zH(t(`timer`),`timer`,`timers`)].filter(e=>e!==null);return n.length>0?`waiting on ${BH(n)}`:null}function zH(e,t,n){return e<=0?null:e===1?`a ${t}`:`${e} ${n}`}function BH(e){return e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function VH(e){let t=e.find(e=>e.kind===`pr`);return t?`PR ${t.value}`:null}var HH=qt({at:{}}),UH=12e3,WH=new Map;function GH(e,t=Date.now()){HH.at[e]=t;let n=WH.get(e);n!==void 0&&clearTimeout(n),WH.set(e,setTimeout(()=>{WH.delete(e),delete HH.at[e]},UH))}function KH(e){let t=WH.get(e);t!==void 0&&(clearTimeout(t),WH.delete(e)),delete HH.at[e]}function qH(){return Zt(HH).at}function JH(e,t,n=Date.now()){return t===void 0||n-t>12e3||e.state===`archived`?e:{...e,state:`archived`,archived:!0,needsYou:!1,pendingAsk:void 0,pendingQuestion:!1,actionableInteraction:!1}}function YH(e){let t=qH();return(0,I.useMemo)(()=>e.map(e=>JH(e,t[e.id])),[e,t])}var XH=.5;function ZH(e,t,n=!1){let r=e.map(e=>({id:e.id,height:Math.max(0,e.bottom-e.top),visible:Math.min(e.bottom,t)-Math.max(e.top,0)})).filter(e=>e.visible>0);if(!r.length)return null;if(n)return r[r.length-1].id;let i=t*XH,a=r[0];for(let e of r)if(e.visible>a.visible&&(a=e),e.visible>=Math.min(i,e.height)&&e.visible>=a.visible)return e.id;return a.id}function QH(e,t,n,r){return!e||e.top<=r&&e.bottom>r?!0:Math.abs(t-n)>1}function $H(e,t,n,r,i=8){return n<e+i?n-e-i:r>t-i?r-t+i:0}var eU=`flex h-[19px] w-[19px] items-center justify-center rounded text-muted/70 outline-none transition-colors hover:bg-panel-2 hover:text-fg`,tU=`sticky top-0 self-start h-screen w-[clamp(272px,34vw,680px)] shrink-0 flex flex-col justify-center max-[800px]:static max-[800px]:h-auto max-[800px]:w-full max-[800px]:justify-start max-[800px]:pt-16`;function nU(){let e=Zt(X),t=YH(fH(jC(kC()?.threads??[]))),n=HT(t,Zt(tT).queueOrder),r=vT(xT(t)),i=e.sidebarCollapsed,a=n.active,o=n.snoozed,s=n.inactive,c=(0,I.useRef)(null),[l,u]=(0,I.useState)(null),d=(0,I.useRef)(null),f=(0,I.useCallback)(()=>{let e=[...document.querySelectorAll(`[data-queue-card][data-queue-leaving="false"]`)].map(e=>{let t=e.dataset.queueCard;if(!t)return null;let{top:n,bottom:r}=(e.querySelector(`[data-queue-card-root]`)??e).getBoundingClientRect();return{id:t,top:n,bottom:r}}).filter(e=>e!==null),t=d.current;if(t)if(QH(e.find(e=>e.id===t.id),window.scrollY,t.landedY,40))d.current=null;else{u(t.id);return}let n=Math.max(0,document.documentElement.scrollHeight-window.innerHeight),r=n>0&&window.scrollY>=n-1,i=ZH(e,window.innerHeight,r);u(e=>e===i?e:i)},[]);(0,I.useEffect)(()=>{let e=0,t=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(f)};t(),document.addEventListener(`scroll`,t,{capture:!0,passive:!0}),window.addEventListener(`resize`,t);let n=document.getElementById(`workpane`),r=n?new ResizeObserver(t):null,i=n?new MutationObserver(t):null;return n&&r?.observe(n),n&&i?.observe(n,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-queue-card`,`data-queue-leaving`,`style`,`class`]}),()=>{cancelAnimationFrame(e),document.removeEventListener(`scroll`,t,!0),window.removeEventListener(`resize`,t),r?.disconnect(),i?.disconnect()}},[f,e.view,e.drawers.length]),(0,I.useLayoutEffect)(()=>{let e=c.current;if(!e||!l||window.matchMedia(`(max-width: 800px)`).matches)return;let t=e.querySelector(`[data-sidebar-item="${CSS.escape(l)}"]`);if(!t)return;let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=$H(n.top,n.bottom,r.top,r.bottom);Math.abs(i)>.5&&(e.scrollTop+=i)},[l]);let p=(0,I.useCallback)(e=>{d.current={id:e,landedY:Uf(e)??window.scrollY},u(e)},[]);return(0,L.jsx)(`aside`,{className:tU,children:(0,L.jsxs)(`div`,{className:`flex max-h-[calc(100vh-32px)] min-h-0 min-w-0 w-full flex-col max-[800px]:max-h-none`,children:[(0,L.jsxs)(`div`,{className:`mb-5 shrink-0 px-0.5`,children:[(0,L.jsx)(rH,{}),(0,L.jsx)(fz,{})]}),(0,L.jsxs)(`div`,{ref:c,"data-sidebar-rail":!0,className:`min-h-0 min-w-0 overflow-y-auto overflow-x-hidden max-[800px]:overflow-y-visible`,children:[n.pinned.length>0&&(0,L.jsxs)(`section`,{"aria-label":`Pinned`,children:[n.pinned.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(uU,{t:e,active:l===e.id,onQueueNavigate:p}),(0,L.jsx)(hU,{t:e})]},e.id)),a.length>0&&(0,L.jsx)(`hr`,{className:`my-3 border-border/50`})]}),a.length>0?(()=>{let{running:e,rested:t}=VT(a),n=e=>t=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(uU,{t,active:l===t.id,onQueueNavigate:p,restedAge:e}),(0,L.jsx)(hU,{t})]},t.id);return(0,L.jsxs)(L.Fragment,{children:[t.map(n(!0)),e.length>0&&t.length>0&&(0,L.jsx)(`hr`,{className:`my-3 border-border/50`}),e.map(n(!1))]})})():n.pinned.length===0?(0,L.jsx)(`div`,{className:`py-1 pl-5 pr-1.5 text-[11.5px] text-muted/50`,children:`No open threads`}):null,o.length>0&&(0,L.jsxs)(`section`,{"aria-label":`Snoozed`,children:[(0,L.jsx)(`hr`,{className:`my-3 border-border/50`}),(0,L.jsx)(rU,{label:`Snoozed`,count:o.length,collapsed:i.snoozed,onToggle:()=>X.sidebarCollapsed.snoozed=!X.sidebarCollapsed.snoozed}),!i.snoozed&&o.map(e=>(0,L.jsxs)(`div`,{children:[(0,L.jsx)(uU,{t:e,active:l===e.id,onQueueNavigate:p}),(0,L.jsx)(hU,{t:e})]},e.id))]}),s.length>0&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`hr`,{className:`my-3 border-border/50`}),(0,L.jsx)(rU,{label:`Done`,count:s.length,collapsed:i.inactive,onToggle:()=>X.sidebarCollapsed.inactive=!X.sidebarCollapsed.inactive}),!i.inactive&&(0,L.jsx)(oU,{threads:s,railRef:c,activeId:l,onQueueNavigate:p})]}),r.length>0&&(0,L.jsxs)(`section`,{"aria-label":`External`,children:[(0,L.jsx)(`hr`,{className:`my-3 border-border/50`}),(0,L.jsx)(rU,{label:`External`,count:r.length,collapsed:i.external,onToggle:()=>X.sidebarCollapsed.external=!X.sidebarCollapsed.external}),!i.external&&r.map(e=>(0,L.jsx)(uU,{t:e,active:l===e.id,onQueueNavigate:p,restedAge:!0},e.id))]})]})]})})}function rU({label:e,count:t,collapsed:n,onToggle:r}){let i=(0,L.jsxs)(L.Fragment,{children:[r?(0,L.jsx)(tm,{size:11,className:`transition-transform ${n?``:`rotate-90`}`}):(0,L.jsx)(`span`,{className:`w-[11px] shrink-0`,"aria-hidden":!0}),(0,L.jsx)(`span`,{children:e}),(0,L.jsx)(`span`,{className:`ml-1.5 tabular-nums text-muted/60`,children:t})]}),a=`flex w-full items-center gap-1 px-1.5 py-1 text-[11px] uppercase tracking-wide text-muted/70`;return r?(0,L.jsx)(`button`,{onClick:r,className:`${a} transition-colors hover:text-fg`,children:i}):(0,L.jsx)(`div`,{className:a,children:i})}var iU=27,aU=8;function oU({threads:e,railRef:t,activeId:n,onQueueNavigate:r}){let i=(0,I.useRef)(null),[a,o]=(0,I.useState)(0),s=jw({count:e.length,getScrollElement:()=>t.current,getItemKey:t=>e[t]?.id??t,estimateSize:()=>iU,overscan:aU,scrollMargin:a});return(0,I.useLayoutEffect)(()=>{let e=t.current,n=i.current;if(!e||!n)return;let r=()=>{let t=n.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;o(e=>Math.abs(e-t)<.5?e:t)};r();let a=new ResizeObserver(r);return a.observe(e),()=>a.disconnect()}),(0,L.jsx)(`div`,{ref:i,"data-done-band":!0,className:`relative w-full`,style:{height:s.getTotalSize()},children:s.getVirtualItems().map(t=>{let i=e[t.index];return i?(0,L.jsxs)(`div`,{ref:s.measureElement,"data-index":t.index,className:`absolute left-0 top-0 w-full`,style:{transform:`translateY(${t.start-a}px)`},children:[(0,L.jsx)(uU,{t:i,active:n===i.id,onQueueNavigate:r}),(0,L.jsx)(hU,{t:i})]},i.id):null})})}var sU=16,cU=12;function lU({title:e,children:t}){let n=e.trimEnd(),r=n.lastIndexOf(` `)+1,i=n.length-r<=sU?r:n.length-cU;return i>=n.length?(0,L.jsxs)(L.Fragment,{children:[e,t]}):(0,L.jsxs)(L.Fragment,{children:[n.slice(0,i),(0,L.jsxs)(`span`,{className:`whitespace-nowrap`,children:[n.slice(i),t]})]})}var uU=(0,I.memo)(function({t:e,legacy:t,active:n=!1,onQueueNavigate:r,restedAge:i=!1}){let a=!t&&e.foreign===!0,o=!t&&OT(e),s=!t&&fT(e),c=!t&&LT(e),l=!t&&ST(e);return(0,L.jsxs)(`div`,{"data-sidebar-item":e.id,className:`group relative flex min-w-0 items-start rounded-md transition-[color,opacity] after:pointer-events-none after:absolute after:inset-0 after:rounded-md after:bg-white/[0.04] after:opacity-0 after:transition-opacity hover:after:opacity-100 ${t?`opacity-80`:o?`opacity-65 hover:opacity-90 focus-within:opacity-90`:``}`,children:[(0,L.jsx)(`span`,{"aria-hidden":`true`,"data-sidebar-marker-rail":!0,className:`pointer-events-none absolute inset-y-0 left-0 w-5`,children:n&&(0,L.jsx)(`span`,{"data-sidebar-scroll-marker":!0,className:`absolute inset-y-0 left-1 w-[2px] rounded-full bg-accent`})}),(0,L.jsxs)(`button`,{onClick:()=>{if(e.needsYou&&sp(e.id)){r?.(e.id);return}np(e.id)},"aria-current":n?`location`:void 0,className:`min-w-0 flex-1 flex items-start gap-2 pb-1 pl-5 pr-1.5 pt-1 text-left`,children:[(0,L.jsx)(`span`,{className:`w-4 h-[19px] shrink-0 flex items-center justify-center`,children:(0,L.jsx)(bU,{t:e,legacy:t})}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 flex flex-col`,children:(0,L.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-3`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-[13px] leading-[19px] ${s?`text-fg/50`:o?`text-fg/75`:`text-fg/90`}`,children:(0,L.jsxs)(lU,{title:aT(e),children:[!t&&(0,L.jsx)(yz,{backend:e.backend,className:`ml-1`}),a&&(0,L.jsx)(`span`,{className:`petite-caps ml-1.5 inline-block rounded border border-border/60 px-1 align-[2px] text-[9.5px] leading-[14px] text-muted/55`,title:`Read-only — running in an external terminal`,children:`terminal`}),t&&(0,L.jsx)(gU,{status:e.archived?`archived`:e.status})]})}),i&&(0,L.jsx)(dU,{t:e,yieldsToRetry:!0}),l&&!i&&(0,L.jsx)(pU,{})]})})]}),t&&(0,L.jsx)(`div`,{className:`absolute right-1 top-1 hidden group-hover:flex items-stretch rounded-md bg-panel shadow-sm shadow-black/30`,children:(0,L.jsx)(OI,{slug:e.id,size:`sm`})}),!t&&(0,L.jsxs)(`div`,{className:`absolute right-1.5 top-1 hidden items-center gap-0.5 bg-bg group-hover:flex group-focus-within:flex before:pointer-events-none before:absolute before:inset-y-0 before:right-full before:w-3 before:bg-linear-to-r before:from-transparent before:to-bg`,children:[!a&&!l&&(0,L.jsx)(mU,{t:e,className:`-mr-0.5`}),(0,L.jsx)(zj,{slug:e.id,size:12,className:eU}),c&&(0,L.jsx)(fU,{slug:e.id}),!a&&l&&(0,L.jsx)(mU,{t:e})]})]})});function dU({t:e,yieldsToRetry:t}){let n=sE(),r=gT(e),i=JT(r,n);return!r||!i?null:(0,L.jsx)(`time`,{dateTime:r,"data-rail-rested-age":!0,title:GT(r,n)??void 0,"aria-label":`Rested ${GT(r,n)??i}`,className:`shrink-0 tabular-nums text-[10.5px] leading-[19px] text-muted/55 ${t?`transition-opacity group-hover:opacity-0 group-focus-within:opacity-0`:``}`,children:i})}function fU({slug:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return(0,L.jsx)(Rj,{label:`Retry — resume this session where it left off`,children:(0,L.jsx)(`button`,{"data-sidebar-retry":e,"aria-label":`Retry exited session`,disabled:n,onMouseDown:e=>e.preventDefault(),onClick:n=>{n.stopPropagation(),r(!0),EH(t,e).finally(()=>r(!1))},className:`${eU} disabled:opacity-50`,children:n?(0,L.jsx)(Mm,{size:13,className:`animate-spin`}):(0,L.jsx)(qm,{size:13})})})}function pU(){return(0,L.jsx)(`span`,{"aria-hidden":!0,"data-rail-pin-mark":!0,className:`-ml-1 flex h-[19px] w-[19px] shrink-0 items-center justify-center self-start text-muted/55 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0`,children:(0,L.jsx)(Hm,{size:12,fill:`currentColor`})})}function mU({t:e,className:t=``}){let n=ST(e),[r,i]=(0,I.useState)(!1);return(0,L.jsx)(Rj,{label:n?`Unpin — return this thread to the rail's bands`:`Pin — keep this thread at the very top`,children:(0,L.jsx)(`button`,{"data-sidebar-pin":e.id,"aria-label":n?`Unpin thread`:`Pin thread`,disabled:r,onMouseDown:e=>e.preventDefault(),onClick:t=>{t.stopPropagation(),i(!0),Y.setThreadPinned({slug:e.id,sessionId:e.sessionId??``,pinned:!n}).catch(e=>Z(`${n?`Unpin`:`Pin`} failed: ${String(e instanceof Error?e.message:e).slice(0,80)}`)).finally(()=>i(!1))},className:`${eU} disabled:opacity-50 ${t}`,children:n?(0,L.jsx)(Vm,{size:12,fill:`currentColor`}):(0,L.jsx)(Hm,{size:12})})})}function hU({t:e}){let t=VE(e.subAgents??[],`rail`);return t.length===0?null:(0,L.jsx)(`div`,{className:`flex flex-col`,children:t.map(t=>(0,L.jsx)(WE,{kind:`AGENT`,label:t.label,state:t.state,density:`rail`,depth:t.depth,startedAt:t.startedAt,parentSlug:e.id,onOpen:()=>ep(e.id,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}),onDismiss:Vj(e.id,t),title:t.subagentType?`[${t.subagentType}] ${t.label}`:t.label},t.id))})}function gU({status:e}){let t=e===`archived`?`Done`:e;return(0,L.jsx)(`span`,{className:`petite-caps ml-1.5 inline-block rounded border px-1 align-[2px] leading-[14px] text-[9.5px] ${iT[e]??`text-muted border-border`}`,children:t})}function _U(e,t,n=null){return[[t,RH(e.lastFence?.kind===`awaiting`?e.lastFence.hints:[]),n].filter(e=>!!e).join(` — `),vU(e)].filter(e=>!!e).join(`
202
202
 
203
- `)}function _U(e){return e.lastFence?.kind===`awaiting`?kH(e.lastFence):null}var vU=7;function yU({t:e,legacy:t}){let{node:n,tip:r}=t?OU(e):bU(e),i=t?void 0:FT(e);return r?(0,L.jsx)(Lj,{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 bU(e){let t=TU(e);if(FT(e)===`snoozed`)return t;let n=DT(e),r=n?Yw(n,e.snoozePrompt):null;return r?{node:t.node,tip:xU(t.tip,r)}:t}function xU(e,t){if(!e)return t;let[n,...r]=e.split(`
203
+ `)}function vU(e){return e.lastFence?.kind===`awaiting`?AH(e.lastFence):null}var yU=7;function bU({t:e,legacy:t}){let{node:n,tip:r}=t?jU(e):xU(e),i=t?void 0:IT(e);return r?(0,L.jsx)(Rj,{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 xU(e){let t=OU(e);if(IT(e)===`snoozed`)return t;let n=DT(e),r=n?Yw(n,e.snoozePrompt):null;return r?{node:t.node,tip:SU(t.tip,r)}:t}function SU(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 SU=(0,L.jsx)(EU,{children:(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-rail-dot`,"data-running-indicator":`thread-background`})}),CU=9,wU=(0,L.jsx)(EU,{children:(0,L.jsx)(wm,{size:CU,className:`text-muted/70`,style:{transform:`translateX(${CU/24}px)`}})});function TU(e){let t=FT(e);if(t===`archived`)return{node:(0,L.jsx)(EU,{children:(0,L.jsx)(Qp,{size:10,strokeWidth:3,className:`text-muted/75`})}),tip:`Done`};if(t===`needs-input`)return{node:(0,L.jsx)(EU,{children:(0,L.jsx)(DU,{ch:`?`,muted:!0})}),tip:`Needs your input`};if(t===`working`)return{node:(0,L.jsx)(sE,{}),tip:`Working`};if(t===`background`)return{node:SU,tip:gU(e,e.lastFence?.kind===`awaiting`&&LH(e.lastFence.hints)!==null?`At rest`:`At rest — a background shell is still running`)};if(t===`done`)return{node:(0,L.jsx)(EU,{children:(0,L.jsx)(Qp,{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)(EU,{accent:!0,children:(0,L.jsx)(DU,{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 ${ZT(t.resumesAt)}`:`continuing automatically once the window resets`:`won't resume by itself — Retry to continue`;return{node:(0,L.jsx)(EU,{accent:!0,children:(0,L.jsx)(Tm,{size:9,className:`text-accent`})}),tip:`Paused by the ${t?.backend===`codex`?`Codex`:`Claude`} ${n} — ${r}`}}if(t===`pr`)return{node:wU,tip:gU(e,`At rest`)};if(t===`snoozed`){let t=(0,L.jsx)(EU,{children:(0,L.jsx)(Tm,{size:9,className:`text-muted/70`})}),n=wU,r=PT(e)?n:t,i=DT(e);if(i){let t=Yw(i,e.snoozePrompt)??`Snoozed until a scheduled check`;return{node:r,tip:gU(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:PT(e)?n:SU,tip:a}:{node:t,tip:(typeof e.revalidate==`string`?Xw(e.revalidate):null)??`Auto-snoozed until a scheduled check`};let o=e.lastFence.hints.find(e=>e.kind===`pr`||e.kind===`shell`||e.kind===`agent`||e.kind===`timer`)?.kind;return{node:PT(e)?n:o===`shell`||o===`agent`?SU:(0,L.jsx)(EU,{children:(0,L.jsx)(dm,{size:9,className:`text-muted/70`})}),tip:gU(e,a??`Snoozed`)}}return{node:(0,L.jsx)(EU,{children:(0,L.jsx)(pm,{size:11,className:`text-muted/70`})}),tip:gU(e,`At rest`)}}function EU({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 DU({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 OU(e){if(e.runtime===`running`||e.runtime===`spawning`||e.runtime===`perm-prompt`)return{node:(0,L.jsx)(kU,{}),tip:`Working`};let t=(e.subAgents??[]).some(e=>e.state===`running`);return e.runtime===`turn-idle`&&t&&!e.humanBlocked?{node:(0,L.jsx)(kU,{}),tip:`Working`}:pT(e)?{node:(0,L.jsx)(AU,{}),tip:`Needs your input`}:e.status===`needs-human`?{node:(0,L.jsx)(jU,{}),tip:`Awaiting you — open to read & reply`}:e.status===`blocked`&&e.mechanism===`timer`?{node:(0,L.jsx)(nh,{size:8,className:`text-muted/70`}),tip:`Waiting on a timer`}:e.status===`blocked`&&e.mechanism===`threads`?{node:(0,L.jsx)(om,{size:8,className:`text-muted/70`}),tip:`Waiting on other work`}:{node:(0,L.jsx)(MU,{}),tip:null}}function kU(){return(0,L.jsx)(`span`,{className:`block rounded-full border border-muted/70 border-t-transparent animate-spin`,style:{width:8,height:8}})}function AU(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-sky-400`,style:{width:vU,height:vU}})}function jU(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-yellow-400`,style:{width:vU,height:vU}})}function MU(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-muted/30`,style:{width:vU,height:vU}})}function NU(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 PU={planning:`Being designed`,planned:`Roadmap`,active:`Active`,"needs-human":`Awaiting you`,blocked:`Blocked`,done:`Done`,dismissed:`Dismissed`,archived:`Done`};function FU({status:e}){let t=_T(jC(kC()?.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:PU[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:()=>$f(`thread`,e.id),children:[(0,L.jsx)(`div`,{className:`leading-snug`,children:aT(e)}),e.statusText&&(0,L.jsx)(`div`,{className:`text-[11px] text-muted mt-0.5`,children:e.statusText})]},e.id))]})]})}var IU=21,LU=4/15;function RU({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*LU},children:e})}function zU({size:e=18}){return(0,L.jsx)(RU,{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 BU({size:e=18}){return(0,L.jsx)(RU,{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 VU({size:e=18}){return(0,L.jsx)(RU,{size:e,tone:`border-muted/40`,children:(0,L.jsx)(Qp,{size:Math.round(e*10/15),strokeWidth:3,className:`text-muted/85`})})}function HU({size:e=18}){return(0,L.jsx)(RU,{size:e,children:(0,L.jsx)(Tm,{size:Math.round(e*10/15),className:`text-muted/75`})})}function UU({kind:e}){return e===`needs-input`?(0,L.jsx)(BU,{}):e===`stalled`?(0,L.jsx)(RU,{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)(zU,{}):e===`limit`?(0,L.jsx)(RU,{tone:`border-accent/90`,children:(0,L.jsx)(Tm,{size:12,className:`text-accent`})}):e===`snoozed`?(0,L.jsx)(HU,{}):e===`done`||e===`archived`?(0,L.jsx)(VU,{}):(0,L.jsx)(RU,{})}var WU=76,GU=10;function KU({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:WU},children:[(0,L.jsx)(dm,{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:WU},children:[(0,L.jsx)(Qp,{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)<GU||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 qU({t:e,last:t,openSwipe:n,onOpenSwipe:r}){let i=Zt(tT).snoozePreset,a=oE(),o=FT(e),s=gT(e),c=e.runtime===`running`||e.runtime===`spawning`||o===`working`||o===`background`?null:qT(s,a),l=e.lastFence?.kind===`awaiting`?BH(e.lastFence.hints):null,u=BE(e.subAgents??[],`rail`);return(0,L.jsxs)(`div`,{className:o===`snoozed`?`opacity-60`:void 0,children:[(0,L.jsx)(KU,{open:n,onOpenChange:r,snoozeLabel:Lw(i),onSnooze:async()=>{try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:Bw(i),prompt:null}),Z(`Snoozed · ${Lw(i)}`)}catch(e){Z(e instanceof Error?e.message.slice(0,100):`Snooze failed`)}},onDone:async()=>{WH(e.id);try{let t=await Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:!1});if(t.needsConfirmation){GH(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){GH(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:()=>np(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)(UU,{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:[aT(e),(0,L.jsx)(vz,{backend:e.backend,className:`ml-1.5`})]}),c?(0,L.jsx)(`span`,{className:`shrink-0 text-[11.5px] leading-[21px] tabular-nums text-muted/60`,children:c}):null]}),l?(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[13px] leading-[18px] text-muted`,children:l}):null,e.activity?(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[13px] leading-[18px] text-muted/85`,children:e.activity}):null]})]})}),u.length>0?(0,L.jsx)(`div`,{className:`flex flex-col pb-1`,children:u.map(t=>(0,L.jsx)(UE,{kind:`AGENT`,label:t.label,state:t.state,density:`rail`,depth:t.depth,startedAt:t.startedAt,parentSlug:e.id,onOpen:()=>ep(e.id,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}),onDismiss:Bj(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 JU({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 YU({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 XU={open:{cls:`bg-live`,word:`connected`},connecting:{cls:`bg-accent`,word:`connecting…`},closed:{cls:`bg-red-500`,word:`disconnected`}};function ZU({connection:e,onClose:t}){let n=XU[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)(_V,{})]}),(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)(Ym,{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)(tm,{size:17,className:`shrink-0 text-muted/45`})]})})})]})]})}function QU(){let e=Zt(X),t=kC(),[n,r]=(0,I.useState)(`queue`),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(null),c=JH(dH(jC(t?.threads??[]))),l=Zt(tT).queueOrder,u=(0,I.useMemo)(()=>VT(c,l),[c,l]),d=(0,I.useMemo)(()=>{let e=u.active.filter(pT),t=u.active.filter(e=>!pT(e));return[...u.pinned,...e,...t]},[u.pinned,u.active]),f=d.filter(pT).length,p=n===`queue`?d:n===`snoozed`?u.snoozed:u.inactive,m=e.view.startsWith(`status:`)?e.view.slice(7):null,h=NU(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)(em,{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)(pm,{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)(FU,{status:m})}):p.length===0?(0,L.jsx)(JU,{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)(qU,{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)(Wm,{size:24,strokeWidth:2.2})}),i?(0,L.jsx)(ZU,{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)(YU,{active:n===`queue`,label:`Queue`,count:f>0?f:d.length,asks:f>0,onClick:()=>r(`queue`),icon:(0,L.jsx)(zU,{size:IU})}),(0,L.jsx)(YU,{active:n===`snoozed`,label:`Snoozed`,count:u.snoozed.length,onClick:()=>r(`snoozed`),icon:(0,L.jsx)(HU,{size:IU})}),(0,L.jsx)(YU,{active:n===`done`,label:`Done`,count:u.inactive.length,onClick:()=>r(`done`),icon:(0,L.jsx)(VU,{size:IU})})]})})]})}var $U=`(max-width: 700px)`,eW=new Set,tW=null;function nW(e){return typeof window>`u`?()=>{}:(tW||(tW=window.matchMedia($U),tW.addEventListener(`change`,()=>eW.forEach(e=>e()))),eW.add(e),()=>eW.delete(e))}function rW(){return tW?tW.matches:typeof window<`u`&&window.matchMedia($U).matches}function iW(){return(0,I.useSyncExternalStore)(nW,rW,()=>!1)}var aW={schedule:(e,t)=>window.setTimeout(e,t),cancel:e=>window.clearTimeout(e)},oW=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??aW,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 sW(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var cW=sW();function lW(e){cW=e}var uW={exec:()=>null};function dW(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(fW.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var fW={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`)},pW=/^(?:[ \t]*(?:\n|$))+/,mW=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,hW=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,gW=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,_W=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,vW=/(?:[*+-]|\d{1,9}[.)])/,yW=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,bW=dW(yW).replace(/bull/g,vW).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(),xW=dW(yW).replace(/bull/g,vW).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(),SW=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,CW=/^[^\n]+/,wW=/(?!\s*\])(?:\\.|[^\[\]\\])+/,TW=dW(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,wW).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),EW=dW(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,vW).getRegex(),DW=`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`,OW=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,kW=dW(`^ {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`,OW).replace(`tag`,DW).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),AW=dW(SW).replace(`hr`,gW).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`,DW).getRegex(),jW={blockquote:dW(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,AW).getRegex(),code:mW,def:TW,fences:hW,heading:_W,hr:gW,html:kW,lheading:bW,list:EW,newline:pW,paragraph:AW,table:uW,text:CW},MW=dW(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,gW).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`,DW).getRegex(),NW={...jW,lheading:xW,table:MW,paragraph:dW(SW).replace(`hr`,gW).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,MW).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`,DW).getRegex()},PW={...jW,html:dW(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,OW).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:uW,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:dW(SW).replace(`hr`,gW).replace(`heading`,` *#{1,6} *[^
209
- ]`).replace(`lheading`,bW).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},FW=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,IW=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,LW=/^( {2,}|\\)\n(?!\s*$)/,RW=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,zW=/[\p{P}\p{S}]/u,BW=/[\s\p{P}\p{S}]/u,VW=/[^\s\p{P}\p{S}]/u,HW=dW(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,BW).getRegex(),UW=/(?!~)[\p{P}\p{S}]/u,WW=/(?!~)[\s\p{P}\p{S}]/u,GW=/(?:[^\s\p{P}\p{S}]|~)/u,KW=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,qW=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,JW=dW(qW,`u`).replace(/punct/g,zW).getRegex(),YW=dW(qW,`u`).replace(/punct/g,UW).getRegex(),XW=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,ZW=dW(XW,`gu`).replace(/notPunctSpace/g,VW).replace(/punctSpace/g,BW).replace(/punct/g,zW).getRegex(),QW=dW(XW,`gu`).replace(/notPunctSpace/g,GW).replace(/punctSpace/g,WW).replace(/punct/g,UW).getRegex(),$W=dW(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,VW).replace(/punctSpace/g,BW).replace(/punct/g,zW).getRegex(),eG=dW(/\\(punct)/,`gu`).replace(/punct/g,zW).getRegex(),tG=dW(/^<(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(),nG=dW(OW).replace(`(?:-->|$)`,`-->`).getRegex(),rG=dW(`^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`,nG).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),iG=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,aG=dW(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,iG).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),oG=dW(/^!?\[(label)\]\[(ref)\]/).replace(`label`,iG).replace(`ref`,wW).getRegex(),sG=dW(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,wW).getRegex(),cG={_backpedal:uW,anyPunctuation:eG,autolink:tG,blockSkip:KW,br:LW,code:IW,del:uW,emStrongLDelim:JW,emStrongRDelimAst:ZW,emStrongRDelimUnd:$W,escape:FW,link:aG,nolink:sG,punctuation:HW,reflink:oG,reflinkSearch:dW(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,oG).replace(`nolink`,sG).getRegex(),tag:rG,text:RW,url:uW},lG={...cG,link:dW(/^!?\[(label)\]\((.*?)\)/).replace(`label`,iG).getRegex(),reflink:dW(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,iG).getRegex()},uG={...cG,emStrongRDelimAst:QW,emStrongLDelim:YW,url:dW(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},dG={...uG,br:dW(LW).replace(`{2,}`,`*`).getRegex(),text:dW(uG.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},fG={normal:jW,gfm:NW,pedantic:PW},pG={normal:cG,gfm:uG,breaks:dG,pedantic:lG},mG={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},hG=e=>mG[e];function gG(e,t){if(t){if(fW.escapeTest.test(e))return e.replace(fW.escapeReplace,hG)}else if(fW.escapeTestNoEncode.test(e))return e.replace(fW.escapeReplaceNoEncode,hG);return e}function _G(e){try{e=encodeURI(e).replace(fW.percentDecode,`%`)}catch{return null}return e}function vG(e,t){let n=e.replace(fW.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(fW.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(fW.slashPipe,`|`);return n}function yG(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 bG(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 xG(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 SG(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
208
+ `)}var CU=(0,L.jsx)(kU,{children:(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-rail-dot`,"data-running-indicator":`thread-background`})}),wU=9,TU=(0,L.jsx)(kU,{children:(0,L.jsx)(wm,{size:wU,className:`text-muted/70`,style:{transform:`translateX(${wU/24}px)`}})}),EU=(0,L.jsx)(kU,{children:(0,L.jsx)(Tm,{size:9,className:`text-muted/70`})});function DU(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 ${vE(n-t)}`:`firing…`}function OU(e){let t=IT(e);if(t===`archived`)return{node:(0,L.jsx)(kU,{children:(0,L.jsx)(Qp,{size:10,strokeWidth:3,className:`text-muted/75`})}),tip:`Done`};if(t===`needs-input`)return{node:(0,L.jsx)(kU,{children:(0,L.jsx)(AU,{ch:`?`,muted:!0})}),tip:`Needs your input`};if(t===`working`)return{node:(0,L.jsx)(cE,{}),tip:`Working`};if(t===`background`)return{node:CU,tip:_U(e,e.lastFence?.kind===`awaiting`&&RH(e.lastFence.hints)!==null?`At rest`:`At rest — a background shell is still running`)};if(t===`done`)return{node:(0,L.jsx)(kU,{children:(0,L.jsx)(Qp,{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)(kU,{accent:!0,children:(0,L.jsx)(AU,{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 ${QT(t.resumesAt)}`:`continuing automatically once the window resets`:`won't resume by itself — Retry to continue`;return{node:(0,L.jsx)(kU,{accent:!0,children:(0,L.jsx)(Tm,{size:9,className:`text-accent`})}),tip:`Paused by the ${t?.backend===`codex`?`Codex`:`Claude`} ${n} — ${r}`}}if(t===`pr`)return{node:TU,tip:_U(e,`At rest`)};if(t===`timer`)return{node:EU,tip:_U(e,e.lastFence?.kind===`awaiting`&&RH(e.lastFence.hints)!==null?`At rest`:`At rest — waiting on a timer`,DU(e))};if(t===`snoozed`){let t=EU,n=TU,r=PT(e)?n:t,i=DT(e);if(i){let t=Yw(i,e.snoozePrompt)??`Snoozed until a scheduled check`;return{node:r,tip:_U(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:PT(e)?n:CU,tip:a}:{node:t,tip:(typeof e.revalidate==`string`?Xw(e.revalidate):null)??`Auto-snoozed until a scheduled check`};let o=e.lastFence.hints.find(e=>e.kind===`pr`||e.kind===`shell`||e.kind===`agent`||e.kind===`timer`)?.kind;return{node:PT(e)?n:o===`shell`||o===`agent`?CU:t,tip:_U(e,a??`Snoozed`,o===`timer`?DU(e):null)}}return{node:(0,L.jsx)(kU,{children:(0,L.jsx)(pm,{size:11,className:`text-muted/70`})}),tip:_U(e,`At rest`)}}function kU({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 AU({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 jU(e){if(e.runtime===`running`||e.runtime===`spawning`||e.runtime===`perm-prompt`)return{node:(0,L.jsx)(MU,{}),tip:`Working`};let t=(e.subAgents??[]).some(e=>e.state===`running`);return e.runtime===`turn-idle`&&t&&!e.humanBlocked?{node:(0,L.jsx)(MU,{}),tip:`Working`}:pT(e)?{node:(0,L.jsx)(NU,{}),tip:`Needs your input`}:e.status===`needs-human`?{node:(0,L.jsx)(PU,{}),tip:`Awaiting you — open to read & reply`}:e.status===`blocked`&&e.mechanism===`timer`?{node:(0,L.jsx)(nh,{size:8,className:`text-muted/70`}),tip:`Waiting on a timer`}:e.status===`blocked`&&e.mechanism===`threads`?{node:(0,L.jsx)(om,{size:8,className:`text-muted/70`}),tip:`Waiting on other work`}:{node:(0,L.jsx)(FU,{}),tip:null}}function MU(){return(0,L.jsx)(`span`,{className:`block rounded-full border border-muted/70 border-t-transparent animate-spin`,style:{width:8,height:8}})}function NU(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-sky-400`,style:{width:yU,height:yU}})}function PU(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-yellow-400`,style:{width:yU,height:yU}})}function FU(){return(0,L.jsx)(`span`,{className:`block rounded-full bg-muted/30`,style:{width:yU,height:yU}})}function IU(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 LU={planning:`Being designed`,planned:`Roadmap`,active:`Active`,"needs-human":`Awaiting you`,blocked:`Blocked`,done:`Done`,dismissed:`Dismissed`,archived:`Done`};function RU({status:e}){let t=_T(jC(kC()?.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:LU[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:()=>$f(`thread`,e.id),children:[(0,L.jsx)(`div`,{className:`leading-snug`,children:aT(e)}),e.statusText&&(0,L.jsx)(`div`,{className:`text-[11px] text-muted mt-0.5`,children:e.statusText})]},e.id))]})]})}var zU=21,BU=4/15;function VU({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*BU},children:e})}function HU({size:e=18}){return(0,L.jsx)(VU,{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 UU({size:e=18}){return(0,L.jsx)(VU,{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 WU({size:e=18}){return(0,L.jsx)(VU,{size:e,tone:`border-muted/40`,children:(0,L.jsx)(Qp,{size:Math.round(e*10/15),strokeWidth:3,className:`text-muted/85`})})}function GU({size:e=18}){return(0,L.jsx)(VU,{size:e,children:(0,L.jsx)(Tm,{size:Math.round(e*10/15),className:`text-muted/75`})})}function KU({kind:e}){return e===`needs-input`?(0,L.jsx)(UU,{}):e===`stalled`?(0,L.jsx)(VU,{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)(HU,{}):e===`limit`?(0,L.jsx)(VU,{tone:`border-accent/90`,children:(0,L.jsx)(Tm,{size:12,className:`text-accent`})}):e===`snoozed`||e===`timer`?(0,L.jsx)(GU,{}):e===`done`||e===`archived`?(0,L.jsx)(WU,{}):(0,L.jsx)(VU,{})}var qU=76,JU=10;function YU({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:qU},children:[(0,L.jsx)(dm,{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:qU},children:[(0,L.jsx)(Qp,{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)<JU||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 XU({t:e,last:t,openSwipe:n,onOpenSwipe:r}){let i=Zt(tT).snoozePreset,a=sE(),o=IT(e),s=gT(e),c=e.runtime===`running`||e.runtime===`spawning`||o===`working`||o===`background`?null:JT(s,a),l=e.lastFence?.kind===`awaiting`?VH(e.lastFence.hints):null,u=VE(e.subAgents??[],`rail`);return(0,L.jsxs)(`div`,{className:o===`snoozed`?`opacity-60`:void 0,children:[(0,L.jsx)(YU,{open:n,onOpenChange:r,snoozeLabel:Lw(i),onSnooze:async()=>{try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:Bw(i),prompt:null}),Z(`Snoozed · ${Lw(i)}`)}catch(e){Z(e instanceof Error?e.message.slice(0,100):`Snooze failed`)}},onDone:async()=>{GH(e.id);try{let t=await Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:!1});if(t.needsConfirmation){KH(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){KH(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:()=>np(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)(KU,{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:[aT(e),(0,L.jsx)(yz,{backend:e.backend,className:`ml-1.5`})]}),c?(0,L.jsx)(`span`,{className:`shrink-0 text-[11.5px] leading-[21px] tabular-nums text-muted/60`,children:c}):null]}),l?(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[13px] leading-[18px] text-muted`,children:l}):null,e.activity?(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[13px] leading-[18px] text-muted/85`,children:e.activity}):null]})]})}),u.length>0?(0,L.jsx)(`div`,{className:`flex flex-col pb-1`,children:u.map(t=>(0,L.jsx)(WE,{kind:`AGENT`,label:t.label,state:t.state,density:`rail`,depth:t.depth,startedAt:t.startedAt,parentSlug:e.id,onOpen:()=>ep(e.id,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}),onDismiss:Vj(e.id,t),title:t.subagentType?`[${t.subagentType}] ${t.label}`:t.label},t.id))}):null,t?null:(0,L.jsx)(`div`,{className:`ml-[46px] h-px bg-border/70`})]})}function ZU({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 QU({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 $U={open:{cls:`bg-live`,word:`connected`},connecting:{cls:`bg-accent`,word:`connecting…`},closed:{cls:`bg-red-500`,word:`disconnected`}};function eW({connection:e,onClose:t}){let n=$U[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)(vV,{})]}),(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)(Ym,{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)(tm,{size:17,className:`shrink-0 text-muted/45`})]})})})]})]})}function tW(){let e=Zt(X),t=kC(),[n,r]=(0,I.useState)(`queue`),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(null),c=YH(fH(jC(t?.threads??[]))),l=Zt(tT).queueOrder,u=(0,I.useMemo)(()=>HT(c,l),[c,l]),d=(0,I.useMemo)(()=>{let e=u.active.filter(pT),t=u.active.filter(e=>!pT(e));return[...u.pinned,...e,...t]},[u.pinned,u.active]),f=d.filter(pT).length,p=n===`queue`?d:n===`snoozed`?u.snoozed:u.inactive,m=e.view.startsWith(`status:`)?e.view.slice(7):null,h=IU(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)(em,{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)(pm,{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)(RU,{status:m})}):p.length===0?(0,L.jsx)(ZU,{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)(XU,{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)(Wm,{size:24,strokeWidth:2.2})}),i?(0,L.jsx)(eW,{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)(QU,{active:n===`queue`,label:`Queue`,count:f>0?f:d.length,asks:f>0,onClick:()=>r(`queue`),icon:(0,L.jsx)(HU,{size:zU})}),(0,L.jsx)(QU,{active:n===`snoozed`,label:`Snoozed`,count:u.snoozed.length,onClick:()=>r(`snoozed`),icon:(0,L.jsx)(GU,{size:zU})}),(0,L.jsx)(QU,{active:n===`done`,label:`Done`,count:u.inactive.length,onClick:()=>r(`done`),icon:(0,L.jsx)(WU,{size:zU})})]})})]})}var nW=`(max-width: 700px)`,rW=new Set,iW=null;function aW(e){return typeof window>`u`?()=>{}:(iW||(iW=window.matchMedia(nW),iW.addEventListener(`change`,()=>rW.forEach(e=>e()))),rW.add(e),()=>rW.delete(e))}function oW(){return iW?iW.matches:typeof window<`u`&&window.matchMedia(nW).matches}function sW(){return(0,I.useSyncExternalStore)(aW,oW,()=>!1)}var cW={schedule:(e,t)=>window.setTimeout(e,t),cancel:e=>window.clearTimeout(e)},lW=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??cW,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 uW(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var dW=uW();function fW(e){dW=e}var pW={exec:()=>null};function mW(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(hW.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var hW={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`)},gW=/^(?:[ \t]*(?:\n|$))+/,_W=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,vW=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,yW=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,bW=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,xW=/(?:[*+-]|\d{1,9}[.)])/,SW=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,CW=mW(SW).replace(/bull/g,xW).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(),wW=mW(SW).replace(/bull/g,xW).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(),TW=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,EW=/^[^\n]+/,DW=/(?!\s*\])(?:\\.|[^\[\]\\])+/,OW=mW(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,DW).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),kW=mW(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,xW).getRegex(),AW=`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`,jW=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,MW=mW(`^ {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`,jW).replace(`tag`,AW).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),NW=mW(TW).replace(`hr`,yW).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`,AW).getRegex(),PW={blockquote:mW(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,NW).getRegex(),code:_W,def:OW,fences:vW,heading:bW,hr:yW,html:MW,lheading:CW,list:kW,newline:gW,paragraph:NW,table:pW,text:EW},FW=mW(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,yW).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`,AW).getRegex(),IW={...PW,lheading:wW,table:FW,paragraph:mW(TW).replace(`hr`,yW).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,FW).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`,AW).getRegex()},LW={...PW,html:mW(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,jW).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:pW,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:mW(TW).replace(`hr`,yW).replace(`heading`,` *#{1,6} *[^
209
+ ]`).replace(`lheading`,CW).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},RW=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,zW=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,BW=/^( {2,}|\\)\n(?!\s*$)/,VW=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,HW=/[\p{P}\p{S}]/u,UW=/[\s\p{P}\p{S}]/u,WW=/[^\s\p{P}\p{S}]/u,GW=mW(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,UW).getRegex(),KW=/(?!~)[\p{P}\p{S}]/u,qW=/(?!~)[\s\p{P}\p{S}]/u,JW=/(?:[^\s\p{P}\p{S}]|~)/u,YW=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,XW=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ZW=mW(XW,`u`).replace(/punct/g,HW).getRegex(),QW=mW(XW,`u`).replace(/punct/g,KW).getRegex(),$W=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,eG=mW($W,`gu`).replace(/notPunctSpace/g,WW).replace(/punctSpace/g,UW).replace(/punct/g,HW).getRegex(),tG=mW($W,`gu`).replace(/notPunctSpace/g,JW).replace(/punctSpace/g,qW).replace(/punct/g,KW).getRegex(),nG=mW(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,WW).replace(/punctSpace/g,UW).replace(/punct/g,HW).getRegex(),rG=mW(/\\(punct)/,`gu`).replace(/punct/g,HW).getRegex(),iG=mW(/^<(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(),aG=mW(jW).replace(`(?:-->|$)`,`-->`).getRegex(),oG=mW(`^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`,aG).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),sG=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,cG=mW(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,sG).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),lG=mW(/^!?\[(label)\]\[(ref)\]/).replace(`label`,sG).replace(`ref`,DW).getRegex(),uG=mW(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,DW).getRegex(),dG={_backpedal:pW,anyPunctuation:rG,autolink:iG,blockSkip:YW,br:BW,code:zW,del:pW,emStrongLDelim:ZW,emStrongRDelimAst:eG,emStrongRDelimUnd:nG,escape:RW,link:cG,nolink:uG,punctuation:GW,reflink:lG,reflinkSearch:mW(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,lG).replace(`nolink`,uG).getRegex(),tag:oG,text:VW,url:pW},fG={...dG,link:mW(/^!?\[(label)\]\((.*?)\)/).replace(`label`,sG).getRegex(),reflink:mW(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,sG).getRegex()},pG={...dG,emStrongRDelimAst:tG,emStrongLDelim:QW,url:mW(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},mG={...pG,br:mW(BW).replace(`{2,}`,`*`).getRegex(),text:mW(pG.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},hG={normal:PW,gfm:IW,pedantic:LW},gG={normal:dG,gfm:pG,breaks:mG,pedantic:fG},_G={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`},vG=e=>_G[e];function yG(e,t){if(t){if(hW.escapeTest.test(e))return e.replace(hW.escapeReplace,vG)}else if(hW.escapeTestNoEncode.test(e))return e.replace(hW.escapeReplaceNoEncode,vG);return e}function bG(e){try{e=encodeURI(e).replace(hW.percentDecode,`%`)}catch{return null}return e}function xG(e,t){let n=e.replace(hW.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(hW.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(hW.slashPipe,`|`);return n}function SG(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 CG(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 wG(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 TG(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 CG=class{options;rules;lexer;constructor(e){this.options=e||cW}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:yG(e,`
212
- `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=SG(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=yG(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:yG(t[0],`
213
- `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=yG(t[0],`
211
+ `)}var EG=class{options;rules;lexer;constructor(e){this.options=e||dW}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:SG(e,`
212
+ `)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let e=t[0],n=TG(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=SG(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:SG(t[0],`
213
+ `)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let e=SG(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=vG(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(vG(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=yG(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=bG(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)),xG(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 xG(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}}}},wG=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||cW,this.options.tokenizer=this.options.tokenizer||new CG,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:fW,block:fG.normal,inline:pG.normal};this.options.pedantic?(t.block=fG.pedantic,t.inline=pG.pedantic):this.options.gfm&&(t.block=fG.gfm,this.options.breaks?t.inline=pG.breaks:t.inline=pG.gfm),this.tokenizer.rules=t}static get rules(){return{block:fG,inline:pG}}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(fW.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(fW.tabCharGlobal,` `).replace(fW.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=xG(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(xG(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=SG(e.slice(0,-1),`\\`);if((e.length-t.length)%2==0)return}else{let e=CG(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)),wG(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 wG(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}}}},DG=class e{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||dW,this.options.tokenizer=this.options.tokenizer||new EG,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:hW,block:hG.normal,inline:gG.normal};this.options.pedantic?(t.block=hG.pedantic,t.inline=gG.pedantic):this.options.gfm&&(t.block=hG.gfm,this.options.breaks?t.inline=gG.breaks:t.inline=gG.gfm),this.tokenizer.rules=t}static get rules(){return{block:hG,inline:gG}}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(hW.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(hW.tabCharGlobal,` `).replace(hW.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}},TG=class{options;parser;constructor(e){this.options=e||cW}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(fW.notSpaceStart)?.[0],i=e.replace(fW.endingNewline,``)+`
244
- `;return r?`<pre><code class="language-`+gG(r)+`">`+(n?i:gG(i,!0))+`</code></pre>
245
- `:`<pre><code>`+(n?i:gG(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}},OG=class{options;parser;constructor(e){this.options=e||dW}space(e){return``}code({text:e,lang:t,escaped:n}){let r=(t||``).match(hW.notSpaceStart)?.[0],i=e.replace(hW.endingNewline,``)+`
244
+ `;return r?`<pre><code class="language-`+yG(r)+`">`+(n?i:yG(i,!0))+`</code></pre>
245
+ `:`<pre><code>`+(n?i:yG(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+` `+gG(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+` `+yG(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>${gG(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=_G(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+gG(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=_G(e);if(i===null)return gG(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${gG(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:gG(e.text)}},EG=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``}},DG=class e{options;renderer;textRenderer;constructor(e){this.options=e||cW,this.options.renderer=this.options.renderer||new TG,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new EG}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}},OG=class{options;block;constructor(e){this.options=e||cW}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?wG.lex:wG.lexInline}provideParser(){return this.block?DG.parse:DG.parseInline}},kG=class{defaults=sW();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=DG;Renderer=TG;TextRenderer=EG;Lexer=wG;Tokenizer=CG;Hooks=OG;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 TG(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 CG(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 OG;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];OG.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 wG.lex(e,t??this.defaults)}parser(e,t){return DG.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?wG.lex:wG.lexInline,s=i.hooks?i.hooks.provideParser():e?DG.parse:DG.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>`+gG(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},AG=new kG;function jG(e,t){return AG.parse(e,t)}jG.options=jG.setOptions=function(e){return AG.setOptions(e),jG.defaults=AG.defaults,lW(jG.defaults),jG},jG.getDefaults=sW,jG.defaults=cW,jG.use=function(...e){return AG.use(...e),jG.defaults=AG.defaults,lW(jG.defaults),jG},jG.walkTokens=function(e,t){return AG.walkTokens(e,t)},jG.parseInline=AG.parseInline,jG.Parser=DG,jG.parser=DG.parse,jG.Renderer=TG,jG.TextRenderer=EG,jG.Lexer=wG,jG.lexer=wG.lex,jG.Tokenizer=CG,jG.Hooks=OG,jG.parse=jG,jG.options,jG.setOptions,jG.use,jG.walkTokens,jG.parseInline,DG.parse,wG.lex;function MG({header:e,caption:t,children:n}){return(0,L.jsxs)(`figure`,{className:NG,children:[e,(0,L.jsx)(`div`,{className:PG,children:n}),t]})}var NG=`frizz-bash max-w-full`,PG=`flex justify-center bg-panel-2 p-1.5`,FG=`block max-h-[420px] max-w-full w-auto rounded-md object-contain`,IG=/^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,LG={del(e){let t=IG.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}},RG=/^:?-+:?$/,zG=/^ {0,3}$/,BG=/^[ \t]*$/;function VG(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||!zG.test(t[0])||!BG.test(t.at(-1))?null:t.slice(1,-1).map(e=>e.trim())}function HG(e){let t=[],n=0;for(let r of e.split(`
264
- `)){let e=VG(r);if(!e)break;if(e.every(e=>RG.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 UG={name:`headerlessTable`,level:`block`,start(e){let t=0;for(let n of e.split(`
265
- `)){if(n.includes(`|`)&&HG(e.slice(t)))return t;t+=n.length+1}},tokenizer(e){let t=HG(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`}},WG=/^\[([ xX/\-?])\](?:[ \t]+|[ \t]*$)/,GG={" ":{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`}},KG={name:`frizzTaskStatus`,level:`inline`,tokenizer(){},renderer(e){let{status:t}=e,n=GG[t];return`<span class="md-task${n.className?` ${n.className}`:``}" title="${n.label}"></span> `}},qG={name:`frizzTaskText`,level:`inline`,tokenizer(){},renderer(e){return`<span class="md-task-text">${this.parser.parseInline(e.tokens)}</span>`}};function JG(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=WG.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 YG={breaks:!0,extensions:[UG,KG,qG],tokenizer:LG,hooks:{processAllTokens(e){return tf(e),e}},walkTokens(e){e.type===`list_item`&&JG(e)},renderer:{code:({text:e,lang:t})=>_S(e,t)}},XG=new kG(YG),ZG=new kG({...YG,breaks:!1});function QG(e,t){return e.trim()?oK((t?.document?ZG:XG).parse(e,{async:!1}),{block:!0,baseDir:t?.baseDir,homeDir:t?.homeDir}):``}function $G(e,t){if(!e.trim())return``;let{baseDir:n,homeDir:r}=t??{};return oK(XG.parseInline(e,{async:!1}),{baseDir:n,homeDir:r})}function eK(e){let t=e.match(/^?---\r?\n[\s\S]*?\r?\n---\r?\n?/);return t?e.slice(t[0].length):e}var tK=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(`.`)),nK=new Set([`href`,`src`,`alt`,`title`,`type`,`class`,`data-local-path`,`data-local-image`]),rK=RegExp(`^(?:hljs(?:-[a-z0-9_-]+)?|language-[a-z0-9-]+|md-task(?:-(?:checked|in-progress|cancelled|blocked|text))?|${fS})$`),iK={ol:{start:/^\d{1,9}$/},th:{align:/^(?:left|center|right)$/},td:{align:/^(?:left|center|right)$/}},aK=new Set([`script`,`style`,`textarea`,`title`,`xmp`,`iframe`,`frame`,`frameset`,`object`,`embed`,`applet`,`noscript`,`template`,`svg`,`math`]);function oK(e,{block:t=!1,baseDir:n,homeDir:r}={}){let i=document.createElement(`template`);return i.innerHTML=e,sK(i.content,{block:t,baseDir:n,homeDir:r}),i.innerHTML}function sK(e,t){let{block:n}=t;for(let r of Array.from(e.children)){let e=r.tagName.toLowerCase();if(!tK.has(e)){aK.has(e)?r.remove():uK(r,t);continue}if((e===`a`||e===`img`)&&cK(r,e===`a`?`href`:`src`,t),e===`a`){let e=Md(r.getAttribute(`href`));e&&r.setAttribute(`href`,e);let t=AS(r.getAttribute(`href`));if(t){let e=NS(t);if(e)r.setAttribute(`href`,e),r.setAttribute(`title`,t.display),r.setAttribute(`data-local-path`,t.posixPath),r.setAttribute(`data-local-image`,`true`);else{let e=t.posixPath&&FS(t.posixPath),n=document.createElement(`button`);for(n.type=`button`,n.className=`local-file-action`,n.title=e?`Read ${t.display}`:t.display,t.posixPath&&n.setAttribute(`data-local-path`,t.posixPath);r.firstChild;)n.append(r.firstChild);r.replaceWith(n);continue}}}if(e===`img`){let e=AS(r.getAttribute(`src`)),t=e&&NS(e);if(!t){r.remove();continue}r.setAttribute(`src`,t),r.setAttribute(`title`,e.display),r.setAttribute(`data-local-path`,e.posixPath),r.setAttribute(`data-local-image`,`true`),r.getAttribute(`alt`)||r.setAttribute(`alt`,e.display),n&&lK(r)}for(let t of Array.from(r.attributes)){let n=t.name.toLowerCase();if(n===`class`&&(e===`code`||e===`span`)){let e=t.value.split(/\s+/).filter(e=>rK.test(e));e.length>0?r.setAttribute(`class`,e.join(` `)):r.removeAttribute(t.name);continue}let i=iK[e]?.[n];if(i){i.test(t.value)||r.removeAttribute(t.name);continue}if(!nK.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=Kd(r.getAttribute(`href`));e&&r.setAttribute(`data-gh-ref`,e)}sK(r,t)}}function cK(e,t,{baseDir:n,homeDir:r}){if(!n&&!r)return;let i=IS(e.getAttribute(t),n??``,r);i&&e.setAttribute(t,i)}function lK(e){let t=e.ownerDocument,n=t.createElement(`span`);n.className=`${NG} md-image-frame`;let r=t.createElement(`span`);r.className=PG,e.replaceWith(n),n.append(r),r.append(e),e.setAttribute(`class`,FG)}function uK(e,t){let n=e.ownerDocument.createDocumentFragment();for(;e.firstChild;)n.append(e.firstChild);sK(n,t),e.replaceWith(n)}function dK(){return(0,I.useSyncExternalStore)(Ud,Hd,Hd)}function fK(){return(0,I.useSyncExternalStore)(zf,Rf,Rf)}function pK(e,t){let n=dK(),r=fK(),{baseDir:i,asDocument:a}=t??{},o=i??r.dir,s=(0,I.useMemo)(()=>QG(e,{baseDir:o,homeDir:r.home,document:a}),[e,o,r.home,a,n]);return mK(s),s}function mK(e){let t=(0,I.useMemo)(()=>Df(e),[e]);(0,I.useEffect)(()=>{t.length>0&&Of(t)},[t])}function hK(e){let t=dK(),n=fK(),r=(0,I.useMemo)(()=>$G(e,{baseDir:n.dir,homeDir:n.home}),[e,n.dir,n.home,t]);return mK(r),r}var gK=e=>new Set(e.split(/\s+/).filter(Boolean)),_K=gK(`
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>${yG(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=bG(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+yG(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=bG(e);if(i===null)return yG(n);e=i;let a=`<img src="${e}" alt="${n}"`;return t&&(a+=` title="${yG(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:yG(e.text)}},kG=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``}},AG=class e{options;renderer;textRenderer;constructor(e){this.options=e||dW,this.options.renderer=this.options.renderer||new OG,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new kG}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}},jG=class{options;block;constructor(e){this.options=e||dW}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}provideLexer(){return this.block?DG.lex:DG.lexInline}provideParser(){return this.block?AG.parse:AG.parseInline}},MG=class{defaults=uW();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=AG;Renderer=OG;TextRenderer=kG;Lexer=DG;Tokenizer=EG;Hooks=jG;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 OG(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 EG(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 jG;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];jG.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 DG.lex(e,t??this.defaults)}parser(e,t){return AG.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?DG.lex:DG.lexInline,s=i.hooks?i.hooks.provideParser():e?AG.parse:AG.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>`+yG(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}},NG=new MG;function PG(e,t){return NG.parse(e,t)}PG.options=PG.setOptions=function(e){return NG.setOptions(e),PG.defaults=NG.defaults,fW(PG.defaults),PG},PG.getDefaults=uW,PG.defaults=dW,PG.use=function(...e){return NG.use(...e),PG.defaults=NG.defaults,fW(PG.defaults),PG},PG.walkTokens=function(e,t){return NG.walkTokens(e,t)},PG.parseInline=NG.parseInline,PG.Parser=AG,PG.parser=AG.parse,PG.Renderer=OG,PG.TextRenderer=kG,PG.Lexer=DG,PG.lexer=DG.lex,PG.Tokenizer=EG,PG.Hooks=jG,PG.parse=PG,PG.options,PG.setOptions,PG.use,PG.walkTokens,PG.parseInline,AG.parse,DG.lex;function FG({header:e,caption:t,children:n}){return(0,L.jsxs)(`figure`,{className:IG,children:[e,(0,L.jsx)(`div`,{className:LG,children:n}),t]})}var IG=`frizz-bash max-w-full`,LG=`flex justify-center bg-panel-2 p-1.5`,RG=`block max-h-[420px] max-w-full w-auto rounded-md object-contain`,zG=/^(~~)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,BG={del(e){let t=zG.exec(e);if(t)return{type:`del`,raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}},VG=/^:?-+:?$/,HG=/^ {0,3}$/,UG=/^[ \t]*$/;function WG(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||!HG.test(t[0])||!UG.test(t.at(-1))?null:t.slice(1,-1).map(e=>e.trim())}function GG(e){let t=[],n=0;for(let r of e.split(`
264
+ `)){let e=WG(r);if(!e)break;if(e.every(e=>VG.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 KG={name:`headerlessTable`,level:`block`,start(e){let t=0;for(let n of e.split(`
265
+ `)){if(n.includes(`|`)&&GG(e.slice(t)))return t;t+=n.length+1}},tokenizer(e){let t=GG(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`}},qG=/^\[([ xX/\-?])\](?:[ \t]+|[ \t]*$)/,JG={" ":{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`}},YG={name:`frizzTaskStatus`,level:`inline`,tokenizer(){},renderer(e){let{status:t}=e,n=JG[t];return`<span class="md-task${n.className?` ${n.className}`:``}" title="${n.label}"></span> `}},XG={name:`frizzTaskText`,level:`inline`,tokenizer(){},renderer(e){return`<span class="md-task-text">${this.parser.parseInline(e.tokens)}</span>`}};function ZG(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=qG.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 QG={breaks:!0,extensions:[KG,YG,XG],tokenizer:BG,hooks:{processAllTokens(e){return tf(e),e}},walkTokens(e){e.type===`list_item`&&ZG(e)},renderer:{code:({text:e,lang:t})=>_S(e,t)}},$G=new MG(QG),eK=new MG({...QG,breaks:!1});function tK(e,t){return e.trim()?lK((t?.document?eK:$G).parse(e,{async:!1}),{block:!0,baseDir:t?.baseDir,homeDir:t?.homeDir}):``}function nK(e,t){if(!e.trim())return``;let{baseDir:n,homeDir:r}=t??{};return lK($G.parseInline(e,{async:!1}),{baseDir:n,homeDir:r})}function rK(e){let t=e.match(/^?---\r?\n[\s\S]*?\r?\n---\r?\n?/);return t?e.slice(t[0].length):e}var iK=new Set(`h1.h2.h3.h4.h5.h6.p.br.hr.strong.em.del.code.pre.blockquote.ul.ol.li.a.img.button.table.thead.tbody.tr.th.td.span`.split(`.`)),aK=new Set([`href`,`src`,`alt`,`title`,`type`,`class`,`data-local-path`,`data-local-image`]),oK=RegExp(`^(?:hljs(?:-[a-z0-9_-]+)?|language-[a-z0-9-]+|md-task(?:-(?:checked|in-progress|cancelled|blocked|text))?|${fS})$`),sK={ol:{start:/^\d{1,9}$/},th:{align:/^(?:left|center|right)$/},td:{align:/^(?:left|center|right)$/}},cK=new Set([`script`,`style`,`textarea`,`title`,`xmp`,`iframe`,`frame`,`frameset`,`object`,`embed`,`applet`,`noscript`,`template`,`svg`,`math`]);function lK(e,{block:t=!1,baseDir:n,homeDir:r}={}){let i=document.createElement(`template`);return i.innerHTML=e,uK(i.content,{block:t,baseDir:n,homeDir:r}),i.innerHTML}function uK(e,t){let{block:n}=t;for(let r of Array.from(e.children)){let e=r.tagName.toLowerCase();if(!iK.has(e)){cK.has(e)?r.remove():pK(r,t);continue}if((e===`a`||e===`img`)&&dK(r,e===`a`?`href`:`src`,t),e===`a`){let e=Md(r.getAttribute(`href`));e&&r.setAttribute(`href`,e);let t=AS(r.getAttribute(`href`));if(t){let e=NS(t);if(e)r.setAttribute(`href`,e),r.setAttribute(`title`,t.display),r.setAttribute(`data-local-path`,t.posixPath),r.setAttribute(`data-local-image`,`true`);else{let e=t.posixPath&&FS(t.posixPath),n=document.createElement(`button`);for(n.type=`button`,n.className=`local-file-action`,n.title=e?`Read ${t.display}`:t.display,t.posixPath&&n.setAttribute(`data-local-path`,t.posixPath);r.firstChild;)n.append(r.firstChild);r.replaceWith(n);continue}}}if(e===`img`){let e=AS(r.getAttribute(`src`)),t=e&&NS(e);if(!t){r.remove();continue}r.setAttribute(`src`,t),r.setAttribute(`title`,e.display),r.setAttribute(`data-local-path`,e.posixPath),r.setAttribute(`data-local-image`,`true`),r.getAttribute(`alt`)||r.setAttribute(`alt`,e.display),n&&fK(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=>oK.test(e));e.length>0?r.setAttribute(`class`,e.join(` `)):r.removeAttribute(t.name);continue}let i=sK[e]?.[n];if(i){i.test(t.value)||r.removeAttribute(t.name);continue}if(!aK.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=Kd(r.getAttribute(`href`));e&&r.setAttribute(`data-gh-ref`,e)}uK(r,t)}}function dK(e,t,{baseDir:n,homeDir:r}){if(!n&&!r)return;let i=IS(e.getAttribute(t),n??``,r);i&&e.setAttribute(t,i)}function fK(e){let t=e.ownerDocument,n=t.createElement(`span`);n.className=`${IG} md-image-frame`;let r=t.createElement(`span`);r.className=LG,e.replaceWith(n),n.append(r),r.append(e),e.setAttribute(`class`,RG)}function pK(e,t){let n=e.ownerDocument.createDocumentFragment();for(;e.firstChild;)n.append(e.firstChild);uK(n,t),e.replaceWith(n)}function mK(){return(0,I.useSyncExternalStore)(Ud,Hd,Hd)}function hK(){return(0,I.useSyncExternalStore)(zf,Rf,Rf)}function gK(e,t){let n=mK(),r=hK(),{baseDir:i,asDocument:a}=t??{},o=i??r.dir,s=(0,I.useMemo)(()=>tK(e,{baseDir:o,homeDir:r.home,document:a}),[e,o,r.home,a,n]);return _K(s),s}function _K(e){let t=(0,I.useMemo)(()=>Df(e),[e]);(0,I.useEffect)(()=>{t.length>0&&Of(t)},[t])}function vK(e){let t=mK(),n=hK(),r=(0,I.useMemo)(()=>nK(e,{baseDir:n.dir,homeDir:n.home}),[e,n.dir,n.home,t]);return _K(r),r}var yK=e=>new Set(e.split(/\s+/).filter(Boolean)),bK=yK(`
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
- `),vK=gK(`
273
+ `),xK=yK(`
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
- `),yK={typescript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:_K,types:vK},javascript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:_K,types:vK},go:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:_K,types:vK},rust:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:_K,types:vK},java:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:_K,types:vK},c:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:_K,types:vK},cpp:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:_K,types:vK},css:{line:null,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:gK(`important media supports keyframes import from to`),types:new Set},json:{line:null,block:null,quotes:[`"`],keywords:gK(`true false null`),types:new Set},python:{line:`#`,block:null,quotes:[`"`,`'`],keywords:gK(`
278
+ `),SK={typescript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:bK,types:xK},javascript:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:bK,types:xK},go:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`,"`"],keywords:bK,types:xK},rust:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:bK,types:xK},java:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:bK,types:xK},c:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:bK,types:xK},cpp:{line:`//`,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:bK,types:xK},css:{line:null,block:[`/*`,`*/`],quotes:[`"`,`'`],keywords:yK(`important media supports keyframes import from to`),types:new Set},json:{line:null,block:null,quotes:[`"`],keywords:yK(`true false null`),types:new Set},python:{line:`#`,block:null,quotes:[`"`,`'`],keywords:yK(`
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:gK(`int float str bool list dict set tuple bytes object`)},shell:{line:`#`,block:null,quotes:[`"`,`'`],keywords:gK(`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:gK(`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:gK(`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}},bK=(e,t)=>{let n=e.indexOf(`
282
- `,t);return n===-1?e.length:n},xK=(e,t)=>{let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;return e[n]??``},SK=new Set(Object.keys(yK)),CK=e=>/[A-Za-z_$]/.test(e),wK=e=>/[A-Za-z0-9_$]/.test(e),TK=e=>e>=`0`&&e<=`9`,EK=new Set(`{}()[];,.`),DK=new Set(`+-*/%=<>!&|^~?:@`);function OK(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,bK(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:yK(`int float str bool list dict set tuple bytes object`)},shell:{line:`#`,block:null,quotes:[`"`,`'`],keywords:yK(`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:yK(`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:yK(`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}},CK=(e,t)=>{let n=e.indexOf(`
282
+ `,t);return n===-1?e.length:n},wK=(e,t)=>{let n=t;for(;n<e.length&&(e[n]===` `||e[n]===` `);)n++;return e[n]??``},TK=new Set(Object.keys(SK)),EK=e=>/[A-Za-z_$]/.test(e),DK=e=>/[A-Za-z0-9_$]/.test(e),OK=e=>e>=`0`&&e<=`9`,kK=new Set(`{}()[];,.`),AK=new Set(`+-*/%=<>!&|^~?:@`);function jK(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,CK(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(TK(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(CK(n)){let n=a+1;for(;n<r&&wK(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(xK(e,n))?`key`:e[n]===`(`?`fn`:`plain`),a=n;continue}if(EK.has(n)){i(n,`punct`),a++;continue}if(DK.has(n)){let t=a+1;for(;t<r&&DK.has(e[t]);)t++;i(e.slice(a,t),`op`),a=t;continue}let o=a+1;for(;o<r&&!CK(e[o])&&!TK(e[o])&&!t.quotes.includes(e[o])&&!EK.has(e[o])&&!DK.has(e[o])&&!(t.line&&e.startsWith(t.line,o));)o++;i(e.slice(a,o),`plain`),a=o}return n}function kK(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 AK(e,t){if(e===``)return[];let n=yK[t];return n?kK(OK(e,n)):e.split(`
287
- `).map(e=>e?[{text:e,kind:`plain`}]:[])}var jK={".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`},MK={Dockerfile:`shell`,Makefile:`shell`,".gitignore":`shell`,".env":`shell`,".bashrc":`shell`,".zshrc":`shell`};function NK(e){let t=e.split(`/`).pop()??``,n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=MK[t]??jK[r]??`text`;return SK.has(i)?i:`text`}function PK(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 FK(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(...PK(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 IK=3,LK=e=>e===``?[]:e.split(`
288
- `);function RK(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 zK(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]-IK),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+IK),!(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-IK)))}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 BK(e,t,n){let r=NK(n),i=AK(e,r),a=AK(t,r),o=LK(e),s=LK(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=FK(o,s).map(e=>RK(e,i,a)),u=l.filter(e=>e.type===`add`).length,d=l.filter(e=>e.type===`del`).length,{hunks:f,collapsedAfter:p}=zK(l);return{file:n,lang:r,status:c,hunks:f,collapsedAfter:p,additions:u,deletions:d}}function VK(){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(),UK(n,t.dataset.localImage===`true`))};document.addEventListener(`click`,e);let t=HK();return document.addEventListener(`error`,t,!0),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`error`,t,!0)}}function HK(){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 UK(e,t=!1){if(!t&&FS(e)){up(e);return}if(!t&&X.splitFileViewer){fp(e);return}WK(e,t)}async function WK(e,t){try{let n=await Y.openLocalFile({path:e,...t?{image:!0}:{}});n.action===`copy`&&(await CR(n.path),Z(`Copied local path`))}catch(e){Z(`Could not open local file: ${e.message.slice(0,100)}`)}}var GK=`a, button, input, select, textarea, summary, label, [role="button"], [role="link"]`;function KK(e){let t=e;return typeof t?.closest==`function`&&t.closest(GK)!=null}function qK({children:e,className:t,controls:n,expanded:r,label:i,meta:a,onToggle:o,chevronSize:s=12}){function c(e){if(KK(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)(tm,{"aria-hidden":!0,size:s,className:`relative -top-px shrink-0 transition-transform ${r?`rotate-90`:``}`}))))}function JK({path:e,className:t=``,children:n}){return(0,L.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),UK(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 YK(e){let t=e.split(`/`).filter(Boolean);return t.length?t[t.length-1]:e}function XK({edits:e,meta:t}){let{compactDiffs:n}=Zt(tT),r=(0,I.useId)(),i=e[0].file,a=(0,I.useMemo)(()=>e.map(e=>BK(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)(qK,{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)(JK,{path:i,className:`text-inherit no-underline`,children:YK(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)(ZK,{hunks:e.hunks,collapsedAfter:e.collapsedAfter})},t))})]})}function ZK({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)(QK,{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)(QK,{n:t},`safter`)),(0,L.jsx)(L.Fragment,{children:r})}function QK({n:e}){return(0,L.jsxs)(`div`,{className:`frizz-diff-sep`,children:[e,` unchanged line`,e===1?``:`s`]})}function $K(e){return(0,I.useMemo)(()=>({__html:e}),[e])}var eq=/^[\w.@+-]+\.[a-z][a-z0-9]{0,7}$/i;function tq(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(`/`)?!0:eq.test(t)}var nq=new Map,rq=new Set,iq=0,aq=new Set,oq=e=>(aq.add(e),()=>{aq.delete(e)}),sq=()=>iq,cq=128;async function lq(e){let t=[...new Set(e)].filter(e=>!nq.has(e)&&!rq.has(e));if(!t.length)return;for(let e of t)rq.add(e);let n=[];for(let e=0;e<t.length;e+=cq)n.push(t.slice(e,e+cq));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)nq.has(t.input)||(nq.set(t.input,t.path),i=!0);for(let e of t)rq.delete(e);if(i){iq+=1;for(let e of aq)e()}}function uq(e,t){e.setAttribute(`data-local-path`,t),e.setAttribute(`title`,`Open ${t}`),e.classList.add(`local-file-code`)}function dq(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(!tq(t))continue;let r=nq.get(t);r===void 0?n.push(t):r&&uq(e,r)}n.length&&lq(n)},[e,t,(0,I.useSyncExternalStore)(oq,sq,sq)])}function fq({as:e=`div`,className:t,html:n}){let r=$K(n),i=(0,I.useRef)(null);return dq(i,n),(0,I.createElement)(e,{ref:i,className:t,dangerouslySetInnerHTML:r})}function pq({text:e,language:t,className:n=``,...r}){let i=$K((0,I.useMemo)(()=>TS(e,t),[e,t]));return(0,L.jsx)(`pre`,{...r,className:`hljs ${n}`,dangerouslySetInnerHTML:i})}var mq=`Todos`,hq={pending:{Icon:th,className:`text-muted/50`},in_progress:{Icon:$m,className:`text-accent`},completed:{Icon:Qm,className:`text-muted/75`}},gq={pending:`text-fg/75`,in_progress:`text-fg`,completed:`text-muted/70`};function _q({status:e}){let{Icon:t,className:n}=hq[e];return(0,L.jsx)(t,{"aria-hidden":`true`,size:`1em`,strokeWidth:2,className:`frizz-todo-mark shrink-0 ${n}`})}var vq={pending:`to do`,in_progress:`in progress`,completed:`done`};function yq({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`} `:``}${mq}${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:mq}),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)(_q,{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)(tm,{"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)(_q,{status:e.status}),(0,L.jsx)(`span`,{className:`min-w-0 ${gq[e.status]}`,children:e.text}),(0,L.jsx)(`span`,{className:`sr-only`,children:` — ${vq[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 bq=/^```question(?:[ \t]+([A-Za-z][^\r\n]*?))?[ \t]*\r?\n(?:([\s\S]*?)\r?\n)??```[ \t]*$/gm,xq=/^qst_[a-z0-9]+$/;function Sq(e){let t=(e??``).toLowerCase().split(/\s+/).filter(Boolean),n=e=>t.includes(e),r=t.find(e=>xq.test(e));return{kind:n(`multi`)?`multi`:`question`,danger:n(`danger`),...r?{registeredId:r}:{}}}function Cq(e){let t=[],n=Ec(e),r=0;bq.lastIndex=0;for(let i=bq.exec(e);i!==null;i=bq.exec(e)){if(n(i.index)){bq.lastIndex=i.index+1;continue}let{kind:a,danger:o,registeredId:s}=Sq(i[1]);if(i[2]===void 0&&!s){bq.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}),wq(t)}function wq(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=Iq(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=zq(i.options[i.options.length-1]);if(!/^([A-Z]|\d+)$/.test(e))continue;a=e}let o=Tq(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(OK(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(EK(n)){let n=a+1;for(;n<r&&DK(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(wK(e,n))?`key`:e[n]===`(`?`fn`:`plain`),a=n;continue}if(kK.has(n)){i(n,`punct`),a++;continue}if(AK.has(n)){let t=a+1;for(;t<r&&AK.has(e[t]);)t++;i(e.slice(a,t),`op`),a=t;continue}let o=a+1;for(;o<r&&!EK(e[o])&&!OK(e[o])&&!t.quotes.includes(e[o])&&!kK.has(e[o])&&!AK.has(e[o])&&!(t.line&&e.startsWith(t.line,o));)o++;i(e.slice(a,o),`plain`),a=o}return n}function MK(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 NK(e,t){if(e===``)return[];let n=SK[t];return n?MK(jK(e,n)):e.split(`
287
+ `).map(e=>e?[{text:e,kind:`plain`}]:[])}var PK={".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`},FK={Dockerfile:`shell`,Makefile:`shell`,".gitignore":`shell`,".env":`shell`,".bashrc":`shell`,".zshrc":`shell`};function IK(e){let t=e.split(`/`).pop()??``,n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=FK[t]??PK[r]??`text`;return TK.has(i)?i:`text`}function LK(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 RK(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(...LK(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 zK=3,BK=e=>e===``?[]:e.split(`
288
+ `);function VK(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 HK(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]-zK),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+zK),!(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-zK)))}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 UK(e,t,n){let r=IK(n),i=NK(e,r),a=NK(t,r),o=BK(e),s=BK(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=RK(o,s).map(e=>VK(e,i,a)),u=l.filter(e=>e.type===`add`).length,d=l.filter(e=>e.type===`del`).length,{hunks:f,collapsedAfter:p}=HK(l);return{file:n,lang:r,status:c,hunks:f,collapsedAfter:p,additions:u,deletions:d}}function WK(){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(),KK(n,t.dataset.localImage===`true`))};document.addEventListener(`click`,e);let t=GK();return document.addEventListener(`error`,t,!0),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`error`,t,!0)}}function GK(){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 KK(e,t=!1){if(!t&&FS(e)){up(e);return}if(!t&&X.splitFileViewer){fp(e);return}qK(e,t)}async function qK(e,t){try{let n=await Y.openLocalFile({path:e,...t?{image:!0}:{}});n.action===`copy`&&(await wR(n.path),Z(`Copied local path`))}catch(e){Z(`Could not open local file: ${e.message.slice(0,100)}`)}}var JK=`a, button, input, select, textarea, summary, label, [role="button"], [role="link"]`;function YK(e){let t=e;return typeof t?.closest==`function`&&t.closest(JK)!=null}function XK({children:e,className:t,controls:n,expanded:r,label:i,meta:a,onToggle:o,chevronSize:s=12}){function c(e){if(YK(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)(tm,{"aria-hidden":!0,size:s,className:`relative -top-px shrink-0 transition-transform ${r?`rotate-90`:``}`}))))}function ZK({path:e,className:t=``,children:n}){return(0,L.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),KK(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 QK(e){let t=e.split(`/`).filter(Boolean);return t.length?t[t.length-1]:e}function $K({edits:e,meta:t}){let{compactDiffs:n}=Zt(tT),r=(0,I.useId)(),i=e[0].file,a=(0,I.useMemo)(()=>e.map(e=>UK(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)(XK,{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)(ZK,{path:i,className:`text-inherit no-underline`,children:QK(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)(eq,{hunks:e.hunks,collapsedAfter:e.collapsedAfter})},t))})]})}function eq({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)(tq,{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)(tq,{n:t},`safter`)),(0,L.jsx)(L.Fragment,{children:r})}function tq({n:e}){return(0,L.jsxs)(`div`,{className:`frizz-diff-sep`,children:[e,` unchanged line`,e===1?``:`s`]})}function nq(e){return(0,I.useMemo)(()=>({__html:e}),[e])}var rq=/^[\w.@+-]+\.[a-z][a-z0-9]{0,7}$/i;function iq(e){let t=e.trim();return!t||t.length>1024||/\s/.test(t)||/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?!1:t===`~`||t.startsWith(`~/`)||t.startsWith(`/`)||t.includes(`/`)?!0:rq.test(t)}var aq=new Map,oq=new Set,sq=0,cq=new Set,lq=e=>(cq.add(e),()=>{cq.delete(e)}),uq=()=>sq,dq=128;async function fq(e){let t=[...new Set(e)].filter(e=>!aq.has(e)&&!oq.has(e));if(!t.length)return;for(let e of t)oq.add(e);let n=[];for(let e=0;e<t.length;e+=dq)n.push(t.slice(e,e+dq));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)aq.has(t.input)||(aq.set(t.input,t.path),i=!0);for(let e of t)oq.delete(e);if(i){sq+=1;for(let e of cq)e()}}function pq(e,t){e.setAttribute(`data-local-path`,t),e.setAttribute(`title`,`Open ${t}`),e.classList.add(`local-file-code`)}function mq(e,t){(0,I.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let n=[];for(let e of t.querySelectorAll(`code`)){if(e.closest(`pre`)||e.closest(`a, [data-local-path]`))continue;let t=(e.textContent??``).trim();if(!iq(t))continue;let r=aq.get(t);r===void 0?n.push(t):r&&pq(e,r)}n.length&&fq(n)},[e,t,(0,I.useSyncExternalStore)(lq,uq,uq)])}function hq({as:e=`div`,className:t,html:n}){let r=nq(n),i=(0,I.useRef)(null);return mq(i,n),(0,I.createElement)(e,{ref:i,className:t,dangerouslySetInnerHTML:r})}function gq({text:e,language:t,className:n=``,...r}){let i=nq((0,I.useMemo)(()=>TS(e,t),[e,t]));return(0,L.jsx)(`pre`,{...r,className:`hljs ${n}`,dangerouslySetInnerHTML:i})}var _q=`Todos`,vq={pending:{Icon:th,className:`text-muted/50`},in_progress:{Icon:$m,className:`text-accent`},completed:{Icon:Qm,className:`text-muted/75`}},yq={pending:`text-fg/75`,in_progress:`text-fg`,completed:`text-muted/70`};function bq({status:e}){let{Icon:t,className:n}=vq[e];return(0,L.jsx)(t,{"aria-hidden":`true`,size:`1em`,strokeWidth:2,className:`frizz-todo-mark shrink-0 ${n}`})}var xq={pending:`to do`,in_progress:`in progress`,completed:`done`};function Sq({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`} `:``}${_q}${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:_q}),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)(bq,{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)(tm,{"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)(bq,{status:e.status}),(0,L.jsx)(`span`,{className:`min-w-0 ${yq[e.status]}`,children:e.text}),(0,L.jsx)(`span`,{className:`sr-only`,children:` — ${xq[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 Cq=/^```question(?:[ \t]+([A-Za-z][^\r\n]*?))?[ \t]*\r?\n(?:([\s\S]*?)\r?\n)??```[ \t]*$/gm,wq=/^qst_[a-z0-9]+$/;function Tq(e){let t=(e??``).toLowerCase().split(/\s+/).filter(Boolean),n=e=>t.includes(e),r=t.find(e=>wq.test(e));return{kind:n(`multi`)?`multi`:`question`,danger:n(`danger`),...r?{registeredId:r}:{}}}function Eq(e){let t=[],n=Ec(e),r=0;Cq.lastIndex=0;for(let i=Cq.exec(e);i!==null;i=Cq.exec(e)){if(n(i.index)){Cq.lastIndex=i.index+1;continue}let{kind:a,danger:o,registeredId:s}=Tq(i[1]);if(i[2]===void 0&&!s){Cq.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}),Dq(t)}function Dq(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=zq(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=Hq(i.options[i.options.length-1]);if(!/^([A-Z]|\d+)$/.test(e))continue;a=e}let o=Oq(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 Tq(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||!Dq.test(n[r]))return null;let i=Aq(n[r]);if(t===null?!Mq(i):!jq(t,i))return null;let a=r,o=i;for(let e=r+1;e<n.length;e++){let t=n[e];if(Dq.test(t)){if(!jq(o,Aq(t)))break;o=Aq(t),a=e;continue}if(t.trim()===``)continue;if(Oq.test(t)){a=e;break}let r=n.findIndex((t,n)=>n>e&&Dq.test(t));if(r===-1||!jq(o,Aq(n[r])))break}let s=n.slice(r,a+1);return s.filter(e=>Dq.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 Oq(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||!Aq.test(n[r]))return null;let i=Nq(n[r]);if(t===null?!Fq(i):!Pq(t,i))return null;let a=r,o=i;for(let e=r+1;e<n.length;e++){let t=n[e];if(Aq.test(t)){if(!Pq(o,Nq(t)))break;o=Nq(t),a=e;continue}if(t.trim()===``)continue;if(jq.test(t)){a=e;break}let r=n.findIndex((t,n)=>n>e&&Aq.test(t));if(r===-1||!Pq(o,Nq(n[r])))break}let s=n.slice(r,a+1);return s.filter(e=>Aq.test(e)).length<(t===null?2:1)?null:{run:s.join(`
292
292
  `),rest:n.slice(a+1).join(`
293
- `)}}function Eq(e){return e.includes("```question")&&Cq(e).some(e=>e.kind===`question`)}var Dq=/^\s*(?:[-*+]\s+)?([A-Z]|\d+)[.)]\s+\S/,Oq=/^\s*recommendation\b/i;function kq(e){return e.trim().replace(/^[-*+]\s+/,``)}function Aq(e){return kq(e).match(/^([A-Za-z]|\d+)[.)]/)?.[1].toUpperCase()??``}function jq(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 Mq=e=>e===`A`||e===`1`,Nq=/(^|[^a-z])recommended([^a-z]|$)/i;function Pq(e){return e.replace(/\s{2,}/g,` `).trim()}function Fq(e){if(!Nq.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:Pq(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:Pq(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:Pq(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=Pq((i[1]??``)+e.slice(i[0].length));if(t)return{label:t,recommended:!0}}return{label:e,recommended:!1}}function Iq(e,t,n=!1){let r=e.split(`
294
- `).map(e=>e.replace(/\r$/,``)),i=e=>r.findIndex((t,n)=>n>e&&Dq.test(t)),a=e=>{let t=[];for(let n=e;n<r.length;n++){if(Dq.test(r[n])){t.push(n);continue}if(t.length===0||r[n].trim()===``)continue;if(Oq.test(r[n]))break;let e=i(n);if(e===-1||!jq(Aq(r[t[t.length-1]]),Aq(r[e])))break}return t},o=e=>{for(let t=e.length-1;t>0;t--)if(!jq(Aq(r[e[t-1]]),Aq(r[e[t]])))return Mq(Aq(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}=Fq(kq(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 kq(e){return e.includes("```question")&&Eq(e).some(e=>e.kind===`question`)}var Aq=/^\s*(?:[-*+]\s+)?([A-Z]|\d+)[.)]\s+\S/,jq=/^\s*recommendation\b/i;function Mq(e){return e.trim().replace(/^[-*+]\s+/,``)}function Nq(e){return Mq(e).match(/^([A-Za-z]|\d+)[.)]/)?.[1].toUpperCase()??``}function Pq(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 Fq=e=>e===`A`||e===`1`,Iq=/(^|[^a-z])recommended([^a-z]|$)/i;function Lq(e){return e.replace(/\s{2,}/g,` `).trim()}function Rq(e){if(!Iq.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:Lq(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:Lq(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:Lq(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=Lq((i[1]??``)+e.slice(i[0].length));if(t)return{label:t,recommended:!0}}return{label:e,recommended:!1}}function zq(e,t,n=!1){let r=e.split(`
294
+ `).map(e=>e.replace(/\r$/,``)),i=e=>r.findIndex((t,n)=>n>e&&Aq.test(t)),a=e=>{let t=[];for(let n=e;n<r.length;n++){if(Aq.test(r[n])){t.push(n);continue}if(t.length===0||r[n].trim()===``)continue;if(jq.test(r[n]))break;let e=i(n);if(e===-1||!Pq(Nq(r[t[t.length-1]]),Nq(r[e])))break}return t},o=e=>{for(let t=e.length-1;t>0;t--)if(!Pq(Nq(r[e[t-1]]),Nq(r[e[t]])))return Fq(Nq(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}=Rq(Mq(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&&Oq.test(e)?g=e.trim():_.push(e);let v=m(_).join(`
297
- `)||void 0;return d===null&&g&&(d=Rq(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 Lq=/^[*_`~\s]+/;function Rq(e,t){if(!e)return null;let n=e.replace(/^\s*recommendation\s*:?\s*/i,``).replace(Lq,``).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(Lq,``).match(/^([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase()===r:!1});return i===-1?null:i}function zq(e){let t=e.match(/^\s*([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase():e.trim()}function Bq(e,t){let n=t.text.trim();if(e.kind===`multi`){let r=(t.chosenSet??[]).slice().sort((e,t)=>e-t).map(t=>zq(e.options[t]??``)).filter(Boolean).join(`, `);return r&&n?`${r} — ${n}`:r||n}return t.chosen==null?n:e.options[t.chosen]??``}var Vq=/^```(done|awaiting)[ \t]*\r?\n([\s\S]*?)\r?\n```[ \t]*$/gm;function Hq(e,t){return t===`done`?{body:e.trim(),hints:[]}:cl(e)}function Uq(e){let t=[],n=Ec(e),r=0;Vq.lastIndex=0;for(let i=Vq.exec(e);i!==null;i=Vq.exec(e)){if(n(i.index)){Vq.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}=Hq(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 Wq(e,t){let n=e?.lastFence;return!(!n||n.kind!==`done`||n.registered!==!0||t&&Uq(t).some(e=>e.kind===`fence`&&e.fenceKind===`done`))}var Gq=`[overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`,Kq=`rounded-xl`,qq=`rounded-t-xl`,Jq=`rounded-b-[calc(var(--block-radius)_-_1px)]`,Yq={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`}},Xq=`card-icon-offset`;function Zq({icon:e,label:t,head:n=Yq.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 ${Xq} ${n}`})]})}function Qq({children:e}){return(0,L.jsx)(`div`,{className:`card-md mt-1 min-w-0 text-fg/75`,children:e})}function $q({tone:e=`neutral`,icon:t,label:n,aside:r,children:i,className:a=``,...o}){let{border:s,head:c}=Yq[e];return(0,L.jsxs)(`div`,{...o,className:`min-w-0 ${Kq} border ${s} bg-panel-2 p-4 ${a}`,children:[(0,L.jsx)(Zq,{icon:t,label:n,head:c,aside:r}),i!=null&&(0,L.jsx)(Qq,{children:i})]})}var eJ=`block min-w-0 text-[13px] leading-5 text-fg/75`;function tJ({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 nJ=`min-w-0 flex-1 text-[11px] leading-snug text-muted/70`,rJ=`text-accent underline underline-offset-2 decoration-accent/40 hover:decoration-accent`,iJ=`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 aJ(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||Uq(t).some(e=>e.kind===`fence`)||Eq(t))}function oJ({thread:e}){return e.crashed===!0?(0,L.jsx)($q,{"data-rested-card":`stalled`,icon:rh,label:`Stalled`,children:(0,L.jsx)(`p`,{className:eJ,children:`The agent's process exited mid-turn. Retry, in the header, re-sends the last message.`})}):(0,L.jsx)($q,{"data-rested-card":`bare`,icon:om,label:`Rested without a sign-off`,children:(0,L.jsx)(`p`,{className:eJ,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 sJ(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 cJ({error:e}){return(0,L.jsxs)($q,{"data-codex-error":e.code??`unknown`,tone:e.retrying?`caution`:`danger`,icon:rh,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:`${eJ} 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 lJ=/^(\d+)\.\s+(.*)$/;function uJ(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&&jq.test(e)?g=e.trim():_.push(e);let v=m(_).join(`
297
+ `)||void 0;return d===null&&g&&(d=Vq(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 Bq=/^[*_`~\s]+/;function Vq(e,t){if(!e)return null;let n=e.replace(/^\s*recommendation\s*:?\s*/i,``).replace(Bq,``).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(Bq,``).match(/^([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase()===r:!1});return i===-1?null:i}function Hq(e){let t=e.match(/^\s*([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase():e.trim()}function Uq(e,t){let n=t.text.trim();if(e.kind===`multi`){let r=(t.chosenSet??[]).slice().sort((e,t)=>e-t).map(t=>Hq(e.options[t]??``)).filter(Boolean).join(`, `);return r&&n?`${r} — ${n}`:r||n}return t.chosen==null?n:e.options[t.chosen]??``}var Wq=/^```(done|awaiting)[ \t]*\r?\n([\s\S]*?)\r?\n```[ \t]*$/gm;function Gq(e,t){return t===`done`?{body:e.trim(),hints:[]}:cl(e)}function Kq(e){let t=[],n=Ec(e),r=0;Wq.lastIndex=0;for(let i=Wq.exec(e);i!==null;i=Wq.exec(e)){if(n(i.index)){Wq.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}=Gq(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 qq(e,t){let n=e?.lastFence;return!(!n||n.kind!==`done`||n.registered!==!0||t&&Kq(t).some(e=>e.kind===`fence`&&e.fenceKind===`done`))}var Jq=`[overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`,Yq=`rounded-xl`,Xq=`rounded-t-xl`,Zq=`rounded-b-[calc(var(--block-radius)_-_1px)]`,Qq={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`}},$q=`card-icon-offset`;function eJ({icon:e,label:t,head:n=Qq.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 ${$q} ${n}`})]})}function tJ({children:e}){return(0,L.jsx)(`div`,{className:`card-md mt-1 min-w-0 text-fg/75`,children:e})}function nJ({tone:e=`neutral`,icon:t,label:n,aside:r,children:i,className:a=``,...o}){let{border:s,head:c}=Qq[e];return(0,L.jsxs)(`div`,{...o,className:`min-w-0 ${Yq} border ${s} bg-panel-2 p-4 ${a}`,children:[(0,L.jsx)(eJ,{icon:t,label:n,head:c,aside:r}),i!=null&&(0,L.jsx)(tJ,{children:i})]})}var rJ=`block min-w-0 text-[13px] leading-5 text-fg/75`;function iJ({children:e,className:t=``}){return(0,L.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center justify-start gap-x-2.5 gap-y-2 ${t}`,children:e})}var aJ=`min-w-0 flex-1 text-[11px] leading-snug text-muted/70`,oJ=`text-accent underline underline-offset-2 decoration-accent/40 hover:decoration-accent`,sJ=`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 cJ(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||Kq(t).some(e=>e.kind===`fence`)||kq(t))}function lJ({thread:e}){return e.crashed===!0?(0,L.jsx)(nJ,{"data-rested-card":`stalled`,icon:rh,label:`Stalled`,children:(0,L.jsx)(`p`,{className:rJ,children:`The agent's process exited mid-turn. Retry, in the header, re-sends the last message.`})}):(0,L.jsx)(nJ,{"data-rested-card":`bare`,icon:om,label:`Rested without a sign-off`,children:(0,L.jsx)(`p`,{className:rJ,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 uJ(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 dJ({error:e}){return(0,L.jsxs)(nJ,{"data-codex-error":e.code??`unknown`,tone:e.retrying?`caution`:`danger`,icon:rh,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:`${rJ} 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 fJ=/^(\d+)\.\s+(.*)$/;function pJ(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(lJ);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 dJ=eu,fJ=RegExp(`^(\\d+)\\.\\s+(⤷\\s+)?[“"](.*?)[”"]\\s+→\\s+(.*)$`);function pJ(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(fJ);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 mJ=eu,hJ=RegExp(`^(\\d+)\\.\\s+(⤷\\s+)?[“"](.*?)[”"]\\s+→\\s+(.*)$`);function gJ(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()!==dJ)return null;n++;let r=[];for(;n<t.length;n++){let e=t[n],i=e.match(fJ);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 mJ(e){return pJ(e)??uJ(e)}var hJ=e=>e.displayText??e.text;function gJ(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`?!1:mJ(hJ(e))!==null}var _J=e=>`${e.question??``}${e.answer}`;function vJ(e,t){let n=t?mJ(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 mJ(hJ(t))??[])r.add(_J(e));if(r.size===0)return n;let i=n.filter(e=>!r.has(_J(e)));return i.length>0?i:null}function yJ(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=Cq(t.text).filter(e=>e.kind===`question`);if(r.length>0)return r}return null}var bJ=e=>e.kind===`question`?Iq(e.text,e.questionKind,e.danger).contextMd.trim():``;function xJ(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=Iq(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 SJ(e,t){let n=e[t];if(!n||n.role!==`user`||n.kind===`event`)return null;let r=hJ(n),i=pJ(r);if(i)return i;let a=uJ(r),o=yJ(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=bJ(o[e.n-1]);return t?{...e,question:t}:{...e}}):o?xJ(r,o):null}function CJ(e){return e.map((t,n)=>SJ(e,n))}function wJ(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function TJ(e){for(let t=e.length-1;t>=0;t--){if(e[t].role===`assistant`)return!0;if(wJ(e[t]))return!1}return!1}function EJ(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(!wJ(r))continue;let i=r.at?Date.parse(r.at):NaN;if(!(!Number.isFinite(i)||i<=n))return t-1}return r}function DJ(e,t,n={}){if(n.atRest&&t.length>0&&TJ(e))return new Map([[e.length-1,[...t]]]);let r=new Map;for(let n of t){let t=EJ(e,n.askedAt),i=r.get(t);i?i.push(n):r.set(t,[n])}return r}function OJ(e,t){for(let n=t;n>=0;n--)if(kJ(e[n]))return n+1;return 0}function kJ(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function AJ(e,t){let n=new Map;for(let[r,i]of DJ(e,t))for(let t=OJ(e,r);t<e.length;t++){if(kJ(e[t]))continue;let r=n.get(t);r?r.push(...i):n.set(t,[...i])}return n}var jJ=12;function MJ(e){return e.replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[*_~`]/g,``).replace(/\s+/g,` `).trim().toLowerCase()}function NJ(e){let t=e.indexOf(`?`);return t===-1?void 0:e.slice(0,t+1)}function PJ(e,t){if(t.length===0)return!1;let n=MJ(Iq(e,`question`).contextMd);if(n.length<jJ)return!1;let r=NJ(n);return t.some(({spec:e})=>{let t=MJ(e.question);if(t.length<jJ)return!1;if(n.includes(t)||t.startsWith(n))return!0;let i=NJ(t);return i!==void 0&&i.length>=jJ&&n.includes(i)?!0:r!==void 0&&r.length>=jJ&&t.includes(r)})}function FJ(e,t){if(t.length===0||!e.includes("```question"))return!1;let n=Cq(e).filter(e=>e.kind===`question`);return n.length>0&&n.every(e=>e.kind===`question`&&IJ(e,t)!==void 0)}function IJ(e,t){return e.registeredId?t.find(t=>t.id.toLowerCase()===e.registeredId):t.find(t=>PJ(e.text,[t]))}function LJ({h:e=14}){return(0,L.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0`,style:{height:e}})}function RJ({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:BJ}),t,(0,L.jsx)(zJ,{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 zJ({at:e}){let t=YT(e,oE());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:XT(e)??void 0,className:`shrink-0 tabular-nums`,children:t})]}):null}var BJ=`shrink-0 translate-y-[0.04em]`;function VJ(e,t,n){return e===1?n?`New ${t} from @${n}`:`New ${t}`:`${e} new items`}var HJ=`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 UJ({steer:e,text:t,sourceId:n,at:r,wrap:i}){let a=Ol(t);if(a)return(0,L.jsx)(XJ,{wake:a,sourceId:n,at:r});let o=Al(t);if(o)return(0,L.jsx)(WJ,{wake:o,sourceId:n});let s=Pl(t);if(s)return(0,L.jsx)(JJ,{window:s.window,sourceId:n,at:r});let c=Ml(t);if(c)return(0,L.jsx)(YJ,{capped:c.capped,to:c.to,sourceId:n,at:r});let l=Rl(t);if(l)return(0,L.jsx)(KJ,{wake:l,sourceId:n,at:r});let u=Bl(t);if(u)return(0,L.jsx)(qJ,{watchRef:u.ref,sourceId:n,at:r});let d=nu(t);if(d)return(0,L.jsx)(GJ,{count:d.count,sourceId:n,at:r});let f=Ku(t),p=Wu(t),m=e??zu(f||p?t.split(`
301
+ `),n=0;for(;n<t.length&&!t[n].trim();)n++;if(n>=t.length||t[n].trim()!==mJ)return null;n++;let r=[];for(;n<t.length;n++){let e=t[n],i=e.match(hJ);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 _J(e){return gJ(e)??pJ(e)}var vJ=e=>e.displayText??e.text;function yJ(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`?!1:_J(vJ(e))!==null}var bJ=e=>`${e.question??``}${e.answer}`;function xJ(e,t){let n=t?_J(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 _J(vJ(t))??[])r.add(bJ(e));if(r.size===0)return n;let i=n.filter(e=>!r.has(bJ(e)));return i.length>0?i:null}function SJ(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=Eq(t.text).filter(e=>e.kind===`question`);if(r.length>0)return r}return null}var CJ=e=>e.kind===`question`?zq(e.text,e.questionKind,e.danger).contextMd.trim():``;function wJ(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=zq(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 TJ(e,t){let n=e[t];if(!n||n.role!==`user`||n.kind===`event`)return null;let r=vJ(n),i=gJ(r);if(i)return i;let a=pJ(r),o=SJ(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=CJ(o[e.n-1]);return t?{...e,question:t}:{...e}}):o?wJ(r,o):null}function EJ(e){return e.map((t,n)=>TJ(e,n))}function DJ(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function OJ(e){for(let t=e.length-1;t>=0;t--){if(e[t].role===`assistant`)return!0;if(DJ(e[t]))return!1}return!1}function kJ(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(!DJ(r))continue;let i=r.at?Date.parse(r.at):NaN;if(!(!Number.isFinite(i)||i<=n))return t-1}return r}function AJ(e,t,n={}){if(n.atRest&&t.length>0&&OJ(e))return new Map([[e.length-1,[...t]]]);let r=new Map;for(let n of t){let t=kJ(e,n.askedAt),i=r.get(t);i?i.push(n):r.set(t,[n])}return r}function jJ(e,t){for(let n=t;n>=0;n--)if(MJ(e[n]))return n+1;return 0}function MJ(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function NJ(e,t){let n=new Map;for(let[r,i]of AJ(e,t))for(let t=jJ(e,r);t<e.length;t++){if(MJ(e[t]))continue;let r=n.get(t);r?r.push(...i):n.set(t,[...i])}return n}var PJ=12;function FJ(e){return e.replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[*_~`]/g,``).replace(/\s+/g,` `).trim().toLowerCase()}function IJ(e){let t=e.indexOf(`?`);return t===-1?void 0:e.slice(0,t+1)}function LJ(e,t){if(t.length===0)return!1;let n=FJ(zq(e,`question`).contextMd);if(n.length<PJ)return!1;let r=IJ(n);return t.some(({spec:e})=>{let t=FJ(e.question);if(t.length<PJ)return!1;if(n.includes(t)||t.startsWith(n))return!0;let i=IJ(t);return i!==void 0&&i.length>=PJ&&n.includes(i)?!0:r!==void 0&&r.length>=PJ&&t.includes(r)})}function RJ(e,t){if(t.length===0||!e.includes("```question"))return!1;let n=Eq(e).filter(e=>e.kind===`question`);return n.length>0&&n.every(e=>e.kind===`question`&&zJ(e,t)!==void 0)}function zJ(e,t){return e.registeredId?t.find(t=>t.id.toLowerCase()===e.registeredId):t.find(t=>LJ(e.text,[t]))}function BJ({h:e=14}){return(0,L.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0`,style:{height:e}})}function VJ({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:UJ}),t,(0,L.jsx)(HJ,{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 HJ({at:e}){let t=XT(e,sE());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:ZT(e)??void 0,className:`shrink-0 tabular-nums`,children:t})]}):null}var UJ=`shrink-0 translate-y-[0.04em]`;function WJ(e,t,n){return e===1?n?`New ${t} from @${n}`:`New ${t}`:`${e} new items`}var GJ=`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 KJ({steer:e,text:t,sourceId:n,at:r,wrap:i}){let a=Ol(t);if(a)return(0,L.jsx)($J,{wake:a,sourceId:n,at:r});let o=Al(t);if(o)return(0,L.jsx)(qJ,{wake:o,sourceId:n});let s=Pl(t);if(s)return(0,L.jsx)(ZJ,{window:s.window,sourceId:n,at:r});let c=Ml(t);if(c)return(0,L.jsx)(QJ,{capped:c.capped,to:c.to,sourceId:n,at:r});let l=Rl(t);if(l)return(0,L.jsx)(YJ,{wake:l,sourceId:n,at:r});let u=Bl(t);if(u)return(0,L.jsx)(XJ,{watchRef:u.ref,sourceId:n,at:r});let d=nu(t);if(d)return(0,L.jsx)(JJ,{count:d.count,sourceId:n,at:r});let f=Ku(t),p=Wu(t),m=e??zu(f||p?t.split(`
302
302
  `).filter(e=>!Ku(e)&&!Wu(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)($q,{icon:Yp,label:`Frizz`,children:(0,L.jsx)(`div`,{className:`${eJ} whitespace-pre-wrap [overflow-wrap:anywhere]${i?` ${Gq}`:``}`,children:Cu(t)})})}):f||p?(0,L.jsxs)(`div`,{"data-frizz-wake":!0,className:`flex flex-col`,children:[f&&(0,L.jsx)(ZJ,{wake:f,sourceId:n,at:r}),p&&(0,L.jsxs)(L.Fragment,{children:[f&&(0,L.jsx)(LJ,{}),(0,L.jsx)(QJ,{wake:p,sourceId:f?void 0:n,at:r})]}),m&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(LJ,{}),(0,L.jsx)($J,{steer:m,text:t,at:r})]})]}):(0,L.jsx)($J,{steer:m,text:t,sourceId:n,at:r})}function WJ({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)(RJ,{icon:Gp,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 GJ({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)(RJ,{icon:Pm,sourceId:t,marker:`event`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function KJ({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)(RJ,{icon:Tm,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)(RJ,{icon:Tm,sourceId:t,marker:`event`,ariaLabel:o,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:o})})}function qJ({watchRef:e,sourceId:t,at:n}){let r=EH(e);return(0,L.jsx)(RJ,{icon:wm,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:HJ,children:e}):e,` `,`expired`]})})}function JJ({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)(RJ,{icon:Tm,sourceId:t,marker:`limit-resume`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function YJ({capped:e,to:t,sourceId:n,at:r}){let i=`${e} limit — switched to ${t}`;return(0,L.jsx)(RJ,{icon:Tm,sourceId:n,marker:`limit-model-switch`,ariaLabel:i,at:r,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:i})})}function XJ({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)(RJ,{icon:eh,sourceId:t,marker:`event`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function ZJ({wake:e,sourceId:t,at:n}){let r=EH(e.ref),i=r?(0,L.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:HJ,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)(RJ,{icon:wm,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 QJ({wake:e,sourceId:t,at:n}){let r=EH(e.ref),i=r?(0,L.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:HJ,children:e.ref}):(0,L.jsx)(`span`,{children:e.ref});return(0,L.jsx)(RJ,{icon:wm,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 $J({steer:e,text:t,sourceId:n,at:r}){let i=EH(e.ref),a=e.items.length+e.omitted,o=Nu(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`:VJ(a,e.items[0]?.label??`item`,s?.actor),u=c?(0,L.jsx)(`a`,{href:c,target:`_blank`,rel:`noreferrer noopener`,className:HJ,children:e.ref}):(0,L.jsx)(`span`,{children:e.ref});return(0,L.jsx)(RJ,{icon:wm,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 eY({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)(RJ,{icon:Zm,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)(RJ,{icon:r?nh:Km,sourceId:t,marker:r?`schedule`:`rest`,ariaLabel:i,at:n,children:i})}var tY=/(^|[^\w/.@-])(https?:\/\/[^\s<>`]+|www\.[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:[^\s<>`]*)?)/gi,nY=new Set([`.`,`,`,`:`,`;`,`!`,`?`,`*`,`_`,`~`,`'`,`"`]),rY={")":`(`,"]":`[`,"}":`{`};function iY(e){let t=e;for(;;){let e=t[t.length-1];if(e!==void 0&&nY.has(e)){t=t.slice(0,-1);continue}let n=e===void 0?void 0:rY[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 aY(e,t){if(t===``)return;let n=0;for(let r of Zd(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:Kd(r.href)}),n=r.start+r.text.length;n<t.length&&e.push({kind:`text`,text:t.slice(n)})}function oY(e){let t=[],n=0;tY.lastIndex=0;for(let r=tY.exec(e);r;r=tY.exec(e)){let[,i,a]=r,o=iY(a);if(/^https?:\/\/$/i.test(o)||o===``)continue;let s=r.index+i.length;tY.lastIndex=s+o.length;let c=/^www\./i.test(o)?`http://${o}`:o;s>n&&aY(t,e.slice(n,s)),t.push({kind:`link`,text:o,href:c,ghRef:Kd(c)}),n=s+o.length}return n<e.length&&aY(t,e.slice(n)),t}function sY({text:e}){let t=(0,I.useMemo)(()=>oY(e),[e,dK()]),n=(0,I.useMemo)(()=>t.flatMap(e=>e.kind===`link`&&e.ghRef?[e.ghRef]:[]),[t]);return(0,I.useEffect)(()=>{n.length>0&&Of(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 cY({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 ${Kq} rounded-br-sm border border-border-strong bg-elevated p-4`,children:[(0,L.jsx)(Zq,{icon:jm,label:`Answers`}),(0,L.jsx)(Qq,{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)(sY,{text:e.answer})})]})]},t))})})]})})}function lY(e){return e.sourceId??`legacy-${yY(e.text)}`}function uY(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 dY=e=>Cq(e).filter(e=>e.kind===`question`).map(e=>e.kind===`question`?Iq(e.text,e.questionKind,e.danger):Iq(``,`question`));function fY(){let e=new Set;return(t,n)=>{let r=lY(t);return e.has(r)&&(r=`${r}#${n}`),e.add(r),r}}function pY(e){let t=uY(e),n=fY(),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=dY(a.text);o.length>0&&r.push({idx:i,identity:n(a,i),blocks:o,isLive:i===t})}return r}function mY(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())&&dY(n.text).length>0)return t}}return-1}function hY(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)(nJ,{icon:Yp,label:`Frizz`,children:(0,L.jsx)(`div`,{className:`${rJ} whitespace-pre-wrap [overflow-wrap:anywhere]${i?` ${Jq}`:``}`,children:Cu(t)})})}):f||p?(0,L.jsxs)(`div`,{"data-frizz-wake":!0,className:`flex flex-col`,children:[f&&(0,L.jsx)(eY,{wake:f,sourceId:n,at:r}),p&&(0,L.jsxs)(L.Fragment,{children:[f&&(0,L.jsx)(BJ,{}),(0,L.jsx)(tY,{wake:p,sourceId:f?void 0:n,at:r})]}),m&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(BJ,{}),(0,L.jsx)(nY,{steer:m,text:t,at:r})]})]}):(0,L.jsx)(nY,{steer:m,text:t,sourceId:n,at:r})}function qJ({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)(VJ,{icon:Gp,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 JJ({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)(VJ,{icon:Pm,sourceId:t,marker:`event`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function YJ({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)(VJ,{icon:Tm,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)(VJ,{icon:Tm,sourceId:t,marker:`event`,ariaLabel:o,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:o})})}function XJ({watchRef:e,sourceId:t,at:n}){let r=DH(e);return(0,L.jsx)(VJ,{icon:wm,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:GJ,children:e}):e,` `,`expired`]})})}function ZJ({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)(VJ,{icon:Tm,sourceId:t,marker:`limit-resume`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function QJ({capped:e,to:t,sourceId:n,at:r}){let i=`${e} limit — switched to ${t}`;return(0,L.jsx)(VJ,{icon:Tm,sourceId:n,marker:`limit-model-switch`,ariaLabel:i,at:r,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:i})})}function $J({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)(VJ,{icon:eh,sourceId:t,marker:`event`,ariaLabel:r,at:n,children:(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function eY({wake:e,sourceId:t,at:n}){let r=DH(e.ref),i=r?(0,L.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:GJ,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)(VJ,{icon:wm,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 tY({wake:e,sourceId:t,at:n}){let r=DH(e.ref),i=r?(0,L.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:GJ,children:e.ref}):(0,L.jsx)(`span`,{children:e.ref});return(0,L.jsx)(VJ,{icon:wm,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 nY({steer:e,text:t,sourceId:n,at:r}){let i=DH(e.ref),a=e.items.length+e.omitted,o=Nu(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`:WJ(a,e.items[0]?.label??`item`,s?.actor),u=c?(0,L.jsx)(`a`,{href:c,target:`_blank`,rel:`noreferrer noopener`,className:GJ,children:e.ref}):(0,L.jsx)(`span`,{children:e.ref});return(0,L.jsx)(VJ,{icon:wm,sourceId:n,marker:`github`,at:s?.at??r,ariaLabel:c?void 0:`${l} on ${e.ref}`,children:(0,L.jsxs)(`span`,{className:`min-w-0 truncate`,children:[l,` on `,u]})})}function rY({bump:e,sourceId:t,at:n}){let r=e.kind===`schedule`;if(e.kind===`signoff`){let e=`Frizz asked for a sign-off`;return(0,L.jsx)(VJ,{icon:Zm,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)(VJ,{icon:r?nh:Km,sourceId:t,marker:r?`schedule`:`rest`,ariaLabel:i,at:n,children:i})}var iY=/(^|[^\w/.@-])(https?:\/\/[^\s<>`]+|www\.[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:[^\s<>`]*)?)/gi,aY=new Set([`.`,`,`,`:`,`;`,`!`,`?`,`*`,`_`,`~`,`'`,`"`]),oY={")":`(`,"]":`[`,"}":`{`};function sY(e){let t=e;for(;;){let e=t[t.length-1];if(e!==void 0&&aY.has(e)){t=t.slice(0,-1);continue}let n=e===void 0?void 0:oY[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 cY(e,t){if(t===``)return;let n=0;for(let r of Zd(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:Kd(r.href)}),n=r.start+r.text.length;n<t.length&&e.push({kind:`text`,text:t.slice(n)})}function lY(e){let t=[],n=0;iY.lastIndex=0;for(let r=iY.exec(e);r;r=iY.exec(e)){let[,i,a]=r,o=sY(a);if(/^https?:\/\/$/i.test(o)||o===``)continue;let s=r.index+i.length;iY.lastIndex=s+o.length;let c=/^www\./i.test(o)?`http://${o}`:o;s>n&&cY(t,e.slice(n,s)),t.push({kind:`link`,text:o,href:c,ghRef:Kd(c)}),n=s+o.length}return n<e.length&&cY(t,e.slice(n)),t}function uY({text:e}){let t=(0,I.useMemo)(()=>lY(e),[e,mK()]),n=(0,I.useMemo)(()=>t.flatMap(e=>e.kind===`link`&&e.ghRef?[e.ghRef]:[]),[t]);return(0,I.useEffect)(()=>{n.length>0&&Of(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 dY({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 ${Yq} rounded-br-sm border border-border-strong bg-elevated p-4`,children:[(0,L.jsx)(eJ,{icon:jm,label:`Answers`}),(0,L.jsx)(tJ,{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)(uY,{text:e.answer})})]})]},t))})})]})})}function fY(e){return e.sourceId??`legacy-${SY(e.text)}`}function pY(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 mY=e=>Eq(e).filter(e=>e.kind===`question`).map(e=>e.kind===`question`?zq(e.text,e.questionKind,e.danger):zq(``,`question`));function hY(){let e=new Set;return(t,n)=>{let r=fY(t);return e.has(r)&&(r=`${r}#${n}`),e.add(r),r}}function gY(e){let t=pY(e),n=hY(),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=mY(a.text);o.length>0&&r.push({idx:i,identity:n(a,i),blocks:o,isLive:i===t})}return r}function _Y(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())&&mY(n.text).length>0)return t}}return-1}function vY(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
  `)}`:`${eu}\n${t.map((e,t)=>`${t+1}. “${e.question}” → ${e.answer}`).join(`
306
- `)}`}function gY(e,t,n,r={}){let i=wH(e),[a,o]=(0,I.useState)({}),s=(0,I.useMemo)(()=>pY(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)(()=>mY(t)!==-1,[t]),u=sz(),d=cz(e),f=(0,I.useCallback)((t,n)=>oz.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=uz(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];iz.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)=>Bq(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)=>Bq(e.blocks[t],_(e.identity,t)),l=n.flatMap(e=>e.blocks.map((t,n)=>({ask:e,bi:n,question:vY(t),answer:c(e,n)})).filter(e=>e.answer!==``));if(l.length===0)return;let u=n.find(e=>e.isLive),d=hY({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,iz.get(e)]);C(d,{onOptimistic:()=>{r.forEach(e=>iz.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&&!iz.get(e)&&iz.set(e,t)})}})},[a,s,_,C,p,f]),T=(0,I.useCallback)(e=>{let t=v.get(lY(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)=>Bq(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 _Y(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 vY(e){return _Y(e.contextMd)||_Y(e.options.join(` / `))||`earlier question`}function yY(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 bY({raw:e,question:t,questionKind:n,danger:r,interactive:i,wrap:a,aside:o,label:s,settled:c}){let l=(0,I.useMemo)(()=>t??Iq(e??``,n??`question`,r),[t,e,n,r]),u=pK(l.contextMd),d=pK(l.trailingMd??``),f=l.recommendedIdx,p=hK(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)($q,{tone:h?`risk`:`neutral`,icon:h?rh:void 0,label:s??(m?`Select multiple`:`Question`),aside:o,children:[u&&(0,L.jsx)(`div`,{className:`text-fg`,children:(0,L.jsx)(fq,{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||FL({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)(xY,{md:l.optionHeadings[t],wrap:a}),(0,L.jsx)(CY,{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}FL({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?`${SY(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)(fq,{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)(fq,{className:`md-inline mt-1.5 text-[11px] text-muted/70`,html:p})]})}function xY({md:e,wrap:t}){let n=hK(e.split(`
308
- `).join(` `));return(0,L.jsx)(`div`,{className:`mt-1 text-fg`,children:(0,L.jsx)(fq,{className:`md-body${t?` ${Gq}`:``}`,html:n})})}function SY(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 CY({label:e,bodyMd:t,wrap:n,selected:r,settledPick:i,disabled:a,multi:o,recommended:s,recTitle:c,onClick:l}){let u=hK(e),d=pK(t??``),f=(0,I.useId)();return(0,L.jsxs)(`div`,{"data-question-option":!0,title:c,onClick:e=>{a||e.target.closest(`a, button, .local-file-action, .local-file-code`)||window.getSelection()?.toString()||l()},className:`relative flex items-start gap-2 rounded-md border px-3 py-1.5 text-[12px] leading-snug transition-colors ${r?`border-accent bg-accent/10 text-fg`:i?`border-border-strong border-l-2 border-l-accent/40 bg-bg/50 pl-[11px] text-fg`:a?`border-border text-muted/80`:`border-border text-fg/90 hover:bg-elevated hover:border-border-strong`}`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:a,"aria-labelledby":f,onClick:l,onMouseDown:e=>e.preventDefault(),className:`absolute inset-0 rounded-md outline-none`}),o&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`mt-px flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-[3px] border ${r?`border-accent bg-accent text-bg`:i?`border-border-strong text-fg`:`border-border-strong`}`,children:(r||i)&&(0,L.jsx)(Qp,{size:10,strokeWidth:3})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{id:f,children:[s&&(0,L.jsx)(`span`,{className:`pointer-events-none float-right ml-2 mt-px -translate-y-[2px] rounded-full border border-border-strong px-1.5 py-px text-[9.5px] uppercase tracking-wide text-muted`,children:`Recommended`}),(0,L.jsx)(fq,{as:`span`,className:`md-inline`,html:u})]}),t!==void 0&&(0,L.jsx)(fq,{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 wY({blocks:e,answering:t,onClose:n}){let[r,i]=(0,I.useState)(0),[a,o]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let e=requestAnimationFrame(()=>o(!0));return()=>cancelAnimationFrame(e)},[]),(0,I.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),n())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n]);let s=e[Math.min(r,e.length-1)];if(!s)return null;let c=r>=e.length-1;return(0,ot.createPortal)((0,L.jsxs)(`div`,{"data-mobile-answer-sheet":!0,className:`fixed inset-0 z-[80] flex flex-col justify-end`,children:[(0,L.jsx)(`button`,{"aria-label":`Close`,onClick:n,className:`absolute inset-0 bg-black/50 transition-opacity duration-200 ${a?`opacity-100`:`opacity-0`}`}),(0,L.jsxs)(`div`,{className:`relative flex max-h-[86%] flex-col overflow-hidden rounded-t-[14px] border-t border-border-strong bg-panel pb-[env(safe-area-inset-bottom)] shadow-[0_-20px_60px_-10px_rgba(0,0,0,0.8)] transition-transform duration-200 ease-out motion-reduce:transition-none ${a?`translate-y-0`:`translate-y-full`}`,children:[(0,L.jsx)(`div`,{className:`mx-auto mt-[6px] h-[5px] w-[36px] shrink-0 rounded-full bg-muted/35`}),(0,L.jsxs)(`div`,{className:`flex h-[48px] shrink-0 items-center gap-2 border-b border-border/70 px-3`,children:[(0,L.jsx)(`button`,{onClick:n,className:`flex h-[44px] items-center px-2 text-[16px] text-fg/85`,children:`Cancel`}),(0,L.jsx)(`span`,{className:`flex-1 text-center text-[15px] font-semibold tracking-[-0.01em] text-fg`,children:e.length>1?`Question ${r+1} of ${e.length}`:`Question`}),(0,L.jsx)(`span`,{className:`flex h-[44px] w-[44px] items-center justify-center`,children:(0,L.jsx)(ah,{size:19,className:`opacity-0`,"aria-hidden":!0})})]}),(0,L.jsx)(`div`,{"data-mobile-answer-body":!0,className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:(0,L.jsx)(bY,{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 TY(e){return(0,I.useSyncExternalStore)(e=>Jt(X,e),()=>e?EY(e)!==`codex`:!1,()=>!1)}function EY(e){return Dp(X.board,e)?.backend}function DY(e,t,n,r){let i=oz.followUp(e,t,n),a=iz.get(i),o=a?`${r}\n\n${a}`:r;return iz.set(i,o),i}function OY(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 kY(e){let t=Ve(),n=sz(),[r,i]=(0,I.useState)(!1);return{unqueue:(0,I.useCallback)(a=>{if(!e||r)return;let o=Dp(X.board,e)?.sessionId;if(!o){Z(`This thread has no live session to unqueue from`);return}i(!0),Y.unqueueFollowUp({slug:e,sessionId:o,deliveryId:a.deliveryId}).then(r=>{if(i(!1),!r.unqueued){Z(r.reason??`That message could not be taken back`);return}JC(t,e,a.rawText,a.deliveryId),DY(n,e,o,a.text),OY(a.from)},e=>{i(!1),Z(`Couldn't unqueue — ${(e instanceof Error?e.message:String(e)).slice(0,90)}`)})},[r,n,t,e]),pending:r}}function AY(e){return(0,I.useSyncExternalStore)(e=>Jt(X,e),()=>{if(!e)return!1;let t=Dp(X.board,e);return t?.backend!==`codex`&&t?.runtime===`running`},()=>!1)}function jY(e){let[t,n]=(0,I.useState)(!1);return{deliverNow:(0,I.useCallback)(()=>{if(!e||t)return;let r=Dp(X.board,e)?.sessionId;if(!r){Z(`This thread has no live session to interrupt`);return}n(!0),Y.deliverQueuedNow({slug:e,sessionId:r}).then(e=>{n(!1),e.interrupted||Z(e.reason??`That message could not be pushed through`)},e=>{n(!1),Z(`Couldn't push it through — ${(e instanceof Error?e.message:String(e)).slice(0,90)}`)})},[t,e]),pending:t}}function MY(e){return e.displayText??e.text}function NY(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 PY(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&&!gJ(n)))return t}return 0}function FY(e,t){if(e.kind===`event`||e.kind===`reasoning`||e.role!==`user`)return!1;let n=MY(e).replace(/\r\n?/g,`
309
- `);return(t===void 0?mJ(n):t)?!0:!(e.wake||e.peerFrom)}function IY(e,t){return FY(e,t)?`bubble`:`prose`}var LY=`icon-label-nudge`,RY=new Set([`planning`,`planned`,`active`,`needs-human`,`blocked`]);function zY(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&&RY.has(e.status))}function BY(e,t){let n=e.trim();if(!(!n||n===t.trim()))return n}function VY(e,t){let n=e.trim();return!n||n===t||n===`Untitled thread`||n===`Spinning up a thread…`?``:n}function HY(e){return e.kind!==`session`||e.foreign||e.backend===`codex`||e.claudeRuntime!==void 0&&e.claudeRuntime!==`broker`?{show:!1,enabled:!1,label:``}:e.runtime===`exited`||e.runtime===`none`?{show:!0,enabled:!1,label:`Resume this Claude thread to rename it with Claude`}:e.runtime===`spawning`?{show:!0,enabled:!1,label:`Rename with Claude once this thread has started`}:{show:!0,enabled:!0,label:`Rename with Claude — a fresh title from the opening request`}}var UY=`sticky top-0 z-10 flex min-w-0 shrink-0 items-center gap-2.5 border-b border-border bg-panel px-3 ${oh} max-[640px]:h-auto max-[640px]:min-h-12 max-[640px]:flex-wrap max-[640px]:items-start max-[640px]:gap-y-2 max-[640px]:px-4 max-[640px]:py-2.5`,WY=`min-w-0 flex-1 pl-1 max-[640px]:basis-full`,GY=`flex shrink-0 items-center max-[640px]:w-full max-[640px]:justify-between`;function KY(e){return e?.trim()?{kind:`profile-error`,message:`Profile controls unavailable: ${e.trim().slice(0,160)}`}:null}function qY(e){if(e.foreign)return`Read-only external thread`;if(e.permissionChangePending||e.permissionPending)return`A permission change is already in progress`;if(e.profileChangePending)return`A model and effort change is already in progress`;if(e.runtimeControlPending)return`Another runtime control is already in progress`;if(e.pendingAsk||e.runtime===`perm-prompt`)return`Resolve the current terminal approval or question first`;if(e.backend===`codex`)return null;let t=[...e.subAgents??[],...e.bgShells??[]].filter(e=>e.state===`running`||e.state===`stale`).length;return t>0?`Wait for ${t} unresolved background operation${t===1?``:`s`}`:e.runtime===`running`||e.runtime===`spawning`?`Wait for the current turn to finish`:null}function JY(e){return e.permissionChangePending===!0||e.permissionPending!==void 0||e.profileChangePending===!0||e.runtimeControlPending===!0}function YY(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 XY(e){return e===`right`?`pl-3 pr-7`:`pl-7 pr-3`}function ZY(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 QY=`__frizz_empty_select_value__`,$Y=e=>e===``?QY:e,eX=e=>e===QY?``:e,tX={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`},nX={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 rX({o:e,indicatorPosition:t,typography:n}){return(0,L.jsxs)(yI,{value:$Y(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 ${XY(t)} ${n??``}`,children:[(0,L.jsx)(bI,{className:`pointer-events-none absolute top-1/2 inline-flex -translate-y-1/2 items-center text-accent ${t===`right`?`right-2`:`left-2`}`,children:(0,L.jsx)(Qp,{size:13})}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]})}function iX({value:e,onValueChange:t,options:n,groups:r,placeholder:i,ariaLabel:a,title:o,disabled:s=!1,variant:c=`ghost`,indicatorPosition:l=`left`,side:u=`bottom`,className:d=``}){let f=ZY(e,n,r,i),p=s?nX[c]:tX[c],m=c===`readout`?eR:``,[h,g]=(0,I.useState)(!1),_=(0,I.useRef)(h),v=(0,I.useRef)(s),y=(0,I.useRef)(void 0);return _.current=h,v.current=s,(0,I.useLayoutEffect)(()=>{let e=e=>{e.key!==`Escape`||!_.current||v.current||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),_.current=!1,y.current?.(),y.current=void 0,g(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]),(0,I.useLayoutEffect)(()=>{!s||!h||(_.current=!1,y.current?.(),y.current=void 0,g(!1))},[s,h]),(0,I.useLayoutEffect)(()=>()=>y.current?.(),[]),(0,L.jsxs)(dI,{modal:!1,open:h,onOpenChange:e=>{y.current?.(),y.current=void 0,_.current=e,g(e),e&&(y.current=vR(()=>{_.current=!1,y.current=void 0,g(!1)}))},children:[(0,L.jsx)(fI,{asChild:!0,disabled:s,children:(0,L.jsxs)(`button`,{type:`button`,"aria-label":a,title:o,className:`group inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md border px-2 py-1 text-left text-[12px] text-fg outline-none data-[placeholder]:text-muted ${s?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors`} ${p} ${c===`readout`?`select-trigger-readout`:``} ${m} ${d}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left ${f.placeholder?`text-muted`:``}`,children:f.text}),(0,L.jsx)($p,{className:`select-caret shrink-0 text-muted ${s?``:`transition-transform group-data-[state=open]:rotate-180`}`,size:13})]})}),(0,L.jsx)(pI,{children:(0,L.jsx)(mI,{align:`start`,side:u,sideOffset:5,onEscapeKeyDown:e=>e.stopPropagation(),className:`${Nj} min-w-[var(--radix-dropdown-menu-trigger-width)] max-w-[calc(100vw-1rem)] overflow-hidden rounded-lg p-1 ${m}`,children:(0,L.jsx)(vI,{value:$Y(e),onValueChange:e=>t(eX(e)),className:`max-h-[300px] min-w-0 overflow-y-auto`,children:r?r.map((e,t)=>(0,L.jsxs)(hI,{children:[e.label&&(0,L.jsx)(gI,{className:`${XY(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)(rX,{o:e,indicatorPosition:l,typography:m},e.value))]},e.label||`g${t}`)):(n??[]).map(e=>(0,L.jsx)(rX,{o:e,indicatorPosition:l,typography:m},e.value))})})})]})}function aX(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 oX(e){let t=Zt(X).board?.threads.find(t=>t.id===e),n=nt({queryKey:[`threadProfileOptions`,e],queryFn:()=>Y.threadProfileOptions({slug:e}),enabled:!!(t&&!t.foreign&&t.kind===`session`),staleTime:5e3}),r=it({mutationFn:t=>Y.setThreadProfile({slug:e,...t})}),i=it({mutationFn:t=>Y.setThreadPermission({slug:e,permissionMode:t})}),a=r.isPending||i.isPending;if(!t||t.foreign||t.kind!==`session`)return{busy:a,footer:null,status:null};let o=a||JY(t),s=t.model?.trim(),c=t.effort?.trim(),l=t.backend===`codex`?`codex`:`claude`,u=r.isPending?r.variables:void 0,d=t.profilePendingModel??u?.model,f=t.profilePendingEffort??u?.effort,p=n.data?.options??[],{modelSelectable:m}=aX(p,s,c,t.runtime===`exited`),h=n.data!==void 0,g=[{id:l,label:l===`codex`?`Codex`:`Claude Code`,options:p}],_=KY(n.isError?n.error.message:void 0),v=t.permissionMode?IR(t.permissionMode):`auto`,y=PR.some(e=>e.value===v)?v:`auto`,b=i.isPending?i.variables:y,x=qY(t);function S(e){e!==y&&i.mutate(e,{onSuccess:e=>Z(YY(e.effect,`claude`)),onError:e=>Z(`Permission change failed: ${e.message.slice(0,120)}`)})}function C(e){r.mutate(e,{onSuccess:e=>Z(e.effect===`next-resume`?`Model and effort saved for the next resume`:`Model and effort applied`),onError:e=>Z(`Profile change failed: ${e.message.slice(0,120)}`)})}return{busy:o,footer:(0,L.jsxs)(`div`,{"data-thread-composer-controls":!0,className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-1.5 gap-y-0.5`,children:[(0,L.jsx)(SR,{groups:g,value:{provider:l,model:s,effort:c},pending:d||f?{provider:l,model:d,effort:f}:void 0,onValueChange:({model:e,effort:t})=>C({model:e,effort:t}),placeholder:n.isPending?`Profile loading…`:`Profile unknown`,ariaLabel:`Thread model and effort`,menuAriaLabel:`Choose ${l===`codex`?`Codex`:`Claude Code`} model and effort`,title:m?t.runtime===`exited`?`Saved per thread and applied when this conversation resumes`:`Change this idle conversation's model and reasoning effort`:`The current live backend profile is unavailable; controls fail closed`,disabled:o||!h||!m||n.isError,compact:!0,side:`top`,className:`min-w-0 max-w-[min(72%,20rem)] px-1.5 py-0.5`}),l===`claude`&&(0,L.jsx)(iX,{variant:`readout`,side:`top`,value:b,onValueChange:e=>S(e),options:PR,ariaLabel:`Thread permission mode`,title:x?`${x} — changing permissions restarts this thread's worker process`:b===`bypassPermissions`?`Bypass: the worker never asks for approval. Changing this restarts the worker process; the conversation resumes from disk on the next turn.`:`Auto: risky actions raise an approval card here. Changing this restarts the worker process; the conversation resumes from disk on the next turn.`,disabled:o||x!==null,className:`shrink-0`}),d&&f&&(0,L.jsxs)(`span`,{className:`min-w-0 truncate text-[9px] text-muted/50`,children:[`→ `,d,` · `,f,` pending`]})]}),status:_?(0,L.jsx)(`div`,{"data-thread-control-error":``,className:`px-1 pt-1 text-[9.5px] leading-tight text-muted/65`,children:_.message}):null}}var sX=new Map;function cX(e){let t=sX.get(e);if(t)return t;let n=Y.threadSkills({slug:e}).then(e=>e.skills,()=>(sX.delete(e),[]));return sX.set(e,n),n}function lX({slug:e,surface:t,placeholder:n,className:r,id:i,ops:a,submitOverride:o}){let s=Zt(X),c=s.board?.threads.find(t=>t.id===e),l=sz(),u=oz.followUp(l,e,c?.sessionId),[d,f,p]=lz(u),m=oX(e),h=wH(e),[g,_]=(0,I.useState)(null),v=(0,I.useMemo)(()=>()=>cX(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}=mL(d),r=t.filter(e=>bL(n,e.token));r.length!==t.length&&(X.composerContext[e]=r)},[e,d,x]);let C=!o&&c?.runtime===`running`&&c.backend!==`codex`;function w(t=!1){let n=d.trim();if(!n)return;let r=DR(n);if(r){p();let e=c?.backend===`codex`?`codex`:`claude`;r===`login`?_(e):b(e);return}let i=gp(e),a=kL(n,i,l),s={onOptimistic:p,onRollback:()=>{iz.get(u)||f(d),_p(e,i)}};o?o(a,s):h.submit(a,{...s,interrupt:t})}return(0,L.jsxs)(`div`,{"data-thread-composer-box":t,...t===`chatComposer`?{"data-thread-action-bar":``}:{},className:r,children:[(0,L.jsx)(YL,{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)(kR,{backend:g,onClose:()=>_(null),onAuthed:()=>_(null)}),y&&(0,L.jsx)(AR,{backend:y,onClose:()=>b(null)})]})}function uX({slug:e,ops:t}){let n=Zt(X).board?.threads.find(t=>t.id===e);return n?(0,L.jsx)(lX,{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 dX({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)(Lj,{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:eD,children:(0,L.jsx)(Um,{size:14,strokeWidth:2})})})}function fX(e,t){return new Promise(n=>{CH(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 pX(){return OV(RV().data??null)}function mX({thread:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return!pX()||e.kind!==`session`||e.foreign||e.backend===`codex`||e.runtime===`exited`?null:(0,L.jsx)(Lj,{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),fX(t,e.id).finally(()=>r(!1))},className:`${eD} mx-[2px]`,children:n?(0,L.jsx)(Mm,{size:14,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(Gm,{size:14,strokeWidth:2})})})}function hX({slug:e,label:t=`Exit fullscreen`}){let n=$E(e)??ZC(`/`);function r(e){Id(e)&&(e.preventDefault(),nw(n,{viewTransition:!Mp()}))}return(0,L.jsx)(Lj,{label:t,children:(0,L.jsx)(`a`,{href:n,"aria-label":t,"data-standalone-return":!0,onMouseDown:e=>e.preventDefault(),onClick:r,className:eD,children:(0,L.jsx)(Lm,{size:14})})})}function gX({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)(vX,{label:o?`Expand`:`Collapse`,icon:o?rm:nm,size:13,onClick:a}),(0,L.jsx)(dX,{thread:e}),(0,L.jsx)(mX,{thread:e}),r&&(0,L.jsx)(vX,{label:`Frizz document`,icon:gm,size:14,onClick:r}),t&&(0,L.jsx)(Rj,{slug:e.id}),n&&(0,L.jsx)(hX,{slug:e.id}),d?IT(e)?(0,L.jsx)(_X,{slug:e.id}):null:(0,L.jsx)(`div`,{className:`ml-1`,children:(0,L.jsx)(DI,{slug:e.id,onDone:i,doneBusy:s,onMutateStart:c,onApplied:l,onFailed:u})})]})}function _X({slug:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return(0,L.jsx)(Lj,{label:`Retry — resume this session where it left off`,children:(0,L.jsxs)(`button`,{onClick:()=>{r(!0),TH(t,e).finally(()=>r(!1))},disabled:n,"aria-label":`Retry exited session`,onMouseDown:e=>e.preventDefault(),className:`ml-1 flex items-center gap-1.5 rounded-md border border-accent/45 bg-accent/10 px-2.5 py-1 text-[12px] font-medium text-accent outline-none transition-colors hover:border-accent/70 hover:bg-accent/15 disabled:opacity-50`,children:[n?(0,L.jsx)(Mm,{size:12,className:`animate-spin`}):(0,L.jsx)(qm,{size:12}),`Retry`]})})}function vX({label:e,icon:t,size:n,busy:r,...i}){return(0,L.jsx)(Lj,{label:e,children:(0,L.jsx)(`button`,{...i,"aria-label":e,onMouseDown:e=>e.preventDefault(),className:eD,children:r?(0,L.jsx)(Mm,{size:n,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(t,{size:n,strokeWidth:2})})})}function yX(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 bX(e){if(e.runtime===`exited`&&e.crashed)return!1;if(e.runtime===`perm-prompt`||e.pendingAsk)return!0;if(e.runtime===`running`||e.runtime===`spawning`)return!1;let t=e=>e.state===`running`||e.state===`stale`;return!(e.subAgents?.some(e=>Xc(e)&&t(e))||e.bgShells?.some(t))}function xX(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=[SX(`agent`,`sub-agent`,e.subAgents,e.subAgentCount),SX(`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 SX(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 CX({open:e,onOpenChange:t,title:n,children:r,footer:i,className:a=`w-[640px] max-w-[92vw] max-h-[82vh]`}){return(0,L.jsx)(NI,{open:e,onOpenChange:t,children:(0,L.jsxs)(zI,{children:[(0,L.jsx)(VI,{className:`overlay-in fixed inset-0 z-[200] bg-black/55 backdrop-blur-[1px]`}),(0,L.jsxs)(GI,{"aria-modal":`true`,onEscapeKeyDown:bR,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)(XI,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:n}),(0,L.jsx)(eL,{type:`button`,"aria-label":`Close`,className:`rounded-md p-1 text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg`,children:(0,L.jsx)(ah,{size:15})})]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:r}),i&&(0,L.jsx)(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3`,children:i})]})]})})}function wX({thread:e,onSnoozed:t}){let[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(``),f=(0,I.useId)(),p=(0,I.useId)(),m=(0,I.useId)(),h=DT(e),g=Zt(tT).snoozePreset,_=Lw(g),v=zw(g),y=(0,I.useMemo)(()=>Hw(new Date(Date.now()+6e4)),[i]);async function b(n,i=null){r(!0);try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:n,prompt:n?i:null}),n?(Z(`${i?`Bump scheduled`:`Snoozed`} · ${Ww(n)}`),t?.()):Z(`Snooze cleared`),a(!1),d(``)}catch(e){let t=e instanceof Error?e.message:`Snooze failed`;Z(t.slice(0,100)),d(t)}finally{r(!1)}}function x(e){tT.snoozePreset=e,b(Bw(e))}function S(){s(Hw(new Date(h??Bw(g)))),l(e.snoozePrompt??``),d(``),a(!0)}function C(){let e=Uw(o);if(!e.ok){d(e.message);return}let t=c.trim();if(t.length>4e3){d(`Prompt is too long (${t.length}/${fl})`);return}b(e.until,t||null)}return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`inline-flex items-stretch rounded-md border border-border-strong bg-panel-2/60`,children:[(0,L.jsxs)(`button`,{type:`button`,disabled:n,"aria-label":h?`Wake thread now`:v,title:h?`Wake now · ${Ww(h)}`:v,onClick:()=>void b(h?null:Bw(g)),className:`flex items-center gap-1.5 rounded-l-md px-2.5 py-1 text-[12px] font-medium text-fg/75 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60 disabled:cursor-not-allowed disabled:opacity-45`,children:[n&&(0,L.jsx)(Mm,{size:12,className:`animate-spin`}),h?`Wake now`:v]}),(0,L.jsx)(`span`,{"aria-hidden":!0,className:`my-1 w-px bg-border`}),(0,L.jsxs)(SI,{children:[(0,L.jsx)(CI,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,disabled:n,"aria-label":`Snooze options`,title:`Selected snooze: ${_}`,className:`flex min-w-0 items-center justify-center gap-1 rounded-r-md px-2 text-fg/75 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60 disabled:cursor-not-allowed disabled:opacity-45`,children:(0,L.jsx)($p,{size:12})})}),(0,L.jsxs)(wI,{align:`end`,children:[Pw.map(e=>(0,L.jsx)(TI,{onSelect:()=>x(e.value),icon:(0,L.jsx)(dm,{size:12}),children:(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-4`,children:[(0,L.jsx)(`span`,{children:e.label}),(0,L.jsx)(`span`,{className:`text-[10px] text-muted/55`,children:e.detail})]})},e.value)),(0,L.jsx)(EI,{}),(0,L.jsx)(TI,{onSelect:S,children:`Custom time & prompt…`}),h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(EI,{}),(0,L.jsx)(TI,{onSelect:()=>void b(null),children:`Wake now`})]})]})]})]}),(0,L.jsx)(CX,{open:i,onOpenChange:e=>{n||a(e)},title:`Snooze thread`,className:`w-[360px] max-w-[92vw]`,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>a(!1),className:`rounded-md px-3 py-1.5 text-[12px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:opacity-45`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`submit`,form:m,disabled:n,className:`flex items-center gap-1.5 rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-opacity hover:opacity-90 disabled:opacity-45`,children:[n&&(0,L.jsx)(Mm,{size:12,className:`animate-spin`}),c.trim()?`Snooze & bump`:`Snooze`]})]}),children:(0,L.jsxs)(`form`,{id:m,className:`flex flex-col gap-2.5 p-4`,onSubmit:e=>{e.preventDefault(),C()},children:[(0,L.jsx)(`label`,{htmlFor:f,className:`text-[11px] font-medium text-muted`,children:`Wake at this local time`}),(0,L.jsx)(`input`,{id:f,type:`datetime-local`,required:!0,min:y,value:o,onChange:e=>{s(e.target.value),d(``)},className:`w-full rounded-md border border-border bg-bg px-2.5 py-2 text-[13px] text-fg outline-none focus:border-accent`}),(0,L.jsx)(`p`,{className:`text-[10.5px] text-muted/65`,children:`Stored as an exact instant; shown here in your browser’s local time zone.`}),(0,L.jsxs)(`label`,{htmlFor:p,className:`mt-1 text-[11px] font-medium text-muted`,children:[`Then send this prompt `,(0,L.jsx)(`span`,{className:`font-normal text-muted/55`,children:`(optional)`})]}),(0,L.jsx)(`textarea`,{id:p,autoFocus:!0,rows:3,maxLength:fl,placeholder:`e.g. Check whether CI went green and land it if so.`,value:c,onChange:e=>{l(e.target.value),d(``)},onKeyDown:e=>{FL({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 TX=1.25,EX=7.5-TX/2,DX=2*Math.PI*EX;function OX(e,t){return Math.max(0,Math.min(100,Math.floor(e/t*100)))}function kX({thread:e}){let t=e.context;if(!t||t.window<=0)return null;let n=OX(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)(Lj,{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:EX,fill:`none`,stroke:`currentColor`,strokeOpacity:.3,strokeWidth:TX}),(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:EX,fill:`none`,stroke:`currentColor`,strokeWidth:TX,strokeDasharray:`${DX*r} ${DX}`})]})})})}var AX={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 jX({checked:e,onChange:t,disabled:n,label:r,size:i=`sm`,testId:a}){let o=AX[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 MX({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 NX({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),PX)}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)(oV,{open:t!==`closed`,onOpenChange:e=>{e||(clearTimeout(i.current),n(`closed`))},children:[(0,L.jsx)(cV,{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 ${BL}`,children:(0,L.jsx)(MX,{size:12,className:o?`text-amber-400/90`:`text-muted/60 hover:text-muted`})})}),t===`preview`?(0,L.jsx)(lV,{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)(FX,{armed:a})}):(0,L.jsx)(lV,{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)(GX,{thread:e,armed:a,close:()=>n(`closed`)})})]})}var PX=260;function FX({armed:e}){let t=e?.prompt?.trim(),n=e?WX({stopHook:e.stopHook===!0,heartbeat:e.heartbeat===!0,postCompaction:e.postCompaction===!0,seconds:e.intervalSeconds??RX}):[];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 IX=1,LX=1440,RX=600;function zX(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(LX,Math.max(IX,n))*60:t}var BX=null;function VX(e){return{prompt:e.text.trim(),stopHook:e.stopHook,heartbeat:e.heartbeat,postCompaction:e.postCompaction,seconds:e.seconds}}function HX(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 UX(e,t){return!e.archived&&!t}function WX(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 GX({thread:e,armed:t,close:n}){let r=UX(e,t)?_l:``,i=BX?.slug===e.id?BX.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??RX),h=s||l||d,[g,_]=(0,I.useState)(String(Math.round((i?.seconds??t?.intervalSeconds??RX)/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??RX}),b=e=>({text:a,stopHook:s,heartbeat:l,postCompaction:d,seconds:zX(g,p),...e}),x=(0,I.useRef)(b());x.current=b(),(0,I.useEffect)(()=>()=>{let n=x.current;if(HX(n,y.current)){BX?.slug===e.id&&(BX=null);return}if(n.text.trim()===``&&!t){BX={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?BX?.slug===e.id&&(BX=null):BX={slug:e.id,draft:t},n});return S.current=n,n}async function w(t){let n=t.text.trim()||null;if(HX(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={...VX(t),prompt:n??``};let r=WX(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(HX(b(),y.current)||a.trim()===``&&!t){n();return}C(b()).then(e=>{e&&n()})}function E(){let e=zX(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 ${CE(O.at)}`:`Last sent ${O.how} ${CE(O.at)}`;return(0,L.jsxs)(`section`,{"data-recurring-panel":!0,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Goal`}),k&&(0,L.jsx)(`span`,{className:`ml-auto truncate text-muted/55`,children:k})]}),(0,L.jsx)(`textarea`,{ref:v,"data-recurring-text":!0,value:a,maxLength:ml,onChange:e=>o(e.target.value),onKeyDown:e=>{FL({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)(jX,{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)(jX,{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:IX,max:LX,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)(jX,{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 KX({thread:e,sticky:t=!1,safeArea:n=!1,onArchived:r,onDismissCancel:i,onSnoozed:a}){let o=yX(e);return o.footer?(0,L.jsxs)(`footer`,{"aria-label":`Thread lifecycle actions`,"data-thread-lifecycle-footer":!0,className:`${t?`z-20`:Jq} flex min-h-10 shrink-0 flex-wrap items-center justify-end ${RL} 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 ${RL}`,children:[(0,L.jsx)(kX,{thread:e}),(0,L.jsx)(JX,{thread:e}),(0,L.jsx)(NX,{thread:e})]}),o.done?(0,L.jsx)(qX,{}):(0,L.jsxs)(L.Fragment,{children:[o.snooze&&(0,L.jsx)(wX,{thread:e,onSnoozed:a}),(0,L.jsx)(YX,{thread:e,onArchived:r,onDismissCancel:i})]})]}):null}function qX(){let e=`Marked done — send a message to reopen it`;return(0,L.jsx)(Lj,{label:e,side:`top`,children:(0,L.jsxs)(`span`,{"data-thread-done":!0,"aria-label":e,className:`flex items-center gap-1 rounded-md border border-transparent px-2.5 py-1 font-medium text-muted`,children:[(0,L.jsx)(Qp,{size:12}),`Done`]})})}function JX({thread:e}){let t=DT(e);if(!t)return null;let n=e.snoozePrompt?.trim(),r=n?`Bumps ${Ww(t)}\n${n}`:`Snoozed until ${Ww(t)}`;return(0,L.jsx)(Lj,{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 ${zL}`,children:(0,L.jsx)(Tm,{size:12})})})}function YX({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||bX(e))&&WH(e.id),Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:r}).then(r=>{if(r.needsConfirmation){GH(e.id),i&&n?.(),u(r.hold),c(!0),o(!1);return}c(!1),Z(`Done`),i||t?.()}).catch(t=>{GH(e.id),i&&n?.(),Z(`Couldn’t finish: ${t.message.slice(0,80)}`),o(!1)})},f=!!t&&!!n&&bX(e);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>d(!1,f),disabled:a,"aria-label":`Mark as done`,title:`Mark as done`,onMouseDown:e=>e.preventDefault(),className:`flex items-center gap-1 font-medium outline-none transition-colors focus-visible:ring-1 focus-visible:ring-fg/60 disabled:opacity-45 ${r}`,children:[(0,L.jsx)(Qp,{size:12,className:i}),`Mark as done`]}),(0,L.jsx)(CX,{open:s,onOpenChange:e=>{a||c(e)},title:l?.cutOff?`Mark an unfinished thread done?`:`End this session?`,className:`w-[390px] max-w-[92vw]`,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>c(!1),className:`rounded-md px-3 py-1.5 text-[12px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:opacity-45`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>d(!0,!1),className:`flex items-center gap-1.5 rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-opacity hover:opacity-90 disabled:opacity-45`,children:[a&&(0,L.jsx)(Mm,{size:12,className:`animate-spin`}),l?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,L.jsx)(XX,{hold:l})})]})}function XX({hold:e}){let t=xX(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:TE,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 ZX({thread:e,hidden:t=!1}){let n=it({mutationFn:()=>Y.aiRenameThread({slug:e.id}),onSuccess:({title:e})=>Z(`Renamed to “${e}”`),onError:e=>Z(e instanceof Error?e.message:`Could not rename with Claude`,{duration:7e3})}),r=HY(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)(Lj,{label:i,children:(0,L.jsx)(`button`,{type:`button`,"data-ai-rename":!0,"aria-label":n.isPending?`Renaming with Claude`:r.label,"aria-busy":n.isPending,"aria-disabled":!r.enabled,onMouseDown:e=>e.preventDefault(),onClick:()=>{if(!n.isPending){if(!r.enabled){Z(r.label);return}n.reset(),n.mutate()}},className:`title-refresh-offset -mx-[7px] -my-3 flex h-6 w-6 shrink-0 items-center justify-center rounded-md outline-none transition-[color,background-color,opacity] focus-visible:opacity-100 group-hover/thread-title:opacity-100 ${a?`opacity-100`:`opacity-0`} ${n.error?`text-red-400 hover:bg-red-500/10`:r.enabled?`text-muted hover:bg-panel-2 hover:text-fg`:`cursor-not-allowed text-muted/50 hover:bg-panel-2`}`,children:n.isPending?(0,L.jsx)(Mm,{size:12,className:`animate-spin`}):(0,L.jsx)(Jm,{size:12})})})}var QX=new Set([`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]);function $X(e,t){let n=e.lastIndexOf(t);if(n<=0)return{model:e};let r=e.slice(n+1);return QX.has(r)?{model:e.slice(0,n),effort:r}:{model:e}}function eZ(e){let t=e?.trim();if(!t)return`Profile unknown`;if(t.startsWith(`frizz:`)){let{model:e,effort:n}=$X(t.slice(6).replace(/^frizz-/,``),`-`);return n?`${e} › ${n}`:e}let n=t.split(/\s+/),{model:r,effort:i}=$X(n.at(-1)??t,`/`);if(!i)return t;let a=n.slice(0,-1).join(` `);return`${a?`${a} · `:``}${r} › ${i}`}function tZ(e){return e?.trim()?eZ(e):void 0}function nZ(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 rZ={completed:`finished`,killed:`stopped`,failed:`failed`};function iZ(e){let t=rZ[e.agentStatus??`completed`],n=e.agentElapsedMs===void 0?void 0:bE(e.agentElapsedMs);return{outcome:t,tail:`${t}${n?` · ${n}`:``}`}}var aZ=e=>e===void 0?void 0:hE(e),oZ=e=>{if(e!==void 0)return bE(e)||void 0};function sZ(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=aZ(n);return{label:t===`completed`?void 0:rZ[t],duration:oZ(n),tone:r?`failed`:`muted`,title:`${e?`Stopped`:r?`Failed`:`Ran for`}${e||r?` after`:``} ${i??`an unknown time`}`}}if(r){let e=aZ(i);return{label:void 0,duration:oZ(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=aZ(o);return{label:c?rZ.killed:s?rZ.failed:void 0,duration:oZ(o),tone:s?`failed`:`muted`,title:`${c?`Stopped after`:s?`Failed after`:`Ran for`} ${l??`an unknown time`}`}}function cZ({at:e,host:t}){let n=JT(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 lZ({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)(cZ,{at:e,host:t})]})}var uZ=`text-[14px] leading-5 text-muted`,dZ=`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 fZ(e){return`${dZ} ${e?`-mx-[0.208em] rotate-90`:`-mx-[0.333em]`}`}var $=I.createElement;function pZ({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,$(mZ,{label:`Redacted command preview`,text:e.command.preview}),e.command.actions?$(hZ,{actions:e.command.actions}):null,e.capabilities?$(_Z,{capabilities:e.capabilities}):null):e.kind===`file-approval`?$(I.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},xZ(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?$(mZ,{label:`Plain-text diff preview`,text:e.diffPreview}):null,e.changes?$(gZ,{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?$(_Z,{capabilities:e.capabilities}):null)}function mZ({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 hZ({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`},bZ(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,$(mZ,{label:`${bZ(e.kind)} command detail`,text:e.commandPreview})))))}function gZ({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`},xZ(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?$(mZ,{label:`${xZ(e.operation)} plain-text diff`,text:e.diffPreview}):null))))}function _Z({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`},$(vZ,{capability:e})))))}function vZ({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?$(yZ,{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),$(yZ,{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`),$(yZ,{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`),$(yZ,{label:`Hosts`,values:e.hosts}))}function yZ({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 bZ(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 xZ(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 SZ(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 CZ={semantic:`approve`,label:`Approve once`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`},wZ={semantic:`approve`,label:`Approve for session`,order:20,tone:`primary`,durable:!0,scope:`Persists for later matching requests in this thread session.`},TZ={semantic:`approve`,label:`Grant for turn`,order:10,tone:`primary`,durable:!1,scope:`Applies to this turn only.`},EZ={semantic:`approve`,label:`Grant for session`,order:20,tone:`primary`,durable:!0,scope:`Persists until this thread session ends.`},DZ={semantic:`deny`,label:`Deny`,order:70,tone:`danger`,durable:!1,scope:`Rejects this request.`},OZ={semantic:`decline`,label:`Decline`,order:70,tone:`danger`,durable:!1,scope:`Declines this request.`},kZ={semantic:`cancel`,label:`Cancel request`,order:80,tone:`neutral`,durable:!1,scope:`Cancels this pending request.`};function AZ(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`?CZ:n===`acceptForSession`&&r===`approve`?wZ:(n===`decline`||n===`deny`)&&r===`deny`?DZ:n===`cancel`&&r===`cancel`?kZ:void 0;if(e.kind===`permission-approval`)return n===`grant-turn`&&r===`approve`?TZ:n===`grant-session`&&r===`approve`?EZ:(n===`deny`||n===`decline`)&&r===`deny`?DZ:n===`cancel`&&r===`cancel`?kZ: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`?OZ:n===`cancel`&&r===`cancel`?kZ: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 OZ;if(n===`cancel`&&r===`cancel`)return kZ}function jZ(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=AZ(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 MZ(e){switch(e){case`claude`:return`Claude`;case`codex`:return`Codex`;case`frizz`:return`Frizz`}}function NZ(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 PZ(e,t){let n=e.options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t));return n<0?``:String(n)}function FZ(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?``:PZ(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 IZ(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 LZ(e,t){if(e.some(e=>e.secret))return{errors:{},formError:`Secret responses cannot be sent through this Frizz connection.`};let n=Object.create(null),r={};for(let i of e){let e=t[i.id],a;if(i.input===`text`||i.input===`multiline`){let t=typeof e==`string`?e:``;if(!i.required&&t===``)continue;i.required&&t===``?r[i.id]=`This field is required.`:a=t}else if(i.input===`number`||i.input===`integer`){let t=typeof e==`string`?e.trim():``;if(!i.required&&t===``)continue;if(t===``)r[i.id]=`This field is required.`;else{let e=Number(t);Number.isFinite(e)?a=e:r[i.id]=`Enter a valid number.`}}else if(i.input===`boolean`)a=e===!0;else if(i.input===`select`){let t=typeof e==`string`&&/^\d+$/.test(e)?Number(e):-1;if(t<0||t>=i.options.length)if(i.required)r[i.id]=`Choose an option.`;else continue;else a=i.options[t].value}else if(i.input===`multi-select`){let t=(Array.isArray(e)?e:[]).flatMap(e=>/^\d+$/.test(e)?[Number(e)]:[]);if(t.some(e=>e<0||e>=i.options.length))r[i.id]=`Choose only advertised options.`;else if(i.required&&t.length===0)r[i.id]=`Choose at least one option.`;else if(t.length>0)a=t.map(e=>i.options[e].value);else continue}if(a!==void 0&&!r[i.id]){let e=ac(i,a);e?r[i.id]=`Value ${e}.`:n[i.id]=a}}if(Object.keys(r).length>0)return{errors:r};let i=yc.safeParse(n);return i.success?{errors:r,values:i.data}:{errors:r,formError:`The response is too large or contains invalid values.`}}function RZ(e,t){return JSON.stringify([e,t??null])}function zZ(e,t){try{let n=new URL(e,t);return n.protocol===`http:`||n.protocol===`https:`?n.toString():null}catch{return null}}function BZ(e,t){let n=e.getAttribute(`href`);if(!n)return!1;let r=zZ(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 VZ(e=()=>location.href){return t=>{if(t.defaultPrevented||t.button!==0)return;let n=UZ(t);n&&BZ(n,e())}}function HZ(){let e=VZ();return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)}function UZ(e){let t=typeof e.composedPath==`function`?e.composedPath():[];for(let e of t)if(WZ(e))return e;let n=e.target?.closest?.(`a[href]`);return WZ(n)?n:null}function WZ(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 GZ(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 KZ(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)=>`${GZ(t)} ${e.label}`),recommendedIdx:null},...e?{optionFieldId:e.id}:{},optionValues:r.map(e=>e.value),...t?{notesFieldId:t.id}:{}}}function qZ(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=KZ(r,a);if(!e)return null;n.push(e)}else if(r.input===`text`||r.input===`multiline`){let e=KZ(void 0,r);if(!e)return null;n.push(e)}else return null}return n.length>0?n:null}function JZ(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)=>`${GZ(t)} ${e.label}${e.description?` — ${e.description}`:``}`),recommendedIdx:null},chosenIdxs:n,text:r}}function YZ(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 XZ(e){let t=e instanceof Error?e.message:`The request could not be updated.`;return t.length>240?`${t.slice(0,239)}…`:t}function ZZ(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`frizz-response-${Date.now()}-${Math.random().toString(36).slice(2)}`}function QZ({thread:e,className:t=``,autoFocusFirst:n=!1}){let r=PC(e),i=IC(e),a=(0,I.useMemo)(()=>[...i.data?.interactions??[]].sort((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.id.localeCompare(t.id)),[i.data?.interactions]);return r?i.isError&&a.length===0?(0,L.jsxs)(`div`,{"data-interactions-error":!0,role:`alert`,className:`${Kq} 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:XZ(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)(eQ,{record:e,autoFocus:n&&t===0},e.id))}):null}function $Z({record:e,questions:t,autoFocus:n}){let r=Ve(),i=(0,I.useRef)(null),a=(0,I.useRef)(new Map),o=sz(),s=SZ(e.delivery?.effect),c=(0,I.useMemo)(()=>jZ(e).find(e=>e.semantic===`answer`),[e]),l=uz(t.flatMap(t=>t.notesFieldId?[oz.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(oz.interaction(o,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId))??``:``})),p=YZ(t,f),[m,h]=(0,I.useState)(),[g,_]=(0,I.useState)(!1);(0,I.useEffect)(()=>{if(!n)return;let e=document.activeElement;e&&e!==document.body||requestAnimationFrame(()=>i.current?.focus())},[n,e.id]);let v=it({mutationFn:async t=>Y.interactionResolve({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id,sessionEpoch:e.owner.sessionEpoch,capabilityRevision:e.owner.capabilityRevision,expectedRecordRevision:e.recordRevision,responseId:t.responseId,decisionId:t.decisionId,values:t.values}),onSuccess:t=>{_(!0),Pb(r,t.interaction),r.invalidateQueries({queryKey:Mb(e.owner.threadSlug,e.owner.sessionId)}),r.invalidateQueries({queryKey:Nb(e.owner.threadSlug,e.owner.sessionId,e.id)})},onError:t=>{Fb(r,e),h(XZ(t))}}),y=()=>{if(!c||!p||v.isPending||g||!s.actionsEnabled)return;h(void 0);let e=RZ(c.id,p),t=a.current.get(e)??ZZ();a.current.set(e,t),v.mutate({decisionId:c.id,values:p,responseId:t})},b=(t,n)=>{t.notesFieldId&&iz.set(oz.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)(bY,{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 eQ({record:e,autoFocus:t=!1}){let n=(0,I.useMemo)(()=>qZ(e),[e]);return n?(0,L.jsx)($Z,{record:e,questions:n,autoFocus:t}):(0,L.jsx)(tQ,{record:e,autoFocus:t})}function tQ({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=sz(),l=o.filter(e=>!e.secret&&(e.input===`text`||e.input===`multiline`)).map(t=>oz.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.id)),u=uz(l),[d,f]=(0,I.useState)(()=>FZ(o)),p=(0,I.useMemo)(()=>{let t={...d};return o.forEach(n=>{if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=oz.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=SZ(e.delivery?.effect),D=(0,I.useMemo)(()=>jZ(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`&&iz.set(oz.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id),r)}f(t)},[o,c,e.id,e.owner]);(0,I.useEffect)(()=>{if(!t)return;let e=document.activeElement;e&&e!==document.body||requestAnimationFrame(()=>i.current?.focus())},[t,e.id]),(0,I.useEffect)(()=>{E.actionsEnabled||(C(void 0),T(!1))},[E.actionsEnabled]);let A=it({mutationFn:async({decision:t,values:n,responseId:r})=>{if(t.semantic===`cancel`&&e.provider.kind===`frizz`){let t=await Y.interactionCancel({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id,sessionEpoch:e.owner.sessionEpoch,capabilityRevision:e.owner.capabilityRevision,expectedRecordRevision:e.recordRevision});return{effect:t.effect,interaction:t.interaction,waitingForProvider:!1}}let i=await Y.interactionResolve({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id,sessionEpoch:e.owner.sessionEpoch,capabilityRevision:e.owner.capabilityRevision,expectedRecordRevision:e.recordRevision,responseId:r,decisionId:t.id,...n===void 0?{}:{values:n}});return{effect:i.effect,interaction:i.interaction,waitingForProvider:i.interaction.delivery?.effect===`sending`||i.effect===`queued`||i.effect===`already-queued`}},onSuccess:(t,r)=>{t.waitingForProvider||a.current.delete(RZ(r.decision.id,r.values)),_(void 0),C(void 0),T(!1),x(!0),l.forEach(e=>iz.clear(e)),y(t.waitingForProvider?`Response sent. Waiting for the provider to acknowledge it…`:`Request completed.`),Pb(n,t.interaction),n.setQueryData(Nb(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t.interaction}),n.invalidateQueries({queryKey:Mb(e.owner.threadSlug,e.owner.sessionId),exact:!0}),t.waitingForProvider&&window.setTimeout(()=>{n.invalidateQueries({queryKey:Mb(e.owner.threadSlug,e.owner.sessionId),exact:!0})},1e3)},onError:t=>{y(void 0),_(XZ(t)),Fb(n,e),Y.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{Pb(n,t),n.setQueryData(Nb(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t}),t.delivery?.effect===`sending`?(_(void 0),y(void 0),x(!0)):t.delivery?.effect===`reconnect-required`?(_(void 0),y(void 0)):(t.lifecycle!==`pending`||t.recordRevision!==e.recordRevision)&&(_(void 0),y(t.lifecycle===`expired`?`This request expired.`:`This request changed in another client.`),n.invalidateQueries({queryKey:Mb(e.owner.threadSlug,e.owner.sessionId),exact:!0})),n.invalidateQueries({queryKey:Mb(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}});function j(e){if(!e.requiresValues){h({});return}let t=LZ(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=RZ(e.id,n),i=a.current.get(r)??ZZ();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 ${Kq} border border-accent/45 bg-accent/[0.065] shadow-sm shadow-black/15 outline-none focus-visible:ring-2 focus-visible:ring-accent/60`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 border-b border-accent/20 px-4 py-3`,children:[(0,L.jsx)(Xm,{"aria-hidden":`true`,size:16,className:`shrink-0 text-accent`}),(0,L.jsx)(`h3`,{id:r,className:`min-w-0 flex-1 break-words text-[14px] font-semibold leading-snug text-fg`,children:e.payload.title})]}),(0,L.jsx)(`form`,{onSubmit:P,onKeyDown:e=>{e.target instanceof HTMLButtonElement||FL({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)(rQ,{record:e,instanceId:r,draft:p,setDraft:k,errors:m,autoFocus:t}),s&&(0,L.jsxs)(`div`,{"data-secret-fallback":!0,className:`mt-3 rounded-md border border-amber-500/35 bg-amber-500/[0.07] p-3 text-[12px] leading-snug text-amber-100/90`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(km,{"aria-hidden":`true`,size:14,className:`mt-0.5 shrink-0`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`font-medium`,children:`Secret input is unavailable in this page.`}),(0,L.jsx)(`div`,{className:`mt-1 text-amber-100/70`,children:`Frizz will not persist or send secret values through the current RPC.`})]})]}),(0,L.jsx)(`div`,{className:`mt-2 font-medium`,children:`Use the provider's trusted secret-input flow. The thread terminal cannot answer this typed request.`})]}),O>0&&(0,L.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-md border border-amber-500/25 bg-amber-500/[0.05] px-3 py-2 text-[11px] leading-snug text-amber-100/75`,children:[(0,L.jsx)(rh,{"aria-hidden":`true`,size:13,className:`mt-0.5 shrink-0`}),(0,L.jsxs)(`span`,{children:[O===1?`One advertised choice`:`${O} advertised choices`,` cannot be safely labeled or delivered in Frizz and is not shown.`]})]}),S&&(0,L.jsxs)(`div`,{"data-durable-confirmation":!0,role:`group`,"aria-label":`Confirm ${S.label}`,className:`mt-3 rounded-md border border-amber-400/45 bg-amber-500/[0.08] p-3`,children:[(0,L.jsx)(`div`,{className:`text-[12px] font-semibold text-amber-100`,children:`This approval persists beyond the current request.`}),(0,L.jsx)(`div`,{className:`mt-1 text-[11px] leading-snug text-amber-100/75`,children:S.scope}),(0,L.jsxs)(`label`,{className:`mt-2.5 flex cursor-pointer items-start gap-2 text-[11px] leading-snug text-fg/85`,children:[(0,L.jsx)(`input`,{type:`checkbox`,autoFocus:!0,checked:w,onChange:e=>T(e.target.checked),className:`mt-0.5 accent-[var(--color-accent)]`}),(0,L.jsx)(`span`,{children:`I understand this may authorize later matching actions in this session.`})]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-start gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>{C(void 0),T(!1)},className:`rounded-md border border-border px-2.5 py-1.5 text-[11px] text-muted hover:bg-panel-2 hover:text-fg`,children:`Back`}),(0,L.jsxs)(`button`,{type:`button`,disabled:!w||A.isPending,onClick:()=>M(S,!0),className:`rounded-md border border-amber-400/50 bg-amber-500/15 px-2.5 py-1.5 text-[11px] font-semibold text-amber-50 hover:bg-amber-500/25 disabled:opacity-35`,children:[`Confirm `,S.label.toLowerCase()]})]})]}),g&&(0,L.jsx)(`div`,{role:`alert`,className:`mt-3 break-words text-[11px] leading-snug text-red-300`,children:g}),(E.status??v)&&(0,L.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`mt-3 text-[11px] leading-snug text-muted`,children:E.status??v}),E.actionsEnabled&&!S&&!b&&D.length>0&&(0,L.jsxs)(`div`,{className:`mt-4 flex flex-wrap justify-start gap-2`,children:[D.map(e=>(0,L.jsxs)(`button`,{type:e===N?`submit`:`button`,"data-interaction-decision":e.id,disabled:A.isPending,"aria-describedby":e.durable?`${r}-scope-${e.id}`:void 0,onClick:e===N?void 0:()=>M(e),className:nQ(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}`))]}),!iQ.has(e.payload.kind)&&(0,L.jsx)(sQ,{record:e})]})})]})}function nQ(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 rQ({record:e,instanceId:t,draft:n,setDraft:r,errors:i,autoFocus:a}){let o=e.payload,s=(e,t)=>r(IZ(n,e,t)),c;return c=o.kind===`command-approval`||o.kind===`file-approval`||o.kind===`permission-approval`?(0,L.jsx)(pZ,{payload:o}):o.kind===`mcp-elicitation-url`?(0,L.jsx)(oQ,{url:o.url}):(0,L.jsx)(cQ,{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)(aQ,{text:o.message}),(0,L.jsx)(`div`,{className:`message`in o&&o.message?`mt-3`:``,children:c})]})}var iQ=new Set([`command-approval`,`file-approval`,`permission-approval`]);function aQ({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 oQ({url:e}){let t=zZ(e,location.href);return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[11px] font-medium text-fg`,children:`Open this page to continue`}),(0,L.jsx)(`code`,{className:`mt-1.5 block max-h-24 overflow-auto break-all rounded-md border border-border bg-bg/40 px-2.5 py-2 font-mono-keep text-[10.5px] text-fg/80`,children:e}),t?(0,L.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:`mt-2 inline-flex items-center gap-1.5 rounded-md border border-border bg-panel px-2.5 py-1.5 text-[11px] font-medium text-fg hover:bg-panel-2`,children:[(0,L.jsx)(mm,{"aria-hidden":`true`,size:12}),`Open page`]}):(0,L.jsx)(`div`,{role:`alert`,className:`mt-1.5 break-words text-[11px] text-red-300`,children:`This request did not provide a safe http(s) URL.`})]})}function sQ({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:MZ(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:NZ(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 cQ({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)(lQ,{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 lQ({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 uQ(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 dQ(e,t){let n=t.description?.trim(),r=n&&!n.includes(`
306
+ `)}`}function yY(e,t,n,r={}){let i=TH(e),[a,o]=(0,I.useState)({}),s=(0,I.useMemo)(()=>gY(t),[t]),c=(0,I.useMemo)(()=>{for(let e=t.length-1;e>=0;e--)if(!(t[e].kind===`event`||t[e].kind===`reasoning`)&&t[e].role===`assistant`&&t[e].text.trim())return t[e]},[t]),l=(0,I.useMemo)(()=>_Y(t)!==-1,[t]),u=cz(),d=lz(e),f=(0,I.useCallback)((t,n)=>sz.answer(u,e,d,t,n),[u,e,d]),p=(0,I.useMemo)(()=>s.flatMap(e=>e.blocks.map((t,n)=>f(e.identity,n))),[s,f]),m=dz(p),h=(0,I.useRef)(n);h.current=n;let g=(0,I.useRef)(r.onSendFailed);g.current=r.onSendFailed;let _=(0,I.useCallback)((e,t)=>({...a[`${e}::${t}`]??{chosen:null,text:``},text:m.get(f(e,t))??``}),[a,m,f]),v=(0,I.useMemo)(()=>{let e=new Map;for(let t of s)e.set(t.identity,t);return e},[s]),y=(0,I.useCallback)((e,t,n)=>{let r=v.get(e)?.blocks[t],i=`${e}::${t}`;o(e=>{let t=e[i]??{chosen:null,text:``};if(r?.kind===`multi`){let r=new Set(t.chosenSet??[]);return r.has(n)?r.delete(n):r.add(n),{...e,[i]:{chosen:null,text:t.text,chosenSet:[...r].sort((e,t)=>e-t)}}}return{...e,[i]:{chosen:t.chosen===n?null:n,text:t.text}}})},[v]),b=(0,I.useCallback)((e,t,n)=>{let r=v.get(e)?.blocks[t];az.set(f(e,t),n),o(i=>{let a=`${e}::${t}`,o=i[a]??{chosen:null,text:``};return r?.kind===`multi`?{...i,[a]:{chosen:null,text:n,chosenSet:o.chosenSet??[]}}:{...i,[a]:{chosen:null,text:n}}})},[v,f]),x=s.some(e=>e.blocks.some((t,n)=>Uq(t,_(e.identity,n))!==``)),S=r.scrollToBottom!==!1,C=(0,I.useCallback)((e,t={})=>{i.submit(e,{...t,scrollToBottom:S,onRollback:()=>{t.onRollback?.(),g.current?.()}})&&h.current?.()},[i,S]),w=(0,I.useCallback)(e=>{let t=typeof e==`string`?e:void 0,n=t?s.filter(e=>e.identity===t):s,r=t?n.flatMap(e=>e.blocks.map((t,n)=>f(e.identity,n))):p,i=n.flatMap(e=>e.blocks.map((t,n)=>`${e.identity}::${n}`)),c=(e,t)=>Uq(e.blocks[t],_(e.identity,t)),l=n.flatMap(e=>e.blocks.map((t,n)=>({ask:e,bi:n,question:xY(t),answer:c(e,n)})).filter(e=>e.answer!==``));if(l.length===0)return;let u=n.find(e=>e.isLive),d=vY({answered:l.map(e=>({isLive:e.ask.isLive,question:e.question,answer:e.answer})),live:u&&{numbered:u.blocks.map((e,t)=>({n:t+1,a:c(u,t)})).filter(({a:e})=>e!==``)}}),m=a,h=r.map(e=>[e,az.get(e)]);C(d,{onOptimistic:()=>{r.forEach(e=>az.clear(e)),o(e=>{let t={...e};for(let e of i)delete t[e];return t})},onRollback:()=>{o(e=>{let t={...e};for(let e of i)m[e]?t[e]=m[e]:delete t[e];return t}),h.forEach(([e,t])=>{t&&!az.get(e)&&az.set(e,t)})}})},[a,s,_,C,p,f]),T=(0,I.useCallback)(e=>{let t=v.get(fY(e));if(t)return{answerFor:e=>_(t.identity,e),onChip:(e,n)=>y(t.identity,e,n),onText:(e,n)=>b(t.identity,e,n),onSubmit:()=>w(t.identity),anyAnswered:t.blocks.some((e,n)=>Uq(e,_(t.identity,n))!==``),sending:i.pending}},[v,_,y,b,w,i.pending]);return{liveMsg:c,answering:(0,I.useMemo)(()=>c?T(c):void 0,[c,T]),answeringForMessage:T,answerable:l,anyAnswered:x,sending:i.pending,sendAnswers:w,sendMessage:C}}function bY(e){let t=e.split(`
307
+ `).map(e=>e.trim()).find(e=>e.length>0)??``;return t.length>120?`${t.slice(0,117)}…`:t}function xY(e){return bY(e.contextMd)||bY(e.options.join(` / `))||`earlier question`}function SY(e){let t=2166136261;for(let n=0;n<e.length;n++)t=Math.imul(t^e.charCodeAt(n),16777619);return(t>>>0).toString(36)}function CY({raw:e,question:t,questionKind:n,danger:r,interactive:i,wrap:a,aside:o,label:s,settled:c}){let l=(0,I.useMemo)(()=>t??zq(e??``,n??`question`,r),[t,e,n,r]),u=gK(l.contextMd),d=gK(l.trailingMd??``),f=l.recommendedIdx,p=vK(l.recommendation??``),m=l.kind===`multi`,h=l.danger,g=i?.answer.chosen??null,_=i?.answer.chosenSet??[],v=i?.answer.text??``,y=(0,I.useRef)(null),b=(0,I.useRef)(null);return(0,I.useLayoutEffect)(()=>{let e=y.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`)},[v]),(0,L.jsxs)(nJ,{tone:h?`risk`:`neutral`,icon:h?rh:void 0,label:s??(m?`Select multiple`:`Question`),aside:o,children:[u&&(0,L.jsx)(`div`,{className:`text-fg`,children:(0,L.jsx)(hq,{className:`md-body${a?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:u})}),(l.options.length>0||i)&&(0,L.jsxs)(`div`,{ref:b,tabIndex:-1,onKeyDown:e=>{!i||e.target!==e.currentTarget||IL({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),e.stopPropagation(),i.onSubmit())},className:`mt-2 grid grid-cols-1 gap-1.5 outline-none`,children:[l.options.map((e,t)=>(0,L.jsxs)(I.Fragment,{children:[l.optionHeadings?.[t]&&(0,L.jsx)(wY,{md:l.optionHeadings[t],wrap:a}),(0,L.jsx)(EY,{label:e,bodyMd:l.optionBodies?.[t],wrap:a,multi:m,recommended:f===t,recTitle:f===t?l.recommendedNote:void 0,selected:m?_.includes(t):g===t,settledPick:c?.chosenIdxs.includes(t)??!1,disabled:!i,onClick:()=>{i?.onChip(t,e),!(m&&y.current&&document.activeElement===y.current)&&b.current?.focus()}})]},t)),i&&(0,L.jsx)(`textarea`,{ref:y,rows:1,"data-surface":`questionAnswer`,value:v,onChange:e=>i.onText(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){e.preventDefault(),e.currentTarget.blur();return}IL({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),i.onSubmit())},onFocus:()=>{!m&&g!==null&&i.onText(v)},placeholder:m?`Add a note…`:l.options.length?`${TY(l.options)} Something else…`:`Type your answer…`,className:`col-span-full w-full resize-none overflow-hidden rounded-md border px-3 py-1.5 text-[12px] leading-snug text-fg/90 outline-none placeholder:text-muted/80 transition-colors ${v.trim()&&(m||g===null)?`border-accent bg-accent/10`:`border-border bg-transparent hover:bg-panel-2 focus:border-accent`}`})]}),c?.text&&(0,L.jsx)(`div`,{className:`mt-2 whitespace-pre-wrap [overflow-wrap:anywhere] rounded-md border border-border-strong border-l-2 border-l-accent/40 bg-bg/50 py-1.5 pl-[11px] pr-3 text-[12px] leading-snug text-fg`,children:c.text}),c&&c.chosenIdxs.length===0&&!c.text&&(0,L.jsx)(`div`,{className:`mt-2 text-[11px] text-muted/70`,children:`Not answered`}),l.trailingMd&&(0,L.jsx)(hq,{className:`mt-2 md-body text-[12px] text-muted/70${a?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:d}),l.recommendation&&f===null&&(0,L.jsx)(hq,{className:`md-inline mt-1.5 text-[11px] text-muted/70`,html:p})]})}function wY({md:e,wrap:t}){let n=vK(e.split(`
308
+ `).join(` `));return(0,L.jsx)(`div`,{className:`mt-1 text-fg`,children:(0,L.jsx)(hq,{className:`md-body${t?` ${Jq}`:``}`,html:n})})}function TY(e){let t=e[e.length-1]?.match(/^\s*([A-Za-z]|\d+)([.)])\s/);if(!t)return`${String.fromCharCode(65+e.length)}.`;let[,n,r]=t;return/\d/.test(n)?`${Number(n)+1}${r}`:`${String.fromCharCode(n.toUpperCase().charCodeAt(0)+1)}${r}`}function EY({label:e,bodyMd:t,wrap:n,selected:r,settledPick:i,disabled:a,multi:o,recommended:s,recTitle:c,onClick:l}){let u=vK(e),d=gK(t??``),f=(0,I.useId)();return(0,L.jsxs)(`div`,{"data-question-option":!0,title:c,onClick:e=>{a||e.target.closest(`a, button, .local-file-action, .local-file-code`)||window.getSelection()?.toString()||l()},className:`relative flex items-start gap-2 rounded-md border px-3 py-1.5 text-[12px] leading-snug transition-colors ${r?`border-accent bg-accent/10 text-fg`:i?`border-border-strong border-l-2 border-l-accent/40 bg-bg/50 pl-[11px] text-fg`:a?`border-border text-muted/80`:`border-border text-fg/90 hover:bg-elevated hover:border-border-strong`}`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:a,"aria-labelledby":f,onClick:l,onMouseDown:e=>e.preventDefault(),className:`absolute inset-0 rounded-md outline-none`}),o&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`mt-px flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded-[3px] border ${r?`border-accent bg-accent text-bg`:i?`border-border-strong text-fg`:`border-border-strong`}`,children:(r||i)&&(0,L.jsx)(Qp,{size:10,strokeWidth:3})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{id:f,children:[s&&(0,L.jsx)(`span`,{className:`pointer-events-none float-right ml-2 mt-px -translate-y-[2px] rounded-full border border-border-strong px-1.5 py-px text-[9.5px] uppercase tracking-wide text-muted`,children:`Recommended`}),(0,L.jsx)(hq,{as:`span`,className:`md-inline`,html:u})]}),t!==void 0&&(0,L.jsx)(hq,{className:`md-body mt-1.5 text-[11.5px] opacity-90${n?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:d})]})]})}function DY({blocks:e,answering:t,onClose:n}){let[r,i]=(0,I.useState)(0),[a,o]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let e=requestAnimationFrame(()=>o(!0));return()=>cancelAnimationFrame(e)},[]),(0,I.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.stopPropagation(),n())};return window.addEventListener(`keydown`,e,!0),()=>window.removeEventListener(`keydown`,e,!0)},[n]);let s=e[Math.min(r,e.length-1)];if(!s)return null;let c=r>=e.length-1;return(0,ot.createPortal)((0,L.jsxs)(`div`,{"data-mobile-answer-sheet":!0,className:`fixed inset-0 z-[80] flex flex-col justify-end`,children:[(0,L.jsx)(`button`,{"aria-label":`Close`,onClick:n,className:`absolute inset-0 bg-black/50 transition-opacity duration-200 ${a?`opacity-100`:`opacity-0`}`}),(0,L.jsxs)(`div`,{className:`relative flex max-h-[86%] flex-col overflow-hidden rounded-t-[14px] border-t border-border-strong bg-panel pb-[env(safe-area-inset-bottom)] shadow-[0_-20px_60px_-10px_rgba(0,0,0,0.8)] transition-transform duration-200 ease-out motion-reduce:transition-none ${a?`translate-y-0`:`translate-y-full`}`,children:[(0,L.jsx)(`div`,{className:`mx-auto mt-[6px] h-[5px] w-[36px] shrink-0 rounded-full bg-muted/35`}),(0,L.jsxs)(`div`,{className:`flex h-[48px] shrink-0 items-center gap-2 border-b border-border/70 px-3`,children:[(0,L.jsx)(`button`,{onClick:n,className:`flex h-[44px] items-center px-2 text-[16px] text-fg/85`,children:`Cancel`}),(0,L.jsx)(`span`,{className:`flex-1 text-center text-[15px] font-semibold tracking-[-0.01em] text-fg`,children:e.length>1?`Question ${r+1} of ${e.length}`:`Question`}),(0,L.jsx)(`span`,{className:`flex h-[44px] w-[44px] items-center justify-center`,children:(0,L.jsx)(ah,{size:19,className:`opacity-0`,"aria-hidden":!0})})]}),(0,L.jsx)(`div`,{"data-mobile-answer-body":!0,className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:(0,L.jsx)(CY,{raw:s.raw,questionKind:s.kind,danger:s.danger,interactive:{answer:t.answerFor(s.bi),onChip:(e,n)=>t.onChip(s.bi,e,n),onText:e=>t.onText(s.bi,e),onSubmit:()=>c?l():i(e=>e+1)}},s.bi)}),(0,L.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center gap-3 border-t border-border/70 px-4 pb-[30px] pt-3`,children:[e.length>1?(0,L.jsx)(`div`,{className:`flex items-center gap-1.5`,children:e.map((e,t)=>(0,L.jsx)(`span`,{className:`size-[6px] rounded-full ${t===r?`bg-accent`:`bg-muted/35`}`},e.bi))}):null,(0,L.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[r>0?(0,L.jsx)(`button`,{onClick:()=>i(e=>e-1),className:`flex h-[50px] shrink-0 items-center justify-center rounded-[14px] border border-border-strong bg-elevated px-5 text-[17px] text-fg active:bg-panel-2`,children:`Back`}):null,(0,L.jsx)(`button`,{onClick:()=>c?l():i(e=>e+1),disabled:c?!t.anyAnswered||t.sending:!1,className:`flex h-[50px] flex-1 items-center justify-center rounded-[14px] bg-accent px-5 text-[17px] font-semibold text-bg transition-[filter,opacity] active:brightness-90 disabled:opacity-40`,children:c?t.sending?`Sending…`:`Send answers`:`Continue`})]})]})]})]}),document.body);function l(){t.onSubmit(),n()}}function OY(e){return(0,I.useSyncExternalStore)(e=>Jt(X,e),()=>e?kY(e)!==`codex`:!1,()=>!1)}function kY(e){return Dp(X.board,e)?.backend}function AY(e,t,n,r){let i=sz.followUp(e,t,n),a=az.get(i),o=a?`${r}\n\n${a}`:r;return az.set(i,o),i}function jY(e){if(!(typeof document>`u`)){for(let t=e;t;t=t.parentElement){let e=t.querySelector(`[data-thread-composer-box] textarea`);if(e){e.focus(),e.setSelectionRange(e.value.length,e.value.length);return}}document.getElementById(`followup-input`)?.focus()}}function MY(e){let t=Ve(),n=cz(),[r,i]=(0,I.useState)(!1);return{unqueue:(0,I.useCallback)(a=>{if(!e||r)return;let o=Dp(X.board,e)?.sessionId;if(!o){Z(`This thread has no live session to unqueue from`);return}i(!0),Y.unqueueFollowUp({slug:e,sessionId:o,deliveryId:a.deliveryId}).then(r=>{if(i(!1),!r.unqueued){Z(r.reason??`That message could not be taken back`);return}JC(t,e,a.rawText,a.deliveryId),AY(n,e,o,a.text),jY(a.from)},e=>{i(!1),Z(`Couldn't unqueue — ${(e instanceof Error?e.message:String(e)).slice(0,90)}`)})},[r,n,t,e]),pending:r}}function NY(e){return(0,I.useSyncExternalStore)(e=>Jt(X,e),()=>{if(!e)return!1;let t=Dp(X.board,e);return t?.backend!==`codex`&&t?.runtime===`running`},()=>!1)}function PY(e){let[t,n]=(0,I.useState)(!1);return{deliverNow:(0,I.useCallback)(()=>{if(!e||t)return;let r=Dp(X.board,e)?.sessionId;if(!r){Z(`This thread has no live session to interrupt`);return}n(!0),Y.deliverQueuedNow({slug:e,sessionId:r}).then(e=>{n(!1),e.interrupted||Z(e.reason??`That message could not be pushed through`)},e=>{n(!1),Z(`Couldn't push it through — ${(e instanceof Error?e.message:String(e)).slice(0,90)}`)})},[t,e]),pending:t}}function FY(e){return e.displayText??e.text}function IY(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role===`user`&&!n.queued&&!n.peerFrom&&!n.agentInstruction)return t}return-1}function LY(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.role!==`user`||n.queued||n.peerFrom||n.agentInstruction)&&!(n.wake&&!yJ(n)))return t}return 0}function RY(e,t){if(e.kind===`event`||e.kind===`reasoning`||e.role!==`user`)return!1;let n=FY(e).replace(/\r\n?/g,`
309
+ `);return(t===void 0?_J(n):t)?!0:!(e.wake||e.peerFrom)}function zY(e,t){return RY(e,t)?`bubble`:`prose`}var BY=`icon-label-nudge`,VY=new Set([`planning`,`planned`,`active`,`needs-human`,`blocked`]);function HY(e){return!!(e&&e.kind===`legacy`&&!e.foreign&&e.runtime===`none`&&!e.sessionId&&!e.threadName&&!e.owner&&e.agents.length===0&&e.errors.length===0&&VY.has(e.status))}function UY(e,t){let n=e.trim();if(!(!n||n===t.trim()))return n}function WY(e,t){let n=e.trim();return!n||n===t||n===`Untitled thread`||n===`Spinning up a thread…`?``:n}function GY(e){return e.kind!==`session`||e.foreign||e.backend===`codex`||e.claudeRuntime!==void 0&&e.claudeRuntime!==`broker`?{show:!1,enabled:!1,label:``}:e.runtime===`exited`||e.runtime===`none`?{show:!0,enabled:!1,label:`Resume this Claude thread to rename it with Claude`}:e.runtime===`spawning`?{show:!0,enabled:!1,label:`Rename with Claude once this thread has started`}:{show:!0,enabled:!0,label:`Rename with Claude — a fresh title from the opening request`}}var KY=`sticky top-0 z-10 flex min-w-0 shrink-0 items-center gap-2.5 border-b border-border bg-panel px-3 ${oh} max-[640px]:h-auto max-[640px]:min-h-12 max-[640px]:flex-wrap max-[640px]:items-start max-[640px]:gap-y-2 max-[640px]:px-4 max-[640px]:py-2.5`,qY=`min-w-0 flex-1 pl-1 max-[640px]:basis-full`,JY=`flex shrink-0 items-center max-[640px]:w-full max-[640px]:justify-between`;function YY(e){return e?.trim()?{kind:`profile-error`,message:`Profile controls unavailable: ${e.trim().slice(0,160)}`}:null}function XY(e){if(e.foreign)return`Read-only external thread`;if(e.permissionChangePending||e.permissionPending)return`A permission change is already in progress`;if(e.profileChangePending)return`A model and effort change is already in progress`;if(e.runtimeControlPending)return`Another runtime control is already in progress`;if(e.pendingAsk||e.runtime===`perm-prompt`)return`Resolve the current terminal approval or question first`;if(e.backend===`codex`)return null;let t=[...e.subAgents??[],...e.bgShells??[]].filter(e=>e.state===`running`||e.state===`stale`).length;return t>0?`Wait for ${t} unresolved background operation${t===1?``:`s`}`:e.runtime===`running`||e.runtime===`spawning`?`Wait for the current turn to finish`:null}function ZY(e){return e.permissionChangePending===!0||e.permissionPending!==void 0||e.profileChangePending===!0||e.runtimeControlPending===!0}function QY(e,t){let n=t===`codex`?`Sandbox`:`Permissions`;return e===`applied`?`${n} applied to the live session`:e===`next-turn`?t===`codex`?`${n} applied — takes effect on the next turn`:`${n} saved — the worker restarts on the next turn`:`${n} saved for the next resume`}function $Y(e){return e===`right`?`pl-3 pr-7`:`pl-7 pr-3`}function eX(e,t,n,r){let i=(n?n.flatMap(e=>e.options):t??[]).find(t=>t.value===e);return i?{text:i.label,placeholder:!1}:e?{text:e,placeholder:!1}:{text:r??``,placeholder:!0}}var tX=`__frizz_empty_select_value__`,nX=e=>e===``?tX:e,rX=e=>e===tX?``:e,iX={ghost:`border-transparent bg-transparent hover:border-border hover:bg-panel-2 data-[state=open]:border-border data-[state=open]:bg-panel-2`,bordered:`w-full justify-between border-border bg-bg hover:bg-panel-2 data-[state=open]:bg-panel-2`,readout:`text-muted hover:text-fg border-border/50 bg-transparent hover:border-border hover:bg-panel-2 data-[state=open]:border-border data-[state=open]:bg-panel-2 [&_.select-caret]:text-fg/65 [&_.select-caret]:opacity-100`},aX={ghost:`border-transparent bg-transparent`,bordered:`w-full justify-between border-border bg-bg`,readout:`text-muted border-border/50 bg-transparent [&_.select-caret]:text-fg/65 [&_.select-caret]:opacity-100`};function oX({o:e,indicatorPosition:t,typography:n}){return(0,L.jsxs)(bI,{value:nX(e.value),title:e.title,className:`relative flex w-full min-w-0 cursor-pointer select-none items-center overflow-hidden rounded-md py-1.5 text-left text-[12px] text-muted outline-none data-[highlighted]:bg-panel-2 data-[highlighted]:text-fg data-[state=checked]:bg-panel-2 data-[state=checked]:font-medium data-[state=checked]:text-fg ${$Y(t)} ${n??``}`,children:[(0,L.jsx)(xI,{className:`pointer-events-none absolute top-1/2 inline-flex -translate-y-1/2 items-center text-accent ${t===`right`?`right-2`:`left-2`}`,children:(0,L.jsx)(Qp,{size:13})}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]})}function sX({value:e,onValueChange:t,options:n,groups:r,placeholder:i,ariaLabel:a,title:o,disabled:s=!1,variant:c=`ghost`,indicatorPosition:l=`left`,side:u=`bottom`,className:d=``}){let f=eX(e,n,r,i),p=s?aX[c]:iX[c],m=c===`readout`?tR:``,[h,g]=(0,I.useState)(!1),_=(0,I.useRef)(h),v=(0,I.useRef)(s),y=(0,I.useRef)(void 0);return _.current=h,v.current=s,(0,I.useLayoutEffect)(()=>{let e=e=>{e.key!==`Escape`||!_.current||v.current||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),_.current=!1,y.current?.(),y.current=void 0,g(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]),(0,I.useLayoutEffect)(()=>{!s||!h||(_.current=!1,y.current?.(),y.current=void 0,g(!1))},[s,h]),(0,I.useLayoutEffect)(()=>()=>y.current?.(),[]),(0,L.jsxs)(fI,{modal:!1,open:h,onOpenChange:e=>{y.current?.(),y.current=void 0,_.current=e,g(e),e&&(y.current=yR(()=>{_.current=!1,y.current=void 0,g(!1)}))},children:[(0,L.jsx)(pI,{asChild:!0,disabled:s,children:(0,L.jsxs)(`button`,{type:`button`,"aria-label":a,title:o,className:`group inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md border px-2 py-1 text-left text-[12px] text-fg outline-none data-[placeholder]:text-muted ${s?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors`} ${p} ${c===`readout`?`select-trigger-readout`:``} ${m} ${d}`,children:[(0,L.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left ${f.placeholder?`text-muted`:``}`,children:f.text}),(0,L.jsx)($p,{className:`select-caret shrink-0 text-muted ${s?``:`transition-transform group-data-[state=open]:rotate-180`}`,size:13})]})}),(0,L.jsx)(mI,{children:(0,L.jsx)(hI,{align:`start`,side:u,sideOffset:5,onEscapeKeyDown:e=>e.stopPropagation(),className:`${Pj} min-w-[var(--radix-dropdown-menu-trigger-width)] max-w-[calc(100vw-1rem)] overflow-hidden rounded-lg p-1 ${m}`,children:(0,L.jsx)(yI,{value:nX(e),onValueChange:e=>t(rX(e)),className:`max-h-[300px] min-w-0 overflow-y-auto`,children:r?r.map((e,t)=>(0,L.jsxs)(gI,{children:[e.label&&(0,L.jsx)(_I,{className:`${$Y(l)} min-w-0 truncate pb-1 pt-2 text-left text-[10px] font-medium uppercase tracking-wide text-muted/60 first:pt-1`,children:e.label}),e.options.map(e=>(0,L.jsx)(oX,{o:e,indicatorPosition:l,typography:m},e.value))]},e.label||`g${t}`)):(n??[]).map(e=>(0,L.jsx)(oX,{o:e,indicatorPosition:l,typography:m},e.value))})})})]})}function cX(e,t,n,r){let i=e.find(e=>e.model===t),a=!!i,o=!!(i&&n&&i.efforts.includes(n)),s=a&&o;return{selectedProfile:i,modelKnown:a,effortKnown:o,profileKnown:s,modelSelectable:r||a,effortSelectable:!!i&&(r||s)}}function lX(e){let t=Zt(X).board?.threads.find(t=>t.id===e),n=nt({queryKey:[`threadProfileOptions`,e],queryFn:()=>Y.threadProfileOptions({slug:e}),enabled:!!(t&&!t.foreign&&t.kind===`session`),staleTime:5e3}),r=it({mutationFn:t=>Y.setThreadProfile({slug:e,...t})}),i=it({mutationFn:t=>Y.setThreadPermission({slug:e,permissionMode:t})}),a=r.isPending||i.isPending;if(!t||t.foreign||t.kind!==`session`)return{busy:a,footer:null,status:null};let o=a||ZY(t),s=t.model?.trim(),c=t.effort?.trim(),l=t.backend===`codex`?`codex`:`claude`,u=r.isPending?r.variables:void 0,d=t.profilePendingModel??u?.model,f=t.profilePendingEffort??u?.effort,p=n.data?.options??[],{modelSelectable:m}=cX(p,s,c,t.runtime===`exited`),h=n.data!==void 0,g=[{id:l,label:l===`codex`?`Codex`:`Claude Code`,options:p}],_=YY(n.isError?n.error.message:void 0),v=t.permissionMode?LR(t.permissionMode):`auto`,y=FR.some(e=>e.value===v)?v:`auto`,b=i.isPending?i.variables:y,x=XY(t);function S(e){e!==y&&i.mutate(e,{onSuccess:e=>Z(QY(e.effect,`claude`)),onError:e=>Z(`Permission change failed: ${e.message.slice(0,120)}`)})}function C(e){r.mutate(e,{onSuccess:e=>Z(e.effect===`next-resume`?`Model and effort saved for the next resume`:`Model and effort applied`),onError:e=>Z(`Profile change failed: ${e.message.slice(0,120)}`)})}return{busy:o,footer:(0,L.jsxs)(`div`,{"data-thread-composer-controls":!0,className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-1.5 gap-y-0.5`,children:[(0,L.jsx)(CR,{groups:g,value:{provider:l,model:s,effort:c},pending:d||f?{provider:l,model:d,effort:f}:void 0,onValueChange:({model:e,effort:t})=>C({model:e,effort:t}),placeholder:n.isPending?`Profile loading…`:`Profile unknown`,ariaLabel:`Thread model and effort`,menuAriaLabel:`Choose ${l===`codex`?`Codex`:`Claude Code`} model and effort`,title:m?t.runtime===`exited`?`Saved per thread and applied when this conversation resumes`:`Change this idle conversation's model and reasoning effort`:`The current live backend profile is unavailable; controls fail closed`,disabled:o||!h||!m||n.isError,compact:!0,side:`top`,className:`min-w-0 max-w-[min(72%,20rem)] px-1.5 py-0.5`}),l===`claude`&&(0,L.jsx)(sX,{variant:`readout`,side:`top`,value:b,onValueChange:e=>S(e),options:FR,ariaLabel:`Thread permission mode`,title:x?`${x} — changing permissions restarts this thread's worker process`:b===`bypassPermissions`?`Bypass: the worker never asks for approval. Changing this restarts the worker process; the conversation resumes from disk on the next turn.`:`Auto: risky actions raise an approval card here. Changing this restarts the worker process; the conversation resumes from disk on the next turn.`,disabled:o||x!==null,className:`shrink-0`}),d&&f&&(0,L.jsxs)(`span`,{className:`min-w-0 truncate text-[9px] text-muted/50`,children:[`→ `,d,` · `,f,` pending`]})]}),status:_?(0,L.jsx)(`div`,{"data-thread-control-error":``,className:`px-1 pt-1 text-[9.5px] leading-tight text-muted/65`,children:_.message}):null}}var uX=new Map;function dX(e){let t=uX.get(e);if(t)return t;let n=Y.threadSkills({slug:e}).then(e=>e.skills,()=>(uX.delete(e),[]));return uX.set(e,n),n}function fX({slug:e,surface:t,placeholder:n,className:r,id:i,ops:a,submitOverride:o}){let s=Zt(X),c=s.board?.threads.find(t=>t.id===e),l=cz(),u=sz.followUp(l,e,c?.sessionId),[d,f,p]=uz(u),m=lX(e),h=TH(e),[g,_]=(0,I.useState)(null),v=(0,I.useMemo)(()=>()=>dX(e),[e]),[y,b]=(0,I.useState)(null),x=s.composerContext[e],S=(0,I.useMemo)(()=>x?.map(e=>e.token)??[],[x]);(0,I.useEffect)(()=>{let t=X.composerContext[e];if(!t?.length)return;let{prose:n}=hL(d),r=t.filter(e=>xL(n,e.token));r.length!==t.length&&(X.composerContext[e]=r)},[e,d,x]);let C=!o&&c?.runtime===`running`&&c.backend!==`codex`;function w(t=!1){let n=d.trim();if(!n)return;let r=OR(n);if(r){p();let e=c?.backend===`codex`?`codex`:`claude`;r===`login`?_(e):b(e);return}let i=gp(e),a=AL(n,i,l),s={onOptimistic:p,onRollback:()=>{az.get(u)||f(d),_p(e,i)}};o?o(a,s):h.submit(a,{...s,interrupt:t})}return(0,L.jsxs)(`div`,{"data-thread-composer-box":t,...t===`chatComposer`?{"data-thread-action-bar":``}:{},className:r,children:[(0,L.jsx)(XL,{contextTokens:S,id:i,surface:t,value:d,onChange:f,onSubmit:()=>w(),onInterruptSubmit:C?()=>w(!0):void 0,slashSuggest:v,placeholder:n,busy:m.busy,footer:m.footer}),m.status,(0,L.jsx)(`div`,{className:`ops-column-optical-inset empty:hidden`,children:a}),g&&(0,L.jsx)(AR,{backend:g,onClose:()=>_(null),onAuthed:()=>_(null)}),y&&(0,L.jsx)(jR,{backend:y,onClose:()=>b(null)})]})}function pX({slug:e,ops:t}){let n=Zt(X).board?.threads.find(t=>t.id===e);return n?(0,L.jsx)(fX,{slug:e,surface:`chatComposer`,id:`followup-input`,placeholder:n.foreign?`Send a message to take over this session…`:`Follow up…`,className:`shrink-0 px-3 py-3`,ops:t}):null}function mX({thread:e}){let[t,n]=(0,I.useState)(!1);if(e.kind!==`session`||e.foreign||e.claudeRuntime!==`broker`||e.runtime===`exited`)return null;async function r(){n(!0);try{let t=await Y.reloadThreadPlugins({slug:e.id,sessionId:e.sessionId??``}),n=[`${t.plugins} plugin${t.plugins===1?``:`s`}`,`${t.commands} skill${t.commands===1?``:`s`}`,`${t.agents} agent${t.agents===1?``:`s`}`],r=t.mcpServers.length?` · MCP: ${t.mcpServers.join(`, `)}`:``,i=t.errorCount?` · ${t.errorCount} load error${t.errorCount===1?``:`s`}`:``;Z(`Reloaded ${n.join(`, `)}${r}${i}`)}catch(e){Z((e instanceof Error?e.message:`Plugin reload failed`).slice(0,120))}finally{n(!1)}}return(0,L.jsx)(Rj,{label:`Reload plugins — hooks, skills, agents and MCP re-read from disk, same conversation`,side:`top`,children:(0,L.jsx)(`button`,{type:`button`,"data-reload-plugins":!0,disabled:t,"aria-label":`Reload plugins`,onMouseDown:e=>e.preventDefault(),onClick:()=>void r(),className:tD,children:(0,L.jsx)(Um,{size:14,strokeWidth:2})})})}function hX(e,t){return new Promise(n=>{wH(e,t,`Your worker process was restarted so it picks up frizz's current tooling (hooks and worker contract). Re-read whatever you left in your scratch directory, then continue exactly where you left off.`,{freshProcess:!0,onSuccess:()=>{Z(`Restarting worker…`),n()},onRollback:()=>n(),failureToast:e=>`Restart failed: ${e.slice(0,80)}`})||n()})}function gX(){return kV(zV().data??null)}function _X({thread:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return!gX()||e.kind!==`session`||e.foreign||e.backend===`codex`||e.runtime===`exited`?null:(0,L.jsx)(Rj,{label:`Restart worker — same conversation, fresh process on current tooling`,side:`top`,children:(0,L.jsx)(`button`,{type:`button`,disabled:n,"aria-label":`Restart worker`,onMouseDown:e=>e.preventDefault(),onClick:()=>{r(!0),hX(t,e.id).finally(()=>r(!1))},className:`${tD} mx-[2px]`,children:n?(0,L.jsx)(Mm,{size:14,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(Gm,{size:14,strokeWidth:2})})})}function vX({slug:e,label:t=`Exit fullscreen`}){let n=eD(e)??ZC(`/`);function r(e){Id(e)&&(e.preventDefault(),nw(n,{viewTransition:!Mp()}))}return(0,L.jsx)(Rj,{label:t,children:(0,L.jsx)(`a`,{href:n,"aria-label":t,"data-standalone-return":!0,onMouseDown:e=>e.preventDefault(),onClick:r,className:tD,children:(0,L.jsx)(Lm,{size:14})})})}function yX({thread:e,expand:t,collapse:n,onDoc:r,onDone:i,onCollapse:a,collapsed:o,doneBusy:s,onStatusMutate:c,onStatusApplied:l,onStatusFailed:u}){let d=e.kind===`session`;return(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[a&&(0,L.jsx)(xX,{label:o?`Expand`:`Collapse`,icon:o?rm:nm,size:13,onClick:a}),(0,L.jsx)(mX,{thread:e}),(0,L.jsx)(_X,{thread:e}),r&&(0,L.jsx)(xX,{label:`Frizz document`,icon:gm,size:14,onClick:r}),t&&(0,L.jsx)(zj,{slug:e.id}),n&&(0,L.jsx)(vX,{slug:e.id}),d?LT(e)?(0,L.jsx)(bX,{slug:e.id}):null:(0,L.jsx)(`div`,{className:`ml-1`,children:(0,L.jsx)(OI,{slug:e.id,onDone:i,doneBusy:s,onMutateStart:c,onApplied:l,onFailed:u})})]})}function bX({slug:e}){let t=Ve(),[n,r]=(0,I.useState)(!1);return(0,L.jsx)(Rj,{label:`Retry — resume this session where it left off`,children:(0,L.jsxs)(`button`,{onClick:()=>{r(!0),EH(t,e).finally(()=>r(!1))},disabled:n,"aria-label":`Retry exited session`,onMouseDown:e=>e.preventDefault(),className:`ml-1 flex items-center gap-1.5 rounded-md border border-accent/45 bg-accent/10 px-2.5 py-1 text-[12px] font-medium text-accent outline-none transition-colors hover:border-accent/70 hover:bg-accent/15 disabled:opacity-50`,children:[n?(0,L.jsx)(Mm,{size:12,className:`animate-spin`}):(0,L.jsx)(qm,{size:12}),`Retry`]})})}function xX({label:e,icon:t,size:n,busy:r,...i}){return(0,L.jsx)(Rj,{label:e,children:(0,L.jsx)(`button`,{...i,"aria-label":e,onMouseDown:e=>e.preventDefault(),className:tD,children:r?(0,L.jsx)(Mm,{size:n,strokeWidth:2,className:`animate-spin`}):(0,L.jsx)(t,{size:n,strokeWidth:2})})})}function SX(e){let t=e.kind===`session`&&e.foreign!==!0,n=t&&(e.state===`archived`||e.archived===!0),r=t,i=t&&!n;return{footer:r,done:n,snooze:i,archive:i}}function CX(e){if(e.runtime===`exited`&&e.crashed)return!1;if(e.runtime===`perm-prompt`||e.pendingAsk)return!0;if(e.runtime===`running`||e.runtime===`spawning`)return!1;let t=e=>e.state===`running`||e.state===`stale`;return!(e.subAgents?.some(e=>Xc(e)&&t(e))||e.bgShells?.some(t))}function wX(e){let t={lead:`This thread is still running.`,groups:[],trailer:`Marking it done will stop its agent session, then move it to Done.`};if(!e)return t;if(e.cutOff)return{lead:`This session was cut off mid-turn — its worker ended before the turn finished, so the thread isn’t done.`,groups:[],trailer:`Marking it done files it under Done as it is. Retry resumes it where it left off.`};let n=[TX(`agent`,`sub-agent`,e.subAgents,e.subAgentCount),TX(`shell`,`background shell`,e.bgShells,e.bgShellCount)].filter(e=>e!==null);return e.unobservable?{lead:`This session is live, but its transcript can’t be read right now — it may still be working.`,groups:n,trailer:`Marking it done will stop the session anyway, then move it to Done.`}:!e.turnInFlight&&n.length===0?t:{lead:e.turnInFlight?n.length>0?`The agent is mid-turn, and it still owns background work:`:`The agent is mid-turn — it’s executing right now.`:`The agent is resting, but the background work it launched is still running:`,groups:n,trailer:n.length>0?`Marking it done will stop the session and everything running under it, then move it to Done.`:`Marking it done will stop its agent session mid-turn, then move it to Done.`}}function TX(e,t,n,r){let i=Math.max(r,n.length);return i===0?null:{kind:e,heading:`${i} ${t}${i===1?``:`s`}`,items:n.map(e=>({label:e.label,stale:e.state===`stale`})),overflow:Math.max(0,i-n.length)}}function EX({open:e,onOpenChange:t,title:n,children:r,footer:i,className:a=`w-[640px] max-w-[92vw] max-h-[82vh]`}){return(0,L.jsx)(PI,{open:e,onOpenChange:t,children:(0,L.jsxs)(BI,{children:[(0,L.jsx)(HI,{className:`overlay-in fixed inset-0 z-[200] bg-black/55 backdrop-blur-[1px]`}),(0,L.jsxs)(KI,{"aria-modal":`true`,onEscapeKeyDown:xR,className:`pop-in fixed left-1/2 top-1/2 z-[200] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border bg-panel shadow-2xl shadow-black/50 outline-none ${a}`,children:[(0,L.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border px-4`,children:[(0,L.jsx)(ZI,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:n}),(0,L.jsx)(tL,{type:`button`,"aria-label":`Close`,className:`rounded-md p-1 text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg`,children:(0,L.jsx)(ah,{size:15})})]}),(0,L.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:r}),i&&(0,L.jsx)(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3`,children:i})]})]})})}function DX({thread:e,onSnoozed:t}){let[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(``),[c,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(``),f=(0,I.useId)(),p=(0,I.useId)(),m=(0,I.useId)(),h=DT(e),g=Zt(tT).snoozePreset,_=Lw(g),v=zw(g),y=(0,I.useMemo)(()=>Hw(new Date(Date.now()+6e4)),[i]);async function b(n,i=null){r(!0);try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:n,prompt:n?i:null}),n?(Z(`${i?`Bump scheduled`:`Snoozed`} · ${Ww(n)}`),t?.()):Z(`Snooze cleared`),a(!1),d(``)}catch(e){let t=e instanceof Error?e.message:`Snooze failed`;Z(t.slice(0,100)),d(t)}finally{r(!1)}}function x(e){tT.snoozePreset=e,b(Bw(e))}function S(){s(Hw(new Date(h??Bw(g)))),l(e.snoozePrompt??``),d(``),a(!0)}function C(){let e=Uw(o);if(!e.ok){d(e.message);return}let t=c.trim();if(t.length>4e3){d(`Prompt is too long (${t.length}/${fl})`);return}b(e.until,t||null)}return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`inline-flex items-stretch rounded-md border border-border-strong bg-panel-2/60`,children:[(0,L.jsxs)(`button`,{type:`button`,disabled:n,"aria-label":h?`Wake thread now`:v,title:h?`Wake now · ${Ww(h)}`:v,onClick:()=>void b(h?null:Bw(g)),className:`flex items-center gap-1.5 rounded-l-md px-2.5 py-1 text-[12px] font-medium text-fg/75 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60 disabled:cursor-not-allowed disabled:opacity-45`,children:[n&&(0,L.jsx)(Mm,{size:12,className:`animate-spin`}),h?`Wake now`:v]}),(0,L.jsx)(`span`,{"aria-hidden":!0,className:`my-1 w-px bg-border`}),(0,L.jsxs)(CI,{children:[(0,L.jsx)(wI,{asChild:!0,children:(0,L.jsx)(`button`,{type:`button`,disabled:n,"aria-label":`Snooze options`,title:`Selected snooze: ${_}`,className:`flex min-w-0 items-center justify-center gap-1 rounded-r-md px-2 text-fg/75 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60 disabled:cursor-not-allowed disabled:opacity-45`,children:(0,L.jsx)($p,{size:12})})}),(0,L.jsxs)(TI,{align:`end`,children:[Pw.map(e=>(0,L.jsx)(EI,{onSelect:()=>x(e.value),icon:(0,L.jsx)(dm,{size:12}),children:(0,L.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center justify-between gap-4`,children:[(0,L.jsx)(`span`,{children:e.label}),(0,L.jsx)(`span`,{className:`text-[10px] text-muted/55`,children:e.detail})]})},e.value)),(0,L.jsx)(DI,{}),(0,L.jsx)(EI,{onSelect:S,children:`Custom time & prompt…`}),h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(DI,{}),(0,L.jsx)(EI,{onSelect:()=>void b(null),children:`Wake now`})]})]})]})]}),(0,L.jsx)(EX,{open:i,onOpenChange:e=>{n||a(e)},title:`Snooze thread`,className:`w-[360px] max-w-[92vw]`,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>a(!1),className:`rounded-md px-3 py-1.5 text-[12px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:opacity-45`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`submit`,form:m,disabled:n,className:`flex items-center gap-1.5 rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-opacity hover:opacity-90 disabled:opacity-45`,children:[n&&(0,L.jsx)(Mm,{size:12,className:`animate-spin`}),c.trim()?`Snooze & bump`:`Snooze`]})]}),children:(0,L.jsxs)(`form`,{id:m,className:`flex flex-col gap-2.5 p-4`,onSubmit:e=>{e.preventDefault(),C()},children:[(0,L.jsx)(`label`,{htmlFor:f,className:`text-[11px] font-medium text-muted`,children:`Wake at this local time`}),(0,L.jsx)(`input`,{id:f,type:`datetime-local`,required:!0,min:y,value:o,onChange:e=>{s(e.target.value),d(``)},className:`w-full rounded-md border border-border bg-bg px-2.5 py-2 text-[13px] text-fg outline-none focus:border-accent`}),(0,L.jsx)(`p`,{className:`text-[10.5px] text-muted/65`,children:`Stored as an exact instant; shown here in your browser’s local time zone.`}),(0,L.jsxs)(`label`,{htmlFor:p,className:`mt-1 text-[11px] font-medium text-muted`,children:[`Then send this prompt `,(0,L.jsx)(`span`,{className:`font-normal text-muted/55`,children:`(optional)`})]}),(0,L.jsx)(`textarea`,{id:p,autoFocus:!0,rows:3,maxLength:fl,placeholder:`e.g. Check whether CI went green and land it if so.`,value:c,onChange:e=>{l(e.target.value),d(``)},onKeyDown:e=>{IL({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),C())},className:`w-full resize-y rounded-md border border-border bg-bg px-2.5 py-2 text-[13px] leading-5 text-fg outline-none placeholder:text-muted/40 focus:border-accent`}),(0,L.jsx)(`p`,{className:`min-h-4 text-[10.5px] text-muted/65`,children:c.trim()?`frizz will resume this thread with the prompt at the wake time.`:`Leave empty to just bring the card back to your queue.`}),u&&(0,L.jsx)(`p`,{role:`alert`,className:`text-[11px] text-red-400`,children:u})]})})]})}var OX=1.25,kX=7.5-OX/2,AX=2*Math.PI*kX;function jX(e,t){return Math.max(0,Math.min(100,Math.floor(e/t*100)))}function MX({thread:e}){let t=e.context;if(!t||t.window<=0)return null;let n=jX(t.tokens,t.window),r=Math.max(0,Math.min(1,t.tokens/t.window)),i=`Context ${n}% full\n${t.tokens.toLocaleString()} of ${t.window.toLocaleString()} tokens`;return(0,L.jsx)(Rj,{label:i,side:`top`,multiline:!0,children:(0,L.jsx)(`span`,{"data-context-meter":!0,"data-context-percent":n,"aria-label":i,className:`flex shrink-0 items-center text-muted/60`,children:(0,L.jsxs)(`svg`,{viewBox:`0 0 16 16`,className:`h-[1.05em] w-[1.05em]`,"aria-hidden":!0,style:{transform:`rotate(-90deg)`},children:[(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:kX,fill:`none`,stroke:`currentColor`,strokeOpacity:.3,strokeWidth:OX}),(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:kX,fill:`none`,stroke:`currentColor`,strokeWidth:OX,strokeDasharray:`${AX*r} ${AX}`})]})})})}var NX={sm:{track:`h-[16px] w-[28px]`,thumb:`size-[12px]`,travel:`translate-x-[12px]`,onCap:`translate-y-[calc(6px_-_0.5cap)]`},md:{track:`h-[20px] w-[34px]`,thumb:`size-[16px]`,travel:`translate-x-[14px]`,onCap:`translate-y-[calc(8px_-_0.5cap)]`}};function PX({checked:e,onChange:t,disabled:n,label:r,size:i=`sm`,testId:a}){let o=NX[i];return(0,L.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e,"aria-label":r,disabled:n,"data-switch":a,"data-state":e?`checked`:`unchecked`,onMouseDown:e=>e.preventDefault(),onClick:()=>t(!e),className:`inline-flex shrink-0 cursor-pointer items-center self-baseline rounded-full p-[2px] outline-none transition-colors focus-visible:ring-1 focus-visible:ring-fg/60 disabled:cursor-default disabled:opacity-45 ${o.track} ${o.onCap} ${e?`bg-fg`:`bg-border hover:bg-border-strong`}`,children:(0,L.jsx)(`span`,{className:`pointer-events-none block rounded-full transition-transform duration-150 ease-out ${o.thumb} ${e?`bg-bg ${o.travel}`:`translate-x-0 bg-muted/70`}`})})}function FX({size:e=12,className:t=``}){return(0,L.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`,className:t,"aria-hidden":`true`,children:[(0,L.jsx)(`path`,{d:`M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,L.jsx)(`path`,{d:`M12 7a5 5 0 1 0 5 5`}),(0,L.jsx)(`path`,{d:`M13 3.055a9 9 0 1 0 7.941 7.945`}),(0,L.jsx)(`path`,{d:`M15 6v3h3l3 -3h-3v-3l-3 3`}),(0,L.jsx)(`path`,{d:`M15 9l-3 3`})]})}function IX({thread:e}){let[t,n]=(0,I.useState)(`closed`),r=(0,I.useRef)(null),i=(0,I.useRef)(void 0);(0,I.useEffect)(()=>()=>clearTimeout(i.current),[]);let a=e.recurringPrompt,o=a?.stopHook===!0||a?.heartbeat===!0||a?.postCompaction===!0;function s(){clearTimeout(i.current),i.current=setTimeout(()=>n(e=>e===`closed`?`preview`:e),LX)}function c(){clearTimeout(i.current),n(e=>e===`preview`?`closed`:e)}let l=e=>{r.current?.contains(e.detail.originalEvent.target)&&e.preventDefault()};return(0,L.jsxs)(sV,{open:t!==`closed`,onOpenChange:e=>{e||(clearTimeout(i.current),n(`closed`))},children:[(0,L.jsx)(lV,{asChild:!0,children:(0,L.jsx)(`button`,{ref:r,type:`button`,"data-recurring-prompt":!0,"data-recurring-prompt-on":o?`true`:`false`,"aria-label":o?`Goal (on)`:`Goal`,"aria-haspopup":`dialog`,"aria-expanded":t===`full`,onClick:()=>{clearTimeout(i.current),n(e=>e===`full`?`closed`:`full`)},onPointerEnter:e=>{e.pointerType===`mouse`&&s()},onPointerLeave:e=>{e.pointerType===`mouse`&&c()},onFocus:()=>n(e=>e===`closed`?`preview`:e),onBlur:c,className:`flex items-center rounded-md px-0.5 py-0.5 outline-none ${VL}`,children:(0,L.jsx)(FX,{size:12,className:o?`text-amber-400/90`:`text-muted/60 hover:text-muted`})})}),t===`preview`?(0,L.jsx)(uV,{side:`top`,align:`start`,"data-recurring-preview":!0,onPointerDownOutside:l,className:`pointer-events-none max-w-[min(22rem,calc(100vw-1.5rem))] p-2.5 text-[11px] leading-snug text-fg`,onOpenAutoFocus:e=>e.preventDefault(),children:(0,L.jsx)(RX,{armed:a})}):(0,L.jsx)(uV,{side:`top`,align:`start`,className:`w-[min(46rem,calc(100vw-1.5rem))] p-3 text-[11px] leading-relaxed text-fg`,onPointerDownOutside:l,onOpenAutoFocus:e=>e.preventDefault(),children:(0,L.jsx)(JX,{thread:e,armed:a,close:()=>n(`closed`)})})]})}var LX=260;function RX({armed:e}){let t=e?.prompt?.trim(),n=e?qX({stopHook:e.stopHook===!0,heartbeat:e.heartbeat===!0,postCompaction:e.postCompaction===!0,seconds:e.intervalSeconds??VX}):[];return(0,L.jsxs)(`div`,{"data-recurring-preview-body":!0,children:[(0,L.jsxs)(`div`,{className:`mb-1 flex items-baseline gap-2`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Goal`}),(0,L.jsx)(`span`,{className:`text-muted/70`,children:n.length>0?`sent ${n.join(`, `)}`:t?`no trigger is on`:`not set`})]}),(0,L.jsx)(`p`,{className:`line-clamp-4 whitespace-pre-wrap ${t?`text-fg/90`:`text-muted`}`,children:t||`Click to write what this thread is trying to achieve.`})]})}var zX=1,BX=1440,VX=600;function HX(e,t){if(e===String(Math.round(t/60)))return t;let n=Math.round(Number(e));return Number.isFinite(n)&&n>0?Math.min(BX,Math.max(zX,n))*60:t}var UX=null;function WX(e){return{prompt:e.text.trim(),stopHook:e.stopHook,heartbeat:e.heartbeat,postCompaction:e.postCompaction,seconds:e.seconds}}function GX(e,t){return(e.text.trim()||null)===(t.prompt||null)&&e.stopHook===t.stopHook&&e.heartbeat===t.heartbeat&&e.postCompaction===t.postCompaction&&e.seconds===t.seconds}function KX(e,t){return!e.archived&&!t}function qX(e){return[e.stopHook?`at every rest`:null,e.heartbeat?`every ${Math.round(e.seconds/60)}m`:null,e.postCompaction?`after every compaction`:null].filter(e=>e!==null)}function JX({thread:e,armed:t,close:n}){let r=KX(e,t)?_l:``,i=UX?.slug===e.id?UX.draft:null,[a,o]=(0,I.useState)(i?.text??t?.prompt??r),[s,c]=(0,I.useState)(i?.stopHook??t?.stopHook??!1),[l,u]=(0,I.useState)(i?.heartbeat??t?.heartbeat??!1),[d,f]=(0,I.useState)(i?.postCompaction??t?.postCompaction??!1),[p,m]=(0,I.useState)(i?.seconds??t?.intervalSeconds??VX),h=s||l||d,[g,_]=(0,I.useState)(String(Math.round((i?.seconds??t?.intervalSeconds??VX)/60))),v=(0,I.useRef)(null),y=(0,I.useRef)({prompt:t?.prompt??r,stopHook:t?.stopHook??!1,heartbeat:t?.heartbeat??!1,postCompaction:t?.postCompaction??!1,seconds:t?.intervalSeconds??VX}),b=e=>({text:a,stopHook:s,heartbeat:l,postCompaction:d,seconds:HX(g,p),...e}),x=(0,I.useRef)(b());x.current=b(),(0,I.useEffect)(()=>()=>{let n=x.current;if(GX(n,y.current)){UX?.slug===e.id&&(UX=null);return}if(n.text.trim()===``&&!t){UX={slug:e.id,draft:n};return}C(n)},[]);let S=(0,I.useRef)(Promise.resolve(!0));function C(t){let n=S.current.catch(()=>!1).then(async()=>{let n=await w(t);return n?UX?.slug===e.id&&(UX=null):UX={slug:e.id,draft:t},n});return S.current=n,n}async function w(t){let n=t.text.trim()||null;if(GX(t,y.current))return!0;try{await Y.setThreadRecurringPrompt({slug:e.id,sessionId:e.sessionId??``,prompt:n,stopHook:t.stopHook,heartbeat:t.heartbeat,postCompaction:t.postCompaction,...n===null?{}:{intervalSeconds:t.seconds}}),y.current={...WX(t),prompt:n??``};let r=qX(t);Z(n===null?`Goal cleared`:r.length===0?`Goal saved — no trigger is on, so nothing is sent`:`Goal: sent ${r.join(`, `)}`)}catch(e){return Z((e instanceof Error?e.message:`Could not save the recurring prompt`).slice(0,100)),!1}return!0}function T(){if(GX(b(),y.current)||a.trim()===``&&!t){n();return}C(b()).then(e=>{e&&n()})}function E(){let e=HX(g,p);_(String(Math.round(e/60))),m(e)}let D=[{at:t?.lastRestFiredAt,how:`at rest`},{at:t?.lastScheduleFiredAt,how:`on schedule`},{at:t?.lastCompactFiredAt,how:`after a compaction`}].filter(e=>e.at!==void 0),O=D.reduce((e,t)=>e&&Date.parse(e.at)>=Date.parse(t.at)?e:t,void 0),k=O===void 0?null:D.length>1?`Last sent ${wE(O.at)}`:`Last sent ${O.how} ${wE(O.at)}`;return(0,L.jsxs)(`section`,{"data-recurring-panel":!0,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Goal`}),k&&(0,L.jsx)(`span`,{className:`ml-auto truncate text-muted/55`,children:k})]}),(0,L.jsx)(`textarea`,{ref:v,"data-recurring-text":!0,value:a,maxLength:ml,onChange:e=>o(e.target.value),onKeyDown:e=>{IL({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),T())},placeholder:`What is this thread trying to achieve?`,className:`field-sizing-content max-h-[28vh] min-h-[4rem] w-full resize-none overflow-y-auto rounded-md border border-border bg-bg px-2 py-1.5 text-[12px] leading-snug outline-none placeholder:text-muted/50 focus:border-border-strong ${h?`text-fg`:`text-muted`}`}),(0,L.jsxs)(`div`,{className:`mt-3 grid grid-cols-[auto_auto_1fr] items-baseline gap-x-2.5 gap-y-2`,children:[(0,L.jsx)(PX,{testId:`stop-hook`,label:`Stop hook`,checked:s,onChange:e=>{c(e),e&&!a.trim()&&requestAnimationFrame(()=>v.current?.focus())}}),(0,L.jsx)(`span`,{className:`font-medium ${s?`text-fg`:`text-muted`}`,children:`Stop hook`}),(0,L.jsx)(`span`,{className:`text-muted`,children:`every rest — unless it signed off or parked on a wait`}),(0,L.jsx)(PX,{testId:`heartbeat`,label:`Heartbeat`,checked:l,onChange:e=>{u(e),e&&!a.trim()&&requestAnimationFrame(()=>v.current?.focus())}}),(0,L.jsx)(`span`,{className:`font-medium ${l?`text-fg`:`text-muted`}`,children:`Heartbeat`}),l?(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted`,children:[`every`,(0,L.jsx)(`input`,{type:`number`,"data-recurring-minutes":!0,inputMode:`numeric`,min:zX,max:BX,value:g,onChange:e=>_(e.target.value),onBlur:E,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),E())},"aria-label":`Heartbeat interval in minutes`,className:`w-[4.5ch] rounded-md border border-border bg-bg px-1 py-[3px] text-center text-[11px] leading-none tabular-nums text-fg outline-none focus:border-border-strong disabled:opacity-45 [appearance:textfield] [&::-webkit-inner-spin-button]:appearance-none [&::-webkit-outer-spin-button]:appearance-none`}),`min, even mid-turn`]}):(0,L.jsx)(`span`,{className:`text-muted`,children:`on a clock, even mid-turn`}),(0,L.jsx)(PX,{testId:`post-compaction`,label:`Compaction`,checked:d,onChange:e=>{f(e),e&&!a.trim()&&requestAnimationFrame(()=>v.current?.focus())}}),(0,L.jsx)(`span`,{className:`font-medium ${d?`text-fg`:`text-muted`}`,children:`Compaction`}),(0,L.jsx)(`span`,{className:`text-muted`,children:`when the context is summarized away — link the doc to re-read`})]})]})}function YX({thread:e,sticky:t=!1,safeArea:n=!1,onArchived:r,onDismissCancel:i,onSnoozed:a}){let o=SX(e);return o.footer?(0,L.jsxs)(`footer`,{"aria-label":`Thread lifecycle actions`,"data-thread-lifecycle-footer":!0,className:`${t?`z-20`:Zq} flex min-h-10 shrink-0 flex-wrap items-center justify-end ${zL} border-t border-border/70 bg-panel/95 px-3 pt-2 text-[12px] ${n?`pb-[max(0.5rem,env(safe-area-inset-bottom))]`:`pb-2`} backdrop-blur-sm`,children:[(0,L.jsxs)(`span`,{className:`mr-auto flex items-center ${zL}`,children:[(0,L.jsx)(MX,{thread:e}),(0,L.jsx)(ZX,{thread:e}),(0,L.jsx)(IX,{thread:e})]}),o.done?(0,L.jsx)(XX,{}):(0,L.jsxs)(L.Fragment,{children:[o.snooze&&(0,L.jsx)(DX,{thread:e,onSnoozed:a}),(0,L.jsx)(QX,{thread:e,onArchived:r,onDismissCancel:i})]})]}):null}function XX(){let e=`Marked done — send a message to reopen it`;return(0,L.jsx)(Rj,{label:e,side:`top`,children:(0,L.jsxs)(`span`,{"data-thread-done":!0,"aria-label":e,className:`flex items-center gap-1 rounded-md border border-transparent px-2.5 py-1 font-medium text-muted`,children:[(0,L.jsx)(Qp,{size:12}),`Done`]})})}function ZX({thread:e}){let t=DT(e);if(!t)return null;let n=e.snoozePrompt?.trim(),r=n?`Bumps ${Ww(t)}\n${n}`:`Snoozed until ${Ww(t)}`;return(0,L.jsx)(Rj,{label:r,side:`top`,multiline:!!n,children:(0,L.jsx)(`span`,{"data-pending-snooze":!0,"aria-label":r,className:`flex items-center px-0.5 text-muted/60 ${BL}`,children:(0,L.jsx)(Tm,{size:12})})})}function QX({thread:e,onArchived:t,onDismissCancel:n,className:r=`rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] text-fg/80 hover:bg-panel-2 hover:text-fg`,iconClassName:i=``}){let[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(void 0),d=(r,i)=>{o(!0),i&&t?.(),(r||CX(e))&&GH(e.id),Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:r}).then(r=>{if(r.needsConfirmation){KH(e.id),i&&n?.(),u(r.hold),c(!0),o(!1);return}c(!1),Z(`Done`),i||t?.()}).catch(t=>{KH(e.id),i&&n?.(),Z(`Couldn’t finish: ${t.message.slice(0,80)}`),o(!1)})},f=!!t&&!!n&&CX(e);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>d(!1,f),disabled:a,"aria-label":`Mark as done`,title:`Mark as done`,onMouseDown:e=>e.preventDefault(),className:`flex items-center gap-1 font-medium outline-none transition-colors focus-visible:ring-1 focus-visible:ring-fg/60 disabled:opacity-45 ${r}`,children:[(0,L.jsx)(Qp,{size:12,className:i}),`Mark as done`]}),(0,L.jsx)(EX,{open:s,onOpenChange:e=>{a||c(e)},title:l?.cutOff?`Mark an unfinished thread done?`:`End this session?`,className:`w-[390px] max-w-[92vw]`,footer:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`button`,{type:`button`,disabled:a,onClick:()=>c(!1),className:`rounded-md px-3 py-1.5 text-[12px] text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg disabled:opacity-45`,children:`Cancel`}),(0,L.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>d(!0,!1),className:`flex items-center gap-1.5 rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-opacity hover:opacity-90 disabled:opacity-45`,children:[a&&(0,L.jsx)(Mm,{size:12,className:`animate-spin`}),l?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,L.jsx)($X,{hold:l})})]})}function $X({hold:e}){let t=wX(e);return(0,L.jsxs)(`div`,{"data-completion-hold":!0,className:`flex flex-col gap-2 p-4 text-[12px] leading-relaxed text-muted`,children:[(0,L.jsx)(`p`,{children:t.lead}),t.groups.map(e=>(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,L.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-fg/70`,children:e.heading}),(0,L.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[e.items.map((e,t)=>(0,L.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,L.jsx)(`span`,{"aria-hidden":!0,className:EE,children:`⤷`}),(0,L.jsx)(`span`,{className:`min-w-0 truncate text-fg/80`,children:e.label}),e.stale&&(0,L.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted/60`,children:`no recent output`})]},`${e.label}-${t}`)),e.overflow>0&&(0,L.jsxs)(`li`,{className:`pl-[15px] text-muted/60`,children:[`+`,e.overflow,` more`]})]})]},e.kind)),(0,L.jsx)(`p`,{children:t.trailer})]})}function eZ({thread:e,hidden:t=!1}){let n=it({mutationFn:()=>Y.aiRenameThread({slug:e.id}),onSuccess:({title:e})=>Z(`Renamed to “${e}”`),onError:e=>Z(e instanceof Error?e.message:`Could not rename with Claude`,{duration:7e3})}),r=GY(e);if(!r.show||t)return null;let i=n.isPending?`Claude is generating a title…`:n.error instanceof Error?n.error.message:r.label,a=n.isPending||!!n.error;return(0,L.jsx)(Rj,{label:i,children:(0,L.jsx)(`button`,{type:`button`,"data-ai-rename":!0,"aria-label":n.isPending?`Renaming with Claude`:r.label,"aria-busy":n.isPending,"aria-disabled":!r.enabled,onMouseDown:e=>e.preventDefault(),onClick:()=>{if(!n.isPending){if(!r.enabled){Z(r.label);return}n.reset(),n.mutate()}},className:`title-refresh-offset -mx-[7px] -my-3 flex h-6 w-6 shrink-0 items-center justify-center rounded-md outline-none transition-[color,background-color,opacity] focus-visible:opacity-100 group-hover/thread-title:opacity-100 ${a?`opacity-100`:`opacity-0`} ${n.error?`text-red-400 hover:bg-red-500/10`:r.enabled?`text-muted hover:bg-panel-2 hover:text-fg`:`cursor-not-allowed text-muted/50 hover:bg-panel-2`}`,children:n.isPending?(0,L.jsx)(Mm,{size:12,className:`animate-spin`}):(0,L.jsx)(Jm,{size:12})})})}var tZ=new Set([`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]);function nZ(e,t){let n=e.lastIndexOf(t);if(n<=0)return{model:e};let r=e.slice(n+1);return tZ.has(r)?{model:e.slice(0,n),effort:r}:{model:e}}function rZ(e){let t=e?.trim();if(!t)return`Profile unknown`;if(t.startsWith(`frizz:`)){let{model:e,effort:n}=nZ(t.slice(6).replace(/^frizz-/,``),`-`);return n?`${e} › ${n}`:e}let n=t.split(/\s+/),{model:r,effort:i}=nZ(n.at(-1)??t,`/`);if(!i)return t;let a=n.slice(0,-1).join(` `);return`${a?`${a} · `:``}${r} › ${i}`}function iZ(e){return e?.trim()?rZ(e):void 0}function aZ(e){if(e.kind!==void 0||e.role!==`assistant`||e.text.trim())return;let t=e.parts??[],n=t.length>0?t.length===1&&t[0].kind===`tools`?t[0].tools:[]:e.tools??[],r=n.length===1?n[0]:void 0;return r?.agentCompletion?r:void 0}var oZ={completed:`finished`,killed:`stopped`,failed:`failed`};function sZ(e){let t=oZ[e.agentStatus??`completed`],n=e.agentElapsedMs===void 0?void 0:xE(e.agentElapsedMs);return{outcome:t,tail:`${t}${n?` · ${n}`:``}`}}var cZ=e=>e===void 0?void 0:gE(e),lZ=e=>{if(e!==void 0)return xE(e)||void 0};function uZ(e){let{agentStatus:t,agentElapsedMs:n,liveState:r,liveElapsedMs:i,status:a,durationMs:o}=e;if(t){let e=t===`killed`,r=t===`failed`,i=cZ(n);return{label:t===`completed`?void 0:oZ[t],duration:lZ(n),tone:r?`failed`:`muted`,title:`${e?`Stopped`:r?`Failed`:`Ran for`}${e||r?` after`:``} ${i??`an unknown time`}`}}if(r){let e=cZ(i);return{label:void 0,duration:lZ(i),tone:`muted`,title:r===`running`?`Working for ${e??`an unknown time`}`:`Dispatched ${e??`an unknown time`} ago`}}if(a===`pending`||a!==`failed`&&a!==`cancelled`)return null;let s=a===`failed`,c=a===`cancelled`,l=cZ(o);return{label:c?oZ.killed:s?oZ.failed:void 0,duration:lZ(o),tone:s?`failed`:`muted`,title:`${c?`Stopped after`:s?`Failed after`:`Ran for`} ${l??`an unknown time`}`}}function dZ({at:e,host:t}){let n=YT(e);return!n||!e?null:(0,L.jsx)(`time`,{dateTime:e,"aria-hidden":`true`,className:`!pointer-events-none absolute right-6 top-full z-10 ${t===`bubble`?`mt-[2px]`:`-mt-[5px]`} select-none text-[11px] leading-4 [font-variant-numeric:tabular-nums] text-muted/70 opacity-0 transition-opacity group-hover/ts:opacity-100`,children:n})}function fZ({at:e,host:t,gap:n,children:r}){return(0,L.jsxs)(`div`,{className:`group/ts relative flex flex-col px-6`,style:{paddingTop:n},children:[r,(0,L.jsx)(dZ,{at:e,host:t})]})}var pZ=`text-[14px] leading-5 text-muted`,mZ=`size-[1em] shrink-0 self-baseline -mt-[calc(1em_-_1cap)] translate-y-[calc(0.5em_-_0.5cap)] text-muted/70 transition-transform group-hover:text-fg`;function hZ(e){return`${mZ} ${e?`-mx-[0.208em] rotate-90`:`-mx-[0.333em]`}`}var $=I.createElement;function gZ({payload:e}){return e.kind===`command-approval`?$(I.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},`Command`),$(`div`,{className:`mt-0.5 break-words text-[13px] font-medium text-fg`},e.command.summary),e.command.workingDirectoryLabel?$(`div`,{className:`mt-1 break-all text-[10.5px] text-muted/70`},`Working directory: `,e.command.workingDirectoryLabel):null,$(_Z,{label:`Redacted command preview`,text:e.command.preview}),e.command.actions?$(vZ,{actions:e.command.actions}):null,e.capabilities?$(bZ,{capabilities:e.capabilities}):null):e.kind===`file-approval`?$(I.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},wZ(e.operation)),$(`div`,{className:`mt-0.5 break-all font-mono-keep text-[12px] text-fg`},e.pathLabel),e.destinationLabel?$(`div`,{className:`mt-1 break-all font-mono-keep text-[11px] text-muted`},`→ `,e.destinationLabel):null,e.grantRootLabel?$(`section`,{"aria-label":`Requested session write root`,className:`mt-2.5 min-w-0 rounded-md border border-amber-400/35 bg-amber-500/[0.06] px-2.5 py-2`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-amber-100/80`},`Requested session write root`),$(`div`,{className:`mt-1 min-w-0 break-all font-mono-keep text-[10.5px] text-fg/85`},e.grantRootLabel),e.scopeLabel?$(`div`,{className:`mt-1.5 whitespace-pre-wrap break-words text-[10.5px] leading-snug text-amber-100/75`},e.scopeLabel):null):null,e.diffPreview?$(_Z,{label:`Plain-text diff preview`,text:e.diffPreview}):null,e.changes?$(yZ,{changes:e.changes}):null):$(I.Fragment,null,e.preview?$(`pre`,{className:`max-h-64 max-w-full min-w-0 overflow-auto rounded-md border border-border/70 bg-bg/40 px-2.5 py-2 whitespace-pre-wrap break-words font-mono-keep text-[11.5px] leading-relaxed text-fg/90`},e.promptLabel?$(`span`,{className:`text-shell/90`},e.promptLabel):null,e.promptLabel?$(`span`,{className:`text-accent`},` ❯ `):null,e.preview):null,e.resourceLabel?$(`div`,{className:`mt-1 break-all text-[11px] text-muted`},`Resource: `,e.resourceLabel):null,e.workingDirectoryLabel?$(`div`,{className:`mt-1.5 break-all text-[10.5px] text-muted/70`},`Working directory: `,e.workingDirectoryLabel):null,e.scopeLabel?$(`div`,{className:`mt-2 whitespace-pre-wrap break-words text-[11px] leading-snug text-muted`},e.scopeLabel):null,e.capabilities?$(bZ,{capabilities:e.capabilities}):null)}function _Z({label:e,text:t}){return $(`details`,{className:`mt-2.5 min-w-0 rounded-md border border-border/70 bg-bg/35`,open:t.length<1200},$(`summary`,{className:`cursor-pointer px-2.5 py-2 text-[10.5px] text-muted outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/50`},e),$(`pre`,{className:`max-h-64 max-w-full min-w-0 overflow-auto border-t border-border/60 px-2.5 py-2 whitespace-pre-wrap break-words font-mono-keep text-[11px] leading-relaxed text-fg/80`},t))}function vZ({actions:e}){return $(`section`,{"aria-label":`Parsed command actions`,className:`mt-3 min-w-0`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-muted/75`},`Parsed actions`),$(`ul`,{className:`mt-1.5 flex min-w-0 flex-col gap-2`},e.map((e,t)=>$(`li`,{key:t,className:`min-w-0 rounded-md border border-border/65 bg-bg/25 px-2.5 py-2`},$(`div`,{className:`text-[11px] font-medium text-fg/90`},CZ(e.kind)),e.resourceLabel?$(`div`,{className:`mt-0.5 break-all font-mono-keep text-[10.5px] text-muted`},e.resourceLabel):null,e.queryLabel?$(`div`,{className:`mt-0.5 break-all text-[10.5px] text-muted`},`Query: `,e.queryLabel):null,$(_Z,{label:`${CZ(e.kind)} command detail`,text:e.commandPreview})))))}function yZ({changes:e}){return $(`section`,{"aria-label":`Affected file changes`,className:`mt-3 min-w-0`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-muted/75`},`Affected changes`),$(`ol`,{className:`mt-1.5 flex min-w-0 flex-col gap-2`},e.map((e,t)=>$(`li`,{key:t,className:`min-w-0 rounded-md border border-border/65 bg-bg/25 px-2.5 py-2`},$(`div`,{className:`text-[11px] font-medium text-fg/90`},wZ(e.operation)),$(`div`,{className:`mt-0.5 break-all font-mono-keep text-[10.5px] text-fg/80`},e.pathLabel),e.destinationLabel?$(`div`,{className:`mt-0.5 min-w-0 break-all font-mono-keep text-[10.5px] text-muted`},`→ `,e.destinationLabel):null,e.diffPreview?$(_Z,{label:`${wZ(e.operation)} plain-text diff`,text:e.diffPreview}):null))))}function bZ({capabilities:e}){return $(`section`,{"aria-label":`Requested capabilities`,className:`mt-3 min-w-0`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-muted/75`},`Requested capabilities`),$(`ul`,{className:`mt-1.5 flex min-w-0 flex-col gap-2`},e.map((e,t)=>$(`li`,{key:t,className:`min-w-0 rounded-md border border-border/65 bg-bg/25 px-2.5 py-2`},$(xZ,{capability:e})))))}function xZ({capability:e}){if(e.kind===`network`){let t=e.enabled===!0?`Enable network access`:e.enabled===!1?`Disable network access`:`Network access request`;return $(I.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},t),e.hosts.length>0?$(SZ,{label:`Hosts and protocols`,values:e.hosts}):null)}if(e.kind===`filesystem`){let t=e.access===`read`?`Read filesystem paths`:e.access===`write`?`Write filesystem paths`:`Deny filesystem paths`;return $(I.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},t),$(SZ,{label:`Paths`,values:e.resources}))}return e.kind===`glob-scan`?$(I.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},`Filesystem glob scanning`),$(`div`,{className:`mt-0.5 text-[10.5px] text-muted`},`Maximum depth: `,String(e.depth))):e.kind===`exec-policy`?$(I.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},`Future command policy amendment`),$(SZ,{label:`Command prefix tokens`,values:e.prefixes})):$(I.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},e.access===`allow`?`Allow future network hosts`:`Deny future network hosts`),$(SZ,{label:`Hosts`,values:e.hosts}))}function SZ({label:e,values:t}){return $(`div`,{className:`mt-1 min-w-0`},$(`div`,{className:`sr-only`},e),$(`ul`,{"aria-label":e,className:`flex min-w-0 flex-col gap-0.5`},t.map((e,t)=>$(`li`,{key:t,className:`min-w-0 break-all font-mono-keep text-[10.5px] text-muted`},e))))}function CZ(e){switch(e){case`read`:return`Read a file`;case`list-files`:return`List files`;case`search`:return`Search files`;case`unknown`:return`Unclassified command`}}function wZ(e){switch(e){case`read`:return`Read file`;case`create`:return`Create file`;case`write`:return`Modify file`;case`move`:return`Move file`;case`delete`:return`Delete file`;case`execute`:return`Execute file`;case`other`:return`File operation`}}function TZ(e){return e===`sending`?{actionsEnabled:!1,status:`Sending to runtime…`}:e===`reconnect-required`?{actionsEnabled:!1,status:`Runtime reconnect required before this request can be answered.`}:{actionsEnabled:!0}}var EZ={semantic:`approve`,label:`Approve once`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`},DZ={semantic:`approve`,label:`Approve for session`,order:20,tone:`primary`,durable:!0,scope:`Persists for later matching requests in this thread session.`},OZ={semantic:`approve`,label:`Grant for turn`,order:10,tone:`primary`,durable:!1,scope:`Applies to this turn only.`},kZ={semantic:`approve`,label:`Grant for session`,order:20,tone:`primary`,durable:!0,scope:`Persists until this thread session ends.`},AZ={semantic:`deny`,label:`Deny`,order:70,tone:`danger`,durable:!1,scope:`Rejects this request.`},jZ={semantic:`decline`,label:`Decline`,order:70,tone:`danger`,durable:!1,scope:`Declines this request.`},MZ={semantic:`cancel`,label:`Cancel request`,order:80,tone:`neutral`,durable:!1,scope:`Cancels this pending request.`};function NZ(e,t){let{id:n,semantic:r}=t;if(e.kind===`command-approval`||e.kind===`file-approval`)return(n===`accept`||n===`approve-once`)&&r===`approve`?EZ:n===`acceptForSession`&&r===`approve`?DZ:(n===`decline`||n===`deny`)&&r===`deny`?AZ:n===`cancel`&&r===`cancel`?MZ:void 0;if(e.kind===`permission-approval`)return n===`grant-turn`&&r===`approve`?OZ:n===`grant-session`&&r===`approve`?kZ:(n===`deny`||n===`decline`)&&r===`deny`?AZ:n===`cancel`&&r===`cancel`?MZ:void 0;if(e.kind===`mcp-elicitation-form`||e.kind===`mcp-elicitation-url`)return n===`accept`&&r===`accept`?{semantic:`accept`,label:e.kind===`mcp-elicitation-form`?`Submit`:`Continue`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`}:n===`decline`&&r===`decline`?jZ:n===`cancel`&&r===`cancel`?MZ:void 0;if(n===`answer`&&r===`answer`)return{semantic:`answer`,label:`Send answer`,order:10,tone:`primary`,durable:!1,scope:`Sends these answers to this request only.`};if(n===`decline`&&r===`decline`)return jZ;if(n===`cancel`&&r===`cancel`)return MZ}function PZ(e){let t=t=>e.payload.kind===`mcp-elicitation-form`&&t===`accept`||e.payload.kind===`agent-question`&&t===`answer`;return e.allowedDecisions.flatMap(n=>{let r=NZ(e.payload,n);return r?[{...r,id:n.id,semantic:n.semantic,requiresValues:t(n.semantic)}]:[]}).sort((e,t)=>e.order-t.order||e.id.localeCompare(t.id))}function FZ(e){switch(e){case`claude`:return`Claude`;case`codex`:return`Codex`;case`frizz`:return`Frizz`}}function IZ(e){switch(e){case`runtime`:return`Runtime`;case`agent`:return`Agent`;case`tool`:return`Tool`;case`mcp-server`:return`MCP server`;case`frizz`:return`Frizz`}}function LZ(e,t){let n=e.options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t));return n<0?``:String(n)}function RZ(e){let t=Object.create(null);for(let n of e)if(n.input===`text`||n.input===`multiline`)t[n.id]=n.default??``;else if(n.input===`number`||n.input===`integer`)t[n.id]=n.default===void 0?``:String(n.default);else if(n.input===`boolean`)t[n.id]=n.default??!1;else if(n.input===`select`)t[n.id]=n.default===void 0?``:LZ(n,n.default);else if(n.input===`multi-select`){let e=new Set(n.default??[]);t[n.id]=n.options.flatMap((t,n)=>e.has(t.value)?[String(n)]:[])}return t}function zZ(e,t,n){let r=Object.create(null);for(let t of Object.keys(e))r[t]=e[t];return r[t]=n,r}function BZ(e,t){if(e.some(e=>e.secret))return{errors:{},formError:`Secret responses cannot be sent through this Frizz connection.`};let n=Object.create(null),r={};for(let i of e){let e=t[i.id],a;if(i.input===`text`||i.input===`multiline`){let t=typeof e==`string`?e:``;if(!i.required&&t===``)continue;i.required&&t===``?r[i.id]=`This field is required.`:a=t}else if(i.input===`number`||i.input===`integer`){let t=typeof e==`string`?e.trim():``;if(!i.required&&t===``)continue;if(t===``)r[i.id]=`This field is required.`;else{let e=Number(t);Number.isFinite(e)?a=e:r[i.id]=`Enter a valid number.`}}else if(i.input===`boolean`)a=e===!0;else if(i.input===`select`){let t=typeof e==`string`&&/^\d+$/.test(e)?Number(e):-1;if(t<0||t>=i.options.length)if(i.required)r[i.id]=`Choose an option.`;else continue;else a=i.options[t].value}else if(i.input===`multi-select`){let t=(Array.isArray(e)?e:[]).flatMap(e=>/^\d+$/.test(e)?[Number(e)]:[]);if(t.some(e=>e<0||e>=i.options.length))r[i.id]=`Choose only advertised options.`;else if(i.required&&t.length===0)r[i.id]=`Choose at least one option.`;else if(t.length>0)a=t.map(e=>i.options[e].value);else continue}if(a!==void 0&&!r[i.id]){let e=ac(i,a);e?r[i.id]=`Value ${e}.`:n[i.id]=a}}if(Object.keys(r).length>0)return{errors:r};let i=yc.safeParse(n);return i.success?{errors:r,values:i.data}:{errors:r,formError:`The response is too large or contains invalid values.`}}function VZ(e,t){return JSON.stringify([e,t??null])}function HZ(e,t){try{let n=new URL(e,t);return n.protocol===`http:`||n.protocol===`https:`?n.toString():null}catch{return null}}function UZ(e,t){let n=e.getAttribute(`href`);if(!n)return!1;let r=HZ(n,t);if(!r)return!1;let i;try{i=new URL(t)}catch{return!1}if(new URL(r).origin===i.origin)return!1;e.setAttribute(`target`,`_blank`);let a=new Set((e.getAttribute(`rel`)??``).split(/\s+/u).filter(Boolean));return a.add(`noopener`),a.add(`noreferrer`),e.setAttribute(`rel`,[...a].join(` `)),!0}function WZ(e=()=>location.href){return t=>{if(t.defaultPrevented||t.button!==0)return;let n=KZ(t);n&&UZ(n,e())}}function GZ(){let e=WZ();return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)}function KZ(e){let t=typeof e.composedPath==`function`?e.composedPath():[];for(let e of t)if(qZ(e))return e;let n=e.target?.closest?.(`a[href]`);return qZ(n)?n:null}function qZ(e){if(!e||typeof e!=`object`)return!1;let t=e;return t.tagName?.toLowerCase()===`a`&&typeof t.getAttribute==`function`&&typeof t.setAttribute==`function`&&typeof t.hasAttribute==`function`&&t.hasAttribute(`href`)}function JZ(e){let t=e,n=``;do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return`${n}.`}function YZ(e,t){let n=e??t;if(!n)return null;let r=e&&(e.input===`select`||e.input===`multi-select`)?e.options:[];return{question:{kind:e?.input===`multi-select`?`multi`:`question`,danger:!1,contextMd:n.description??n.label,options:r.map((e,t)=>`${JZ(t)} ${e.label}`),recommendedIdx:null},...e?{optionFieldId:e.id}:{},optionValues:r.map(e=>e.value),...t?{notesFieldId:t.id}:{}}}function XZ(e){if(e.payload.kind!==`agent-question`)return null;let t=e.payload.fields,n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r.secret)return null;if(r.id.endsWith(`_notes`))continue;let i=t[e+1],a=i&&i.id===`${r.id}_notes`?i:void 0;if(r.input===`select`||r.input===`multi-select`){let e=YZ(r,a);if(!e)return null;n.push(e)}else if(r.input===`text`||r.input===`multiline`){let e=YZ(void 0,r);if(!e)return null;n.push(e)}else return null}return n.length>0?n:null}function ZZ(e,t){let n=[],r;if(t){let i=e.multiSelect?t.split(`, `):[t];e.options.forEach((e,t)=>{i.includes(e.label)&&n.push(t)}),n.length===0&&(r=t)}return{question:{kind:e.multiSelect?`multi`:`question`,danger:!1,contextMd:e.question,options:e.options.map((e,t)=>`${JZ(t)} ${e.label}${e.description?` — ${e.description}`:``}`),recommendedIdx:null},chosenIdxs:n,text:r}}function QZ(e,t){let n={};return e.forEach((e,r)=>{let i=t[r];if(!i)return;let a=i.text.trim();if(e.question.kind===`multi`){let t=(i.chosenSet??[]).slice().sort((e,t)=>e-t).flatMap(t=>{let n=e.optionValues[t];return n===void 0?[]:[n]});e.optionFieldId&&t.length>0&&(n[e.optionFieldId]=t),e.notesFieldId&&a&&(n[e.notesFieldId]=a);return}let o=i.chosen;if(e.optionFieldId&&o!==null&&e.optionValues[o]!==void 0){n[e.optionFieldId]=e.optionValues[o];return}a&&e.notesFieldId&&(n[e.notesFieldId]=a)}),Object.keys(n).length>0?n:void 0}function $Z(e){let t=e instanceof Error?e.message:`The request could not be updated.`;return t.length>240?`${t.slice(0,239)}…`:t}function eQ(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`frizz-response-${Date.now()}-${Math.random().toString(36).slice(2)}`}function tQ({thread:e,className:t=``,autoFocusFirst:n=!1}){let r=PC(e),i=IC(e),a=(0,I.useMemo)(()=>[...i.data?.interactions??[]].sort((e,t)=>e.createdAt.localeCompare(t.createdAt)||e.id.localeCompare(t.id)),[i.data?.interactions]);return r?i.isError&&a.length===0?(0,L.jsxs)(`div`,{"data-interactions-error":!0,role:`alert`,className:`${Yq} border border-amber-500/35 bg-amber-500/[0.07] p-4 text-[12px] text-amber-100 ${t}`,children:[(0,L.jsx)(`div`,{className:`font-medium`,children:`Pending requests could not be loaded.`}),(0,L.jsx)(`div`,{className:`mt-1 break-words text-amber-100/75`,children:$Z(i.error)}),(0,L.jsx)(`button`,{type:`button`,onClick:()=>void i.refetch(),className:`mt-2 rounded-md border border-amber-400/40 px-2 py-1 text-[11px] hover:bg-amber-500/10`,children:`Try again`})]}):a.length===0?null:(0,L.jsx)(`section`,{"data-typed-interactions":!0,"aria-label":`${a.length} pending request${a.length===1?``:`s`}`,className:`flex min-w-0 flex-col gap-3 ${t}`,children:a.map((e,t)=>(0,L.jsx)(rQ,{record:e,autoFocus:n&&t===0},e.id))}):null}function nQ({record:e,questions:t,autoFocus:n}){let r=Ve(),i=(0,I.useRef)(null),a=(0,I.useRef)(new Map),o=cz(),s=TZ(e.delivery?.effect),c=(0,I.useMemo)(()=>PZ(e).find(e=>e.semantic===`answer`),[e]),l=dz(t.flatMap(t=>t.notesFieldId?[sz.interaction(o,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId)]:[])),[u,d]=(0,I.useState)(()=>t.map(()=>({chosen:null,chosenSet:[]}))),f=t.map((t,n)=>({chosen:u[n]?.chosen??null,chosenSet:u[n]?.chosenSet??[],text:t.notesFieldId?l.get(sz.interaction(o,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId))??``:``})),p=QZ(t,f),[m,h]=(0,I.useState)(),[g,_]=(0,I.useState)(!1);(0,I.useEffect)(()=>{if(!n)return;let e=document.activeElement;e&&e!==document.body||requestAnimationFrame(()=>i.current?.focus())},[n,e.id]);let v=it({mutationFn:async t=>Y.interactionResolve({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id,sessionEpoch:e.owner.sessionEpoch,capabilityRevision:e.owner.capabilityRevision,expectedRecordRevision:e.recordRevision,responseId:t.responseId,decisionId:t.decisionId,values:t.values}),onSuccess:t=>{_(!0),Pb(r,t.interaction),r.invalidateQueries({queryKey:Mb(e.owner.threadSlug,e.owner.sessionId)}),r.invalidateQueries({queryKey:Nb(e.owner.threadSlug,e.owner.sessionId,e.id)})},onError:t=>{Fb(r,e),h($Z(t))}}),y=()=>{if(!c||!p||v.isPending||g||!s.actionsEnabled)return;h(void 0);let e=VZ(c.id,p),t=a.current.get(e)??eQ();a.current.set(e,t),v.mutate({decisionId:c.id,values:p,responseId:t})},b=(t,n)=>{t.notesFieldId&&az.set(sz.interaction(o,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId),n)};return(0,L.jsxs)(`article`,{ref:i,tabIndex:-1,"data-interaction-id":e.id,"data-interaction-kind":e.payload.kind,"data-interaction-question":`native`,"data-delivery-effect":e.delivery?.effect,className:`flex min-w-0 flex-col gap-2 outline-none`,children:[t.map((e,t)=>(0,L.jsx)(CY,{question:e.question,interactive:s.actionsEnabled&&!g?{answer:f[t],onChip:n=>{d(r=>r.map((r,i)=>{if(i!==t)return r;if(e.question.kind===`multi`){let e=r.chosenSet.includes(n)?r.chosenSet.filter(e=>e!==n):[...r.chosenSet,n];return{...r,chosenSet:e}}return{...r,chosen:r.chosen===n?null:n}}))},onText:n=>{b(e,n),e.question.kind!==`multi`&&d(e=>e[t]?.chosen===null||e[t]===void 0?e:e.map((e,n)=>n===t?{...e,chosen:null}:e))},onSubmit:y}:void 0},e.optionFieldId??e.notesFieldId??t)),m&&(0,L.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-red-300`,children:m}),(s.status||v.isPending||g)&&(0,L.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[11px] leading-snug text-muted`,children:s.status??(g?`Answer sent.`:`Sending…`)}),s.actionsEnabled&&!g&&(0,L.jsx)(`div`,{className:`flex justify-start`,children:(0,L.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:!p||v.isPending,onClick:y,onMouseDown:e=>e.preventDefault(),className:`rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:`Send answers`})})]})}function rQ({record:e,autoFocus:t=!1}){let n=(0,I.useMemo)(()=>XZ(e),[e]);return n?(0,L.jsx)(nQ,{record:e,questions:n,autoFocus:t}):(0,L.jsx)(iQ,{record:e,autoFocus:t})}function iQ({record:e,autoFocus:t=!1}){let n=Ve(),r=(0,I.useId)(),i=(0,I.useRef)(null),a=(0,I.useRef)(new Map),o=e.payload.kind===`mcp-elicitation-form`||e.payload.kind===`agent-question`?e.payload.fields:[],s=o.some(e=>e.secret),c=cz(),l=o.filter(e=>!e.secret&&(e.input===`text`||e.input===`multiline`)).map(t=>sz.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.id)),u=dz(l),[d,f]=(0,I.useState)(()=>RZ(o)),p=(0,I.useMemo)(()=>{let t={...d};return o.forEach(n=>{if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=sz.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id);t[n.id]=u.get(r)??``}}),t},[o,d,u,c,e.id,e.owner]),[m,h]=(0,I.useState)({}),[g,_]=(0,I.useState)(),[v,y]=(0,I.useState)(),[b,x]=(0,I.useState)(!1),[S,C]=(0,I.useState)(),[w,T]=(0,I.useState)(!1),E=TZ(e.delivery?.effect),D=(0,I.useMemo)(()=>PZ(e),[e]).filter(e=>!(s&&e.requiresValues)),O=e.allowedDecisions.length-D.length,k=(0,I.useCallback)(t=>{for(let n of o)if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=t[n.id];typeof r==`string`&&az.set(sz.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id),r)}f(t)},[o,c,e.id,e.owner]);(0,I.useEffect)(()=>{if(!t)return;let e=document.activeElement;e&&e!==document.body||requestAnimationFrame(()=>i.current?.focus())},[t,e.id]),(0,I.useEffect)(()=>{E.actionsEnabled||(C(void 0),T(!1))},[E.actionsEnabled]);let A=it({mutationFn:async({decision:t,values:n,responseId:r})=>{if(t.semantic===`cancel`&&e.provider.kind===`frizz`){let t=await Y.interactionCancel({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id,sessionEpoch:e.owner.sessionEpoch,capabilityRevision:e.owner.capabilityRevision,expectedRecordRevision:e.recordRevision});return{effect:t.effect,interaction:t.interaction,waitingForProvider:!1}}let i=await Y.interactionResolve({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id,sessionEpoch:e.owner.sessionEpoch,capabilityRevision:e.owner.capabilityRevision,expectedRecordRevision:e.recordRevision,responseId:r,decisionId:t.id,...n===void 0?{}:{values:n}});return{effect:i.effect,interaction:i.interaction,waitingForProvider:i.interaction.delivery?.effect===`sending`||i.effect===`queued`||i.effect===`already-queued`}},onSuccess:(t,r)=>{t.waitingForProvider||a.current.delete(VZ(r.decision.id,r.values)),_(void 0),C(void 0),T(!1),x(!0),l.forEach(e=>az.clear(e)),y(t.waitingForProvider?`Response sent. Waiting for the provider to acknowledge it…`:`Request completed.`),Pb(n,t.interaction),n.setQueryData(Nb(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t.interaction}),n.invalidateQueries({queryKey:Mb(e.owner.threadSlug,e.owner.sessionId),exact:!0}),t.waitingForProvider&&window.setTimeout(()=>{n.invalidateQueries({queryKey:Mb(e.owner.threadSlug,e.owner.sessionId),exact:!0})},1e3)},onError:t=>{y(void 0),_($Z(t)),Fb(n,e),Y.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{Pb(n,t),n.setQueryData(Nb(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t}),t.delivery?.effect===`sending`?(_(void 0),y(void 0),x(!0)):t.delivery?.effect===`reconnect-required`?(_(void 0),y(void 0)):(t.lifecycle!==`pending`||t.recordRevision!==e.recordRevision)&&(_(void 0),y(t.lifecycle===`expired`?`This request expired.`:`This request changed in another client.`),n.invalidateQueries({queryKey:Mb(e.owner.threadSlug,e.owner.sessionId),exact:!0})),n.invalidateQueries({queryKey:Mb(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}});function j(e){if(!e.requiresValues){h({});return}let t=BZ(o,p);return h(t.errors),t.formError?(_(t.formError),null):t.values?t.values:null}function M(e,t=!1){if(!E.actionsEnabled||A.isPending||b)return;_(void 0);let n=j(e);if(n===null)return;if(e.durable&&!t){C(e),T(!1);return}let r=VZ(e.id,n),i=a.current.get(r)??eQ();a.current.set(r,i),A.mutate({decision:e,values:n,responseId:i})}let N=D.find(e=>e.requiresValues&&e.tone===`primary`);function P(e){e.preventDefault(),E.actionsEnabled&&N&&M(N)}return(0,L.jsxs)(`article`,{ref:i,tabIndex:-1,"aria-labelledby":r,"data-interaction-id":e.id,"data-interaction-kind":e.payload.kind,"data-delivery-effect":e.delivery?.effect,className:`min-w-0 ${Yq} border border-accent/45 bg-accent/[0.065] shadow-sm shadow-black/15 outline-none focus-visible:ring-2 focus-visible:ring-accent/60`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 border-b border-accent/20 px-4 py-3`,children:[(0,L.jsx)(Xm,{"aria-hidden":`true`,size:16,className:`shrink-0 text-accent`}),(0,L.jsx)(`h3`,{id:r,className:`min-w-0 flex-1 break-words text-[14px] font-semibold leading-snug text-fg`,children:e.payload.title})]}),(0,L.jsx)(`form`,{onSubmit:P,onKeyDown:e=>{e.target instanceof HTMLButtonElement||IL({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),E.actionsEnabled&&N&&M(N))},className:`min-w-0 px-4 py-3.5`,noValidate:!0,children:(0,L.jsxs)(`fieldset`,{disabled:!E.actionsEnabled,className:`min-w-0 border-0 p-0`,children:[(0,L.jsx)(`legend`,{className:`sr-only`,children:`Interaction request`}),(0,L.jsx)(oQ,{record:e,instanceId:r,draft:p,setDraft:k,errors:m,autoFocus:t}),s&&(0,L.jsxs)(`div`,{"data-secret-fallback":!0,className:`mt-3 rounded-md border border-amber-500/35 bg-amber-500/[0.07] p-3 text-[12px] leading-snug text-amber-100/90`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(km,{"aria-hidden":`true`,size:14,className:`mt-0.5 shrink-0`}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`font-medium`,children:`Secret input is unavailable in this page.`}),(0,L.jsx)(`div`,{className:`mt-1 text-amber-100/70`,children:`Frizz will not persist or send secret values through the current RPC.`})]})]}),(0,L.jsx)(`div`,{className:`mt-2 font-medium`,children:`Use the provider's trusted secret-input flow. The thread terminal cannot answer this typed request.`})]}),O>0&&(0,L.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-md border border-amber-500/25 bg-amber-500/[0.05] px-3 py-2 text-[11px] leading-snug text-amber-100/75`,children:[(0,L.jsx)(rh,{"aria-hidden":`true`,size:13,className:`mt-0.5 shrink-0`}),(0,L.jsxs)(`span`,{children:[O===1?`One advertised choice`:`${O} advertised choices`,` cannot be safely labeled or delivered in Frizz and is not shown.`]})]}),S&&(0,L.jsxs)(`div`,{"data-durable-confirmation":!0,role:`group`,"aria-label":`Confirm ${S.label}`,className:`mt-3 rounded-md border border-amber-400/45 bg-amber-500/[0.08] p-3`,children:[(0,L.jsx)(`div`,{className:`text-[12px] font-semibold text-amber-100`,children:`This approval persists beyond the current request.`}),(0,L.jsx)(`div`,{className:`mt-1 text-[11px] leading-snug text-amber-100/75`,children:S.scope}),(0,L.jsxs)(`label`,{className:`mt-2.5 flex cursor-pointer items-start gap-2 text-[11px] leading-snug text-fg/85`,children:[(0,L.jsx)(`input`,{type:`checkbox`,autoFocus:!0,checked:w,onChange:e=>T(e.target.checked),className:`mt-0.5 accent-[var(--color-accent)]`}),(0,L.jsx)(`span`,{children:`I understand this may authorize later matching actions in this session.`})]}),(0,L.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-start gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>{C(void 0),T(!1)},className:`rounded-md border border-border px-2.5 py-1.5 text-[11px] text-muted hover:bg-panel-2 hover:text-fg`,children:`Back`}),(0,L.jsxs)(`button`,{type:`button`,disabled:!w||A.isPending,onClick:()=>M(S,!0),className:`rounded-md border border-amber-400/50 bg-amber-500/15 px-2.5 py-1.5 text-[11px] font-semibold text-amber-50 hover:bg-amber-500/25 disabled:opacity-35`,children:[`Confirm `,S.label.toLowerCase()]})]})]}),g&&(0,L.jsx)(`div`,{role:`alert`,className:`mt-3 break-words text-[11px] leading-snug text-red-300`,children:g}),(E.status??v)&&(0,L.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`mt-3 text-[11px] leading-snug text-muted`,children:E.status??v}),E.actionsEnabled&&!S&&!b&&D.length>0&&(0,L.jsxs)(`div`,{className:`mt-4 flex flex-wrap justify-start gap-2`,children:[D.map(e=>(0,L.jsxs)(`button`,{type:e===N?`submit`:`button`,"data-interaction-decision":e.id,disabled:A.isPending,"aria-describedby":e.durable?`${r}-scope-${e.id}`:void 0,onClick:e===N?void 0:()=>M(e),className:aQ(e),children:[A.isPending?`Sending…`:e.label,e.durable&&(0,L.jsx)(`span`,{className:`sr-only`,children:`; persistent approval`})]},e.id)),D.filter(e=>e.durable).map(e=>(0,L.jsx)(`span`,{id:`${r}-scope-${e.id}`,className:`sr-only`,children:e.scope},`scope-${e.id}`))]}),!sQ.has(e.payload.kind)&&(0,L.jsx)(uQ,{record:e})]})})]})}function aQ(e){let t=`rounded-md border px-2.5 py-1.5 text-[11px] font-medium outline-none transition-colors focus-visible:ring-2 focus-visible:ring-fg/50 disabled:opacity-40`;return e.tone===`primary`?`${t} border-accent/55 bg-accent/15 text-fg hover:bg-accent/25`:e.tone===`danger`?`${t} border-red-400/35 bg-red-500/[0.07] text-red-200 hover:bg-red-500/15`:`${t} border-border bg-panel text-muted hover:bg-panel-2 hover:text-fg`}function oQ({record:e,instanceId:t,draft:n,setDraft:r,errors:i,autoFocus:a}){let o=e.payload,s=(e,t)=>r(zZ(n,e,t)),c;return c=o.kind===`command-approval`||o.kind===`file-approval`||o.kind===`permission-approval`?(0,L.jsx)(gZ,{payload:o}):o.kind===`mcp-elicitation-url`?(0,L.jsx)(lQ,{url:o.url}):(0,L.jsx)(dQ,{instanceId:t,fields:o.fields,draft:n,setValue:s,errors:i,autoFocus:a}),(0,L.jsxs)(L.Fragment,{children:[`message`in o&&o.message&&(0,L.jsx)(cQ,{text:o.message}),(0,L.jsx)(`div`,{className:`message`in o&&o.message?`mt-3`:``,children:c})]})}var sQ=new Set([`command-approval`,`file-approval`,`permission-approval`]);function cQ({text:e}){return e.length>600||e.split(`
310
+ `).length>6?(0,L.jsxs)(`details`,{className:`rounded-md border border-border/70 bg-panel/60`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer px-2.5 py-2 text-[11px] text-muted outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/50`,children:`Request message`}),(0,L.jsx)(`div`,{className:`max-h-52 overflow-auto border-t border-border/60 px-2.5 py-2 whitespace-pre-wrap break-words text-[12px] leading-relaxed text-fg/80`,children:e})]}):(0,L.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-[12px] leading-relaxed text-fg/80`,children:e})}function lQ({url:e}){let t=HZ(e,location.href);return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`text-[11px] font-medium text-fg`,children:`Open this page to continue`}),(0,L.jsx)(`code`,{className:`mt-1.5 block max-h-24 overflow-auto break-all rounded-md border border-border bg-bg/40 px-2.5 py-2 font-mono-keep text-[10.5px] text-fg/80`,children:e}),t?(0,L.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:`mt-2 inline-flex items-center gap-1.5 rounded-md border border-border bg-panel px-2.5 py-1.5 text-[11px] font-medium text-fg hover:bg-panel-2`,children:[(0,L.jsx)(mm,{"aria-hidden":`true`,size:12}),`Open page`]}):(0,L.jsx)(`div`,{role:`alert`,className:`mt-1.5 break-words text-[11px] text-red-300`,children:`This request did not provide a safe http(s) URL.`})]})}function uQ({record:e}){return(0,L.jsxs)(`details`,{className:`mt-3 border-t border-border/50 pt-2 text-[10.5px] text-muted/70`,children:[(0,L.jsx)(`summary`,{className:`cursor-pointer w-fit outline-none hover:text-muted focus-visible:ring-1 focus-visible:ring-fg/50`,children:`Request details`}),(0,L.jsxs)(`dl`,{className:`mt-2 grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1`,children:[(0,L.jsx)(`dt`,{children:`Provider`}),(0,L.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:FZ(e.provider.kind)}),e.provider.name&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Reported name`}),(0,L.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.provider.name})]}),e.provider.version&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Reported version`}),(0,L.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.provider.version})]}),(0,L.jsx)(`dt`,{children:`Source`}),(0,L.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:IZ(e.source.kind)}),e.source.label&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Reported source`}),(0,L.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.source.label})]}),(0,L.jsx)(`dt`,{children:`Scope`}),(0,L.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:`This thread · this request`}),e.expiresAt&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`dt`,{children:`Expires`}),(0,L.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.expiresAt})]})]})]})}function dQ({instanceId:e,fields:t,draft:n,setValue:r,errors:i,autoFocus:a}){let o=t.findIndex(e=>!e.secret);return(0,L.jsxs)(`fieldset`,{className:`min-w-0`,children:[(0,L.jsx)(`legend`,{className:`sr-only`,children:`Requested information`}),(0,L.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:t.map((t,s)=>(0,L.jsx)(fQ,{instanceId:e,field:t,value:n[t.id],setValue:e=>r(t.id,e),error:i[t.id],autoFocus:a&&s===o},t.id))})]})}function fQ({instanceId:e,field:t,value:n,setValue:r,error:i,autoFocus:a}){let o=`${e}-${t.id}`,s=t.description?`${o}-description`:void 0,c=i?`${o}-error`:void 0,l=[s,c].filter(Boolean).join(` `)||void 0,u=(0,L.jsxs)(L.Fragment,{children:[t.label,t.required&&(0,L.jsx)(`span`,{"aria-hidden":`true`,className:`ml-0.5 text-accent`,children:`*`})]}),d=`mt-1 w-full min-w-0 rounded-md border border-border bg-bg/45 px-2.5 py-2 text-[12px] text-fg outline-none focus:border-accent focus:ring-1 focus:ring-accent/40`,f;if(t.secret)f=(0,L.jsx)(`div`,{className:`mt-1 text-[11px] text-amber-100/70`,children:`Use the secure fallback below.`});else if(t.input===`multiline`)f=(0,L.jsx)(`textarea`,{id:o,name:t.id,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,minLength:t.minLength,maxLength:t.maxLength,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,rows:4,className:`${d} resize-y`});else if(t.input===`text`){let e=t.format===`email`?`email`:t.format===`uri`?`url`:t.format===`date`?`date`:`text`;f=(0,L.jsx)(`input`,{id:o,name:t.id,type:e,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,minLength:t.minLength,maxLength:t.maxLength,placeholder:t.format===`date-time`?`2026-07-13T12:00:00Z`:void 0,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,className:d})}else if(t.input===`number`||t.input===`integer`)f=(0,L.jsx)(`input`,{id:o,name:t.id,type:`number`,step:t.input===`integer`?1:`any`,min:t.minimum,max:t.maximum,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,className:d});else if(t.input===`boolean`)f=(0,L.jsxs)(`label`,{htmlFor:o,className:`mt-1 flex cursor-pointer items-center gap-2 rounded-md border border-border bg-bg/30 px-2.5 py-2 text-[12px] text-fg/85`,children:[(0,L.jsx)(`input`,{id:o,name:t.id,type:`checkbox`,checked:n===!0,onChange:e=>r(e.target.checked),"aria-describedby":l,autoFocus:a,className:`accent-[var(--color-accent)]`}),(0,L.jsx)(`span`,{children:u})]});else if(t.input===`select`)f=(0,L.jsxs)(`select`,{id:o,name:t.id,value:typeof n==`string`?n:``,onChange:e=>r(e.target.value),required:t.required,"aria-describedby":l,"aria-invalid":!!i,autoFocus:a,className:d,children:[(0,L.jsx)(`option`,{value:``,children:`Choose an option…`}),t.options.map((e,t)=>(0,L.jsx)(`option`,{value:String(t),children:e.label},t))]});else if(t.input===`multi-select`){let e=Array.isArray(n)?n:[];f=(0,L.jsxs)(`fieldset`,{id:o,"aria-describedby":l,className:`mt-1 rounded-md border border-border bg-bg/30 px-2.5 py-2`,children:[(0,L.jsx)(`legend`,{className:`px-1 text-[11px] font-medium text-fg/85`,children:u}),(0,L.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t.options.map((n,i)=>{let o=String(i);return(0,L.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-[12px] text-fg/85`,children:[(0,L.jsx)(`input`,{type:`checkbox`,name:t.id,value:o,checked:e.includes(o),onChange:t=>r(t.target.checked?[...e,o]:e.filter(e=>e!==o)),autoFocus:a&&i===0,className:`mt-0.5 accent-[var(--color-accent)]`}),(0,L.jsx)(`span`,{children:n.label})]},o)})})]})}return(0,L.jsxs)(`div`,{className:`min-w-0`,children:[t.secret?(0,L.jsx)(`div`,{className:`text-[11px] font-medium text-fg/85`,children:u}):t.input!==`boolean`&&t.input!==`multi-select`?(0,L.jsx)(`label`,{htmlFor:o,className:`block text-[11px] font-medium text-fg/85`,children:u}):null,t.description&&(0,L.jsx)(`div`,{id:s,className:`mt-0.5 whitespace-pre-wrap break-words text-[10.5px] leading-snug text-muted`,children:t.description}),f,i&&(0,L.jsx)(`div`,{id:c,role:`alert`,className:`mt-1 text-[10.5px] text-red-300`,children:i})]})}function pQ(e){let t=e,n=``;do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return`${n}.`}function mQ(e,t){let n=t.description?.trim(),r=n&&!n.includes(`
311
311
  `)?n:void 0,i=[r?void 0:n,t.preview?.trim()].filter(Boolean).join(`
312
312
 
313
- `)||void 0;return{line:`${uQ(e)} ${t.label}${r?` — ${r}`:``}`,...i?{body:i}:{}}}var fQ=`root`;function pQ(e,t,n){return`${e}/${t}.${n}`}function mQ(e){let t=e.options??[],n=t.findIndex(e=>e.recommended),r=t.map((e,t)=>dQ(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 hQ(e,t){return!t||e.kind===`multi`?null:t.chosen}function gQ(e,t){let n=[],r=(e,i,a)=>{let{question:o,optionLabels:s}=mQ(e);n.push({path:i,spec:e,question:o,optionLabels:s,depth:a});let c=hQ(e,t.get(i));c!==null&&(e.options?.[c]?.followUps??[]).forEach((e,t)=>r(e,pQ(i,c,t),a+1))};return r(e,fQ,1),n}function _Q(e,t){return t?t.text.trim()?!0:e.kind===`multi`?(t.chosenSet??[]).length>0:t.chosen!==null:!1}function vQ(e,t){if(!_Q(e.spec,t.get(`root`)))return;let n=(r,i)=>{let a=t.get(i),o=(r.options??[]).map(e=>e.label),s=hQ(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,pQ(i,s,t)));return{questionId:e.id,question:r.question,chosen:c,...l?{text:l}:{},...u.length>0?{followUps:u}:{}}};return n(e.spec,fQ)}function yQ(e){let t=e instanceof Error?e.message:`The answer could not be sent.`;return t.length>240?`${t.slice(0,239)}…`:t}var bQ=(e,t)=>`${e}|${t}`;function xQ({thread:e,questions:t,inFlight:n=null,className:r=``}){let i=e?.id,a=t??e?.questions??[],o=sz(),[s,c]=(0,I.useState)(()=>new Map),[l,u]=(0,I.useState)(),d=(0,I.useContext)(I1),f=uz((0,I.useMemo)(()=>i?a.flatMap(e=>SQ(e).map(t=>oz.question(o,i,e.id,t))):[],[o,i,a])),p=(e,t)=>{let n=s.get(bQ(e.id,t));return{chosen:n?.chosen??null,chosenSet:n?.chosenSet??[],text:(i?f.get(oz.question(o,i,e.id,t)):void 0)??``}},m=e=>new Map(SQ(e).map(t=>[t,p(e,t)])),h=a.flatMap(e=>{let t=vQ(e,m(e));return t?[t]:[]}),g=it({mutationFn:async e=>Y.answerQuestions({slug:i,answers:e}),onSuccess:e=>{for(let t of e.answered){c(e=>{let n=new Map(e);for(let e of[...n.keys()])e.startsWith(`${t}|`)&&n.delete(e);return n});let e=a.find(e=>e.id===t);if(e&&i)for(let t of SQ(e))iz.set(oz.question(o,i,e.id,t),``)}},onError:e=>{d?.cancel(),u(yQ(e))}}),_=it({mutationFn:async e=>Y.dismissQuestions({slug:i,ids:[e]}),onError:e=>u(yQ(e))});if(!i||a.length===0)return!i||!n?.length?null:(0,L.jsx)(`section`,{"data-answers-in-flight":!0,"aria-label":`Your answer, on its way to the worker`,className:`flex min-w-0 flex-col items-end ${r}`,children:(0,L.jsx)(cY,{answers:n,queued:!0})});let v=()=>{h.length===0||g.isPending||(u(void 0),d?.dismiss(),g.mutate(h))};return(0,L.jsxs)(`section`,{"data-registered-questions":!0,"aria-label":`${a.length} question${a.length===1?``:`s`} waiting for an answer`,className:`flex min-w-0 flex-col gap-3 ${r}`,children:[a.map(e=>(0,L.jsx)(`article`,{"data-question-id":e.id,className:`flex min-w-0 flex-col gap-2`,children:(()=>{let t=gQ(e.spec,m(e)),n=t=>(0,L.jsx)(bY,{question:t.question,label:t.depth>1?`Follow-up`:void 0,aside:t.depth===1&&!e.spec.danger?(0,L.jsx)(`button`,{type:`button`,"data-dismiss-question":!0,"aria-label":`Dismiss this question`,title:`Dismiss — the worker decides it itself`,disabled:_.isPending,onClick:()=>_.mutate(e.id),className:`card-icon-offset -mx-2 -my-1 flex rounded-md p-1 text-muted/70 outline-none transition-colors hover:bg-elevated hover:text-fg disabled:opacity-40`,children:(0,L.jsx)(ah,{size:16})}):void 0,interactive:{answer:p(e,t.path),onChip:n=>{c(r=>{let i=new Map(r),a=bQ(e.id,t.path),o=i.get(a)??{chosen:null,chosenSet:[]};if(t.spec.kind===`multi`){let e=o.chosenSet.includes(n)?o.chosenSet.filter(e=>e!==n):[...o.chosenSet,n];i.set(a,{...o,chosenSet:e})}else i.set(a,{...o,chosen:o.chosen===n?null:n});return i})},onText:n=>{iz.set(oz.question(o,i,e.id,t.path),n),t.spec.kind!==`multi`&&c(n=>{let r=bQ(e.id,t.path),i=n.get(r);return!i||i.chosen===null?n:new Map(n).set(r,{...i,chosen:null})})},onSubmit:v}},t.path),r=t.slice(1);return(0,L.jsxs)(L.Fragment,{children:[n(t[0]),r.length>0&&(0,L.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:r.map(e=>(0,L.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:n(e)},e.path))})]})})()},e.id)),l&&(0,L.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-red-300`,children:l}),g.isPending&&(0,L.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[11px] leading-snug text-muted`,children:`Sending…`}),(0,L.jsx)(`div`,{className:`flex justify-start`,children:(0,L.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:h.length===0||g.isPending,onClick:v,onMouseDown:e=>e.preventDefault(),className:`rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:`Send answers`})})]})}function SQ(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,fQ),t}function CQ(e){return(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).length}function wQ(e,t={}){let n=(e.subAgents??[]).filter(e=>Xc(e)&&e.state===`running`).length,r=(e.bgShells??[]).filter(e=>e.state===`running`).length,i=t.watchers===!1?0:CQ(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 TQ(e){return(e.subAgents??[]).some(e=>Xc(e)&&e.state===`running`)}function EQ(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length}function DQ(e){return TQ(e)||EQ(e)>0}function OQ(e,t){return ul(t)??(kQ(e)?`Background shells running`:`Awaiting`)}function kQ(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length>0&&!TQ(e)&&CQ(e)===0&&AQ(e).length===0}function AQ(e){return(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`)}var jQ={id:``,subAgents:[],bgShells:[],watches:[]},MQ=[];function NQ(e,t){let n=new Set((e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).map(e=>e.target));return OH(t).filter(e=>!n.has(e.ref))}function PQ({watch:e}){return(0,I.useEffect)(()=>{e.url&&Of([e.ref])},[e.url,e.ref]),e.url?(0,L.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-gh-ref":e.ref,className:`${rJ} text-[12px]`,children:e.ref}):(0,L.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.ref})}var FQ={mergeable:`no conflicts`,blocked:`merge blocked`,conflicting:`has conflicts`,unknown:null};function IQ(e){return e.state!==`open`||e.merge===`blocked`&&e.checks!==`passing`&&e.checks!==`none`?null:FQ[e.merge]}var LQ=`shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`;function RQ({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 ${LQ}`})}function zQ(){return(0,L.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 16 16`,width:12,height:12,fill:`none`,stroke:`currentColor`,overflow:`visible`,className:LQ,style:{color:wE.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 BQ({status:e}){return e?e.state===`merged`?(0,L.jsx)(bm,{size:12,className:LQ,style:{color:wE.fgDone}}):e.state===`closed`?(0,L.jsx)(xm,{size:12,className:LQ,style:{color:wE.fgDanger}}):e.checks===`failing`?(0,L.jsx)(um,{size:12,className:LQ,style:{color:wE.fgDanger}}):e.checks===`passing`?(0,L.jsx)(am,{size:12,className:LQ,style:{color:wE.fgSuccess}}):e.gated>0&&e.running===0?(0,L.jsx)(im,{size:12,className:LQ,style:{color:wE.fgAttention}}):e.checks===`running`?(0,L.jsx)(zQ,{}):(0,L.jsx)(om,{size:12,className:`${LQ} text-muted/60`}):(0,L.jsx)(om,{size:12,className:`${LQ} text-muted/60`})}function VQ(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 HQ(e){if(!e)return`Checking…`;if(e.state===`merged`)return`Merged`;if(e.state===`closed`)return`Closed`;let t=VQ(e),n=IQ(e);return[t||`No checks`,n].filter(e=>e!==null).join(` · `)}var UQ=`group relative col-span-4 grid grid-cols-subgrid items-baseline rounded-sm text-[12px] leading-5`,WQ=`group relative col-span-4 flex items-baseline rounded-sm text-[12px] leading-5`,GQ=`ml-1.5 min-w-0 truncate font-medium text-fg/90`,KQ=`ml-3 min-w-0 truncate text-right text-muted/70`,qQ=`outline-none after:absolute after:inset-0 after:rounded-sm focus-visible:after:ring-1 focus-visible:after:ring-fg/60`;function JQ(){return(0,L.jsx)(tm,{size:13,"aria-hidden":!0,className:`${LQ} ml-[3px] -mr-[4px] text-muted/35 transition-colors group-hover:text-muted/70`})}function YQ({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?`${GQ} flex-1`:GQ,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} ${qQ} 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} ${qQ} 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?WQ:UQ} ${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:KQ,children:n}),m?(0,L.jsx)(JQ,{}):(0,L.jsx)(`span`,{})]})}function XQ({watch:e}){let t=e.github,n=EH(e.target);return(0,I.useEffect)(()=>{n&&Of([e.target])},[n,e.target]),(0,L.jsx)(YQ,{testKind:`github`,testId:e.target,mark:(0,L.jsx)(BQ,{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:[HQ(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 ZQ(e,t){return(e.bgShells??[]).find(e=>e.id===t||e.taskId===t||e.label===t)}function QQ(e){return(e.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`)}function $Q({watch:e,thread:t,slug:n,now:r}){let i=ZQ(t,e.target);if(i)return(0,L.jsx)(e$,{shell:i,slug:n,now:r,testId:e.target});let a=yE(e.createdAt,r);return(0,L.jsx)(YQ,{testKind:`shell`,testId:e.target,mark:(0,L.jsx)(eh,{size:12,className:`${LQ} text-shell`}),name:e.target,title:e.target,status:a?`running · ${a}`:`running`})}function e$({shell:e,slug:t,now:n,testId:r}){let i=yE(e.startedAt,n),a=e.id&&!e.outputUnavailable;return(0,L.jsx)(YQ,{testKind:`shell`,testId:r??e.id??e.label,mark:(0,L.jsx)(eh,{size:12,className:`${LQ} text-shell`}),name:e.label,onOpen:a?()=>tp(t,e.id,{label:e.label,startedAt:e.startedAt}):void 0,title:a?`Read this shell's output — running for ${i}`:e.label,status:i?`running · ${i}`:`running`})}function t$({watch:e,now:t}){let n=Date.parse(e.timer?.fireAt??``),r=Number.isFinite(n)?n>t?`fires in ${_E(n-t)}`:`firing…`:`armed`;return(0,L.jsx)(YQ,{testKind:`timer`,testId:e.target,mark:(0,L.jsx)(dm,{size:12,className:`${LQ} 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 n$(e){return(e.subAgents??[]).filter(e=>Xc(e)&&e.state===`running`)}function r$({agent:e,slug:t,now:n}){let r=yE(e.startedAt,n),i=e.subagentType?.replace(/^frizz:/,``);return(0,L.jsx)(YQ,{testKind:`agent`,testId:e.id??e.label,mark:(0,L.jsx)(RQ,{tone:`border-accent`}),name:e.label,onOpen:e.id?()=>ep(t,e.id,{label:e.label,subagentType:e.subagentType,startedAt:e.startedAt}):void 0,title:e.id?`Open this sub-agent — working for ${r}`:e.label,status:[i,r].filter(Boolean).join(` · `)})}function i$(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=ZQ(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 a$(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=QQ(e).filter(t=>r(ZQ(e,t.target)?.startedAt??t.createdAt));return{prs:i,shells:[...a,...i$(e,t.hints??[],a)],agents:n$(e).filter(e=>r(e.startedAt)),timers:AQ(e).filter(e=>r(e.createdAt))}}function o$(e,t={}){let n=a$(e,t);return n.prs.length+n.shells.length+n.agents.length+n.timers.length>0}function s$(e,t,n={}){let{prs:r,shells:i,agents:a,timers:o}=a$(e,n);return[{head:`Sub-agents`,rows:a.map(n=>(0,L.jsx)(r$,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:i.map(n=>(0,L.jsx)($Q,{watch:n,thread:e,slug:e.id,now:t},n.id))},{head:`Pull requests`,rows:r.map(e=>(0,L.jsx)(XQ,{watch:e},e.id))},{head:`Timers`,rows:o.map(e=>(0,L.jsx)(t$,{watch:e,now:t},e.id))}].filter(e=>e.rows.length>0)}function c$({group:e,first:t}){let n=`col-span-4 text-[10.5px] uppercase tracking-wide text-muted/45 ${t?``:`mt-2.5`}`;return e.onToggle?(0,L.jsxs)(`button`,{type:`button`,onClick:e.onToggle,"aria-expanded":!e.collapsed,onMouseDown:e=>e.stopPropagation(),className:`${n} flex items-baseline rounded-sm text-left transition-colors hover:text-muted/80`,children:[(0,L.jsx)(`span`,{children:e.head}),e.count!==void 0&&(0,L.jsx)(`span`,{className:`ml-1.5 tabular-nums`,children:e.count}),(0,L.jsx)(tm,{size:10,"aria-hidden":!0,className:`${LQ} ml-[5px] transition-transform ${e.collapsed?``:`rotate-90`}`})]}):(0,L.jsx)(`div`,{className:n,children:e.head})}function l$({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)(c$,{group:e,first:t===0}),!e.collapsed&&e.rows]},e.head))})]})}function u$(e){return e?.awaitingBackground===!0&&e.runtime===`turn-idle`&&e.bgSnoozed!==!0}var d$=`Hides card until new activity is detected`;function f$({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:d$,className:`disabled:opacity-45 ${iJ}`,children:[(0,L.jsx)(Tm,{size:12,className:LY}),`Snooze`]}),(0,L.jsx)(`span`,{className:nJ,children:d$})]})}function p$({thread:e,fence:t,onSnooze:n,onSnoozeFailed:r,notAfter:i}){let a=e??jQ,o=t??(e?.lastFence?.kind===`awaiting`?e.lastFence:void 0),s=o?.hints??MQ,c=TQ(a),l=PH(o?.body),u=pK(l??``),d=s$(a,oE(),{hints:s,notAfter:i}),f=NQ(a,s),p=i===void 0&&e!==void 0&&u$(e)&&yX(e).snooze;return(0,L.jsxs)($q,{"data-awaiting-background":!0,icon:kQ(a)?eh:Tm,label:(0,L.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:OQ(a,s)}),aside:f.length===1?(0,L.jsx)(PQ,{watch:f[0]}):void 0,className:p?`pb-0`:``,children:[l?(0,L.jsx)(fq,{className:`md-body ${Gq}`,html:u}):d.length===0&&!DQ(a)?(0,L.jsx)(`p`,{className:eJ,children:DH}):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)(PQ,{watch:e},e.ref))}),d.length===0&&DQ(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 `,wQ(a,{watchers:!1}),` it dispatched. It returns to the queue on its own when the work comes back.`]}):(0,L.jsxs)(L.Fragment,{children:[wQ(a,{watchers:!1}),` `,EQ(a)===1?`is`:`are`,` still running. It resumes on its own when`,` `,EQ(a)===1?`it finishes`:`one of them finishes`,`.`]})}),(0,L.jsx)(l$,{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 ${Jq}`,children:(0,L.jsx)(f$,{thread:e,onSnooze:n,onSnoozeFailed:r})}):null]})}function m$(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 h$(e,t=Date.now()){return e!==void 0&&DT(e,t)!==void 0}function g$(){let[e,t]=(0,I.useState)(()=>Date.now());return(0,I.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function _$({thread:e}){let t=g$(),[n,r]=(0,I.useState)(!1),i=DT(e,t);if(!i)return null;let a=Date.parse(i),o=Ww(i,t).replace(/^(Today|Tomorrow)/,e=>e.toLowerCase()),s=e.snoozePrompt?.trim();async function c(){r(!0);try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:null,prompt:null}),Z(`Snooze cleared`)}catch(e){Z((e instanceof Error?e.message:`Wake failed`).slice(0,100))}finally{r(!1)}}return(0,L.jsxs)($q,{"data-snooze-card":!0,icon:Tm,label:`Snoozed`,children:[(0,L.jsx)(`div`,{"data-snooze-countdown":!0,title:new Date(a).toLocaleString(),className:`text-[22px] font-semibold leading-8 tracking-tight text-fg tabular-nums`,children:xE(a-t)}),(0,L.jsx)(`p`,{className:eJ,children:s?(0,L.jsxs)(L.Fragment,{children:[`Resumes `,o,` and sends: “`,Jw(s),`”`]}):(0,L.jsxs)(L.Fragment,{children:[`Returns to the queue `,o,`.`]})}),e.foreign!==!0&&(0,L.jsx)(tJ,{children:(0,L.jsx)(`button`,{type:`button`,"data-snooze-wake-now":!0,disabled:n,onClick:()=>void c(),className:`${iJ} disabled:cursor-not-allowed disabled:opacity-45`,children:`Wake now`})})]})}function v$({at:e,fallbackAt:t,className:n=``}){let r=oE(),i=HT(e,t),a=UT(i,r);return!a||!i?null:(0,L.jsx)(`time`,{dateTime:i,className:n,children:a})}var y$=1500;function b$(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},y$),a},fail(t){t===n&&(i(),e(!1))},dispose(){n++,i()}}}var x$=`Could not copy terminal command`,S$={attach:`Attach command copied`,resume:`Resume command copied`},C$={attach:`Copy command to attach to this thread's live terminal`,resume:`Copy command to resume this thread in a new terminal`},w$=e=>[`terminalCommand`,e];function T$(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 E$(e){let t=T$(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 CR(n),r}function D$(e){let t=it({mutationFn:()=>E$(e)});return e=>t.mutate(void 0,{onSuccess:t=>{e?.onSuccess?.(),Z(S$[t])},onError:t=>{e?.onError?.(),Z(t instanceof Error?`${x$}: ${t.message}`:x$,{duration:7e3})}})}function O$({slug:e}){let[t,n]=(0,I.useState)(!1),r=(0,I.useRef)(null);r.current||=b$(n,{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)});let i=Ve(),a=D$(e);(0,I.useEffect)(()=>()=>r.current?.dispose(),[]);function o(){i.prefetchQuery({queryKey:w$(e),queryFn:()=>T$(e),staleTime:15e3})}function s(){let t=i.getQueryData(w$(e));if(t){CR(t.command).then(()=>{r.current?.begin(),Z(S$[t.mode])},()=>Z(x$,{duration:7e3}));return}a({onSuccess:()=>r.current?.begin()})}let c=i.getQueryData(w$(e)),l=t?c?S$[c.mode]:`Terminal command copied`:c?C$[c.mode]:`Copy terminal command`;return(0,L.jsx)(Lj,{label:l,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":l,title:l,onClick:s,onPointerEnter:o,onFocus:o,className:eD,children:t?(0,L.jsx)(Qp,{size:14,strokeWidth:2.2,className:`text-fg`}):(0,L.jsx)(eh,{size:14,strokeWidth:1.8})})})}function k$(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 A$(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 j$(e){return`legacy:${e.role}:${e.kind??`message`}:${e.at??``}:${e.text}`}function M$(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??j$(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 N$(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 P$(e,t){let n=e.map(e=>e.message);return e.filter((e,r)=>!N$(n,r,t))}var F$=new Set([`agent`,`follow up`,`interrupt`,`send message`,`spawn agent`,`wait for agents`]),I$=new Set([`poll process`,`wait`]);function L$(e){return(e.split(`__`).pop()||e).replaceAll(`_`,` `).trim()}function R$(e){return L$(e).toLowerCase()}function z$(e){return e.prompt!==void 0||e.agentId!==void 0||e.sendTo!==void 0||e.sendBody!==void 0||e.backgroundState!==void 0&&!H$(e)||V$(e)||B$(e)||F$.has(R$(e.name))}function B$(e){return e.ask!==void 0&&e.ask.length>0&&e.status!==void 0&&e.status!==`pending`}function V$(e){return e.outputImage!==void 0||e.sentImages!==void 0&&e.sentImages.length>0}function H$(e){return e.backgroundState===`unknown`&&I$.has(R$(e.name))}function U$(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=>!z$(e))?t:null}return e.text.trim()||e.tools.length===0?null:e.tools.every(e=>!z$(e))?e.tools:null}function W$(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 G$(e){if(e.role!==`assistant`||e.kind||e.queued)return null;if(!e.parts?.length)return K$(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 K$(n.tools)}return null}function K$(e){let t=[];for(let n=e.length-1;n>=0&&!z$(e[n]);n--)t.unshift(e[n]);return t.length>0?t:null}function q$(e){if(e.role!==`assistant`||e.kind||e.queued)return null;let t=[],n=e=>{for(let n of e){if(z$(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 J$(e,t){return Y$(e,new Set(t))}function Y$(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 X$(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 Z$(e){let t=[],n=null;return e.forEach((e,r)=>{if(W$(e))return;if(e.queued){t.push({message:e,messageIndex:r});return}let i=U$(e);if(i&&n){n.message=X$(n.message,i,e.at);return}let a=n?q$(e):null,o=a?J$(e,a):e;a&&n&&(n.message=X$(n.message,a,e.at));let s={message:o,messageIndex:r};t.push(s),G$(o)?(s.runStartedAt=o.at,n=s):n=null}),t}function Q$(e){return e.status===`completed`||e.status===`failed`||e.status===`cancelled`}function $$(e){let t=e1(e);return t?.tools.some(e=>!Q$(e))?t.tools.at(-1):void 0}function e1(e){let t=t1(e);if(!t)return;let n=G$(t.message);return n?{tools:n,at:t.message.at}:void 0}function t1(e){for(let t=e.length-1;t>=0;t--)if(!e[t].message.queued)return e[t]}function n1(e){let t=t1(e);if(t)return G$(t.message)?t.runStartedAt??t.message.at:t.message.at}function r1(e){return e.runStartedAt??e.message.at}function i1(e){let t=G$(e);return t?Y$(e,new Set(t)):e}function a1(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].message;if(!r.queued){G$(r)&&(t=r);break}}if(!t)return[...e];let n=[];for(let r of e){let e=r.message===t?i1(r.message):r.message;W$(e)||n.push(e===r.message?r:{...r,message:e})}return n}function o1(e){return e.detail?.trim()||void 0}var s1={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 c1(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=s1[i.toLowerCase()];return a?a+(r===-1?``:n.slice(r)):n.charAt(0).toUpperCase()+n.slice(1)}function l1(e,t){let n=t?.trim().replace(/\/+$/,``);if(!n||n===`/`||!n.startsWith(`/`))return e;let r=e.replaceAll(`${n}/`,``),i=/^(\/(?:Users|home)\/[^/]+)(?:\/|$)/.exec(n)?.[1];return i?r.replaceAll(`${i}/`,`~/`):r}function u1(e,t){return l1(d1(e),t)}function d1(e){let t=R$(e.name),n=o1(e),r=n?` ${n}`:``;return t===`bash`||t===`exec`||t===`run command`?c1(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 ${L$(e.name)||`a tool`}`}var f1=new Set([`edit`,`multiedit`,`write`,`apply patch`]);function p1(e){let t=new Set;for(let n of e){for(let e of n.edits??(n.edit?[n.edit]:[]))e.file.trim()&&t.add(e.file.trim());if(n.edit||n.edits?.length)continue;let e=n.detail?.trim();e&&f1.has(R$(n.name))&&t.add(e)}return t.size}function m1(e,t=0){let n=`Ran ${e} tool ${e===1?`call`:`calls`}`;return t===0?n:`${n}, edited ${t} file${t===1?``:`s`}`}function h1(e){return e>0?`${m1(e)}. Thinking…`:`Thinking…`}function g1(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function _1(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function v1(e,t){let n=g1(e,t);if(n)try{let e=new URL(n);return e.protocol===`https:`||e.protocol===`http:`?e.href:void 0}catch{return}}function y1({directive:e,icon:t,title:n,meta:r,children:i}){return(0,L.jsxs)(`section`,{"data-codex-directive":e.name,className:`min-w-0 ${Kq} 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 b1({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 x1({directive:e}){let t=e.attrs,n=g1(t,`display_name`)??g1(t,`skill_name`)??`Artifact template`,r=g1(t,`artifact_kind`),i=g1(t,`skill_name`),a=g1(t,`skill_directory`),[o,s]=(0,I.useState)(!!a);return(0,L.jsxs)(y1,{directive:e,icon:(0,L.jsx)(Am,{size:15}),title:n,meta:r?`${r} template`:`Template`,children:[i&&(0,L.jsx)(b1,{mono:!0,children:i.startsWith(`$`)?i:`$${i}`}),o&&a&&(0,L.jsx)(`img`,{src:jS(`${a}/assets/preview.png`),alt:`${n} template preview`,loading:`lazy`,onError:()=>s(!1),className:`ml-6 mt-2 max-h-44 max-w-[calc(100%-1.5rem)] rounded-md border border-border object-contain`})]})}function S1({directive:e}){let t=e.attrs,n=g1(t,`file`),r=_1(t,`start`),i=_1(t,`end`)??r,a=_1(t,`priority`),o=n?`${n}${r?`:${r}${i&&i!==r?`-${i}`:``}`:``}`:`Code location unavailable`;return(0,L.jsxs)(y1,{directive:e,icon:(0,L.jsx)(Fm,{size:15}),title:g1(t,`title`)??`Review finding`,meta:a===void 0?void 0:`P${a}`,children:[g1(t,`body`)&&(0,L.jsx)(b1,{children:g1(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)(b1,{mono:!0,children:o})]})}var C1={"git-stage":[zm,`Changes staged`],"git-commit":[ym,`Commit created`],"git-create-branch":[vm,`Branch created`],"git-push":[ih,`Branch pushed`],"git-create-pr":[Cm,`Pull request created`]};function w1({directive:e}){let[t,n]=C1[e.name],r=g1(e.attrs,`branch`),i=v1(e.attrs,`url`),a=`${n}${e.attrs.isDraft===!0?` as draft`:``}`;return(0,L.jsx)(y1,{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 T1({directive:e}){let t=g1(e.attrs,`threadId`),n=g1(e.attrs,`pendingWorktreeId`);return(0,L.jsx)(y1,{directive:e,icon:(0,L.jsx)(Rm,{size:15}),title:n?`Thread setup queued`:`Thread created`,meta:(t||n)&&(0,L.jsx)(`span`,{className:`font-mono-keep`,children:t??n})})}function E1({directive:e}){let t=g1(e.attrs,`reason`);return(0,L.jsx)(y1,{directive:e,icon:(0,L.jsx)(Kp,{size:15}),title:`Archive suggested`,meta:t})}function D1(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 O1({directive:e}){let t=e.attrs,n=g1(t,`mode`),r=g1(t,`name`)??`Automation`,i=D1(t.rrule),a=[r,n,g1(t,`status`),i].filter(Boolean).join(` · `);return(0,L.jsx)(y1,{directive:e,icon:(0,L.jsx)(Zp,{size:15}),title:`Automation suggested`,meta:a,children:g1(t,`prompt`)&&(0,L.jsx)(b1,{children:g1(t,`prompt`)})})}function k1({directive:e}){return e.name===`artifact-template`?(0,L.jsx)(x1,{directive:e}):e.name===`code-comment`?(0,L.jsx)(S1,{directive:e}):e.name.startsWith(`git-`)?(0,L.jsx)(w1,{directive:e}):e.name===`created-thread`?(0,L.jsx)(T1,{directive:e}):e.name===`archive`||e.name===`archive-thread`?(0,L.jsx)(E1,{directive:e}):(0,L.jsx)(O1,{directive:e})}var A1;function j1(){return A1??=By(async()=>{let{default:e}=await import(`./mermaid.core-CuxdqC2S.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)),A1}function M1({source:e}){let t=(0,I.useId)(),[n,r]=(0,I.useState)({}),i=$K(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 j1().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:`${Kq} 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 ${Kq} 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 ${Kq} bg-panel-2`})}var N1=(0,I.createContext)(null),P1=(0,I.createContext)(null);function F1(){let e=(0,I.useContext)(N1),t=(0,I.useContext)(P1);return e??t}var I1=(0,I.createContext)(null);function L1(e){return e.status===`pending`&&e.backgroundState===`background`}function R1(e){let t=[];for(let n of e)for(let e of n.tools)L1(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 z1(e){return e.map(e=>{if(!e.tools.some(L1))return e;let t=e.tools.filter(e=>!L1(e)),n=e.parts?.map(e=>e.kind===`tools`?{...e,tools:e.tools.filter(e=>!L1(e))}:e).filter(e=>e.kind!==`tools`||e.tools.length>0);return{...e,tools:t,parts:n}})}function B1({slug:e,onStatusApplied:t,onClose:n,virtualized:r=!1,showReturnToQueue:i=!1}){let a=Dp(kC(),e);return(0,L.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,L.jsx)(Q1,{slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:i}),(0,L.jsx)(V1,{slug:e,virtualized:r}),a&&(0,L.jsx)(KX,{thread:a,sticky:!0,safeArea:!0,onArchived:t})]})}function V1({slug:e,virtualized:t}){let n=kC(),r=Dp(n,e),i=r?.runtime===`running`||r?.runtime===`spawning`,a=D$(e),o=UC(e,{poll:i}),s=Ve(),c=(0,I.useRef)(!1),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(null),p=(0,I.useMemo)(()=>o.data?.messages??[],[o.data]),m=(0,I.useMemo)(()=>R1(p),[p]),h=(0,I.useMemo)(()=>z1(p),[p]),g=(0,I.useMemo)(()=>f0(h),[h]),_=(0,I.useMemo)(()=>i?m$(h):void 0,[i,h]),v=_&&_.index>=0?_.index:g,y=(0,I.useMemo)(()=>Z$(h),[h]),b=i?e1(y):void 0,x=i?$$(y):void 0,S=x?u1(x,n?.projectDir):void 0,C=i?n1(y):void 0,w=u$(r),T=(0,I.useMemo)(()=>{let e=i?a1(y):y;return P$(e,p0(e,v,w))},[y,i,v,w]),E=i,D=(0,I.useMemo)(()=>CJ(p),[p]),O=(0,I.useMemo)(()=>vJ(p,r?.answersInFlight),[p,r?.answersInFlight]),k=(0,I.useMemo)(()=>NY(p),[p]),A={thread:r,showWorking:E,registeredDone:Wq(r,g>=0?h[g]?.text:void 0),restedCard:aJ(r,g>=0?h[g]?.text:void 0),errorVisible:sJ(h,r?.providerError)},{answeringForMessage:j}=gY(e,p),M=(0,I.useMemo)(()=>AJ(p,r?.questions??[]),[p,r?.questions]),N=(0,I.useRef)(null),[P,ee]=(0,I.useState)(null),F=o.data?.messages.length??0,te=!o.isLoading;(0,I.useEffect)(()=>{if(t)return;let e=N.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<=4&&(e.scrollTop=e.scrollHeight)},[F,i,t]);let ne=(0,I.useCallback)(async()=>{if(c.current)return;let t=s.getQueryData([`transcript`,e]),n=t?.beforeCursor,r=t?.transcriptKey;if(!(!t?.hasEarlier||!n||!r)){c.current=!0,u(!0),f(null);try{let t=await Y.threadTranscriptEarlier({slug:e,cursor:n}),i=s.getQueryData([`transcript`,e]);if(!i?.transcriptKey||i.transcriptKey!==r||t.transcriptKey!==r){await o.refetch(),Z(`Transcript changed while loading history; refreshed the current session`);return}s.setQueryData([`transcript`,e],mx(i,t))}catch(e){let t=e instanceof Error?e.message:`Could not load earlier transcript history`;f(t)}finally{c.current=!1,u(!1)}}},[o,s,e]);return(0,L.jsx)(N1.Provider,{value:e,children:(0,L.jsxs)(`div`,{"data-drawer-scroll-ready":o.isPending?`false`:`true`,className:`flex-1 min-h-0 flex flex-col overflow-hidden outline-none`,children:[(0,L.jsxs)(`div`,{className:`relative min-h-0 flex-1 flex flex-col`,children:[(0,L.jsx)(`div`,{ref:N,"data-drawer-transcript-scroll":!0,"data-virtualized-transcript-scroll":t||void 0,tabIndex:t?0:void 0,role:t?`region`:void 0,"aria-label":t?`Thread conversation`:void 0,"aria-busy":t&&l?!0:void 0,className:`relative min-h-0 flex-1 overflow-y-auto pb-3 outline-none [overflow-anchor:none] focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/60`,children:t&&F>0?(0,L.jsx)(X1,{slug:e,transcriptRef:N,transcriptKey:o.data?.transcriptKey,messages:h,paired:D,inFlightAnswers:O,answeringForMessage:j,thread:r,running:i,copyTerminalCommand:a,transportFallback:o.transportFallback,isFetching:o.isFetching,refresh:()=>void o.refetch(),retryLiveUpdates:o.retryLiveUpdates,hasEarlier:o.data?.hasEarlier===!0,beforeCursor:o.data?.beforeCursor,loadingEarlier:l,earlierError:d,loadEarlier:()=>void ne(),jumpOverlay:P}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(QZ,{thread:r,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(xQ,{thread:r,inFlight:O,className:`px-6 pt-5`}),o.transportFallback&&(0,L.jsxs)(`div`,{"data-transcript-sync-fallback":!0,className:`mx-6 mt-3 flex flex-wrap items-center gap-2.5 rounded-xl border border-border-strong bg-panel-2 px-4 py-2.5 text-[12px]`,title:o.transportFallback.kind===`payload-too-large`?`Live payload ${o.transportFallback.actualBytes} bytes; socket limit ${o.transportFallback.maxBytes} bytes`:`Transcript read budget reached (${o.transportFallback.scope}); retry after about ${o.transportFallback.retryAfterMs}ms`,children:[(0,L.jsx)(rh,{size:13,className:`shrink-0 text-muted`}),(0,L.jsxs)(`div`,{className:`min-w-[180px] flex-1 leading-snug text-fg/85`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Live transcript updates paused.`}),` `,o.transportFallback.kind===`payload-too-large`?`The transcript is too large for push; the last complete HTTP-loaded copy remains visible.`:`The live read budget was reached; the last complete copy remains visible. Retry in a moment.`]}),(0,L.jsx)(`button`,{type:`button`,disabled:o.isFetching,onClick:()=>void o.refetch(),className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel disabled:opacity-40`,children:o.isFetching?`Refreshing…`:`Refresh once`}),(0,L.jsx)(`button`,{type:`button`,onClick:o.retryLiveUpdates,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel`,children:`Retry live`})]}),(0,L.jsx)(`div`,{"data-transcript-column":!0,className:`flex min-h-full flex-col px-6 py-5`,children:F===0?(0,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted`,children:o.isPending?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(_2,{}),` Loading…`]}):i?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(_2,{}),` Session starting…`]}):zY(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:[_0(T.map(e=>e.message),(e,t)=>{let n=T[t].messageIndex;return(0,L.jsx)(Q0,{m:e,answering:j(e),showSendButton:!0,paired:D[n],staleAwaiting:v>=0&&n<v,restingCardShown:n===g&&w,restedAt:_&&n===_.index?_.at??``:void 0,shadowedBy:M.get(n),thread:r},t)},e=>!!e.queued),te&&q1(A)!==null&&(0,L.jsx)(LJ,{h:J1(A,T.map(e=>e.message))}),te&&(0,L.jsx)(Y1,{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)(l2,{policy:r.permPolicy,denies:r.permDenies})}):null,p.some(e=>e.queued)&&(0,L.jsx)(LJ,{}),(0,L.jsx)(`div`,{className:`flex flex-col gap-3.5`,children:p.map((e,t)=>e.queued?(0,L.jsx)(Q0,{m:e,paired:D[t]},`q${t}`):null)})]})})]})}),(0,L.jsx)(`div`,{ref:ee,"data-transcript-overlay":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-end p-4 [&>*]:pointer-events-auto`})]}),(0,L.jsx)(`div`,{"data-thread-chat-footer":!0,className:`z-10 shrink-0 border-t border-border/60 bg-panel`,children:(0,L.jsx)(uX,{slug:e,onTerminal:a,ops:(0,L.jsx)(u2,{slug:e,transcriptShells:m,className:`px-1 pt-1.5`})})})]})})}var H1=700,U1=250,W1=(()=>{try{return localStorage.getItem(`frizz.debugScroll`)===`1`}catch{return!1}})();function G1(e){return e?.pendingInteraction===!0}function K1(e){return G1(e)?void 0:e?.pendingAsk}function q1({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`:K1(e)?`pending-ask`:e?.runtime===`perm-prompt`&&!G1(e)?`perm-prompt`:t?`working`:e?.providerError?i?null:`provider-error`:h$(e)?`snooze`:u$(e)?`resting`:n?`registered-done`:r?`rested`:null}function J1(e,t){return q1(e)===`working`?g0(t):14}function Y1({state:e,slug:t,retryText:n,onTerminal:r,liveRuntimeStart:i,liveActivityLabel:a,liveToolRun:o}){let s=e.thread;switch(q1(e)){case`provider-fault`:return(0,L.jsx)(o2,{slug:t,sessionId:s.sessionId,fault:s.providerFault,retryText:n});case`provider-error`:return(0,L.jsx)(cJ,{error:s.providerError});case`limit-pause`:return(0,L.jsx)(s2,{slug:t,sessionId:s.sessionId,pause:s.limitPause});case`pending-ask`:return(0,L.jsx)(d2,{ask:K1(s),onTerminal:r});case`perm-prompt`:return(0,L.jsx)(c2,{onTerminal:r});case`working`:return(0,L.jsx)(v2,{since:s?.lastUserAt,startedAt:i,activityLabel:a,run:o});case`snooze`:return(0,L.jsx)(_$,{thread:s});case`resting`:return(0,L.jsx)(p$,{thread:s});case`registered-done`:return(0,L.jsx)(a2,{fenceKind:`done`,body:s.lastFence.body,hints:[]});case`rested`:return(0,L.jsx)(oJ,{thread:s});default:return null}}function X1({slug:e,transcriptRef:t,transcriptKey:n,messages:r,paired:i,inFlightAnswers:a,answeringForMessage:o,thread:s,running:c,copyTerminalCommand:l,transportFallback:u,isFetching:d,refresh:f,retryLiveUpdates:p,hasEarlier:m,beforeCursor:h,loadingEarlier:g,earlierError:_,loadEarlier:v,jumpOverlay:y}){let b=AC(),x=(0,I.useMemo)(()=>Z$(r),[r]),S=c?e1(x):void 0,C=c?$$(x):void 0,w=C?u1(C,b):void 0,T=c?n1(x):void 0,E=(0,I.useMemo)(()=>f0(r),[r]),D=(0,I.useMemo)(()=>c?m$(r):void 0,[c,r]),O=D&&D.index>=0?D.index:E,k=u$(s),A=(0,I.useMemo)(()=>{let e=c?a1(x):x;return P$(e,p0(e,O,k))},[x,c,O,k]),j=c,M=(0,I.useMemo)(()=>M$(A.map(e=>e.message),p0(A,O,k),u0).map(e=>{let t=A[e.messageIndex];return{...e,messageIndex:t.messageIndex,stampAt:r1(t)}}),[A,O,k]),N=(0,I.useMemo)(()=>NY(r),[r]),P=Wq(s,E>=0?r[E]?.text:void 0),ee=aJ(s,E>=0?r[E]?.text:void 0),F=sJ(r,s?.providerError),te={thread:s,showWorking:j,registeredDone:P,restedCard:ee,errorVisible:F},ne=q1(te)!==null,re=(0,I.useMemo)(()=>J1({thread:s,showWorking:j,registeredDone:P,restedCard:ee,errorVisible:F},A.map(e=>e.message)),[A,j,s,P,ee,F]),ie=(0,I.useMemo)(()=>{let e=[],t=new Map,n=r.length-1;for(let[i,a]of DJ(r,s?.questions??[],{atRest:!c})){if(i>=n){e.push(...a);continue}let r=-1;for(let e=0;e<M.length&&!(M[e].messageIndex>i);e++)r=e;let o=t.get(r);o?o.push(...a):t.set(r,[...a])}return{byRow:t,tail:e}},[M,r,c,s?.questions]),ae=(0,I.useMemo)(()=>AJ(r,s?.questions??[]),[r,s?.questions]),oe=(0,I.useMemo)(()=>{let e=[{key:`head-anchor`,kind:`head-anchor`}];u&&e.push({key:`transport-fallback`,kind:`transport-fallback`}),(m||g||_)&&e.push({key:`earlier-history:${h??`complete`}`,kind:`earlier-history`});let t=ie.byRow.get(-1);t&&e.push({key:`questions:head`,kind:`questions`,questions:t}),M.forEach((t,n)=>{e.push({...t,kind:`message`});let r=ie.byRow.get(n);r&&e.push({key:`questions:${t.key}`,kind:`questions`,questions:r})}),e.push({key:`interactions`,kind:`interactions`}),ne&&e.push({key:`runtime-status`,kind:`runtime-status`});let n=ne||M.length>0?14:0;return r.forEach((t,r)=>{if(!t.queued)return;let i=`queued:${t.deliveryId??t.sourceId??r}`;e.push({key:i,kind:`queued`,message:t,messageIndex:r,gap:n}),n=14}),e},[h,_,m,ne,g,M,r,ie,u]),se=jw({count:oe.length,getScrollElement:()=>t.current,getItemKey:e=>oe[e]?.key??e,estimateSize:e=>{let t=oe[e];return t?t.kind===`head-anchor`||t.kind===`interactions`?1:t.kind===`earlier-history`?42:t.kind===`transport-fallback`?76:t.kind===`runtime-status`?54:t.kind===`questions`?220:t.kind===`message`?108+t.gap:82+t.gap:80},overscan:8,paddingStart:20,paddingEnd:20,anchorTo:`end`,followOnAppend:!0,scrollEndThreshold:4,scrollToFn:(e,{adjustments:t,behavior:n},r)=>{let i=r.scrollElement;i&&i.scrollTo({top:t===void 0?e:i.scrollTop+t,behavior:n})}}),[ce,le]=(0,I.useState)(!0),ue=(0,I.useRef)(!0),de=(0,I.useRef)(-1),fe=(0,I.useRef)(0),pe=(0,I.useRef)(null),me=(0,I.useRef)(!1),he=(0,I.useRef)(!1),ge=(0,I.useRef)(!0),_e=(0,I.useRef)(null),ve=(0,I.useRef)(void 0),ye=(0,I.useRef)(null),be=(0,I.useRef)(void 0),xe=(0,I.useRef)(0),Se=(0,I.useCallback)(()=>{let e=t.current;if(e){let t=e.getBoundingClientRect().top,n=Array.from(e.querySelectorAll(`[data-transcript-source-id]`)).find(e=>e.getBoundingClientRect().bottom>t+1),r=n?.dataset.transcriptRowKey;n&&r&&(_e.current={rowKey:r,viewportTop:n.getBoundingClientRect().top-t})}v()},[v,t]),Ce=(0,I.useCallback)((e,n)=>{let r=t.current;if(!r)return;let i=Array.from(r.querySelectorAll(`[data-transcript-source-id]`)).find(t=>t.dataset.transcriptSourceId===e);i&&(r.scrollTop+=i.getBoundingClientRect().top-n)},[t]);(0,I.useLayoutEffect)(()=>{if(!n||oe.length===0||ve.current===n)return;ve.current=n,me.current=!1,he.current=!1,ge.current=!0;let t=XE(e)?.candidates.map(e=>({candidate:e,index:oe.findIndex(t=>t.kind===`message`&&t.message.sourceId===e.sourceId)})).find(e=>e.index>=0),r=requestAnimationFrame(()=>{if(!t){se.scrollToEnd({behavior:`instant`}),le(!0),me.current=!0;return}se.scrollToIndex(t.index,{align:`start`,behavior:`instant`}),ue.current=!1,le(!1),me.current=!0;let e=performance.now()+U1;xe.current=e;let n=()=>{performance.now()>=e||performance.now()<fe.current||(Ce(t.candidate.sourceId,t.candidate.screenTop),r=requestAnimationFrame(n))};n()});return()=>cancelAnimationFrame(r)},[Ce,oe.length,e,n,se]),(0,I.useLayoutEffect)(()=>{let e=_e.current,n=t.current;if(!e||!n||g)return;let r=()=>{let t=Array.from(n.querySelectorAll(`[data-transcript-row-key]`)).find(t=>t.dataset.transcriptRowKey===e.rowKey);if(!t)return;let r=t.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTop+=r-e.viewportTop};r();let i=0,a=requestAnimationFrame(()=>{r(),i=requestAnimationFrame(()=>{r(),_e.current===e&&(_e.current=null)})});return()=>{cancelAnimationFrame(a),cancelAnimationFrame(i)}},[g,M.length,t]);let we=(0,I.useCallback)(()=>{let e=t.current;if(!e)return null;let n=e.getBoundingClientRect().top,r=Array.from(e.querySelectorAll(`[data-transcript-row-key]`)).find(e=>e.getBoundingClientRect().bottom>n+1),i=r?.dataset.transcriptRowKey;return!r||!i?null:{rowKey:i,viewportTop:r.getBoundingClientRect().top-n}},[t]),Te=(0,I.useCallback)(e=>{let n=t.current;if(!n)return;let r=Array.from(n.querySelectorAll(`[data-transcript-row-key]`)).find(t=>t.dataset.transcriptRowKey===e.rowKey);if(!r)return;let i=r.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTop+=i-e.viewportTop},[t]),Ee=M[0]?.key;(0,I.useLayoutEffect)(()=>{let e=be.current;if(be.current=Ee,e===void 0||e===Ee||!me.current||ue.current||_e.current)return;let t=ye.current;if(!t)return;Te(t);let n=()=>{if(performance.now()<fe.current)return;let e=ye.current;e&&Te(e)},r=0,i=requestAnimationFrame(()=>{n(),r=requestAnimationFrame(n)});return()=>{cancelAnimationFrame(i),cancelAnimationFrame(r)}},[Te,Ee]);let De=(0,I.useCallback)(()=>{let e=t.current;if(!e||_e.current||performance.now()<xe.current)return;let n=k$({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,previousScrollHeight:de.current,following:ue.current,readerMoved:performance.now()<fe.current});if(ue.current=n.following,n.scrollTop!==null&&(e.scrollTop=n.scrollTop),de.current=e.scrollHeight,le(e=>e===n.following?e:n.following),W1&&!n.following&&performance.now()>=fe.current){let t=ye.current,n=t&&Array.from(e.querySelectorAll(`[data-transcript-row-key]`)).find(e=>e.dataset.transcriptRowKey===t.rowKey);if(t&&n){let r=Math.round(n.getBoundingClientRect().top-e.getBoundingClientRect().top-t.viewportTop);Math.abs(r)>2&&console.warn(`[frizz] transcript moved ${r}px under a still reader — row=${t.rowKey}`)}}ye.current=we()??ye.current},[we,t]);(0,I.useLayoutEffect)(De),(0,I.useEffect)(()=>{let e=pe.current;if(!e)return;let t=new ResizeObserver(De);return t.observe(e),()=>t.disconnect()},[De]),(0,I.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{De();let t=A$({armed:ge.current,scrollTop:e.scrollTop,readerMoved:me.current&&he.current,hasEarlier:m,loading:g});ge.current=t.armed,t.shouldLoad&&Se()},r=()=>{he.current=!0,fe.current=performance.now()+H1,requestAnimationFrame(n)},i=t=>{[`ArrowUp`,`PageUp`,`Home`,` `].includes(t.key)&&(e.scrollTop<=480&&(ge.current=!0),r())},a=t=>{t.deltaY<0&&e.scrollTop<=480&&(ge.current=!0),r()},o=()=>{e.scrollTop<=480&&(ge.current=!0),r()};e.addEventListener(`scroll`,n,{passive:!0}),e.addEventListener(`wheel`,a,{passive:!0}),e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`pointerdown`,r,{passive:!0}),e.addEventListener(`keydown`,i);let s=requestAnimationFrame(n);return()=>{cancelAnimationFrame(s),e.removeEventListener(`scroll`,n),e.removeEventListener(`wheel`,a),e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,o),e.removeEventListener(`pointerdown`,r),e.removeEventListener(`keydown`,i)}},[m,g,Se,De,t]);let Oe=se.getVirtualItems(),ke=se.getTotalSize();return(0,L.jsxs)(`div`,{ref:pe,"data-virtualized-transcript":!0,"data-virtual-row-count":Oe.length,className:`relative w-full`,style:{height:ke},children:[Oe.map(t=>{let n=oe[t.index];return n?(0,L.jsx)(`div`,{ref:se.measureElement,"data-index":t.index,"data-transcript-row-key":n.key,"data-transcript-source-id":n.kind===`message`?n.message.sourceId:void 0,className:`absolute left-0 top-0 w-full hover:z-[1]`,style:{transform:`translateY(${t.start}px)`},children:n.kind===`head-anchor`?null:n.kind===`interactions`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(QZ,{thread:s,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(xQ,{thread:s,questions:ie.tail,inFlight:a,className:`px-6 pt-5`})]}):n.kind===`questions`?(0,L.jsx)(xQ,{thread:s,questions:n.questions,className:`px-6 pt-5`}):n.kind===`transport-fallback`?u?(0,L.jsx)(`div`,{className:`px-6 pt-3`,children:(0,L.jsxs)(`div`,{"data-transcript-sync-fallback":!0,className:`flex flex-wrap items-center gap-2.5 ${Kq} border border-border-strong bg-panel-2 px-4 py-2.5 text-[12px]`,title:u.kind===`payload-too-large`?`Live payload ${u.actualBytes} bytes; socket limit ${u.maxBytes} bytes`:`Transcript read budget reached (${u.scope}); retry after about ${u.retryAfterMs}ms`,children:[(0,L.jsx)(rh,{size:13,className:`shrink-0 text-muted`}),(0,L.jsxs)(`div`,{className:`min-w-[180px] flex-1 leading-snug text-fg/85`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Live transcript updates paused.`}),` `,u.kind===`payload-too-large`?`The transcript is too large for push; the last complete HTTP-loaded copy remains visible.`:`The live read budget was reached; the last complete copy remains visible. Retry in a moment.`]}),(0,L.jsx)(`button`,{type:`button`,disabled:d,onClick:f,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel disabled:opacity-40`,children:d?`Refreshing…`:`Refresh once`}),(0,L.jsx)(`button`,{type:`button`,onClick:p,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel`,children:`Retry live`})]})}):null:n.kind===`earlier-history`?(0,L.jsx)(`div`,{className:`flex min-h-10 items-center justify-center px-6 text-[11px] text-muted`,role:`status`,children:_?(0,L.jsxs)(`span`,{className:`flex flex-wrap items-center justify-center gap-2 text-center`,children:[(0,L.jsx)(`span`,{children:_}),(0,L.jsx)(`button`,{type:`button`,onClick:Se,className:`rounded-md border border-border px-2 py-1 text-fg/90 hover:bg-panel-2`,children:`Retry`})]}):g?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Mm,{size:12,className:`animate-spin`}),` Loading earlier messages…`]}):(0,L.jsx)(`button`,{type:`button`,onClick:Se,className:`rounded-md px-2 py-1 outline-none hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:`Load earlier messages`})}):n.kind===`message`?(0,L.jsx)(lZ,{at:n.stampAt,host:IY(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(Q0,{m:n.message,answering:o(n.message),showSendButton:!0,paired:i[n.messageIndex],staleAwaiting:O>=0&&n.messageIndex<O,restingCardShown:n.messageIndex===E&&k,restedAt:D&&n.messageIndex===D.index?D.at??``:void 0,shadowedBy:ae.get(n.messageIndex),thread:s})}):n.kind===`runtime-status`?(0,L.jsxs)(`div`,{className:`px-6`,style:{paddingTop:re},children:[(0,L.jsx)(Y1,{state:te,slug:e,retryText:N>=0?r[N]?.text:void 0,onTerminal:l,liveRuntimeStart:T,liveActivityLabel:w,liveToolRun:S}),s?.permPolicy?(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(l2,{policy:s.permPolicy,denies:s.permDenies})}):null]}):(0,L.jsx)(lZ,{at:n.message.at,host:IY(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(Q0,{m:n.message,paired:i[n.messageIndex]})})},n.key):null}),(0,L.jsx)(Z1,{overlay:y,hidden:ce,onJump:()=>se.scrollToEnd({behavior:`smooth`})})]})}function Z1({overlay:e,hidden:t,onJump:n}){return!e||t?null:(0,ot.createPortal)((0,L.jsxs)(`button`,{type:`button`,"data-jump-to-latest":!0,onClick:n,className:`flex items-center gap-1.5 rounded-full border border-border-strong bg-elevated px-3 py-1.5 text-[11px] font-medium text-fg shadow-lg shadow-black/30 hover:bg-panel-2`,children:[(0,L.jsx)(qp,{size:12}),`Jump to latest`]}),e)}function Q1({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1}){let i=Dp(kC(),e),a=it({mutationFn:()=>Y.markComplete({slug:e})}),o=it({mutationFn:t=>Y.renameThread({slug:e,title:t})}),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(``),d=(0,I.useRef)(null);(0,I.useEffect)(()=>{if(!s)return;let e=requestAnimationFrame(()=>{d.current?.focus(),d.current?.select()});return()=>cancelAnimationFrame(e)},[s]),(0,I.useEffect)(()=>{c(!1),u(``)},[e]);let f=eK(nt({queryKey:[`threadBody`,e],queryFn:()=>Y.threadBody({slug:e})}).data?.markdown??``).trim().length>0;if(!i)return null;let p=i.kind===`session`&&i.foreign!==!0,m=i.foreign===!0,h=i.kind===`session`&&!m,g=aT(i);function _(){c(!1),u(``)}function v(){let e=BY(l,g);if(c(!1),!e){u(``);return}o.mutate(e,{onSuccess:()=>{u(``),Z(`Thread renamed`)},onError:t=>{u(e),c(!0),Z(t instanceof Error?t.message:`Could not rename thread`)}})}return(0,L.jsxs)(`header`,{"data-thread-header":!0,className:UY,children:[(0,L.jsx)(`div`,{className:WY,children:(0,L.jsxs)(`div`,{className:`min-w-0 leading-tight`,children:[(0,L.jsxs)(`div`,{className:`group/thread-title flex min-w-0 items-center gap-2`,children:[s?(0,L.jsx)(`input`,{ref:d,"aria-label":`Thread title`,value:l,maxLength:200,onChange:e=>u(e.target.value),onBlur:v,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),v()):e.key===`Escape`&&(e.preventDefault(),_())},className:`min-w-0 flex-1 rounded-md border border-border bg-elevated px-1.5 py-1 font-semibold text-[15px] text-fg outline-none focus:border-accent`}):h?(0,L.jsx)(`button`,{type:`button`,title:`Edit title`,"aria-label":`Edit thread title: ${g}`,disabled:o.isPending,onClick:()=>{u(VY(g,i.id)),c(!0)},className:`min-w-0 max-w-full shrink truncate rounded px-0.5 -mx-0.5 font-semibold text-[15px] text-left outline-none transition-colors hover:bg-panel-2 focus-visible:ring-1 focus-visible:ring-fg/60 disabled:cursor-not-allowed disabled:opacity-40`,children:g}):(0,L.jsx)(`div`,{className:`min-w-0 max-w-full shrink truncate px-0.5 -mx-0.5 font-semibold text-[15px]`,title:g,children:g}),(0,L.jsx)(ZX,{thread:i,hidden:s})]}),(0,L.jsx)(v$,{at:gT(i),fallbackAt:i.spawnedAt,className:`mt-0.5 block truncate text-[11px] leading-tight text-muted/75`})]})}),(0,L.jsxs)(`div`,{className:GY,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[p&&(0,L.jsx)(O$,{slug:e}),(0,L.jsx)(gX,{thread:i,collapse:r,onDoc:f?()=>$f(`doc`,i.id):void 0,onDone:()=>a.mutate(void 0,{onSuccess:t}),doneBusy:a.isPending,onStatusApplied:t}),n&&(0,L.jsx)(Rj,{slug:e})]}),n&&(0,L.jsx)(`button`,{type:`button`,"aria-label":`Close`,"data-dialog-initial-focus":!0,onClick:n,className:`ml-0.5 shrink-0 rounded-md p-1.5 text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg`,children:(0,L.jsx)(ah,{size:15})})]})]})}function $1(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||nZ(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 e0(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||nZ(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 t0(e){return $1(e)!==null}function n0(e){return e0(e)!==null}function r0(e){return e.kind===`event`&&!e.boundary||e.kind===`reasoning`}function i0(e){return r0(e)||t0(e)}function a0(e){return r0(e)||n0(e)}function o0(e){if(r0(e))return!0;let t=$1(e);return t!==null&&!z$(t[t.length-1])}function s0(e){if(r0(e))return!0;let t=e0(e);return t!==null&&!z$(t[0])}function c0(e){let t=$1(e);return t!==null&&V$(t[t.length-1])}function l0(e){let t=e0(e);return t!==null&&V$(t[0])}function u0(e,t){let n=c0(e)||l0(t),r=!n&&i0(e)&&a0(t)&&!(o0(e)&&s0(t));return(n?22:r?6:14)+(e.role===`user`&&t.role!==`user`?3:0)}function d0(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:m0(e,n.text,t)):(e.tools?.length??0)===0&&m0(e,e.text,t)}function f0(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`&&e[t].kind!==`event`)return t;return-1}function p0(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=>d0(e,r.has(e))}function m0(e,t,n){return!e.fenceRefused&&!n?!t.trim():Uq(t).every(e=>e.kind===`fence`&&e.fenceKind===`awaiting`)}function h0(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`&&!m0(e,n.text,t)):typeof e.text==`string`&&!m0(e,e.text,t)}function g0(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.queued||d0(n)))return c0(n)?22:i0(n)&&!o0(n)?6:14+(n.role===`user`?3:0)}return 0}function _0(e,t,n){let r=[],i=null;return e.forEach((e,a)=>{n?.(e,a)||d0(e)||(i!==null&&r.push((0,L.jsx)(LJ,{h:u0(i,e)},`s${a}`)),r.push(t(e,a)),i=e)}),r}function v0(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 y0(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)(LJ,{h:typeof t==`number`?t:t(n)},`vs${n}`)),r.push(e)}),r}var b0={head:!1,tail:!1};function x0(e,t){return n=>e[n-1]?.tail||e[n]?.head?22:t}function S0(e){return{head:V$(e[0]),tail:V$(e[e.length-1])}}function C0(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}):B$(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 w0(e){return e.split(`__`).pop()||e}function T0(e){let t=X.board?.projectDir;return t&&e.startsWith(t+`/`)?e.slice(t.length+1):e}function E0({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=m1(a,p1(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 ${uZ}`,children:[(0,L.jsx)(`span`,{"data-tool-activity-label":!0,title:o,className:`min-w-0 truncate text-muted`,children:o}),(0,L.jsx)(tm,{"data-tool-activity-chevron":!0,"aria-hidden":`true`,size:13,className:fZ(n)})]}),n&&(0,L.jsx)(`div`,{id:i,className:`mt-1.5 flex flex-col`,children:y0(e.map((e,n)=>(0,L.jsx)(O0,{t:e,startedAt:t},n)),6)}),!n&&(0,L.jsx)(`div`,{id:i,hidden:!0})]})}function D0({tools:e,at:t}){let n=[];for(let t of e){let e=z$(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:y0(n.map((e,n)=>e.exceptional?(0,L.jsx)(`div`,{className:`flex flex-col`,children:y0(e.tools.map((e,n)=>(0,L.jsx)(O0,{t:e,startedAt:t},n)),x0(e.tools.map(e=>S0([e])),6))},`exceptions-${n}`):(0,L.jsx)(E0,{tools:e.tools,at:t},`activity-${n}`)),x0(n.map(e=>S0(e.tools)),6))})}function O0({t:e,startedAt:t}){let n=(0,I.useContext)(N1),r=kC(),i=mE(e,(n?Dp(r,n):void 0)?.bgShells??[]);return e.edits&&e.status!==`failed`&&e.status!==`cancelled`?(0,L.jsx)(XK,{edits:e.edits,meta:(0,L.jsx)(N0,{status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,durationMs:e.durationMs})}):e.command?(0,L.jsx)(V0,{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)(R0,{name:e.name,detail:e.detail,outputImage:e.outputImage,output:e.output,status:e.status,durationMs:e.durationMs}):e.read?(0,L.jsx)(U0,{detail:e.detail,read:e.read,status:e.status,durationMs:e.durationMs}):e.prompt||e.agentId?(0,L.jsx)(G0,{detail:e.detail,prompt:e.prompt,input:e.input,subagentType:e.subagentType,agentId:e.agentId,agentStatus:e.agentStatus,agentElapsedMs:e.agentElapsedMs,status:e.status,durationMs:e.durationMs,output:e.output}):e.sendTo!==void 0||e.sendBody!==void 0?(0,L.jsx)(q0,{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)(z0,{images:e.sentImages??[],files:e.sentFiles??[],caption:e.caption,status:e.status,durationMs:e.durationMs}):e.todos?(0,L.jsx)(yq,{todos:e.todos,note:e.input,meta:(0,L.jsx)(N0,{status:e.status,durationMs:e.durationMs})}):B$(e)?(0,L.jsx)(k0,{ask:e.ask??[],askAnswers:e.askAnswers}):e.input||e.output?(0,L.jsx)(V0,{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)(L0,{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 k0({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=JZ(e,t?.[n]);return(0,L.jsx)(bY,{question:r.question,settled:{chosenIdxs:r.chosenIdxs,text:r.text}},n)})})}function A0({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 j0(e,t,n){let[r,i]=(0,I.useState)(()=>Date.now()),a=dE(e,t),o=fE(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(uE-(Date.now()-e),0));return()=>clearTimeout(t)},[a,o,n]),o}function M0({status:e,backgroundState:t,liveBackgroundState:n,startedAt:r}){let i=j0(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:AE}):lE(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 N0({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:hE(i),c=[o,s].filter(Boolean).join(` · `);return(0,L.jsx)(A0,{tone:e===`failed`?`frizz-tool-failed`:e===`cancelled`?`text-amber-400`:`text-muted/55`,title:c,label:a,duration:s})}function P0(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 F0(e,t,n){let r=t&&t!==X.board?.projectDir?`in ${T0(t)}`:void 0;return[e,t?r:n!==void 0&&!e?.includes(String(n))?`session ${n}`:void 0].filter(Boolean).join(` · `)||void 0}function I0(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.includes(`…`)}function L0({name:e,detail:t,count:n,status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,cwd:s,sessionId:c,durationMs:l,startedAt:u}){let d=F0(t,s,c),f=d?T0(d):void 0,p=t&&I0(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)(M0,{status:r,backgroundState:i,liveBackgroundState:a,startedAt:u}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:w0(e)}),f&&(p?(0,L.jsx)(`span`,{className:`min-w-0 truncate`,onClick:e=>e.stopPropagation(),children:(0,L.jsx)(JK,{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)(N0,{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 R0({name:e,detail:t,outputImage:n,output:r,status:i,durationMs:a}){let o=t?T0(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:w0(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)(N0,{status:i,durationMs:a})})]});return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(e2,{path:n,hideCaption:!0,altText:o?`${w0(e)}: ${o}`:w0(e),header:s}),r&&(0,L.jsx)(`pre`,{className:`frizz-bash frizz-bash-body frizz-bash-output-body mt-1.5`,children:r})]})}function z0({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)(N0,{status:r,durationMs:i}),(0,L.jsx)(tm,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${a?`rotate-90`:``}`})]})]}),(0,L.jsx)(`div`,{id:s,hidden:!a,children:a&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-2.5 pb-2.5 pt-1.5`,children:[e.map((e,t)=>(0,L.jsx)(e2,{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)(t2,{path:e},`f${t}`))}),n&&(0,L.jsx)(`div`,{className:`max-w-[65%] text-[12px] leading-snug text-muted`,children:n})]})})]})}var B0=16;function V0({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=P0(i,d,l),b=(0,I.useMemo)(()=>e.split(`
314
- `).length,[e]),x=b>B0,S=(0,I.useMemo)(()=>n?n.split(`
315
- `).length:0,[n]),C=S>B0,w=F0(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`} `:``}${w0(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)(M0,{status:i,backgroundState:a,liveBackgroundState:o,startedAt:d}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:w0(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)(N0,{status:i,backgroundState:a,liveBackgroundState:o,exitCode:s,durationMs:y}),T&&(0,L.jsx)(tm,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${f?`rotate-90`:``}`})]})]}),T&&(0,L.jsxs)(`div`,{id:v,hidden:!f,children:[f&&e&&(0,L.jsxs)(L.Fragment,{children:[u&&(0,L.jsx)(`div`,{className:`frizz-bash-output-label petite-caps`,children:u}),(0,L.jsx)(pq,{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 H0=16;function U0({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>H0,d=e?T0(e):void 0,f=e&&I0(e)?e:void 0;return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(qK,{className:`frizz-bash-header`,controls:c,expanded:i,label:`${i?`Collapse`:`Expand`} Read${e?`: ${e}`:``}`,onToggle:()=>a(e=>!e),meta:(0,L.jsx)(N0,{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)(JK,{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)(pq,{text:t,language:lS(e),className:`frizz-bash-body${u&&!o?` frizz-bash-clamp`:``}`}),u&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:o?`Collapse`:`Show all ${l} lines`})]})})]})}var W0=16;function G0({detail:e,prompt:t,input:n,subagentType:r,agentId:i,agentStatus:a,agentElapsedMs:o,status:s,durationMs:c,output:l}){let[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(!1),m=(0,I.useId)(),h=t??n,g=(0,I.useMemo)(()=>h?h.split(`
317
- `).length:0,[h]),_=g>W0,v=F1(),y=kC(),b=v?Dp(y,v):void 0,x=!a&&i?(b?.subAgents??[]).find(e=>e.id===i):void 0,S=x?.state===`running`,C=!!(v&&i),w=e??`sub-agent`,T=tZ(r),E=oE(),D=sZ({agentStatus:a,agentElapsedMs:o,liveState:x?.state,liveElapsedMs:x?.startedAt?Math.max(E-Date.parse(x.startedAt),0):void 0,status:s,durationMs:c}),O=S?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--agent`,"data-running-indicator":`subagent-disclosure`}):x?.state===`stale`?(0,L.jsx)(`span`,{className:EE,title:DE}):x?.state===`rested`?(0,L.jsx)(`span`,{className:OE,title:kE}):null;function k(){!v||!i||ep(v,i,{label:w,subagentType:r,startedAt:x?.startedAt})}return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(qK,{className:`frizz-bash-header`,controls:m,expanded:u,label:`${u?`Collapse`:`Expand`} Agent dispatch: ${w}`,onToggle:()=>d(e=>!e),meta:(T||D)&&(0,L.jsxs)(L.Fragment,{children:[T&&(0,L.jsx)(`span`,{"data-subagent-profile":!0,className:`petite-caps frizz-tool-header-caps shrink-0 whitespace-nowrap text-[11.5px] leading-none text-muted/55`,title:`Sub-agent profile: ${T}`,children:T}),T&&D&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`petite-caps frizz-tool-header-caps -mx-[2px] shrink-0 text-[11.5px] leading-none text-muted/55`,children:`·`}),D&&(0,L.jsx)(A0,{tone:D.tone===`failed`?`frizz-tool-failed`:`text-muted/55`,title:D.title,label:D.label,duration:D.duration})]}),children:[O&&(0,L.jsx)(`span`,{className:`frizz-tool-mark -mr-1 flex w-[9px] shrink-0 justify-center`,children:O}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Agent`}),C?(0,L.jsx)(`button`,{type:`button`,"aria-label":`Open sub-agent transcript: ${w}`,title:`Open sub-agent transcript`,onClick:k,className:`min-w-[4rem] flex-1 truncate text-left text-[11.5px] text-muted outline-none hover:underline hover:text-fg/80 focus-visible:underline focus-visible:text-fg/80`,children:w}):(0,L.jsx)(`span`,{className:`min-w-[4rem] flex-1 truncate text-[11.5px] text-muted`,title:w,children:w})]}),(0,L.jsx)(`div`,{id:m,hidden:!u,children:u&&(0,L.jsxs)(L.Fragment,{children:[h&&(0,L.jsx)(`pre`,{className:`frizz-bash-body${_&&!f?` frizz-bash-clamp`:``}`,children:h}),_&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>p(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:f?`Collapse`:`Show all ${g} lines`}),l&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`frizz-bash-output-label petite-caps`,children:`output`}),(0,L.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body`,children:l})]})]})})]})}function K0(e,t){return t===`shutdown_request`?`Shutdown`:t===`codex_followup`?`Followed up`:e===`main`?`Reported`:`Steered`}function q0({to:e,summary:t,body:n,type:r,dispatchId:i,targetLabel:a,status:o,durationMs:s,at:c}){return(0,I.useContext)(N1)===null?(0,L.jsx)(Y0,{to:e,summary:t,body:n,type:r,status:o,durationMs:s}):(0,L.jsx)(m2,{to:e,type:r,dispatchId:i,targetLabel:a,at:c})}var J0=16;function Y0({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=$K(pK(n)),f=(0,I.useMemo)(()=>n.split(`
318
- `).length,[n]),p=f>J0,m=!!n.trim(),h=K0(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)(N0,{status:i,durationMs:a}),m&&(0,L.jsx)(tm,{"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 X0({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)(()=>wL(e,[...i.keys()]),[e,i]).map((e,t)=>{let a=e.token?i.get(e.token):void 0;if(!a)return(0,L.jsx)(sY,{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:_L(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 Z0({text:e,rawText:t,queued:n,deliveryUnconfirmed:r,deliveryId:i,sourceId:a}){let o=(0,I.useContext)(N1),s=TY(o),{unqueue:c,pending:l}=kY(o),u=!!(n&&i&&o&&s),d=AY(n?o:null),{deliverNow:f,pending:p}=jY(o),m=!!(n&&o&&d),{prose:h,attachments:g}=(0,I.useMemo)(()=>mL(e),[e]),_=(0,I.useMemo)(()=>jL(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)(X0,{body:_.body,items:_.items}):(0,L.jsx)(sY,{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)(Mm,{size:15,strokeWidth:2.2,className:`animate-spin`}):(0,L.jsx)(Jp,{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)(e2,{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)(t2,{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 Q0=(0,I.memo)(function({m:e,answering:t,dense:n,paired:r,textOnly:i,showSendButton:a,staleAwaiting:o,shadowedBy:s,thread:c,restingCardShown:l,restedAt:u}){let d=iW(),[f,p]=(0,I.useState)(!1);if(e.providerError)return(0,L.jsx)(cJ,{error:e.providerError});if(e.kind===`event`)return(0,L.jsx)(h2,{text:e.text,boundary:e.boundary,sourceId:e.sourceId,at:e.at});if(e.kind===`reasoning`)return(0,L.jsx)(g2,{text:e.text,sourceId:e.sourceId});let m=nZ(e);if(m)return(0,L.jsx)(f2,{call:m,sourceId:e.sourceId,at:e.at});if(e.role===`user`){let t=MY(e).replace(/\r\n?/g,`
319
- `),i=r===void 0?mJ(t):r;if(i)return(0,L.jsx)(cY,{answers:i,queued:e.queued,sourceId:e.sourceId});let a=e.wake?xl(t):void 0;return a?(0,L.jsx)(eY,{bump:a,sourceId:e.sourceId,at:e.at}):e.wake?(0,L.jsx)(UJ,{steer:e.wakeSteer,text:t,sourceId:e.sourceId,at:e.at,wrap:n}):e.peerFrom?(0,L.jsx)(p2,{from:e.peerFrom,unnamed:e.peerUnnamed,dispatchId:e.peerDispatchId,sourceId:e.sourceId,at:e.at}):(0,L.jsx)(Z0,{text:t,rawText:e.text,queued:e.queued,deliveryUnconfirmed:e.deliveryState===`unconfirmed`,deliveryId:e.deliveryId,sourceId:e.sourceId})}let h=[],g=[],_=(e,t=b0)=>{h.push(e),g.push(t)},v={n:-1},y={drawn:!1},b=[],x=(r,i)=>{for(let[a,c]of Uq(r).entries()){if(c.kind===`fence`){if(c.fenceKind===`awaiting`&&(e.fenceRefused||o||l))continue;c.fenceKind===`awaiting`&&(y.drawn=!0),_((0,L.jsx)(a2,{fenceKind:c.fenceKind,body:c.body,hints:c.hints,wrap:n,notAfter:u},`${i}-f${a}`));continue}for(let[e,r]of Cq(c.text).entries()){if(r.kind===`prose`){for(let[t,o]of pL(r.text).entries()){let r=`${i}-${a}-p${e}-${t}`;_(o.kind===`image`?(0,L.jsx)(e2,{path:o.path},r):o.kind===`file`?(0,L.jsx)(t2,{path:o.path},r):o.kind===`visualization`?(0,L.jsx)(i2,{file:o.file},r):o.kind===`directive`?(0,L.jsx)(k1,{directive:o.directive},r):o.kind===`mermaid`?(0,L.jsx)(M1,{source:o.source},r):(0,L.jsx)($0,{md:o.text,wrap:n},r))}continue}v.n+=1;let o=v.n;if(s&&IJ(r,s)!==void 0||r.registeredId&&r.text.trim()===``)continue;t&&b.push({raw:r.text,kind:r.questionKind,danger:r.danger,bi:o});let c=t&&!d?{answer:t.answerFor(o),onChip:(e,n)=>t.onChip(o,e,n),onText:e=>t.onText(o,e),onSubmit:t.onSubmit}:void 0;_((0,L.jsx)(bY,{raw:r.text,questionKind:r.questionKind,danger:r.danger,interactive:c,wrap:n},`${i}-${a}-q${e}`))}}};if(e.parts&&e.parts.length>0)v0(e.parts).forEach((t,r)=>{if(t.kind===`tools`){if(i)return;let a=C0(t.tools);a.length&&_((0,L.jsx)(D0,{tools:a,dense:n,at:e.at},`t${r}`),S0(a))}else x(t.text,`x${r}`)});else{if(!i){let t=C0(e.tools);t.length>0&&_((0,L.jsx)(D0,{tools:t,dense:n,at:e.at},`tools`),S0(t))}x(e.text,`leg`)}return u!==void 0&&c&&!y.drawn&&!e.fenceRefused&&o$(c,{notAfter:u})&&_((0,L.jsx)(p$,{thread:c,notAfter:u},`rested-on`)),h.length===0?null:(a&&t&&d&&b.length>0?_((0,L.jsx)(`div`,{className:`flex justify-start`,children:(0,L.jsx)(`button`,{type:`button`,"data-mobile-answer-open":!0,onClick:()=>p(!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:b.length>1?`Answer ${b.length} questions`:`Answer`})},`answer-open`)):a&&t&&b.length>0&&_((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:[y0(h,x0(g,14)),f&&t&&b.length>0?(0,L.jsx)(wY,{blocks:b,answering:t,onClose:()=>p(!1)}):null]}))});function $0({md:e,wrap:t}){let n=pK(e),r=$K(n),i=(0,I.useRef)(null);return dq(i,n),n?(0,L.jsx)(`div`,{ref:i,className:`md-body${t?` ${Gq}`:``}`,dangerouslySetInnerHTML:r}):null}function e2({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=e.split(`/`).filter(Boolean).pop()||e;return(0,L.jsx)(MG,{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:jS(e),alt:n??o,"data-local-path":e,"data-local-image":`true`,onError:()=>a(!0),className:`cursor-pointer ${FG}`})})}function t2({path:e}){let t=e.split(`/`).filter(Boolean).pop()||e;return(0,L.jsxs)(`button`,{type:`button`,className:`local-file-action inline-flex max-w-full items-center gap-1.5 ${Kq} 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)(gm,{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 n2={"--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 r2(){let e=getComputedStyle(document.documentElement),t=Object.fromEntries(Object.entries(n2).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 i2({file:e}){let t=(0,I.useContext)(N1),n=(0,I.useRef)(null),[r,i]=(0,I.useState)(360),[a,o]=(0,I.useState)(null),s=t?`${Nd()}/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:`${Kq} 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 ${Kq} 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(r2(),`*`),className:`block w-full border-0 bg-transparent`,style:{height:r}})}function a2({fenceKind:e,body:t,hints:n,wrap:r,notAfter:i}){let a=pK(t),o=(0,I.useContext)(N1),s=(0,I.useContext)(I1),c=kC(),l=o?Dp(c,o):void 0,u=l?yX(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)($q,{icon:Qp,label:`Done`,children:[a&&(0,L.jsx)(fq,{className:`md-body${r?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:a}),p&&(0,L.jsx)(tJ,{children:(0,L.jsx)(YX,{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&&u$(l)?null:(0,L.jsx)(p$,{thread:l,fence:{body:t,hints:n},notAfter:i})}function o2({slug:e,sessionId:t,fault:n,retryText:r}){let[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(!1),c=Ve(),l=ER[n.backend],u=t=>{s(!0),CH(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)($q,{"data-provider-fault":!0,tone:`danger`,icon:km,label:`${l} sign-in required`,children:[(0,L.jsx)(`span`,{className:eJ,children:`The provider rejected this session's credential. Sign in, then retry.`}),(0,L.jsxs)(tJ,{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:iJ,children:`Sign in`})]}),i&&(0,L.jsx)(kR,{backend:n.backend,onClose:()=>a(!1),onAuthed:()=>a(!1)})]})}function s2({slug:e,sessionId:t,pause:n}){let r=ER[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)($q,{"data-limit-pause":!0,tone:`caution`,icon:Tm,label:`Paused by the ${r} ${i}`,children:[(0,L.jsx)(`span`,{className:eJ,children:n.autoResume?n.resumesAt?`Continuing automatically at ${ZT(n.resumesAt)}.`:`Continuing automatically once the window resets.`:`Continue it whenever you have capacity again.`}),(0,L.jsx)(tJ,{children:(0,L.jsx)(`button`,{onClick:()=>{o(!0),CH(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 ${iJ}`,children:`Continue now`})})]})}function c2({onTerminal:e}){return(0,L.jsxs)($q,{tone:`attention`,icon:km,label:`Permission approval`,children:[(0,L.jsx)(`span`,{className:eJ,children:`The agent is waiting on your approval — respond in your external terminal.`}),(0,L.jsx)(tJ,{children:(0,L.jsx)(`button`,{onClick:()=>e(),onMouseDown:e=>e.preventDefault(),className:iJ,children:`Copy terminal command`})})]})}function l2({policy:e,denies:t}){let n=[e.tool,e.command].filter(Boolean).join(`: `);return(0,L.jsxs)($q,{tone:`caution`,icon:rh,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:eJ,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 u2({slug:e,className:t=`px-4 pb-2 pt-1`,includeAgents:n=!0,transcriptShells:r=[],parentAgentId:i}){let a=Dp(kC(),e),o=a?.subAgents??[],s=n?i?RE(o,i):o:[],c=i?[...r]:HE(a?.bgShells??[],r),l=i?[]:(a?.watches??[]).filter(e=>e.kind===`github`),u=s.length+c.length+l.length,d=new Set((a?.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`).map(e=>e.target)),f=e=>d.has(e.taskId??``)||d.has(e.id??``)||d.has(e.label),[,p]=(0,I.useState)(0);(0,I.useEffect)(()=>{if(u===0)return;let e=setInterval(()=>p(e=>e+1),3e4);return()=>clearInterval(e)},[u]);let m=KC(e,c.flatMap(e=>e.id&&!e.outputUnavailable?[e.id]:[]));return u===0?null:(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5 ${t}`,"data-background-ops":!0,children:[BE(s,`sheet`).map((t,n)=>(0,L.jsx)(UE,{kind:`AGENT`,label:t.label,state:t.state,density:`sheet`,depth:t.displayDepth??t.depth,startedAt:t.startedAt,onOpen:t.id?()=>ep(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:Bj(e,t)},`a${n}`)),BE(c,`sheet`).map((t,n)=>(0,L.jsx)(UE,{kind:`SHELL`,label:t.label,state:t.state,density:`sheet`,startedAt:t.startedAt,counter:t.id?ME(m.get(t.id)):void 0,counterTitle:`Lines of output so far — open the row to read them`,onOpen:t.id&&!t.outputUnavailable?()=>tp(e,t.id,{label:t.label,startedAt:t.startedAt}):void 0,onDismiss:Bj(e,t,`SHELL`),title:f(t)?`${t.label}\nWatched — this thread wakes when it finishes`:void 0},`s${n}`)),l.map(e=>(0,L.jsx)(UE,{kind:`GITHUB`,label:e.target,state:`running`,density:`sheet`,startedAt:e.createdAt,counter:NE(e.github),counterTone:e.github?.checks===`failing`?`danger`:void 0,counterTitle:e.github?`${e.target} — ${HQ(e.github)}`:void 0,onOpen:()=>window.open(EH(e.target)??`https://github.com/${e.target.replace(`#`,`/pull/`)}`,`_blank`,`noreferrer,noopener`)},e.id))]})}function d2({ask:e,onTerminal:t}){return(0,L.jsxs)($q,{tone:`attention`,icon:cm,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)(tJ,{children:(0,L.jsxs)(`button`,{onClick:()=>t(),onMouseDown:e=>e.preventDefault(),className:iJ,children:[(0,L.jsx)(km,{size:12,className:`shrink-0 ${LY}`}),`Copy terminal command`]})})]})}function f2({call:e,sourceId:t,at:n}){let r=F1(),i=e.detail??`sub-agent`,{tail:a}=iZ(e),o=!!(r&&e.agentId);return(0,L.jsxs)(RJ,{icon:Xp,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:jE.AGENT,"aria-label":`${jE.AGENT}: ${i}`,onClick:()=>ep(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 p2({from:e,unnamed:t,dispatchId:n,sourceId:r,at:i}){let a=F1(),o=!!(a&&n),s=t?void 0:e,c=t&&e?`${jE.AGENT} — ${e}`:jE.AGENT;return s===void 0?(0,L.jsx)(RJ,{icon:Xp,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":`${jE.AGENT}${e?`: ${e}`:``}`,onClick:()=>ep(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)(RJ,{icon:Xp,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:jE.AGENT,"aria-label":`${jE.AGENT}: ${s}`,onClick:()=>ep(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 m2({to:e,type:t,dispatchId:n,targetLabel:r,sourceId:i,at:a}){let o=F1(),s=K0(e,t),c=e===`main`?void 0:r??e,l=!!(o&&n);return(0,L.jsxs)(RJ,{icon:Xp,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:jE.AGENT,"aria-label":`${jE.AGENT}: ${c}`,onClick:()=>ep(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 h2({text:e,boundary:t,sourceId:n,at:r}){return t?(0,L.jsx)(RJ,{icon:t===`wake`?eh: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:uZ,children:e})}function g2({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:`${uZ} 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)(tm,{"aria-hidden":`true`,size:13,className:fZ(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)($0,{md:e,wrap:!0})})]})}function _2(){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 v2({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=vE(Math.max(0,o-a)),f=(0,I.useMemo)(()=>C0([...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 ${uZ}`,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??h1(p)}),m&&(0,L.jsx)(tm,{"data-working-chevron":!0,"aria-hidden":`true`,size:13,className:fZ(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:y0(f.map((e,t)=>(0,L.jsx)(O0,{t:e,startedAt:r?.at},t)),6)}),m&&!c&&(0,L.jsx)(`div`,{id:u,hidden:!0})]})}function y2(){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 b2({id:e,slug:t,depth:n,widthDepth:r,initiallyOpen:i}){let{shown:a,close:o,closingRef:s}=Np(e,i===!0),[c,l]=(0,I.useState)(i===!0),u=(0,I.useRef)(null),d=(0,I.useRef)(null),f=Zt(X),p=[...f.drawers].reverse().find(e=>!e.closing)?.id===e,m=y2(),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 _=kC(),v=Sd(_,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 oW({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)(()=>(hd(e,()=>{(u.current?.querySelector(`[data-dialog-initial-focus]`)??u.current)?.focus({preventScroll:!0})}),()=>hd(e,null)),[e]),(0,L.jsx)(NI,{modal:m,open:!0,onOpenChange:e=>{e||o()},children:(0,L.jsxs)(zI,{children:[(0,L.jsx)(VI,{className:`${Op} ${a?`opacity-100`:`opacity-0`}`,style:{zIndex:50+n*2}}),(0,L.jsxs)(GI,{ref:u,"aria-modal":m||void 0,"aria-describedby":void 0,tabIndex:-1,onEscapeKeyDown:t=>{if(X.drawers.at(-1)?.id!==e){t.preventDefault();return}bR(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 ${kp} ${a?`translate-x-0`:`translate-x-full`}`,style:{zIndex:51+n*2,width:jp(r),viewTransitionName:f.vtReturnTarget===t?`thread-chat`:void 0},children:[(0,L.jsx)(XI,{className:`sr-only`,children:v.kind===`found`?`Thread: ${aT(v.thread)}`:`Thread: ${t}`}),c&&v.kind===`found`?(0,L.jsx)(B1,{slug:t,onStatusApplied:o,onClose:o,virtualized:!0}):c&&v.kind===`missing`?(0,L.jsx)(x2,{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 x2({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 ${oh} 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 S2({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=WC(t,n),f=AC(),p=(0,I.useMemo)(()=>d.data?.messages??[],[d.data]),m=d.data?.state,h=m===`running`,g=(0,I.useMemo)(()=>R1(p),[p]),_=(0,I.useMemo)(()=>z1(p),[p]),v=(0,I.useMemo)(()=>Z$(_),[_]),y=h?e1(v):void 0,b=h?$$(v):void 0,x=b?u1(b,f):void 0,S=h?n1(v):void 0,C=(0,I.useMemo)(()=>h?a1(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)(Lp,{id:e,depth:o,widthDepth:s,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(sh,{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)(P1.Provider,{value:t,children:(0,L.jsxs)(`div`,{"data-transcript-column":!0,className:`flex flex-col px-6 py-5`,children:[_0(C.map(e=>e.message),(e,t)=>(0,L.jsx)(Q0,{m:e},t)),w&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(LJ,{h:g0(C.map(e=>e.message))}),(0,L.jsx)(v2,{since:a,startedAt:S,activityLabel:x,run:y})]})]})})}),(0,L.jsx)(C2,{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)(u2,{slug:t,parentAgentId:n,transcriptShells:g,className:e})})]})})}function C2({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)(w2,{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)(YL,{value:c,onChange:l,onSubmit:h,surface:`subAgentComposer`,placeholder:`Steer this sub-agent…`,busy:u||f,footer:(0,L.jsx)(w2,{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)(w2,{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 w2({subagentType:e}){let t=eZ(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 ${eR}`,children:(0,L.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 truncate`,children:t})})}var T2=`font-mono-keep overflow-x-auto whitespace-pre-wrap break-words ${Kq} border border-border bg-bg/75 px-4 py-2.5 text-[12px] leading-relaxed text-fg/85`;function E2({id:e,slug:t,shellId:n,label:r,startedAt:i,depth:a,widthDepth:o}){let s=(0,I.useRef)(null),c=GC(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=SE(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 CR(u),Z(`Command copied`)}catch{Z(`Could not copy command`)}}return(0,L.jsx)(Lp,{id:e,depth:a,widthDepth:o,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(sh,{title:r,icon:(0,L.jsx)(eh,{"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)(fm,{"aria-hidden":!0,size:11}),` Copy`]})]}),u?(0,L.jsx)(pq,{"data-background-shell-command":!0,text:u,language:`bash`,className:T2}):(0,L.jsx)(`pre`,{"data-background-shell-command":!0,className:T2,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 ${Kq} 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 ${Kq} 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 D2(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 O2={paddingBottom:`max(0.75rem, env(safe-area-inset-bottom))`};function k2({path:e}){return(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{Y.openLocalFile({path:e}).then(async e=>{e.action===`copy`&&(await CR(e.path),Z(`Copied local path`))}).catch(e=>Z(`Could not open local file: ${e.message.slice(0,100)}`))},onMouseDown:e=>e.preventDefault(),className:`flex items-center gap-1.5 rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] font-medium text-fg/80 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,title:`Open ${e} outside Frizz`,"aria-label":`Open`,children:[(0,L.jsx)(mm,{size:12,"aria-hidden":`true`}),` Open`]})}function A2({source:e}){return(0,L.jsx)(pq,{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 j2({id:e,path:t,title:n,depth:r,widthDepth:i}){let a=MC(t),o=nt({...zS(t),refetchInterval:a?!1:BS}),s=o.data?.path??t,{front:c,body:l}=D2(o.data?.markdown??``),u=pK(l,{baseDir:LS(s),asDocument:!0}),d=$K(u),f=(0,I.useRef)(null);return dq(f,u),(0,L.jsx)(Lp,{id:e,depth:r,widthDepth:i,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(sh,{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)(A2,{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:O2,children:(0,L.jsx)(k2,{path:s})})]})})}function M2({id:e,slug:t,title:n,depth:r,widthDepth:i}){let a=nt({queryKey:[`threadBody`,t],queryFn:()=>Y.threadBody({slug:t})}),o=Zt(X);(0,I.useEffect)(()=>{a.refetch()},[o.board]);let s=zY(Dp(o.board,t)),c=sz(),l=oz.adopt(c,t),[u,d,f]=lz(l),p=it({mutationFn:async e=>{await Y.adoptThread({slug:t,message:e.trim()||void 0})},onSuccess:()=>{X.drawers.find(t=>t.id===e)?.closing||(X.drawers=X.drawers.map(t=>t.id===e?{...t,kind:`thread`}:t))},onError:(e,t)=>{iz.get(l)||d(t),Z(`Start failed: ${e.message.slice(0,80)}`)}}),m=pK(eK(a.data?.markdown??``)),h=$K(m);return(0,L.jsx)(Lp,{id:e,depth:r,widthDepth:i,widthOffset:1,subagentParent:t,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(sh,{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)(YL,{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 N2(){let e=Zt(X),t=kC();(0,I.useEffect)(()=>{function e(e){if(e.key===`Escape`&&!(e.target instanceof Element&&e.target.closest(`.xterm`))){if(yR()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(X.showPalette)X.showPalette=!1;else if(X.showNewThread)X.showNewThread=!1;else if(X.showGithubPicker)Kf();else if(X.showSettings)ud()||(X.showSettings=!1);else if(X.drawers.length>0){let e=X.drawers[X.drawers.length-1];md(e.id)||X.drawers.pop()}else X.filePanel&&pp()}}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)(b2,{id:e.id,slug:e.slug,depth:r,widthDepth:i,initiallyOpen:e.routed},e.id):e.kind===`subagent`?(0,L.jsx)(S2,{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)(E2,{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)(j2,{id:e.id,path:e.path??e.slug,title:e.label??e.slug,depth:r,widthDepth:i},e.id):(0,L.jsx)(M2,{id:e.id,slug:e.slug,depth:r,widthDepth:i,title:(()=>{let n=Dp(t,e.slug);return n?aT(n):e.slug})()},e.id);return(0,L.jsx)(lh,{label:`this drawer`,resetKeys:[e.kind,e.slug,e.subId,e.path],fallback:(t,n)=>(0,L.jsx)(mh,{id:e.id,depth:r,widthDepth:i,error:t,onRetry:n}),children:a},e.id)})})}function P2(e){return(e.tools??[]).some(e=>e.name===`mcp__frizz__done`&&e.status===`completed`)}function F2(e){let t=Cq(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 I2(e){let t=new Map,n=[];for(let r=0;r<e.length;r++){let i=F2(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 L2(e,t,n){return Eq(e.text)?!n.has(t):P2(e)?!0:e.wake===!0}function R2(e){return e.wake===!0}function z2(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 B2(e){return e.open<0||e.tools<1&&e.steps<1?!1:e.resumed||e.open!==e.close}function V2(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 H2(e){return BE(e,`card`).length>0}function U2({slug:e,subAgents:t,className:n=`px-1 pt-1.5`}){let r=BE(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)(UE,{kind:`AGENT`,label:t.label,state:t.state,density:`card`,depth:t.depth,startedAt:t.startedAt,parentSlug:e,onOpen:t.id?()=>ep(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:Bj(e,t)},t.id??`${t.startedAt}-${n}`))})}var W2=320;function G2(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 K2(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 q2=0,J2=``;function Y2(){q2++===0&&(J2=document.documentElement.style.overflowAnchor,document.documentElement.style.overflowAnchor=`none`)}function X2(){q2>0&&--q2===0&&(document.documentElement.style.overflowAnchor=J2)}function Z2({thread:e,onSnooze:t,onSnoozeFailed:n}){return(0,L.jsx)(p$,{thread:e,onSnooze:t,onSnoozeFailed:n})}function Q2(){let e=kC(),t=yT(jC(e?.threads??[]).filter(bT),Zt(tT).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=lH(),b=e=>v(e.id)||cH(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=K2(e);h.current=t?{kind:`top`,slug:t}:null}else{let t=G2(e);h.current=t?{kind:`hold`,...t}:null}f.current.add(e),d.current.delete(e),_(e=>e+1)},W2);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}Y2();let n=()=>{let t=Uf(e.slug);t!==null&&Math.abs(_d()-t)>.5&&window.scrollTo({top:t,left:0,behavior:`auto`})};n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n(),X2()})})},[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)($2,{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)(t4,{slug:e.id,leaving:v(e.id),children:(0,L.jsx)(i4,{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)(nH,{}),(0,L.jsx)(dz,{autoFocus:!0})]}):x.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-2 pt-2`,children:[(0,L.jsx)(Om,{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 $2({board:e}){let t=e?.errorItems??[],n=e?.errors??[];return t.length===0&&n.length===0?null:(0,L.jsxs)(`div`,{className:`mb-6 ${Kq} 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)(e4,{file:e.file})]},t)):n.slice(0,3).map((e,t)=>(0,L.jsx)(`div`,{className:`truncate`,title:e,children:e},t))]})}function e4({file:e}){let t=it({mutationFn:()=>Y.repairThread({file:e}),onSuccess:({slug:e})=>Z(`Repaired ${e} — verify its status`),onError:e=>Z(e instanceof Error?e.message:`Repair failed`)});return(0,L.jsx)(`button`,{onClick:()=>t.mutate(),disabled:t.isPending,className:`shrink-0 rounded border border-amber-400/50 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-100 transition-colors hover:bg-amber-500/25 disabled:opacity-50`,title:`Prepend minimal frontmatter (title + status: active) so this thread becomes visible again`,children:t.isPending?`Repairing…`:`Repair`})}function t4({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 n4({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)(RJ,{icon:rm,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 r4({toolCount:e,onExpand:t}){let n=e>0?`${e} tool call${e===1?``:`s`}`:``;return(0,L.jsxs)(RJ,{icon:rm,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 i4=(0,I.memo)(function({thread:e,leaving:t,frozen:n,onResolve:r,onUnresolve:i}){let a=Zt(X),[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(0),v=(0,I.useRef)(null),y=(0,I.useRef)(null),b=(0,I.useRef)(!1),x=(0,I.useRef)(!1),S=(0,I.useRef)(null),C=Ve(),w=D$(e.id),T=UC(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)(()=>f0(A),[A]),M=e=>j>=0&&e<j,N=u$(e),P=e=>M(e)||e===j&&N,ee=(0,I.useMemo)(()=>CJ(A),[A]),F=(0,I.useMemo)(()=>PY(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`||d0(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)(()=>I2(A),[A]),ie=(0,I.useMemo)(()=>A.map((e,t)=>{if(!e||e.queued||d0(e,P(t)))return{skip:!0};if(e.boundary===`rest`)return{skip:!0,closes:!0};let n=nZ(e),r=n?0:e.tools.length;return{text:h0(e,P(t)),tools:r,countable:h0(e,P(t))||r>0||n!==void 0||e.kind!==void 0,survives:L2(e,t,re),opens:R2(e),completion:e.boundary===`wake`||n!==void 0}}),[A,re]),ae=(0,I.useMemo)(()=>z2(ie,F+1),[ie,F]),{kept:oe,middle:se}=(0,I.useMemo)(()=>V2(ae),[ae]),ce=(0,I.useMemo)(()=>oe.filter(B2),[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=ux(A,f,F),fe=(0,I.useMemo)(()=>A.slice(de),[A,de]),pe=(0,I.useMemo)(()=>Z$(fe).map(e=>({...e,messageIndex:e.messageIndex+de})),[fe,de]),me=(0,I.useMemo)(()=>{let t=[],n=new Map,r=A.length-1,i=e.runtime!==`running`&&e.runtime!==`spawning`;for(let[a,o]of DJ(A,e?.questions??[],{atRest:i})){if(a>=r){t.push(...o);continue}let e=n.get(a);e?e.push(...o):n.set(a,[...o])}return{byAnchor:n,tail:t}},[A,e.runtime,e?.questions]),he=(0,I.useMemo)(()=>AJ(A,e?.questions??[]),[A,e?.questions]),ge=(0,I.useMemo)(()=>vJ(A,e.answersInFlight),[A,e.answersInFlight]),_e=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=()=>{_x(t,e.anchor,e=>{e!==0&&window.scrollBy({top:e,left:0,behavior:`auto`})});let n=0;return _x(t,e.anchor,e=>{n=e}),n},r=n();if(vx({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,X2())})}))},[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,X2()))},[D?.transcriptKey]),(0,I.useEffect)(()=>()=>{b.current&&(b.current=!1,X2())},[]);let ve=e=>{let t=hx(v.current);!e||!t||(b.current||(b.current=!0,Y2()),y.current={anchor:t,targetStartId:e})},ye=async()=>{if(m||!_e)return;let t=lx(A,de),n=t!==null&&A[t]?.role===`user`?t:null;if(n!==null){let e=A[n].sourceId;ve(e),p(e??null);return}let r=D?.beforeCursor;if(!r){if(de>0){let e=A[0]?.sourceId;ve(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;ve(a);let o=mx(n,t);C.setQueryData([`transcript`,e.id],o),p(a??null)}catch(e){await T.refetch(),p(null),Z(e instanceof Error?e.message:`Could not load earlier transcript history`)}finally{h(!1)}}},be=it({mutationFn:()=>Y.markComplete({slug:e.id})}),{answeringForMessage:xe,answerable:Se,anyAnswered:Ce,sendAnswers:we,sendMessage:Te}=gY(e.id,A,()=>{document.activeElement?.blur(),r(e.id)},{scrollToBottom:!1,onSendFailed:()=>i(e.id)}),Ee=(0,I.useMemo)(()=>{let e=mY(A);return e!==-1&&FJ(A[e].text,he.get(e)??[])},[A,he]),De=Se&&!Ee||Ce,Oe=(0,I.useCallback)(()=>r(e.id),[r,e.id]),ke=(0,I.useCallback)(()=>i(e.id),[i,e.id]),Ae=(0,I.useMemo)(()=>({dismiss:Oe,cancel:ke}),[Oe,ke]);return(0,L.jsx)(N1.Provider,{value:e.id,children:(0,L.jsx)(I1.Provider,{value:Ae,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(!Ce)return;let t=e.target;t instanceof HTMLButtonElement||t instanceof HTMLAnchorElement||t instanceof HTMLTextAreaElement&&t.value.trim()||FL({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(),we())},"data-vt-chat":!0,className:`flex flex-col min-w-0 max-w-full ${Kq} 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?Kq:`${qq} border-b border-border/60`}`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`group/thread-title flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`min-w-0 shrink truncate font-semibold text-[15px] leading-snug`,title:aT(e),children:aT(e)}),(0,L.jsx)(ZX,{thread:e})]}),(0,L.jsx)(v$,{at:gT(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)(O$,{slug:e.id}),(0,L.jsx)(gX,{thread:e,collapsed:o,onCollapse:()=>s(e=>!e),expand:!0,onDone:()=>be.mutate(void 0,{onSuccess:()=>r(e.id),onError:()=>d(!1)}),doneBusy:be.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 ${De?`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:[_e&&(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 ye(),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=[...me.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)(LJ,{h:14},`qa-space-${t}`)),n.push((0,L.jsx)(xQ,{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||d0(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)(LJ,{h:14},`middle-runs-space`)),n.push((0,L.jsx)(n4,{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&&!Eq(t.text)&&!P2(t)&&L2(t,i,re);if(d!==void 0&&i===d.waker){r!==null&&n.push((0,L.jsx)(LJ,{h:r&&a0(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)(Q0,{m:t,dense:!0})},e)),r=i0(t);return}if(f&&!h){if(!p&&!m&&!L2(t,i,re)||(!p&&u!==void 0&&!o.has(u)&&(r!==null&&n.push((0,L.jsx)(LJ,{h:14},`im-space-${u}`)),n.push((0,L.jsx)(r4,{toolCount:d.tools,onExpand:()=>l(!0)},`intermediate-summary-${u}`)),r=!1,o.add(u)),!h0(t,P(i))))return;r!==null&&n.push((0,L.jsx)(LJ,{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)(Q0,{m:t,dense:!0,textOnly:!0,answering:xe(t),paired:ee[i],staleAwaiting:M(i),restingCardShown:i===j&&N,shadowedBy:he.get(i),thread:e})},s)),r=!1,a(i);return}r!==null&&n.push((0,L.jsx)(LJ,{h:r&&a0(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)(Q0,{m:t,dense:!0,staleAwaiting:M(i),restingCardShown:i===j&&N,answering:xe(t),paired:ee[i],shadowedBy:he.get(i),thread:e})},g)),r=i0(t),a(i)}),fe.forEach((e,r)=>{e.queued&&(n.push((0,L.jsx)(LJ,{},`qs${r}`)),n.push((0,L.jsx)(Q0,{m:e,dense:!0,paired:ee[t+r]},`q${t+r}`)))}),n})()]}),!T.isLoading&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(QZ,{thread:e,className:`mt-4`}),e.pendingInteraction?null:e.pendingAsk?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(d2,{ask:e.pendingAsk,onTerminal:w})}):e.runtime===`perm-prompt`?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(c2,{onTerminal:w})}):null,e.permPolicy?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(l2,{policy:e.permPolicy,denies:e.permDenies})}):null]}),!T.isLoading&&u$(e)&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(Z2,{thread:e,onSnooze:Oe,onSnoozeFailed:ke})}),!T.isLoading&&Wq(e,j>=0?A[j]?.text:void 0)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(LJ,{}),(0,L.jsx)(a2,{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)(s2,{slug:e.id,sessionId:e.sessionId,pause:e.limitPause})}),!T.isLoading&&aJ(e,j>=0?A[j]?.text:void 0)&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(oJ,{thread:e})})]}),(0,L.jsx)(xQ,{thread:e,questions:me.tail,inFlight:ge,className:`shrink-0 px-5 pb-4 pt-0`}),De&&(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:!Ce,onClick:()=>we(),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)(lX,{slug:e.id,surface:`queueComposer`,className:`shrink-0 px-5 pb-3 pt-0`,placeholder:Se||(e.questions?.length??0)>0?`Or skip the questions and reply…`:`Reply to the agent…`,submitOverride:Te,ops:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(U2,{slug:e.id,subAgents:e.subAgents??[],className:`px-1 pt-1.5`}),(0,L.jsx)(u2,{slug:e.id,includeAgents:!1,className:`px-1 ${H2(e.subAgents??[])?`pt-0.5`:`pt-1.5`}`})]})})]})]}),(0,L.jsx)(KX,{thread:e,onArchived:()=>r(e.id),onDismissCancel:()=>i(e.id),onSnoozed:()=>r(e.id)})]})})})},a4);function a4(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 o4(e,t){if(e.backend===`claude`)return FR.some(t=>t.value===e.model)?BR(e.model).includes(e.effort)?void 0:`Reasoning level ${e.effort} is not available for ${e.model}`:`Claude model ${e.model} is no longer available`;let n=t.find(t=>t.slug===e.model);if(!n)return`Codex model ${e.model} is no longer available`;if(!n.efforts.includes(e.effort))return`Reasoning level ${e.effort} is not available for ${e.model}`}function s4(e,t){return{items:t.map(e=>({...e})),backend:e.backend,model:e.model,effort:e.effort}}function c4({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 l4=30;function u4({onClose:e}){let t=ZL(),{resolved:n,codexList:r,loadError:i,saveProfile:a}=JR(),[o,s]=(0,I.useState)(`issues`),[c,l]=(0,I.useState)(`recent`),[u,d]=(0,I.useState)(1),[f,p]=(0,I.useState)(()=>new Set),[m,h]=(0,I.useState)(null),g=nt({queryKey:[`githubList`,o,c,u],queryFn:()=>Y.githubList({kind:o,sort:c,page:u,perPage:l4}),placeholderData:ee}),_=g.data?.items??[],v=g.data?.page??u,y=g.data?.pageCount??1,b=g.data?.total??0,x=(0,I.useRef)(null);(0,I.useEffect)(()=>{x.current&&(x.current.scrollTop=0)},[u,o,c]);let S=it({mutationFn:e=>Y.githubDispatchBatch(e),onMutate:e=>Z(`Starting ${e.items.length} thread${e.items.length===1?``:`s`}…`,{spinner:!0,sticky:!0}),onSuccess:t=>{let n=t.dispatched.length,r=t.failed.length;Z(`Started ${n} thread${n===1?``:`s`}${r?` (${r} failed)`:``}`),e()},onError:e=>Z(`Dispatch failed: ${e.message.slice(0,80)}`)});function C(e){e!==o&&(s(e),d(1),p(new Set),h(null))}function w(e){e!==c&&(l(e),d(1),p(new Set),h(null))}function T(e,t){let n=c4({keys:_.map(e=>e.number),key:e,shiftKey:t,anchor:m,selected:f});p(n.selected),h(n.anchor)}function E(){p(new Set),h(null)}let D=t.data?.nameWithOwner??`this repo`,O=f.size,k=(0,I.useMemo)(()=>KR(r),[r]),A=n?{backend:n.backend,model:n.model,effort:n.effort}:void 0,j=A?o4(A,r):i?`Could not load the model catalogue — reopen once it loads`:void 0,M=j??(A?void 0:`Loading the model catalogue…`);function N(){if(!A||M){Z(M??`Choose a model and reasoning level`);return}S.mutate(s4(A,[...f].map(e=>({kind:o===`issues`?`issue`:`pr`,number:e}))))}return(0,L.jsx)(pz,{onClose:e,children:(0,L.jsxs)(`div`,{className:`flex max-h-[85vh] w-[720px] max-w-[90vw] flex-col rounded-xl border border-border bg-panel p-5 shadow-2xl shadow-black/50`,onKeyDownCapture:t=>{t.key===`Escape`&&(t.stopPropagation(),e())},children:[(0,L.jsxs)(`h2`,{className:`mb-4 flex items-center gap-2 text-[14px] font-medium`,children:[(0,L.jsx)(wm,{size:15,className:`text-muted`}),(0,L.jsx)(`span`,{children:`Investigate this issue and make recommendations`}),(0,L.jsx)(`span`,{className:`text-muted/40`,children:`—`}),(0,L.jsx)(`span`,{className:`font-mono-keep text-[12.5px] text-muted`,children:D})]}),(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,L.jsx)(f4,{value:o,onChange:e=>C(e),options:[{value:`issues`,label:`Issues`},{value:`prs`,label:`PRs`}]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`petite-caps text-[11px] text-muted/70`,children:`Sort`}),(0,L.jsx)(f4,{value:c,onChange:w,options:[{value:`recent`,label:`Recent`},{value:`reactions`,label:`Reactions`}]})]})]}),(0,L.jsx)(`div`,{ref:x,className:`min-h-[240px] flex-1 overflow-y-auto rounded-lg border border-border/70 bg-bg/40 transition-opacity ${g.isPlaceholderData?`opacity-40`:``}`,children:g.isLoading?(0,L.jsx)(x4,{}):g.isError?(0,L.jsxs)(S4,{children:[(0,L.jsxs)(`span`,{className:`text-[12.5px] text-muted/80`,children:[`Couldn't load `,o===`issues`?`issues`:`pull requests`,`.`]}),(0,L.jsx)(`span`,{className:`max-w-[80%] text-center text-[11px] text-muted/45`,children:g.error.message.slice(0,140)})]}):_.length===0?(0,L.jsxs)(S4,{children:[(0,L.jsx)(Om,{size:28,strokeWidth:1.25,className:`text-muted/30`}),(0,L.jsxs)(`span`,{className:`text-[12.5px] text-muted/60`,children:[`No open `,o===`issues`?`issues`:`pull requests`]})]}):_.map(e=>(0,L.jsx)(h4,{item:e,checked:f.has(e.number),onActivate:t=>T(e.number,t)},e.number))}),!g.isLoading&&!g.isError&&(0,L.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between gap-3 whitespace-nowrap text-[11.5px] text-muted/60`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsxs)(`span`,{className:`truncate tabular-nums`,children:[b,` open `,o===`issues`?b===1?`issue`:`issues`:b===1?`pull request`:`pull requests`]}),O>0&&(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`text-muted/30`,children:`·`}),(0,L.jsxs)(`span`,{className:`tabular-nums text-fg/70`,children:[O,` selected`]}),(0,L.jsx)(`button`,{onClick:E,onMouseDown:e=>e.preventDefault(),className:`rounded py-0.5 text-muted/60 underline-offset-2 outline-none transition-colors hover:text-fg hover:underline`,children:`Clear`})]})]}),y>1&&(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,L.jsx)(d4,{label:`Previous page`,disabled:v<=1,onClick:()=>d(Math.max(1,v-1)),children:(0,L.jsx)(em,{size:14})}),(0,L.jsxs)(`span`,{className:`relative px-2 text-center tabular-nums`,children:[(0,L.jsxs)(`span`,{"aria-hidden":!0,className:`invisible`,children:[`Page `,y,` of `,y]}),(0,L.jsxs)(`span`,{className:`absolute inset-0`,children:[`Page `,v,` of `,y]})]}),(0,L.jsx)(d4,{label:`Next page`,disabled:v>=y,onClick:()=>d(Math.min(y,v+1)),children:(0,L.jsx)(tm,{size:14})})]})]}),(0,L.jsxs)(`div`,{className:`mt-4 flex items-end justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(SR,{groups:k,value:n?{provider:n.backend,model:n.model,effort:n.effort}:void 0,onValueChange:e=>a({field:`profile`,backend:e.provider,model:e.model,effort:e.effort}),placeholder:i?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort`,title:M??`Model and reasoning effort for every thread this batch starts`,disabled:!n,side:`top`,menuZClass:Pj,className:`max-w-[min(21rem,60vw)]`}),j&&(0,L.jsx)(`p`,{className:`mt-1 max-w-[430px] text-[10.5px] text-red-400`,children:j})]}),(0,L.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,L.jsxs)(`button`,{disabled:O===0||S.isPending||!!M,onClick:N,onMouseDown:e=>e.preventDefault(),className:`flex items-center gap-2 rounded-md bg-fg px-3.5 py-1.5 text-[12.5px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:[S.isPending&&(0,L.jsx)(Mm,{size:13,className:`animate-spin`}),O<=1?`Start investigation`:`Start ${O} investigations`]})})]})]})})}function d4({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 f4({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 p4({item:e}){let t=(e.state??`OPEN`).toUpperCase();return e.kind===`pr`?t===`MERGED`?(0,L.jsx)(bm,{size:15,className:`shrink-0`,style:{color:wE.fgDone}}):t===`CLOSED`?(0,L.jsx)(xm,{size:15,className:`shrink-0`,style:{color:wE.fgDanger}}):e.isDraft?(0,L.jsx)(Sm,{size:15,className:`shrink-0`,style:{color:wE.fgNeutral}}):(0,L.jsx)(Cm,{size:15,className:`shrink-0`,style:{color:wE.fgSuccess}}):t===`CLOSED`?(0,L.jsx)(am,{size:15,className:`shrink-0`,style:{color:wE.fgDone}}):(0,L.jsx)(sm,{size:15,className:`shrink-0`,style:{color:wE.fgSuccess}})}function m4({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 h4({item:e,checked:t,onActivate:n}){let r=YT(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)(g4,{checked:t})}),(0,L.jsx)(`span`,{className:`mt-px`,children:(0,L.jsx)(p4,{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)(m4,{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)(y4,{prs:e.linkedPrs}):null,e.comments?(0,L.jsx)(b4,{icon:Im,n:e.comments,label:`comments`}):null,e.reactions?(0,L.jsx)(b4,{emoji:`👍`,n:e.reactions,label:`reactions`}):null]})]})}function g4({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)(Qp,{size:11,strokeWidth:3,className:`text-bg`})})}var _4={octicon:`-0.1em`,stroke:`-0.112em`};function v4({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(${_4.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 y4({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)(v4,{size:12}),e.count]})}function b4({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(${_4.stroke})`},children:(0,L.jsx)(e,{size:12,strokeWidth:2})}):null,n]})}function x4(){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 S4({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 C4={permissionMode:`The permission mode new Claude Code threads launch with. Auto runs safe actions and asks you to approve the risky ones in the thread. Bypass launches the worker with --dangerously-skip-permissions: it never asks, so nothing waits on you and nothing is checked either. Takes effect on the next thread you dispatch; to change a thread that already exists, use the picker beside its model in the prompt box. Codex threads always run with full workspace access and are unaffected.`,promptCacheTtl:`Which prompt-cache tier a new Claude thread writes to. A 1-hour entry costs twice the input price to write, a 5-minute entry 1.25 times; the hour only pays off when the thread's cache actually survives that long. Measured 2026-09-03: cache writes were half of a day's spend and the entries were lost every 15 to 30 minutes regardless, so 5 minutes was the cheaper tier. Automatic leaves the choice to Claude Code, which picks 1 hour on a subscription. Takes effect on the next thread you dispatch and on a thread that resumes after its worker exited.`,autoCompactWindow:`How large a new Claude thread's conversation may grow, in tokens, before Claude Code compacts it. Frizz launches every Claude thread with the 1M context window, so without a ceiling a long thread keeps re-sending everything it has read on every turn; 500K halves that at the cost of an earlier summary. Takes effect on the next thread you dispatch and on a thread that resumes after its worker exited; a thread whose worker is already running keeps its current ceiling. A thread's context dial reads against the ceiling it was launched with, not the model's full window.`,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 w4(){return typeof Notification>`u`?`unsupported`:Notification.permission}var T4=500,E4=1600,D4=2e3,O4=6;function k4(){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=>{u5.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`),E4))}).catch(i=>{--a.current,t(`error`),!(n.current||!lf(i)||s.current>=O4)&&(s.current+=1,n.current=e,r.current=window.setTimeout(c.current,D4))}))},[]);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,T4)},[l]);return(0,I.useEffect)(()=>()=>{l(),o.current!==void 0&&window.clearTimeout(o.current)},[l]),{state:e,queue:u,flush:l}}function A4(){let e=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()}),[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(w4()),{state:a,queue:o,flush:s}=k4(),[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)(()=>(ld(p),()=>ld(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,Mp()?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:`${Op} z-50 flex justify-end ${c?`opacity-100`:`opacity-0`}`,onMouseDown:e=>e.target===e.currentTarget&&p(),children:(0,L.jsxs)(`div`,{className:`${kp} w-[560px] max-w-[94vw] ${c?`translate-x-0`:`translate-x-full`}`,children:[(0,L.jsx)(sh,{title:`Settings`,actions:(0,L.jsx)(j4,{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)(N4,{label:`Font`,help:C4.font,children:(0,L.jsx)(U4,{value:t.font??`mono`,onChange:e=>f({...t,font:e})})}),(0,L.jsx)(N4,{label:`Project sidebar`,help:C4.projectRail,children:(0,L.jsx)(iX,{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)(N4,{label:`Local file links`,help:C4.localFileOpener,children:(0,L.jsx)(iX,{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)(N4,{label:`Density`,help:C4.density,children:(0,L.jsx)(G4,{})}),(0,L.jsx)(N4,{label:`Queue order`,help:C4.queueOrder,children:(0,L.jsx)(K4,{})}),(0,L.jsxs)(N4,{label:`Desktop notifications`,help:C4.notifications,children:[(0,L.jsx)(W4,{value:t.notifications,onChange:m}),t.notifications&&(0,L.jsx)(J4,{perm:r})]}),(0,L.jsx)(R4,{draft:t,setDraft:f}),(0,L.jsx)(z4,{draft:t,setDraft:f})]}):(0,L.jsx)(`div`,{className:`p-4 text-[13px] text-muted`,children:`Loading…`})]})})}function j4({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 M4({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)(Lj,{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)(cm,{size:12})})})]})}function N4({label:e,help:t,children:n}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(M4,{label:e,help:t}),n]})}var P4=[{token:`repo`,gloss:`repository`},{token:`n`,gloss:`number`},{token:`title`,gloss:`title`},{token:`url`,gloss:`link`},{token:`labels`,gloss:`labels`},{token:`body`,gloss:`description`}],F4=5e5,I4=[{value:`200000`,label:`200K tokens`},{value:`350000`,label:`350K tokens`},{value:`500000`,label:`500K tokens (default)`},{value:`750000`,label:`750K tokens`},{value:`1000000`,label:`1M tokens`}],L4=[{value:`auto`,label:`Automatic (default)`},{value:`5m`,label:`5 minutes`},{value:`1h`,label:`1 hour`}];function R4({draft:e,setDraft:t}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(B4,{label:`Claude`}),(0,L.jsxs)(N4,{label:`Permissions`,help:C4.permissionMode,children:[(0,L.jsx)(iX,{variant:`bordered`,value:e.permissionMode===`bypassPermissions`?`bypassPermissions`:`auto`,onValueChange:n=>t({...e,permissionMode:n}),options:PR,indicatorPosition:`right`,ariaLabel:`Claude permission mode`}),e.permissionMode===`bypassPermissions`&&(0,L.jsx)(q4,{})]}),(0,L.jsx)(N4,{label:`Compaction window`,help:C4.autoCompactWindow,children:(0,L.jsx)(iX,{variant:`bordered`,value:String(e.autoCompactWindow??F4),onValueChange:n=>t({...e,autoCompactWindow:Number(n)}),options:I4,indicatorPosition:`right`,ariaLabel:`Claude compaction window`})}),(0,L.jsx)(N4,{label:`Prompt cache tier`,help:C4.promptCacheTtl,children:(0,L.jsx)(iX,{variant:`bordered`,value:e.promptCacheTtl??`auto`,onValueChange:n=>t({...e,promptCacheTtl:n}),options:L4,indicatorPosition:`right`,ariaLabel:`Claude prompt cache tier`})})]})}function z4({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)(B4,{label:`Prompts`}),n.data?(0,L.jsx)(H4,{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 B4({label:e}){return(0,L.jsxs)(`div`,{className:`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 V4(){let[e,t]=(0,I.useState)(!1);return(0,L.jsxs)(oV,{open:e,onOpenChange:t,children:[(0,L.jsx)(sV,{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)(lV,{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:P4.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 H4({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)(M4,{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)(V4,{})]})]}),(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 U4({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 W4({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 G4(){let{compactDiffs:e}=Zt(tT);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:()=>tT.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 K4(){let{queueOrder:e}=Zt(tT);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:()=>tT.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 q4(){return(0,L.jsx)(`span`,{className:`text-[11px] text-muted/70`,children:`New Claude threads will run every command, edit, and network call without asking you first.`})}function J4({perm:e}){return e===`denied`?(0,L.jsx)(X4,{}):(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 Y4(){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 X4(){let e=(0,I.useMemo)(Y4,[]),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)(Q4,{url:n,hint:`Paste this into a new tab, set Notifications → Allow:`}):e===`safari`?(0,L.jsxs)(`span`,{children:[`Safari → Settings → Websites → Notifications → allow `,Z4(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 Z4(e){try{return new URL(e).host}catch{return e}}function Q4({url:e,hint:t}){let[n,r]=(0,I.useState)(!1);async function i(){try{await CR(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)(Qp,{size:11,className:`text-live`}):(0,L.jsx)(fm,{size:11})})]})]})}var $4=1,e3=.9,t3=.8,n3=.17,r3=.1,i3=.999,a3=.9999,o3=.99,s3=/[\\\/_+.#"@\[\(\{&]/,c3=/[\\\/_+.#"@\[\(\{&]/g,l3=/[\s-]/,u3=/[\s-]/g;function d3(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?$4:o3;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=d3(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=$4:s3.test(e.charAt(l-1))?(d*=t3,p=e.slice(i,l-1).match(c3),p&&i>0&&(d*=i3**+p.length)):l3.test(e.charAt(l-1))?(d*=e3,m=e.slice(i,l-1).match(u3),m&&i>0&&(d*=i3**+m.length)):(d*=n3,i>0&&(d*=i3**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=a3)),(d<r3&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=d3(e,t,n,r,l+1,a+2,o),f*r3>d&&(d=f*r3)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function f3(e){return e.toLowerCase().replace(u3,` `)}function p3(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,d3(e,t,f3(e),f3(t),0,0,{})}var m3=`[cmdk-group=""]`,h3=`[cmdk-group-items=""]`,g3=`[cmdk-group-heading=""]`,_3=`[cmdk-item=""]`,v3=`${_3}:not([aria-disabled="true"])`,y3=`cmdk-item-select`,b3=`data-value`,x3=(e,t,n)=>p3(e,t,n),S3=I.createContext(void 0),C3=()=>I.useContext(S3),w3=I.createContext(void 0),T3=()=>I.useContext(w3),E3=I.createContext(void 0),D3=I.forwardRef((e,t)=>{let n=V3(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=V3(()=>new Set),i=V3(()=>new Map),a=V3(()=>new Map),o=V3(()=>new Set),s=z3(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=UD(),y=UD(),b=UD(),x=I.useRef(null),S=W3();B3(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),B3(()=>{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??x3;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(h3);t?t.appendChild(e.parentElement===t?e:e.closest(`${h3} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${h3} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${m3}[${b3}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(b3);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(m3)?.querySelector(g3))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${_3}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(v3)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(b3))}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(b3))}function P(e){let t=A()?.closest(m3),n;for(;t&&!n;)t=e>0?L3(t,m3):R3(t,m3),n=t?.querySelector(v3);n?C.setState(`value`,n.getAttribute(b3)):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(bD.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(y3);t.dispatchEvent(e)}}}}},I.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:q3},c),K3(e,e=>I.createElement(w3.Provider,{value:C},I.createElement(S3.Provider,{value:w},e))))}),O3=I.forwardRef((e,t)=>{let n=UD(),r=I.useRef(null),i=I.useContext(E3),a=C3(),o=z3(e),s=o.current?.forceMount??i?.forceMount;B3(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=U3(n,r,[e.value,e.children,r],e.keywords),l=T3(),u=H3(e=>e.value&&e.value===c.current),d=H3(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(y3,f),()=>t.removeEventListener(y3,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(bD.div,{ref:rD(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)}),k3=I.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=UD(),s=I.useRef(null),c=I.useRef(null),l=UD(),u=C3(),d=H3(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);B3(()=>u.group(o),[]),U3(o,s,[e.value,e.heading,c]);let f=I.useMemo(()=>({id:o,forceMount:i}),[i]);return I.createElement(bD.div,{ref:rD(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),K3(e,e=>I.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},I.createElement(E3.Provider,{value:f},e))))}),A3=I.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=I.useRef(null),a=H3(e=>!e.search);return!n&&!a?null:I.createElement(bD.div,{ref:rD(i,t),...r,"cmdk-separator":``,role:`separator`})}),j3=I.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=T3(),o=H3(e=>e.search),s=H3(e=>e.selectedItemId),c=C3();return I.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),I.createElement(bD.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)}})}),M3=I.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=I.useRef(null),o=I.useRef(null),s=H3(e=>e.selectedItemId),c=C3();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(bD.div,{ref:rD(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},K3(e,e=>I.createElement(`div`,{ref:rD(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),N3=I.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return I.createElement(NI,{open:n,onOpenChange:r},I.createElement(zI,{container:o},I.createElement(VI,{"cmdk-overlay":``,className:i}),I.createElement(GI,{"aria-label":e.label,"cmdk-dialog":``,className:a},I.createElement(D3,{ref:t,...s}))))}),P3=I.forwardRef((e,t)=>H3(e=>e.filtered.count===0)?I.createElement(bD.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),F3=I.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return I.createElement(bD.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},K3(e,e=>I.createElement(`div`,{"aria-hidden":!0},e)))}),I3=Object.assign(D3,{List:M3,Item:O3,Input:j3,Group:k3,Separator:A3,Dialog:N3,Empty:P3,Loading:F3});function L3(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function R3(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function z3(e){let t=I.useRef(e);return B3(()=>{t.current=e}),t}var B3=typeof window>`u`?I.useEffect:I.useLayoutEffect;function V3(e){let t=I.useRef();return t.current===void 0&&(t.current=e()),t}function H3(e){let t=T3(),n=()=>e(t.snapshot());return I.useSyncExternalStore(t.subscribe,n,n)}function U3(e,t,n,r=[]){let i=I.useRef(),a=C3();return B3(()=>{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(b3,s),i.current=s}),i}var W3=()=>{let[e,t]=I.useState(),n=V3(()=>new Map);return B3(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function G3(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function K3({asChild:e,children:t},n){return e&&I.isValidElement(t)?I.cloneElement(G3(t),{ref:t.ref},n(t.props.children)):n(t)}var q3={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function J3(){let e=Zt(X),t=kC(),[n,r]=(0,I.useState)(``);if((0,I.useEffect)(()=>{e.showPalette&&r(``)},[e.showPalette]),!e.showPalette)return null;let i=_T(jC(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){np(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)(I3,{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)(I3.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)(I3.List,{className:`max-h-[52vh] overflow-y-auto py-1.5`,children:[(0,L.jsx)(I3.Empty,{className:`px-4 py-6 text-center text-sm text-muted`,children:`No matches.`}),(0,L.jsxs)(I3.Group,{heading:`Actions`,className:`cmdk-group`,children:[(0,L.jsx)(Y3,{value:`new thread create home`,onSelect:()=>c(()=>Wf()),children:`New thread`}),(0,L.jsx)(Y3,{value:`queue todos inbox pending`,onSelect:()=>c(()=>{xp(X.drawers.map(e=>e.id)),X.view=`todos`}),children:`Queue`}),(0,L.jsx)(Y3,{value:`open settings preferences`,onSelect:()=>c(()=>X.showSettings=!0),children:`Open settings`}),o&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Y3,{value:`open details drawer doc ${aT(o)}`,onSelect:()=>c(()=>{let e=Sp();e&&$f(`doc`,e)}),children:`Open thread details`}),(0,L.jsxs)(Y3,{value:`mark complete done ${aT(o)}`,onSelect:()=>c(()=>Y.markComplete({slug:o.id}).catch(()=>{})),children:[`Mark “`,aT(o),`” complete`]}),(0,L.jsxs)(Y3,{value:`mark read ${aT(o)}`,onSelect:()=>c(()=>Y.markRead({slug:o.id}).catch(()=>{})),children:[`Mark “`,aT(o),`” read`]})]})]}),i.length>0&&(0,L.jsx)(I3.Group,{heading:`Threads`,className:`cmdk-group`,children:i.map(e=>(0,L.jsxs)(Y3,{value:`${aT(e)} ${e.id}`,onSelect:()=>c(()=>l(e.id)),children:[(0,L.jsx)(`span`,{className:`truncate`,children:aT(e)}),(0,L.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted/70`,children:e.id})]},e.id))})]})]})})}function Y3({value:e,onSelect:t,children:n}){return(0,L.jsx)(I3.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 X3=`Updating and restarting Frizz`,Z3=`This may take a moment while the new build is being prepared. All of your threads will continue running normally.`;function Q3(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 $3({open:e,message:t}){let n=(0,I.useRef)(null);if((0,I.useEffect)(()=>{if(!e)return;let t=document.activeElement;t instanceof HTMLElement&&t.blur(),n.current?.focus({preventScroll:!0});let r=e=>{Q3(e)&&(e.preventDefault(),e.stopImmediatePropagation())};return window.addEventListener(`keydown`,r,{capture:!0}),()=>window.removeEventListener(`keydown`,r,{capture:!0})},[e]),!e)return null;let r=t?.trim()?t.trim():null;return(0,L.jsx)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":X3,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:n,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)(Gm,{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:X3}),(0,L.jsx)(`p`,{className:`mt-2 text-[12.5px] leading-relaxed text-muted`,children:Z3}),r&&(0,L.jsx)(`p`,{"aria-live":`polite`,className:`mt-2 text-[11.5px] leading-relaxed text-muted/80`,children:r})]})})}var e6=`frizz:reload-after-update-restart`,t6=!1;function n6(){t6||(t6=!0,Z("Sign in to the GitHub CLI (`gh auth login`) to dispatch from issues/PRs.",{duration:6e3}))}function r6(){let e=Zt(X),t=(0,I.useRef)({projectDir:null,hasBeenVisible:!1});(0,I.useEffect)(()=>{Y.board().then(Tp).catch(()=>{})},[]);let n=Rv();(0,I.useEffect)(()=>rw((e,t)=>n(e,t)),[n]);let{data:r,dataUpdatedAt:i}=RV(),a=(0,I.useRef)(null);(0,I.useEffect)(()=>{let e=r;if(!e)return;X.controlPlaneRestartPending?e.state!==`ready`&&(X.controlPlaneRestartPending=!1,X.controlPlaneState=e.state,X.controlPlaneMessage=e.message??null):(X.controlPlaneState=e.state,X.controlPlaneMessage=e.message??null);let t=sessionStorage.getItem(e6);if(e.state===`ready`&&t&&!X.controlPlaneRestartPending){sessionStorage.removeItem(e6),window.location.replace(t);return}e.state===`failed`&&t&&(sessionStorage.removeItem(e6),a.current!==e.message&&(a.current=e.message??`Update & Restart failed`,Z(`Update & Restart failed — Frizz kept running the previous version`,{duration:7e3})))},[r,i]);let o=e.drawers.length>0||e.showSettings||e.showNewThread||e.showGithubPicker||e.showPalette;(0,I.useEffect)(()=>{if(!o)return;let e=window.scrollY,t=document.body;return xd(),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,xd()??e)}},[o]);let s=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()});(0,I.useEffect)(()=>{X.notificationsEnabled=s.data?.notifications??!1},[s.data?.notifications]);let c=ZL();(0,I.useEffect)(()=>{c.data?.inRepo&&!c.data.authed&&n6()},[c.data?.inRepo,c.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=vp(),n=Sp();t?.kind===`doc`?(e.preventDefault(),md(t.id)||X.drawers.pop()):n&&(e.preventDefault(),$f(`doc`,n))}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let l=kC(),u=iW();(0,I.useEffect)(()=>{rp()},[l,e.routeThreadSlug]),t.current=iw(t.current,l);let d=l!==null&&t.current.hasBeenVisible,f=l===null&&ow(Dd()),p=t.current.hasBeenVisible;(0,I.useEffect)(()=>{l!==null&&sw(Dd(),p)},[l,p]);let m=l?.projectLabel??l?.projectName;return(0,I.useEffect)(()=>{let e=window.matchMedia?.(`(display-mode: standalone)`).matches;document.title=e?m??`Frizz`:m?`${m} — Frizz`:`Frizz`},[m]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)($3,{open:e.controlPlaneState===`restarting`,message:e.controlPlaneMessage}),(0,L.jsxs)(`div`,{inert:e.controlPlaneState===`restarting`,className:`relative min-h-screen bg-bg text-fg text-sm`,children:[u?(0,L.jsx)(QU,{}):(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:[d&&(0,L.jsx)(lh,{label:`the sidebar`,children:(0,L.jsx)(tU,{})}),f&&(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`||!l?`min-h-screen`:``} ${e.view===`todos`?``:`rounded-lg border border-border bg-panel`}`,children:l?(0,L.jsxs)(lh,{label:`the queue`,resetKeys:[e.view],children:[e.view.startsWith(`status:`)&&(0,L.jsx)(FU,{status:e.view.slice(7)}),e.view===`todos`&&(0,L.jsx)(Q2,{})]}):(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)(N2,{}),e.showSettings&&(0,L.jsx)(A4,{}),e.showNewThread&&(0,L.jsx)(fz,{onClose:()=>{X.showNewThread=!1}}),e.showGithubPicker&&(0,L.jsx)(u4,{onClose:Kf}),(0,L.jsx)(J3,{})]})]})}function i6(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 a6(e,t,n,r=48){let i=Math.round(t/r);return Math.max(0,Math.min(n-1,e+i))}function o6(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 s6(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 c6=`w-[57px]`,l6=`max-[800px]:pl-0 pl-[57px]`;function u6(e){let t=0;for(let n=0;n<e.length;n++)t=(t*31+e.charCodeAt(n))%360;return t}function d6(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 f6(e){let t=e.iconVersion?`&v=${encodeURIComponent(e.iconVersion)}`:``;return`/_frizz/project-icon?id=${encodeURIComponent(e.id)}${t}`}function p6({project:e,size:t}){let[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(!1),o=u6(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:d6(e.name)})}),s&&!c&&(0,L.jsx)(`img`,{src:f6(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 m6=40;function h6({project:e,current:t,count:n,index:r,drag:i,onPointerDown:a,onKeyDown:o}){let s=i?.fromIndex===r,c=i?s?i.deltaY:o6(r,i.fromIndex,i.toIndex):0;return(0,L.jsx)(Lj,{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)(fb,{to:Od(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||y6())&&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)(p6,{project:e,size:m6})}),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 g6({project:e,children:t}){let n=(0,I.useRef)(null),r=Ve(),i=()=>r.invalidateQueries({queryKey:[`projectsList`]}),a=e=>Z(e instanceof Error?e.message:String(e),{duration:7e3}),o=it({mutationFn:async t=>{let n=new Uint8Array(await t.arrayBuffer()),r=``;for(let e=0;e<n.length;e+=8192)r+=String.fromCharCode(...n.subarray(e,e+8192));return Y.projectIconSet({id:e.id,name:t.name,data:btoa(r)})},onSuccess:()=>void i(),onError:a}),s=it({mutationFn:()=>Y.projectIconClear({id:e.id}),onSuccess:()=>void i(),onError:a}),c=it({mutationFn:()=>Y.projectIconPick({id:e.id}),onSuccess:e=>{if(e.kind!==`cancelled`){if(e.kind===`unavailable`){n.current?.click();return}i()}},onError:()=>n.current?.click()}),l=`cursor-default rounded px-2 py-1.5 text-[12.5px] text-fg outline-none data-[highlighted]:bg-panel-2`;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`input`,{ref:n,type:`file`,accept:od.map(e=>`.${e}`).join(`,`),className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&o.mutate(t)}}),(0,L.jsxs)(dI,{children:[(0,L.jsx)(fI,{asChild:!0,children:t}),(0,L.jsx)(pI,{children:(0,L.jsxs)(mI,{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)(_I,{className:l,onSelect:()=>c.mutate(),children:o.isPending?`Uploading…`:`Choose an icon…`}),(0,L.jsx)(_I,{className:l,onSelect:()=>s.mutate(),children:e.iconIsCustom?`Use the detected icon`:`Look for an icon again`})]})})]})]})}var _6=4,v6=0;function y6(){return Date.now()-v6<250}function b6(e,t){let n=nt({queryKey:[`projectsQueueCounts`],queryFn:()=>Y.projectsQueueCounts(),refetchInterval:5e3}),r=Zt(X).board,i=e!==void 0&&r?jC(r.threads).filter(bT).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 x6(){let e=Ve(),{data:t}=nt({queryKey:[`projectsList`],queryFn:()=>Y.projectsList()}),n=Dd(),[r,i]=(0,I.useState)(!1),a=Rv(),[o,s]=(0,I.useState)(null),[c,l]=(0,I.useState)(null),u=(0,I.useRef)(null),d=it({mutationFn:()=>Y.projectPick({}),onSuccess:e=>{e.kind===`picked`?a(Od(e.project.slug)):e.kind===`unavailable`&&a(`/`)},onSettled:()=>i(!1)}),f=it({mutationFn:e=>Y.projectsReorder({ids:e}),onSuccess:async()=>{await e.invalidateQueries({queryKey:[`projectsList`]}),l(null)},onError:()=>l(null)}),p=c??t??[],m=b6(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=s6(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:a6(t,c,i.length),deltaY:c},s(o)},m=0,h=e=>{if(!a){if(Math.abs(e.clientY-r)<_6)return;a=!0,n.setPointerCapture(e.pointerId)}e.preventDefault();let t=e.clientY;cancelAnimationFrame(c);let i=()=>{d(t),u.current&&s6(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;v6=Date.now();let e=i6(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=i6(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 ${c6}`,children:[(0,L.jsx)(Lj,{side:`right`,label:`All projects`,children:(0,L.jsx)(fb,{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)(Em,{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)(h6,{project:e,index:t,current:e.slug===n,count:m(e),drag:o,onPointerDown:_,onKeyDown:v},e.id))}),(0,L.jsx)(Lj,{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)(Wm,{size:16})})})]})}var S6=76;function C6(e,t){return t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}var w6=`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`,T6=`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`,E6=38;function D6({project:e,home:t}){let n=WT(e.lastOpenedAt),[r,i]=(0,I.useState)(!1);return(0,L.jsxs)(`div`,{className:`group/card relative`,children:[(0,L.jsxs)(fb,{to:Od(e.slug),className:`${w6} ${T6} 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)(p6,{project:e,size:E6})}),(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:C6(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)(g6,{project:e,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":`Change the icon for ${e.name}`,style:{width:E6,height:E6},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)(Dm,{size:16,strokeWidth:1.75})})}),(0,L.jsx)(O6,{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)(pm,{size:15})})}),r?(0,L.jsx)(k6,{project:e,home:t,onClose:()=>i(!1)}):null]})}function O6({onDelete:e,children:t}){return(0,L.jsxs)(dI,{children:[(0,L.jsx)(fI,{asChild:!0,children:t}),(0,L.jsx)(pI,{children:(0,L.jsx)(mI,{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)(_I,{className:`cursor-default rounded px-2 py-1.5 text-[12.5px] text-red-400 outline-none data-[highlighted]:bg-red-500/10 data-[highlighted]:text-red-300`,onSelect:e,children:`Delete project…`})})})]})}function k6({project:e,home:t,onClose:n}){let[r,i]=(0,I.useState)(!1),a=Ve(),o=it({mutationFn:()=>Y.projectRemove({id:e.id,deleteData:r}),onSuccess:t=>{a.invalidateQueries({queryKey:[`projectsList`]}),Z(t.stoppedWorkers>0?`Deleted ${e.name} — ${t.stoppedWorkers} ${t.stoppedWorkers===1?`worker`:`workers`} stopped`:`Deleted ${e.name}`),n()}}),s=o.error instanceof Error?o.error.message:o.error?String(o.error):null;return(0,L.jsx)(CX,{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)(Mm,{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:C6(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 A6({hero:e,pending:t,onClick:n}){return(0,L.jsxs)(`button`,{type:`button`,onClick:n,disabled:t,className:`${w6} 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 j6({reason:e,proposed:t,onClose:n}){let[r,i]=(0,I.useState)(t??``),a=Rv(),o=Ve(),s=it({mutationFn:e=>Y.projectAdd({path:e}),onSuccess:e=>{o.invalidateQueries({queryKey:[`projectsList`]}),a(Od(e.slug))}}),c=s.error instanceof Error?s.error.message:s.error?String(s.error):null;return(0,L.jsx)(NI,{open:!0,onOpenChange:e=>{!e&&!s.isPending&&n()},children:(0,L.jsxs)(zI,{children:[(0,L.jsx)(VI,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(GI,{"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)(XI,{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 M6(){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=Rv(),i=Ve(),a=it({mutationFn:()=>Y.projectPick({}),onSuccess:e=>{if(e.kind!==`cancelled`){if(e.kind===`unavailable`){n({reason:e.reason});return}i.invalidateQueries({queryKey:[`projectsList`]}),r(Od(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:S6,height:S6,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)(D6,{project:e,home:l},e.id)),(0,L.jsx)(A6,{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)(j6,{reason:t.reason,proposed:e,onClose:()=>n(null)}):null]})}function N6(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 P6(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 F6({slug:e,path:t}){let n=FS(t),r=MC(t),i=nt({...zS(t),refetchInterval:r?!1:BS}),a=i.data?.path??t,o=i.data?.markdown??``,{front:s,body:c}=D2(n?o:``),[l,u]=(0,I.useState)(n?`rendered`:`source`),d=pK(c,{baseDir:LS(a),asDocument:!0}),f=$K(d),p=$K((0,I.useMemo)(()=>l===`source`?US(a,o):``,[o,a,l])),m=(0,I.useRef)(null),h=(0,I.useRef)(null),g=(0,I.useRef)(null);dq(m,d);let _=a.split(`/`).filter(Boolean).pop()||a,v=sz(),y=cz(e);return(0,I.useEffect)(()=>{let t=()=>document.querySelector(`main[data-standalone-thread] textarea`);function n(e,t){return e?document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0?t.length:Math.min(e.selectionStart??t.length,t.length):t.length}function r(r){if(!(r.metaKey||r.ctrlKey)||r.altKey||r.shiftKey||r.key.toLowerCase()!==`i`)return;let i=g.current,s=window.getSelection(),c=s&&!s.isCollapsed&&s.rangeCount>0?s.getRangeAt(0):null,l=!!(i&&c&&i.contains(c.commonAncestorContainer)),u=l?s.toString():``;if(!l||!u.trim()){r.preventDefault(),r.stopPropagation();let e=t();if(!e)return;document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0&&e.setSelectionRange(e.value.length,e.value.length),e.focus();return}r.preventDefault(),r.stopPropagation();let d=null,f=h.current;if(f&&f.contains(c.commonAncestorContainer)){let e=N6(f,c.startContainer,c.startOffset),t=N6(f,c.endContainer,c.endOffset);e!==null&&t!==null&&(d={startLine:P6(o,Math.min(e,t)),endLine:P6(o,Math.max(0,Math.max(e,t)-1))})}else d=TL(o,u);let p=t(),m=oz.followUp(v,e,y),{prose:_,attachments:b}=mL(iz.get(m)),x=SL(gL({path:a,...d??{}}),X.composerContext[e]??[],_),S=CL(_,n(p,_),x);iz.set(m,hL(S.prose,b.map(e=>e.path))),hp(e,{token:x,path:a,text:u,...d??{}}),s.removeAllRanges(),requestAnimationFrame(()=>{let e=t();e&&(e.setSelectionRange(S.caret,S.caret),e.focus())})}return window.addEventListener(`keydown`,r,!0),()=>window.removeEventListener(`keydown`,r,!0)},[e,a,o,v,y]),(0,L.jsxs)(`div`,{ref:g,"data-file-viewer-panel":!0,className:`flex h-full min-h-0 flex-col`,children:[(0,L.jsx)(sh,{title:_,subtitle:a,onClose:pp,actions:n?(0,L.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5 rounded-md border border-border-strong p-0.5 text-[11px] font-medium`,role:`group`,"aria-label":`File view`,children:[`rendered`,`source`].map(e=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>u(e),"aria-pressed":l===e,className:`rounded px-2 py-0.5 transition-colors ${l===e?`bg-panel-2 text-fg`:`text-muted hover:text-fg`}`,children:e===`rendered`?`Rendered`:`Source`},e))}):null}),(0,L.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:[i.isLoading?(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):i.error?(0,L.jsxs)(`div`,{className:`text-[13px] text-red-400/90`,children:[`Couldn’t read this file: `,i.error.message]}):l===`source`?o?(0,L.jsx)(`pre`,{ref:h,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:p}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):d?(0,L.jsxs)(L.Fragment,{children:[s&&(0,L.jsx)(A2,{source:s}),(0,L.jsx)(`div`,{ref:m,className:`md-body`,dangerouslySetInnerHTML:f})]}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!i.isLoading&&!i.error&&i.data?.truncated&&(0,L.jsx)(`p`,{className:`mt-4 border-t border-border/60 pt-3 text-[12px] text-muted`,children:`This file is too long to render in full — everything above the cut is shown. Open it to read the rest.`})]}),(0,L.jsxs)(`div`,{className:`shrink-0 flex items-center justify-between gap-3 border-t border-border/60 bg-panel px-5 pt-3`,style:O2,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)(k2,{path:a})]})]})}function I6(){return{dirs:new Map,files:new Map}}function L6(e,t){let n=e.replace(/\/+$/,``);if(t){let e=t.replace(/\/+$/,``);if(n.startsWith(e+`/`))return n.slice(e.length+1).split(`/`).filter(Boolean)}let r=n.split(`/`).filter(Boolean);return n.startsWith(`/`)?[`/`,...r]:r}var R6=(e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`,numeric:!0});function z6(e,t){let n=[];for(let r of[...e.dirs.keys()].sort(R6)){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:z6(i,t+1)})}for(let r of[...e.files.keys()].sort(R6))n.push({kind:`file`,name:r,depth:t,file:e.files.get(r)});return n}function B6(e,t){let n=I6();for(let r of e){let e=L6(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=I6(),i.dirs.set(t,e)),i=e}i.files.set(e[e.length-1],r)}return z6(n,0)}function V6(e){let t=[],n=e=>{for(let r of e)t.push(r),r.kind===`dir`&&n(r.children)};return n(e),t}var H6=10;function U6({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*H6},children:[(0,L.jsx)(`span`,{className:`flex shrink-0`,children:(0,L.jsx)(_m,{size:12,className:`${LQ} text-muted/45`})}),(0,L.jsx)(`span`,{className:`ml-[5px] min-w-0 truncate`,title:e,children:e})]})}function W6({files:e}){return(0,L.jsx)(`div`,{"data-edited-file-tree":!0,className:`col-span-4 flex flex-col gap-y-px`,children:V6(B6(e,AC())).map(e=>e.kind===`dir`?(0,L.jsx)(U6,{name:e.name,depth:e.depth},`d:${e.depth}:${e.name}`):(0,L.jsx)(G6,{file:e.file,name:e.name,depth:e.depth},e.file.path))})}function G6({file:e,name:t,depth:n}){let r=Ve();return(0,L.jsx)(YQ,{testKind:`file`,testId:e.path,mark:(0,L.jsx)(hm,{size:12,className:`${LQ} -mr-[2px] text-muted/60`}),name:t,indent:n*H6,onOpen:()=>UK(e.path),onPrewarm:()=>GS(r,e.path),title:e.path,status:(0,L.jsxs)(L.Fragment,{children:[(e.added??0)>0&&(0,L.jsxs)(`span`,{style:{color:wE.fgSuccess},children:[`+`,e.added]}),(e.added??0)>0&&(e.removed??0)>0&&` `,(e.removed??0)>0&&(0,L.jsxs)(`span`,{style:{color:wE.fgDanger},children:[`−`,e.removed]})]})})}function K6({thread:e}){let t=oE(),n=UC(e.id,{poll:!1}).data?.editedFiles??[],r=n$(e),i=(e.bgShells??[]).filter(e=>e.state===`running`),a=(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`),o=(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`),{railFilesCollapsed:s}=Zt(tT),c=[{head:`Sub-agents`,rows:r.map(n=>(0,L.jsx)(r$,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:i.map(n=>(0,L.jsx)(e$,{shell:n,slug:e.id,now:t},n.id??n.label))},{head:`Pull requests`,rows:a.map(e=>(0,L.jsx)(XQ,{watch:e},e.id))},{head:`Timers`,rows:o.map(e=>(0,L.jsx)(t$,{watch:e,now:t},e.id))},{head:`Edited files`,rows:n.length>0?[(0,L.jsx)(W6,{files:n},`tree`)]:[],count:n.length,collapsed:s,onToggle:()=>tT.railFilesCollapsed=!tT.railFilesCollapsed}].filter(e=>e.rows.length>0);return(0,L.jsx)(`aside`,{"data-focus-rail":!0,"aria-label":`Thread activity`,className:`flex h-full shrink-0 flex-col overflow-y-auto px-4 [view-transition-name:thread-rail]`,style:{width:340},children:(0,L.jsx)(`div`,{className:`my-auto py-6`,children:c.length===0?(0,L.jsx)(`div`,{className:`text-[11.5px] text-muted/50`,children:`Nothing running, watched or edited yet.`}):(0,L.jsx)(l$,{groups:c,divider:!1})})})}function q6(){let e=Zt(X),t=e.toast,[n,r]=(0,I.useState)(!1),i=e.drawers.some(e=>!e.closing);return(0,I.useEffect)(()=>{if(!t||(r(!0),t.sticky))return;let e=setTimeout(()=>r(!1),t.duration??(t.link?5e3:1600));return()=>clearTimeout(e)},[t?.id]),t?(0,L.jsx)(`div`,{className:`pointer-events-none fixed right-4 z-[70] flex justify-end ${i?`bottom-20`:`bottom-4`}`,children:(0,L.jsxs)(`div`,{"data-toast":!0,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`flex max-w-[min(30rem,calc(100vw-2rem))] items-center gap-2.5 break-words rounded-lg border border-border-strong bg-elevated px-4 py-2 text-[13px] font-medium text-fg shadow-xl shadow-black/40 transition-all duration-200 ease-out ${n?`translate-y-0 opacity-100`:`translate-y-8 opacity-0`}`,children:[t.spinner&&(0,L.jsx)(Mm,{size:13,className:`animate-spin text-muted`}),t.text,t.link&&(0,L.jsx)(`button`,{onClick:()=>{$f(`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 J6=`max(50%, calc(100% - 720px))`,Y6={"--full-thread":`min(720px, ${J6})`,"--full-thread-narrow":`min(720px, 100%)`,"--full-pane":J6,"--full-gutter":`max(0px, calc((100% - min(720px, ${J6}) - 340px) / 2))`};function X6(e,t){return`${Od(e)}${Pd(t,`/`)}`}function Z6({slug:e}){let t=!!Zt(X).filePanel,n=kC(),r=Sd(n,e),i=r.kind===`found`?r.thread:void 0;n?.projectDir,(0,I.useEffect)(()=>{Y.board().then(Tp).catch(()=>{})},[]),(0,I.useEffect)(()=>{let e=window.matchMedia(`(min-width: ${Ap}px)`),t=()=>{X.splitFileViewer=e.matches};return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),X.splitFileViewer=!1,X.filePanel=null}},[]);let a=i?.runtime===`turn-idle`||i?.runtime===`exited`||i?.runtime===`none`;return(0,I.useEffect)(()=>{!i||!a||Y.threadSeen({slug:e}).catch(()=>{})},[a,e,i?.lastActivityAt]),(0,I.useEffect)(()=>{let t=n?.projectLabel??n?.projectName,r=i?aT(i):e;document.title=t?`${r} · ${t} — Frizz`:`${r} · Frizz`},[n?.projectLabel,n?.projectName,e,i]),(0,L.jsx)(Ij,{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:{...Y6,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)($6,{slug:e}):(0,L.jsx)(B1,{slug:e,virtualized:!0,showReturnToQueue:!0})}),i?(0,L.jsx)(Q6,{slug:e,thread:i}):(0,L.jsx)(`div`,{className:`hidden w-[var(--full-pane)] shrink-0 split:block`,"aria-hidden":`true`})]})}),(0,L.jsx)(N2,{}),(0,L.jsx)(q6,{})]})})}function Q6({slug:e,thread:t}){let n=Zt(X).filePanel,[r,i]=(0,I.useState)(null),a=n?.path??r;return(0,I.useEffect)(()=>{if(n){i(n.path);return}let e=window.setTimeout(()=>i(null),210);return()=>window.clearTimeout(e)},[n]),(0,L.jsxs)(`div`,{"data-side-pane":!0,className:`relative hidden h-full w-[var(--full-pane)] min-h-0 min-w-0 shrink-0 grow-0 overflow-hidden split:block`,children:[(0,L.jsx)(`div`,{inert:n?!0:void 0,className:`h-full min-h-0`,children:(0,L.jsx)(K6,{thread:t})}),(0,L.jsx)(`aside`,{"data-file-viewer-slot":!0,"aria-hidden":!n,className:`absolute inset-0 transition-[translate,opacity] duration-200 ease-out motion-reduce:transition-none ${n?`translate-x-0 opacity-100`:`translate-x-full opacity-0`}`,children:a&&(0,L.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-panel`,children:(0,L.jsx)(F6,{slug:e,path:a},a)})})]})}function $6({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(X6(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:X6(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 e8={OPEN_ISSUE:{bg:wE.bgSuccessEmphasis,icon:sm,label:`Open`},CLOSED_ISSUE:{bg:wE.bgDoneEmphasis,icon:am,label:`Closed`},NOT_PLANNED:{bg:wE.bgNeutralEmphasis,icon:lm,label:`Closed as not planned`},OPEN_PR:{bg:wE.bgSuccessEmphasis,icon:Cm,label:`Open`},DRAFT:{bg:wE.bgNeutralEmphasis,icon:Sm,label:`Draft`},MERGED:{bg:wE.bgDoneEmphasis,icon:bm,label:`Merged`},CLOSED_PR:{bg:wE.bgDangerEmphasis,icon:xm,label:`Closed`}};function t8(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 n8(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 r8(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 ${n8(e,t)}`:YT(e,t)??``:``}function i8(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 a8={add:wE.fgSuccess,del:wE.fgDanger},o8={add:{backgroundColor:wE.bgSuccessEmphasis,borderColor:wE.bgSuccessEmphasis},del:{backgroundColor:wE.bgDangerEmphasis,borderColor:wE.bgDangerEmphasis},none:{backgroundColor:`${wE.bgNeutralEmphasis}33`,borderColor:`#3d444d`}};function s8({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:a8.add},children:[`+`,e.toLocaleString()]}),(0,L.jsxs)(`span`,{"data-gh-del":!0,style:{color:a8.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:i8(e,t).map((e,t)=>(0,L.jsx)(`span`,{className:`size-[8px] rounded-[2px] border`,style:o8[e]},t))})]})}function c8({card:e}){let t=t8(e),n=t?e8[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 l8({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 u8=/`([^`\n]+)`/g;function d8(e,t){if(!t)return[e];let n=[],r=0;for(let t of e.matchAll(u8))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 f8({text:e,code:t,className:n}){return(0,L.jsx)(`div`,{className:n,children:d8(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 p8=new Set([`avatars.githubusercontent.com`,`camo.githubusercontent.com`]);function m8(e){if(e)try{let t=new URL(e);return t.protocol===`https:`&&p8.has(t.hostname)?e:void 0}catch{return}}function h8({card:e,nowMs:t}){let n=m8(e.authorAvatar),r=e.authorLogin??e.authorName??`Someone`,i=e.kind===`commit`?`committed`:e.kind===`pr`?`opened this pull request`:`opened this issue`,a=r8(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 g8=`w-[360px] max-w-[min(360px,calc(100vw-24px))] leading-normal`;function _8({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:g8,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)(ym,{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)(f8,{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)(s8,{additions:e.additions,deletions:e.deletions})}):null]})]}),(0,L.jsx)(h8,{card:e,nowMs:t})]});let r=e.ref.slice(e.ref.indexOf(`#`));return(0,L.jsxs)(`div`,{className:g8,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 ${n8(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)(c8,{card:e}),n?(0,L.jsx)(s8,{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)(f8,{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)(l8,{name:e.name,color:e.color},e.name))}):null]}):null,(0,L.jsx)(h8,{card:e,nowMs:t})]})}var v8=250,y8=180;function b8(e){let t=e.getClientRects()[0]??e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}}function x8(){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)},y8)},[]);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),Of([o]),n.current=setTimeout(()=>t({ref:o,rect:b8(a)}),v8)))},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)(oV,{open:e!==null,children:[(0,L.jsx)(cV,{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)(lV,{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)(S8,{refKey:e.ref})}):null]})}function S8({refKey:e}){let t=(0,I.useSyncExternalStore)(Cf,()=>wf(e),()=>wf(e));return(0,I.useEffect)(()=>{Tf(wf(e))&&Mf(e)},[e]),t?.card?(0,L.jsx)(_8,{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 C8=`frizz-project-rail`;function w8(){try{return localStorage.getItem(C8)===`shown`}catch{return!1}}function T8(e){try{localStorage.setItem(C8,e?`shown`:`hidden`)}catch{}}function E8(){Iv();let e=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet(),placeholderData:ee}).data?.projectRail;return(0,I.useEffect)(()=>{e!==void 0&&T8(e===!0)},[e]),e===void 0?w8():e===!0}var D8=`/project/:slug`;function O8(){N8();let e=E8();return(0,L.jsxs)(Ij,{children:[e?(0,L.jsx)(x6,{}):null,(0,L.jsx)(`div`,{className:e?l6:void 0,children:(0,L.jsx)(vy,{})}),(0,L.jsx)(q6,{}),(0,L.jsx)(x8,{})]})}function k8(e){(0,I.useEffect)(()=>{uC(e)||(wp(),DC())},[e])}function A8(){let{slug:e,thread:t}=Hv();return k8(e),M8(),(0,I.useState)(()=>op(t)),(0,L.jsx)(r6,{},e??`__launching__`)}function j8(){return(0,L.jsx)(M6,{})}function M8(){let e=Iv();(0,I.useEffect)(()=>{QC(Ad(e.pathname))},[e.pathname])}function N8(){let e=Rv();(0,I.useEffect)(()=>(tw((t,n)=>e(t,n)),()=>tw(null)),[e])}function P8(){let{thread:e,slug:t}=Hv();return N8(),k8(t),(0,I.useState)(()=>{X.drawers.length>0&&(X.drawers=[])}),ap(e),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Z6,{slug:e}),(0,L.jsx)(q6,{})]})}var F8=[{index:!0,element:(0,L.jsx)(A8,{})},{path:`thread/:thread`,element:(0,L.jsx)(A8,{})},{path:`status/:status`,element:(0,L.jsx)(A8,{})}],I8=cb([{path:`/thread/:thread/full`,element:(0,L.jsx)(P8,{})},{path:`${D8}/thread/:thread/full`,element:(0,L.jsx)(P8,{})},{element:(0,L.jsx)(O8,{}),children:[{path:`/`,element:(0,L.jsx)(j8,{})},{path:`/thread/:thread`,element:(0,L.jsx)(A8,{})},{path:`/status/:status`,element:(0,L.jsx)(A8,{})},{path:D8,children:F8},{path:`*`,element:(0,L.jsx)(A8,{})}]}]),L8=24,R8=6,z8=700,B8=new Map,V8=null,H8=null;function U8(e){return!Array.isArray(e)||e.length!==2?null:e[0]===`transcript`&&typeof e[1]==`string`?e[1]:null}function W8(e){return X.board?.threads.find(t=>t.id===e)?.lastActivityAt}function G8(){let e=[...B8.entries()].filter(([,e])=>e.observers>0),t=new Set(e.slice(-24).map(([e])=>e));for(let[e,n]of B8){if(n.observers<=0){n.live&&(n.live=!1,CC(e)),B8.delete(e);continue}t.has(e)?!n.live&&!n.queued&&(n.queued=!0):(n.queued=!1,n.live&&(n.live=!1,CC(e)))}K8()}function K8(){H8||[...B8.values()].some(e=>e.queued)&&(H8=setTimeout(()=>{H8=null;let e=0,t=[...B8.values()].filter(e=>e.live).length;for(let[n,r]of B8){if(e>=R8||t>=L8)break;r.queued&&(r.queued=!1,!(r.observers<=0||r.live)&&(r.live=!0,t++,r.lastActivityAt=W8(n),SC(n),e++))}K8()},z8))}function q8(){if(V8)for(let[e,t]of B8){if(t.observers<=0)continue;let n=W8(e);n!==t.lastActivityAt&&(t.lastActivityAt=n,!(t.live&&X.socketTranscripts)&&(X.socketTranscriptFallbacks[e]||V8.refetchQueries({queryKey:[`transcript`,e],exact:!0,type:`active`})))}}function J8(e){V8||(V8=e,e.getQueryCache().subscribe(e=>{let t=U8(e.query.queryKey);if(!t||e.type!==`observerAdded`&&e.type!==`observerRemoved`)return;let n=e.query.getObserversCount(),r=B8.get(t);e.type===`observerAdded`?(B8.delete(t),B8.set(t,{observers:n,live:r?.live??!1,queued:r?.queued??!1,lastActivityAt:r?r.lastActivityAt:W8(t)})):r&&(r.observers=n),G8()}),Jt(X,q8))}var Y8=`ui-monospace, "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Mono", Consolas, Menlo, "DejaVu Sans Mono", monospace`,X8=`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;function Z8(e){let t=e===`mono`?`mono`:`sans`;document.documentElement.dataset.font=t,document.body&&(document.body.style.fontFamily=t===`sans`?X8:Y8);try{localStorage.setItem(`frizz-font`,t)}catch{}}function Q8(e){let t=e.getQueryData([`settingsGet`]);t&&Z8(t.font),Y.settingsGet().then(e=>Z8(e.font)).catch(()=>{}),e.getQueryCache().subscribe(()=>{let t=e.getQueryData([`settingsGet`]);t&&Z8(t.font)})}function $8(){let e=e=>{if(e.button!==0||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`.${pS}`):null;t&&(e.preventDefault(),e.stopPropagation(),t5(t))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)}function e5(e){return e.closest(`.md-code`)?.querySelector(`pre code`)??null}async function t5(e){let t=e5(e);if(!t)return;let n=(t.textContent??``).replace(/\n$/,``);if(n){try{await CR(n)}catch(e){Z(`Could not copy code: ${e.message.slice(0,100)}`,{duration:7e3});return}r5(e)}}var n5=new WeakMap;function r5(e){e.classList.add(mS),e.title=`Copied`;let t=n5.get(e);t!==void 0&&window.clearTimeout(t),n5.set(e,window.setTimeout(()=>{e.classList.remove(mS),e.title=hS,n5.delete(e)},y$))}var i5=/^\/thread\/([a-z0-9][a-z0-9-]*)\/?$/;function a5(){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=Dd(n);if(r&&r!==Dd())return;let i=i5.exec(Ad(n));i&&(e.preventDefault(),e.stopPropagation(),np(i[1]))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)}var o5=new Set([`projectsList`,`projectsQueueCounts`,`threadLocate`,`dispatchPreferencesGet`,`supervisorStatus`]);function s5(e){let t=e[0];return typeof t==`string`&&o5.has(t)?T(e):T([`project:${Dd()??``}`,...e])}var c5=typeof window<`u`&&window.location.pathname.endsWith(`/settings-formatting-fixture.html`),l5=typeof window<`u`?Fd(Ad()):null;!c5&&!l5&&$C();var u5=new Le({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,queryKeyHashFn:s5}}});c5||(OC(u5),J8(u5),BV(u5),Q8(u5),HZ(),VK(),$8(),a5()),c5||(0,at.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(He,{client:u5,children:(0,L.jsx)(ph,{children:(0,L.jsx)(my,{router:I8})})}));export{a as i,Nd as n,ze as r,By as t};
313
+ `)||void 0;return{line:`${pQ(e)} ${t.label}${r?` — ${r}`:``}`,...i?{body:i}:{}}}var hQ=`root`;function gQ(e,t,n){return`${e}/${t}.${n}`}function _Q(e){let t=e.options??[],n=t.findIndex(e=>e.recommended),r=t.map((e,t)=>mQ(t,e));return{question:{kind:e.kind,danger:e.danger===!0,contextMd:e.question,options:r.map(e=>e.line),recommendedIdx:n===-1?null:n,...r.some(e=>e.body)?{optionBodies:r.map(e=>e.body)}:{}},optionLabels:t.map(e=>e.label)}}function vQ(e,t){return!t||e.kind===`multi`?null:t.chosen}function yQ(e,t){let n=[],r=(e,i,a)=>{let{question:o,optionLabels:s}=_Q(e);n.push({path:i,spec:e,question:o,optionLabels:s,depth:a});let c=vQ(e,t.get(i));c!==null&&(e.options?.[c]?.followUps??[]).forEach((e,t)=>r(e,gQ(i,c,t),a+1))};return r(e,hQ,1),n}function bQ(e,t){return t?t.text.trim()?!0:e.kind===`multi`?(t.chosenSet??[]).length>0:t.chosen!==null:!1}function xQ(e,t){if(!bQ(e.spec,t.get(`root`)))return;let n=(r,i)=>{let a=t.get(i),o=(r.options??[]).map(e=>e.label),s=vQ(r,a),c=r.kind===`multi`?(a?.chosenSet??[]).slice().sort((e,t)=>e-t).flatMap(e=>o[e]===void 0?[]:[o[e]]):s===null?[]:[o[s]].filter(e=>e!==void 0),l=r.kind===`multi`||s===null?a?.text.trim():void 0,u=s===null?[]:(r.options?.[s]?.followUps??[]).map((e,t)=>n(e,gQ(i,s,t)));return{questionId:e.id,question:r.question,chosen:c,...l?{text:l}:{},...u.length>0?{followUps:u}:{}}};return n(e.spec,hQ)}function SQ(e){let t=e instanceof Error?e.message:`The answer could not be sent.`;return t.length>240?`${t.slice(0,239)}…`:t}var CQ=(e,t)=>`${e}|${t}`;function wQ({thread:e,questions:t,inFlight:n=null,className:r=``}){let i=e?.id,a=t??e?.questions??[],o=cz(),[s,c]=(0,I.useState)(()=>new Map),[l,u]=(0,I.useState)(),d=(0,I.useContext)(z1),f=dz((0,I.useMemo)(()=>i?a.flatMap(e=>TQ(e).map(t=>sz.question(o,i,e.id,t))):[],[o,i,a])),p=(e,t)=>{let n=s.get(CQ(e.id,t));return{chosen:n?.chosen??null,chosenSet:n?.chosenSet??[],text:(i?f.get(sz.question(o,i,e.id,t)):void 0)??``}},m=e=>new Map(TQ(e).map(t=>[t,p(e,t)])),h=a.flatMap(e=>{let t=xQ(e,m(e));return t?[t]:[]}),g=it({mutationFn:async e=>Y.answerQuestions({slug:i,answers:e}),onSuccess:e=>{for(let t of e.answered){c(e=>{let n=new Map(e);for(let e of[...n.keys()])e.startsWith(`${t}|`)&&n.delete(e);return n});let e=a.find(e=>e.id===t);if(e&&i)for(let t of TQ(e))az.set(sz.question(o,i,e.id,t),``)}},onError:e=>{d?.cancel(),u(SQ(e))}}),_=it({mutationFn:async e=>Y.dismissQuestions({slug:i,ids:[e]}),onError:e=>u(SQ(e))});if(!i||a.length===0)return!i||!n?.length?null:(0,L.jsx)(`section`,{"data-answers-in-flight":!0,"aria-label":`Your answer, on its way to the worker`,className:`flex min-w-0 flex-col items-end ${r}`,children:(0,L.jsx)(dY,{answers:n,queued:!0})});let v=()=>{h.length===0||g.isPending||(u(void 0),d?.dismiss(),g.mutate(h))};return(0,L.jsxs)(`section`,{"data-registered-questions":!0,"aria-label":`${a.length} question${a.length===1?``:`s`} waiting for an answer`,className:`flex min-w-0 flex-col gap-3 ${r}`,children:[a.map(e=>(0,L.jsx)(`article`,{"data-question-id":e.id,className:`flex min-w-0 flex-col gap-2`,children:(()=>{let t=yQ(e.spec,m(e)),n=t=>(0,L.jsx)(CY,{question:t.question,label:t.depth>1?`Follow-up`:void 0,aside:t.depth===1&&!e.spec.danger?(0,L.jsx)(`button`,{type:`button`,"data-dismiss-question":!0,"aria-label":`Dismiss this question`,title:`Dismiss — the worker decides it itself`,disabled:_.isPending,onClick:()=>_.mutate(e.id),className:`card-icon-offset -mx-2 -my-1 flex rounded-md p-1 text-muted/70 outline-none transition-colors hover:bg-elevated hover:text-fg disabled:opacity-40`,children:(0,L.jsx)(ah,{size:16})}):void 0,interactive:{answer:p(e,t.path),onChip:n=>{c(r=>{let i=new Map(r),a=CQ(e.id,t.path),o=i.get(a)??{chosen:null,chosenSet:[]};if(t.spec.kind===`multi`){let e=o.chosenSet.includes(n)?o.chosenSet.filter(e=>e!==n):[...o.chosenSet,n];i.set(a,{...o,chosenSet:e})}else i.set(a,{...o,chosen:o.chosen===n?null:n});return i})},onText:n=>{az.set(sz.question(o,i,e.id,t.path),n),t.spec.kind!==`multi`&&c(n=>{let r=CQ(e.id,t.path),i=n.get(r);return!i||i.chosen===null?n:new Map(n).set(r,{...i,chosen:null})})},onSubmit:v}},t.path),r=t.slice(1);return(0,L.jsxs)(L.Fragment,{children:[n(t[0]),r.length>0&&(0,L.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:r.map(e=>(0,L.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:n(e)},e.path))})]})})()},e.id)),l&&(0,L.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-red-300`,children:l}),g.isPending&&(0,L.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[11px] leading-snug text-muted`,children:`Sending…`}),(0,L.jsx)(`div`,{className:`flex justify-start`,children:(0,L.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:h.length===0||g.isPending,onClick:v,onMouseDown:e=>e.preventDefault(),className:`rounded-md bg-fg px-3 py-1.5 text-[12px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:`Send answers`})})]})}function TQ(e){let t=[],n=(e,r)=>{t.push(r),e.options?.forEach((e,t)=>{e.followUps?.forEach((e,i)=>n(e,`${r}/${t}.${i}`))})};return n(e.spec,hQ),t}function EQ(e){return(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).length}function DQ(e,t={}){let n=(e.subAgents??[]).filter(e=>Xc(e)&&e.state===`running`).length,r=(e.bgShells??[]).filter(e=>e.state===`running`).length,i=t.watchers===!1?0:EQ(e),a=[n>0?`${n} sub-agent${n===1?``:`s`}`:null,r>0?`${r} background shell${r===1?``:`s`}`:null,i>0?`${i} PR watcher${i===1?``:`s`}`:null].filter(e=>e!==null);return a.length===0?`0 background shells`:a.length===1?a[0]:`${a.slice(0,-1).join(`, `)} and ${a[a.length-1]}`}function OQ(e){return(e.subAgents??[]).some(e=>Xc(e)&&e.state===`running`)}function kQ(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length}function AQ(e){return OQ(e)||kQ(e)>0}function jQ(e,t){return ul(t)??(MQ(e)?`Background shells running`:`Awaiting`)}function MQ(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length>0&&!OQ(e)&&EQ(e)===0&&NQ(e).length===0}function NQ(e){return(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`)}var PQ={id:``,subAgents:[],bgShells:[],watches:[]},FQ=[];function IQ(e,t){let n=new Set((e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).map(e=>e.target));return kH(t).filter(e=>!n.has(e.ref))}function LQ({watch:e}){return(0,I.useEffect)(()=>{e.url&&Of([e.ref])},[e.url,e.ref]),e.url?(0,L.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-gh-ref":e.ref,className:`${oJ} text-[12px]`,children:e.ref}):(0,L.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.ref})}var RQ={mergeable:`no conflicts`,blocked:`merge blocked`,conflicting:`has conflicts`,unknown:null};function zQ(e){return e.state!==`open`||e.merge===`blocked`&&e.checks!==`passing`&&e.checks!==`none`?null:RQ[e.merge]}var BQ=`shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`;function VQ({tone:e}){return(0,L.jsx)(`span`,{"aria-hidden":!0,className:`inline-block size-3 rounded-full border ${e} border-t-transparent motion-safe:animate-spin ${BQ}`})}function HQ(){return(0,L.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 16 16`,width:12,height:12,fill:`none`,stroke:`currentColor`,overflow:`visible`,className:BQ,style:{color:TE.fgAttention},children:[(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:`4`,fill:`currentColor`,stroke:`none`}),(0,L.jsxs)(`g`,{strokeWidth:`2`,className:`origin-center motion-safe:animate-spin`,children:[(0,L.jsx)(`circle`,{cx:`8`,cy:`8`,r:`7`,opacity:`0.25`}),(0,L.jsx)(`path`,{d:`M15 8A7 7 0 0 1 8 15`})]})]})}function UQ({status:e}){return e?e.state===`merged`?(0,L.jsx)(bm,{size:12,className:BQ,style:{color:TE.fgDone}}):e.state===`closed`?(0,L.jsx)(xm,{size:12,className:BQ,style:{color:TE.fgDanger}}):e.checks===`failing`?(0,L.jsx)(um,{size:12,className:BQ,style:{color:TE.fgDanger}}):e.checks===`passing`?(0,L.jsx)(am,{size:12,className:BQ,style:{color:TE.fgSuccess}}):e.gated>0&&e.running===0?(0,L.jsx)(im,{size:12,className:BQ,style:{color:TE.fgAttention}}):e.checks===`running`?(0,L.jsx)(HQ,{}):(0,L.jsx)(om,{size:12,className:`${BQ} text-muted/60`}):(0,L.jsx)(om,{size:12,className:`${BQ} text-muted/60`})}function WQ(e){return[e.failed>0?`${e.failed} failing`:null,e.gated>0?`${e.gated} awaiting approval`:null,e.running>0?`${e.running} in progress`:null,e.passed>0?`${e.passed} successful`:null,e.skipped>0?`${e.skipped} skipped`:null].filter(e=>e!==null).join(`, `)}function GQ(e){if(!e)return`Checking…`;if(e.state===`merged`)return`Merged`;if(e.state===`closed`)return`Closed`;let t=WQ(e),n=zQ(e);return[t||`No checks`,n].filter(e=>e!==null).join(` · `)}var KQ=`group relative col-span-4 grid grid-cols-subgrid items-baseline rounded-sm text-[12px] leading-5`,qQ=`group relative col-span-4 flex items-baseline rounded-sm text-[12px] leading-5`,JQ=`ml-1.5 min-w-0 truncate font-medium text-fg/90`,YQ=`ml-3 min-w-0 truncate text-right text-muted/70`,XQ=`outline-none after:absolute after:inset-0 after:rounded-sm focus-visible:after:ring-1 focus-visible:after:ring-fg/60`;function ZQ(){return(0,L.jsx)(tm,{size:13,"aria-hidden":!0,className:`${BQ} ml-[3px] -mr-[4px] text-muted/35 transition-colors group-hover:text-muted/70`})}function QQ({mark:e,name:t,status:n,onOpen:r,onPrewarm:i,href:a,ghRef:o,title:s,testKind:c,testId:l,indent:u}){let d=u!==void 0,f=d?`${JQ} flex-1`:JQ,p=a?(0,L.jsx)(`a`,{href:a,target:`_blank`,rel:`noreferrer noopener`,title:s,"data-gh-ref":o,onMouseDown:e=>e.stopPropagation(),className:`${f} ${XQ} group-hover:underline group-hover:decoration-fg/40 group-hover:underline-offset-2`,children:t}):r?(0,L.jsx)(`button`,{type:`button`,onClick:r,onMouseDown:e=>e.stopPropagation(),title:s,className:`${f} ${XQ} text-left group-hover:underline group-hover:decoration-fg/40 group-hover:underline-offset-2`,children:t}):(0,L.jsx)(`span`,{className:f,title:s,children:t}),m=!!(a||r);return(0,L.jsxs)(`div`,{"data-wait-row":l,"data-wait-kind":c,onMouseEnter:i,onFocus:i,style:d?{paddingLeft:u}:void 0,className:`${d?qQ:KQ} ${m?`cursor-pointer transition-colors hover:bg-fg/[0.045]`:``}`,children:[(0,L.jsx)(`span`,{className:`flex shrink-0`,children:e}),p,(0,L.jsx)(`span`,{"data-wait-status":!0,className:YQ,children:n}),m?(0,L.jsx)(ZQ,{}):(0,L.jsx)(`span`,{})]})}function $Q({watch:e}){let t=e.github,n=DH(e.target);return(0,I.useEffect)(()=>{n&&Of([e.target])},[n,e.target]),(0,L.jsx)(QQ,{testKind:`github`,testId:e.target,mark:(0,L.jsx)(UQ,{status:t}),name:e.target,href:n??void 0,ghRef:n?e.target:void 0,title:n?`Open ${e.target} on GitHub`:e.target,status:(0,L.jsxs)(L.Fragment,{children:[GQ(t),t&&t.failing.length>0&&n&&(0,L.jsxs)(L.Fragment,{children:[` · `,(0,L.jsx)(`a`,{href:`${n}/checks`,target:`_blank`,rel:`noreferrer noopener`,onMouseDown:e=>e.stopPropagation(),className:`relative underline underline-offset-2 text-[#f85149]/85 decoration-[#f85149]/30 hover:decoration-[#f85149]`,children:`view failures`})]})]})})}function e$(e,t){return(e.bgShells??[]).find(e=>e.id===t||e.taskId===t||e.label===t)}function t$(e){return(e.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`)}function n$({watch:e,thread:t,slug:n,now:r}){let i=e$(t,e.target);if(i)return(0,L.jsx)(r$,{shell:i,slug:n,now:r,testId:e.target});let a=bE(e.createdAt,r);return(0,L.jsx)(QQ,{testKind:`shell`,testId:e.target,mark:(0,L.jsx)(eh,{size:12,className:`${BQ} text-shell`}),name:e.target,title:e.target,status:a?`running · ${a}`:`running`})}function r$({shell:e,slug:t,now:n,testId:r}){let i=bE(e.startedAt,n),a=e.id&&!e.outputUnavailable;return(0,L.jsx)(QQ,{testKind:`shell`,testId:r??e.id??e.label,mark:(0,L.jsx)(eh,{size:12,className:`${BQ} text-shell`}),name:e.label,onOpen:a?()=>tp(t,e.id,{label:e.label,startedAt:e.startedAt}):void 0,title:a?`Read this shell's output — running for ${i}`:e.label,status:i?`running · ${i}`:`running`})}function i$({watch:e,now:t}){let n=Date.parse(e.timer?.fireAt??``),r=Number.isFinite(n)?n>t?`fires in ${vE(n-t)}`:`firing…`:`armed`;return(0,L.jsx)(QQ,{testKind:`timer`,testId:e.target,mark:(0,L.jsx)(dm,{size:12,className:`${BQ} text-muted/60`}),name:e.timer?.prompt||e.target,title:e.timer?.fireAt?`One-off timer, set for ${e.timer.fireAt}`:e.target,status:r})}function a$(e){return(e.subAgents??[]).filter(e=>Xc(e)&&e.state===`running`)}function o$({agent:e,slug:t,now:n}){let r=bE(e.startedAt,n),i=e.subagentType?.replace(/^frizz:/,``);return(0,L.jsx)(QQ,{testKind:`agent`,testId:e.id??e.label,mark:(0,L.jsx)(VQ,{tone:`border-accent`}),name:e.label,onOpen:e.id?()=>ep(t,e.id,{label:e.label,subagentType:e.subagentType,startedAt:e.startedAt}):void 0,title:e.id?`Open this sub-agent — working for ${r}`:e.label,status:[i,r].filter(Boolean).join(` · `)})}function s$(e,t,n){let r=new Set(n.map(e=>e.target)),i=[];for(let n of t){if(n.kind!==`shell`)continue;let t=n.value.trim();if(!t||r.has(t))continue;let a=e$(e,t);!a||a.state!==`running`||(r.add(t),i.push({id:`shell:${e.id}:${t}`,kind:`shell`,target:t,state:`armed`,createdAt:a.startedAt}))}return i}function c$(e,t={}){let n=Date.parse(t.notAfter??``),r=e=>!Number.isFinite(n)||!e||!(Date.parse(e)>n),i=(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`&&r(e.createdAt)),a=t$(e).filter(t=>r(e$(e,t.target)?.startedAt??t.createdAt));return{prs:i,shells:[...a,...s$(e,t.hints??[],a)],agents:a$(e).filter(e=>r(e.startedAt)),timers:NQ(e).filter(e=>r(e.createdAt))}}function l$(e,t={}){let n=c$(e,t);return n.prs.length+n.shells.length+n.agents.length+n.timers.length>0}function u$(e,t,n={}){let{prs:r,shells:i,agents:a,timers:o}=c$(e,n);return[{head:`Sub-agents`,rows:a.map(n=>(0,L.jsx)(o$,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:i.map(n=>(0,L.jsx)(n$,{watch:n,thread:e,slug:e.id,now:t},n.id))},{head:`Pull requests`,rows:r.map(e=>(0,L.jsx)($Q,{watch:e},e.id))},{head:`Timers`,rows:o.map(e=>(0,L.jsx)(i$,{watch:e,now:t},e.id))}].filter(e=>e.rows.length>0)}function d$({group:e,first:t}){let n=`col-span-4 text-[10.5px] uppercase tracking-wide text-muted/45 ${t?``:`mt-2.5`}`;return e.onToggle?(0,L.jsxs)(`button`,{type:`button`,onClick:e.onToggle,"aria-expanded":!e.collapsed,onMouseDown:e=>e.stopPropagation(),className:`${n} flex items-baseline rounded-sm text-left transition-colors hover:text-muted/80`,children:[(0,L.jsx)(`span`,{children:e.head}),e.count!==void 0&&(0,L.jsx)(`span`,{className:`ml-1.5 tabular-nums`,children:e.count}),(0,L.jsx)(tm,{size:10,"aria-hidden":!0,className:`${BQ} ml-[5px] transition-transform ${e.collapsed?``:`rotate-90`}`})]}):(0,L.jsx)(`div`,{className:n,children:e.head})}function f$({groups:e,divider:t}){return e.length===0?null:(0,L.jsxs)(L.Fragment,{children:[t&&(0,L.jsx)(`div`,{"aria-hidden":!0,className:`-mx-4 mt-3 border-t border-border`}),(0,L.jsx)(`div`,{className:`mt-3 grid grid-cols-[auto_1fr_fit-content(50%)_auto] gap-y-px`,children:e.map((e,t)=>(0,L.jsxs)(I.Fragment,{children:[(0,L.jsx)(d$,{group:e,first:t===0}),!e.collapsed&&e.rows]},e.head))})]})}function p$(e){return e?.awaitingBackground===!0&&e.runtime===`turn-idle`&&e.bgSnoozed!==!0}var m$=`Hides card until new activity is detected`;function h$({thread:e,onSnooze:t,onSnoozeFailed:n}){let[r,i]=(0,I.useState)(!1);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{i(!0),t?.(),Y.snoozeAwaitingBackground({slug:e.id,sessionId:e.sessionId??``}).then(()=>Z(`Snoozed until the background work returns`)).catch(e=>{n?.(),Z(`Couldn’t snooze: ${e.message.slice(0,80)}`),i(!1)})},disabled:r,onMouseDown:e=>e.preventDefault(),title:m$,className:`disabled:opacity-45 ${sJ}`,children:[(0,L.jsx)(Tm,{size:12,className:BY}),`Snooze`]}),(0,L.jsx)(`span`,{className:aJ,children:m$})]})}function g$({thread:e,fence:t,onSnooze:n,onSnoozeFailed:r,notAfter:i}){let a=e??PQ,o=t??(e?.lastFence?.kind===`awaiting`?e.lastFence:void 0),s=o?.hints??FQ,c=OQ(a),l=FH(o?.body),u=gK(l??``),d=u$(a,sE(),{hints:s,notAfter:i}),f=IQ(a,s),p=i===void 0&&e!==void 0&&p$(e)&&SX(e).snooze;return(0,L.jsxs)(nJ,{"data-awaiting-background":!0,icon:MQ(a)?eh:Tm,label:(0,L.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:jQ(a,s)}),aside:f.length===1?(0,L.jsx)(LQ,{watch:f[0]}):void 0,className:p?`pb-0`:``,children:[l?(0,L.jsx)(hq,{className:`md-body ${Jq}`,html:u}):d.length===0&&!AQ(a)?(0,L.jsx)(`p`,{className:rJ,children:OH}):null,f.length>1&&(0,L.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:f.map(e=>(0,L.jsx)(LQ,{watch:e},e.ref))}),d.length===0&&AQ(a)&&(0,L.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75`,children:c?(0,L.jsxs)(L.Fragment,{children:[`It’s awaiting the results from `,DQ(a,{watchers:!1}),` it dispatched. It returns to the queue on its own when the work comes back.`]}):(0,L.jsxs)(L.Fragment,{children:[DQ(a,{watchers:!1}),` `,kQ(a)===1?`is`:`are`,` still running. It resumes on its own when`,` `,kQ(a)===1?`it finishes`:`one of them finishes`,`.`]})}),(0,L.jsx)(f$,{groups:d,divider:!!l}),p?(0,L.jsx)(`div`,{"data-awaiting-snooze":!0,className:`-mx-4 mt-3 flex flex-wrap items-center gap-x-2.5 gap-y-2 border-t border-border bg-fg/[0.03] px-4 py-2.5 ${Zq}`,children:(0,L.jsx)(h$,{thread:e,onSnooze:n,onSnoozeFailed:r})}):null]})}function _$(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.kind!==`event`||n.boundary!==`rest`)){for(let r=t-1;r>=0;r--){let t=e[r];if(t.role===`assistant`&&t.kind!==`event`&&t.kind!==`reasoning`)return{index:r,at:n.at}}return{index:-1,at:n.at}}}}function v$(e,t=Date.now()){return e!==void 0&&DT(e,t)!==void 0}function y$(){let[e,t]=(0,I.useState)(()=>Date.now());return(0,I.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function b$({thread:e}){let t=y$(),[n,r]=(0,I.useState)(!1),i=DT(e,t);if(!i)return null;let a=Date.parse(i),o=Ww(i,t).replace(/^(Today|Tomorrow)/,e=>e.toLowerCase()),s=e.snoozePrompt?.trim();async function c(){r(!0);try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:null,prompt:null}),Z(`Snooze cleared`)}catch(e){Z((e instanceof Error?e.message:`Wake failed`).slice(0,100))}finally{r(!1)}}return(0,L.jsxs)(nJ,{"data-snooze-card":!0,icon:Tm,label:`Snoozed`,children:[(0,L.jsx)(`div`,{"data-snooze-countdown":!0,title:new Date(a).toLocaleString(),className:`text-[22px] font-semibold leading-8 tracking-tight text-fg tabular-nums`,children:SE(a-t)}),(0,L.jsx)(`p`,{className:rJ,children:s?(0,L.jsxs)(L.Fragment,{children:[`Resumes `,o,` and sends: “`,Jw(s),`”`]}):(0,L.jsxs)(L.Fragment,{children:[`Returns to the queue `,o,`.`]})}),e.foreign!==!0&&(0,L.jsx)(iJ,{children:(0,L.jsx)(`button`,{type:`button`,"data-snooze-wake-now":!0,disabled:n,onClick:()=>void c(),className:`${sJ} disabled:cursor-not-allowed disabled:opacity-45`,children:`Wake now`})})]})}function x$({at:e,fallbackAt:t,className:n=``}){let r=sE(),i=UT(e,t),a=WT(i,r);return!a||!i?null:(0,L.jsx)(`time`,{dateTime:i,className:n,children:a})}var S$=1500;function C$(e,t){let n=0,r;function i(){r!==void 0&&(t.clearTimeout(r),r=void 0)}return{begin(){let a=++n;return e(!0),i(),r=t.setTimeout(()=>{a===n&&e(!1),r=void 0},S$),a},fail(t){t===n&&(i(),e(!1))},dispose(){n++,i()}}}var w$=`Could not copy terminal command`,T$={attach:`Attach command copied`,resume:`Resume command copied`},E$={attach:`Copy command to attach to this thread's live terminal`,resume:`Copy command to resume this thread in a new terminal`},D$=e=>[`terminalCommand`,e];function O$(e){return Y.threadTerminalCommand({slug:e}).then(e=>{if(!e.command)throw Error(e.reason??`No verified provider session is available to resume`);return{command:e.command,mode:e.mode===`attach`?`attach`:`resume`}})}async function k$(e){let t=O$(e);if(typeof ClipboardItem<`u`&&navigator.clipboard?.write)return await navigator.clipboard.write([new ClipboardItem({"text/plain":t.then(({command:e})=>new Blob([e],{type:`text/plain`}))})]),(await t).mode;let{command:n,mode:r}=await t;return await wR(n),r}function A$(e){let t=it({mutationFn:()=>k$(e)});return e=>t.mutate(void 0,{onSuccess:t=>{e?.onSuccess?.(),Z(T$[t])},onError:t=>{e?.onError?.(),Z(t instanceof Error?`${w$}: ${t.message}`:w$,{duration:7e3})}})}function j$({slug:e}){let[t,n]=(0,I.useState)(!1),r=(0,I.useRef)(null);r.current||=C$(n,{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)});let i=Ve(),a=A$(e);(0,I.useEffect)(()=>()=>r.current?.dispose(),[]);function o(){i.prefetchQuery({queryKey:D$(e),queryFn:()=>O$(e),staleTime:15e3})}function s(){let t=i.getQueryData(D$(e));if(t){wR(t.command).then(()=>{r.current?.begin(),Z(T$[t.mode])},()=>Z(w$,{duration:7e3}));return}a({onSuccess:()=>r.current?.begin()})}let c=i.getQueryData(D$(e)),l=t?c?T$[c.mode]:`Terminal command copied`:c?E$[c.mode]:`Copy terminal command`;return(0,L.jsx)(Rj,{label:l,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":l,title:l,onClick:s,onPointerEnter:o,onFocus:o,className:tD,children:t?(0,L.jsx)(Qp,{size:14,strokeWidth:2.2,className:`text-fg`}):(0,L.jsx)(eh,{size:14,strokeWidth:1.8})})})}function M$(e){let t=Math.max(e.scrollHeight-e.clientHeight,0),n=t-e.scrollTop,r=e.scrollHeight!==e.previousScrollHeight,i=r&&!e.readerMoved?e.following||n<=1:n<=4;return!i||!r||t<=0||n<=1?{following:i,scrollTop:null}:{following:i,scrollTop:t}}function N$(e){let t=e.scrollTop>640?!0:e.armed,n=t&&e.readerMoved&&e.scrollTop<=480&&e.hasEarlier&&!e.loading;return{armed:n?!1:t,shouldLoad:n}}function P$(e){return`legacy:${e.role}:${e.kind??`message`}:${e.at??``}:${e.text}`}function F$(e,t,n){let r=[],i=new Map,a=null;return e.forEach((e,o)=>{if(e.queued||t(e))return;let s=e.sourceId??P$(e),c=i.get(s)??0;i.set(s,c+1),r.push({key:c===0?s:`${s}:${c}`,message:e,messageIndex:o,gap:a===null?0:n(a,e)}),a=e}),r}function I$(e,t,n){let r=e[t];if(!r||r.kind!==`event`||r.boundary!==`rest`)return!1;for(let r=t+1;r<e.length;r++){let t=e[r];if(!(t.queued||n(t)))return!!t.boundary||t.wake===!0}return!0}function L$(e,t){let n=e.map(e=>e.message);return e.filter((e,r)=>!I$(n,r,t))}var R$=new Set([`agent`,`follow up`,`interrupt`,`send message`,`spawn agent`,`wait for agents`]),z$=new Set([`poll process`,`wait`]);function B$(e){return(e.split(`__`).pop()||e).replaceAll(`_`,` `).trim()}function V$(e){return B$(e).toLowerCase()}function H$(e){return e.prompt!==void 0||e.agentId!==void 0||e.sendTo!==void 0||e.sendBody!==void 0||e.backgroundState!==void 0&&!G$(e)||W$(e)||U$(e)||R$.has(V$(e.name))}function U$(e){return e.ask!==void 0&&e.ask.length>0&&e.status!==void 0&&e.status!==`pending`}function W$(e){return e.outputImage!==void 0||e.sentImages!==void 0&&e.sentImages.length>0}function G$(e){return e.backgroundState===`unknown`&&z$.has(V$(e.name))}function K$(e){if(e.role!==`assistant`||e.kind||e.queued)return null;if(e.parts&&e.parts.length>0){let t=[];for(let n of e.parts)if(n.kind===`text`){if(n.text.trim())return null}else t.push(...n.tools);return t.length>0&&t.every(e=>!H$(e))?t:null}return e.text.trim()||e.tools.length===0?null:e.tools.every(e=>!H$(e))?e.tools:null}function q$(e){return e.role!==`assistant`||e.kind||e.queued||e.text.trim()||e.tools.length>0?!1:!e.parts?.some(e=>e.kind===`text`?e.text.trim().length>0:e.tools.length>0)}function J$(e){if(e.role!==`assistant`||e.kind||e.queued)return null;if(!e.parts?.length)return Y$(e.tools);for(let t=e.parts.length-1;t>=0;t--){let n=e.parts[t];if(n.kind===`text`){if(n.text.trim())return null;continue}if(n.tools.length!==0)return Y$(n.tools)}return null}function Y$(e){let t=[];for(let n=e.length-1;n>=0&&!H$(e[n]);n--)t.unshift(e[n]);return t.length>0?t:null}function X$(e){if(e.role!==`assistant`||e.kind||e.queued)return null;let t=[],n=e=>{for(let n of e){if(H$(n))return!0;t.push(n)}return!1};if(!e.parts?.length)return e.text.trim()?null:n(e.tools)&&t.length>0?t:null;for(let r of e.parts){if(r.kind===`text`){if(!r.text.trim())continue;return t.length>0?t:null}if(n(r.tools))return t.length>0?t:null}return null}function Z$(e,t){return Q$(e,new Set(t))}function Q$(e,t){if(!e.parts?.length)return{...e,tools:e.tools.filter(e=>!t.has(e))};let n=e.parts.map(e=>e.kind===`text`?e:{kind:`tools`,tools:e.tools.filter(e=>!t.has(e))}).filter(e=>e.kind===`text`||e.tools.length>0);return{...e,tools:n.flatMap(e=>e.kind===`tools`?e.tools:[]),parts:n}}function $$(e,t,n){let r=[...e.tools,...t],i=e.parts?.map(e=>e.kind===`text`?e:{...e,tools:[...e.tools]})??[],a=-1;for(let e=i.length-1;e>=0;e--){let t=i[e];if(t.kind===`text`){if(t.text.trim())break;continue}if(t.tools.length>0){a=e;break}}let o=i[a];return o?.kind===`tools`?i[a]={kind:`tools`,tools:[...o.tools,...t]}:i.push({kind:`tools`,tools:t}),{...e,at:n??e.at,tools:r,parts:i}}function e1(e){let t=[],n=null;return e.forEach((e,r)=>{if(q$(e))return;if(e.queued){t.push({message:e,messageIndex:r});return}let i=K$(e);if(i&&n){n.message=$$(n.message,i,e.at);return}let a=n?X$(e):null,o=a?Z$(e,a):e;a&&n&&(n.message=$$(n.message,a,e.at));let s={message:o,messageIndex:r};t.push(s),J$(o)?(s.runStartedAt=o.at,n=s):n=null}),t}function t1(e){return e.status===`completed`||e.status===`failed`||e.status===`cancelled`}function n1(e){let t=r1(e);return t?.tools.some(e=>!t1(e))?t.tools.at(-1):void 0}function r1(e){let t=i1(e);if(!t)return;let n=J$(t.message);return n?{tools:n,at:t.message.at}:void 0}function i1(e){for(let t=e.length-1;t>=0;t--)if(!e[t].message.queued)return e[t]}function a1(e){let t=i1(e);if(t)return J$(t.message)?t.runStartedAt??t.message.at:t.message.at}function o1(e){return e.runStartedAt??e.message.at}function s1(e){let t=J$(e);return t?Q$(e,new Set(t)):e}function c1(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].message;if(!r.queued){J$(r)&&(t=r);break}}if(!t)return[...e];let n=[];for(let r of e){let e=r.message===t?s1(r.message):r.message;q$(e)||n.push(e===r.message?r:{...r,message:e})}return n}function l1(e){return e.detail?.trim()||void 0}var u1={add:`Adding`,analyze:`Analyzing`,apply:`Applying`,audit:`Auditing`,benchmark:`Benchmarking`,build:`Building`,bump:`Bumping`,capture:`Capturing`,check:`Checking`,clean:`Cleaning`,collect:`Collecting`,commit:`Committing`,compare:`Comparing`,confirm:`Confirming`,copy:`Copying`,count:`Counting`,create:`Creating`,debug:`Debugging`,delete:`Deleting`,diff:`Diffing`,disable:`Disabling`,dispatch:`Dispatching`,drive:`Driving`,dump:`Dumping`,edit:`Editing`,enable:`Enabling`,extract:`Extracting`,fetch:`Fetching`,find:`Finding`,fix:`Fixing`,format:`Formatting`,generate:`Generating`,grep:`Grepping`,inspect:`Inspecting`,install:`Installing`,kill:`Killing`,launch:`Launching`,lint:`Linting`,list:`Listing`,load:`Loading`,measure:`Measuring`,merge:`Merging`,migrate:`Migrating`,move:`Moving`,open:`Opening`,parse:`Parsing`,patch:`Patching`,poll:`Polling`,print:`Printing`,probe:`Probing`,profile:`Profiling`,publish:`Publishing`,pull:`Pulling`,push:`Pushing`,query:`Querying`,read:`Reading`,rebase:`Rebasing`,refactor:`Refactoring`,regenerate:`Regenerating`,remove:`Removing`,rename:`Renaming`,render:`Rendering`,reproduce:`Reproducing`,restart:`Restarting`,revert:`Reverting`,review:`Reviewing`,run:`Running`,save:`Saving`,scan:`Scanning`,search:`Searching`,seed:`Seeding`,spawn:`Spawning`,start:`Starting`,stop:`Stopping`,summarize:`Summarizing`,sync:`Syncing`,tag:`Tagging`,test:`Testing`,trace:`Tracing`,typecheck:`Typechecking`,update:`Updating`,validate:`Validating`,verify:`Verifying`,wait:`Waiting`,watch:`Watching`,write:`Writing`};function d1(e,t){let n=e?.trim();if(!n)return t;let r=n.indexOf(` `),i=(r===-1?n:n.slice(0,r)).replace(/[.:]$/,``);if(/ing$/i.test(i))return i.charAt(0).toUpperCase()+i.slice(1)+(r===-1?``:n.slice(r));let a=u1[i.toLowerCase()];return a?a+(r===-1?``:n.slice(r)):n.charAt(0).toUpperCase()+n.slice(1)}function f1(e,t){let n=t?.trim().replace(/\/+$/,``);if(!n||n===`/`||!n.startsWith(`/`))return e;let r=e.replaceAll(`${n}/`,``),i=/^(\/(?:Users|home)\/[^/]+)(?:\/|$)/.exec(n)?.[1];return i?r.replaceAll(`${i}/`,`~/`):r}function p1(e,t){return f1(m1(e),t)}function m1(e){let t=V$(e.name),n=l1(e),r=n?` ${n}`:``;return t===`bash`||t===`exec`||t===`run command`?d1(e.desc,n?`Running ${n}`:`Running a command`):t===`read`||t===`view image`?`Reading${r||` a file`}`:t===`grep`||t===`search`||t===`search query`||t===`find`?n?`Searching for ${n}`:`Searching`:t===`glob`||t===`find files`?n?`Finding ${n}`:`Finding files`:t===`edit`||t===`write`||t===`apply patch`?n?`Editing ${n}`:`Editing files`:t===`todos`||t===`update plan`?`Updating the plan`:t===`screenshot`||t===`snapshot`?n?`Capturing ${n}`:`Capturing the page`:t===`navigate`?n?`Navigating to ${n}`:`Navigating`:t===`evaluate`?`Evaluating the page`:t===`pages`?`Listing pages`:t===`new page`?`Opening a new page`:t===`close page`?`Closing the page`:t===`select page`?`Selecting a page`:t===`console`||t===`console message`?`Reading the console`:t===`network`||t===`network request`?`Inspecting network traffic`:t===`press key`?n?`Pressing ${n}`:`Pressing a key`:t===`fill form`?`Filling the form`:t===`dialog`?`Handling a dialog`:t===`upload`?n?`Uploading ${n}`:`Uploading a file`:t===`wait for`||t===`wait`?n?`Waiting for ${n}`:`Waiting`:t===`resize`?`Resizing the page`:t===`ask`?`Preparing a question`:t===`web`||t===`web search`?n?`Searching for ${n}`:`Searching the web`:`Using ${B$(e.name)||`a tool`}`}var h1=new Set([`edit`,`multiedit`,`write`,`apply patch`]);function g1(e){let t=new Set;for(let n of e){for(let e of n.edits??(n.edit?[n.edit]:[]))e.file.trim()&&t.add(e.file.trim());if(n.edit||n.edits?.length)continue;let e=n.detail?.trim();e&&h1.has(V$(n.name))&&t.add(e)}return t.size}function _1(e,t=0){let n=`Ran ${e} tool ${e===1?`call`:`calls`}`;return t===0?n:`${n}, edited ${t} file${t===1?``:`s`}`}function v1(e){return e>0?`${_1(e)}. Thinking…`:`Thinking…`}function y1(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function b1(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function x1(e,t){let n=y1(e,t);if(n)try{let e=new URL(n);return e.protocol===`https:`||e.protocol===`http:`?e.href:void 0}catch{return}}function S1({directive:e,icon:t,title:n,meta:r,children:i}){return(0,L.jsxs)(`section`,{"data-codex-directive":e.name,className:`min-w-0 ${Yq} border border-border bg-panel-2/75 p-4`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center text-muted`,"aria-hidden":!0,children:t}),(0,L.jsx)(`div`,{className:`max-w-[calc(100%-1.5rem)] shrink-0 break-words text-[12px] font-medium leading-4 text-fg`,children:n}),r&&(0,L.jsx)(`div`,{className:`min-w-0 truncate text-[11px] font-normal leading-4 text-muted`,children:r})]}),i]})}function C1({children:e,mono:t=!1}){return(0,L.jsx)(`div`,{className:`ml-6 mt-1 break-words text-[11px] leading-4 text-muted${t?` font-mono-keep`:``}`,children:e})}function w1({directive:e}){let t=e.attrs,n=y1(t,`display_name`)??y1(t,`skill_name`)??`Artifact template`,r=y1(t,`artifact_kind`),i=y1(t,`skill_name`),a=y1(t,`skill_directory`),[o,s]=(0,I.useState)(!!a);return(0,L.jsxs)(S1,{directive:e,icon:(0,L.jsx)(Am,{size:15}),title:n,meta:r?`${r} template`:`Template`,children:[i&&(0,L.jsx)(C1,{mono:!0,children:i.startsWith(`$`)?i:`$${i}`}),o&&a&&(0,L.jsx)(`img`,{src:jS(`${a}/assets/preview.png`),alt:`${n} template preview`,loading:`lazy`,onError:()=>s(!1),className:`ml-6 mt-2 max-h-44 max-w-[calc(100%-1.5rem)] rounded-md border border-border object-contain`})]})}function T1({directive:e}){let t=e.attrs,n=y1(t,`file`),r=b1(t,`start`),i=b1(t,`end`)??r,a=b1(t,`priority`),o=n?`${n}${r?`:${r}${i&&i!==r?`-${i}`:``}`:``}`:`Code location unavailable`;return(0,L.jsxs)(S1,{directive:e,icon:(0,L.jsx)(Fm,{size:15}),title:y1(t,`title`)??`Review finding`,meta:a===void 0?void 0:`P${a}`,children:[y1(t,`body`)&&(0,L.jsx)(C1,{children:y1(t,`body`)}),n?(0,L.jsx)(`button`,{type:`button`,className:`local-file-action ml-6 mt-1 max-w-[calc(100%-1.5rem)] break-all text-left font-mono-keep text-[11px] leading-4 text-accent underline decoration-dotted underline-offset-2`,"data-local-path":n,title:o,children:o}):(0,L.jsx)(C1,{mono:!0,children:o})]})}var E1={"git-stage":[zm,`Changes staged`],"git-commit":[ym,`Commit created`],"git-create-branch":[vm,`Branch created`],"git-push":[ih,`Branch pushed`],"git-create-pr":[Cm,`Pull request created`]};function D1({directive:e}){let[t,n]=E1[e.name],r=y1(e.attrs,`branch`),i=x1(e.attrs,`url`),a=`${n}${e.attrs.isDraft===!0?` as draft`:``}`;return(0,L.jsx)(S1,{directive:e,icon:(0,L.jsx)(t,{size:15}),title:i?(0,L.jsx)(`a`,{className:`text-accent underline underline-offset-2`,href:i,target:`_blank`,rel:`noopener noreferrer`,children:a}):a,meta:r&&(0,L.jsx)(`span`,{className:`font-mono-keep`,children:r})})}function O1({directive:e}){let t=y1(e.attrs,`threadId`),n=y1(e.attrs,`pendingWorktreeId`);return(0,L.jsx)(S1,{directive:e,icon:(0,L.jsx)(Rm,{size:15}),title:n?`Thread setup queued`:`Thread created`,meta:(t||n)&&(0,L.jsx)(`span`,{className:`font-mono-keep`,children:t??n})})}function k1({directive:e}){let t=y1(e.attrs,`reason`);return(0,L.jsx)(S1,{directive:e,icon:(0,L.jsx)(Kp,{size:15}),title:`Archive suggested`,meta:t})}function A1(e){if(typeof e!=`string`||!e)return;let t=e.match(/(?:^|;)INTERVAL=(\d+)(?:;|$)/)?.[1];return/(?:^|;)FREQ=HOURLY(?:;|$)/.test(e)?`Every ${t??`1`} hour${t===`1`||t===void 0?``:`s`}`:/(?:^|;)FREQ=WEEKLY(?:;|$)/.test(e)?`Weekly schedule`:`Custom schedule`}function j1({directive:e}){let t=e.attrs,n=y1(t,`mode`),r=y1(t,`name`)??`Automation`,i=A1(t.rrule),a=[r,n,y1(t,`status`),i].filter(Boolean).join(` · `);return(0,L.jsx)(S1,{directive:e,icon:(0,L.jsx)(Zp,{size:15}),title:`Automation suggested`,meta:a,children:y1(t,`prompt`)&&(0,L.jsx)(C1,{children:y1(t,`prompt`)})})}function M1({directive:e}){return e.name===`artifact-template`?(0,L.jsx)(w1,{directive:e}):e.name===`code-comment`?(0,L.jsx)(T1,{directive:e}):e.name.startsWith(`git-`)?(0,L.jsx)(D1,{directive:e}):e.name===`created-thread`?(0,L.jsx)(O1,{directive:e}):e.name===`archive`||e.name===`archive-thread`?(0,L.jsx)(k1,{directive:e}):(0,L.jsx)(j1,{directive:e})}var N1;function P1(){return N1??=By(async()=>{let{default:e}=await import(`./mermaid.core-D5Mvu4fo.js`);return{default:e}},__vite__mapDeps([2,3,4,1,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21])).then(({default:e})=>(e.initialize({startOnLoad:!1,securityLevel:`strict`,theme:`dark`,themeVariables:{background:`#181b20`,primaryColor:`#181b20`,primaryTextColor:`#e6e7e9`,primaryBorderColor:`#33363c`,lineColor:`#8b8f96`,secondaryColor:`#26282d`,tertiaryColor:`#0d0e10`,fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`}}),e)),N1}function F1({source:e}){let t=(0,I.useId)(),[n,r]=(0,I.useState)({}),i=nq(n.html??``);return(0,I.useEffect)(()=>{let n=!0;if(r({}),e.length>5e4)return r({error:`Diagram source exceeds the 50 KB rendering limit`}),()=>{n=!1};let i=`frizz-mermaid-${t.replace(/[^a-zA-Z0-9]/g,``)}`;return P1().then(t=>t.render(i,e)).then(({svg:e})=>{n&&r({html:e})}).catch(e=>{if(!n)return;let t=e instanceof Error?e.message.split(/\n| for text:/,1)[0]:`Unknown diagram error`;r({error:t.slice(0,240)})}).finally(()=>document.getElementById(`d${i}`)?.remove()),()=>{n=!1}},[t,e]),n.error?(0,L.jsxs)(`section`,{"data-mermaid-state":`error`,className:`${Yq} border border-border bg-panel-2/75 p-4`,children:[(0,L.jsx)(`div`,{className:`text-[12px] font-medium text-fg`,children:`Diagram unavailable`}),(0,L.jsx)(`div`,{className:`mt-1 text-[11px] text-muted`,children:n.error}),(0,L.jsx)(`pre`,{className:`mt-2 overflow-x-auto whitespace-pre-wrap rounded-md bg-bg p-2 font-mono-keep text-[11px] text-muted`,children:e})]}):n.html?(0,L.jsx)(`div`,{"data-mermaid-state":`ready`,className:`overflow-x-auto ${Yq} border border-border bg-panel-2/75 p-4 [&_svg]:mx-auto [&_svg]:h-auto [&_svg]:max-w-full`,dangerouslySetInnerHTML:i}):(0,L.jsx)(`div`,{"data-mermaid-state":`loading`,role:`status`,"aria-label":`Rendering diagram`,className:`h-24 animate-pulse ${Yq} bg-panel-2`})}var I1=(0,I.createContext)(null),L1=(0,I.createContext)(null);function R1(){let e=(0,I.useContext)(I1),t=(0,I.useContext)(L1);return e??t}var z1=(0,I.createContext)(null);function B1(e){return e.status===`pending`&&e.backgroundState===`background`}function V1(e){let t=[];for(let n of e)for(let e of n.tools)B1(e)&&n.at&&t.push({label:e.desc??e.detail??e.command??`Background command`,startedAt:n.at,state:`running`,...e.shellId?{launchId:e.shellId}:{},...e.command?{command:e.command}:{}});return t}function H1(e){return e.map(e=>{if(!e.tools.some(B1))return e;let t=e.tools.filter(e=>!B1(e)),n=e.parts?.map(e=>e.kind===`tools`?{...e,tools:e.tools.filter(e=>!B1(e))}:e).filter(e=>e.kind!==`tools`||e.tools.length>0);return{...e,tools:t,parts:n}})}function U1({slug:e,onStatusApplied:t,onClose:n,virtualized:r=!1,showReturnToQueue:i=!1}){let a=Dp(kC(),e);return(0,L.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,L.jsx)(t0,{slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:i}),(0,L.jsx)(W1,{slug:e,virtualized:r}),a&&(0,L.jsx)(YX,{thread:a,sticky:!0,safeArea:!0,onArchived:t})]})}function W1({slug:e,virtualized:t}){let n=kC(),r=Dp(n,e),i=r?.runtime===`running`||r?.runtime===`spawning`,a=A$(e),o=UC(e,{poll:i}),s=Ve(),c=(0,I.useRef)(!1),[l,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(null),p=(0,I.useMemo)(()=>o.data?.messages??[],[o.data]),m=(0,I.useMemo)(()=>V1(p),[p]),h=(0,I.useMemo)(()=>H1(p),[p]),g=(0,I.useMemo)(()=>h0(h),[h]),_=(0,I.useMemo)(()=>i?_$(h):void 0,[i,h]),v=_&&_.index>=0?_.index:g,y=(0,I.useMemo)(()=>e1(h),[h]),b=i?r1(y):void 0,x=i?n1(y):void 0,S=x?p1(x,n?.projectDir):void 0,C=i?a1(y):void 0,w=p$(r),T=(0,I.useMemo)(()=>{let e=i?c1(y):y;return L$(e,g0(e,v,w))},[y,i,v,w]),E=i,D=(0,I.useMemo)(()=>EJ(p),[p]),O=(0,I.useMemo)(()=>xJ(p,r?.answersInFlight),[p,r?.answersInFlight]),k=(0,I.useMemo)(()=>IY(p),[p]),A={thread:r,showWorking:E,registeredDone:qq(r,g>=0?h[g]?.text:void 0),restedCard:cJ(r,g>=0?h[g]?.text:void 0),errorVisible:uJ(h,r?.providerError)},{answeringForMessage:j}=yY(e,p),M=(0,I.useMemo)(()=>NJ(p,r?.questions??[]),[p,r?.questions]),N=(0,I.useRef)(null),[P,ee]=(0,I.useState)(null),F=o.data?.messages.length??0,te=!o.isLoading;(0,I.useEffect)(()=>{if(t)return;let e=N.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<=4&&(e.scrollTop=e.scrollHeight)},[F,i,t]);let ne=(0,I.useCallback)(async()=>{if(c.current)return;let t=s.getQueryData([`transcript`,e]),n=t?.beforeCursor,r=t?.transcriptKey;if(!(!t?.hasEarlier||!n||!r)){c.current=!0,u(!0),f(null);try{let t=await Y.threadTranscriptEarlier({slug:e,cursor:n}),i=s.getQueryData([`transcript`,e]);if(!i?.transcriptKey||i.transcriptKey!==r||t.transcriptKey!==r){await o.refetch(),Z(`Transcript changed while loading history; refreshed the current session`);return}s.setQueryData([`transcript`,e],mx(i,t))}catch(e){let t=e instanceof Error?e.message:`Could not load earlier transcript history`;f(t)}finally{c.current=!1,u(!1)}}},[o,s,e]);return(0,L.jsx)(I1.Provider,{value:e,children:(0,L.jsxs)(`div`,{"data-drawer-scroll-ready":o.isPending?`false`:`true`,className:`flex-1 min-h-0 flex flex-col overflow-hidden outline-none`,children:[(0,L.jsxs)(`div`,{className:`relative min-h-0 flex-1 flex flex-col`,children:[(0,L.jsx)(`div`,{ref:N,"data-drawer-transcript-scroll":!0,"data-virtualized-transcript-scroll":t||void 0,tabIndex:t?0:void 0,role:t?`region`:void 0,"aria-label":t?`Thread conversation`:void 0,"aria-busy":t&&l?!0:void 0,className:`relative min-h-0 flex-1 overflow-y-auto pb-3 outline-none [overflow-anchor:none] focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/60`,children:t&&F>0?(0,L.jsx)($1,{slug:e,transcriptRef:N,transcriptKey:o.data?.transcriptKey,messages:h,paired:D,inFlightAnswers:O,answeringForMessage:j,thread:r,running:i,copyTerminalCommand:a,transportFallback:o.transportFallback,isFetching:o.isFetching,refresh:()=>void o.refetch(),retryLiveUpdates:o.retryLiveUpdates,hasEarlier:o.data?.hasEarlier===!0,beforeCursor:o.data?.beforeCursor,loadingEarlier:l,earlierError:d,loadEarlier:()=>void ne(),jumpOverlay:P}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(tQ,{thread:r,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(wQ,{thread:r,inFlight:O,className:`px-6 pt-5`}),o.transportFallback&&(0,L.jsxs)(`div`,{"data-transcript-sync-fallback":!0,className:`mx-6 mt-3 flex flex-wrap items-center gap-2.5 rounded-xl border border-border-strong bg-panel-2 px-4 py-2.5 text-[12px]`,title:o.transportFallback.kind===`payload-too-large`?`Live payload ${o.transportFallback.actualBytes} bytes; socket limit ${o.transportFallback.maxBytes} bytes`:`Transcript read budget reached (${o.transportFallback.scope}); retry after about ${o.transportFallback.retryAfterMs}ms`,children:[(0,L.jsx)(rh,{size:13,className:`shrink-0 text-muted`}),(0,L.jsxs)(`div`,{className:`min-w-[180px] flex-1 leading-snug text-fg/85`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Live transcript updates paused.`}),` `,o.transportFallback.kind===`payload-too-large`?`The transcript is too large for push; the last complete HTTP-loaded copy remains visible.`:`The live read budget was reached; the last complete copy remains visible. Retry in a moment.`]}),(0,L.jsx)(`button`,{type:`button`,disabled:o.isFetching,onClick:()=>void o.refetch(),className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel disabled:opacity-40`,children:o.isFetching?`Refreshing…`:`Refresh once`}),(0,L.jsx)(`button`,{type:`button`,onClick:o.retryLiveUpdates,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel`,children:`Retry live`})]}),(0,L.jsx)(`div`,{"data-transcript-column":!0,className:`flex min-h-full flex-col px-6 py-5`,children:F===0?(0,L.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted`,children:o.isPending?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(b2,{}),` Loading…`]}):i?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(b2,{}),` Session starting…`]}):HY(r)?(0,L.jsxs)(`div`,{className:`text-center`,children:[(0,L.jsx)(`p`,{className:`mb-3`,children:`No session is attached to this thread yet.`}),(0,L.jsx)(`button`,{className:`btn-ghost border border-border text-[12px]`,onClick:()=>Y.adoptThread({slug:e}).catch(()=>{}),children:`Start a session on this thread`})]}):`No conversation yet.`}):(0,L.jsxs)(L.Fragment,{children:[b0(T.map(e=>e.message),(e,t)=>{let n=T[t].messageIndex;return(0,L.jsx)(t2,{m:e,answering:j(e),showSendButton:!0,paired:D[n],staleAwaiting:v>=0&&n<v,restingCardShown:n===g&&w,restedAt:_&&n===_.index?_.at??``:void 0,shadowedBy:M.get(n),thread:r},t)},e=>!!e.queued),te&&X1(A)!==null&&(0,L.jsx)(BJ,{h:Z1(A,T.map(e=>e.message))}),te&&(0,L.jsx)(Q1,{state:A,slug:e,retryText:k>=0?p[k]?.text:void 0,onTerminal:a,liveRuntimeStart:C,liveActivityLabel:S,liveToolRun:b}),r?.permPolicy?(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(f2,{policy:r.permPolicy,denies:r.permDenies})}):null,p.some(e=>e.queued)&&(0,L.jsx)(BJ,{}),(0,L.jsx)(`div`,{className:`flex flex-col gap-3.5`,children:p.map((e,t)=>e.queued?(0,L.jsx)(t2,{m:e,paired:D[t]},`q${t}`):null)})]})})]})}),(0,L.jsx)(`div`,{ref:ee,"data-transcript-overlay":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 z-20 flex justify-end p-4 [&>*]:pointer-events-auto`})]}),(0,L.jsx)(`div`,{"data-thread-chat-footer":!0,className:`z-10 shrink-0 border-t border-border/60 bg-panel`,children:(0,L.jsx)(pX,{slug:e,onTerminal:a,ops:(0,L.jsx)(p2,{slug:e,transcriptShells:m,className:`px-1 pt-1.5`})})})]})})}var G1=700,K1=250,q1=(()=>{try{return localStorage.getItem(`frizz.debugScroll`)===`1`}catch{return!1}})();function J1(e){return e?.pendingInteraction===!0}function Y1(e){return J1(e)?void 0:e?.pendingAsk}function X1({thread:e,showWorking:t,registeredDone:n,restedCard:r,errorVisible:i}){return e?.providerError?.retrying?`provider-error`:e?.providerFault&&!e.foreign?`provider-fault`:e?.limitPause&&!e.foreign?`limit-pause`:Y1(e)?`pending-ask`:e?.runtime===`perm-prompt`&&!J1(e)?`perm-prompt`:t?`working`:e?.providerError?i?null:`provider-error`:v$(e)?`snooze`:p$(e)?`resting`:n?`registered-done`:r?`rested`:null}function Z1(e,t){return X1(e)===`working`?y0(t):14}function Q1({state:e,slug:t,retryText:n,onTerminal:r,liveRuntimeStart:i,liveActivityLabel:a,liveToolRun:o}){let s=e.thread;switch(X1(e)){case`provider-fault`:return(0,L.jsx)(l2,{slug:t,sessionId:s.sessionId,fault:s.providerFault,retryText:n});case`provider-error`:return(0,L.jsx)(dJ,{error:s.providerError});case`limit-pause`:return(0,L.jsx)(u2,{slug:t,sessionId:s.sessionId,pause:s.limitPause});case`pending-ask`:return(0,L.jsx)(m2,{ask:Y1(s),onTerminal:r});case`perm-prompt`:return(0,L.jsx)(d2,{onTerminal:r});case`working`:return(0,L.jsx)(x2,{since:s?.lastUserAt,startedAt:i,activityLabel:a,run:o});case`snooze`:return(0,L.jsx)(b$,{thread:s});case`resting`:return(0,L.jsx)(g$,{thread:s});case`registered-done`:return(0,L.jsx)(c2,{fenceKind:`done`,body:s.lastFence.body,hints:[]});case`rested`:return(0,L.jsx)(lJ,{thread:s});default:return null}}function $1({slug:e,transcriptRef:t,transcriptKey:n,messages:r,paired:i,inFlightAnswers:a,answeringForMessage:o,thread:s,running:c,copyTerminalCommand:l,transportFallback:u,isFetching:d,refresh:f,retryLiveUpdates:p,hasEarlier:m,beforeCursor:h,loadingEarlier:g,earlierError:_,loadEarlier:v,jumpOverlay:y}){let b=AC(),x=(0,I.useMemo)(()=>e1(r),[r]),S=c?r1(x):void 0,C=c?n1(x):void 0,w=C?p1(C,b):void 0,T=c?a1(x):void 0,E=(0,I.useMemo)(()=>h0(r),[r]),D=(0,I.useMemo)(()=>c?_$(r):void 0,[c,r]),O=D&&D.index>=0?D.index:E,k=p$(s),A=(0,I.useMemo)(()=>{let e=c?c1(x):x;return L$(e,g0(e,O,k))},[x,c,O,k]),j=c,M=(0,I.useMemo)(()=>F$(A.map(e=>e.message),g0(A,O,k),p0).map(e=>{let t=A[e.messageIndex];return{...e,messageIndex:t.messageIndex,stampAt:o1(t)}}),[A,O,k]),N=(0,I.useMemo)(()=>IY(r),[r]),P=qq(s,E>=0?r[E]?.text:void 0),ee=cJ(s,E>=0?r[E]?.text:void 0),F=uJ(r,s?.providerError),te={thread:s,showWorking:j,registeredDone:P,restedCard:ee,errorVisible:F},ne=X1(te)!==null,re=(0,I.useMemo)(()=>Z1({thread:s,showWorking:j,registeredDone:P,restedCard:ee,errorVisible:F},A.map(e=>e.message)),[A,j,s,P,ee,F]),ie=(0,I.useMemo)(()=>{let e=[],t=new Map,n=r.length-1;for(let[i,a]of AJ(r,s?.questions??[],{atRest:!c})){if(i>=n){e.push(...a);continue}let r=-1;for(let e=0;e<M.length&&!(M[e].messageIndex>i);e++)r=e;let o=t.get(r);o?o.push(...a):t.set(r,[...a])}return{byRow:t,tail:e}},[M,r,c,s?.questions]),ae=(0,I.useMemo)(()=>NJ(r,s?.questions??[]),[r,s?.questions]),oe=(0,I.useMemo)(()=>{let e=[{key:`head-anchor`,kind:`head-anchor`}];u&&e.push({key:`transport-fallback`,kind:`transport-fallback`}),(m||g||_)&&e.push({key:`earlier-history:${h??`complete`}`,kind:`earlier-history`});let t=ie.byRow.get(-1);t&&e.push({key:`questions:head`,kind:`questions`,questions:t}),M.forEach((t,n)=>{e.push({...t,kind:`message`});let r=ie.byRow.get(n);r&&e.push({key:`questions:${t.key}`,kind:`questions`,questions:r})}),e.push({key:`interactions`,kind:`interactions`}),ne&&e.push({key:`runtime-status`,kind:`runtime-status`});let n=ne||M.length>0?14:0;return r.forEach((t,r)=>{if(!t.queued)return;let i=`queued:${t.deliveryId??t.sourceId??r}`;e.push({key:i,kind:`queued`,message:t,messageIndex:r,gap:n}),n=14}),e},[h,_,m,ne,g,M,r,ie,u]),se=jw({count:oe.length,getScrollElement:()=>t.current,getItemKey:e=>oe[e]?.key??e,estimateSize:e=>{let t=oe[e];return t?t.kind===`head-anchor`||t.kind===`interactions`?1:t.kind===`earlier-history`?42:t.kind===`transport-fallback`?76:t.kind===`runtime-status`?54:t.kind===`questions`?220:t.kind===`message`?108+t.gap:82+t.gap:80},overscan:8,paddingStart:20,paddingEnd:20,anchorTo:`end`,followOnAppend:!0,scrollEndThreshold:4,scrollToFn:(e,{adjustments:t,behavior:n},r)=>{let i=r.scrollElement;i&&i.scrollTo({top:t===void 0?e:i.scrollTop+t,behavior:n})}}),[ce,le]=(0,I.useState)(!0),ue=(0,I.useRef)(!0),de=(0,I.useRef)(-1),fe=(0,I.useRef)(0),pe=(0,I.useRef)(null),me=(0,I.useRef)(!1),he=(0,I.useRef)(!1),ge=(0,I.useRef)(!0),_e=(0,I.useRef)(null),ve=(0,I.useRef)(void 0),ye=(0,I.useRef)(null),be=(0,I.useRef)(void 0),xe=(0,I.useRef)(0),Se=(0,I.useCallback)(()=>{let e=t.current;if(e){let t=e.getBoundingClientRect().top,n=Array.from(e.querySelectorAll(`[data-transcript-source-id]`)).find(e=>e.getBoundingClientRect().bottom>t+1),r=n?.dataset.transcriptRowKey;n&&r&&(_e.current={rowKey:r,viewportTop:n.getBoundingClientRect().top-t})}v()},[v,t]),Ce=(0,I.useCallback)((e,n)=>{let r=t.current;if(!r)return;let i=Array.from(r.querySelectorAll(`[data-transcript-source-id]`)).find(t=>t.dataset.transcriptSourceId===e);i&&(r.scrollTop+=i.getBoundingClientRect().top-n)},[t]);(0,I.useLayoutEffect)(()=>{if(!n||oe.length===0||ve.current===n)return;ve.current=n,me.current=!1,he.current=!1,ge.current=!0;let t=ZE(e)?.candidates.map(e=>({candidate:e,index:oe.findIndex(t=>t.kind===`message`&&t.message.sourceId===e.sourceId)})).find(e=>e.index>=0),r=requestAnimationFrame(()=>{if(!t){se.scrollToEnd({behavior:`instant`}),le(!0),me.current=!0;return}se.scrollToIndex(t.index,{align:`start`,behavior:`instant`}),ue.current=!1,le(!1),me.current=!0;let e=performance.now()+K1;xe.current=e;let n=()=>{performance.now()>=e||performance.now()<fe.current||(Ce(t.candidate.sourceId,t.candidate.screenTop),r=requestAnimationFrame(n))};n()});return()=>cancelAnimationFrame(r)},[Ce,oe.length,e,n,se]),(0,I.useLayoutEffect)(()=>{let e=_e.current,n=t.current;if(!e||!n||g)return;let r=()=>{let t=Array.from(n.querySelectorAll(`[data-transcript-row-key]`)).find(t=>t.dataset.transcriptRowKey===e.rowKey);if(!t)return;let r=t.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTop+=r-e.viewportTop};r();let i=0,a=requestAnimationFrame(()=>{r(),i=requestAnimationFrame(()=>{r(),_e.current===e&&(_e.current=null)})});return()=>{cancelAnimationFrame(a),cancelAnimationFrame(i)}},[g,M.length,t]);let we=(0,I.useCallback)(()=>{let e=t.current;if(!e)return null;let n=e.getBoundingClientRect().top,r=Array.from(e.querySelectorAll(`[data-transcript-row-key]`)).find(e=>e.getBoundingClientRect().bottom>n+1),i=r?.dataset.transcriptRowKey;return!r||!i?null:{rowKey:i,viewportTop:r.getBoundingClientRect().top-n}},[t]),Te=(0,I.useCallback)(e=>{let n=t.current;if(!n)return;let r=Array.from(n.querySelectorAll(`[data-transcript-row-key]`)).find(t=>t.dataset.transcriptRowKey===e.rowKey);if(!r)return;let i=r.getBoundingClientRect().top-n.getBoundingClientRect().top;n.scrollTop+=i-e.viewportTop},[t]),Ee=M[0]?.key;(0,I.useLayoutEffect)(()=>{let e=be.current;if(be.current=Ee,e===void 0||e===Ee||!me.current||ue.current||_e.current)return;let t=ye.current;if(!t)return;Te(t);let n=()=>{if(performance.now()<fe.current)return;let e=ye.current;e&&Te(e)},r=0,i=requestAnimationFrame(()=>{n(),r=requestAnimationFrame(n)});return()=>{cancelAnimationFrame(i),cancelAnimationFrame(r)}},[Te,Ee]);let De=(0,I.useCallback)(()=>{let e=t.current;if(!e||_e.current||performance.now()<xe.current)return;let n=M$({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,previousScrollHeight:de.current,following:ue.current,readerMoved:performance.now()<fe.current});if(ue.current=n.following,n.scrollTop!==null&&(e.scrollTop=n.scrollTop),de.current=e.scrollHeight,le(e=>e===n.following?e:n.following),q1&&!n.following&&performance.now()>=fe.current){let t=ye.current,n=t&&Array.from(e.querySelectorAll(`[data-transcript-row-key]`)).find(e=>e.dataset.transcriptRowKey===t.rowKey);if(t&&n){let r=Math.round(n.getBoundingClientRect().top-e.getBoundingClientRect().top-t.viewportTop);Math.abs(r)>2&&console.warn(`[frizz] transcript moved ${r}px under a still reader — row=${t.rowKey}`)}}ye.current=we()??ye.current},[we,t]);(0,I.useLayoutEffect)(De),(0,I.useEffect)(()=>{let e=pe.current;if(!e)return;let t=new ResizeObserver(De);return t.observe(e),()=>t.disconnect()},[De]),(0,I.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{De();let t=N$({armed:ge.current,scrollTop:e.scrollTop,readerMoved:me.current&&he.current,hasEarlier:m,loading:g});ge.current=t.armed,t.shouldLoad&&Se()},r=()=>{he.current=!0,fe.current=performance.now()+G1,requestAnimationFrame(n)},i=t=>{[`ArrowUp`,`PageUp`,`Home`,` `].includes(t.key)&&(e.scrollTop<=480&&(ge.current=!0),r())},a=t=>{t.deltaY<0&&e.scrollTop<=480&&(ge.current=!0),r()},o=()=>{e.scrollTop<=480&&(ge.current=!0),r()};e.addEventListener(`scroll`,n,{passive:!0}),e.addEventListener(`wheel`,a,{passive:!0}),e.addEventListener(`touchstart`,o,{passive:!0}),e.addEventListener(`touchmove`,o,{passive:!0}),e.addEventListener(`pointerdown`,r,{passive:!0}),e.addEventListener(`keydown`,i);let s=requestAnimationFrame(n);return()=>{cancelAnimationFrame(s),e.removeEventListener(`scroll`,n),e.removeEventListener(`wheel`,a),e.removeEventListener(`touchstart`,o),e.removeEventListener(`touchmove`,o),e.removeEventListener(`pointerdown`,r),e.removeEventListener(`keydown`,i)}},[m,g,Se,De,t]);let Oe=se.getVirtualItems(),ke=se.getTotalSize();return(0,L.jsxs)(`div`,{ref:pe,"data-virtualized-transcript":!0,"data-virtual-row-count":Oe.length,className:`relative w-full`,style:{height:ke},children:[Oe.map(t=>{let n=oe[t.index];return n?(0,L.jsx)(`div`,{ref:se.measureElement,"data-index":t.index,"data-transcript-row-key":n.key,"data-transcript-source-id":n.kind===`message`?n.message.sourceId:void 0,className:`absolute left-0 top-0 w-full hover:z-[1]`,style:{transform:`translateY(${t.start}px)`},children:n.kind===`head-anchor`?null:n.kind===`interactions`?(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(tQ,{thread:s,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,L.jsx)(wQ,{thread:s,questions:ie.tail,inFlight:a,className:`px-6 pt-5`})]}):n.kind===`questions`?(0,L.jsx)(wQ,{thread:s,questions:n.questions,className:`px-6 pt-5`}):n.kind===`transport-fallback`?u?(0,L.jsx)(`div`,{className:`px-6 pt-3`,children:(0,L.jsxs)(`div`,{"data-transcript-sync-fallback":!0,className:`flex flex-wrap items-center gap-2.5 ${Yq} border border-border-strong bg-panel-2 px-4 py-2.5 text-[12px]`,title:u.kind===`payload-too-large`?`Live payload ${u.actualBytes} bytes; socket limit ${u.maxBytes} bytes`:`Transcript read budget reached (${u.scope}); retry after about ${u.retryAfterMs}ms`,children:[(0,L.jsx)(rh,{size:13,className:`shrink-0 text-muted`}),(0,L.jsxs)(`div`,{className:`min-w-[180px] flex-1 leading-snug text-fg/85`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:`Live transcript updates paused.`}),` `,u.kind===`payload-too-large`?`The transcript is too large for push; the last complete HTTP-loaded copy remains visible.`:`The live read budget was reached; the last complete copy remains visible. Retry in a moment.`]}),(0,L.jsx)(`button`,{type:`button`,disabled:d,onClick:f,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel disabled:opacity-40`,children:d?`Refreshing…`:`Refresh once`}),(0,L.jsx)(`button`,{type:`button`,onClick:p,className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel`,children:`Retry live`})]})}):null:n.kind===`earlier-history`?(0,L.jsx)(`div`,{className:`flex min-h-10 items-center justify-center px-6 text-[11px] text-muted`,role:`status`,children:_?(0,L.jsxs)(`span`,{className:`flex flex-wrap items-center justify-center gap-2 text-center`,children:[(0,L.jsx)(`span`,{children:_}),(0,L.jsx)(`button`,{type:`button`,onClick:Se,className:`rounded-md border border-border px-2 py-1 text-fg/90 hover:bg-panel-2`,children:`Retry`})]}):g?(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(Mm,{size:12,className:`animate-spin`}),` Loading earlier messages…`]}):(0,L.jsx)(`button`,{type:`button`,onClick:Se,className:`rounded-md px-2 py-1 outline-none hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,children:`Load earlier messages`})}):n.kind===`message`?(0,L.jsx)(fZ,{at:n.stampAt,host:zY(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(t2,{m:n.message,answering:o(n.message),showSendButton:!0,paired:i[n.messageIndex],staleAwaiting:O>=0&&n.messageIndex<O,restingCardShown:n.messageIndex===E&&k,restedAt:D&&n.messageIndex===D.index?D.at??``:void 0,shadowedBy:ae.get(n.messageIndex),thread:s})}):n.kind===`runtime-status`?(0,L.jsxs)(`div`,{className:`px-6`,style:{paddingTop:re},children:[(0,L.jsx)(Q1,{state:te,slug:e,retryText:N>=0?r[N]?.text:void 0,onTerminal:l,liveRuntimeStart:T,liveActivityLabel:w,liveToolRun:S}),s?.permPolicy?(0,L.jsx)(`div`,{className:`mt-3`,children:(0,L.jsx)(f2,{policy:s.permPolicy,denies:s.permDenies})}):null]}):(0,L.jsx)(fZ,{at:n.message.at,host:zY(n.message,i[n.messageIndex]),gap:n.gap,children:(0,L.jsx)(t2,{m:n.message,paired:i[n.messageIndex]})})},n.key):null}),(0,L.jsx)(e0,{overlay:y,hidden:ce,onJump:()=>se.scrollToEnd({behavior:`smooth`})})]})}function e0({overlay:e,hidden:t,onJump:n}){return!e||t?null:(0,ot.createPortal)((0,L.jsxs)(`button`,{type:`button`,"data-jump-to-latest":!0,onClick:n,className:`flex items-center gap-1.5 rounded-full border border-border-strong bg-elevated px-3 py-1.5 text-[11px] font-medium text-fg shadow-lg shadow-black/30 hover:bg-panel-2`,children:[(0,L.jsx)(qp,{size:12}),`Jump to latest`]}),e)}function t0({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1}){let i=Dp(kC(),e),a=it({mutationFn:()=>Y.markComplete({slug:e})}),o=it({mutationFn:t=>Y.renameThread({slug:e,title:t})}),[s,c]=(0,I.useState)(!1),[l,u]=(0,I.useState)(``),d=(0,I.useRef)(null);(0,I.useEffect)(()=>{if(!s)return;let e=requestAnimationFrame(()=>{d.current?.focus(),d.current?.select()});return()=>cancelAnimationFrame(e)},[s]),(0,I.useEffect)(()=>{c(!1),u(``)},[e]);let f=rK(nt({queryKey:[`threadBody`,e],queryFn:()=>Y.threadBody({slug:e})}).data?.markdown??``).trim().length>0;if(!i)return null;let p=i.kind===`session`&&i.foreign!==!0,m=i.foreign===!0,h=i.kind===`session`&&!m,g=aT(i);function _(){c(!1),u(``)}function v(){let e=UY(l,g);if(c(!1),!e){u(``);return}o.mutate(e,{onSuccess:()=>{u(``),Z(`Thread renamed`)},onError:t=>{u(e),c(!0),Z(t instanceof Error?t.message:`Could not rename thread`)}})}return(0,L.jsxs)(`header`,{"data-thread-header":!0,className:KY,children:[(0,L.jsx)(`div`,{className:qY,children:(0,L.jsxs)(`div`,{className:`min-w-0 leading-tight`,children:[(0,L.jsxs)(`div`,{className:`group/thread-title flex min-w-0 items-center gap-2`,children:[s?(0,L.jsx)(`input`,{ref:d,"aria-label":`Thread title`,value:l,maxLength:200,onChange:e=>u(e.target.value),onBlur:v,onKeyDown:e=>{e.key===`Enter`?(e.preventDefault(),v()):e.key===`Escape`&&(e.preventDefault(),_())},className:`min-w-0 flex-1 rounded-md border border-border bg-elevated px-1.5 py-1 font-semibold text-[15px] text-fg outline-none focus:border-accent`}):h?(0,L.jsx)(`button`,{type:`button`,title:`Edit title`,"aria-label":`Edit thread title: ${g}`,disabled:o.isPending,onClick:()=>{u(WY(g,i.id)),c(!0)},className:`min-w-0 max-w-full shrink truncate rounded px-0.5 -mx-0.5 font-semibold text-[15px] text-left outline-none transition-colors hover:bg-panel-2 focus-visible:ring-1 focus-visible:ring-fg/60 disabled:cursor-not-allowed disabled:opacity-40`,children:g}):(0,L.jsx)(`div`,{className:`min-w-0 max-w-full shrink truncate px-0.5 -mx-0.5 font-semibold text-[15px]`,title:g,children:g}),(0,L.jsx)(eZ,{thread:i,hidden:s})]}),(0,L.jsx)(x$,{at:gT(i),fallbackAt:i.spawnedAt,className:`mt-0.5 block truncate text-[11px] leading-tight text-muted/75`})]})}),(0,L.jsxs)(`div`,{className:JY,children:[(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[p&&(0,L.jsx)(j$,{slug:e}),(0,L.jsx)(yX,{thread:i,collapse:r,onDoc:f?()=>$f(`doc`,i.id):void 0,onDone:()=>a.mutate(void 0,{onSuccess:t}),doneBusy:a.isPending,onStatusApplied:t}),n&&(0,L.jsx)(zj,{slug:e})]}),n&&(0,L.jsx)(`button`,{type:`button`,"aria-label":`Close`,"data-dialog-initial-focus":!0,onClick:n,className:`ml-0.5 shrink-0 rounded-md p-1.5 text-muted outline-none transition-colors hover:bg-panel-2 hover:text-fg`,children:(0,L.jsx)(ah,{size:15})})]})]})}function n0(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||aZ(e))return null;if(e.parts&&e.parts.length>0){for(let t=e.parts.length-1;t>=0;t--){let n=e.parts[t];if(n.kind===`tools`?n.tools.length>0:n.text.trim())return n.kind===`tools`?n.tools:null}return null}return(e.tools?.length??0)>0&&!e.text.trim()?e.tools:null}function r0(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||aZ(e))return null;if(e.parts&&e.parts.length>0){for(let t of e.parts)if(t.kind===`tools`?t.tools.length>0:t.text.trim())return t.kind===`tools`?t.tools:null;return null}return(e.tools?.length??0)>0?e.tools:null}function i0(e){return n0(e)!==null}function a0(e){return r0(e)!==null}function o0(e){return e.kind===`event`&&!e.boundary||e.kind===`reasoning`}function s0(e){return o0(e)||i0(e)}function c0(e){return o0(e)||a0(e)}function l0(e){if(o0(e))return!0;let t=n0(e);return t!==null&&!H$(t[t.length-1])}function u0(e){if(o0(e))return!0;let t=r0(e);return t!==null&&!H$(t[0])}function d0(e){let t=n0(e);return t!==null&&W$(t[t.length-1])}function f0(e){let t=r0(e);return t!==null&&W$(t[0])}function p0(e,t){let n=d0(e)||f0(t),r=!n&&s0(e)&&c0(t)&&!(l0(e)&&u0(t));return(n?22:r?6:14)+(e.role===`user`&&t.role!==`user`?3:0)}function m0(e,t){return e.kind===`event`||e.kind===`reasoning`||e.role===`user`?!1:e.parts&&e.parts.length>0?e.parts.every(n=>n.kind===`tools`?n.tools.length===0:_0(e,n.text,t)):(e.tools?.length??0)===0&&_0(e,e.text,t)}function h0(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`&&e[t].kind!==`event`)return t;return-1}function g0(e,t,n=!1){let r=new WeakSet;if(t>=0)for(let n of e)n.messageIndex<t&&r.add(n.message);if(t>=0&&n)for(let n of e)n.messageIndex===t&&r.add(n.message);return e=>m0(e,r.has(e))}function _0(e,t,n){return!e.fenceRefused&&!n?!t.trim():Kq(t).every(e=>e.kind===`fence`&&e.fenceKind===`awaiting`)}function v0(e,t){return e.kind===`event`||e.kind===`reasoning`||e.role===`user`?!1:e.parts&&e.parts.length>0?e.parts.some(n=>n.kind===`text`&&!_0(e,n.text,t)):typeof e.text==`string`&&!_0(e,e.text,t)}function y0(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.queued||m0(n)))return d0(n)?22:s0(n)&&!l0(n)?6:14+(n.role===`user`?3:0)}return 0}function b0(e,t,n){let r=[],i=null;return e.forEach((e,a)=>{n?.(e,a)||m0(e)||(i!==null&&r.push((0,L.jsx)(BJ,{h:p0(i,e)},`s${a}`)),r.push(t(e,a)),i=e)}),r}function x0(e){let t=[];for(let n of e){if(n.kind===`text`){if(!n.text.trim())continue;t.push(n);continue}if(n.tools.length===0)continue;let e=t[t.length-1];e&&e.kind===`tools`?t[t.length-1]={kind:`tools`,tools:[...e.tools,...n.tools]}:t.push(n)}return t}function S0(e,t=14){let n=e.filter(e=>e!=null&&e!==!1),r=[];return n.forEach((e,n)=>{n>0&&r.push((0,L.jsx)(BJ,{h:typeof t==`number`?t:t(n)},`vs${n}`)),r.push(e)}),r}var C0={head:!1,tail:!1};function w0(e,t){return n=>e[n-1]?.tail||e[n]?.head?22:t}function T0(e){return{head:W$(e[0]),tail:W$(e[e.length-1])}}function E0(e){let t=[];for(let n of e){let e=t[t.length-1];if(n.edit){let r=!!(n.input||n.output||n.status||n.exitCode!==void 0);e&&e.edits&&!r&&!e.input&&!e.output&&!e.status&&e.edits[0].file===n.edit.file?e.edits.push(n.edit):t.push({name:n.name,detail:n.detail,edits:[n.edit],input:n.input,output:n.output,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1})}else n.command?t.push({name:n.name,detail:n.detail,command:n.command,desc:n.desc,input:n.input,output:n.output,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1}):n.outputImage?t.push({name:n.name,detail:n.detail,outputImage:n.outputImage,output:n.output??n.read,status:n.status,durationMs:n.durationMs,count:1}):n.read?t.push({name:n.name,detail:n.detail,read:n.read,status:n.status,durationMs:n.durationMs,count:1}):n.prompt||n.agentId?t.push({name:n.name,detail:n.detail,prompt:n.prompt,input:n.input,subagentType:n.subagentType,agentId:n.agentId,agentStatus:n.agentStatus,agentElapsedMs:n.agentElapsedMs,output:n.output,status:n.status,durationMs:n.durationMs,count:1}):n.sendTo!==void 0||n.sendBody!==void 0?t.push({name:n.name,detail:n.detail,sendTo:n.sendTo,sendSummary:n.sendSummary,sendBody:n.sendBody,sendType:n.sendType,sendDispatchId:n.sendDispatchId,sendTargetLabel:n.sendTargetLabel,status:n.status,durationMs:n.durationMs,count:1}):n.todos?t.push({name:n.name,detail:n.detail,todos:n.todos,input:n.input,status:n.status,durationMs:n.durationMs,count:1}):U$(n)?t.push({name:n.name,detail:n.detail,ask:n.ask,askAnswers:n.askAnswers,status:n.status,durationMs:n.durationMs,count:1}):n.sentImages||n.sentFiles?t.push({name:n.name,detail:n.detail,sentImages:n.sentImages,sentFiles:n.sentFiles,caption:n.caption,status:n.status,durationMs:n.durationMs,count:1}):n.input||n.output?t.push({name:n.name,detail:n.detail,input:n.input,output:n.output,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1}):e&&!e.edits&&!e.command&&!e.input&&!e.output&&!e.read&&!e.prompt&&!e.outputImage&&!e.sentImages&&!e.sentFiles&&e.sendTo===void 0&&e.sendBody===void 0&&e.name===n.name&&e.detail===n.detail&&e.status===n.status&&e.backgroundState===n.backgroundState&&e.exitCode===n.exitCode&&e.cwd===n.cwd&&e.sessionId===n.sessionId&&e.durationMs===n.durationMs?e.count++:t.push({name:n.name,detail:n.detail,status:n.status,backgroundState:n.backgroundState,exitCode:n.exitCode,cwd:n.cwd,sessionId:n.sessionId,durationMs:n.durationMs,count:1})}return t}function D0(e){return e.split(`__`).pop()||e}function O0(e){let t=X.board?.projectDir;return t&&e.startsWith(t+`/`)?e.slice(t.length+1):e}function k0({tools:e,at:t}){let[n,r]=(0,I.useState)(!1),i=(0,I.useId)(),a=e.reduce((e,t)=>e+t.count,0),o=_1(a,g1(e));return(0,L.jsxs)(`div`,{"data-tool-activity":!0,"data-tool-activity-state":`settled`,className:`flex min-w-0 flex-col`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>r(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":i,"aria-expanded":n,"aria-label":`${n?`Collapse`:`Expand`} ${a} tool ${a===1?`call`:`calls`}: ${o}`,className:`group flex w-full min-w-0 items-baseline gap-1.5 rounded py-0.5 text-left outline-none transition-colors hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60 ${pZ}`,children:[(0,L.jsx)(`span`,{"data-tool-activity-label":!0,title:o,className:`min-w-0 truncate text-muted`,children:o}),(0,L.jsx)(tm,{"data-tool-activity-chevron":!0,"aria-hidden":`true`,size:13,className:hZ(n)})]}),n&&(0,L.jsx)(`div`,{id:i,className:`mt-1.5 flex flex-col`,children:S0(e.map((e,n)=>(0,L.jsx)(j0,{t:e,startedAt:t},n)),6)}),!n&&(0,L.jsx)(`div`,{id:i,hidden:!0})]})}function A0({tools:e,at:t}){let n=[];for(let t of e){let e=H$(t),r=n[n.length-1];r?.exceptional===e?r.tools.push(t):n.push({exceptional:e,tools:[t]})}return(0,L.jsx)(`div`,{className:`flex flex-col`,children:S0(n.map((e,n)=>e.exceptional?(0,L.jsx)(`div`,{className:`flex flex-col`,children:S0(e.tools.map((e,n)=>(0,L.jsx)(j0,{t:e,startedAt:t},n)),w0(e.tools.map(e=>T0([e])),6))},`exceptions-${n}`):(0,L.jsx)(k0,{tools:e.tools,at:t},`activity-${n}`)),w0(n.map(e=>T0(e.tools)),6))})}function j0({t:e,startedAt:t}){let n=(0,I.useContext)(I1),r=kC(),i=hE(e,(n?Dp(r,n):void 0)?.bgShells??[]);return e.edits&&e.status!==`failed`&&e.status!==`cancelled`?(0,L.jsx)($K,{edits:e.edits,meta:(0,L.jsx)(I0,{status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,durationMs:e.durationMs})}):e.command?(0,L.jsx)(W0,{command:e.command,desc:e.desc??e.detail,output:e.output,status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,sessionId:e.sessionId,durationMs:e.durationMs,startedAt:t}):e.outputImage?(0,L.jsx)(V0,{name:e.name,detail:e.detail,outputImage:e.outputImage,output:e.output,status:e.status,durationMs:e.durationMs}):e.read?(0,L.jsx)(K0,{detail:e.detail,read:e.read,status:e.status,durationMs:e.durationMs}):e.prompt||e.agentId?(0,L.jsx)(J0,{detail:e.detail,prompt:e.prompt,input:e.input,subagentType:e.subagentType,agentId:e.agentId,agentStatus:e.agentStatus,agentElapsedMs:e.agentElapsedMs,status:e.status,durationMs:e.durationMs,output:e.output}):e.sendTo!==void 0||e.sendBody!==void 0?(0,L.jsx)(X0,{to:e.sendTo,summary:e.sendSummary,body:e.sendBody??``,type:e.sendType,dispatchId:e.sendDispatchId,targetLabel:e.sendTargetLabel,status:e.status,durationMs:e.durationMs,at:t}):e.sentImages||e.sentFiles?(0,L.jsx)(H0,{images:e.sentImages??[],files:e.sentFiles??[],caption:e.caption,status:e.status,durationMs:e.durationMs}):e.todos?(0,L.jsx)(Sq,{todos:e.todos,note:e.input,meta:(0,L.jsx)(I0,{status:e.status,durationMs:e.durationMs})}):U$(e)?(0,L.jsx)(M0,{ask:e.ask??[],askAnswers:e.askAnswers}):e.input||e.output?(0,L.jsx)(W0,{name:e.name,command:e.input??``,desc:e.detail,output:e.output,status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,sessionId:e.sessionId,durationMs:e.durationMs,inputLabel:`input`,startedAt:t}):(0,L.jsx)(B0,{name:e.name,detail:e.detail,count:e.count,status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,cwd:e.cwd,sessionId:e.sessionId,durationMs:e.durationMs,startedAt:t})}function M0({ask:e,askAnswers:t}){return(0,L.jsx)(`div`,{"data-settled-ask":!0,className:`flex flex-col gap-1.5`,children:e.map((e,n)=>{let r=ZZ(e,t?.[n]);return(0,L.jsx)(CY,{question:r.question,settled:{chosenIdxs:r.chosenIdxs,text:r.text}},n)})})}function N0({tone:e,indicator:t,label:n,duration:r,title:i}){return(0,L.jsxs)(`span`,{className:`petite-caps frizz-tool-header-caps flex shrink-0 items-center gap-1 whitespace-nowrap text-[11.5px] leading-none ${e}`,title:i,"aria-label":i,children:[t,(0,L.jsx)(`span`,{children:[n,r].filter(Boolean).join(` · `)})]})}function P0(e,t,n){let[r,i]=(0,I.useState)(()=>Date.now()),a=fE(e,t),o=pE(e,t,n,r);return(0,I.useEffect)(()=>{if(!a||o)return;let e=n?Date.parse(n):NaN;if(!Number.isFinite(e))return;let t=setTimeout(()=>i(Date.now()),Math.max(dE-(Date.now()-e),0));return()=>clearTimeout(t)},[a,o,n]),o}function F0({status:e,backgroundState:t,liveBackgroundState:n,startedAt:r}){let i=P0(e,t,r),a=n===`running`?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--shell`,"data-running-indicator":`tool-disclosure`}):n===`stale`?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot-quiet frizz-live-dot-quiet--shell`,"data-running-indicator":`tool-quiet`,title:jE}):uE(e,t)||i?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--shell`,"data-running-indicator":`tool-disclosure`}):null;return a?(0,L.jsx)(`span`,{className:`frizz-tool-mark -mr-1 flex w-[9px] shrink-0 justify-center`,children:a}):null}function I0({status:e,backgroundState:t,liveBackgroundState:n,exitCode:r,durationMs:i}){if(!e&&i===void 0)return null;let[a,o]=n===`running`?[`running`,`background running`]:n===`stale`?[`stale`,`background stale`]:e===`pending`?t===`unknown`?[`unknown`,`background / unknown`]:[`running`,t===`background`?`background running`:`running`]:e===`failed`?r===void 0?[`failed`,`failed`]:[`exit ${r}`,`exit ${r}`]:e===`cancelled`?[`cancelled`,`cancelled`]:e===`completed`?[`done`,`done`]:[void 0,void 0],s=i===void 0?void 0:gE(i),c=[o,s].filter(Boolean).join(` · `);return(0,L.jsx)(N0,{tone:e===`failed`?`frizz-tool-failed`:e===`cancelled`?`text-amber-400`:`text-muted/55`,title:c,label:a,duration:s})}function L0(e,t,n){let r=t?Date.parse(t):NaN,i=e===`pending`&&Number.isFinite(r),[a,o]=(0,I.useState)(()=>Date.now());return(0,I.useEffect)(()=>{if(!i)return;let e=()=>o(Date.now()),t,n=setTimeout(()=>{e(),t=setInterval(e,1e3)},1e3-Date.now()%1e3);return()=>{clearTimeout(n),t&&clearInterval(t)}},[i,t]),i?Math.max(a-r,0):n}function R0(e,t,n){let r=t&&t!==X.board?.projectDir?`in ${O0(t)}`:void 0;return[e,t?r:n!==void 0&&!e?.includes(String(n))?`session ${n}`:void 0].filter(Boolean).join(` · `)||void 0}function z0(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.includes(`…`)}function B0({name:e,detail:t,count:n,status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,cwd:s,sessionId:c,durationMs:l,startedAt:u}){let d=R0(t,s,c),f=d?O0(d):void 0,p=t&&z0(t)?t:void 0;return(0,L.jsx)(`div`,{className:`frizz-bash`,title:d,children:(0,L.jsxs)(`div`,{className:`frizz-bash-header`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(F0,{status:r,backgroundState:i,liveBackgroundState:a,startedAt:u}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:D0(e)}),f&&(p?(0,L.jsx)(`span`,{className:`min-w-0 truncate`,onClick:e=>e.stopPropagation(),children:(0,L.jsx)(ZK,{path:p,className:`text-[11.5px] text-muted`,children:f})}):(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:f}))]}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,L.jsx)(I0,{status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,durationMs:l}),n>1&&(0,L.jsxs)(`span`,{className:`tabular-nums text-[11px] text-muted/45`,children:[`×`,n]})]})]})})}function V0({name:e,detail:t,outputImage:n,output:r,status:i,durationMs:a}){let o=t?O0(t):void 0,s=(0,L.jsxs)(`div`,{className:`frizz-bash-header`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:D0(e)}),o&&(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,title:t,children:o})]}),(0,L.jsx)(`span`,{className:`flex shrink-0 items-center gap-2`,children:(0,L.jsx)(I0,{status:i,durationMs:a})})]});return(0,L.jsxs)(`div`,{children:[(0,L.jsx)(r2,{path:n,hideCaption:!0,altText:o?`${D0(e)}: ${o}`:D0(e),header:s}),r&&(0,L.jsx)(`pre`,{className:`frizz-bash frizz-bash-body frizz-bash-output-body mt-1.5`,children:r})]})}function H0({images:e,files:t,caption:n,status:r,durationMs:i}){let[a,o]=(0,I.useState)(!0),s=(0,I.useId)(),c=[e.length?`${e.length} image${e.length===1?``:`s`}`:``,t.length?`${t.length} file${t.length===1?``:`s`}`:``].filter(Boolean).join(` · `);return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":s,"aria-expanded":a,"aria-label":`${a?`Collapse`:`Expand`} files sent to you${c?`: ${c}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/60`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Sent to you`}),c&&(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:c})]}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,L.jsx)(I0,{status:r,durationMs:i}),(0,L.jsx)(tm,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${a?`rotate-90`:``}`})]})]}),(0,L.jsx)(`div`,{id:s,hidden:!a,children:a&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-2.5 pb-2.5 pt-1.5`,children:[e.map((e,t)=>(0,L.jsx)(r2,{path:e,hideCaption:!0,altText:n??`delivered image`},`i${t}`)),t.length>0&&(0,L.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map((e,t)=>(0,L.jsx)(i2,{path:e},`f${t}`))}),n&&(0,L.jsx)(`div`,{className:`max-w-[65%] text-[12px] leading-snug text-muted`,children:n})]})})]})}var U0=16;function W0({command:e,desc:t,output:n,name:r=`Bash`,status:i,backgroundState:a,liveBackgroundState:o,exitCode:s,sessionId:c,durationMs:l,inputLabel:u,startedAt:d}){let[f,p]=(0,I.useState)(!1),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(!1),v=(0,I.useId)(),y=L0(i,d,l),b=(0,I.useMemo)(()=>e.split(`
314
+ `).length,[e]),x=b>U0,S=(0,I.useMemo)(()=>n?n.split(`
315
+ `).length:0,[n]),C=S>U0,w=R0(t,void 0,c),T=!!(e||n);return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(`button`,{type:`button`,onClick:()=>T&&p(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-controls":T?v:void 0,"aria-expanded":T?f:void 0,"aria-label":`${T?`${f?`Collapse`:`Expand`} `:``}${D0(r)}${w?`: ${w}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-fg/60`,children:[(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(F0,{status:i,backgroundState:a,liveBackgroundState:o,startedAt:d}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:D0(r)}),(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,title:w,children:w??``})]}),(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,L.jsx)(I0,{status:i,backgroundState:a,liveBackgroundState:o,exitCode:s,durationMs:y}),T&&(0,L.jsx)(tm,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${f?`rotate-90`:``}`})]})]}),T&&(0,L.jsxs)(`div`,{id:v,hidden:!f,children:[f&&e&&(0,L.jsxs)(L.Fragment,{children:[u&&(0,L.jsx)(`div`,{className:`frizz-bash-output-label petite-caps`,children:u}),(0,L.jsx)(gq,{text:e,language:u?`plaintext`:`bash`,className:`frizz-bash-body${u?` frizz-bash-output-body`:``}${x&&!m?` frizz-bash-clamp`:``}`}),x&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>h(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:m?`Collapse`:`Show all ${b} lines`})]}),f&&n&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`frizz-bash-output-label petite-caps`,children:`output`}),(0,L.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body${C&&!g?` frizz-bash-clamp`:``}`,children:n}),C&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>_(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:g?`Collapse`:`Show all ${S} lines`})]})]})]})}var G0=16;function K0({detail:e,read:t,status:n,durationMs:r}){let[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(!1),c=(0,I.useId)(),l=(0,I.useMemo)(()=>t.split(`
316
+ `).length,[t]),u=l>G0,d=e?O0(e):void 0,f=e&&z0(e)?e:void 0;return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(XK,{className:`frizz-bash-header`,controls:c,expanded:i,label:`${i?`Collapse`:`Expand`} Read${e?`: ${e}`:``}`,onToggle:()=>a(e=>!e),meta:(0,L.jsx)(I0,{status:n,durationMs:r}),children:[(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Read`}),d&&(f?(0,L.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,L.jsx)(ZK,{path:f,className:`text-[11.5px] text-muted`,children:d})}):(0,L.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:d}))]}),(0,L.jsx)(`div`,{id:c,hidden:!i,children:i&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(gq,{text:t,language:lS(e),className:`frizz-bash-body${u&&!o?` frizz-bash-clamp`:``}`}),u&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:o?`Collapse`:`Show all ${l} lines`})]})})]})}var q0=16;function J0({detail:e,prompt:t,input:n,subagentType:r,agentId:i,agentStatus:a,agentElapsedMs:o,status:s,durationMs:c,output:l}){let[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(!1),m=(0,I.useId)(),h=t??n,g=(0,I.useMemo)(()=>h?h.split(`
317
+ `).length:0,[h]),_=g>q0,v=R1(),y=kC(),b=v?Dp(y,v):void 0,x=!a&&i?(b?.subAgents??[]).find(e=>e.id===i):void 0,S=x?.state===`running`,C=!!(v&&i),w=e??`sub-agent`,T=iZ(r),E=sE(),D=uZ({agentStatus:a,agentElapsedMs:o,liveState:x?.state,liveElapsedMs:x?.startedAt?Math.max(E-Date.parse(x.startedAt),0):void 0,status:s,durationMs:c}),O=S?(0,L.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--agent`,"data-running-indicator":`subagent-disclosure`}):x?.state===`stale`?(0,L.jsx)(`span`,{className:DE,title:OE}):x?.state===`rested`?(0,L.jsx)(`span`,{className:kE,title:AE}):null;function k(){!v||!i||ep(v,i,{label:w,subagentType:r,startedAt:x?.startedAt})}return(0,L.jsxs)(`div`,{className:`frizz-bash`,children:[(0,L.jsxs)(XK,{className:`frizz-bash-header`,controls:m,expanded:u,label:`${u?`Collapse`:`Expand`} Agent dispatch: ${w}`,onToggle:()=>d(e=>!e),meta:(T||D)&&(0,L.jsxs)(L.Fragment,{children:[T&&(0,L.jsx)(`span`,{"data-subagent-profile":!0,className:`petite-caps frizz-tool-header-caps shrink-0 whitespace-nowrap text-[11.5px] leading-none text-muted/55`,title:`Sub-agent profile: ${T}`,children:T}),T&&D&&(0,L.jsx)(`span`,{"aria-hidden":!0,className:`petite-caps frizz-tool-header-caps -mx-[2px] shrink-0 text-[11.5px] leading-none text-muted/55`,children:`·`}),D&&(0,L.jsx)(N0,{tone:D.tone===`failed`?`frizz-tool-failed`:`text-muted/55`,title:D.title,label:D.label,duration:D.duration})]}),children:[O&&(0,L.jsx)(`span`,{className:`frizz-tool-mark -mr-1 flex w-[9px] shrink-0 justify-center`,children:O}),(0,L.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Agent`}),C?(0,L.jsx)(`button`,{type:`button`,"aria-label":`Open sub-agent transcript: ${w}`,title:`Open sub-agent transcript`,onClick:k,className:`min-w-[4rem] flex-1 truncate text-left text-[11.5px] text-muted outline-none hover:underline hover:text-fg/80 focus-visible:underline focus-visible:text-fg/80`,children:w}):(0,L.jsx)(`span`,{className:`min-w-[4rem] flex-1 truncate text-[11.5px] text-muted`,title:w,children:w})]}),(0,L.jsx)(`div`,{id:m,hidden:!u,children:u&&(0,L.jsxs)(L.Fragment,{children:[h&&(0,L.jsx)(`pre`,{className:`frizz-bash-body${_&&!f?` frizz-bash-clamp`:``}`,children:h}),_&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>p(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:f?`Collapse`:`Show all ${g} lines`}),l&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`div`,{className:`frizz-bash-output-label petite-caps`,children:`output`}),(0,L.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body`,children:l})]})]})})]})}function Y0(e,t){return t===`shutdown_request`?`Shutdown`:t===`codex_followup`?`Followed up`:e===`main`?`Reported`:`Steered`}function X0({to:e,summary:t,body:n,type:r,dispatchId:i,targetLabel:a,status:o,durationMs:s,at:c}){return(0,I.useContext)(I1)===null?(0,L.jsx)(Q0,{to:e,summary:t,body:n,type:r,status:o,durationMs:s}):(0,L.jsx)(_2,{to:e,type:r,dispatchId:i,targetLabel:a,at:c})}var Z0=16;function Q0({to:e,summary:t,body:n,type:r,status:i,durationMs:a}){let[o,s]=(0,I.useState)(!t),[c,l]=(0,I.useState)(!1),u=(0,I.useId)(),d=nq(gK(n)),f=(0,I.useMemo)(()=>n.split(`
318
+ `).length,[n]),p=f>Z0,m=!!n.trim(),h=Y0(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)(I0,{status:i,durationMs:a}),m&&(0,L.jsx)(tm,{"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 $0({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)(()=>TL(e,[...i.keys()]),[e,i]).map((e,t)=>{let a=e.token?i.get(e.token):void 0;if(!a)return(0,L.jsx)(uY,{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:vL(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 e2({text:e,rawText:t,queued:n,deliveryUnconfirmed:r,deliveryId:i,sourceId:a}){let o=(0,I.useContext)(I1),s=OY(o),{unqueue:c,pending:l}=MY(o),u=!!(n&&i&&o&&s),d=NY(n?o:null),{deliverNow:f,pending:p}=PY(o),m=!!(n&&o&&d),{prose:h,attachments:g}=(0,I.useMemo)(()=>hL(e),[e]),_=(0,I.useMemo)(()=>ML(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)($0,{body:_.body,items:_.items}):(0,L.jsx)(uY,{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)(Mm,{size:15,strokeWidth:2.2,className:`animate-spin`}):(0,L.jsx)(Jp,{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)(r2,{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)(i2,{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 t2=(0,I.memo)(function({m:e,answering:t,dense:n,paired:r,textOnly:i,showSendButton:a,staleAwaiting:o,shadowedBy:s,thread:c,restingCardShown:l,restedAt:u}){let d=sW(),[f,p]=(0,I.useState)(!1);if(e.providerError)return(0,L.jsx)(dJ,{error:e.providerError});if(e.kind===`event`)return(0,L.jsx)(v2,{text:e.text,boundary:e.boundary,sourceId:e.sourceId,at:e.at});if(e.kind===`reasoning`)return(0,L.jsx)(y2,{text:e.text,sourceId:e.sourceId});let m=aZ(e);if(m)return(0,L.jsx)(h2,{call:m,sourceId:e.sourceId,at:e.at});if(e.role===`user`){let t=FY(e).replace(/\r\n?/g,`
319
+ `),i=r===void 0?_J(t):r;if(i)return(0,L.jsx)(dY,{answers:i,queued:e.queued,sourceId:e.sourceId});let a=e.wake?xl(t):void 0;return a?(0,L.jsx)(rY,{bump:a,sourceId:e.sourceId,at:e.at}):e.wake?(0,L.jsx)(KJ,{steer:e.wakeSteer,text:t,sourceId:e.sourceId,at:e.at,wrap:n}):e.peerFrom?(0,L.jsx)(g2,{from:e.peerFrom,unnamed:e.peerUnnamed,dispatchId:e.peerDispatchId,sourceId:e.sourceId,at:e.at}):(0,L.jsx)(e2,{text:t,rawText:e.text,queued:e.queued,deliveryUnconfirmed:e.deliveryState===`unconfirmed`,deliveryId:e.deliveryId,sourceId:e.sourceId})}let h=[],g=[],_=(e,t=C0)=>{h.push(e),g.push(t)},v={n:-1},y={drawn:!1},b=[],x=(r,i)=>{for(let[a,c]of Kq(r).entries()){if(c.kind===`fence`){if(c.fenceKind===`awaiting`&&(e.fenceRefused||o||l))continue;c.fenceKind===`awaiting`&&(y.drawn=!0),_((0,L.jsx)(c2,{fenceKind:c.fenceKind,body:c.body,hints:c.hints,wrap:n,notAfter:u},`${i}-f${a}`));continue}for(let[e,r]of Eq(c.text).entries()){if(r.kind===`prose`){for(let[t,o]of mL(r.text).entries()){let r=`${i}-${a}-p${e}-${t}`;_(o.kind===`image`?(0,L.jsx)(r2,{path:o.path},r):o.kind===`file`?(0,L.jsx)(i2,{path:o.path},r):o.kind===`visualization`?(0,L.jsx)(s2,{file:o.file},r):o.kind===`directive`?(0,L.jsx)(M1,{directive:o.directive},r):o.kind===`mermaid`?(0,L.jsx)(F1,{source:o.source},r):(0,L.jsx)(n2,{md:o.text,wrap:n},r))}continue}v.n+=1;let o=v.n;if(s&&zJ(r,s)!==void 0||r.registeredId&&r.text.trim()===``)continue;t&&b.push({raw:r.text,kind:r.questionKind,danger:r.danger,bi:o});let c=t&&!d?{answer:t.answerFor(o),onChip:(e,n)=>t.onChip(o,e,n),onText:e=>t.onText(o,e),onSubmit:t.onSubmit}:void 0;_((0,L.jsx)(CY,{raw:r.text,questionKind:r.questionKind,danger:r.danger,interactive:c,wrap:n},`${i}-${a}-q${e}`))}}};if(e.parts&&e.parts.length>0)x0(e.parts).forEach((t,r)=>{if(t.kind===`tools`){if(i)return;let a=E0(t.tools);a.length&&_((0,L.jsx)(A0,{tools:a,dense:n,at:e.at},`t${r}`),T0(a))}else x(t.text,`x${r}`)});else{if(!i){let t=E0(e.tools);t.length>0&&_((0,L.jsx)(A0,{tools:t,dense:n,at:e.at},`tools`),T0(t))}x(e.text,`leg`)}return u!==void 0&&c&&!y.drawn&&!e.fenceRefused&&l$(c,{notAfter:u})&&_((0,L.jsx)(g$,{thread:c,notAfter:u},`rested-on`)),h.length===0?null:(a&&t&&d&&b.length>0?_((0,L.jsx)(`div`,{className:`flex justify-start`,children:(0,L.jsx)(`button`,{type:`button`,"data-mobile-answer-open":!0,onClick:()=>p(!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:b.length>1?`Answer ${b.length} questions`:`Answer`})},`answer-open`)):a&&t&&b.length>0&&_((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:[S0(h,w0(g,14)),f&&t&&b.length>0?(0,L.jsx)(DY,{blocks:b,answering:t,onClose:()=>p(!1)}):null]}))});function n2({md:e,wrap:t}){let n=gK(e),r=nq(n),i=(0,I.useRef)(null);return mq(i,n),n?(0,L.jsx)(`div`,{ref:i,className:`md-body${t?` ${Jq}`:``}`,dangerouslySetInnerHTML:r}):null}function r2({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=e.split(`/`).filter(Boolean).pop()||e;return(0,L.jsx)(FG,{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:jS(e),alt:n??o,"data-local-path":e,"data-local-image":`true`,onError:()=>a(!0),className:`cursor-pointer ${RG}`})})}function i2({path:e}){let t=e.split(`/`).filter(Boolean).pop()||e;return(0,L.jsxs)(`button`,{type:`button`,className:`local-file-action inline-flex max-w-full items-center gap-1.5 ${Yq} 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)(gm,{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 a2={"--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 o2(){let e=getComputedStyle(document.documentElement),t=Object.fromEntries(Object.entries(a2).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 s2({file:e}){let t=(0,I.useContext)(I1),n=(0,I.useRef)(null),[r,i]=(0,I.useState)(360),[a,o]=(0,I.useState)(null),s=t?`${Nd()}/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:`${Yq} 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 ${Yq} 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(o2(),`*`),className:`block w-full border-0 bg-transparent`,style:{height:r}})}function c2({fenceKind:e,body:t,hints:n,wrap:r,notAfter:i}){let a=gK(t),o=(0,I.useContext)(I1),s=(0,I.useContext)(z1),c=kC(),l=o?Dp(c,o):void 0,u=l?SX(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)(nJ,{icon:Qp,label:`Done`,children:[a&&(0,L.jsx)(hq,{className:`md-body${r?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:a}),p&&(0,L.jsx)(iJ,{children:(0,L.jsx)(QX,{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&&p$(l)?null:(0,L.jsx)(g$,{thread:l,fence:{body:t,hints:n},notAfter:i})}function l2({slug:e,sessionId:t,fault:n,retryText:r}){let[i,a]=(0,I.useState)(!1),[o,s]=(0,I.useState)(!1),c=Ve(),l=DR[n.backend],u=t=>{s(!0),wH(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)(nJ,{"data-provider-fault":!0,tone:`danger`,icon:km,label:`${l} sign-in required`,children:[(0,L.jsx)(`span`,{className:rJ,children:`The provider rejected this session's credential. Sign in, then retry.`}),(0,L.jsxs)(iJ,{children:[r?.trim()&&(0,L.jsx)(`button`,{onClick:()=>u(r),disabled:o,onMouseDown:e=>e.preventDefault(),className:`shrink-0 rounded-md border border-border px-2 py-1 text-[11px] text-fg/90 transition-colors hover:bg-panel hover:border-border-strong disabled:opacity-60`,children:`Retry`}),(0,L.jsx)(`button`,{onClick:()=>a(!0),onMouseDown:e=>e.preventDefault(),className:sJ,children:`Sign in`})]}),i&&(0,L.jsx)(AR,{backend:n.backend,onClose:()=>a(!1),onAuthed:()=>a(!1)})]})}function u2({slug:e,sessionId:t,pause:n}){let r=DR[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)(nJ,{"data-limit-pause":!0,tone:`caution`,icon:Tm,label:`Paused by the ${r} ${i}`,children:[(0,L.jsx)(`span`,{className:rJ,children:n.autoResume?n.resumesAt?`Continuing automatically at ${QT(n.resumesAt)}.`:`Continuing automatically once the window resets.`:`Continue it whenever you have capacity again.`}),(0,L.jsx)(iJ,{children:(0,L.jsx)(`button`,{onClick:()=>{o(!0),wH(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 ${sJ}`,children:`Continue now`})})]})}function d2({onTerminal:e}){return(0,L.jsxs)(nJ,{tone:`attention`,icon:km,label:`Permission approval`,children:[(0,L.jsx)(`span`,{className:rJ,children:`The agent is waiting on your approval — respond in your external terminal.`}),(0,L.jsx)(iJ,{children:(0,L.jsx)(`button`,{onClick:()=>e(),onMouseDown:e=>e.preventDefault(),className:sJ,children:`Copy terminal command`})})]})}function f2({policy:e,denies:t}){let n=[e.tool,e.command].filter(Boolean).join(`: `);return(0,L.jsxs)(nJ,{tone:`caution`,icon:rh,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:rJ,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 p2({slug:e,className:t=`px-4 pb-2 pt-1`,includeAgents:n=!0,transcriptShells:r=[],parentAgentId:i}){let a=Dp(kC(),e),o=a?.subAgents??[],s=n?i?zE(o,i):o:[],c=i?[...r]:UE(a?.bgShells??[],r),l=i?[]:(a?.watches??[]).filter(e=>e.kind===`github`),u=s.length+c.length+l.length,d=new Set((a?.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`).map(e=>e.target)),f=e=>d.has(e.taskId??``)||d.has(e.id??``)||d.has(e.label),[,p]=(0,I.useState)(0);(0,I.useEffect)(()=>{if(u===0)return;let e=setInterval(()=>p(e=>e+1),3e4);return()=>clearInterval(e)},[u]);let m=KC(e,c.flatMap(e=>e.id&&!e.outputUnavailable?[e.id]:[]));return u===0?null:(0,L.jsxs)(`div`,{className:`flex flex-col gap-0.5 ${t}`,"data-background-ops":!0,children:[VE(s,`sheet`).map((t,n)=>(0,L.jsx)(WE,{kind:`AGENT`,label:t.label,state:t.state,density:`sheet`,depth:t.displayDepth??t.depth,startedAt:t.startedAt,onOpen:t.id?()=>ep(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:Vj(e,t)},`a${n}`)),VE(c,`sheet`).map((t,n)=>(0,L.jsx)(WE,{kind:`SHELL`,label:t.label,state:t.state,density:`sheet`,startedAt:t.startedAt,counter:t.id?NE(m.get(t.id)):void 0,counterTitle:`Lines of output so far — open the row to read them`,onOpen:t.id&&!t.outputUnavailable?()=>tp(e,t.id,{label:t.label,startedAt:t.startedAt}):void 0,onDismiss:Vj(e,t,`SHELL`),title:f(t)?`${t.label}\nWatched — this thread wakes when it finishes`:void 0},`s${n}`)),l.map(e=>(0,L.jsx)(WE,{kind:`GITHUB`,label:e.target,state:`running`,density:`sheet`,startedAt:e.createdAt,counter:PE(e.github),counterTone:e.github?.checks===`failing`?`danger`:void 0,counterTitle:e.github?`${e.target} — ${GQ(e.github)}`:void 0,onOpen:()=>window.open(DH(e.target)??`https://github.com/${e.target.replace(`#`,`/pull/`)}`,`_blank`,`noreferrer,noopener`)},e.id))]})}function m2({ask:e,onTerminal:t}){return(0,L.jsxs)(nJ,{tone:`attention`,icon:cm,label:`Waiting on your answer — in your external terminal`,children:[(0,L.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.header&&(0,L.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted/55`,children:e.header}),(0,L.jsx)(`div`,{className:`min-w-0 text-[12px] font-medium leading-5 text-fg`,children:e.question}),e.options.length>0&&(0,L.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.options.map((e,t)=>(0,L.jsxs)(`div`,{className:`rounded-md border border-border bg-elevated px-3 py-1.5 text-[12px] text-fg/80`,children:[(0,L.jsx)(`span`,{className:`font-medium text-fg/90`,children:e.label}),e.description&&(0,L.jsxs)(`span`,{className:`text-muted/70`,children:[` — `,e.description]})]},t)),e.multiSelect&&(0,L.jsx)(`div`,{className:`text-[10px] text-muted/50`,children:`select one or more`})]})]},t))}),(0,L.jsx)(iJ,{children:(0,L.jsxs)(`button`,{onClick:()=>t(),onMouseDown:e=>e.preventDefault(),className:sJ,children:[(0,L.jsx)(km,{size:12,className:`shrink-0 ${BY}`}),`Copy terminal command`]})})]})}function h2({call:e,sourceId:t,at:n}){let r=R1(),i=e.detail??`sub-agent`,{tail:a}=sZ(e),o=!!(r&&e.agentId);return(0,L.jsxs)(VJ,{icon:Xp,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:ME.AGENT,"aria-label":`${ME.AGENT}: ${i}`,onClick:()=>ep(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 g2({from:e,unnamed:t,dispatchId:n,sourceId:r,at:i}){let a=R1(),o=!!(a&&n),s=t?void 0:e,c=t&&e?`${ME.AGENT} — ${e}`:ME.AGENT;return s===void 0?(0,L.jsx)(VJ,{icon:Xp,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":`${ME.AGENT}${e?`: ${e}`:``}`,onClick:()=>ep(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)(VJ,{icon:Xp,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:ME.AGENT,"aria-label":`${ME.AGENT}: ${s}`,onClick:()=>ep(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 _2({to:e,type:t,dispatchId:n,targetLabel:r,sourceId:i,at:a}){let o=R1(),s=Y0(e,t),c=e===`main`?void 0:r??e,l=!!(o&&n);return(0,L.jsxs)(VJ,{icon:Xp,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:ME.AGENT,"aria-label":`${ME.AGENT}: ${c}`,onClick:()=>ep(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 v2({text:e,boundary:t,sourceId:n,at:r}){return t?(0,L.jsx)(VJ,{icon:t===`wake`?eh: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:pZ,children:e})}function y2({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:`${pZ} 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)(tm,{"aria-hidden":`true`,size:13,className:hZ(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)(n2,{md:e,wrap:!0})})]})}function b2(){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 x2({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=yE(Math.max(0,o-a)),f=(0,I.useMemo)(()=>E0([...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 ${pZ}`,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??v1(p)}),m&&(0,L.jsx)(tm,{"data-working-chevron":!0,"aria-hidden":`true`,size:13,className:hZ(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:S0(f.map((e,t)=>(0,L.jsx)(j0,{t:e,startedAt:r?.at},t)),6)}),m&&!c&&(0,L.jsx)(`div`,{id:u,hidden:!0})]})}function S2(){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 C2({id:e,slug:t,depth:n,widthDepth:r,initiallyOpen:i}){let{shown:a,close:o,closingRef:s}=Np(e,i===!0),[c,l]=(0,I.useState)(i===!0),u=(0,I.useRef)(null),d=(0,I.useRef)(null),f=Zt(X),p=[...f.drawers].reverse().find(e=>!e.closing)?.id===e,m=S2(),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 _=kC(),v=Sd(_,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 lW({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)(()=>(hd(e,()=>{(u.current?.querySelector(`[data-dialog-initial-focus]`)??u.current)?.focus({preventScroll:!0})}),()=>hd(e,null)),[e]),(0,L.jsx)(PI,{modal:m,open:!0,onOpenChange:e=>{e||o()},children:(0,L.jsxs)(BI,{children:[(0,L.jsx)(HI,{className:`${Op} ${a?`opacity-100`:`opacity-0`}`,style:{zIndex:50+n*2}}),(0,L.jsxs)(KI,{ref:u,"aria-modal":m||void 0,"aria-describedby":void 0,tabIndex:-1,onEscapeKeyDown:t=>{if(X.drawers.at(-1)?.id!==e){t.preventDefault();return}xR(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 ${kp} ${a?`translate-x-0`:`translate-x-full`}`,style:{zIndex:51+n*2,width:jp(r),viewTransitionName:f.vtReturnTarget===t?`thread-chat`:void 0},children:[(0,L.jsx)(ZI,{className:`sr-only`,children:v.kind===`found`?`Thread: ${aT(v.thread)}`:`Thread: ${t}`}),c&&v.kind===`found`?(0,L.jsx)(U1,{slug:t,onStatusApplied:o,onClose:o,virtualized:!0}):c&&v.kind===`missing`?(0,L.jsx)(w2,{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 w2({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 ${oh} 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 T2({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=WC(t,n),f=AC(),p=(0,I.useMemo)(()=>d.data?.messages??[],[d.data]),m=d.data?.state,h=m===`running`,g=(0,I.useMemo)(()=>V1(p),[p]),_=(0,I.useMemo)(()=>H1(p),[p]),v=(0,I.useMemo)(()=>e1(_),[_]),y=h?r1(v):void 0,b=h?n1(v):void 0,x=b?p1(b,f):void 0,S=h?a1(v):void 0,C=(0,I.useMemo)(()=>h?c1(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)(Lp,{id:e,depth:o,widthDepth:s,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(sh,{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)(L1.Provider,{value:t,children:(0,L.jsxs)(`div`,{"data-transcript-column":!0,className:`flex flex-col px-6 py-5`,children:[b0(C.map(e=>e.message),(e,t)=>(0,L.jsx)(t2,{m:e},t)),w&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(BJ,{h:y0(C.map(e=>e.message))}),(0,L.jsx)(x2,{since:a,startedAt:S,activityLabel:x,run:y})]})]})})}),(0,L.jsx)(E2,{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)(p2,{slug:t,parentAgentId:n,transcriptShells:g,className:e})})]})})}function E2({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)(D2,{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)(XL,{value:c,onChange:l,onSubmit:h,surface:`subAgentComposer`,placeholder:`Steer this sub-agent…`,busy:u||f,footer:(0,L.jsx)(D2,{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)(D2,{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 D2({subagentType:e}){let t=rZ(e);return(0,L.jsx)(`span`,{"data-subagent-profile":!0,"aria-label":`Sub-agent profile: ${t}`,title:e?.trim()||`The provider did not report this sub-agent's model and effort`,className:`inline-flex min-w-0 max-w-[min(72%,20rem)] items-center rounded-md border border-border/50 bg-transparent px-1.5 py-0.5 text-muted ${tR}`,children:(0,L.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 truncate`,children:t})})}var O2=`font-mono-keep overflow-x-auto whitespace-pre-wrap break-words ${Yq} border border-border bg-bg/75 px-4 py-2.5 text-[12px] leading-relaxed text-fg/85`;function k2({id:e,slug:t,shellId:n,label:r,startedAt:i,depth:a,widthDepth:o}){let s=(0,I.useRef)(null),c=GC(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=CE(i),g=l===`running`?`running${h?` ${h}`:``}`:l===`done`?`finished`:l===`gone`?`unavailable`:``,_=c.isError||l===`gone`;function v(){f||(p(!0),Y.subAgentStop({slug:t,id:n}).then(({note:e})=>{e?Z(`Background shell stopped. ${e}`,{duration:7e3}):Z(`Background shell stopped — the worker was told`),m.invalidateQueries({queryKey:[`backgroundShellOutput`,t,n]})}).catch(e=>{Z(e instanceof Error?e.message:`Could not stop this background shell`)}).finally(()=>p(!1)))}async function y(){if(u)try{await wR(u),Z(`Command copied`)}catch{Z(`Could not copy command`)}}return(0,L.jsx)(Lp,{id:e,depth:a,widthDepth:o,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(sh,{title:r,icon:(0,L.jsx)(eh,{"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)(fm,{"aria-hidden":!0,size:11}),` Copy`]})]}),u?(0,L.jsx)(gq,{"data-background-shell-command":!0,text:u,language:`bash`,className:O2}):(0,L.jsx)(`pre`,{"data-background-shell-command":!0,className:O2,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 ${Yq} 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 ${Yq} 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 A2(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 j2={paddingBottom:`max(0.75rem, env(safe-area-inset-bottom))`};function M2({path:e}){return(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{Y.openLocalFile({path:e}).then(async e=>{e.action===`copy`&&(await wR(e.path),Z(`Copied local path`))}).catch(e=>Z(`Could not open local file: ${e.message.slice(0,100)}`))},onMouseDown:e=>e.preventDefault(),className:`flex items-center gap-1.5 rounded-md border border-border-strong bg-panel-2/60 px-2.5 py-1 text-[12px] font-medium text-fg/80 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-fg/60`,title:`Open ${e} outside Frizz`,"aria-label":`Open`,children:[(0,L.jsx)(mm,{size:12,"aria-hidden":`true`}),` Open`]})}function N2({source:e}){return(0,L.jsx)(gq,{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 P2({id:e,path:t,title:n,depth:r,widthDepth:i}){let a=MC(t),o=nt({...zS(t),refetchInterval:a?!1:BS}),s=o.data?.path??t,{front:c,body:l}=A2(o.data?.markdown??``),u=gK(l,{baseDir:LS(s),asDocument:!0}),d=nq(u),f=(0,I.useRef)(null);return mq(f,u),(0,L.jsx)(Lp,{id:e,depth:r,widthDepth:i,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(sh,{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)(N2,{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:j2,children:(0,L.jsx)(M2,{path:s})})]})})}function F2({id:e,slug:t,title:n,depth:r,widthDepth:i}){let a=nt({queryKey:[`threadBody`,t],queryFn:()=>Y.threadBody({slug:t})}),o=Zt(X);(0,I.useEffect)(()=>{a.refetch()},[o.board]);let s=HY(Dp(o.board,t)),c=cz(),l=sz.adopt(c,t),[u,d,f]=uz(l),p=it({mutationFn:async e=>{await Y.adoptThread({slug:t,message:e.trim()||void 0})},onSuccess:()=>{X.drawers.find(t=>t.id===e)?.closing||(X.drawers=X.drawers.map(t=>t.id===e?{...t,kind:`thread`}:t))},onError:(e,t)=>{az.get(l)||d(t),Z(`Start failed: ${e.message.slice(0,80)}`)}}),m=gK(rK(a.data?.markdown??``)),h=nq(m);return(0,L.jsx)(Lp,{id:e,depth:r,widthDepth:i,widthOffset:1,subagentParent:t,children:e=>(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(sh,{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)(XL,{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 I2(){let e=Zt(X),t=kC();(0,I.useEffect)(()=>{function e(e){if(e.key===`Escape`&&!(e.target instanceof Element&&e.target.closest(`.xterm`))){if(bR()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(X.showPalette)X.showPalette=!1;else if(X.showNewThread)X.showNewThread=!1;else if(X.showGithubPicker)Kf();else if(X.showSettings)ud()||(X.showSettings=!1);else if(X.drawers.length>0){let e=X.drawers[X.drawers.length-1];md(e.id)||X.drawers.pop()}else X.filePanel&&pp()}}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)(C2,{id:e.id,slug:e.slug,depth:r,widthDepth:i,initiallyOpen:e.routed},e.id):e.kind===`subagent`?(0,L.jsx)(T2,{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)(k2,{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)(P2,{id:e.id,path:e.path??e.slug,title:e.label??e.slug,depth:r,widthDepth:i},e.id):(0,L.jsx)(F2,{id:e.id,slug:e.slug,depth:r,widthDepth:i,title:(()=>{let n=Dp(t,e.slug);return n?aT(n):e.slug})()},e.id);return(0,L.jsx)(lh,{label:`this drawer`,resetKeys:[e.kind,e.slug,e.subId,e.path],fallback:(t,n)=>(0,L.jsx)(mh,{id:e.id,depth:r,widthDepth:i,error:t,onRetry:n}),children:a},e.id)})})}function L2(e){return(e.tools??[]).some(e=>e.name===`mcp__frizz__done`&&e.status===`completed`)}function R2(e){let t=Eq(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 z2(e){let t=new Map,n=[];for(let r=0;r<e.length;r++){let i=R2(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 B2(e,t,n){return kq(e.text)?!n.has(t):L2(e)?!0:e.wake===!0}function V2(e){return e.wake===!0}function H2(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 U2(e){return e.open<0||e.tools<1&&e.steps<1?!1:e.resumed||e.open!==e.close}function W2(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 G2(e){return VE(e,`card`).length>0}function K2({slug:e,subAgents:t,className:n=`px-1 pt-1.5`}){let r=VE(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)(WE,{kind:`AGENT`,label:t.label,state:t.state,density:`card`,depth:t.depth,startedAt:t.startedAt,parentSlug:e,onOpen:t.id?()=>ep(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:Vj(e,t)},t.id??`${t.startedAt}-${n}`))})}var q2=320;function J2(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 Y2(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 X2=0,Z2=``;function Q2(){X2++===0&&(Z2=document.documentElement.style.overflowAnchor,document.documentElement.style.overflowAnchor=`none`)}function $2(){X2>0&&--X2===0&&(document.documentElement.style.overflowAnchor=Z2)}function e4({thread:e,onSnooze:t,onSnoozeFailed:n}){return(0,L.jsx)(g$,{thread:e,onSnooze:t,onSnoozeFailed:n})}function t4(){let e=kC(),t=yT(jC(e?.threads??[]).filter(bT),Zt(tT).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=uH(),b=e=>v(e.id)||lH(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=Y2(e);h.current=t?{kind:`top`,slug:t}:null}else{let t=J2(e);h.current=t?{kind:`hold`,...t}:null}f.current.add(e),d.current.delete(e),_(e=>e+1)},q2);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}Q2();let n=()=>{let t=Uf(e.slug);t!==null&&Math.abs(_d()-t)>.5&&window.scrollTo({top:t,left:0,behavior:`auto`})};n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n(),$2()})})},[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)(n4,{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)(i4,{slug:e.id,leaving:v(e.id),children:(0,L.jsx)(s4,{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)(rH,{}),(0,L.jsx)(fz,{autoFocus:!0})]}):x.length===0?(0,L.jsxs)(`div`,{className:`flex flex-col items-center gap-2 pt-2`,children:[(0,L.jsx)(Om,{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 n4({board:e}){let t=e?.errorItems??[],n=e?.errors??[];return t.length===0&&n.length===0?null:(0,L.jsxs)(`div`,{className:`mb-6 ${Yq} 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)(r4,{file:e.file})]},t)):n.slice(0,3).map((e,t)=>(0,L.jsx)(`div`,{className:`truncate`,title:e,children:e},t))]})}function r4({file:e}){let t=it({mutationFn:()=>Y.repairThread({file:e}),onSuccess:({slug:e})=>Z(`Repaired ${e} — verify its status`),onError:e=>Z(e instanceof Error?e.message:`Repair failed`)});return(0,L.jsx)(`button`,{onClick:()=>t.mutate(),disabled:t.isPending,className:`shrink-0 rounded border border-amber-400/50 bg-amber-500/10 px-2 py-0.5 text-[11px] font-medium text-amber-100 transition-colors hover:bg-amber-500/25 disabled:opacity-50`,title:`Prepend minimal frontmatter (title + status: active) so this thread becomes visible again`,children:t.isPending?`Repairing…`:`Repair`})}function i4({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 a4({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)(VJ,{icon:rm,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 o4({toolCount:e,onExpand:t}){let n=e>0?`${e} tool call${e===1?``:`s`}`:``;return(0,L.jsxs)(VJ,{icon:rm,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 s4=(0,I.memo)(function({thread:e,leaving:t,frozen:n,onResolve:r,onUnresolve:i}){let a=Zt(X),[o,s]=(0,I.useState)(!1),[c,l]=(0,I.useState)(!1),[u,d]=(0,I.useState)(!1),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(!1),[g,_]=(0,I.useState)(0),v=(0,I.useRef)(null),y=(0,I.useRef)(null),b=(0,I.useRef)(!1),x=(0,I.useRef)(!1),S=(0,I.useRef)(null),C=Ve(),w=A$(e.id),T=UC(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)(()=>h0(A),[A]),M=e=>j>=0&&e<j,N=p$(e),P=e=>M(e)||e===j&&N,ee=(0,I.useMemo)(()=>EJ(A),[A]),F=(0,I.useMemo)(()=>LY(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`||m0(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)(()=>z2(A),[A]),ie=(0,I.useMemo)(()=>A.map((e,t)=>{if(!e||e.queued||m0(e,P(t)))return{skip:!0};if(e.boundary===`rest`)return{skip:!0,closes:!0};let n=aZ(e),r=n?0:e.tools.length;return{text:v0(e,P(t)),tools:r,countable:v0(e,P(t))||r>0||n!==void 0||e.kind!==void 0,survives:B2(e,t,re),opens:V2(e),completion:e.boundary===`wake`||n!==void 0}}),[A,re]),ae=(0,I.useMemo)(()=>H2(ie,F+1),[ie,F]),{kept:oe,middle:se}=(0,I.useMemo)(()=>W2(ae),[ae]),ce=(0,I.useMemo)(()=>oe.filter(U2),[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=ux(A,f,F),fe=(0,I.useMemo)(()=>A.slice(de),[A,de]),pe=(0,I.useMemo)(()=>e1(fe).map(e=>({...e,messageIndex:e.messageIndex+de})),[fe,de]),me=(0,I.useMemo)(()=>{let t=[],n=new Map,r=A.length-1,i=e.runtime!==`running`&&e.runtime!==`spawning`;for(let[a,o]of AJ(A,e?.questions??[],{atRest:i})){if(a>=r){t.push(...o);continue}let e=n.get(a);e?e.push(...o):n.set(a,[...o])}return{byAnchor:n,tail:t}},[A,e.runtime,e?.questions]),he=(0,I.useMemo)(()=>NJ(A,e?.questions??[]),[A,e?.questions]),ge=(0,I.useMemo)(()=>xJ(A,e.answersInFlight),[A,e.answersInFlight]),_e=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=()=>{_x(t,e.anchor,e=>{e!==0&&window.scrollBy({top:e,left:0,behavior:`auto`})});let n=0;return _x(t,e.anchor,e=>{n=e}),n},r=n();if(vx({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,$2())})}))},[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,$2()))},[D?.transcriptKey]),(0,I.useEffect)(()=>()=>{b.current&&(b.current=!1,$2())},[]);let ve=e=>{let t=hx(v.current);!e||!t||(b.current||(b.current=!0,Q2()),y.current={anchor:t,targetStartId:e})},ye=async()=>{if(m||!_e)return;let t=lx(A,de),n=t!==null&&A[t]?.role===`user`?t:null;if(n!==null){let e=A[n].sourceId;ve(e),p(e??null);return}let r=D?.beforeCursor;if(!r){if(de>0){let e=A[0]?.sourceId;ve(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;ve(a);let o=mx(n,t);C.setQueryData([`transcript`,e.id],o),p(a??null)}catch(e){await T.refetch(),p(null),Z(e instanceof Error?e.message:`Could not load earlier transcript history`)}finally{h(!1)}}},be=it({mutationFn:()=>Y.markComplete({slug:e.id})}),{answeringForMessage:xe,answerable:Se,anyAnswered:Ce,sendAnswers:we,sendMessage:Te}=yY(e.id,A,()=>{document.activeElement?.blur(),r(e.id)},{scrollToBottom:!1,onSendFailed:()=>i(e.id)}),Ee=(0,I.useMemo)(()=>{let e=_Y(A);return e!==-1&&RJ(A[e].text,he.get(e)??[])},[A,he]),De=Se&&!Ee||Ce,Oe=(0,I.useCallback)(()=>r(e.id),[r,e.id]),ke=(0,I.useCallback)(()=>i(e.id),[i,e.id]),Ae=(0,I.useMemo)(()=>({dismiss:Oe,cancel:ke}),[Oe,ke]);return(0,L.jsx)(I1.Provider,{value:e.id,children:(0,L.jsx)(z1.Provider,{value:Ae,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(!Ce)return;let t=e.target;t instanceof HTMLButtonElement||t instanceof HTMLAnchorElement||t instanceof HTMLTextAreaElement&&t.value.trim()||IL({key:e.key,altKey:e.altKey,ctrlKey:e.ctrlKey,metaKey:e.metaKey,shiftKey:e.shiftKey,isComposing:e.nativeEvent.isComposing,keyCode:e.nativeEvent.keyCode})&&(e.preventDefault(),we())},"data-vt-chat":!0,className:`flex flex-col min-w-0 max-w-full ${Yq} 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?Yq:`${Xq} border-b border-border/60`}`,children:[(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsxs)(`div`,{className:`group/thread-title flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(`div`,{className:`min-w-0 shrink truncate font-semibold text-[15px] leading-snug`,title:aT(e),children:aT(e)}),(0,L.jsx)(eZ,{thread:e})]}),(0,L.jsx)(x$,{at:gT(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)(j$,{slug:e.id}),(0,L.jsx)(yX,{thread:e,collapsed:o,onCollapse:()=>s(e=>!e),expand:!0,onDone:()=>be.mutate(void 0,{onSuccess:()=>r(e.id),onError:()=>d(!1)}),doneBusy:be.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 ${De?`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:[_e&&(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 ye(),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=[...me.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)(BJ,{h:14},`qa-space-${t}`)),n.push((0,L.jsx)(wQ,{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||m0(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)(BJ,{h:14},`middle-runs-space`)),n.push((0,L.jsx)(a4,{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&&!kq(t.text)&&!L2(t)&&B2(t,i,re);if(d!==void 0&&i===d.waker){r!==null&&n.push((0,L.jsx)(BJ,{h:r&&c0(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)(t2,{m:t,dense:!0})},e)),r=s0(t);return}if(f&&!h){if(!p&&!m&&!B2(t,i,re)||(!p&&u!==void 0&&!o.has(u)&&(r!==null&&n.push((0,L.jsx)(BJ,{h:14},`im-space-${u}`)),n.push((0,L.jsx)(o4,{toolCount:d.tools,onExpand:()=>l(!0)},`intermediate-summary-${u}`)),r=!1,o.add(u)),!v0(t,P(i))))return;r!==null&&n.push((0,L.jsx)(BJ,{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)(t2,{m:t,dense:!0,textOnly:!0,answering:xe(t),paired:ee[i],staleAwaiting:M(i),restingCardShown:i===j&&N,shadowedBy:he.get(i),thread:e})},s)),r=!1,a(i);return}r!==null&&n.push((0,L.jsx)(BJ,{h:r&&c0(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)(t2,{m:t,dense:!0,staleAwaiting:M(i),restingCardShown:i===j&&N,answering:xe(t),paired:ee[i],shadowedBy:he.get(i),thread:e})},g)),r=s0(t),a(i)}),fe.forEach((e,r)=>{e.queued&&(n.push((0,L.jsx)(BJ,{},`qs${r}`)),n.push((0,L.jsx)(t2,{m:e,dense:!0,paired:ee[t+r]},`q${t+r}`)))}),n})()]}),!T.isLoading&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(tQ,{thread:e,className:`mt-4`}),e.pendingInteraction?null:e.pendingAsk?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(m2,{ask:e.pendingAsk,onTerminal:w})}):e.runtime===`perm-prompt`?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(d2,{onTerminal:w})}):null,e.permPolicy?(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(f2,{policy:e.permPolicy,denies:e.permDenies})}):null]}),!T.isLoading&&p$(e)&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(e4,{thread:e,onSnooze:Oe,onSnoozeFailed:ke})}),!T.isLoading&&qq(e,j>=0?A[j]?.text:void 0)&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(BJ,{}),(0,L.jsx)(c2,{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)(u2,{slug:e.id,sessionId:e.sessionId,pause:e.limitPause})}),!T.isLoading&&cJ(e,j>=0?A[j]?.text:void 0)&&(0,L.jsx)(`div`,{className:`mt-4`,children:(0,L.jsx)(lJ,{thread:e})})]}),(0,L.jsx)(wQ,{thread:e,questions:me.tail,inFlight:ge,className:`shrink-0 px-5 pb-4 pt-0`}),De&&(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:!Ce,onClick:()=>we(),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)(fX,{slug:e.id,surface:`queueComposer`,className:`shrink-0 px-5 pb-3 pt-0`,placeholder:Se||(e.questions?.length??0)>0?`Or skip the questions and reply…`:`Reply to the agent…`,submitOverride:Te,ops:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(K2,{slug:e.id,subAgents:e.subAgents??[],className:`px-1 pt-1.5`}),(0,L.jsx)(p2,{slug:e.id,includeAgents:!1,className:`px-1 ${G2(e.subAgents??[])?`pt-0.5`:`pt-1.5`}`})]})})]})]}),(0,L.jsx)(YX,{thread:e,onArchived:()=>r(e.id),onDismissCancel:()=>i(e.id),onSnoozed:()=>r(e.id)})]})})})},c4);function c4(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 l4(e,t){if(e.backend===`claude`)return IR.some(t=>t.value===e.model)?VR(e.model).includes(e.effort)?void 0:`Reasoning level ${e.effort} is not available for ${e.model}`:`Claude model ${e.model} is no longer available`;let n=t.find(t=>t.slug===e.model);if(!n)return`Codex model ${e.model} is no longer available`;if(!n.efforts.includes(e.effort))return`Reasoning level ${e.effort} is not available for ${e.model}`}function u4(e,t){return{items:t.map(e=>({...e})),backend:e.backend,model:e.model,effort:e.effort}}function d4({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 f4=30;function p4({onClose:e}){let t=QL(),{resolved:n,codexList:r,loadError:i,saveProfile:a}=YR(),[o,s]=(0,I.useState)(`issues`),[c,l]=(0,I.useState)(`recent`),[u,d]=(0,I.useState)(1),[f,p]=(0,I.useState)(()=>new Set),[m,h]=(0,I.useState)(null),g=nt({queryKey:[`githubList`,o,c,u],queryFn:()=>Y.githubList({kind:o,sort:c,page:u,perPage:f4}),placeholderData:ee}),_=g.data?.items??[],v=g.data?.page??u,y=g.data?.pageCount??1,b=g.data?.total??0,x=(0,I.useRef)(null);(0,I.useEffect)(()=>{x.current&&(x.current.scrollTop=0)},[u,o,c]);let S=it({mutationFn:e=>Y.githubDispatchBatch(e),onMutate:e=>Z(`Starting ${e.items.length} thread${e.items.length===1?``:`s`}…`,{spinner:!0,sticky:!0}),onSuccess:t=>{let n=t.dispatched.length,r=t.failed.length;Z(`Started ${n} thread${n===1?``:`s`}${r?` (${r} failed)`:``}`),e()},onError:e=>Z(`Dispatch failed: ${e.message.slice(0,80)}`)});function C(e){e!==o&&(s(e),d(1),p(new Set),h(null))}function w(e){e!==c&&(l(e),d(1),p(new Set),h(null))}function T(e,t){let n=d4({keys:_.map(e=>e.number),key:e,shiftKey:t,anchor:m,selected:f});p(n.selected),h(n.anchor)}function E(){p(new Set),h(null)}let D=t.data?.nameWithOwner??`this repo`,O=f.size,k=(0,I.useMemo)(()=>qR(r),[r]),A=n?{backend:n.backend,model:n.model,effort:n.effort}:void 0,j=A?l4(A,r):i?`Could not load the model catalogue — reopen once it loads`:void 0,M=j??(A?void 0:`Loading the model catalogue…`);function N(){if(!A||M){Z(M??`Choose a model and reasoning level`);return}S.mutate(u4(A,[...f].map(e=>({kind:o===`issues`?`issue`:`pr`,number:e}))))}return(0,L.jsx)(mz,{onClose:e,children:(0,L.jsxs)(`div`,{className:`flex max-h-[85vh] w-[720px] max-w-[90vw] flex-col rounded-xl border border-border bg-panel p-5 shadow-2xl shadow-black/50`,onKeyDownCapture:t=>{t.key===`Escape`&&(t.stopPropagation(),e())},children:[(0,L.jsxs)(`h2`,{className:`mb-4 flex items-center gap-2 text-[14px] font-medium`,children:[(0,L.jsx)(wm,{size:15,className:`text-muted`}),(0,L.jsx)(`span`,{children:`Investigate this issue and make recommendations`}),(0,L.jsx)(`span`,{className:`text-muted/40`,children:`—`}),(0,L.jsx)(`span`,{className:`font-mono-keep text-[12.5px] text-muted`,children:D})]}),(0,L.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,L.jsx)(h4,{value:o,onChange:e=>C(e),options:[{value:`issues`,label:`Issues`},{value:`prs`,label:`PRs`}]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`petite-caps text-[11px] text-muted/70`,children:`Sort`}),(0,L.jsx)(h4,{value:c,onChange:w,options:[{value:`recent`,label:`Recent`},{value:`reactions`,label:`Reactions`}]})]})]}),(0,L.jsx)(`div`,{ref:x,className:`min-h-[240px] flex-1 overflow-y-auto rounded-lg border border-border/70 bg-bg/40 transition-opacity ${g.isPlaceholderData?`opacity-40`:``}`,children:g.isLoading?(0,L.jsx)(w4,{}):g.isError?(0,L.jsxs)(T4,{children:[(0,L.jsxs)(`span`,{className:`text-[12.5px] text-muted/80`,children:[`Couldn't load `,o===`issues`?`issues`:`pull requests`,`.`]}),(0,L.jsx)(`span`,{className:`max-w-[80%] text-center text-[11px] text-muted/45`,children:g.error.message.slice(0,140)})]}):_.length===0?(0,L.jsxs)(T4,{children:[(0,L.jsx)(Om,{size:28,strokeWidth:1.25,className:`text-muted/30`}),(0,L.jsxs)(`span`,{className:`text-[12.5px] text-muted/60`,children:[`No open `,o===`issues`?`issues`:`pull requests`]})]}):_.map(e=>(0,L.jsx)(v4,{item:e,checked:f.has(e.number),onActivate:t=>T(e.number,t)},e.number))}),!g.isLoading&&!g.isError&&(0,L.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between gap-3 whitespace-nowrap text-[11.5px] text-muted/60`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsxs)(`span`,{className:`truncate tabular-nums`,children:[b,` open `,o===`issues`?b===1?`issue`:`issues`:b===1?`pull request`:`pull requests`]}),O>0&&(0,L.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`text-muted/30`,children:`·`}),(0,L.jsxs)(`span`,{className:`tabular-nums text-fg/70`,children:[O,` selected`]}),(0,L.jsx)(`button`,{onClick:E,onMouseDown:e=>e.preventDefault(),className:`rounded py-0.5 text-muted/60 underline-offset-2 outline-none transition-colors hover:text-fg hover:underline`,children:`Clear`})]})]}),y>1&&(0,L.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,L.jsx)(m4,{label:`Previous page`,disabled:v<=1,onClick:()=>d(Math.max(1,v-1)),children:(0,L.jsx)(em,{size:14})}),(0,L.jsxs)(`span`,{className:`relative px-2 text-center tabular-nums`,children:[(0,L.jsxs)(`span`,{"aria-hidden":!0,className:`invisible`,children:[`Page `,y,` of `,y]}),(0,L.jsxs)(`span`,{className:`absolute inset-0`,children:[`Page `,v,` of `,y]})]}),(0,L.jsx)(m4,{label:`Next page`,disabled:v>=y,onClick:()=>d(Math.min(y,v+1)),children:(0,L.jsx)(tm,{size:14})})]})]}),(0,L.jsxs)(`div`,{className:`mt-4 flex items-end justify-between gap-3`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(CR,{groups:k,value:n?{provider:n.backend,model:n.model,effort:n.effort}:void 0,onValueChange:e=>a({field:`profile`,backend:e.provider,model:e.model,effort:e.effort}),placeholder:i?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort`,title:M??`Model and reasoning effort for every thread this batch starts`,disabled:!n,side:`top`,menuZClass:Fj,className:`max-w-[min(21rem,60vw)]`}),j&&(0,L.jsx)(`p`,{className:`mt-1 max-w-[430px] text-[10.5px] text-red-400`,children:j})]}),(0,L.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,L.jsxs)(`button`,{disabled:O===0||S.isPending||!!M,onClick:N,onMouseDown:e=>e.preventDefault(),className:`flex items-center gap-2 rounded-md bg-fg px-3.5 py-1.5 text-[12.5px] font-medium text-bg outline-none transition-all hover:opacity-90 active:scale-95 disabled:opacity-30 disabled:hover:opacity-30`,children:[S.isPending&&(0,L.jsx)(Mm,{size:13,className:`animate-spin`}),O<=1?`Start investigation`:`Start ${O} investigations`]})})]})]})})}function m4({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 h4({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 g4({item:e}){let t=(e.state??`OPEN`).toUpperCase();return e.kind===`pr`?t===`MERGED`?(0,L.jsx)(bm,{size:15,className:`shrink-0`,style:{color:TE.fgDone}}):t===`CLOSED`?(0,L.jsx)(xm,{size:15,className:`shrink-0`,style:{color:TE.fgDanger}}):e.isDraft?(0,L.jsx)(Sm,{size:15,className:`shrink-0`,style:{color:TE.fgNeutral}}):(0,L.jsx)(Cm,{size:15,className:`shrink-0`,style:{color:TE.fgSuccess}}):t===`CLOSED`?(0,L.jsx)(am,{size:15,className:`shrink-0`,style:{color:TE.fgDone}}):(0,L.jsx)(sm,{size:15,className:`shrink-0`,style:{color:TE.fgSuccess}})}function _4({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 v4({item:e,checked:t,onActivate:n}){let r=XT(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)(y4,{checked:t})}),(0,L.jsx)(`span`,{className:`mt-px`,children:(0,L.jsx)(g4,{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)(_4,{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)(S4,{prs:e.linkedPrs}):null,e.comments?(0,L.jsx)(C4,{icon:Im,n:e.comments,label:`comments`}):null,e.reactions?(0,L.jsx)(C4,{emoji:`👍`,n:e.reactions,label:`reactions`}):null]})]})}function y4({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)(Qp,{size:11,strokeWidth:3,className:`text-bg`})})}var b4={octicon:`-0.1em`,stroke:`-0.112em`};function x4({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(${b4.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 S4({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)(x4,{size:12}),e.count]})}function C4({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(${b4.stroke})`},children:(0,L.jsx)(e,{size:12,strokeWidth:2})}):null,n]})}function w4(){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 T4({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 E4={permissionMode:`The permission mode new Claude Code threads launch with. Auto runs safe actions and asks you to approve the risky ones in the thread. Bypass launches the worker with --dangerously-skip-permissions: it never asks, so nothing waits on you and nothing is checked either. Takes effect on the next thread you dispatch; to change a thread that already exists, use the picker beside its model in the prompt box. Codex threads always run with full workspace access and are unaffected.`,promptCacheTtl:`Which prompt-cache tier a new Claude thread writes to. A 1-hour entry costs twice the input price to write, a 5-minute entry 1.25 times; the hour only pays off when the thread's cache actually survives that long. Measured 2026-09-03: cache writes were half of a day's spend and the entries were lost every 15 to 30 minutes regardless, so 5 minutes was the cheaper tier. Automatic leaves the choice to Claude Code, which picks 1 hour on a subscription. Takes effect on the next thread you dispatch and on a thread that resumes after its worker exited.`,autoCompactWindow:`How large a new Claude thread's conversation may grow, in tokens, before Claude Code compacts it. Frizz launches every Claude thread with the 1M context window, so without a ceiling a long thread keeps re-sending everything it has read on every turn; 500K halves that at the cost of an earlier summary. Takes effect on the next thread you dispatch and on a thread that resumes after its worker exited; a thread whose worker is already running keeps its current ceiling. A thread's context dial reads against the ceiling it was launched with, not the model's full window.`,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 D4(){return typeof Notification>`u`?`unsupported`:Notification.permission}var O4=500,k4=1600,A4=2e3,j4=6;function M4(){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=>{p5.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`),k4))}).catch(i=>{--a.current,t(`error`),!(n.current||!lf(i)||s.current>=j4)&&(s.current+=1,n.current=e,r.current=window.setTimeout(c.current,A4))}))},[]);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,O4)},[l]);return(0,I.useEffect)(()=>()=>{l(),o.current!==void 0&&window.clearTimeout(o.current)},[l]),{state:e,queue:u,flush:l}}function N4(){let e=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()}),[t,n]=(0,I.useState)(null),[r,i]=(0,I.useState)(D4()),{state:a,queue:o,flush:s}=M4(),[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)(()=>(ld(p),()=>ld(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,Mp()?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:`${Op} z-50 flex justify-end ${c?`opacity-100`:`opacity-0`}`,onMouseDown:e=>e.target===e.currentTarget&&p(),children:(0,L.jsxs)(`div`,{className:`${kp} w-[560px] max-w-[94vw] ${c?`translate-x-0`:`translate-x-full`}`,children:[(0,L.jsx)(sh,{title:`Settings`,actions:(0,L.jsx)(P4,{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)(I4,{label:`Font`,help:E4.font,children:(0,L.jsx)(K4,{value:t.font??`mono`,onChange:e=>f({...t,font:e})})}),(0,L.jsx)(I4,{label:`Project sidebar`,help:E4.projectRail,children:(0,L.jsx)(sX,{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)(I4,{label:`Local file links`,help:E4.localFileOpener,children:(0,L.jsx)(sX,{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)(I4,{label:`Density`,help:E4.density,children:(0,L.jsx)(J4,{})}),(0,L.jsx)(I4,{label:`Queue order`,help:E4.queueOrder,children:(0,L.jsx)(Y4,{})}),(0,L.jsxs)(I4,{label:`Desktop notifications`,help:E4.notifications,children:[(0,L.jsx)(q4,{value:t.notifications,onChange:m}),t.notifications&&(0,L.jsx)(Z4,{perm:r})]}),(0,L.jsx)(V4,{draft:t,setDraft:f}),(0,L.jsx)(H4,{draft:t,setDraft:f})]}):(0,L.jsx)(`div`,{className:`p-4 text-[13px] text-muted`,children:`Loading…`})]})})}function P4({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 F4({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)(Rj,{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)(cm,{size:12})})})]})}function I4({label:e,help:t,children:n}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,L.jsx)(F4,{label:e,help:t}),n]})}var L4=[{token:`repo`,gloss:`repository`},{token:`n`,gloss:`number`},{token:`title`,gloss:`title`},{token:`url`,gloss:`link`},{token:`labels`,gloss:`labels`},{token:`body`,gloss:`description`}],R4=5e5,z4=[{value:`200000`,label:`200K tokens`},{value:`350000`,label:`350K tokens`},{value:`500000`,label:`500K tokens (default)`},{value:`750000`,label:`750K tokens`},{value:`1000000`,label:`1M tokens`}],B4=[{value:`auto`,label:`Automatic (default)`},{value:`5m`,label:`5 minutes`},{value:`1h`,label:`1 hour`}];function V4({draft:e,setDraft:t}){return(0,L.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,L.jsx)(U4,{label:`Claude`}),(0,L.jsxs)(I4,{label:`Permissions`,help:E4.permissionMode,children:[(0,L.jsx)(sX,{variant:`bordered`,value:e.permissionMode===`bypassPermissions`?`bypassPermissions`:`auto`,onValueChange:n=>t({...e,permissionMode:n}),options:FR,indicatorPosition:`right`,ariaLabel:`Claude permission mode`}),e.permissionMode===`bypassPermissions`&&(0,L.jsx)(X4,{})]}),(0,L.jsx)(I4,{label:`Compaction window`,help:E4.autoCompactWindow,children:(0,L.jsx)(sX,{variant:`bordered`,value:String(e.autoCompactWindow??R4),onValueChange:n=>t({...e,autoCompactWindow:Number(n)}),options:z4,indicatorPosition:`right`,ariaLabel:`Claude compaction window`})}),(0,L.jsx)(I4,{label:`Prompt cache tier`,help:E4.promptCacheTtl,children:(0,L.jsx)(sX,{variant:`bordered`,value:e.promptCacheTtl??`auto`,onValueChange:n=>t({...e,promptCacheTtl:n}),options:B4,indicatorPosition:`right`,ariaLabel:`Claude prompt cache tier`})})]})}function H4({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)(U4,{label:`Prompts`}),n.data?(0,L.jsx)(G4,{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 U4({label:e}){return(0,L.jsxs)(`div`,{className:`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 W4(){let[e,t]=(0,I.useState)(!1);return(0,L.jsxs)(sV,{open:e,onOpenChange:t,children:[(0,L.jsx)(cV,{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)(uV,{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:L4.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 G4({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)(F4,{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)(W4,{})]})]}),(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 K4({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 q4({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 J4(){let{compactDiffs:e}=Zt(tT);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:()=>tT.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 Y4(){let{queueOrder:e}=Zt(tT);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:()=>tT.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 X4(){return(0,L.jsx)(`span`,{className:`text-[11px] text-muted/70`,children:`New Claude threads will run every command, edit, and network call without asking you first.`})}function Z4({perm:e}){return e===`denied`?(0,L.jsx)($4,{}):(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 Q4(){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 $4(){let e=(0,I.useMemo)(Q4,[]),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)(t3,{url:n,hint:`Paste this into a new tab, set Notifications → Allow:`}):e===`safari`?(0,L.jsxs)(`span`,{children:[`Safari → Settings → Websites → Notifications → allow `,e3(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 e3(e){try{return new URL(e).host}catch{return e}}function t3({url:e,hint:t}){let[n,r]=(0,I.useState)(!1);async function i(){try{await wR(e),r(!0),window.setTimeout(()=>r(!1),1500)}catch{}}return(0,L.jsxs)(`span`,{className:`flex w-full flex-col gap-1`,children:[(0,L.jsx)(`span`,{children:t}),(0,L.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsx)(`code`,{className:`min-w-0 flex-1 font-mono-keep select-all rounded border border-border bg-bg px-1.5 py-0.5 text-[10.5px] text-fg/90 break-all`,children:e}),(0,L.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`Copy address`,className:`shrink-0 rounded border border-border p-1 text-muted hover:bg-panel-2 hover:text-fg transition-colors`,children:n?(0,L.jsx)(Qp,{size:11,className:`text-live`}):(0,L.jsx)(fm,{size:11})})]})]})}var n3=1,r3=.9,i3=.8,a3=.17,o3=.1,s3=.999,c3=.9999,l3=.99,u3=/[\\\/_+.#"@\[\(\{&]/,d3=/[\\\/_+.#"@\[\(\{&]/g,f3=/[\s-]/,p3=/[\s-]/g;function m3(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?n3:l3;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=m3(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=n3:u3.test(e.charAt(l-1))?(d*=i3,p=e.slice(i,l-1).match(d3),p&&i>0&&(d*=s3**+p.length)):f3.test(e.charAt(l-1))?(d*=r3,m=e.slice(i,l-1).match(p3),m&&i>0&&(d*=s3**+m.length)):(d*=a3,i>0&&(d*=s3**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=c3)),(d<o3&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=m3(e,t,n,r,l+1,a+2,o),f*o3>d&&(d=f*o3)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function h3(e){return e.toLowerCase().replace(p3,` `)}function g3(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,m3(e,t,h3(e),h3(t),0,0,{})}var _3=`[cmdk-group=""]`,v3=`[cmdk-group-items=""]`,y3=`[cmdk-group-heading=""]`,b3=`[cmdk-item=""]`,x3=`${b3}:not([aria-disabled="true"])`,S3=`cmdk-item-select`,C3=`data-value`,w3=(e,t,n)=>g3(e,t,n),T3=I.createContext(void 0),E3=()=>I.useContext(T3),D3=I.createContext(void 0),O3=()=>I.useContext(D3),k3=I.createContext(void 0),A3=I.forwardRef((e,t)=>{let n=W3(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=W3(()=>new Set),i=W3(()=>new Map),a=W3(()=>new Map),o=W3(()=>new Set),s=H3(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=WD(),y=WD(),b=WD(),x=I.useRef(null),S=q3();U3(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),U3(()=>{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??w3;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(v3);t?t.appendChild(e.parentElement===t?e:e.closest(`${v3} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${v3} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${_3}[${C3}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(C3);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(_3)?.querySelector(y3))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${b3}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(x3)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(C3))}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(C3))}function P(e){let t=A()?.closest(_3),n;for(;t&&!n;)t=e>0?B3(t,_3):V3(t,_3),n=t?.querySelector(x3);n?C.setState(`value`,n.getAttribute(C3)):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(xD.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(S3);t.dispatchEvent(e)}}}}},I.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:X3},c),Y3(e,e=>I.createElement(D3.Provider,{value:C},I.createElement(T3.Provider,{value:w},e))))}),j3=I.forwardRef((e,t)=>{let n=WD(),r=I.useRef(null),i=I.useContext(k3),a=E3(),o=H3(e),s=o.current?.forceMount??i?.forceMount;U3(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=K3(n,r,[e.value,e.children,r],e.keywords),l=O3(),u=G3(e=>e.value&&e.value===c.current),d=G3(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(S3,f),()=>t.removeEventListener(S3,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(xD.div,{ref:iD(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)}),M3=I.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=WD(),s=I.useRef(null),c=I.useRef(null),l=WD(),u=E3(),d=G3(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);U3(()=>u.group(o),[]),K3(o,s,[e.value,e.heading,c]);let f=I.useMemo(()=>({id:o,forceMount:i}),[i]);return I.createElement(xD.div,{ref:iD(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),Y3(e,e=>I.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},I.createElement(k3.Provider,{value:f},e))))}),N3=I.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=I.useRef(null),a=G3(e=>!e.search);return!n&&!a?null:I.createElement(xD.div,{ref:iD(i,t),...r,"cmdk-separator":``,role:`separator`})}),P3=I.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=O3(),o=G3(e=>e.search),s=G3(e=>e.selectedItemId),c=E3();return I.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),I.createElement(xD.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)}})}),F3=I.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=I.useRef(null),o=I.useRef(null),s=G3(e=>e.selectedItemId),c=E3();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(xD.div,{ref:iD(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},Y3(e,e=>I.createElement(`div`,{ref:iD(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),I3=I.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return I.createElement(PI,{open:n,onOpenChange:r},I.createElement(BI,{container:o},I.createElement(HI,{"cmdk-overlay":``,className:i}),I.createElement(KI,{"aria-label":e.label,"cmdk-dialog":``,className:a},I.createElement(A3,{ref:t,...s}))))}),L3=I.forwardRef((e,t)=>G3(e=>e.filtered.count===0)?I.createElement(xD.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),R3=I.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return I.createElement(xD.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Y3(e,e=>I.createElement(`div`,{"aria-hidden":!0},e)))}),z3=Object.assign(A3,{List:F3,Item:j3,Input:P3,Group:M3,Separator:N3,Dialog:I3,Empty:L3,Loading:R3});function B3(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function V3(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function H3(e){let t=I.useRef(e);return U3(()=>{t.current=e}),t}var U3=typeof window>`u`?I.useEffect:I.useLayoutEffect;function W3(e){let t=I.useRef();return t.current===void 0&&(t.current=e()),t}function G3(e){let t=O3(),n=()=>e(t.snapshot());return I.useSyncExternalStore(t.subscribe,n,n)}function K3(e,t,n,r=[]){let i=I.useRef(),a=E3();return U3(()=>{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(C3,s),i.current=s}),i}var q3=()=>{let[e,t]=I.useState(),n=W3(()=>new Map);return U3(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function J3(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Y3({asChild:e,children:t},n){return e&&I.isValidElement(t)?I.cloneElement(J3(t),{ref:t.ref},n(t.props.children)):n(t)}var X3={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Z3(){let e=Zt(X),t=kC(),[n,r]=(0,I.useState)(``);if((0,I.useEffect)(()=>{e.showPalette&&r(``)},[e.showPalette]),!e.showPalette)return null;let i=_T(jC(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){np(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)(z3,{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)(z3.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)(z3.List,{className:`max-h-[52vh] overflow-y-auto py-1.5`,children:[(0,L.jsx)(z3.Empty,{className:`px-4 py-6 text-center text-sm text-muted`,children:`No matches.`}),(0,L.jsxs)(z3.Group,{heading:`Actions`,className:`cmdk-group`,children:[(0,L.jsx)(Q3,{value:`new thread create home`,onSelect:()=>c(()=>Wf()),children:`New thread`}),(0,L.jsx)(Q3,{value:`queue todos inbox pending`,onSelect:()=>c(()=>{xp(X.drawers.map(e=>e.id)),X.view=`todos`}),children:`Queue`}),(0,L.jsx)(Q3,{value:`open settings preferences`,onSelect:()=>c(()=>X.showSettings=!0),children:`Open settings`}),o&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(Q3,{value:`open details drawer doc ${aT(o)}`,onSelect:()=>c(()=>{let e=Sp();e&&$f(`doc`,e)}),children:`Open thread details`}),(0,L.jsxs)(Q3,{value:`mark complete done ${aT(o)}`,onSelect:()=>c(()=>Y.markComplete({slug:o.id}).catch(()=>{})),children:[`Mark “`,aT(o),`” complete`]}),(0,L.jsxs)(Q3,{value:`mark read ${aT(o)}`,onSelect:()=>c(()=>Y.markRead({slug:o.id}).catch(()=>{})),children:[`Mark “`,aT(o),`” read`]})]})]}),i.length>0&&(0,L.jsx)(z3.Group,{heading:`Threads`,className:`cmdk-group`,children:i.map(e=>(0,L.jsxs)(Q3,{value:`${aT(e)} ${e.id}`,onSelect:()=>c(()=>l(e.id)),children:[(0,L.jsx)(`span`,{className:`truncate`,children:aT(e)}),(0,L.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted/70`,children:e.id})]},e.id))})]})]})})}function Q3({value:e,onSelect:t,children:n}){return(0,L.jsx)(z3.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 $3=`Updating and restarting Frizz`,e6=`This may take a moment while the new build is being prepared. All of your threads will continue running normally.`;function t6(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 n6({open:e,message:t}){let n=(0,I.useRef)(null);if((0,I.useEffect)(()=>{if(!e)return;let t=document.activeElement;t instanceof HTMLElement&&t.blur(),n.current?.focus({preventScroll:!0});let r=e=>{t6(e)&&(e.preventDefault(),e.stopImmediatePropagation())};return window.addEventListener(`keydown`,r,{capture:!0}),()=>window.removeEventListener(`keydown`,r,{capture:!0})},[e]),!e)return null;let r=t?.trim()?t.trim():null;return(0,L.jsx)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":$3,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:n,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)(Gm,{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:$3}),(0,L.jsx)(`p`,{className:`mt-2 text-[12.5px] leading-relaxed text-muted`,children:e6}),r&&(0,L.jsx)(`p`,{"aria-live":`polite`,className:`mt-2 text-[11.5px] leading-relaxed text-muted/80`,children:r})]})})}var r6=`frizz:reload-after-update-restart`,i6=!1;function a6(){i6||(i6=!0,Z("Sign in to the GitHub CLI (`gh auth login`) to dispatch from issues/PRs.",{duration:6e3}))}function o6(){let e=Zt(X),t=(0,I.useRef)({projectDir:null,hasBeenVisible:!1});(0,I.useEffect)(()=>{Y.board().then(Tp).catch(()=>{})},[]);let n=Rv();(0,I.useEffect)(()=>rw((e,t)=>n(e,t)),[n]);let{data:r,dataUpdatedAt:i}=zV(),a=(0,I.useRef)(null);(0,I.useEffect)(()=>{let e=r;if(!e)return;X.controlPlaneRestartPending?e.state!==`ready`&&(X.controlPlaneRestartPending=!1,X.controlPlaneState=e.state,X.controlPlaneMessage=e.message??null):(X.controlPlaneState=e.state,X.controlPlaneMessage=e.message??null);let t=sessionStorage.getItem(r6);if(e.state===`ready`&&t&&!X.controlPlaneRestartPending){sessionStorage.removeItem(r6),window.location.replace(t);return}e.state===`failed`&&t&&(sessionStorage.removeItem(r6),a.current!==e.message&&(a.current=e.message??`Update & Restart failed`,Z(`Update & Restart failed — Frizz kept running the previous version`,{duration:7e3})))},[r,i]);let o=e.drawers.length>0||e.showSettings||e.showNewThread||e.showGithubPicker||e.showPalette;(0,I.useEffect)(()=>{if(!o)return;let e=window.scrollY,t=document.body;return xd(),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,xd()??e)}},[o]);let s=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()});(0,I.useEffect)(()=>{X.notificationsEnabled=s.data?.notifications??!1},[s.data?.notifications]);let c=QL();(0,I.useEffect)(()=>{c.data?.inRepo&&!c.data.authed&&a6()},[c.data?.inRepo,c.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=vp(),n=Sp();t?.kind===`doc`?(e.preventDefault(),md(t.id)||X.drawers.pop()):n&&(e.preventDefault(),$f(`doc`,n))}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let l=kC(),u=sW();(0,I.useEffect)(()=>{rp()},[l,e.routeThreadSlug]),t.current=iw(t.current,l);let d=l!==null&&t.current.hasBeenVisible,f=l===null&&ow(Dd()),p=t.current.hasBeenVisible;(0,I.useEffect)(()=>{l!==null&&sw(Dd(),p)},[l,p]);let m=l?.projectLabel??l?.projectName;return(0,I.useEffect)(()=>{let e=window.matchMedia?.(`(display-mode: standalone)`).matches;document.title=e?m??`Frizz`:m?`${m} — Frizz`:`Frizz`},[m]),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(n6,{open:e.controlPlaneState===`restarting`,message:e.controlPlaneMessage}),(0,L.jsxs)(`div`,{inert:e.controlPlaneState===`restarting`,className:`relative min-h-screen bg-bg text-fg text-sm`,children:[u?(0,L.jsx)(tW,{}):(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:[d&&(0,L.jsx)(lh,{label:`the sidebar`,children:(0,L.jsx)(nU,{})}),f&&(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`||!l?`min-h-screen`:``} ${e.view===`todos`?``:`rounded-lg border border-border bg-panel`}`,children:l?(0,L.jsxs)(lh,{label:`the queue`,resetKeys:[e.view],children:[e.view.startsWith(`status:`)&&(0,L.jsx)(RU,{status:e.view.slice(7)}),e.view===`todos`&&(0,L.jsx)(t4,{})]}):(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)(I2,{}),e.showSettings&&(0,L.jsx)(N4,{}),e.showNewThread&&(0,L.jsx)(pz,{onClose:()=>{X.showNewThread=!1}}),e.showGithubPicker&&(0,L.jsx)(p4,{onClose:Kf}),(0,L.jsx)(Z3,{})]})]})}function s6(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 c6(e,t,n,r=48){let i=Math.round(t/r);return Math.max(0,Math.min(n-1,e+i))}function l6(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 u6(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 d6=`w-[57px]`,f6=`max-[800px]:pl-0 pl-[57px]`;function p6(e){let t=0;for(let n=0;n<e.length;n++)t=(t*31+e.charCodeAt(n))%360;return t}function m6(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 h6(e){let t=e.iconVersion?`&v=${encodeURIComponent(e.iconVersion)}`:``;return`/_frizz/project-icon?id=${encodeURIComponent(e.id)}${t}`}function g6({project:e,size:t}){let[n,r]=(0,I.useState)(!1),[i,a]=(0,I.useState)(!1),o=p6(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:m6(e.name)})}),s&&!c&&(0,L.jsx)(`img`,{src:h6(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 _6=40;function v6({project:e,current:t,count:n,index:r,drag:i,onPointerDown:a,onKeyDown:o}){let s=i?.fromIndex===r,c=i?s?i.deltaY:l6(r,i.fromIndex,i.toIndex):0;return(0,L.jsx)(Rj,{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)(fb,{to:Od(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||S6())&&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)(g6,{project:e,size:_6})}),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 y6({project:e,children:t}){let n=(0,I.useRef)(null),r=Ve(),i=()=>r.invalidateQueries({queryKey:[`projectsList`]}),a=e=>Z(e instanceof Error?e.message:String(e),{duration:7e3}),o=it({mutationFn:async t=>{let n=new Uint8Array(await t.arrayBuffer()),r=``;for(let e=0;e<n.length;e+=8192)r+=String.fromCharCode(...n.subarray(e,e+8192));return Y.projectIconSet({id:e.id,name:t.name,data:btoa(r)})},onSuccess:()=>void i(),onError:a}),s=it({mutationFn:()=>Y.projectIconClear({id:e.id}),onSuccess:()=>void i(),onError:a}),c=it({mutationFn:()=>Y.projectIconPick({id:e.id}),onSuccess:e=>{if(e.kind!==`cancelled`){if(e.kind===`unavailable`){n.current?.click();return}i()}},onError:()=>n.current?.click()}),l=`cursor-default rounded px-2 py-1.5 text-[12.5px] text-fg outline-none data-[highlighted]:bg-panel-2`;return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(`input`,{ref:n,type:`file`,accept:od.map(e=>`.${e}`).join(`,`),className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&o.mutate(t)}}),(0,L.jsxs)(fI,{children:[(0,L.jsx)(pI,{asChild:!0,children:t}),(0,L.jsx)(mI,{children:(0,L.jsxs)(hI,{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)(vI,{className:l,onSelect:()=>c.mutate(),children:o.isPending?`Uploading…`:`Choose an icon…`}),(0,L.jsx)(vI,{className:l,onSelect:()=>s.mutate(),children:e.iconIsCustom?`Use the detected icon`:`Look for an icon again`})]})})]})]})}var b6=4,x6=0;function S6(){return Date.now()-x6<250}function C6(e,t){let n=nt({queryKey:[`projectsQueueCounts`],queryFn:()=>Y.projectsQueueCounts(),refetchInterval:5e3}),r=Zt(X).board,i=e!==void 0&&r?jC(r.threads).filter(bT).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 w6(){let e=Ve(),{data:t}=nt({queryKey:[`projectsList`],queryFn:()=>Y.projectsList()}),n=Dd(),[r,i]=(0,I.useState)(!1),a=Rv(),[o,s]=(0,I.useState)(null),[c,l]=(0,I.useState)(null),u=(0,I.useRef)(null),d=it({mutationFn:()=>Y.projectPick({}),onSuccess:e=>{e.kind===`picked`?a(Od(e.project.slug)):e.kind===`unavailable`&&a(`/`)},onSettled:()=>i(!1)}),f=it({mutationFn:e=>Y.projectsReorder({ids:e}),onSuccess:async()=>{await e.invalidateQueries({queryKey:[`projectsList`]}),l(null)},onError:()=>l(null)}),p=c??t??[],m=C6(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=u6(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:c6(t,c,i.length),deltaY:c},s(o)},m=0,h=e=>{if(!a){if(Math.abs(e.clientY-r)<b6)return;a=!0,n.setPointerCapture(e.pointerId)}e.preventDefault();let t=e.clientY;cancelAnimationFrame(c);let i=()=>{d(t),u.current&&u6(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;x6=Date.now();let e=s6(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=s6(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 ${d6}`,children:[(0,L.jsx)(Rj,{side:`right`,label:`All projects`,children:(0,L.jsx)(fb,{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)(Em,{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)(v6,{project:e,index:t,current:e.slug===n,count:m(e),drag:o,onPointerDown:_,onKeyDown:v},e.id))}),(0,L.jsx)(Rj,{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)(Wm,{size:16})})})]})}var T6=76;function E6(e,t){return t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}var D6=`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`,O6=`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`,k6=38;function A6({project:e,home:t}){let n=GT(e.lastOpenedAt),[r,i]=(0,I.useState)(!1);return(0,L.jsxs)(`div`,{className:`group/card relative`,children:[(0,L.jsxs)(fb,{to:Od(e.slug),className:`${D6} ${O6} 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)(g6,{project:e,size:k6})}),(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:E6(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)(y6,{project:e,children:(0,L.jsx)(`button`,{type:`button`,"aria-label":`Change the icon for ${e.name}`,style:{width:k6,height:k6},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)(Dm,{size:16,strokeWidth:1.75})})}),(0,L.jsx)(j6,{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)(pm,{size:15})})}),r?(0,L.jsx)(M6,{project:e,home:t,onClose:()=>i(!1)}):null]})}function j6({onDelete:e,children:t}){return(0,L.jsxs)(fI,{children:[(0,L.jsx)(pI,{asChild:!0,children:t}),(0,L.jsx)(mI,{children:(0,L.jsx)(hI,{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)(vI,{className:`cursor-default rounded px-2 py-1.5 text-[12.5px] text-red-400 outline-none data-[highlighted]:bg-red-500/10 data-[highlighted]:text-red-300`,onSelect:e,children:`Delete project…`})})})]})}function M6({project:e,home:t,onClose:n}){let[r,i]=(0,I.useState)(!1),a=Ve(),o=it({mutationFn:()=>Y.projectRemove({id:e.id,deleteData:r}),onSuccess:t=>{a.invalidateQueries({queryKey:[`projectsList`]}),Z(t.stoppedWorkers>0?`Deleted ${e.name} — ${t.stoppedWorkers} ${t.stoppedWorkers===1?`worker`:`workers`} stopped`:`Deleted ${e.name}`),n()}}),s=o.error instanceof Error?o.error.message:o.error?String(o.error):null;return(0,L.jsx)(EX,{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)(Mm,{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:E6(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 N6({hero:e,pending:t,onClick:n}){return(0,L.jsxs)(`button`,{type:`button`,onClick:n,disabled:t,className:`${D6} 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 P6({reason:e,proposed:t,onClose:n}){let[r,i]=(0,I.useState)(t??``),a=Rv(),o=Ve(),s=it({mutationFn:e=>Y.projectAdd({path:e}),onSuccess:e=>{o.invalidateQueries({queryKey:[`projectsList`]}),a(Od(e.slug))}}),c=s.error instanceof Error?s.error.message:s.error?String(s.error):null;return(0,L.jsx)(PI,{open:!0,onOpenChange:e=>{!e&&!s.isPending&&n()},children:(0,L.jsxs)(BI,{children:[(0,L.jsx)(HI,{className:`fixed inset-0 z-[210] bg-black/30 backdrop-blur-md backdrop-saturate-150`}),(0,L.jsxs)(KI,{"aria-modal":`true`,"aria-describedby":void 0,className:`fixed left-1/2 top-1/2 z-[210] w-[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)(ZI,{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 F6(){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=Rv(),i=Ve(),a=it({mutationFn:()=>Y.projectPick({}),onSuccess:e=>{if(e.kind!==`cancelled`){if(e.kind===`unavailable`){n({reason:e.reason});return}i.invalidateQueries({queryKey:[`projectsList`]}),r(Od(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:T6,height:T6,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)(A6,{project:e,home:l},e.id)),(0,L.jsx)(N6,{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)(P6,{reason:t.reason,proposed:e,onClose:()=>n(null)}):null]})}function I6(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 L6(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 R6({slug:e,path:t}){let n=FS(t),r=MC(t),i=nt({...zS(t),refetchInterval:r?!1:BS}),a=i.data?.path??t,o=i.data?.markdown??``,{front:s,body:c}=A2(n?o:``),[l,u]=(0,I.useState)(n?`rendered`:`source`),d=gK(c,{baseDir:LS(a),asDocument:!0}),f=nq(d),p=nq((0,I.useMemo)(()=>l===`source`?US(a,o):``,[o,a,l])),m=(0,I.useRef)(null),h=(0,I.useRef)(null),g=(0,I.useRef)(null);mq(m,d);let _=a.split(`/`).filter(Boolean).pop()||a,v=cz(),y=lz(e);return(0,I.useEffect)(()=>{let t=()=>document.querySelector(`main[data-standalone-thread] textarea`);function n(e,t){return e?document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0?t.length:Math.min(e.selectionStart??t.length,t.length):t.length}function r(r){if(!(r.metaKey||r.ctrlKey)||r.altKey||r.shiftKey||r.key.toLowerCase()!==`i`)return;let i=g.current,s=window.getSelection(),c=s&&!s.isCollapsed&&s.rangeCount>0?s.getRangeAt(0):null,l=!!(i&&c&&i.contains(c.commonAncestorContainer)),u=l?s.toString():``;if(!l||!u.trim()){r.preventDefault(),r.stopPropagation();let e=t();if(!e)return;document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0&&e.setSelectionRange(e.value.length,e.value.length),e.focus();return}r.preventDefault(),r.stopPropagation();let d=null,f=h.current;if(f&&f.contains(c.commonAncestorContainer)){let e=I6(f,c.startContainer,c.startOffset),t=I6(f,c.endContainer,c.endOffset);e!==null&&t!==null&&(d={startLine:L6(o,Math.min(e,t)),endLine:L6(o,Math.max(0,Math.max(e,t)-1))})}else d=EL(o,u);let p=t(),m=sz.followUp(v,e,y),{prose:_,attachments:b}=hL(az.get(m)),x=CL(_L({path:a,...d??{}}),X.composerContext[e]??[],_),S=wL(_,n(p,_),x);az.set(m,gL(S.prose,b.map(e=>e.path))),hp(e,{token:x,path:a,text:u,...d??{}}),s.removeAllRanges(),requestAnimationFrame(()=>{let e=t();e&&(e.setSelectionRange(S.caret,S.caret),e.focus())})}return window.addEventListener(`keydown`,r,!0),()=>window.removeEventListener(`keydown`,r,!0)},[e,a,o,v,y]),(0,L.jsxs)(`div`,{ref:g,"data-file-viewer-panel":!0,className:`flex h-full min-h-0 flex-col`,children:[(0,L.jsx)(sh,{title:_,subtitle:a,onClose:pp,actions:n?(0,L.jsx)(`div`,{className:`flex shrink-0 items-center gap-0.5 rounded-md border border-border-strong p-0.5 text-[11px] font-medium`,role:`group`,"aria-label":`File view`,children:[`rendered`,`source`].map(e=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>u(e),"aria-pressed":l===e,className:`rounded px-2 py-0.5 transition-colors ${l===e?`bg-panel-2 text-fg`:`text-muted hover:text-fg`}`,children:e===`rendered`?`Rendered`:`Source`},e))}):null}),(0,L.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:[i.isLoading?(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):i.error?(0,L.jsxs)(`div`,{className:`text-[13px] text-red-400/90`,children:[`Couldn’t read this file: `,i.error.message]}):l===`source`?o?(0,L.jsx)(`pre`,{ref:h,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:p}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):d?(0,L.jsxs)(L.Fragment,{children:[s&&(0,L.jsx)(N2,{source:s}),(0,L.jsx)(`div`,{ref:m,className:`md-body`,dangerouslySetInnerHTML:f})]}):(0,L.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!i.isLoading&&!i.error&&i.data?.truncated&&(0,L.jsx)(`p`,{className:`mt-4 border-t border-border/60 pt-3 text-[12px] text-muted`,children:`This file is too long to render in full — everything above the cut is shown. Open it to read the rest.`})]}),(0,L.jsxs)(`div`,{className:`shrink-0 flex items-center justify-between gap-3 border-t border-border/60 bg-panel px-5 pt-3`,style:j2,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)(M2,{path:a})]})]})}function z6(){return{dirs:new Map,files:new Map}}function B6(e,t){let n=e.replace(/\/+$/,``);if(t){let e=t.replace(/\/+$/,``);if(n.startsWith(e+`/`))return n.slice(e.length+1).split(`/`).filter(Boolean)}let r=n.split(`/`).filter(Boolean);return n.startsWith(`/`)?[`/`,...r]:r}var V6=(e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`,numeric:!0});function H6(e,t){let n=[];for(let r of[...e.dirs.keys()].sort(V6)){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:H6(i,t+1)})}for(let r of[...e.files.keys()].sort(V6))n.push({kind:`file`,name:r,depth:t,file:e.files.get(r)});return n}function U6(e,t){let n=z6();for(let r of e){let e=B6(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=z6(),i.dirs.set(t,e)),i=e}i.files.set(e[e.length-1],r)}return H6(n,0)}function W6(e){let t=[],n=e=>{for(let r of e)t.push(r),r.kind===`dir`&&n(r.children)};return n(e),t}var G6=10;function K6({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*G6},children:[(0,L.jsx)(`span`,{className:`flex shrink-0`,children:(0,L.jsx)(_m,{size:12,className:`${BQ} text-muted/45`})}),(0,L.jsx)(`span`,{className:`ml-[5px] min-w-0 truncate`,title:e,children:e})]})}function q6({files:e}){return(0,L.jsx)(`div`,{"data-edited-file-tree":!0,className:`col-span-4 flex flex-col gap-y-px`,children:W6(U6(e,AC())).map(e=>e.kind===`dir`?(0,L.jsx)(K6,{name:e.name,depth:e.depth},`d:${e.depth}:${e.name}`):(0,L.jsx)(J6,{file:e.file,name:e.name,depth:e.depth},e.file.path))})}function J6({file:e,name:t,depth:n}){let r=Ve();return(0,L.jsx)(QQ,{testKind:`file`,testId:e.path,mark:(0,L.jsx)(hm,{size:12,className:`${BQ} -mr-[2px] text-muted/60`}),name:t,indent:n*G6,onOpen:()=>KK(e.path),onPrewarm:()=>GS(r,e.path),title:e.path,status:(0,L.jsxs)(L.Fragment,{children:[(e.added??0)>0&&(0,L.jsxs)(`span`,{style:{color:TE.fgSuccess},children:[`+`,e.added]}),(e.added??0)>0&&(e.removed??0)>0&&` `,(e.removed??0)>0&&(0,L.jsxs)(`span`,{style:{color:TE.fgDanger},children:[`−`,e.removed]})]})})}function Y6({thread:e}){let t=sE(),n=UC(e.id,{poll:!1}).data?.editedFiles??[],r=a$(e),i=(e.bgShells??[]).filter(e=>e.state===`running`),a=(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`),o=(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`),{railFilesCollapsed:s}=Zt(tT),c=[{head:`Sub-agents`,rows:r.map(n=>(0,L.jsx)(o$,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:i.map(n=>(0,L.jsx)(r$,{shell:n,slug:e.id,now:t},n.id??n.label))},{head:`Pull requests`,rows:a.map(e=>(0,L.jsx)($Q,{watch:e},e.id))},{head:`Timers`,rows:o.map(e=>(0,L.jsx)(i$,{watch:e,now:t},e.id))},{head:`Edited files`,rows:n.length>0?[(0,L.jsx)(q6,{files:n},`tree`)]:[],count:n.length,collapsed:s,onToggle:()=>tT.railFilesCollapsed=!tT.railFilesCollapsed}].filter(e=>e.rows.length>0);return(0,L.jsx)(`aside`,{"data-focus-rail":!0,"aria-label":`Thread activity`,className:`flex h-full shrink-0 flex-col overflow-y-auto px-4 [view-transition-name:thread-rail]`,style:{width:340},children:(0,L.jsx)(`div`,{className:`my-auto py-6`,children:c.length===0?(0,L.jsx)(`div`,{className:`text-[11.5px] text-muted/50`,children:`Nothing running, watched or edited yet.`}):(0,L.jsx)(f$,{groups:c,divider:!1})})})}function X6(){let e=Zt(X),t=e.toast,[n,r]=(0,I.useState)(!1),i=e.drawers.some(e=>!e.closing);return(0,I.useEffect)(()=>{if(!t||(r(!0),t.sticky))return;let e=setTimeout(()=>r(!1),t.duration??(t.link?5e3:1600));return()=>clearTimeout(e)},[t?.id]),t?(0,L.jsx)(`div`,{className:`pointer-events-none fixed right-4 z-[70] flex justify-end ${i?`bottom-20`:`bottom-4`}`,children:(0,L.jsxs)(`div`,{"data-toast":!0,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:`flex max-w-[min(30rem,calc(100vw-2rem))] items-center gap-2.5 break-words rounded-lg border border-border-strong bg-elevated px-4 py-2 text-[13px] font-medium text-fg shadow-xl shadow-black/40 transition-all duration-200 ease-out ${n?`translate-y-0 opacity-100`:`translate-y-8 opacity-0`}`,children:[t.spinner&&(0,L.jsx)(Mm,{size:13,className:`animate-spin text-muted`}),t.text,t.link&&(0,L.jsx)(`button`,{onClick:()=>{$f(`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 Z6=`max(50%, calc(100% - 720px))`,Q6={"--full-thread":`min(720px, ${Z6})`,"--full-thread-narrow":`min(720px, 100%)`,"--full-pane":Z6,"--full-gutter":`max(0px, calc((100% - min(720px, ${Z6}) - 340px) / 2))`};function $6(e,t){return`${Od(e)}${Pd(t,`/`)}`}function e8({slug:e}){let t=!!Zt(X).filePanel,n=kC(),r=Sd(n,e),i=r.kind===`found`?r.thread:void 0;n?.projectDir,(0,I.useEffect)(()=>{Y.board().then(Tp).catch(()=>{})},[]),(0,I.useEffect)(()=>{let e=window.matchMedia(`(min-width: ${Ap}px)`),t=()=>{X.splitFileViewer=e.matches};return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),X.splitFileViewer=!1,X.filePanel=null}},[]);let a=i?.runtime===`turn-idle`||i?.runtime===`exited`||i?.runtime===`none`;return(0,I.useEffect)(()=>{!i||!a||Y.threadSeen({slug:e}).catch(()=>{})},[a,e,i?.lastActivityAt]),(0,I.useEffect)(()=>{let t=n?.projectLabel??n?.projectName,r=i?aT(i):e;document.title=t?`${r} · ${t} — Frizz`:`${r} · Frizz`},[n?.projectLabel,n?.projectName,e,i]),(0,L.jsx)(Lj,{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:{...Q6,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)(n8,{slug:e}):(0,L.jsx)(U1,{slug:e,virtualized:!0,showReturnToQueue:!0})}),i?(0,L.jsx)(t8,{slug:e,thread:i}):(0,L.jsx)(`div`,{className:`hidden w-[var(--full-pane)] shrink-0 split:block`,"aria-hidden":`true`})]})}),(0,L.jsx)(I2,{}),(0,L.jsx)(X6,{})]})})}function t8({slug:e,thread:t}){let n=Zt(X).filePanel,[r,i]=(0,I.useState)(null),a=n?.path??r;return(0,I.useEffect)(()=>{if(n){i(n.path);return}let e=window.setTimeout(()=>i(null),210);return()=>window.clearTimeout(e)},[n]),(0,L.jsxs)(`div`,{"data-side-pane":!0,className:`relative hidden h-full w-[var(--full-pane)] min-h-0 min-w-0 shrink-0 grow-0 overflow-hidden split:block`,children:[(0,L.jsx)(`div`,{inert:n?!0:void 0,className:`h-full min-h-0`,children:(0,L.jsx)(Y6,{thread:t})}),(0,L.jsx)(`aside`,{"data-file-viewer-slot":!0,"aria-hidden":!n,className:`absolute inset-0 transition-[translate,opacity] duration-200 ease-out motion-reduce:transition-none ${n?`translate-x-0 opacity-100`:`translate-x-full opacity-0`}`,children:a&&(0,L.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-panel`,children:(0,L.jsx)(R6,{slug:e,path:a},a)})})]})}function n8({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($6(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:$6(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 r8={OPEN_ISSUE:{bg:TE.bgSuccessEmphasis,icon:sm,label:`Open`},CLOSED_ISSUE:{bg:TE.bgDoneEmphasis,icon:am,label:`Closed`},NOT_PLANNED:{bg:TE.bgNeutralEmphasis,icon:lm,label:`Closed as not planned`},OPEN_PR:{bg:TE.bgSuccessEmphasis,icon:Cm,label:`Open`},DRAFT:{bg:TE.bgNeutralEmphasis,icon:Sm,label:`Draft`},MERGED:{bg:TE.bgDoneEmphasis,icon:bm,label:`Merged`},CLOSED_PR:{bg:TE.bgDangerEmphasis,icon:xm,label:`Closed`}};function i8(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 a8(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 o8(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 ${a8(e,t)}`:XT(e,t)??``:``}function s8(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 c8={add:TE.fgSuccess,del:TE.fgDanger},l8={add:{backgroundColor:TE.bgSuccessEmphasis,borderColor:TE.bgSuccessEmphasis},del:{backgroundColor:TE.bgDangerEmphasis,borderColor:TE.bgDangerEmphasis},none:{backgroundColor:`${TE.bgNeutralEmphasis}33`,borderColor:`#3d444d`}};function u8({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:c8.add},children:[`+`,e.toLocaleString()]}),(0,L.jsxs)(`span`,{"data-gh-del":!0,style:{color:c8.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:s8(e,t).map((e,t)=>(0,L.jsx)(`span`,{className:`size-[8px] rounded-[2px] border`,style:l8[e]},t))})]})}function d8({card:e}){let t=i8(e),n=t?r8[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 f8({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 p8=/`([^`\n]+)`/g;function m8(e,t){if(!t)return[e];let n=[],r=0;for(let t of e.matchAll(p8))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 h8({text:e,code:t,className:n}){return(0,L.jsx)(`div`,{className:n,children:m8(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 g8=new Set([`avatars.githubusercontent.com`,`camo.githubusercontent.com`]);function _8(e){if(e)try{let t=new URL(e);return t.protocol===`https:`&&g8.has(t.hostname)?e:void 0}catch{return}}function v8({card:e,nowMs:t}){let n=_8(e.authorAvatar),r=e.authorLogin??e.authorName??`Someone`,i=e.kind===`commit`?`committed`:e.kind===`pr`?`opened this pull request`:`opened this issue`,a=o8(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 y8=`w-[360px] max-w-[min(360px,calc(100vw-24px))] leading-normal`;function b8({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:y8,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)(ym,{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)(h8,{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)(u8,{additions:e.additions,deletions:e.deletions})}):null]})]}),(0,L.jsx)(v8,{card:e,nowMs:t})]});let r=e.ref.slice(e.ref.indexOf(`#`));return(0,L.jsxs)(`div`,{className:y8,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 ${a8(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)(d8,{card:e}),n?(0,L.jsx)(u8,{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)(h8,{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)(f8,{name:e.name,color:e.color},e.name))}):null]}):null,(0,L.jsx)(v8,{card:e,nowMs:t})]})}var x8=250,S8=180;function C8(e){let t=e.getClientRects()[0]??e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}}function w8(){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)},S8)},[]);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),Of([o]),n.current=setTimeout(()=>t({ref:o,rect:C8(a)}),x8)))},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)(sV,{open:e!==null,children:[(0,L.jsx)(lV,{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)(uV,{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)(T8,{refKey:e.ref})}):null]})}function T8({refKey:e}){let t=(0,I.useSyncExternalStore)(Cf,()=>wf(e),()=>wf(e));return(0,I.useEffect)(()=>{Tf(wf(e))&&Mf(e)},[e]),t?.card?(0,L.jsx)(b8,{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 E8=`frizz-project-rail`;function D8(){try{return localStorage.getItem(E8)===`shown`}catch{return!1}}function O8(e){try{localStorage.setItem(E8,e?`shown`:`hidden`)}catch{}}function k8(){Iv();let e=nt({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet(),placeholderData:ee}).data?.projectRail;return(0,I.useEffect)(()=>{e!==void 0&&O8(e===!0)},[e]),e===void 0?D8():e===!0}var A8=`/project/:slug`;function j8(){I8();let e=k8();return(0,L.jsxs)(Lj,{children:[e?(0,L.jsx)(w6,{}):null,(0,L.jsx)(`div`,{className:e?f6:void 0,children:(0,L.jsx)(vy,{})}),(0,L.jsx)(X6,{}),(0,L.jsx)(w8,{})]})}function M8(e){(0,I.useEffect)(()=>{uC(e)||(wp(),DC())},[e])}function N8(){let{slug:e,thread:t}=Hv();return M8(e),F8(),(0,I.useState)(()=>op(t)),(0,L.jsx)(o6,{},e??`__launching__`)}function P8(){return(0,L.jsx)(F6,{})}function F8(){let e=Iv();(0,I.useEffect)(()=>{QC(Ad(e.pathname))},[e.pathname])}function I8(){let e=Rv();(0,I.useEffect)(()=>(tw((t,n)=>e(t,n)),()=>tw(null)),[e])}function L8(){let{thread:e,slug:t}=Hv();return I8(),M8(t),(0,I.useState)(()=>{X.drawers.length>0&&(X.drawers=[])}),ap(e),(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(e8,{slug:e}),(0,L.jsx)(X6,{})]})}var R8=[{index:!0,element:(0,L.jsx)(N8,{})},{path:`thread/:thread`,element:(0,L.jsx)(N8,{})},{path:`status/:status`,element:(0,L.jsx)(N8,{})}],z8=cb([{path:`/thread/:thread/full`,element:(0,L.jsx)(L8,{})},{path:`${A8}/thread/:thread/full`,element:(0,L.jsx)(L8,{})},{element:(0,L.jsx)(j8,{}),children:[{path:`/`,element:(0,L.jsx)(P8,{})},{path:`/thread/:thread`,element:(0,L.jsx)(N8,{})},{path:`/status/:status`,element:(0,L.jsx)(N8,{})},{path:A8,children:R8},{path:`*`,element:(0,L.jsx)(N8,{})}]}]),B8=24,V8=6,H8=700,U8=new Map,W8=null,G8=null;function K8(e){return!Array.isArray(e)||e.length!==2?null:e[0]===`transcript`&&typeof e[1]==`string`?e[1]:null}function q8(e){return X.board?.threads.find(t=>t.id===e)?.lastActivityAt}function J8(){let e=[...U8.entries()].filter(([,e])=>e.observers>0),t=new Set(e.slice(-24).map(([e])=>e));for(let[e,n]of U8){if(n.observers<=0){n.live&&(n.live=!1,CC(e)),U8.delete(e);continue}t.has(e)?!n.live&&!n.queued&&(n.queued=!0):(n.queued=!1,n.live&&(n.live=!1,CC(e)))}Y8()}function Y8(){G8||[...U8.values()].some(e=>e.queued)&&(G8=setTimeout(()=>{G8=null;let e=0,t=[...U8.values()].filter(e=>e.live).length;for(let[n,r]of U8){if(e>=V8||t>=B8)break;r.queued&&(r.queued=!1,!(r.observers<=0||r.live)&&(r.live=!0,t++,r.lastActivityAt=q8(n),SC(n),e++))}Y8()},H8))}function X8(){if(W8)for(let[e,t]of U8){if(t.observers<=0)continue;let n=q8(e);n!==t.lastActivityAt&&(t.lastActivityAt=n,!(t.live&&X.socketTranscripts)&&(X.socketTranscriptFallbacks[e]||W8.refetchQueries({queryKey:[`transcript`,e],exact:!0,type:`active`})))}}function Z8(e){W8||(W8=e,e.getQueryCache().subscribe(e=>{let t=K8(e.query.queryKey);if(!t||e.type!==`observerAdded`&&e.type!==`observerRemoved`)return;let n=e.query.getObserversCount(),r=U8.get(t);e.type===`observerAdded`?(U8.delete(t),U8.set(t,{observers:n,live:r?.live??!1,queued:r?.queued??!1,lastActivityAt:r?r.lastActivityAt:q8(t)})):r&&(r.observers=n),J8()}),Jt(X,X8))}var Q8=`ui-monospace, "JetBrains Mono", "Fira Code", "SF Mono", "Cascadia Mono", Consolas, Menlo, "DejaVu Sans Mono", monospace`,$8=`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;function e5(e){let t=e===`mono`?`mono`:`sans`;document.documentElement.dataset.font=t,document.body&&(document.body.style.fontFamily=t===`sans`?$8:Q8);try{localStorage.setItem(`frizz-font`,t)}catch{}}function t5(e){let t=e.getQueryData([`settingsGet`]);t&&e5(t.font),Y.settingsGet().then(e=>e5(e.font)).catch(()=>{}),e.getQueryCache().subscribe(()=>{let t=e.getQueryData([`settingsGet`]);t&&e5(t.font)})}function n5(){let e=e=>{if(e.button!==0||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`.${pS}`):null;t&&(e.preventDefault(),e.stopPropagation(),i5(t))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)}function r5(e){return e.closest(`.md-code`)?.querySelector(`pre code`)??null}async function i5(e){let t=r5(e);if(!t)return;let n=(t.textContent??``).replace(/\n$/,``);if(n){try{await wR(n)}catch(e){Z(`Could not copy code: ${e.message.slice(0,100)}`,{duration:7e3});return}o5(e)}}var a5=new WeakMap;function o5(e){e.classList.add(mS),e.title=`Copied`;let t=a5.get(e);t!==void 0&&window.clearTimeout(t),a5.set(e,window.setTimeout(()=>{e.classList.remove(mS),e.title=hS,a5.delete(e)},S$))}var s5=/^\/thread\/([a-z0-9][a-z0-9-]*)\/?$/;function c5(){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=Dd(n);if(r&&r!==Dd())return;let i=s5.exec(Ad(n));i&&(e.preventDefault(),e.stopPropagation(),np(i[1]))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)}var l5=new Set([`projectsList`,`projectsQueueCounts`,`threadLocate`,`dispatchPreferencesGet`,`supervisorStatus`]);function u5(e){let t=e[0];return typeof t==`string`&&l5.has(t)?T(e):T([`project:${Dd()??``}`,...e])}var d5=typeof window<`u`&&window.location.pathname.endsWith(`/settings-formatting-fixture.html`),f5=typeof window<`u`?Fd(Ad()):null;!d5&&!f5&&$C();var p5=new Le({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,queryKeyHashFn:u5}}});d5||(OC(p5),Z8(p5),VV(p5),t5(p5),GZ(),WK(),n5(),c5()),d5||(0,at.createRoot)(document.getElementById(`root`)).render((0,L.jsx)(He,{client:p5,children:(0,L.jsx)(ph,{children:(0,L.jsx)(my,{router:z8})})}));export{a as i,Nd as n,ze as r,By as t};