frizz-server 0.15.20 → 0.15.22
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.
- package/dist/claude-agent-broker.js +24 -12
- package/dist/dev-child.js +111 -45
- package/package.json +1 -1
- package/runtime/cc-worker/DECISIONS.md +6 -2
- package/runtime/cc-worker/bin/frizz-mcp.mjs +4 -2
- package/runtime/cc-worker/hooks/perm-policy.mjs +10 -1
- package/web-dist/assets/{abnfDiagram-VRR7QNED-B61nQEjt.js → abnfDiagram-VRR7QNED-DqTQZ2Ex.js} +1 -1
- package/web-dist/assets/{arc-CR8_qWI3.js → arc-t56zg8G8.js} +1 -1
- package/web-dist/assets/architecture-TIHT7OUA-Czzg2iAA.js +1 -0
- package/web-dist/assets/{architectureDiagram-ZJ3FMSHR-6sc4SDOh.js → architectureDiagram-ZJ3FMSHR-CSdC9-eQ.js} +1 -1
- package/web-dist/assets/{blockDiagram-677ZJIJ3-p-DPTDGB.js → blockDiagram-677ZJIJ3-Dmw8EopV.js} +1 -1
- package/web-dist/assets/{c4Diagram-LMCZKHZV-cqvAqZE2.js → c4Diagram-LMCZKHZV-BCRaFnis.js} +1 -1
- package/web-dist/assets/channel-CxehNUC2.js +1 -0
- package/web-dist/assets/{chunk-32BRIVSS-BNnoKILR.js → chunk-32BRIVSS-DqOJDRw_.js} +1 -1
- package/web-dist/assets/{chunk-52WLFC77-BmHIWiVu.js → chunk-52WLFC77-BsibludT.js} +1 -1
- package/web-dist/assets/{chunk-C7G6YPKG-D7XYFno8.js → chunk-C7G6YPKG-D7Me5JQU.js} +1 -1
- package/web-dist/assets/{chunk-EX3LRPZG-BUViIha7.js → chunk-EX3LRPZG-CTa4YlOO.js} +1 -1
- package/web-dist/assets/{chunk-FWX5IMBZ-3x5Zky3W.js → chunk-FWX5IMBZ-CjqOt5Jn.js} +2 -2
- package/web-dist/assets/{chunk-HOUHSVGY-C6_RBSov.js → chunk-HOUHSVGY-BDIBDR-8.js} +1 -1
- package/web-dist/assets/{chunk-ICXQ74PX-NbVxQ4i1.js → chunk-ICXQ74PX-C4exiYRm.js} +1 -1
- package/web-dist/assets/{chunk-MOJQB5TN-nRMfcSHe.js → chunk-MOJQB5TN-g8M_GVaO.js} +1 -1
- package/web-dist/assets/{chunk-OGEWGWER-BbSXfbEB.js → chunk-OGEWGWER-C_80lLFe.js} +1 -1
- package/web-dist/assets/{chunk-PUDLZKDR-Byubn9VY.js → chunk-PUDLZKDR-B73Odmxv.js} +1 -1
- package/web-dist/assets/{chunk-Q4XR5HBZ-DLq-aZ3t.js → chunk-Q4XR5HBZ-D-VkroM1.js} +1 -1
- package/web-dist/assets/{chunk-RYQCIY6F-Dbt66M6V.js → chunk-RYQCIY6F-DmPJ8s-8.js} +1 -1
- package/web-dist/assets/{chunk-V7JOEXUC-DNFTmXz6.js → chunk-V7JOEXUC-BQKrRLYX.js} +1 -1
- package/web-dist/assets/{chunk-VAUOI2AC-QWrszv3X.js → chunk-VAUOI2AC-DRKYvsWa.js} +1 -1
- package/web-dist/assets/{chunk-VR4S4FIN-CJdyjwam.js → chunk-VR4S4FIN-DaMMs6V-.js} +1 -1
- package/web-dist/assets/{chunk-WYO6CB5R-D_786t-3.js → chunk-WYO6CB5R-CQAWjeZH.js} +1 -1
- package/web-dist/assets/{chunk-XXDRQBXY-Bd_2jBj_.js → chunk-XXDRQBXY-DJvt-abB.js} +1 -1
- package/web-dist/assets/{chunk-ZGVPDNZ5-DklPG-LG.js → chunk-ZGVPDNZ5-B1v24MrX.js} +1 -1
- package/web-dist/assets/classDiagram-OUVF2IWQ-BwIDe0nq.js +1 -0
- package/web-dist/assets/classDiagram-v2-EOCWNBFH-BwIDe0nq.js +1 -0
- package/web-dist/assets/{cose-bilkent-JH36ORCC-C4MtSvEs.js → cose-bilkent-JH36ORCC-CeNttASr.js} +1 -1
- package/web-dist/assets/{cynefin-VYW2F7L2-Dr0CmMQz.js → cynefin-VYW2F7L2-ClJzZ-Yx.js} +1 -1
- package/web-dist/assets/{cynefinDiagram-TSTJHNR4-BpHXKyDO.js → cynefinDiagram-TSTJHNR4-BCrL5Bu_.js} +1 -1
- package/web-dist/assets/{dagre-VKFMJZFB-CWAtKn43.js → dagre-VKFMJZFB-DO7qy19A.js} +1 -1
- package/web-dist/assets/{diagram-FQU43EPY-B_6PhpPG.js → diagram-FQU43EPY-KPbJc2w8.js} +1 -1
- package/web-dist/assets/{diagram-G47NLZAW-DPNrX-3a.js → diagram-G47NLZAW-9tqHFXzf.js} +1 -1
- package/web-dist/assets/{diagram-NH7WQ7WH-BL4nqAUm.js → diagram-NH7WQ7WH-BUbmU0cY.js} +1 -1
- package/web-dist/assets/{diagram-OA4YK3LP-CcFbtuCf.js → diagram-OA4YK3LP-QmMo96Qi.js} +1 -1
- package/web-dist/assets/{diagram-WEI45ONY-Bkl0nXre.js → diagram-WEI45ONY-BYAyhW16.js} +1 -1
- package/web-dist/assets/{dist-krVNNn4H.js → dist-Cewx01EF.js} +1 -1
- package/web-dist/assets/{ebnfDiagram-CCIWWBDH-C_51YQqw.js → ebnfDiagram-CCIWWBDH-BIMiEDl1.js} +1 -1
- package/web-dist/assets/{erDiagram-Q63AITRT-D8oBhiQB.js → erDiagram-Q63AITRT-aLYQSs2d.js} +1 -1
- package/web-dist/assets/eventmodeling-45OFAUF4-jYGf30I4.js +1 -0
- package/web-dist/assets/flowDiagram-23GEKE2U-uJJwGAew.js +1 -0
- package/web-dist/assets/{ganttDiagram-NO4QXBWP-BOJJvkcQ.js → ganttDiagram-NO4QXBWP-Bu6_kuAX.js} +1 -1
- package/web-dist/assets/{gitGraph-TEB2WS4Q-DrZGs6X0.js → gitGraph-TEB2WS4Q-yz2DuHDq.js} +1 -1
- package/web-dist/assets/{gitGraphDiagram-IHSO6WYX-C0pqDVhD.js → gitGraphDiagram-IHSO6WYX-BXfbKaor.js} +1 -1
- package/web-dist/assets/{index-BwC7xvWu.js → index-DS1RBTF4.js} +37 -37
- package/web-dist/assets/index-DX1b-Y8G.css +2 -0
- package/web-dist/assets/{info-DKCQHKI2-0OcIuVxc.js → info-DKCQHKI2-BdItukhP.js} +1 -1
- package/web-dist/assets/{infoDiagram-FWYZ7A6U-CRAc-N7_.js → infoDiagram-FWYZ7A6U-DXrq8wS3.js} +1 -1
- package/web-dist/assets/{ishikawaDiagram-FXEZZL3T-D_bHCCxh.js → ishikawaDiagram-FXEZZL3T-iM2fPeJv.js} +1 -1
- package/web-dist/assets/{journeyDiagram-5HDEW3XC-Dbvh7D1e.js → journeyDiagram-5HDEW3XC-DNa58xSH.js} +1 -1
- package/web-dist/assets/{kanban-definition-HUTT4EX6-CxOWhFpB.js → kanban-definition-HUTT4EX6-DhSaBCRv.js} +1 -1
- package/web-dist/assets/{line-BGqbhtvK.js → line-CQn0ApgD.js} +1 -1
- package/web-dist/assets/{linear-DRvKJ3WJ.js → linear-DMSasryg.js} +1 -1
- package/web-dist/assets/{mermaid-parser.core-C5lIBam8.js → mermaid-parser.core-BiJ3pVQT.js} +3 -3
- package/web-dist/assets/{mermaid.core-ChLUqNEE.js → mermaid.core-8ofZrJs5.js} +3 -3
- package/web-dist/assets/{mindmap-definition-LN4V7U3C-BfPv_GOf.js → mindmap-definition-LN4V7U3C-BLr4IGuI.js} +1 -1
- package/web-dist/assets/{packet-7NZHBO7P-CH3B2i7_.js → packet-7NZHBO7P-D15LrSHU.js} +1 -1
- package/web-dist/assets/{pegDiagram-2B236MQR-DLuCHUaK.js → pegDiagram-2B236MQR-C9IcvZ_z.js} +1 -1
- package/web-dist/assets/{pie-RZYD4A2V-C-hDlp0h.js → pie-RZYD4A2V-79-1CSta.js} +1 -1
- package/web-dist/assets/{pieDiagram-ENE6RG2P-CKVu3PTC.js → pieDiagram-ENE6RG2P-dm_ORKO7.js} +1 -1
- package/web-dist/assets/{quadrantDiagram-ABIIQ3AL--tZ3JdyA.js → quadrantDiagram-ABIIQ3AL-vQkbT0Ej.js} +1 -1
- package/web-dist/assets/{radar-I7S5WNFK-C10EMwWx.js → radar-I7S5WNFK-B8xvrM0r.js} +1 -1
- package/web-dist/assets/{railroad-3IZDKUUU-BYegvtJS.js → railroad-3IZDKUUU-G0rN-YuN.js} +1 -1
- package/web-dist/assets/railroad-abnf-AHOZXSZD-BaCc6741.js +1 -0
- package/web-dist/assets/railroad-ebnf-EBAXGLYW-cUMY4WQi.js +1 -0
- package/web-dist/assets/railroad-peg-LSFZ7HO6-JS2RjlNP.js +1 -0
- package/web-dist/assets/{railroadDiagram-RFXS5EU6-CfpRdkA8.js → railroadDiagram-RFXS5EU6-BtGt9H2_.js} +1 -1
- package/web-dist/assets/{requirementDiagram-TGXJPOKE-CUajgDbc.js → requirementDiagram-TGXJPOKE-oHUUvJjC.js} +1 -1
- package/web-dist/assets/{sankeyDiagram-HTMAVEWB-DRs5oKTx.js → sankeyDiagram-HTMAVEWB-BoO0DzUn.js} +1 -1
- package/web-dist/assets/{sequenceDiagram-DBY2YBRQ-BTeEqLFC.js → sequenceDiagram-DBY2YBRQ-B344KPVn.js} +1 -1
- package/web-dist/assets/{src-Cf1DXZ3M.js → src-BygbIYKj.js} +1 -1
- package/web-dist/assets/{stateDiagram-2N3HPSRC-BPcqMj-B.js → stateDiagram-2N3HPSRC-DMTN-MuE.js} +1 -1
- package/web-dist/assets/stateDiagram-v2-6OUMAXLB-4HUOVSEd.js +1 -0
- package/web-dist/assets/{swimlanes-5IMT3BWC-CJTd58TJ.js → swimlanes-5IMT3BWC-DQEhwI0k.js} +1 -1
- package/web-dist/assets/swimlanesDiagram-G3AALYLV-PPFuhngt.js +8 -0
- package/web-dist/assets/{timeline-definition-FHXFAJF6-CqbaBVpe.js → timeline-definition-FHXFAJF6-CUoCgDT7.js} +1 -1
- package/web-dist/assets/{treeView-QDETBFTQ-B2OQ8r59.js → treeView-QDETBFTQ-BTHFGWtv.js} +1 -1
- package/web-dist/assets/{treemap-6X3UGDF4-DGpAdWTA.js → treemap-6X3UGDF4-BI2j1PYm.js} +1 -1
- package/web-dist/assets/{vennDiagram-L72KCM5P-BAS_eWHm.js → vennDiagram-L72KCM5P-Cc3sJIb2.js} +1 -1
- package/web-dist/assets/{wardley-OPB4EBWU-DpNHIH3W.js → wardley-OPB4EBWU-kYXYWMgL.js} +1 -1
- package/web-dist/assets/{wardleyDiagram-EHGQE667-2N7X1vj8.js → wardleyDiagram-EHGQE667-KHMHPO99.js} +1 -1
- package/web-dist/assets/{xychartDiagram-FW5EYKEG-C8mfLCei.js → xychartDiagram-FW5EYKEG-DzSZk-Dq.js} +1 -1
- package/web-dist/index.html +2 -2
- package/web-dist/assets/architecture-TIHT7OUA-CXyjbDft.js +0 -1
- package/web-dist/assets/channel-uFMfT294.js +0 -1
- package/web-dist/assets/classDiagram-OUVF2IWQ-D1koMbqS.js +0 -1
- package/web-dist/assets/classDiagram-v2-EOCWNBFH-D1koMbqS.js +0 -1
- package/web-dist/assets/eventmodeling-45OFAUF4-tWFB9ALb.js +0 -1
- package/web-dist/assets/flowDiagram-23GEKE2U-Dz_Opd7B.js +0 -1
- package/web-dist/assets/index-CuXKWysP.css +0 -2
- package/web-dist/assets/railroad-abnf-AHOZXSZD-DLmknJDm.js +0 -1
- package/web-dist/assets/railroad-ebnf-EBAXGLYW-BoZF0VpA.js +0 -1
- package/web-dist/assets/railroad-peg-LSFZ7HO6-Dib7YVqg.js +0 -1
- package/web-dist/assets/stateDiagram-v2-6OUMAXLB-DiV9dOER.js +0 -1
- package/web-dist/assets/swimlanesDiagram-G3AALYLV-BDeobZmn.js +0 -8
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-8ofZrJs5.js","assets/chunk-Y2CYZVJY-DsF7k-Jl.js","assets/src-BygbIYKj.js","assets/chunk-WYO6CB5R-CQAWjeZH.js","assets/chunk-ICXQ74PX-C4exiYRm.js","assets/dist-Cewx01EF.js","assets/chunk-VAUOI2AC-DRKYvsWa.js","assets/chunk-HOUHSVGY-BDIBDR-8.js","assets/chunk-Q4XR5HBZ-D-VkroM1.js","assets/chunk-7BUUIJ7U-Bb538aSH.js","assets/chunk-OGEWGWER-C_80lLFe.js","assets/chunk-C7G6YPKG-D7Me5JQU.js","assets/chunk-ZGVPDNZ5-B1v24MrX.js","assets/rough.esm-CSKSodPl.js","assets/chunk-52WLFC77-BsibludT.js","assets/line-CQn0ApgD.js","assets/path-BWPyau1x.js","assets/array-BifhSqXX.js","assets/chunk-FWX5IMBZ-CjqOt5Jn.js","assets/chunk-ZIRB5QZD-C6fEPe3t.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));(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 l=o((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}}}})),u=o(((e,t)=>{t.exports=l()})),d=o((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 F(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 I=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)},ee={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=ee,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:F}},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,I)}catch(e){I(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`})),f=o(((e,t)=>{t.exports=d()})),p=o((e=>{var t=f();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},a=Symbol.for(`react.portal`);function o(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:``+r,children:e,containerInfo:t,implementation:n}}var s=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function c(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 o(e,t,null,r)},e.flushSync=function(e){var t=s.T,n=i.p;try{if(s.T=null,i.p=2,e)return e()}finally{s.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=c(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=c(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=c(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=c(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 s.H.useFormState(e,t,n)},e.useFormStatus=function(){return s.H.useHostTransitionStatus()},e.version=`19.2.7`})),m=o(((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=p()})),h=o((e=>{var t=u(),n=f(),r=m();function i(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 a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(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 s(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 c(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 l(e){if(o(e)!==e)throw Error(i(188))}function d(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function p(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=p(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 F=Array.isArray,I=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ee=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te={pending:!1,data:null,method:null,action:null},ne=[],re=-1;function ie(e){return{current:e}}function ae(e){0>re||(e.current=ne[re],ne[re]=null,re--)}function oe(e,t){re++,ne[re]=e.current,e.current=t}var se=ie(null),ce=ie(null),le=ie(null),ue=ie(null);function de(e,t){switch(oe(le,t),oe(ce,e),oe(se,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}}ae(se),oe(se,e)}function fe(){ae(se),ae(ce),ae(le)}function pe(e){e.memoizedState!==null&&oe(ue,e);var t=se.current,n=qd(t,e.type);t!==n&&(oe(ce,e),oe(se,n))}function me(e){ce.current===e&&(ae(se),ae(ce)),ue.current===e&&(ae(ue),rp._currentValue=te)}var he,ge;function _e(e){if(he===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);he=t&&t[1]||``,ge=-1<e.stack.indexOf(`
|
|
3
3
|
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
4
4
|
`+he+e+ge}var ve=!1;function ye(e,t){if(!e||ve)return``;ve=!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(`
|
|
@@ -179,41 +179,41 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
|
|
|
179
179
|
`?(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 kT=/^(\s*\d+\t)([\s\S]*)$/,AT=/^\s*\d+$/;function jT(e){let t=0,n=0,r=0;for(let i of e)i.trim()&&(t++,kT.test(i)?(n++,r++):AT.test(i)&&n++);return t>0&&n===t&&r>0}function MT(e){return e.replace(/[&<>"']/g,e=>e===`&`?`&`:e===`<`?`<`:e===`>`?`>`:e===`"`?`"`:`'`)}var NT=`frizz-code-gutter`;function PT(e,t){let n=e.split(`
|
|
180
180
|
`);if(!jT(n))return TT(e,t);let r=[],i=[];for(let e of n){let t=kT.exec(e);t?(r.push(t[1]),i.push(t[2])):e.trim()&&AT.test(e)?(r.push(e),i.push(``)):(r.push(``),i.push(e))}let a=OT(TT(i.join(`
|
|
181
181
|
`),t));return r.map((e,t)=>(e?`<span class="${NT}">${MT(e)}</span>`:``)+(a[t]??``)).join(`
|
|
182
|
-
`)}var FT=/^[a-zA-Z]:[\\/](?![\\/])/,IT=/^(?:cursor|vscode|vscode-insiders|windsurf):\/\/file\/(.*)$/i;function LT(e){try{return decodeURIComponent(e)}catch{return e}}function RT(e){if(e===`/`||e.startsWith(`/?`)||e.startsWith(`/#`))return!0;let t=e.replace(/[?#].*$/u,``);if(tm(t))return!0;let n=im(t).split(`/`)[1]??``;return Zp.has(n)}function zT(e){let t=e?.trim();if(!t)return null;let n=LT(t);if(FT.test(n))return{display:n,filePath:n};if(n.startsWith(`/`)&&!n.startsWith(`//`)&&!RT(n)){let e=LT(t.replace(/[?#].*$/u,``));return{display:e,filePath:e}}let r=IT.exec(t);if(r){let e=LT(r[1].replace(/[?#].*$/u,``)).replace(/^\/+/,``);if(!e)return null;if(FT.test(e))return{display:e,filePath:e};let t=`/${e}`;return{display:t,filePath:t}}if(!/^file:/i.test(t))return null;try{let e=new URL(t);if(e.protocol!==`file:`)return null;if(e.hostname&&e.hostname!==`localhost`)return{display:t};let n=LT(e.pathname);return{display:n,filePath:n}}catch{return{display:t}}}function BT(e){return`${sm()}/local-image?path=${encodeURIComponent(e)}`}var VT=/\.(?:png|jpe?g|gif|webp)$/i;function HT(e){return e.filePath&&VT.test(e.filePath)?BT(e.filePath):null}var UT=/\.(?:mp4|m4v|webm|mov)$/i;function WT(e){return UT.test(e)}var GT=/\.(?:md|mdx|markdown)$/i;function KT(e){return GT.test(e.trim().replace(/:\d+(?::\d+)?$/,``))}function qT(e,t,n){let r=e?.trim();if(!r||/^[a-z][a-z0-9+.-]*:/i.test(r)||/^[\\/#?]/.test(r))return null;let i=LT(r.replace(/[?#].*$/u,``));if(!i)return null;let a=i===`~`||/^~[\\/]/.test(i);if(a&&!(n&&gh(n)))return null;let o=a?n:t;return gh(o)?bh(o,a?i.slice(2):i):null}function JT(e){return Sh(e)||`/`}function YT(e){return[KT(e)?`localMarkdown`:`localFile`,e]}function XT(e){let t=KT(e);return{queryKey:YT(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 ZT=2e3,QT=new Map,$T=12;function eE(e,t){let n=QT.get(e);if(n&&n.raw===t)return n.html;let r=PT(t,vT(e));if(QT.set(e,{raw:t,html:r}),QT.size>$T){let e=QT.keys().next();e.done||QT.delete(e.value)}return r}function tE(e){let t=globalThis.requestIdleCallback;t?t(e,{timeout:500}):setTimeout(e,0)}function nE(e,t){e.prefetchQuery(XT(t)).then(()=>{let n=e.getQueryData(XT(t).queryKey);!n?.markdown||KT(t)||tE(()=>eE(n.path,n.markdown))}).catch(()=>{})}var rE=null,iE=null,aE=null,oE=null,sE=0,cE=0,lE=!1,uE=!1,dE=!1,fE=new Map,pE=new Map,mE=0,hE=new SC(()=>Iee(),e=>{iE&&OC(iE,e)}),gE=35e3;function Nee(){return`${location.origin.replace(/^http/,`ws`)}${sm()}/ws`}var _E,vE=!1;function yE(){_E=tm(),vE=!0}function Pee(e){return vE&&_E===e}function bE(){if(rE||dE)return;X.connection!==`open`&&(X.connection=`connecting`),yE();let e=new WebSocket(Nee()),t=tm();rE=e,lE=!1,cE=Date.now(),e.onopen=()=>{uE=!0,cE=Date.now(),X.connection=`open`,X.socketTranscripts=!0,aE&&=(clearTimeout(aE),null)},e.onmessage=n=>{if(!(rE!==e||t!==tm())){cE=Date.now();try{let e=JSON.parse(n.data),t=Ree(e);t&&(sE=0),t&&e.t===`event`&&e.event.type===`board`&&(lE=!0,mE++,Vee())}catch(e){console.error(`bad /ws message`,e)}}},e.onerror=()=>{},e.onclose=()=>{rE===e&&(rE=null,Fee())},Lee()}function xE(){let e=rE;if(rE=null,lE=!1,e){e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close()}catch{}}}function Fee(){if(hE.reset(),!uE){wE();return}sE++,X.connection=sE>3?`closed`:`connecting`,SE()}function SE(e=!1){if(aE){if(!e)return;clearTimeout(aE),aE=null}let t=e?0:Math.min(1e3*2**Math.min(sE-1,4),15e3);aE=setTimeout(()=>{aE=null,bE()},t)}function Iee(){hE.reset(),xE(),bE()}function Lee(){if(oE)return;oE=setInterval(()=>{rE&&Date.now()-cE>gE&&CE()},1e4);let e=()=>{dE||(!rE||Date.now()-cE>gE)&&CE(!0)};window.addEventListener(`focus`,e),window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,()=>{document.hidden||e()})}function CE(e=!1){if(!dE){if(xE(),hE.reset(),!uE){wE();return}sE++,X.connection=sE>3?`closed`:`connecting`,SE(e)}}function wE(e){dE||(dE=!0,e&&(X.socketBoardFallback=e,X.socketTranscriptFallbacks={}),xE(),X.socketTranscripts=!1,VC(iE??void 0))}function Ree(e){switch(e.t){case`event`:return hE.handle(e.event),e.event.type===`board`&&(X.socketBoardFallback=null),!0;case`transcript`:return iE?.setQueryData([`transcript`,e.slug],t=>{let n=t,r=e.page?iw(n,{...e.page,messages:e.messages,editedFiles:n?.editedFiles}):aw(n,e.messages);return{...r,messages:QC(t?.messages,GC(t?.messages,r.messages))}}),delete X.socketTranscriptFallbacks[e.slug],!0;case`file-changed`:return iE?.invalidateQueries({queryKey:YT(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}),wE({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},qee(e.slug,e.retryAfterMs),!1;case`hb`:return!0}}function TE(e){lE&&rE&&rE.readyState===WebSocket.OPEN&&rE.send(JSON.stringify(e))}var zee=6,Bee=700,EE=null;function Vee(){for(let e of Object.keys(X.socketTranscriptFallbacks))delete X.socketTranscriptFallbacks[e];for(let e of kE.keys())jE(e);AE.clear(),EE&&=(clearTimeout(EE),null);let e=[...fE.keys()],t=()=>{EE=null;for(let t of e.splice(0,zee))fE.has(t)&&!X.socketTranscriptFallbacks[t]&&TE({t:`sub`,topic:`transcript`,slug:t});e.length&&(EE=setTimeout(t,Bee))};t();for(let e of pE.keys())TE({t:`sub`,topic:`file`,path:e}),mE>1&&iE?.invalidateQueries({queryKey:YT(e)})}function DE(e){let t=(fE.get(e)??0)+1;fE.set(e,t),t===1&&!X.socketTranscriptFallbacks[e]&&TE({t:`sub`,topic:`transcript`,slug:e})}function OE(e){let t=(fE.get(e)??0)-1;t<=0?(fE.delete(e),TE({t:`unsub`,topic:`transcript`,slug:e})):fE.set(e,t)}function Hee(e){let t=(pE.get(e)??0)+1;pE.set(e,t),t===1&&TE({t:`sub`,topic:`file`,path:e})}function Uee(e){let t=(pE.get(e)??0)-1;t<=0?(pE.delete(e),TE({t:`unsub`,topic:`file`,path:e})):pE.set(e,t)}function Wee(e){X.socketTranscriptFallbacks[e]&&(jE(e),delete X.socketTranscriptFallbacks[e],fE.has(e)&&TE({t:`sub`,topic:`transcript`,slug:e}))}var Gee=5,Kee=400,kE=new Map,AE=new Map;function qee(e,t){let n=AE.get(e)??0;if(n>=Gee)return;jE(e);let r=Math.max(1,t)+Math.random()*Kee;kE.set(e,setTimeout(()=>{kE.delete(e),AE.set(e,n+1);let t=X.socketTranscriptFallbacks[e];!t||t.kind!==`read-budget`||(delete X.socketTranscriptFallbacks[e],fE.has(e)&&TE({t:`sub`,topic:`transcript`,slug:e}))},r))}function jE(e){let t=kE.get(e);t&&(clearTimeout(t),kE.delete(e))}function Jee(){fE.clear(),pE.clear(),hE.reset(),xE(),X.connection=`connecting`,yE(),dE?BC():bE()}function Yee(e){iE=e,yE();let t=()=>bE();document.readyState===`complete`?t():window.addEventListener(`load`,t,{once:!0})}function ME(){return gr(X).board}function NE(){return gr(X).board?.projectDir}function PE(){return gr(X).board?.homeDir}function FE(e){return e}function IE(e){let t=gr(X).socketTranscripts;return(0,L.useEffect)(()=>(Hee(e),()=>Uee(e)),[e]),t}function Xee(e){if(!(!e||e.kind!==`session`||e.foreign||!e.sessionId))return{slug:e.id,sessionId:e.sessionId}}function LE(e){let t=Xee(e);if(!(!t||e?.pendingInteraction===!1))return t}function Zee(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 Qee(e){let t=LE(e);return ct({queryKey:t?wC(t.slug,t.sessionId):[`interactions`,`pending`,`unowned`],queryFn:()=>Y.pendingInteractions(t),enabled:t!==void 0,refetchInterval:e=>Zee(e.state.data?.interactions??[]),refetchOnReconnect:!0,refetchOnWindowFocus:!0})}var $ee=7e3,ete=5e3,tte=3,nte=15e3,rte=30*6e4;function ite(e,t,n){let r=Cg(e,t)?.lastActivityAt;if(!r)return 0;let i=Date.parse(r);return Number.isFinite(i)?i>n?0:nte:0}function ate(e,t){let n=t?Date.parse(t):NaN,r=e&&e>0?e:NaN;return!Number.isFinite(n)&&!Number.isFinite(r)?t:new Date(Math.max(Number.isFinite(n)?n:0,Number.isFinite(r)?r:0)).toISOString()}function RE(e,t){let n=qe(),r=gr(X),i=r.socketTranscripts,a=r.socketTranscriptFallbacks[e],o=ct({queryKey:[`transcript`,e],queryFn:async()=>{let t=await Y.threadTranscript({slug:e}),r=n.getQueryData([`transcript`,e]),i=iw(r,t);return{...i,messages:QC(r?.messages,GC(r?.messages,i.messages))}},refetchInterval:t.poll&&!i&&!a?1500:!1,refetchOnWindowFocus:!0,staleTime:t=>ite(X.board,e,t.state.dataUpdatedAt),gcTime:rte});return(0,L.useEffect)(()=>{if(!t.poll&&!i||a)return;let r=!1,s=0,c,l=setInterval(()=>{if(r)return;let t=Cg(X.board,e)?.lastActivityAt,a=n.getQueryState([`transcript`,e]),l=ew(a?.data?.messages);if(!$C(t,ate(a?.dataUpdatedAt,l),ete)){s=0;return}if(l!==c&&(s=0),s>=tte)return;s++,c=l;let u=t?Date.parse(t)-(l?Date.parse(l):0):0;console.warn(`[frizz] transcript watchdog: stale view — self-healing`,{slug:e,lagMs:u,transport:i?`socket`:`poll`,attempt:s}),i&&(OE(e),DE(e)),r=!0,o.refetch().finally(()=>{r=!1})},$ee);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:()=>Wee(e)}}function ote(e,t){return ct({queryKey:[`subAgentTranscript`,e,t],queryFn:()=>Y.subAgentTranscript({slug:e,id:t}),refetchInterval:e=>e.state.data?.state===`running`?2500:!1})}function ste(e,t){return ct({queryKey:[`backgroundShellOutput`,e,t],queryFn:()=>Y.backgroundShellOutput({slug:e,id:t}),refetchInterval:e=>e.state.data?.state===`running`?1500:!1})}function cte(e,t){let n=[...t].sort(),r=ct({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,L.useMemo)(()=>new Map((r.data?.shells??[]).flatMap(e=>e.lines===null?[]:[[e.id,e.lines]])),[r.data])}function lte(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 zE(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 BE(){let e=vg();return e?`/thread/${encodeURIComponent(e)}`:X.routeThreadSlug?`/thread/${encodeURIComponent(X.routeThreadSlug)}`:X.view.startsWith(`status:`)?`/status/${encodeURIComponent(X.view.slice(7))}`:`/`}function VE(e){try{return decodeURIComponent(e)}catch{return null}}function HE(e,t=X.board?.projectSlug){let n=am(e);return n===`/`&&t?nm(t):n}function UE(e){let t=e.match(/^\/thread\/([^/]+)$/);if(t){let e=VE(t[1]);if(e===null){X.routeThreadSlug=null,_g(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,_g(X.drawers.slice(n+1).map(e=>e.id));return}Gh({kind:`thread`,slug:e}),X.routeThreadSlug=e;return}let n=e.match(/^\/status\/([^/]+)$/);if(n){X.routeThreadSlug=null,_g(X.drawers.map(e=>e.id));let e=VE(n[1]);X.view=e===null?`todos`:`status:${e}`;return}X.routeThreadSlug=null,_g(X.drawers.map(e=>e.id)),X.view=`todos`}function WE(e=location.pathname){UE(im(e))}var GE=null;function KE(e){GE=e}function qE(e,t){GE?GE(e,t):typeof location<`u`&&location.assign(e)}function JE(e=typeof history>`u`?null:history.state){let t=e&&typeof e==`object`?e.idx:void 0;return typeof t==`number`&&t>0}function YE(e){return WE(),pr(X,()=>{let t=rg();if(lm(im())!==null)return;let n=HE(BE());n!==location.pathname&&e(n,{replace:!BE().startsWith(`/thread/`)&&!t})})}function XE(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 ZE=`frizz-sidebar-seen:`;function QE(e){try{return localStorage.getItem(ZE+(e??``))===`1`}catch{return!1}}function ute(e,t){try{localStorage.setItem(ZE+(e??``),t?`1`:`0`)}catch{}}function $E(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 eD(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 tD(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var nD=(e,t)=>Math.abs(e-t)<1.01,rD=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},iD,aD=()=>{if(iD!==void 0)return iD;if(typeof navigator>`u`)return iD=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return iD=!0;let e=navigator.maxTouchPoints;return iD=navigator.platform===`MacIntel`&&e!==void 0&&e>0},oD=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},sD=e=>e,cD=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},dte=(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(oD(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(oD(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},lD={passive:!0},fte=typeof window>`u`?!0:`onscrollend`in window,pte=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&fte,o=0,s=a?null:rD(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,lD),a&&r.addEventListener(`scrollend`,u,lD),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},uD=(e,t)=>pte(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),dD=(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`]},fD=(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})},pD=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:sD,rangeExtractor:cD,onChange:()=>{},measureElement:dD,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=eD(()=>(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,!(!aD()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,lD),e.addEventListener(`touchend`,n,lD),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&&(aD()&&(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=eD(()=>[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=eD(()=>[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=$E(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=eD(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=gD(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=eD(()=>{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=eD(()=>[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 tD(t[mD(0,t.length-1,r?e=>n[e*2]:e=>tD(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&&(aD()&&(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&&nD(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()}},mD=(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 hD(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 gD(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=hD(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=mD(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 _D=typeof document<`u`?L.useLayoutEffect:L.useEffect;function vD({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=L.useReducer(e=>e+1,0)[1],a=L.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,Tn.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[c]=L.useState(()=>{let e=new pD(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),_D(()=>c._didMount(),[]),_D(()=>c._willUpdate()),_D(()=>{o(c)}),c}function yD(e){return vD({observeElementRect:dte,observeElementOffset:uD,scrollToFn:fD,...e})}var bD=3600*1e3,xD=24*bD,SD=[{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`}],CD=new Set(SD.map(e=>e.value));function wD(e){return typeof e==`string`&&CD.has(e)}function TD(e){return ED(e).label}function ED(e){return SD.find(t=>t.value===e)??SD[2]}function DD(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`?bD:e===`1d`?xD:e===`3d`?3*xD:7*xD)).toISOString()}function OD(e){return String(e).padStart(2,`0`)}function kD(e){return`${e.getFullYear()}-${OD(e.getMonth()+1)}-${OD(e.getDate())}T${OD(e.getHours())}:${OD(e.getMinutes())}`}function AD(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 jD(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)/xD),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 MD(e,t){if(!Number.isFinite(Date.parse(e)))return null;let n=jD(e,t);return n?n.replace(/^(Today|Tomorrow)/,e=>e.toLowerCase()):null}function mte(e,t=Date.now()){let n=MD(e,t);return n?`Snoozed until ${n}`:null}var hte=120;function ND(e,t=hte){let n=e.trim().replace(/\s+/g,` `);return n.length>t?`${n.slice(0,t-1)}…`:n}function PD(e,t,n=Date.now()){let r=t?.trim();if(!r)return mte(e,n);let i=FD(e,n);return i?`${i} — then: ${ND(r)}`:null}function FD(e,t=Date.now()){let n=MD(e,t);return n?`Auto-snoozed until ${n}`:null}var ID=`frizz.prefs.v1`;function gte(e,t){return e===`fifo`||e===`lifo`?e:t}function LD(e){let t={compactDiffs:!0,snoozePreset:`1d`,queueOrder:`fifo`,railFilesCollapsed:!1,dictation:!0,diffsRedefaulted:!0};try{if(!e)return t;let n=JSON.parse(e);return n.diffsRedefaulted||=(n.compactDiffs=!0,!0),{...t,...n,snoozePreset:wD(n.snoozePreset)?n.snoozePreset:t.snoozePreset,queueOrder:gte(n.queueOrder,t.queueOrder),railFilesCollapsed:typeof n.railFilesCollapsed==`boolean`?n.railFilesCollapsed:t.railFilesCollapsed,dictation:typeof n.dictation==`boolean`?n.dictation:t.dictation}}catch{return t}}function RD(){try{return LD(typeof localStorage>`u`?null:localStorage.getItem(ID))}catch{return LD(null)}}var zD=fr(RD());pr(zD,()=>{try{typeof localStorage<`u`&&localStorage.setItem(ID,JSON.stringify(zD))}catch{}});function BD(e){return e.kind===`session`&&e.foreign!==!0&&e.runtime===`exited`}var VD=gu.options,HD={planning:`text-planning border-planning/40`,planned:`text-planned border-planned/40`,active:`text-active-status border-active-status/40`,"needs-human":`text-needs-human border-needs-human/40`,blocked:`text-blocked border-blocked/40`,done:`text-zinc-400 border-zinc-400/40`,dismissed:`text-dismissed border-dismissed/40`,archived:`text-slate-500 border-slate-500/40`};function UD(e){return e.foreign===!0&&e.title.trim()?e.title.trim():XD(e)?KD:e.aiTitle?.trim()&&!WD(e)?GD(e.aiTitle):e.backend===`codex`&&e.titleAuto===!0&&!e.aiTitle?.trim()?qD:e.titleAuto===!1&&e.title.trim()?e.title:e.title.trim()&&!(e.titleAuto===!0&&e.title.trim()===e.id)?e.titleAuto===!0?GD(e.title):e.title.trim():e.titleAuto===!0?qD:e.id}function WD(e){return e.titleLocked??e.titleAuto===!1}function GD(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 KD=`Spinning up a thread…`,qD=`Untitled thread`,JD=6e4,YD=15e3;function XD(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<YD}let t=Date.parse(e.spawnedAt??``);return Number.isFinite(t)&&Date.now()-t<JD}function ZD(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 QD(e){if(vf(e))return ZD(e);let t=Date.parse(e.lastAssistantAt??``);return Number.isFinite(t)?t:ZD(e)}function $D(e){return vf(e)?e.lastActivityAt??e.spawnedAt:e.lastAssistantAt??e.lastActivityAt??e.spawnedAt}function eO(e){return[...e].sort((e,t)=>{let n=Sf(e);if(n!==Sf(t))return n?-1:1;let r=QD(t)-QD(e);return r===0?e.id.localeCompare(t.id):r})}function tO(e){return[...e].sort((e,t)=>{let n=QD(t)-QD(e);return n===0?e.id.localeCompare(t.id):n})}function nO(e,t=`fifo`){let n=t===`lifo`?-1:1;return[...e].sort((e,t)=>{let r=(QD(e)-QD(t))*n;return r===0?e.id.localeCompare(t.id):r})}function rO(e){return uf(e)}function iO(e){return e.filter(e=>e.kind===`session`&&e.foreign===!0)}function aO(e){return e.kind===`session`&&e.foreign!==!0&&typeof e.pinnedAt==`string`}function oO(e){return e.needsYou===!0&&df(e)}function sO(e){return e.runtime===`turn-idle`&&e.awaitingBackground===!0&&!ff(e)}function cO(e){return sO(e)?(e.bgShells??[]).some(e=>e.state===`running`)?!0:lO(e):!1}function lO(e){return(e.watches??[]).some(e=>e.kind===`github`&&e.state===`armed`&&e.github?.checks===`running`&&e.github.state===`open`&&!(e.github.running===0&&(e.github.gated??0)>0))}function uO(e){return e.waitStatus===`working`&&e.runtime===`turn-idle`}function dO(e){return e.runtime===`turn-idle`&&ff(e)}function fO(e){return(e.questions?.length??0)>0&&gO(e)===`working`}function pO(e){return e.runtime===`turn-idle`?mO(e):!1}function mO(e){return(e.watches??[]).some(e=>e.kind===`github`&&e.state===`armed`)?!0:e.lastFence?.kind===`awaiting`&&e.lastFence.hints.some(e=>(e.kind===`pr`||e.kind===`issue`)&&e.value.trim()!==``)}function hO(e){return e.runtime===`turn-idle`?(e.watches??[]).some(e=>e.kind===`timer`&&e.state===`armed`):!1}function gO(e){let t=vf(e);return e.state===`archived`&&!t?`archived`:gf(e)!==void 0&&_f(e)?`snoozed`:e.actionableInteraction||e.pendingAsk||e.pendingQuestion||e.runtime===`perm-prompt`||e.humanBlocked||e.status===`needs-human`?`needs-input`:t&&!oO(e)&&!sO(e)?`working`:(e.questions?.length??0)>0?`needs-input`:_f(e)?`snoozed`:e.limitPause&&e.foreign!==!0?`limit`:e.lastFence?.kind===`done`&&df(e)?`done`:pO(e)?`pr`:hO(e)&&!uO(e)?`timer`:cO(e)?`background`:BD(e)?`stalled`:`rest`}function _O(e){let t=gO(e);return t===`stalled`||t===`limit`}function vO(e,t=`fifo`){let n=e.filter(bf);return[...nO(e.filter(e=>!bf(e)),t),...tO(n)]}function yO(e){return{running:e.filter(bf),rested:e.filter(e=>!bf(e))}}function bO(e,t=`fifo`){let n={pinned:[],active:[],snoozed:[],inactive:[]};for(let t of e){if(t.kind===`session`&&t.foreign===!0)continue;if(aO(t)){n.pinned.push(t);continue}let e=yf(t);e&&n[e].push(t)}return n.pinned.sort((e,t)=>(e.pinnedAt??``).localeCompare(t.pinnedAt??``)||e.id.localeCompare(t.id)),n.active=vO(n.active,t),n.snoozed=tO(n.snoozed),n.inactive=tO(n.inactive),n}function xO(e,t){for(let n of[e,t])if(n&&Number.isFinite(Date.parse(n)))return n}function SO(e,t=Date.now()){let n=CO(e,t);return n&&`Last active ${n}`}function CO(e,t=Date.now()){let n=EO(e,t);return n===null||n===wO?n:`${n} ago`}var wO=`just now`;function TO(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 EO(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?wO:TO(r)}function DO(e,t=Date.now()){let n=e?Date.parse(e):NaN;if(!Number.isFinite(n)||!Number.isFinite(t))return null;let r=Math.floor((n-t)/1e3);return r<=0?null:TO(r)}function OO(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?wO:`${TO(r)} ago`}function kO(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 AO(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 jO=3e4,MO=new Set,NO=Date.now(),PO;function FO(){NO=Date.now();for(let e of MO)e();IO()}function IO(){if(MO.size===0)return;let e=jO-NO%jO;PO=setTimeout(FO,e||jO)}function _te(e){return MO.add(e),MO.size===1&&(NO=Date.now(),IO()),()=>{MO.delete(e),MO.size===0&&PO&&(clearTimeout(PO),PO=void 0)}}function LO(){return NO}function RO(){return(0,L.useSyncExternalStore)(_te,LO,LO)}function zO({size:e=15,children:t}){let n=(0,R.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 15 15`,"aria-hidden":!0,className:`block text-muted-85`,children:[(0,R.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,R.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,R.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:`50`,to:`0`,dur:`1.1s`,repeatCount:`indefinite`})})]});return t==null||t===!1?n:(0,R.jsxs)(`span`,{className:`relative inline-block`,style:{width:e,height:e},children:[n,(0,R.jsx)(`span`,{className:`absolute inset-px flex items-center justify-center`,children:t})]})}function BO(e){return e===`running`}function vte(e,t){return e===`pending`&&t===`background`}var VO=2e3;function HO(e,t){return e===`pending`&&t===void 0}function yte(e,t,n,r){if(!HO(e,t))return!1;let i=n?Date.parse(n):NaN;return Number.isFinite(i)?r-i>=VO:!0}function UO(e){return e?.split(`
|
|
183
|
-
`).find(e=>e.trim())?.trim().replace(/\s+/g,` `)||void 0}function bte(e,t){if(e.name===`Interrupt process`||e.status===`cancelled`||e.backgroundState!==`background`)return;let n=new Set([UO(e.desc),UO(e.detail),UO(e.command)].filter(e=>!!e));if(n.size===0)return;let r=t.filter(e=>n.has(UO(e.label)??``));return r.some(e=>e.state===`running`)?`running`:r.some(e=>e.state===`stale`)?`stale`:void 0}function WO(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 GO(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 KO(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 qO(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 JO(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?KO(Math.max(0,t-n)):``}function YO(e){if(!Number.isFinite(e)||e<0)return``;let t=Math.floor(e/6e4);return t<1?`<1m`:GO(t)}function xte(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 XO(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?GO(Math.floor((t-n)/6e4)):``}function ZO(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`:`${GO(r)} ago`}var QO={fgSuccess:`var(--gh-fg-success)`,bgSuccessEmphasis:`var(--gh-bg-success-emphasis)`,fgDanger:`var(--gh-fg-danger)`,bgDangerEmphasis:`var(--gh-bg-danger-emphasis)`,fgDone:`var(--gh-fg-done)`,bgDoneEmphasis:`var(--gh-bg-done-emphasis)`,fgAttention:`var(--gh-fg-attention)`,fgNeutral:`var(--gh-fg-neutral)`,bgNeutralEmphasis:`var(--gh-bg-neutral-emphasis)`,onEmphasis:`var(--gh-on-emphasis)`},$O=`text-[color:var(--gh-danger-link-fg)] decoration-[color:color-mix(in_srgb,var(--gh-danger-link)_30%,transparent)] hover:decoration-[color:var(--gh-danger-link)]`,ek=`shrink-0 text-[11px] leading-none text-muted-45`,tk=`frizz-kind-tag petite-caps shrink-0 text-[9.5px] text-muted-45`,nk=`flex w-[9px] shrink-0 justify-center`,rk=`block h-1.5 w-1.5 rounded-full bg-muted/30`,ik=`stale — no recent output`,ak=`block h-1.5 w-1.5 rounded-full border border-muted/45`,ok=`rested — it stopped, but the work it launched is still running`,sk=`stale — its process has exited, but no completion was reported`,ck={AGENT:`Open sub-agent transcript`,SHELL:`Open background shell output`,GITHUB:`Open this pull request on GitHub`};function lk(e){if(!(typeof e!=`number`||!Number.isFinite(e)||e<0))return e===1?`1 line`:`${fk(e)??`0`} lines`}function uk(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 dk(e){if(e)return e.state===`open`?e.comments>0?`${e.comments} comment${e.comments===1?``:`s`}`:void 0:e.state}function fk(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 pk={running:`Stop — end this operation and everything it spawned, then clear the row`,settled:`Clear — stop tracking this finished operation`},mk={running:`Stop`,settled:`Clear`},hk={AGENT:`sub-agent`,SHELL:`background shell`,GITHUB:`PR watcher`};function gk(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 _k=e=>e.state===`running`||e.state===`stale`||e.state===`rested`;function vk(e,t){return t===`card`?e.filter(_k):t===`rail`?e.filter(e=>!!e.id&&_k(e)):e}var yk=e=>{let t=e.launchId??e.id;return[...t?[`id:${t}`]:[],...e.command?[`cmd:${e.command}`]:[],`launch:${e.label}\u0000${e.startedAt??``}`]};function bk(e,t){let n=[...e],r=new Set(n.flatMap(yk));for(let e of t)yk(e).some(e=>r.has(e))||n.push(e);return n}function xk({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=BO(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=JO(a,RO()),b=Math.min(Math.max((i??1)-1,0),4)*13,x=p?`running`:`settled`,S=ck[e],C=f??(g?S:void 0),w=n===`rested`?(0,R.jsx)(`span`,{className:ak,title:ok}):(0,R.jsx)(`span`,{className:rk,title:e===`SHELL`?sk:ik}),T=_?(0,R.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:p?(0,R.jsx)(zO,{size:12}):w}):(0,R.jsx)(`span`,{className:`frizz-op-dot-slot ${nk}`,children:p?(0,R.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot ${m[e]}`,"data-running-indicator":r===`card`?`queue-subagent`:`operation`}):w}),E=o||y?(0,R.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 pl-1.5 text-muted-40`,children:[o&&(0,R.jsx)(`span`,{"data-child-op-counter":!0,title:s,style:c===`danger`?{color:QO.fgDanger}:void 0,children:o}),o&&y&&(0,R.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-25`,children:`·`}),y&&(0,R.jsx)(`span`,{title:`Working for ${y}`,children:y})]}):null,D=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:ek,children:`⤷`}),T,!_&&(0,R.jsx)(`span`,{className:`frizz-kind-tag petite-caps shrink-0 text-[9.5px] text-muted-45`,children:h[e]}),(0,R.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-focus-ink-60`:``}`,k=_&&b>0?{paddingLeft:26+b}:void 0,A=g?(0,R.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,R.jsx)(`div`,{style:k,title:C,className:O,children:D});return(0,R.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-hover`:`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,R.jsx)(`button`,{type:`button`,onClick:d,onMouseDown:e=>e.stopPropagation(),title:pk[x],"aria-label":`${mk[x]} ${hk[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-focus-ink-60`,children:(0,R.jsx)(cv,{size:11})}),E]})}var Sk=null,Ck=5e3,wk=6;function Tk(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 Ek(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>=wk)))break;return n}function Dk(e,t){if(Sk=null,!e||typeof window>`u`)return;let n=[...e.querySelectorAll(`[data-transcript-source-id]`)];if(n.length===0)return;let r=Tk(n[0],e),i=Ek(n.map(e=>{let t=e.getBoundingClientRect();return{sourceId:e.dataset.transcriptSourceId,top:t.top,bottom:t.bottom}}),r);i.length!==0&&(Sk={slug:t,candidates:i,at:performance.now()})}function Ok(e){let t=Sk;return!t||(Sk=null,t.slug!==e||performance.now()-t.at>Ck)?null:t}var kk=null;function Ak(e,t){/\/full\/?$/.test(t)||(kk={slug:e,path:t})}function jk(e){return kk&&kk.slug===e?kk.path:null}var Mk=`icon-hover-outline 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`,Nk=Object.defineProperty,Pk=(e,t)=>Nk(e,`name`,{value:t,configurable:!0}),Fk=!!(typeof window<`u`&&window.document&&window.document.createElement);function Ik(e,t,{checkForDefaultPrevented:n=!0}={}){return Pk(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}Pk(Ik,`composeEventHandlers`);function Lk(e){if(!Fk)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}Pk(Lk,`getOwnerWindow`);function Rk(e){if(!Fk)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}Pk(Rk,`getOwnerDocument`);function zk(e,t=!1){let{activeElement:n}=Rk(e);if(!n?.nodeName)return null;if(Bk(n)&&n.contentDocument)return zk(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=Rk(n).getElementById(e);if(t)return t}}return n}Pk(zk,`getActiveElement`);function Bk(e){return e.tagName===`IFRAME`}Pk(Bk,`isFrame`);var Vk=Object.defineProperty,Hk=(e,t)=>Vk(e,`name`,{value:t,configurable:!0});function Uk(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}Hk(Uk,`setRef`);function Wk(...e){return t=>{let n=!1,r=e.map(e=>{let r=Uk(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():Uk(e[t],null)}}}}Hk(Wk,`composeRefs`);function Gk(...e){return L.useCallback(Wk(...e),e)}Hk(Gk,`useComposedRefs`);var Kk=Object.defineProperty,qk=(e,t)=>Kk(e,`name`,{value:t,configurable:!0});function Jk(e,t){let n=L.createContext(t);n.displayName=e+`Context`;let r=qk(e=>{let{children:t,...r}=e,i=L.useMemo(()=>r,Object.values(r));return(0,R.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=L.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return qk(i,`useContext`),[r,i]}qk(Jk,`createContext`);function Yk(e,t=[]){let n=[];function r(t,r){let i=L.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=qk(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=L.useMemo(()=>o,Object.values(o));return(0,R.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=L.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return qk(s,`useContext`),[o,s]}qk(r,`createContext`);let i=qk(()=>{let t=n.map(e=>L.createContext(e));return qk(function(n){let r=n?.[e]||t;return L.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,Xk(i,...t)]}qk(Yk,`createContextScope`);function Xk(...e){let t=e[0];if(e.length===1)return t;let n=qk(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return qk(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return L.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}qk(Xk,`composeContextScopes`);var Zk=Object.defineProperty,Qk=(e,t)=>Zk(e,`name`,{value:t,configurable:!0});function $k(e){let t=L.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];sA(r)&&typeof dA==`function`&&(r=dA(r._payload)),L.Children.forEach(r,e=>{if(aA(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;sA(n)&&typeof dA==`function`&&(n=dA(n._payload)),a=nA(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=L.cloneElement(a,void 0,s):!o&&L.Children.count(r)===1&&L.isValidElement(r)&&(a=r);let c=a?iA(a):void 0,l=Gk(n,c);if(!a){if(r||r===0)throw Error(o?uA(e):lA(e));return r}let u=rA(i,a.props??{});return a.type!==L.Fragment&&(u.ref=n?l:c),L.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}Qk($k,`createSlot`);var eA=Symbol.for(`radix.slottable`);function tA(e){let t=Qk(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=eA,t}Qk(tA,`createSlottable`);var nA=Qk((e,t)=>{if(`child`in e.props){let t=e.props.child;return L.isValidElement(t)?L.cloneElement(t,void 0,e.props.children(t.props.children)):null}return L.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function rA(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}}Qk(rA,`mergeProps`);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)}Qk(iA,`getElementRef`);function aA(e){return L.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===eA}Qk(aA,`isSlottable`);var oA=Symbol.for(`react.lazy`);function sA(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===oA&&`_payload`in e&&cA(e._payload)}Qk(sA,`isLazyComponent`);function cA(e){return typeof e==`object`&&!!e&&`then`in e}Qk(cA,`isPromiseLike`);var lA=Qk(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),uA=Qk(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),dA=L.use,fA=Object.defineProperty,pA=(e,t)=>fA(e,`name`,{value:t,configurable:!0}),mA=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=$k(`Primitive.${t}`),r=L.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,R.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function hA(e,t){e&&Tn.flushSync(()=>e.dispatchEvent(t))}pA(hA,`dispatchDiscreteCustomEvent`);var gA=Object.defineProperty,_A=(e,t)=>gA(e,`name`,{value:t,configurable:!0});function vA(e){let t=L.useRef(e);return L.useEffect(()=>{t.current=e}),L.useMemo(()=>((...e)=>t.current?.(...e)),[])}_A(vA,`useCallbackRef`);var yA=Object.defineProperty,bA=(e,t)=>yA(e,`name`,{value:t,configurable:!0}),xA=`dismissableLayer.update`,SA=`dismissableLayer.pointerDownOutside`,CA=`dismissableLayer.focusOutside`,wA,TA=L.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),EA=L.forwardRef(bA(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=L.useContext(TA),[d,f]=L.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=L.useState({}),h=Gk(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=L.useRef(!1),C=kA(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:L.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return x&&!t},[u.branches,x])}),w=AA(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=vA(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return L.useEffect(()=>{if(T)return p.addEventListener(`keydown`,E,{capture:!0}),()=>p.removeEventListener(`keydown`,E,{capture:!0})},[p,T,E]),L.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(wA=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),jA(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=wA))}},[d,p,n,u]),L.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),jA())},[d,u]),L.useEffect(()=>{let e=bA(()=>m({}),`handleUpdate`);return document.addEventListener(xA,e),()=>document.removeEventListener(xA,e)},[]),(0,R.jsx)(mA.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:Ik(e.onFocusCapture,w.onFocusCapture),onBlurCapture:Ik(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:Ik(e.onPointerDownCapture,C.onPointerDownCapture)})},`DismissableLayer`));function DA(){let e=L.useContext(TA),[t,n]=L.useState(null);return L.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}bA(DA,`useDismissableLayerSurface`);var OA=bA(()=>!0,`IS_TRUE`);function kA(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=OA}=t,s=vA(e),c=L.useRef(!1),l=L.useRef(!1),u=L.useRef(new Map),d=L.useRef(()=>{});return L.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}bA(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}bA(t,`isOutsideInteractionIntercepted`);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)}bA(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}bA(p,`handleInteractionBubble`);let m=bA(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||MA(SA,s,p,{discrete:!0})};if(bA(f,`handleAndDispatchPointerDownOutsideEvent`),!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},`handlePointerDown`),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:bA(()=>c.current=!0,`onPointerDownCapture`)}}bA(kA,`usePointerDownOutside`);function AA(e,t=globalThis?.document){let n=vA(e),r=L.useRef(!1);return L.useEffect(()=>{let e=bA(e=>{e.target&&!r.current&&MA(CA,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:bA(()=>r.current=!0,`onFocusCapture`),onBlurCapture:bA(()=>r.current=!1,`onBlurCapture`)}}bA(AA,`useFocusOutside`);function jA(){let e=new CustomEvent(xA);document.dispatchEvent(e)}bA(jA,`dispatchUpdate`);function MA(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?hA(i,a):i.dispatchEvent(a)}bA(MA,`handleAndDispatchCustomEvent`);var NA=globalThis?.document?L.useLayoutEffect:()=>{},PA=Object.defineProperty,FA=(e,t)=>PA(e,`name`,{value:t,configurable:!0}),IA=L.useId||(()=>void 0),LA=0;function RA(e){let[t,n]=L.useState(IA());return NA(()=>{e||n(e=>e??String(LA++))},[e]),e||(t?`radix-${t}`:``)}FA(RA,`useId`);var zA=[`top`,`right`,`bottom`,`left`],BA=Math.min,VA=Math.max,HA=Math.round,UA=Math.floor,WA=e=>({x:e,y:e}),GA={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function KA(e,t,n){return VA(e,BA(t,n))}function qA(e,t){return typeof e==`function`?e(t):e}function JA(e){return e.split(`-`)[0]}function YA(e){return e.split(`-`)[1]}function XA(e){return e===`x`?`y`:`x`}function ZA(e){return e===`y`?`height`:`width`}function QA(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function $A(e){return XA(QA(e))}function ej(e,t,n){n===void 0&&(n=!1);let r=YA(e),i=$A(e),a=ZA(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=lj(o)),[o,lj(o)]}function tj(e){let t=lj(e);return[nj(e),t,nj(t)]}function nj(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var rj=[`left`,`right`],ij=[`right`,`left`],aj=[`top`,`bottom`],oj=[`bottom`,`top`];function sj(e,t,n){switch(e){case`top`:case`bottom`:return n?t?ij:rj:t?rj:ij;case`left`:case`right`:return t?aj:oj;default:return[]}}function cj(e,t,n,r){let i=YA(e),a=sj(JA(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(nj)))),a}function lj(e){let t=JA(e);return GA[t]+e.slice(t.length)}function uj(e){return{top:0,right:0,bottom:0,left:0,...e}}function dj(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:uj(e)}function fj(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 pj(e,t,n){let{reference:r,floating:i}=e,a=QA(t),o=$A(t),s=ZA(o),c=JA(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(YA(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 mj(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}=qA(t,e),p=dj(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=fj(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=fj(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 hj=50,gj=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:mj},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=pj(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<hj&&(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}=pj(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},_j=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}=qA(e,t)||{};if(l==null)return{};let d=dj(u),f={x:n,y:r},p=$A(i),m=ZA(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=BA(d[_],T),D=BA(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=KA(O,A,k),M=!c.arrow&&YA(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}}}),vj=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}=qA(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=JA(r),_=QA(o),v=JA(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[lj(o)]:tj(o)),x=p!==`none`;!d&&x&&b.push(...cj(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=ej(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`&&_!==QA(t))||T.every(e=>QA(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=QA(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 yj(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function bj(e){return zA.some(t=>e[t]>=0)}var xj=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=qA(e,t);switch(i){case`referenceHidden`:{let e=yj(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:bj(e)}}}case`escaped`:{let e=yj(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:bj(e)}}}default:return{}}}}},Sj=new Set([`left`,`top`]);async function Cj(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=JA(n),s=YA(n),c=QA(n)===`y`,l=Sj.has(o)?-1:1,u=a&&c?-1:1,d=qA(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 wj=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 Cj(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}}}}},Tj=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}=qA(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=QA(JA(i)),p=XA(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=KA(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=KA(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}}}}}},Ej=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}=qA(e,t),u={x:n,y:r},d=QA(i),f=XA(d),p=u[f],m=u[d],h=qA(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=Sj.has(JA(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}}}},Dj=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}=qA(e,t),u=await o.detectOverflow(t,l),d=JA(i),f=YA(i),p=QA(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=BA(h-u[g],v),x=BA(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=VA(u.left,0),t=VA(u.right,0),n=VA(u.top,0),r=VA(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:VA(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:VA(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 Oj(){return typeof window<`u`}function kj(e){return Mj(e)?(e.nodeName||``).toLowerCase():`#document`}function Aj(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function jj(e){return((Mj(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function Mj(e){return Oj()?e instanceof Node||e instanceof Aj(e).Node:!1}function Nj(e){return Oj()?e instanceof Element||e instanceof Aj(e).Element:!1}function Pj(e){return Oj()?e instanceof HTMLElement||e instanceof Aj(e).HTMLElement:!1}function Fj(e){return!Oj()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof Aj(e).ShadowRoot}function Ij(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Uj(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Ste(e){return/^(table|td|th)$/.test(kj(e))}function Lj(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var Cte=/transform|translate|scale|rotate|perspective|filter/,wte=/paint|layout|strict|content/,Rj=e=>!!e&&e!==`none`,zj;function Bj(e){let t=Nj(e)?Uj(e):e;return Rj(t.transform)||Rj(t.translate)||Rj(t.scale)||Rj(t.rotate)||Rj(t.perspective)||!Vj()&&(Rj(t.backdropFilter)||Rj(t.filter))||Cte.test(t.willChange||``)||wte.test(t.contain||``)}function Tte(e){let t=Gj(e);for(;Pj(t)&&!Hj(t);){if(Bj(t))return t;if(Lj(t))return null;t=Gj(t)}return null}function Vj(){return zj??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),zj}function Hj(e){return/^(html|body|#document)$/.test(kj(e))}function Uj(e){return Aj(e).getComputedStyle(e)}function Wj(e){return Nj(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Gj(e){if(kj(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Fj(e)&&e.host||jj(e);return Fj(t)?t.host:t}function Kj(e){let t=Gj(e);return Hj(t)?e.ownerDocument?e.ownerDocument.body:e.body:Pj(t)&&Ij(t)?t:Kj(t)}function qj(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Kj(e),i=r===e.ownerDocument?.body,a=Aj(r);if(i){let e=Jj(a);return t.concat(a,a.visualViewport||[],Ij(r)?r:[],e&&n?qj(e):[])}else return t.concat(r,qj(r,[],n))}function Jj(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Yj(e){let t=Uj(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Pj(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=HA(n)!==a||HA(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Xj(e){return Nj(e)?e:e.contextElement}function Zj(e){let t=Xj(e);if(!Pj(t))return WA(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Yj(t),o=(a?HA(n.width):n.width)/r,s=(a?HA(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Ete=WA(0);function Qj(e){let t=Aj(e);return!Vj()||!t.visualViewport?Ete:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Dte(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==Aj(e)?!1:t}function $j(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Xj(e),o=WA(1);t&&(r?Nj(r)&&(o=Zj(r)):o=Zj(e));let s=Dte(a,n,r)?Qj(a):WA(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=Aj(a),t=r&&Nj(r)?Aj(r):r,n=e,i=Jj(n);for(;i&&r&&t!==n;){let e=Zj(i),t=i.getBoundingClientRect(),r=Uj(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=Aj(i),i=Jj(n)}}return fj({width:u,height:d,x:c,y:l})}function eM(e,t){let n=Wj(e).scrollLeft;return t?t.left+n:$j(jj(e)).left+n}function tM(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-eM(e,n),y:n.top+t.scrollTop}}function Ote(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=jj(r),s=t?Lj(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=WA(1),u=WA(0),d=Pj(r);if((d||!d&&!a)&&((kj(r)!==`body`||Ij(o))&&(c=Wj(r)),d)){let e=$j(r);l=Zj(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?tM(o,c):WA(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 kte(e){return Array.from(e.getClientRects())}function Ate(e){let t=jj(e),n=Wj(e),r=e.ownerDocument.body,i=VA(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=VA(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+eM(e),s=-n.scrollTop;return Uj(r).direction===`rtl`&&(o+=VA(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var nM=25;function rM(e,t){let n=Aj(e),r=jj(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Vj();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=eM(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<=nM&&(a-=o)}else l<=nM&&(a+=l);return{width:a,height:o,x:s,y:c}}function iM(e,t){let n=$j(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Pj(e)?Zj(e):WA(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function aM(e,t,n){let r;if(t===`viewport`)r=rM(e,n);else if(t===`document`)r=Ate(jj(e));else if(Nj(t))r=iM(t,n);else{let n=Qj(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return fj(r)}function oM(e,t){let n=Gj(e);return n===t||!Nj(n)||Hj(n)?!1:Uj(n).position===`fixed`||oM(n,t)}function sM(e,t){let n=t.get(e);if(n)return n;let r=qj(e,[],!1).filter(e=>Nj(e)&&kj(e)!==`body`),i=null,a=Uj(e).position===`fixed`,o=a?Gj(e):e;for(;Nj(o)&&!Hj(o);){let t=Uj(o),n=Bj(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||Ij(o)&&!n&&oM(e,o))?r=r.filter(e=>e!==o):i=t,o=Gj(o)}return t.set(e,r),r}function cM(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Lj(t)?[]:sM(t,this._c):[].concat(n),r],o=aM(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=aM(t,a[e],i);s=VA(n.top,s),c=BA(n.right,c),l=BA(n.bottom,l),u=VA(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function lM(e){let{width:t,height:n}=Yj(e);return{width:t,height:n}}function uM(e,t,n){let r=Pj(t),i=jj(t),a=n===`fixed`,o=$j(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=WA(0);function l(){c.x=eM(i)}if(r||!r&&!a)if((kj(t)!==`body`||Ij(i))&&(s=Wj(t)),r){let e=$j(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?tM(i,s):WA(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 dM(e){return Uj(e).position===`static`}function fM(e,t){if(!Pj(e)||Uj(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return jj(e)===n&&(n=n.ownerDocument.body),n}function pM(e,t){let n=Aj(e);if(Lj(e))return n;if(!Pj(e)){let t=Gj(e);for(;t&&!Hj(t);){if(Nj(t)&&!dM(t))return t;t=Gj(t)}return n}let r=fM(e,t);for(;r&&Ste(r)&&dM(r);)r=fM(r,t);return r&&Hj(r)&&dM(r)&&!Bj(r)?n:r||Tte(e)||n}var mM=async function(e){let t=this.getOffsetParent||pM,n=this.getDimensions,r=await n(e.floating);return{reference:uM(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function hM(e){return Uj(e).direction===`rtl`}var gM={convertOffsetParentRelativeRectToViewportRelativeRect:Ote,getDocumentElement:jj,getClippingRect:cM,getOffsetParent:pM,getElementRects:mM,getClientRects:kte,getDimensions:lM,getScale:Zj,isElement:Nj,isRTL:hM};function _M(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function vM(e,t){let n=null,r,i=jj(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=UA(d),h=UA(i.clientWidth-(u+f)),g=UA(i.clientHeight-(d+p)),_=UA(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:VA(0,BA(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&&!_M(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 yM(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=Xj(e),u=i||a?[...l?qj(l):[],...t?qj(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?vM(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?$j(e):null;c&&g();function g(){let t=$j(e);h&&!_M(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 bM=wj,xM=Tj,SM=vj,CM=Dj,wM=xj,TM=_j,EM=Ej,DM=(e,t,n)=>{let r=new Map,i={platform:gM,...n},a={...i.platform,_c:r};return gj(e,t,{...i,platform:a})},OM=typeof document<`u`?L.useLayoutEffect:function(){};function kM(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(!kM(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)&&!kM(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function AM(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function jM(e,t){let n=AM(e);return Math.round(t*n)/n}function MM(e){let t=L.useRef(e);return OM(()=>{t.current=e}),t}function NM(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]=L.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=L.useState(r);kM(f,r)||p(r);let[m,h]=L.useState(null),[g,_]=L.useState(null),v=L.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=L.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=L.useRef(null),C=L.useRef(null),w=L.useRef(u),T=c!=null,E=MM(c),D=MM(i),O=MM(l),k=L.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),DM(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!kM(w.current,t)&&(w.current=t,Tn.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);OM(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=L.useRef(!1);OM(()=>(A.current=!0,()=>{A.current=!1}),[]),OM(()=>{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=L.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=L.useMemo(()=>({reference:b,floating:x}),[b,x]),N=L.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=jM(M.floating,u.x),r=jM(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...AM(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return L.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var PM=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?{}:TM({element:r.current,padding:i}).fn(n):r?TM({element:r,padding:i}).fn(n):{}}}},FM=(e,t)=>{let n=bM(e);return{name:n.name,fn:n.fn,options:[e,t]}},IM=(e,t)=>{let n=xM(e);return{name:n.name,fn:n.fn,options:[e,t]}},LM=(e,t)=>({fn:EM(e).fn,options:[e,t]}),RM=(e,t)=>{let n=SM(e);return{name:n.name,fn:n.fn,options:[e,t]}},zM=(e,t)=>{let n=CM(e);return{name:n.name,fn:n.fn,options:[e,t]}},BM=(e,t)=>{let n=wM(e);return{name:n.name,fn:n.fn,options:[e,t]}},VM=(e,t)=>{let n=PM(e);return{name:n.name,fn:n.fn,options:[e,t]}},HM=Object.defineProperty,UM=L.forwardRef(((e,t)=>HM(e,`name`,{value:t,configurable:!0}))(function(e,t){let{children:n,width:r=10,height:i=5,...a}=e;return(0,R.jsx)(mA.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,R.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})},`Arrow`)),WM=Object.defineProperty,GM=(e,t)=>WM(e,`name`,{value:t,configurable:!0});function KM(e){let[t,n]=L.useState(void 0);return NA(()=>{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}GM(KM,`useSize`);var qM=Object.defineProperty,JM=(e,t)=>qM(e,`name`,{value:t,configurable:!0}),YM=`Popper`,[XM,ZM]=Yk(YM),[QM,$M]=XM(YM),eN=JM(e=>{let{__scopePopper:t,children:n}=e,[r,i]=L.useState(null),[a,o]=L.useState(void 0);return(0,R.jsx)(QM,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),tN=`PopperAnchor`,nN=L.forwardRef(JM(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=$M(tN,n),o=L.useRef(null),s=a.onAnchorChange,c=Gk(t,L.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=L.useRef(null);L.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&fN(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,R.jsx)(mA.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),rN=`PopperContent`,[iN,aN]=XM(rN),oN=L.forwardRef(JM(function(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=$M(rN,n),[_,v]=L.useState(null),y=Gk(t,v),[b,x]=L.useState(null),S=KM(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(uN),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=NM({strategy:`fixed`,placement:T,whileElementsMounted:JM((...e)=>yM(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:g.anchor},middleware:[FM({mainAxis:i+w,alignmentAxis:o}),c&&IM({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?LM():void 0,...k}),c&&RM({...k}),zM({...k,apply:JM(({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`)},`apply`)}),b&&VM({element:b,padding:s}),dN({arrowWidth:C,arrowHeight:w}),f&&BM({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),F=g.setPlacementState;NA(()=>(F(M),()=>{F(void 0)}),[M,F]);let[I,ee]=fN(M),te=vA(m);NA(()=>{N&&te?.()},[N,te]);let ne=P.arrow?.x,re=P.arrow?.y,ie=P.arrow?.centerOffset!==0,[ae,oe]=L.useState();return NA(()=>{_&&oe(window.getComputedStyle(_).zIndex)},[_]),(0,R.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:N?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ae,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,R.jsx)(iN,{scope:n,placedSide:I,placedAlign:ee,onArrowChange:x,arrowX:ne,arrowY:re,shouldHideArrow:ie,children:(0,R.jsx)(mA.div,{"data-side":I,"data-align":ee,...h,ref:y,style:{...h.style,animation:N?h.style?.animation:`none`}})})})},`PopperContent`)),sN=`PopperArrow`,cN={top:`bottom`,right:`left`,bottom:`top`,left:`right`},lN=L.forwardRef(JM(function(e,t){let{__scopePopper:n,...r}=e,i=aN(sN,n),a=cN[i.placedSide];return(0,R.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,R.jsx)(UM,{...r,ref:t,style:{...r.style,display:`block`}})})},`PopperArrow`));function uN(e){return e!==null}JM(uN,`isNotNull`);var dN=JM(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]=fN(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}}}}),`transformOrigin`);function fN(e){let[t,n=`center`]=e.split(`-`);return[t,n]}JM(fN,`getSideAndAlignFromPlacement`);var pN=eN,mN=nN,hN=oN,gN=lN,_N=Object.defineProperty,vN=L.forwardRef(((e,t)=>_N(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=L.useState(!1);NA(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Tn.createPortal((0,R.jsx)(mA.div,{...r,ref:t}),o):null},`Portal`)),yN=Object.defineProperty,bN=(e,t)=>yN(e,`name`,{value:t,configurable:!0});function xN(e,t){return L.useReducer((e,n)=>t[e][n]??e,e)}bN(xN,`useStateMachine`);var SN=bN(e=>{let{present:t,children:n}=e,r=CN(t),i=typeof n==`function`?n({present:r.isPresent}):L.Children.only(n),a=TN(r.ref,DN(i));return typeof n==`function`||r.isPresent?L.cloneElement(i,{ref:a}):null},`Presence`);function CN(e){let[t,n]=L.useState(),r=L.useRef(null),i=L.useRef(e),a=L.useRef(`none`),o=L.useRef(void 0),[s,c]=xN(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return L.useEffect(()=>{s===`mounted`?(a.current=o.current??EN(r.current),o.current=void 0):a.current=`none`},[s]),NA(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=EN(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]),NA(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=bN(a=>{let o=EN(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)})}},`handleAnimationEnd`),s=bN(e=>{e.target===t&&(a.current=EN(r.current))},`handleAnimationStart`);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:L.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=EN(t)}else r.current=null;n(e)},[])}}bN(CN,`usePresence`);function wN(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}bN(wN,`setRef`);function TN(...e){let t=L.useRef(e);return t.current=e,L.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=wN(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():wN(n[e],null)}}},[])}bN(TN,`useStableComposedRefs`);function EN(e){return e?.animationName||`none`}bN(EN,`getAnimationName`);function DN(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)}bN(DN,`getElementRef`);var ON=Object.defineProperty,kN=(e,t)=>ON(e,`name`,{value:t,configurable:!0}),AN=L.useEffectEvent,jN=L.useInsertionEffect;function MN(e){if(typeof AN==`function`)return AN(e);let t=L.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof jN==`function`?jN(()=>{t.current=e}):NA(()=>{t.current=e}),L.useMemo(()=>((...e)=>t.current?.(...e)),[])}kN(MN,`useEffectEvent`);var NN=Object.defineProperty,PN=(e,t)=>NN(e,`name`,{value:t,configurable:!0}),FN=L.useInsertionEffect||NA;function IN({prop:e,defaultProp:t,onChange:n=PN(()=>{},`onChange`),caller:r}){let[i,a,o]=LN({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,L.useCallback(t=>{if(s){let n=RN(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}PN(IN,`useControllableState`);function LN({defaultProp:e,onChange:t}){let[n,r]=L.useState(e),i=L.useRef(n),a=L.useRef(t);return FN(()=>{a.current=t},[t]),L.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}PN(LN,`useUncontrolledState`);function RN(e){return typeof e==`function`}PN(RN,`isFunction`);var zN=Symbol(`RADIX:SYNC_STATE`);function BN(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=MN(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=L.useReducer((t,n)=>{if(n.type===zN)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=L.useRef(p);L.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=L.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return L.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:zN,state:i})},[i,d.state,c]),[h,f]}PN(BN,`useControllableStateReducer`);var VN=Object.defineProperty,HN=(e,t)=>VN(e,`name`,{value:t,configurable:!0}),UN=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`}),WN=L.forwardRef(HN(function(e,t){return(0,R.jsx)(mA.span,{...e,ref:t,style:{...UN,...e.style}})},`VisuallyHidden`)),GN=Object.defineProperty,KN=(e,t)=>GN(e,`name`,{value:t,configurable:!0}),[qN,jte]=Yk(`Tooltip`,[ZM]),JN=ZM(),YN=`TooltipProvider`,XN=700,ZN=`tooltip.open`,[QN,$N]=qN(YN),eP=KN(e=>{let{__scopeTooltip:t,delayDuration:n=XN,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=L.useRef(!0),s=L.useRef(!1),c=L.useRef(0);return L.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,R.jsx)(QN,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:L.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:L.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:L.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),tP=`Tooltip`,[nP,rP]=qN(tP),iP=KN(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=$N(tP,e.__scopeTooltip),l=JN(t),[u,d]=L.useState(null),[f,p]=L.useState(void 0),m=RA(),h=L.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=L.useRef(!1),[y,b]=IN({prop:r,defaultProp:i??!1,onChange:KN(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(ZN))):c.onClose(),a?.(e)},`onChange`),caller:tP}),x=L.useMemo(()=>y?v.current?`delayed-open`:`instant-open`:`closed`,[y]),S=L.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,b(!0)},[b]),C=L.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),w=L.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,b(!0),h.current=0},_)},[_,b]);L.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let T=f??m;return(0,R.jsx)(pN,{...l,children:(0,R.jsx)(nP,{scope:t,contentId:T,setContentId:p,open:y,stateAttribute:x,trigger:u,onTriggerChange:d,onTriggerEnter:L.useCallback(()=>{c.isOpenDelayedRef.current?w():S()},[c.isOpenDelayedRef,w,S]),onTriggerLeave:L.useCallback(()=>{g?C():(window.clearTimeout(h.current),h.current=0)},[C,g]),onOpen:S,onClose:C,disableHoverableContent:g,children:n})})},`Tooltip`),aP=`TooltipTrigger`,oP=L.forwardRef(KN(function(e,t){let{__scopeTooltip:n,...r}=e,i=rP(aP,n),a=$N(aP,n),o=JN(n),s=Gk(t,L.useRef(null),i.onTriggerChange),c=L.useRef(!1),l=L.useRef(!1),u=L.useCallback(()=>c.current=!1,[]);return L.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,R.jsx)(mN,{asChild:!0,...o,children:(0,R.jsx)(mA.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:Ik(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:Ik(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:Ik(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:Ik(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Ik(e.onBlur,i.onClose),onClick:Ik(e.onClick,i.onClose)})})},`TooltipTrigger`)),sP=`TooltipPortal`,[cP,lP]=qN(sP,{forceMount:void 0}),uP=KN(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=rP(sP,t);return(0,R.jsx)(cP,{scope:t,forceMount:n,children:(0,R.jsx)(SN,{present:n||a.open,children:(0,R.jsx)(vN,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),dP=`TooltipContent`,fP=L.forwardRef(KN(function(e,t){let n=lP(dP,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=rP(dP,e.__scopeTooltip);return(0,R.jsx)(SN,{present:r||o.open,children:o.disableHoverableContent?(0,R.jsx)(hP,{side:i,...a,ref:t}):(0,R.jsx)(pP,{side:i,...a,ref:t})})},`TooltipContent`)),pP=L.forwardRef(KN(function(e,t){let n=rP(dP,e.__scopeTooltip),r=$N(dP,e.__scopeTooltip),i=L.useRef(null),a=Gk(t,i),[o,s]=L.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=L.useCallback(()=>{s(null),d(!1)},[d]),p=L.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=vP(r,_P(r,n.getBoundingClientRect())),a=yP(t.getBoundingClientRect()),o=xP([...i,...a]);s(o),d(!0)},[d]);return L.useEffect(()=>()=>f(),[f]),L.useEffect(()=>{if(c&&u){let e=KN(e=>p(e,u),`handleTriggerLeave`),t=KN(e=>p(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),L.useEffect(()=>{if(o){let e=KN(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!bP(n,o);r?f():i&&(f(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,R.jsx)(hP,{...e,ref:a})},`TooltipContentHoverable`)),mP=tA(`TooltipContent`),hP=L.forwardRef(KN(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=rP(dP,n),u=JN(n),{onClose:d}=l;L.useEffect(()=>(document.addEventListener(ZN,d),()=>document.removeEventListener(ZN,d)),[d]),L.useEffect(()=>{if(l.trigger){let e=KN(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return NA(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,R.jsx)(EA,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,R.jsxs)(hN,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.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,R.jsx)(mP,{children:r}),i?(0,R.jsx)(WN,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`)),gP=L.forwardRef(KN(function(e,t){let{__scopeTooltip:n,...r}=e,i=JN(n);return(0,R.jsx)(gN,{...i,...r,ref:t})},`TooltipArrow`));function _P(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`)}}KN(_P,`getExitSideFromRect`);function vP(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}KN(vP,`getPaddedExitPoints`);function yP(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}]}KN(yP,`getPointsFromRect`);function bP(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}KN(bP,`isPointInPolygon`);function xP(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)),SP(t)}KN(xP,`getHull`);function SP(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)}KN(SP,`getHullPresorted`);var CP=eP,wP=iP,TP=oP,EP=uP,DP=fP,OP=gP,kP=`isolate bg-elevated opacity-100 border border-border shadow-2xl shadow-overlay-shadow`,AP=`z-[110]`,jP=`${AP} ${kP}`,MP=`z-[250]`,NP=`z-[260]`,PP=`z-[250]`;function FP({children:e}){return(0,R.jsx)(CP,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!0,children:e})}function IP({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,L.useState)(!1),l=(0,L.useId)(),u=r&&(0,L.isValidElement)(t)?t:null,d=u?(0,L.cloneElement)(u,{"aria-describedby":l}):t,f=(0,L.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,R.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,Tn.createPortal)((0,R.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-shadow-ink/40 break-words ${o}`,style:{position:`fixed`,left:n,top:r},children:e}),document.body)]})}return(0,R.jsxs)(wP,{open:s&&!a,onOpenChange:c,children:[(0,R.jsx)(TP,{asChild:!0,children:d}),(0,R.jsx)(EP,{children:(0,R.jsxs)(DP,{id:l,side:n,sideOffset:5,collisionPadding:12,className:`${PP} 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-shadow-ink/40 break-words ${o}`,children:[e,(0,R.jsx)(OP,{className:`fill-elevated`})]})})]})}function LP({slug:e,size:t=14,className:n,label:r=`Open fullscreen`}){let i=cm(e);function a(t){if(t.stopPropagation(),!um(t))return;t.preventDefault();let n=!Ah(),r=t.currentTarget.closest(`[data-vt-chat]`);Dk(r,e),typeof location<`u`&&Ak(e,location.pathname),n&&r&&(r.style.viewTransitionName=`thread-chat`,Dp(r)),qE(i,{viewTransition:n})}return(0,R.jsx)(IP,{label:r,children:(0,R.jsx)(`a`,{href:i,"aria-label":r,"data-expand-thread":e,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:a,className:n??`icon-hover-outline 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,R.jsx)(vee,{size:t})})})}function RP(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 zP(e,t,n=`AGENT`){if(!t.id||!Au(t)||t.state===`running`&&!t.stoppable)return;let r=t.id;return()=>RP(e,r,n)}var BP=Object.defineProperty,VP=(e,t)=>BP(e,`name`,{value:t,configurable:!0});function HP(e){let t=e+`CollectionProvider`,[n,r]=Yk(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=VP(e=>{let{scope:t,children:n}=e,r=L.useRef(null),a=L.useRef(new Map).current;return(0,R.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=$k(s),l=L.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Gk(t,a(s,n).collectionRef);return(0,R.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=$k(u),p=L.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=L.useRef(null),s=Gk(t,o),c=a(u,n);return L.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,R.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return L.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 VP(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}VP(HP,`createCollection`);var UP=new WeakMap,WP=class e extends Map{static{VP(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],UP.set(this,!0)}set(e,t){return UP.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=qP(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t===void 0?!1:this.delete(t)}at(e){let t=GP(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=GP(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return GP(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function GP(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=KP(e,t);return n===-1?void 0:e[n]}VP(GP,`at`);function KP(e,t){let n=e.length,r=qP(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}VP(KP,`toSafeIndex`);function qP(e){return e!==e||e===0?0:Math.trunc(e)}VP(qP,`toSafeInteger`);function JP(e){let t=e+`CollectionProvider`,[n,r]=Yk(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new WP,setItemMap:VP(()=>void 0,`setItemMap`)}),o=VP(({state:e,...t})=>e?(0,R.jsx)(c,{...t,state:e}):(0,R.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=VP(e=>{let t=h();return(0,R.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=VP(e=>{let{scope:t,children:n,state:r}=e,a=L.useRef(null),[o,s]=L.useState(null),c=Gk(a,s),[l,u]=r;return L.useEffect(()=>{if(!o)return;let e=QP(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,R.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=$k(l),d=L.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Gk(t,a(l,n).collectionRef);return(0,R.jsx)(u,{ref:i,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=$k(f),m=L.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=L.useRef(null),[s,c]=L.useState(null),l=Gk(t,o,c),{setItemMap:u}=a(f,n),d=L.useRef(i);YP(d.current,i)||(d.current=i);let m=d.current;return L.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(ZP):(t.set(s,{...e,element:s}),t.toSorted(ZP)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new WP(e)))}},[s,m,u]),(0,R.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return L.useState(new WP)}VP(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return VP(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}VP(JP,`createCollection`);function YP(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}VP(YP,`shallowEqual`);function XP(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}VP(XP,`isElementPreceding`);function ZP(e,t){return!e[1].element||!t[1].element?0:XP(e[1].element,t[1].element)?-1:1}VP(ZP,`sortByDocumentPosition`);function QP(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}VP(QP,`getChildListObserver`);var $P=Object.defineProperty,eF=(e,t)=>$P(e,`name`,{value:t,configurable:!0}),tF=L.createContext(void 0);function nF(e){let t=L.useContext(tF);return e||t||`ltr`}eF(nF,`useDirection`);var rF=Object.defineProperty,iF=(e,t)=>rF(e,`name`,{value:t,configurable:!0}),aF=0,oF=null;function sF(e){return cF(),e.children}iF(sF,`FocusGuards`);function cF(){L.useEffect(()=>{oF||={start:lF(),end:lF()};let{start:e,end:t}=oF;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),aF++,()=>{aF===1&&(oF?.start.remove(),oF?.end.remove(),oF=null),aF=Math.max(0,aF-1)}},[])}iF(cF,`useFocusGuards`);function lF(){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}iF(lF,`createFocusGuard`);var uF=Object.defineProperty,dF=(e,t)=>uF(e,`name`,{value:t,configurable:!0}),fF=`focusScope.autoFocusOnMount`,pF=`focusScope.autoFocusOnUnmount`,mF={bubbles:!1,cancelable:!0},hF=L.forwardRef(dF(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=L.useState(null),l=vA(i),u=vA(a),d=L.useRef(null),f=Gk(t,c),p=L.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;L.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:SF(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||SF(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&SF(s)};dF(e,`handleFocusIn`),dF(t,`handleFocusOut`),dF(n,`handleMutations`),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]),L.useEffect(()=>{if(s){CF.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(fF,mF);s.addEventListener(fF,l),s.dispatchEvent(t),t.defaultPrevented||(gF(EF(vF(s)),{select:!0}),document.activeElement===e&&SF(s))}return()=>{s.removeEventListener(fF,l),setTimeout(()=>{let t=new CustomEvent(pF,mF);s.addEventListener(pF,u),s.dispatchEvent(t),t.defaultPrevented||SF(e??document.body,{select:!0}),s.removeEventListener(pF,u),CF.remove(p)},0)}}},[s,l,u,p]);let m=L.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]=_F(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&SF(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&SF(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,R.jsx)(mA.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})},`FocusScope`));function gF(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(SF(r,{select:t}),document.activeElement!==n)return}dF(gF,`focusFirst`);function _F(e){let t=vF(e);return[yF(t,e),yF(t.reverse(),e)]}dF(_F,`getTabbableEdges`);function vF(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:dF(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},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}dF(vF,`getTabbableCandidates`);function yF(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):bF(r,{upTo:t})))return r}dF(yF,`findVisible`);function bF(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}dF(bF,`isHidden`);function xF(e){return e instanceof HTMLInputElement&&`select`in e}dF(xF,`isSelectableInput`);function SF(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&xF(e)&&t&&e.select()}}dF(SF,`focus`);var CF=wF();function wF(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=TF(e,t),e.unshift(t)},remove(t){e=TF(e,t),e[0]?.resume()}}}dF(wF,`createFocusScopesStack`);function TF(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}dF(TF,`arrayRemove`);function EF(e){return e.filter(e=>e.tagName!==`A`)}dF(EF,`removeLinks`);var DF=Object.defineProperty,OF=(e,t)=>DF(e,`name`,{value:t,configurable:!0}),kF=!1;function AF(){let[e,t]=L.useState(kF);return L.useEffect(()=>{kF||(kF=!0,t(!0))},[]),e}OF(AF,`useIsHydrated`);var jF=L.useSyncExternalStore;function MF(){return()=>{}}OF(MF,`subscribe`);function NF(){return jF(MF,()=>!0,()=>!1)}OF(NF,`useIsHydratedModern`);var PF=typeof jF==`function`?NF:AF,FF=Object.defineProperty,IF=(e,t)=>FF(e,`name`,{value:t,configurable:!0}),LF=`rovingFocusGroup.onEntryFocus`,RF={bubbles:!1,cancelable:!0},zF=`RovingFocusGroup`,[BF,VF,HF]=HP(zF),[UF,WF]=Yk(zF,[HF]),[GF,KF]=UF(zF),qF=L.forwardRef(IF(function(e,t){return(0,R.jsx)(BF.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(BF.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(JF,{...e,ref:t})})})},`RovingFocusGroup`)),JF=L.forwardRef(IF(function(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=L.useRef(null),p=Gk(t,f),m=nF(a),[h,g]=IN({prop:o,defaultProp:s??null,onChange:c,caller:zF}),[_,v]=L.useState(!1),y=vA(l),b=VF(n),x=L.useRef(!1),[S,C]=L.useState(0);return L.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(LF,y),()=>e.removeEventListener(LF,y)},[y]),(0,R.jsx)(GF,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:L.useCallback(e=>g(e),[g]),onItemShiftTab:L.useCallback(()=>v(!0),[]),onFocusableItemAdd:L.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:L.useCallback(()=>C(e=>e-1),[]),children:(0,R.jsx)(mA.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:Ik(e.onMouseDown,()=>{x.current=!0}),onFocus:Ik(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(LF,RF);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);eI([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:Ik(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),YF=`RovingFocusGroupItem`,XF=L.forwardRef(IF(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=RA(),l=a||c,u=KF(YF,n),d=u.currentTabStopId===l,f=VF(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=PF();return NA(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),L.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,R.jsx)(BF.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,R.jsx)(mA.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:Ik(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:Ik(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:Ik(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=$F(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?tI(n,r+1):n.slice(r+1)}setTimeout(()=>eI(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),ZF={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function QF(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}IF(QF,`getDirectionAwareKey`);function $F(e,t,n){let r=QF(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return ZF[r]}IF($F,`getFocusIntent`);function eI(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}IF(eI,`focusFirst`);function tI(e,t){return e.map((n,r)=>e[(t+r)%e.length])}IF(tI,`wrapArray`);var nI=qF,rI=XF,iI=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},aI=new WeakMap,oI=new WeakMap,sI={},cI=0,lI=function(e){return e&&(e.host||lI(e.parentNode))},uI=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=lI(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})},dI=function(e,t,n,r){var i=uI(t,Array.isArray(e)?e:[e]);sI[n]||(sI[n]=new WeakMap);var a=sI[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=(aI.get(e)||0)+1,l=(a.get(e)||0)+1;aI.set(e,c),a.set(e,l),o.push(e),c===1&&i&&oI.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(),cI++,function(){o.forEach(function(e){var t=aI.get(e)-1,i=a.get(e)-1;aI.set(e,t),a.set(e,i),t||(oI.has(e)||e.removeAttribute(r),oI.delete(e)),i||e.removeAttribute(n)}),cI--,cI||(aI=new WeakMap,aI=new WeakMap,oI=new WeakMap,sI={})}},fI=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||iI(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),dI(r,i,n,`aria-hidden`)):function(){return null}},pI=Object.defineProperty,mI=(e,t)=>pI(e,`name`,{value:t,configurable:!0}),hI=[`Enter`,` `],gI=[`ArrowDown`,`PageUp`,`Home`],_I=[`ArrowUp`,`PageDown`,`End`],vI=[...gI,..._I];[...hI],[...hI];var yI=`Menu`,[bI,xI,SI]=HP(yI),[CI,wI]=Yk(yI,[SI,ZM,WF]),TI=ZM(),EI=WF(),[DI,OI]=CI(yI),[kI,AI]=CI(yI),jI=mI(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=TI(t),[c,l]=L.useState(null),u=L.useRef(!1),d=vA(a),f=nF(i);return L.useEffect(()=>{let e=mI(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=mI(()=>u.current=!1,`handlePointer`);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})}},[]),L.useEffect(()=>{if(!n)return;let e=mI(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,R.jsx)(pN,{...s,children:(0,R.jsx)(DI,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,R.jsx)(kI,{scope:t,onClose:L.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),MI=L.forwardRef(mI(function(e,t){let{__scopeMenu:n,...r}=e,i=TI(n);return(0,R.jsx)(mN,{...i,...r,ref:t})},`MenuAnchor`)),NI=`MenuPortal`,[PI,FI]=CI(NI,{forceMount:void 0}),II=mI(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=OI(NI,t);return(0,R.jsx)(PI,{scope:t,forceMount:n,children:(0,R.jsx)(SN,{present:n||a.open,children:(0,R.jsx)(vN,{asChild:!0,container:i,children:r})})})},`MenuPortal`),LI=`MenuContent`,[RI,zI]=CI(LI),BI=L.forwardRef(mI(function(e,t){let n=FI(LI,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=OI(LI,e.__scopeMenu),o=AI(LI,e.__scopeMenu);return(0,R.jsx)(bI.Provider,{scope:e.__scopeMenu,children:(0,R.jsx)(SN,{present:r||a.open,children:(0,R.jsx)(bI.Slot,{scope:e.__scopeMenu,children:o.modal?(0,R.jsx)(VI,{...i,ref:t}):(0,R.jsx)(HI,{...i,ref:t})})})})},`MenuContent`)),VI=L.forwardRef(mI(function(e,t){let n=OI(LI,e.__scopeMenu),r=L.useRef(null),i=Gk(t,r);return L.useEffect(()=>{let e=r.current;if(e)return fI(e)},[]),(0,R.jsx)(WI,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Ik(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),HI=L.forwardRef(mI(function(e,t){let n=OI(LI,e.__scopeMenu);return(0,R.jsx)(WI,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),UI=$k(`MenuContent.ScrollLock`),WI=L.forwardRef(mI(function(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=OI(LI,n),_=AI(LI,n),v=TI(n),y=EI(n),b=xI(n),[x,S]=L.useState(null),C=L.useRef(null),w=Gk(t,C,g.onContentChange),T=L.useRef(0),E=L.useRef(``),D=L.useRef(0),O=L.useRef(null),k=L.useRef(`right`),A=L.useRef(0),j=m?wn:L.Fragment,M=m?{as:UI,allowPinchZoom:!0}:void 0,N=mI(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=fL(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;mI((function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);L.useEffect(()=>()=>window.clearTimeout(T.current),[]),cF();let P=L.useCallback(e=>k.current===O.current?.side&&mL(e,O.current?.area),[]);return(0,R.jsx)(RI,{scope:n,searchRef:E,onItemEnter:L.useCallback(e=>{P(e)&&e.preventDefault()},[P]),onItemLeave:L.useCallback(e=>{P(e)||(C.current?.focus(),S(null))},[P]),onTriggerLeave:L.useCallback(e=>{P(e)&&e.preventDefault()},[P]),pointerGraceTimerRef:D,onPointerGraceIntentChange:L.useCallback(e=>{O.current=e},[]),children:(0,R.jsx)(j,{...M,children:(0,R.jsx)(hF,{asChild:!0,trapped:i,onMountAutoFocus:Ik(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,R.jsx)(EA,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,R.jsx)(nI,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:Ik(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,R.jsx)(hN,{role:`menu`,"aria-orientation":`vertical`,"data-state":sL(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:Ik(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||!vI.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);_I.includes(e.key)&&a.reverse(),uL(a)}),onBlur:Ik(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:Ik(e.onPointerMove,hL(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}}))})})})})})})},`MenuContentImpl`)),GI=L.forwardRef(mI(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(mA.div,{role:`group`,...r,ref:t})},`MenuGroup`)),KI=L.forwardRef(mI(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(mA.div,{...r,ref:t})},`MenuLabel`)),qI=`MenuItem`,JI=`menu.itemSelect`,YI=L.forwardRef(mI(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=L.useRef(null),o=AI(qI,e.__scopeMenu),s=zI(qI,e.__scopeMenu),c=Gk(t,a),l=L.useRef(!1),u=mI(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(JI,{bubbles:!0,cancelable:!0});e.addEventListener(JI,e=>r?.(e),{once:!0}),hA(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,R.jsx)(XI,{...i,ref:c,disabled:n,onClick:Ik(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:Ik(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:Ik(e.onKeyDown,e=>{n||e.target!==e.currentTarget||s.searchRef.current!==``&&e.key===` `||hI.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),XI=L.forwardRef(mI(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=zI(qI,n),s=EI(n),c=L.useRef(null),l=Gk(t,c),[u,d]=L.useState(!1),[f,p]=L.useState(``);return L.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,R.jsx)(bI.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,R.jsx)(rI,{asChild:!0,...s,focusable:!r,children:(0,R.jsx)(mA.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:Ik(e.onPointerMove,hL(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Ik(e.onPointerLeave,hL(e=>o.onItemLeave(e))),onFocus:Ik(e.onFocus,()=>d(!0)),onBlur:Ik(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[ZI,QI]=CI(`MenuRadioGroup`,{value:void 0,onValueChange:mI(()=>{},`onValueChange`)}),$I=L.forwardRef(mI(function(e,t){let{value:n,onValueChange:r,...i}=e,a=vA(r);return(0,R.jsx)(ZI,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,R.jsx)(GI,{...i,ref:t})})},`MenuRadioGroup`)),eL=`MenuRadioItem`,tL=L.forwardRef(mI(function(e,t){let{value:n,...r}=e,i=QI(eL,e.__scopeMenu),a=n===i.value;return(0,R.jsx)(rL,{scope:e.__scopeMenu,checked:a,children:(0,R.jsx)(YI,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":lL(a),onSelect:Ik(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),nL=`MenuItemIndicator`,[rL,iL]=CI(nL,{checked:!1}),aL=L.forwardRef(mI(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=iL(nL,n);return(0,R.jsx)(SN,{present:r||cL(a.checked)||a.checked===!0,children:(0,R.jsx)(mA.span,{...i,ref:t,"data-state":lL(a.checked)})})},`MenuItemIndicator`)),oL=L.forwardRef(mI(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(mA.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[Mte,Nte]=CI(`MenuSub`);function sL(e){return e?`open`:`closed`}mI(sL,`getOpenState`);function cL(e){return e===`indeterminate`}mI(cL,`isIndeterminate`);function lL(e){return cL(e)?`indeterminate`:e?`checked`:`unchecked`}mI(lL,`getCheckedState`);function uL(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}mI(uL,`focusFirst`);function dL(e,t){return e.map((n,r)=>e[(t+r)%e.length])}mI(dL,`wrapArray`);function fL(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=dL(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}mI(fL,`getNextMatch`);function pL(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}mI(pL,`isPointInPolygon`);function mL(e,t){return t?pL({x:e.clientX,y:e.clientY},t):!1}mI(mL,`isPointerInGraceArea`);function hL(e){return t=>t.pointerType===`mouse`?e(t):void 0}mI(hL,`whenMouse`);var gL=jI,_L=MI,vL=II,yL=BI,bL=GI,xL=KI,SL=YI,CL=$I,wL=tL,TL=aL,EL=oL,DL=Object.defineProperty,OL=(e,t)=>DL(e,`name`,{value:t,configurable:!0}),kL=`DropdownMenu`,[AL,Pte]=Yk(kL,[wI]),jL=wI(),[ML,NL]=AL(kL),PL=OL(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=jL(t),l=L.useRef(null),[u,d]=IN({prop:i,defaultProp:a??!1,onChange:o,caller:kL});return(0,R.jsx)(ML,{scope:t,triggerId:RA(),triggerRef:l,contentId:RA(),open:u,onOpenChange:d,onOpenToggle:L.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,R.jsx)(gL,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),FL=`DropdownMenuTrigger`,IL=L.forwardRef(OL(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=NL(FL,n),o=jL(n),s=Gk(t,a.triggerRef);return(0,R.jsx)(_L,{asChild:!0,...o,children:(0,R.jsx)(mA.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:Ik(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:Ik(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),LL=OL(e=>{let{__scopeDropdownMenu:t,...n}=e,r=jL(t);return(0,R.jsx)(vL,{...r,...n})},`DropdownMenuPortal`),RL=`DropdownMenuContent`,zL=L.forwardRef(OL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=NL(RL,n),a=jL(n),o=L.useRef(!1);return(0,R.jsx)(yL,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:Ik(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:Ik(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)`}})},`DropdownMenuContent`)),BL=L.forwardRef(OL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=jL(n);return(0,R.jsx)(bL,{...i,...r,ref:t})},`DropdownMenuGroup`)),VL=L.forwardRef(OL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=jL(n);return(0,R.jsx)(xL,{...i,...r,ref:t})},`DropdownMenuLabel`)),HL=L.forwardRef(OL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=jL(n);return(0,R.jsx)(SL,{...i,...r,ref:t})},`DropdownMenuItem`)),UL=L.forwardRef(OL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=jL(n);return(0,R.jsx)(CL,{...i,...r,ref:t})},`DropdownMenuRadioGroup`)),WL=L.forwardRef(OL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=jL(n);return(0,R.jsx)(wL,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),GL=L.forwardRef(OL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=jL(n);return(0,R.jsx)(TL,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),KL=L.forwardRef(OL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=jL(n);return(0,R.jsx)(EL,{...i,...r,ref:t})},`DropdownMenuSeparator`)),qL=PL,JL=IL,YL=LL,XL=zL,ZL=BL,QL=VL,$L=HL,eR=UL,tR=WL,nR=GL,rR=KL;function iR({modal:e=!1,...t}){return(0,R.jsx)(qL,{modal:e,...t})}var aR=JL;function oR({children:e,align:t=`end`,sideOffset:n=6}){return(0,R.jsx)(YL,{children:(0,R.jsx)(XL,{align:t,sideOffset:n,className:`${jP} min-w-[184px] overflow-hidden rounded-lg p-1`,children:e})})}function sR({children:e,onSelect:t,icon:n,danger:r}){return(0,R.jsxs)($L,{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-danger data-[highlighted]:text-danger-soft`:`text-muted data-[highlighted]:text-fg`}`,children:[n&&(0,R.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:n}),e]})}function cR(){return(0,R.jsx)(rR,{className:`my-1 h-px bg-border`})}var lR=(0,L.memo)(function({slug:e,size:t=`md`,onDone:n,doneBusy:r,onMutateStart:i,onApplied:a,onFailed:o}){let[s,c]=(0,L.useState)(`done`),[l,u]=(0,L.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,R.jsxs)(`div`,{className:`flex items-stretch overflow-hidden rounded-md border border-border-strong`,children:[(0,R.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,R.jsx)(M_,{size:p?11:12,className:`animate-spin`}),`Mark as `,s]}),(0,R.jsxs)(iR,{children:[(0,R.jsx)(aR,{"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,R.jsx)(t_,{size:p?11:12})}),(0,R.jsx)(oR,{children:VD.map(e=>(0,R.jsxs)(sR,{onSelect:()=>c(e),children:[`Mark as `,e]},e))})]})]})}),uR=Object.defineProperty,dR=(e,t)=>uR(e,`name`,{value:t,configurable:!0}),fR=`Dialog`,[pR,Fte]=Yk(fR),[mR,hR]=pR(fR),gR=dR(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=L.useRef(null),c=L.useRef(null),[l,u]=IN({prop:r,defaultProp:i??!1,onChange:a,caller:fR}),[d,f]=L.useState(0),[p,m]=L.useState(0);return(0,R.jsx)(mR,{scope:t,triggerRef:s,contentRef:c,contentId:RA(),titleId:RA(),descriptionId:RA(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:L.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),_R=`DialogPortal`,[vR,yR]=pR(_R,{forceMount:void 0}),bR=dR(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=hR(_R,t);return(0,R.jsx)(vR,{scope:t,forceMount:n,children:L.Children.map(r,e=>(0,R.jsx)(SN,{present:n||a.open,children:(0,R.jsx)(vN,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),xR=`DialogOverlay`,SR=L.forwardRef(dR(function(e,t){let n=yR(xR,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=hR(xR,e.__scopeDialog);return a.modal?(0,R.jsx)(SN,{present:r||a.open,children:(0,R.jsx)(wR,{...i,ref:t})}):null},`DialogOverlay`)),CR=$k(`DialogOverlay.RemoveScroll`),wR=L.forwardRef(dR(function(e,t){let{__scopeDialog:n,...r}=e,i=hR(xR,n),a=Gk(t,DA());return(0,R.jsx)(wn,{as:CR,allowPinchZoom:!0,shards:[i.contentRef],children:(0,R.jsx)(mA.div,{"data-state":PR(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),TR=`DialogContent`,ER=L.forwardRef(dR(function(e,t){let n=yR(TR,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=hR(TR,e.__scopeDialog);return(0,R.jsx)(SN,{present:r||a.open,children:a.modal?(0,R.jsx)(DR,{...i,ref:t}):(0,R.jsx)(OR,{...i,ref:t})})},`DialogContent`)),DR=L.forwardRef(dR(function(e,t){let n=hR(TR,e.__scopeDialog),r=L.useRef(null),i=Gk(t,n.contentRef,r);return L.useEffect(()=>{let e=r.current;if(e)return fI(e)},[]),(0,R.jsx)(kR,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Ik(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Ik(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Ik(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),OR=L.forwardRef(dR(function(e,t){let n=hR(TR,e.__scopeDialog),r=L.useRef(!1),i=L.useRef(!1);return(0,R.jsx)(kR,{...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()}})},`DialogContentNonModal`)),kR=L.forwardRef(dR(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=hR(TR,n);return cF(),(0,R.jsx)(R.Fragment,{children:(0,R.jsx)(hF,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,R.jsx)(EA,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":PR(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),AR=`DialogTitle`,jR=L.forwardRef(dR(function(e,t){let{__scopeDialog:n,...r}=e,i=hR(AR,n),{setTitleCount:a}=i;return NA(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,R.jsx)(mA.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),MR=`DialogClose`,NR=L.forwardRef(dR(function(e,t){let{__scopeDialog:n,...r}=e,i=hR(MR,n);return(0,R.jsx)(mA.button,{type:`button`,...r,ref:t,onClick:Ik(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function PR(e){return e?`open`:`closed`}dR(PR,`getState`);var FR=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`]),IR=/[a-zA-Z_][a-zA-Z0-9_-]*/y,LR=/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/;function RR(e){let t={},n=0;for(;n<e.length;){for(;/\s/.test(e[n]??``);)n++;if(n>=e.length)break;IR.lastIndex=n;let r=IR.exec(e);if(!r||Object.hasOwn(t,r[0]))return null;let i=r[0];if(n=IR.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(LR.test(a))t[i]=Number(a);else return null}if(n<e.length&&!/\s/.test(e[n]))return null}return t}function zR(e){let t=e.match(/^\s*::([a-z][a-z0-9-]*)\{([^\n]*)\}\s*$/);if(!t||!FR.has(t[1]))return null;let n=RR(t[2]);return n?{name:t[1],attrs:n}:null}var BR=/^(?:[-*+]|\d{1,3}[.)])\s+/,VR=/^!?\[([^\]]*)\]\((.+)\)$/,HR=/\s+"[^"]*"$/,UR=/\.(?:png|jpe?g|gif|webp|mp4|m4v|webm|mov)(?=$|[\s:|,;—–])/i,WR=/^[\s:|,;—–-]+/,GR=/^(["'“‘])(.*)(["'”’])$/;function KR(e){let t=e.replace(WR,``).trim(),n=GR.exec(t);return n&&(t=n[2].trim()),t||void 0}function qR(e){let t=e.trim().replace(BR,``);if(!t)return null;let n=VR.exec(t);if(n){let e=n[2].trim();return e=e.startsWith(`<`)&&e.endsWith(`>`)?e.slice(1,-1).trim():e.replace(HR,``),{target:e,caption:KR(n[1])}}let r=/^`([^`]+)`(.*)$/.exec(t);if(r)return{target:r[1].trim(),caption:KR(r[2])};let i=UR.exec(t);if(!i)return{target:t};let a=i.index+i[0].length;return{target:t.slice(0,a),caption:KR(t.slice(a))}}function JR(e){let t=[];for(let n of e.split(`
|
|
184
|
-
`)){let e=
|
|
182
|
+
`)}var FT=/^[a-zA-Z]:[\\/](?![\\/])/,IT=/^(?:cursor|vscode|vscode-insiders|windsurf):\/\/file\/(.*)$/i;function LT(e){try{return decodeURIComponent(e)}catch{return e}}function RT(e){if(e===`/`||e.startsWith(`/?`)||e.startsWith(`/#`))return!0;let t=e.replace(/[?#].*$/u,``);if(tm(t))return!0;let n=im(t).split(`/`)[1]??``;return Zp.has(n)}function zT(e){let t=e?.trim();if(!t)return null;let n=LT(t);if(FT.test(n))return{display:n,filePath:n};if(n.startsWith(`/`)&&!n.startsWith(`//`)&&!RT(n)){let e=LT(t.replace(/[?#].*$/u,``));return{display:e,filePath:e}}let r=IT.exec(t);if(r){let e=LT(r[1].replace(/[?#].*$/u,``)).replace(/^\/+/,``);if(!e)return null;if(FT.test(e))return{display:e,filePath:e};let t=`/${e}`;return{display:t,filePath:t}}if(!/^file:/i.test(t))return null;try{let e=new URL(t);if(e.protocol!==`file:`)return null;if(e.hostname&&e.hostname!==`localhost`)return{display:t};let n=LT(e.pathname);return{display:n,filePath:n}}catch{return{display:t}}}function BT(e){return`${sm()}/local-image?path=${encodeURIComponent(e)}`}var VT=/\.(?:png|jpe?g|gif|webp)$/i;function HT(e){return e.filePath&&VT.test(e.filePath)?BT(e.filePath):null}var UT=/\.(?:mp4|m4v|webm|mov)$/i;function WT(e){return UT.test(e)}var GT=/\.(?:md|mdx|markdown)$/i;function KT(e){return GT.test(e.trim().replace(/:\d+(?::\d+)?$/,``))}function qT(e,t,n){let r=e?.trim();if(!r||/^[a-z][a-z0-9+.-]*:/i.test(r)||/^[\\/#?]/.test(r))return null;let i=LT(r.replace(/[?#].*$/u,``));if(!i)return null;let a=i===`~`||/^~[\\/]/.test(i);if(a&&!(n&&gh(n)))return null;let o=a?n:t;return gh(o)?bh(o,a?i.slice(2):i):null}function JT(e){return Sh(e)||`/`}function YT(e){return[KT(e)?`localMarkdown`:`localFile`,e]}function XT(e){let t=KT(e);return{queryKey:YT(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 ZT=2e3,QT=new Map,$T=12;function eE(e,t){let n=QT.get(e);if(n&&n.raw===t)return n.html;let r=PT(t,vT(e));if(QT.set(e,{raw:t,html:r}),QT.size>$T){let e=QT.keys().next();e.done||QT.delete(e.value)}return r}function tE(e){let t=globalThis.requestIdleCallback;t?t(e,{timeout:500}):setTimeout(e,0)}function nE(e,t){e.prefetchQuery(XT(t)).then(()=>{let n=e.getQueryData(XT(t).queryKey);!n?.markdown||KT(t)||tE(()=>eE(n.path,n.markdown))}).catch(()=>{})}var rE=null,iE=null,aE=null,oE=null,sE=0,cE=0,lE=!1,uE=!1,dE=!1,fE=new Map,pE=new Map,mE=0,hE=new SC(()=>Iee(),e=>{iE&&OC(iE,e)}),gE=35e3;function Nee(){return`${location.origin.replace(/^http/,`ws`)}${sm()}/ws`}var _E,vE=!1;function yE(){_E=tm(),vE=!0}function Pee(e){return vE&&_E===e}function bE(){if(rE||dE)return;X.connection!==`open`&&(X.connection=`connecting`),yE();let e=new WebSocket(Nee()),t=tm();rE=e,lE=!1,cE=Date.now(),e.onopen=()=>{uE=!0,cE=Date.now(),X.connection=`open`,X.socketTranscripts=!0,aE&&=(clearTimeout(aE),null)},e.onmessage=n=>{if(!(rE!==e||t!==tm())){cE=Date.now();try{let e=JSON.parse(n.data),t=Ree(e);t&&(sE=0),t&&e.t===`event`&&e.event.type===`board`&&(lE=!0,mE++,Vee())}catch(e){console.error(`bad /ws message`,e)}}},e.onerror=()=>{},e.onclose=()=>{rE===e&&(rE=null,Fee())},Lee()}function xE(){let e=rE;if(rE=null,lE=!1,e){e.onopen=null,e.onmessage=null,e.onerror=null,e.onclose=null;try{e.close()}catch{}}}function Fee(){if(hE.reset(),!uE){wE();return}sE++,X.connection=sE>3?`closed`:`connecting`,SE()}function SE(e=!1){if(aE){if(!e)return;clearTimeout(aE),aE=null}let t=e?0:Math.min(1e3*2**Math.min(sE-1,4),15e3);aE=setTimeout(()=>{aE=null,bE()},t)}function Iee(){hE.reset(),xE(),bE()}function Lee(){if(oE)return;oE=setInterval(()=>{rE&&Date.now()-cE>gE&&CE()},1e4);let e=()=>{dE||(!rE||Date.now()-cE>gE)&&CE(!0)};window.addEventListener(`focus`,e),window.addEventListener(`online`,e),document.addEventListener(`visibilitychange`,()=>{document.hidden||e()})}function CE(e=!1){if(!dE){if(xE(),hE.reset(),!uE){wE();return}sE++,X.connection=sE>3?`closed`:`connecting`,SE(e)}}function wE(e){dE||(dE=!0,e&&(X.socketBoardFallback=e,X.socketTranscriptFallbacks={}),xE(),X.socketTranscripts=!1,VC(iE??void 0))}function Ree(e){switch(e.t){case`event`:return hE.handle(e.event),e.event.type===`board`&&(X.socketBoardFallback=null),!0;case`transcript`:return iE?.setQueryData([`transcript`,e.slug],t=>{let n=t,r=e.page?iw(n,{...e.page,messages:e.messages,editedFiles:n?.editedFiles}):aw(n,e.messages);return{...r,messages:QC(t?.messages,GC(t?.messages,r.messages))}}),delete X.socketTranscriptFallbacks[e.slug],!0;case`file-changed`:return iE?.invalidateQueries({queryKey:YT(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}),wE({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},qee(e.slug,e.retryAfterMs),!1;case`hb`:return!0}}function TE(e){lE&&rE&&rE.readyState===WebSocket.OPEN&&rE.send(JSON.stringify(e))}var zee=6,Bee=700,EE=null;function Vee(){for(let e of Object.keys(X.socketTranscriptFallbacks))delete X.socketTranscriptFallbacks[e];for(let e of kE.keys())jE(e);AE.clear(),EE&&=(clearTimeout(EE),null);let e=[...fE.keys()],t=()=>{EE=null;for(let t of e.splice(0,zee))fE.has(t)&&!X.socketTranscriptFallbacks[t]&&TE({t:`sub`,topic:`transcript`,slug:t});e.length&&(EE=setTimeout(t,Bee))};t();for(let e of pE.keys())TE({t:`sub`,topic:`file`,path:e}),mE>1&&iE?.invalidateQueries({queryKey:YT(e)})}function DE(e){let t=(fE.get(e)??0)+1;fE.set(e,t),t===1&&!X.socketTranscriptFallbacks[e]&&TE({t:`sub`,topic:`transcript`,slug:e})}function OE(e){let t=(fE.get(e)??0)-1;t<=0?(fE.delete(e),TE({t:`unsub`,topic:`transcript`,slug:e})):fE.set(e,t)}function Hee(e){let t=(pE.get(e)??0)+1;pE.set(e,t),t===1&&TE({t:`sub`,topic:`file`,path:e})}function Uee(e){let t=(pE.get(e)??0)-1;t<=0?(pE.delete(e),TE({t:`unsub`,topic:`file`,path:e})):pE.set(e,t)}function Wee(e){X.socketTranscriptFallbacks[e]&&(jE(e),delete X.socketTranscriptFallbacks[e],fE.has(e)&&TE({t:`sub`,topic:`transcript`,slug:e}))}var Gee=5,Kee=400,kE=new Map,AE=new Map;function qee(e,t){let n=AE.get(e)??0;if(n>=Gee)return;jE(e);let r=Math.max(1,t)+Math.random()*Kee;kE.set(e,setTimeout(()=>{kE.delete(e),AE.set(e,n+1);let t=X.socketTranscriptFallbacks[e];!t||t.kind!==`read-budget`||(delete X.socketTranscriptFallbacks[e],fE.has(e)&&TE({t:`sub`,topic:`transcript`,slug:e}))},r))}function jE(e){let t=kE.get(e);t&&(clearTimeout(t),kE.delete(e))}function Jee(){fE.clear(),pE.clear(),hE.reset(),xE(),X.connection=`connecting`,yE(),dE?BC():bE()}function Yee(e){iE=e,yE();let t=()=>bE();document.readyState===`complete`?t():window.addEventListener(`load`,t,{once:!0})}function ME(){return gr(X).board}function NE(){return gr(X).board?.projectDir}function PE(){return gr(X).board?.homeDir}function FE(e){return e}function IE(e){let t=gr(X).socketTranscripts;return(0,L.useEffect)(()=>(Hee(e),()=>Uee(e)),[e]),t}function Xee(e){if(!(!e||e.kind!==`session`||e.foreign||!e.sessionId))return{slug:e.id,sessionId:e.sessionId}}function LE(e){let t=Xee(e);if(!(!t||e?.pendingInteraction===!1))return t}function Zee(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 Qee(e){let t=LE(e);return ct({queryKey:t?wC(t.slug,t.sessionId):[`interactions`,`pending`,`unowned`],queryFn:()=>Y.pendingInteractions(t),enabled:t!==void 0,refetchInterval:e=>Zee(e.state.data?.interactions??[]),refetchOnReconnect:!0,refetchOnWindowFocus:!0})}var $ee=7e3,ete=5e3,tte=3,nte=15e3,rte=30*6e4;function ite(e,t,n){let r=Cg(e,t)?.lastActivityAt;if(!r)return 0;let i=Date.parse(r);return Number.isFinite(i)?i>n?0:nte:0}function ate(e,t){let n=t?Date.parse(t):NaN,r=e&&e>0?e:NaN;return!Number.isFinite(n)&&!Number.isFinite(r)?t:new Date(Math.max(Number.isFinite(n)?n:0,Number.isFinite(r)?r:0)).toISOString()}function RE(e,t){let n=qe(),r=gr(X),i=r.socketTranscripts,a=r.socketTranscriptFallbacks[e],o=ct({queryKey:[`transcript`,e],queryFn:async()=>{let t=await Y.threadTranscript({slug:e}),r=n.getQueryData([`transcript`,e]),i=iw(r,t);return{...i,messages:QC(r?.messages,GC(r?.messages,i.messages))}},refetchInterval:t.poll&&!i&&!a?1500:!1,refetchOnWindowFocus:!0,staleTime:t=>ite(X.board,e,t.state.dataUpdatedAt),gcTime:rte});return(0,L.useEffect)(()=>{if(!t.poll&&!i||a)return;let r=!1,s=0,c,l=setInterval(()=>{if(r)return;let t=Cg(X.board,e)?.lastActivityAt,a=n.getQueryState([`transcript`,e]),l=ew(a?.data?.messages);if(!$C(t,ate(a?.dataUpdatedAt,l),ete)){s=0;return}if(l!==c&&(s=0),s>=tte)return;s++,c=l;let u=t?Date.parse(t)-(l?Date.parse(l):0):0;console.warn(`[frizz] transcript watchdog: stale view — self-healing`,{slug:e,lagMs:u,transport:i?`socket`:`poll`,attempt:s}),i&&(OE(e),DE(e)),r=!0,o.refetch().finally(()=>{r=!1})},$ee);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:()=>Wee(e)}}function ote(e,t){return ct({queryKey:[`subAgentTranscript`,e,t],queryFn:()=>Y.subAgentTranscript({slug:e,id:t}),refetchInterval:e=>e.state.data?.state===`running`?2500:!1})}function ste(e,t){return ct({queryKey:[`backgroundShellOutput`,e,t],queryFn:()=>Y.backgroundShellOutput({slug:e,id:t}),refetchInterval:e=>e.state.data?.state===`running`?1500:!1})}function cte(e,t){let n=[...t].sort(),r=ct({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,L.useMemo)(()=>new Map((r.data?.shells??[]).flatMap(e=>e.lines===null?[]:[[e.id,e.lines]])),[r.data])}function lte(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 zE(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 BE(){let e=vg();return e?`/thread/${encodeURIComponent(e)}`:X.routeThreadSlug?`/thread/${encodeURIComponent(X.routeThreadSlug)}`:X.view.startsWith(`status:`)?`/status/${encodeURIComponent(X.view.slice(7))}`:`/`}function VE(e){try{return decodeURIComponent(e)}catch{return null}}function HE(e,t=X.board?.projectSlug){let n=am(e);return n===`/`&&t?nm(t):n}function UE(e){let t=e.match(/^\/thread\/([^/]+)$/);if(t){let e=VE(t[1]);if(e===null){X.routeThreadSlug=null,_g(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,_g(X.drawers.slice(n+1).map(e=>e.id));return}Gh({kind:`thread`,slug:e}),X.routeThreadSlug=e;return}let n=e.match(/^\/status\/([^/]+)$/);if(n){X.routeThreadSlug=null,_g(X.drawers.map(e=>e.id));let e=VE(n[1]);X.view=e===null?`todos`:`status:${e}`;return}X.routeThreadSlug=null,_g(X.drawers.map(e=>e.id)),X.view=`todos`}function WE(e=location.pathname){UE(im(e))}var GE=null;function KE(e){GE=e}function qE(e,t){GE?GE(e,t):typeof location<`u`&&location.assign(e)}function JE(e=typeof history>`u`?null:history.state){let t=e&&typeof e==`object`?e.idx:void 0;return typeof t==`number`&&t>0}function YE(e){return WE(),pr(X,()=>{let t=rg();if(lm(im())!==null)return;let n=HE(BE());n!==location.pathname&&e(n,{replace:!BE().startsWith(`/thread/`)&&!t})})}function XE(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 ZE=`frizz-sidebar-seen:`;function QE(e){try{return localStorage.getItem(ZE+(e??``))===`1`}catch{return!1}}function ute(e,t){try{localStorage.setItem(ZE+(e??``),t?`1`:`0`)}catch{}}function $E(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 eD(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 tD(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var nD=(e,t)=>Math.abs(e-t)<1.01,rD=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},iD,aD=()=>{if(iD!==void 0)return iD;if(typeof navigator>`u`)return iD=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return iD=!0;let e=navigator.maxTouchPoints;return iD=navigator.platform===`MacIntel`&&e!==void 0&&e>0},oD=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},sD=e=>e,dte=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},fte=(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(oD(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(oD(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},cD={passive:!0},pte=typeof window>`u`?!0:`onscrollend`in window,mte=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&pte,o=0,s=a?null:rD(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,cD),a&&r.addEventListener(`scrollend`,u,cD),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},lD=(e,t)=>mte(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),uD=(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`]},dD=(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})},fD=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:sD,rangeExtractor:dte,onChange:()=>{},measureElement:uD,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=eD(()=>(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,!(!aD()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,cD),e.addEventListener(`touchend`,n,cD),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&&(aD()&&(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=eD(()=>[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=eD(()=>[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=$E(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=eD(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>e.length===0||t===0?(this.range=null,null):(this.range=hD(e,t,n,r,r===1&&this._flatMeasurements!=null?this._flatMeasurements:null),this.range),{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=eD(()=>{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=eD(()=>[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 tD(t[pD(0,t.length-1,r?e=>n[e*2]:e=>tD(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&&(aD()&&(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&&nD(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()}},pD=(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 mD(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 hD(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=mD(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=pD(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 gD=typeof document<`u`?L.useLayoutEffect:L.useEffect;function _D({useFlushSync:e=!0,directDomUpdates:t=!1,directDomUpdatesMode:n=`transform`,...r}){let i=L.useReducer(e=>e+1,0)[1],a=L.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,Tn.flushSync)(i):i()),(s=r.onChange)==null||s.call(r,t,n)}},[c]=L.useState(()=>{let e=new fD(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),gD(()=>c._didMount(),[]),gD(()=>c._willUpdate()),gD(()=>{o(c)}),c}function vD(e){return _D({observeElementRect:fte,observeElementOffset:lD,scrollToFn:dD,...e})}var yD=3600*1e3,bD=24*yD,xD=[{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`}],SD=new Set(xD.map(e=>e.value));function CD(e){return typeof e==`string`&&SD.has(e)}function wD(e){return TD(e).label}function TD(e){return xD.find(t=>t.value===e)??xD[2]}function ED(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`?yD:e===`1d`?bD:e===`3d`?3*bD:7*bD)).toISOString()}function DD(e){return String(e).padStart(2,`0`)}function OD(e){return`${e.getFullYear()}-${DD(e.getMonth()+1)}-${DD(e.getDate())}T${DD(e.getHours())}:${DD(e.getMinutes())}`}function kD(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 AD(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)/bD),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 jD(e,t){if(!Number.isFinite(Date.parse(e)))return null;let n=AD(e,t);return n?n.replace(/^(Today|Tomorrow)/,e=>e.toLowerCase()):null}function hte(e,t=Date.now()){let n=jD(e,t);return n?`Snoozed until ${n}`:null}var gte=120;function MD(e,t=gte){let n=e.trim().replace(/\s+/g,` `);return n.length>t?`${n.slice(0,t-1)}…`:n}function ND(e,t,n=Date.now()){let r=t?.trim();if(!r)return hte(e,n);let i=PD(e,n);return i?`${i} — then: ${MD(r)}`:null}function PD(e,t=Date.now()){let n=jD(e,t);return n?`Auto-snoozed until ${n}`:null}var FD=`frizz.prefs.v1`;function _te(e,t){return e===`fifo`||e===`lifo`?e:t}function ID(e){let t={compactDiffs:!0,snoozePreset:`1d`,queueOrder:`fifo`,railFilesCollapsed:!1,dictation:!0,diffsRedefaulted:!0};try{if(!e)return t;let n=JSON.parse(e);return n.diffsRedefaulted||=(n.compactDiffs=!0,!0),{...t,...n,snoozePreset:CD(n.snoozePreset)?n.snoozePreset:t.snoozePreset,queueOrder:_te(n.queueOrder,t.queueOrder),railFilesCollapsed:typeof n.railFilesCollapsed==`boolean`?n.railFilesCollapsed:t.railFilesCollapsed,dictation:typeof n.dictation==`boolean`?n.dictation:t.dictation}}catch{return t}}function LD(){try{return ID(typeof localStorage>`u`?null:localStorage.getItem(FD))}catch{return ID(null)}}var RD=fr(LD());pr(RD,()=>{try{typeof localStorage<`u`&&localStorage.setItem(FD,JSON.stringify(RD))}catch{}});function zD(e){return e.kind===`session`&&e.foreign!==!0&&e.runtime===`exited`}var BD=gu.options,VD={planning:`text-planning border-planning/40`,planned:`text-planned border-planned/40`,active:`text-active-status border-active-status/40`,"needs-human":`text-needs-human border-needs-human/40`,blocked:`text-blocked border-blocked/40`,done:`text-zinc-400 border-zinc-400/40`,dismissed:`text-dismissed border-dismissed/40`,archived:`text-slate-500 border-slate-500/40`};function HD(e){return e.foreign===!0&&e.title.trim()?e.title.trim():YD(e)?GD:e.aiTitle?.trim()&&!UD(e)?WD(e.aiTitle):e.backend===`codex`&&e.titleAuto===!0&&!e.aiTitle?.trim()?KD:e.titleAuto===!1&&e.title.trim()?e.title:e.title.trim()&&!(e.titleAuto===!0&&e.title.trim()===e.id)?e.titleAuto===!0?WD(e.title):e.title.trim():e.titleAuto===!0?KD:e.id}function UD(e){return e.titleLocked??e.titleAuto===!1}function WD(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 GD=`Spinning up a thread…`,KD=`Untitled thread`,qD=6e4,JD=15e3;function YD(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<JD}let t=Date.parse(e.spawnedAt??``);return Number.isFinite(t)&&Date.now()-t<qD}function XD(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 ZD(e){if(vf(e))return XD(e);let t=Date.parse(e.lastAssistantAt??``);return Number.isFinite(t)?t:XD(e)}function QD(e){return vf(e)?e.lastActivityAt??e.spawnedAt:e.lastAssistantAt??e.lastActivityAt??e.spawnedAt}function $D(e){return[...e].sort((e,t)=>{let n=Sf(e);if(n!==Sf(t))return n?-1:1;let r=ZD(t)-ZD(e);return r===0?e.id.localeCompare(t.id):r})}function eO(e){return[...e].sort((e,t)=>{let n=ZD(t)-ZD(e);return n===0?e.id.localeCompare(t.id):n})}function tO(e,t=`fifo`){let n=t===`lifo`?-1:1;return[...e].sort((e,t)=>{let r=(ZD(e)-ZD(t))*n;return r===0?e.id.localeCompare(t.id):r})}function nO(e){return uf(e)}function rO(e){return e.filter(e=>e.kind===`session`&&e.foreign===!0)}function iO(e){return e.kind===`session`&&e.foreign!==!0&&typeof e.pinnedAt==`string`}function aO(e){return e.needsYou===!0&&df(e)}function oO(e){return e.runtime===`turn-idle`&&e.awaitingBackground===!0&&!ff(e)}function sO(e){return oO(e)?(e.bgShells??[]).some(e=>e.state===`running`)?!0:cO(e):!1}function cO(e){return(e.watches??[]).some(e=>e.kind===`github`&&e.state===`armed`&&e.github?.checks===`running`&&e.github.state===`open`&&!(e.github.running===0&&(e.github.gated??0)>0))}function lO(e){return e.waitStatus===`working`&&e.runtime===`turn-idle`}function uO(e){return e.runtime===`turn-idle`&&ff(e)}function dO(e){return(e.questions?.length??0)>0&&hO(e)===`working`}function fO(e){return e.runtime===`turn-idle`?pO(e):!1}function pO(e){return(e.watches??[]).some(e=>e.kind===`github`&&e.state===`armed`)?!0:e.lastFence?.kind===`awaiting`&&e.lastFence.hints.some(e=>(e.kind===`pr`||e.kind===`issue`)&&e.value.trim()!==``)}function mO(e){return e.runtime===`turn-idle`?(e.watches??[]).some(e=>e.kind===`timer`&&e.state===`armed`):!1}function hO(e){let t=vf(e);return e.state===`archived`&&!t?`archived`:gf(e)!==void 0&&_f(e)?`snoozed`:e.actionableInteraction||e.pendingAsk||e.pendingQuestion||e.runtime===`perm-prompt`||e.humanBlocked||e.status===`needs-human`?`needs-input`:t&&!aO(e)&&!oO(e)?`working`:(e.questions?.length??0)>0?`needs-input`:_f(e)?`snoozed`:e.limitPause&&e.foreign!==!0?`limit`:e.lastFence?.kind===`done`&&df(e)?`done`:fO(e)?`pr`:mO(e)&&!lO(e)?`timer`:sO(e)?`background`:zD(e)?`stalled`:`rest`}function gO(e){let t=hO(e);return t===`stalled`||t===`limit`}function _O(e,t=`fifo`){let n=e.filter(bf);return[...tO(e.filter(e=>!bf(e)),t),...eO(n)]}function vO(e){return{running:e.filter(bf),rested:e.filter(e=>!bf(e))}}function yO(e,t=`fifo`){let n={pinned:[],active:[],snoozed:[],inactive:[]};for(let t of e){if(t.kind===`session`&&t.foreign===!0)continue;if(iO(t)){n.pinned.push(t);continue}let e=yf(t);e&&n[e].push(t)}return n.pinned.sort((e,t)=>(e.pinnedAt??``).localeCompare(t.pinnedAt??``)||e.id.localeCompare(t.id)),n.active=_O(n.active,t),n.snoozed=eO(n.snoozed),n.inactive=eO(n.inactive),n}function bO(e,t){for(let n of[e,t])if(n&&Number.isFinite(Date.parse(n)))return n}function xO(e,t=Date.now()){let n=SO(e,t);return n&&`Last active ${n}`}function SO(e,t=Date.now()){let n=TO(e,t);return n===null||n===CO?n:`${n} ago`}var CO=`just now`;function wO(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 TO(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?CO:wO(r)}function EO(e,t=Date.now()){let n=e?Date.parse(e):NaN;if(!Number.isFinite(n)||!Number.isFinite(t))return null;let r=Math.floor((n-t)/1e3);return r<=0?null:wO(r)}function DO(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?CO:`${wO(r)} ago`}function OO(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 kO(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 AO=3e4,jO=new Set,MO=Date.now(),NO;function PO(){MO=Date.now();for(let e of jO)e();FO()}function FO(){if(jO.size===0)return;let e=AO-MO%AO;NO=setTimeout(PO,e||AO)}function vte(e){return jO.add(e),jO.size===1&&(MO=Date.now(),FO()),()=>{jO.delete(e),jO.size===0&&NO&&(clearTimeout(NO),NO=void 0)}}function IO(){return MO}function LO(){return(0,L.useSyncExternalStore)(vte,IO,IO)}function RO({size:e=15,children:t}){let n=(0,R.jsxs)(`svg`,{width:e,height:e,viewBox:`0 0 15 15`,"aria-hidden":!0,className:`block text-muted-85`,children:[(0,R.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,R.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,R.jsx)(`animate`,{attributeName:`stroke-dashoffset`,from:`50`,to:`0`,dur:`1.1s`,repeatCount:`indefinite`})})]});return t==null||t===!1?n:(0,R.jsxs)(`span`,{className:`relative inline-block`,style:{width:e,height:e},children:[n,(0,R.jsx)(`span`,{className:`absolute inset-px flex items-center justify-center`,children:t})]})}function zO(e){return e===`running`}function yte(e,t){return e===`pending`&&t===`background`}var BO=2e3;function VO(e,t){return e===`pending`&&t===void 0}function bte(e,t,n,r){if(!VO(e,t))return!1;let i=n?Date.parse(n):NaN;return Number.isFinite(i)?r-i>=BO:!0}function HO(e){return e?.split(`
|
|
183
|
+
`).find(e=>e.trim())?.trim().replace(/\s+/g,` `)||void 0}function xte(e,t){if(e.name===`Interrupt process`||e.status===`cancelled`||e.backgroundState!==`background`)return;let n=new Set([HO(e.desc),HO(e.detail),HO(e.command)].filter(e=>!!e));if(n.size===0)return;let r=t.filter(e=>n.has(HO(e.label)??``));return r.some(e=>e.state===`running`)?`running`:r.some(e=>e.state===`stale`)?`stale`:void 0}function UO(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 WO(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 GO(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 KO(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 qO(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?GO(Math.max(0,t-n)):``}function JO(e){if(!Number.isFinite(e)||e<0)return``;let t=Math.floor(e/6e4);return t<1?`<1m`:WO(t)}function Ste(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 YO(e,t=Date.now()){if(!e)return``;let n=Date.parse(e);return Number.isFinite(n)?WO(Math.floor((t-n)/6e4)):``}function XO(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`:`${WO(r)} ago`}var ZO={fgSuccess:`var(--gh-fg-success)`,bgSuccessEmphasis:`var(--gh-bg-success-emphasis)`,fgDanger:`var(--gh-fg-danger)`,bgDangerEmphasis:`var(--gh-bg-danger-emphasis)`,fgDone:`var(--gh-fg-done)`,bgDoneEmphasis:`var(--gh-bg-done-emphasis)`,fgAttention:`var(--gh-fg-attention)`,fgNeutral:`var(--gh-fg-neutral)`,bgNeutralEmphasis:`var(--gh-bg-neutral-emphasis)`,onEmphasis:`var(--gh-on-emphasis)`},QO=`text-[color:var(--gh-danger-link-fg)] decoration-[color:color-mix(in_srgb,var(--gh-danger-link)_30%,transparent)] hover:decoration-[color:var(--gh-danger-link)]`,$O=`shrink-0 text-[11px] leading-none text-muted-45`,ek=`frizz-kind-tag petite-caps shrink-0 text-[9.5px] text-muted-45`,tk=`flex w-[9px] shrink-0 justify-center`,nk=`block h-1.5 w-1.5 rounded-full bg-muted/30`,rk=`stale — no recent output`,ik=`block h-1.5 w-1.5 rounded-full border border-muted/45`,ak=`rested — it stopped, but the work it launched is still running`,ok=`stale — its process has exited, but no completion was reported`,sk={AGENT:`Open sub-agent transcript`,SHELL:`Open background shell output`,GITHUB:`Open this pull request on GitHub`};function ck(e){if(!(typeof e!=`number`||!Number.isFinite(e)||e<0))return e===1?`1 line`:`${dk(e)??`0`} lines`}function lk(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 uk(e){if(e)return e.state===`open`?e.comments>0?`${e.comments} comment${e.comments===1?``:`s`}`:void 0:e.state}function dk(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 fk={running:`Stop — end this operation and everything it spawned, then clear the row`,settled:`Clear — stop tracking this finished operation`},pk={running:`Stop`,settled:`Clear`},mk={AGENT:`sub-agent`,SHELL:`background shell`,GITHUB:`PR watcher`};function hk(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 gk=e=>e.state===`running`||e.state===`stale`||e.state===`rested`;function _k(e,t){return t===`card`?e.filter(gk):t===`rail`?e.filter(e=>!!e.id&&gk(e)):e}var vk=e=>{let t=e.launchId??e.id;return[...t?[`id:${t}`]:[],...e.command?[`cmd:${e.command}`]:[],`launch:${e.label}\u0000${e.startedAt??``}`]};function yk(e,t){let n=[...e],r=new Set(n.flatMap(vk));for(let e of t)vk(e).some(e=>r.has(e))||n.push(e);return n}function bk({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=zO(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=qO(a,LO()),b=Math.min(Math.max((i??1)-1,0),4)*13,x=p?`running`:`settled`,S=sk[e],C=f??(g?S:void 0),w=n===`rested`?(0,R.jsx)(`span`,{className:ik,title:ak}):(0,R.jsx)(`span`,{className:nk,title:e===`SHELL`?ok:rk}),T=_?(0,R.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:p?(0,R.jsx)(RO,{size:12}):w}):(0,R.jsx)(`span`,{className:`frizz-op-dot-slot ${tk}`,children:p?(0,R.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot ${m[e]}`,"data-running-indicator":r===`card`?`queue-subagent`:`operation`}):w}),E=o||y?(0,R.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 pl-1.5 text-muted-40`,children:[o&&(0,R.jsx)(`span`,{"data-child-op-counter":!0,title:s,style:c===`danger`?{color:ZO.fgDanger}:void 0,children:o}),o&&y&&(0,R.jsx)(`span`,{"aria-hidden":!0,className:`text-muted-25`,children:`·`}),y&&(0,R.jsx)(`span`,{title:`Working for ${y}`,children:y})]}):null,D=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:$O,children:`⤷`}),T,!_&&(0,R.jsx)(`span`,{className:`frizz-kind-tag petite-caps shrink-0 text-[9.5px] text-muted-45`,children:h[e]}),(0,R.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-focus-ink-60`:``}`,k=_&&b>0?{paddingLeft:26+b}:void 0,A=g?(0,R.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,R.jsx)(`div`,{style:k,title:C,className:O,children:D});return(0,R.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-hover`:`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,R.jsx)(`button`,{type:`button`,onClick:d,onMouseDown:e=>e.stopPropagation(),title:fk[x],"aria-label":`${pk[x]} ${mk[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-focus-ink-60`,children:(0,R.jsx)(cv,{size:11})}),E]})}var xk=null,Sk=5e3,Ck=6;function wk(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 Tk(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>=Ck)))break;return n}function Ek(e,t){if(xk=null,!e||typeof window>`u`)return;let n=[...e.querySelectorAll(`[data-transcript-source-id]`)];if(n.length===0)return;let r=wk(n[0],e),i=Tk(n.map(e=>{let t=e.getBoundingClientRect();return{sourceId:e.dataset.transcriptSourceId,top:t.top,bottom:t.bottom}}),r);i.length!==0&&(xk={slug:t,candidates:i,at:performance.now()})}function Dk(e){let t=xk;return!t||(xk=null,t.slug!==e||performance.now()-t.at>Sk)?null:t}var Ok=null;function kk(e,t){/\/full\/?$/.test(t)||(Ok={slug:e,path:t})}function Ak(e){return Ok&&Ok.slug===e?Ok.path:null}var jk=`icon-hover-outline 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`,Mk=Object.defineProperty,Nk=(e,t)=>Mk(e,`name`,{value:t,configurable:!0}),Pk=!!(typeof window<`u`&&window.document&&window.document.createElement);function Fk(e,t,{checkForDefaultPrevented:n=!0}={}){return Nk(function(r){if(e?.(r),n===!1||!r||!r.defaultPrevented)return t?.(r)},`handleEvent`)}Nk(Fk,`composeEventHandlers`);function Ik(e){if(!Pk)throw Error(`Cannot access window outside of the DOM`);return e?.ownerDocument?.defaultView??window}Nk(Ik,`getOwnerWindow`);function Lk(e){if(!Pk)throw Error(`Cannot access document outside of the DOM`);return e?.ownerDocument??document}Nk(Lk,`getOwnerDocument`);function Rk(e,t=!1){let{activeElement:n}=Lk(e);if(!n?.nodeName)return null;if(zk(n)&&n.contentDocument)return Rk(n.contentDocument.body,t);if(t){let e=n.getAttribute(`aria-activedescendant`);if(e){let t=Lk(n).getElementById(e);if(t)return t}}return n}Nk(Rk,`getActiveElement`);function zk(e){return e.tagName===`IFRAME`}Nk(zk,`isFrame`);var Bk=Object.defineProperty,Vk=(e,t)=>Bk(e,`name`,{value:t,configurable:!0});function Hk(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}Vk(Hk,`setRef`);function Uk(...e){return t=>{let n=!1,r=e.map(e=>{let r=Hk(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():Hk(e[t],null)}}}}Vk(Uk,`composeRefs`);function Wk(...e){return L.useCallback(Uk(...e),e)}Vk(Wk,`useComposedRefs`);var Gk=Object.defineProperty,Kk=(e,t)=>Gk(e,`name`,{value:t,configurable:!0});function qk(e,t){let n=L.createContext(t);n.displayName=e+`Context`;let r=Kk(e=>{let{children:t,...r}=e,i=L.useMemo(()=>r,Object.values(r));return(0,R.jsx)(n.Provider,{value:i,children:t})},`Provider`);r.displayName=e+`Provider`;function i(r,i={}){let{optional:a=!1}=i,o=L.useContext(n);if(o)return o;if(t!==void 0)return t;if(!a)throw Error(`\`${r}\` must be used within \`${e}\``)}return Kk(i,`useContext`),[r,i]}Kk(qk,`createContext`);function Jk(e,t=[]){let n=[];function r(t,r){let i=L.createContext(r);i.displayName=t+`Context`;let a=n.length;n=[...n,r];let o=Kk(t=>{let{scope:n,children:r,...o}=t,s=n?.[e]?.[a]||i,c=L.useMemo(()=>o,Object.values(o));return(0,R.jsx)(s.Provider,{value:c,children:r})},`Provider`);o.displayName=t+`Provider`;function s(n,o,s={}){let{optional:c=!1}=s,l=o?.[e]?.[a]||i,u=L.useContext(l);if(u)return u;if(r!==void 0)return r;if(!c)throw Error(`\`${n}\` must be used within \`${t}\``)}return Kk(s,`useContext`),[o,s]}Kk(r,`createContext`);let i=Kk(()=>{let t=n.map(e=>L.createContext(e));return Kk(function(n){let r=n?.[e]||t;return L.useMemo(()=>({[`__scope${e}`]:{...n,[e]:r}}),[n,r])},`useScope`)},`createScope`);return i.scopeName=e,[r,Yk(i,...t)]}Kk(Jk,`createContextScope`);function Yk(...e){let t=e[0];if(e.length===1)return t;let n=Kk(()=>{let n=e.map(e=>({useScope:e(),scopeName:e.scopeName}));return Kk(function(e){let r=n.reduce((t,{useScope:n,scopeName:r})=>{let i=n(e)[`__scope${r}`];return{...t,...i}},{});return L.useMemo(()=>({[`__scope${t.scopeName}`]:r}),[r])},`useComposedScopes`)},`createScope`);return n.scopeName=t.scopeName,n}Kk(Yk,`composeContextScopes`);var Xk=Object.defineProperty,Zk=(e,t)=>Xk(e,`name`,{value:t,configurable:!0});function Qk(e){let t=L.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];oA(r)&&typeof uA==`function`&&(r=uA(r._payload)),L.Children.forEach(r,e=>{if(iA(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;oA(n)&&typeof uA==`function`&&(n=uA(n._payload)),a=tA(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=L.cloneElement(a,void 0,s):!o&&L.Children.count(r)===1&&L.isValidElement(r)&&(a=r);let c=a?rA(a):void 0,l=Wk(n,c);if(!a){if(r||r===0)throw Error(o?lA(e):cA(e));return r}let u=nA(i,a.props??{});return a.type!==L.Fragment&&(u.ref=n?l:c),L.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}Zk(Qk,`createSlot`);var $k=Symbol.for(`radix.slottable`);function eA(e){let t=Zk(e=>`child`in e?e.children(e.child):e.children,`Slottable`);return t.displayName=`${e}.Slottable`,t.__radixId=$k,t}Zk(eA,`createSlottable`);var tA=Zk((e,t)=>{if(`child`in e.props){let t=e.props.child;return L.isValidElement(t)?L.cloneElement(t,void 0,e.props.children(t.props.children)):null}return L.isValidElement(t)?t:null},`getSlottableElementFromSlottable`);function nA(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}}Zk(nA,`mergeProps`);function rA(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)}Zk(rA,`getElementRef`);function iA(e){return L.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===$k}Zk(iA,`isSlottable`);var aA=Symbol.for(`react.lazy`);function oA(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===aA&&`_payload`in e&&sA(e._payload)}Zk(oA,`isLazyComponent`);function sA(e){return typeof e==`object`&&!!e&&`then`in e}Zk(sA,`isPromiseLike`);var cA=Zk(e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,`createSlotError`),lA=Zk(e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,`createSlottableError`),uA=L.use,dA=Object.defineProperty,fA=(e,t)=>dA(e,`name`,{value:t,configurable:!0}),pA=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Qk(`Primitive.${t}`),r=L.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,R.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function mA(e,t){e&&Tn.flushSync(()=>e.dispatchEvent(t))}fA(mA,`dispatchDiscreteCustomEvent`);var hA=Object.defineProperty,gA=(e,t)=>hA(e,`name`,{value:t,configurable:!0});function _A(e){let t=L.useRef(e);return L.useEffect(()=>{t.current=e}),L.useMemo(()=>((...e)=>t.current?.(...e)),[])}gA(_A,`useCallbackRef`);var vA=Object.defineProperty,yA=(e,t)=>vA(e,`name`,{value:t,configurable:!0}),bA=`dismissableLayer.update`,xA=`dismissableLayer.pointerDownOutside`,SA=`dismissableLayer.focusOutside`,CA,wA=L.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set,dismissableSurfaces:new Set}),TA=L.forwardRef(yA(function(e,t){let{disableOutsidePointerEvents:n=!1,deferPointerDownOutside:r=!1,onEscapeKeyDown:i,onPointerDownOutside:a,onFocusOutside:o,onInteractOutside:s,onDismiss:c,...l}=e,u=L.useContext(wA),[d,f]=L.useState(null),p=d?.ownerDocument??globalThis?.document,[,m]=L.useState({}),h=Wk(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=L.useRef(!1),C=OA(e=>{a?.(e),s?.(e),e.defaultPrevented||c?.()},{ownerDocument:p,deferPointerDownOutside:r,isDeferredPointerDownOutsideRef:S,dismissableSurfaces:u.dismissableSurfaces,shouldHandlePointerDownOutside:L.useCallback(e=>{if(!(e instanceof Node))return!1;let t=[...u.branches].some(t=>t.contains(e));return x&&!t},[u.branches,x])}),w=kA(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=_A(e=>{e.key===`Escape`&&(i?.(e),!e.defaultPrevented&&c&&(e.preventDefault(),c()))});return L.useEffect(()=>{if(T)return p.addEventListener(`keydown`,E,{capture:!0}),()=>p.removeEventListener(`keydown`,E,{capture:!0})},[p,T,E]),L.useEffect(()=>{if(d)return n&&(u.layersWithOutsidePointerEventsDisabled.size===0&&(CA=p.body.style.pointerEvents,p.body.style.pointerEvents=`none`),u.layersWithOutsidePointerEventsDisabled.add(d)),u.layers.add(d),AA(),()=>{n&&(u.layersWithOutsidePointerEventsDisabled.delete(d),u.layersWithOutsidePointerEventsDisabled.size===0&&(p.body.style.pointerEvents=CA))}},[d,p,n,u]),L.useEffect(()=>()=>{d&&(u.layers.delete(d),u.layersWithOutsidePointerEventsDisabled.delete(d),AA())},[d,u]),L.useEffect(()=>{let e=yA(()=>m({}),`handleUpdate`);return document.addEventListener(bA,e),()=>document.removeEventListener(bA,e)},[]),(0,R.jsx)(pA.div,{...l,ref:h,style:{pointerEvents:b?x?`auto`:`none`:void 0,...e.style},onFocusCapture:Fk(e.onFocusCapture,w.onFocusCapture),onBlurCapture:Fk(e.onBlurCapture,w.onBlurCapture),onPointerDownCapture:Fk(e.onPointerDownCapture,C.onPointerDownCapture)})},`DismissableLayer`));function EA(){let e=L.useContext(wA),[t,n]=L.useState(null);return L.useEffect(()=>{if(t)return e.dismissableSurfaces.add(t),()=>{e.dismissableSurfaces.delete(t)}},[t,e.dismissableSurfaces]),n}yA(EA,`useDismissableLayerSurface`);var DA=yA(()=>!0,`IS_TRUE`);function OA(e,t){let{ownerDocument:n=globalThis?.document,deferPointerDownOutside:r=!1,isDeferredPointerDownOutsideRef:i,dismissableSurfaces:a,shouldHandlePointerDownOutside:o=DA}=t,s=_A(e),c=L.useRef(!1),l=L.useRef(!1),u=L.useRef(new Map),d=L.useRef(()=>{});return L.useEffect(()=>{function e(){l.current=!1,i.current=!1,u.current.clear()}yA(e,`resetOutsideInteraction`);function t(){return Array.from(u.current.values()).some(Boolean)}yA(t,`isOutsideInteractionIntercepted`);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)}yA(f,`handleInteractionCapture`);function p(e){l.current&&u.current.set(e.type,!1)}yA(p,`handleInteractionBubble`);let m=yA(a=>{if(a.target&&!c.current){let f=function(){n.removeEventListener(`click`,d.current);let r=t();e(),r||jA(xA,s,p,{discrete:!0})};if(yA(f,`handleAndDispatchPointerDownOutsideEvent`),!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},`handlePointerDown`),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:yA(()=>c.current=!0,`onPointerDownCapture`)}}yA(OA,`usePointerDownOutside`);function kA(e,t=globalThis?.document){let n=_A(e),r=L.useRef(!1);return L.useEffect(()=>{let e=yA(e=>{e.target&&!r.current&&jA(SA,n,{originalEvent:e},{discrete:!1})},`handleFocus`);return t.addEventListener(`focusin`,e),()=>t.removeEventListener(`focusin`,e)},[t,n]),{onFocusCapture:yA(()=>r.current=!0,`onFocusCapture`),onBlurCapture:yA(()=>r.current=!1,`onBlurCapture`)}}yA(kA,`useFocusOutside`);function AA(){let e=new CustomEvent(bA);document.dispatchEvent(e)}yA(AA,`dispatchUpdate`);function jA(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?mA(i,a):i.dispatchEvent(a)}yA(jA,`handleAndDispatchCustomEvent`);var MA=globalThis?.document?L.useLayoutEffect:()=>{},NA=Object.defineProperty,PA=(e,t)=>NA(e,`name`,{value:t,configurable:!0}),FA=L.useId||(()=>void 0),IA=0;function LA(e){let[t,n]=L.useState(FA());return MA(()=>{e||n(e=>e??String(IA++))},[e]),e||(t?`radix-${t}`:``)}PA(LA,`useId`);var RA=[`top`,`right`,`bottom`,`left`],zA=Math.min,BA=Math.max,VA=Math.round,HA=Math.floor,UA=e=>({x:e,y:e}),WA={left:`right`,right:`left`,bottom:`top`,top:`bottom`};function GA(e,t,n){return BA(e,zA(t,n))}function KA(e,t){return typeof e==`function`?e(t):e}function qA(e){return e.split(`-`)[0]}function JA(e){return e.split(`-`)[1]}function YA(e){return e===`x`?`y`:`x`}function XA(e){return e===`y`?`height`:`width`}function ZA(e){let t=e[0];return t===`t`||t===`b`?`y`:`x`}function QA(e){return YA(ZA(e))}function $A(e,t,n){n===void 0&&(n=!1);let r=JA(e),i=QA(e),a=XA(i),o=i===`x`?r===(n?`end`:`start`)?`right`:`left`:r===`start`?`bottom`:`top`;return t.reference[a]>t.floating[a]&&(o=cj(o)),[o,cj(o)]}function ej(e){let t=cj(e);return[tj(e),t,tj(t)]}function tj(e){return e.includes(`start`)?e.replace(`start`,`end`):e.replace(`end`,`start`)}var nj=[`left`,`right`],rj=[`right`,`left`],ij=[`top`,`bottom`],aj=[`bottom`,`top`];function oj(e,t,n){switch(e){case`top`:case`bottom`:return n?t?rj:nj:t?nj:rj;case`left`:case`right`:return t?ij:aj;default:return[]}}function sj(e,t,n,r){let i=JA(e),a=oj(qA(e),n===`start`,r);return i&&(a=a.map(e=>e+`-`+i),t&&(a=a.concat(a.map(tj)))),a}function cj(e){let t=qA(e);return WA[t]+e.slice(t.length)}function lj(e){return{top:0,right:0,bottom:0,left:0,...e}}function uj(e){return typeof e==`number`?{top:e,right:e,bottom:e,left:e}:lj(e)}function dj(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 fj(e,t,n){let{reference:r,floating:i}=e,a=ZA(t),o=QA(t),s=XA(o),c=qA(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(JA(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 pj(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}=KA(t,e),p=uj(f),m=o[d?u===`floating`?`reference`:`floating`:u],h=dj(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=dj(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 mj=50,hj=async(e,t,n)=>{let{placement:r=`bottom`,strategy:i=`absolute`,middleware:a=[],platform:o}=n,s=o.detectOverflow?o:{...o,detectOverflow:pj},c=await(o.isRTL==null?void 0:o.isRTL(t)),l=await o.getElementRects({reference:e,floating:t,strategy:i}),{x:u,y:d}=fj(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<mj&&(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}=fj(l,f,c)),n=-1)}return{x:u,y:d,placement:f,strategy:i,middlewareData:m}},gj=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}=KA(e,t)||{};if(l==null)return{};let d=uj(u),f={x:n,y:r},p=QA(i),m=XA(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=zA(d[_],T),D=zA(d[v],T),O=E,k=C-h[m]-D,A=C/2-h[m]/2+w,j=GA(O,A,k),M=!c.arrow&&JA(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}}}),_j=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}=KA(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};let g=qA(r),_=ZA(o),v=qA(o)===o,y=await(s.isRTL==null?void 0:s.isRTL(c.floating)),b=d||(v||!m?[cj(o)]:ej(o)),x=p!==`none`;!d&&x&&b.push(...sj(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=$A(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`&&_!==ZA(t))||T.every(e=>ZA(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=ZA(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 vj(e,t){return{top:e.top-t.height,right:e.right-t.width,bottom:e.bottom-t.height,left:e.left-t.width}}function yj(e){return RA.some(t=>e[t]>=0)}var bj=function(e){return e===void 0&&(e={}),{name:`hide`,options:e,async fn(t){let{rects:n,platform:r}=t,{strategy:i=`referenceHidden`,...a}=KA(e,t);switch(i){case`referenceHidden`:{let e=vj(await r.detectOverflow(t,{...a,elementContext:`reference`}),n.reference);return{data:{referenceHiddenOffsets:e,referenceHidden:yj(e)}}}case`escaped`:{let e=vj(await r.detectOverflow(t,{...a,altBoundary:!0}),n.floating);return{data:{escapedOffsets:e,escaped:yj(e)}}}default:return{}}}}},xj=new Set([`left`,`top`]);async function Sj(e,t){let{placement:n,platform:r,elements:i}=e,a=await(r.isRTL==null?void 0:r.isRTL(i.floating)),o=qA(n),s=JA(n),c=ZA(n)===`y`,l=xj.has(o)?-1:1,u=a&&c?-1:1,d=KA(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 Cj=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 Sj(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}}}}},wj=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}=KA(e,t),u={x:n,y:r},d=await a.detectOverflow(t,l),f=ZA(qA(i)),p=YA(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=GA(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=GA(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}}}}}},Tj=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}=KA(e,t),u={x:n,y:r},d=ZA(i),f=YA(d),p=u[f],m=u[d],h=KA(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=xj.has(qA(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}}}},Ej=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}=KA(e,t),u=await o.detectOverflow(t,l),d=qA(i),f=JA(i),p=ZA(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=zA(h-u[g],v),x=zA(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=BA(u.left,0),t=BA(u.right,0),n=BA(u.top,0),r=BA(u.bottom,0);p?w=m-2*(e!==0||t!==0?e+t:BA(u.left,u.right)):C=h-2*(n!==0||r!==0?n+r:BA(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 Dj(){return typeof window<`u`}function Oj(e){return jj(e)?(e.nodeName||``).toLowerCase():`#document`}function kj(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Aj(e){return((jj(e)?e.ownerDocument:e.document)||window.document)?.documentElement}function jj(e){return Dj()?e instanceof Node||e instanceof kj(e).Node:!1}function Mj(e){return Dj()?e instanceof Element||e instanceof kj(e).Element:!1}function Nj(e){return Dj()?e instanceof HTMLElement||e instanceof kj(e).HTMLElement:!1}function Pj(e){return!Dj()||typeof ShadowRoot>`u`?!1:e instanceof ShadowRoot||e instanceof kj(e).ShadowRoot}function Fj(e){let{overflow:t,overflowX:n,overflowY:r,display:i}=Hj(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!==`inline`&&i!==`contents`}function Cte(e){return/^(table|td|th)$/.test(Oj(e))}function Ij(e){try{if(e.matches(`:popover-open`))return!0}catch{}try{return e.matches(`:modal`)}catch{return!1}}var wte=/transform|translate|scale|rotate|perspective|filter/,Tte=/paint|layout|strict|content/,Lj=e=>!!e&&e!==`none`,Rj;function zj(e){let t=Mj(e)?Hj(e):e;return Lj(t.transform)||Lj(t.translate)||Lj(t.scale)||Lj(t.rotate)||Lj(t.perspective)||!Bj()&&(Lj(t.backdropFilter)||Lj(t.filter))||wte.test(t.willChange||``)||Tte.test(t.contain||``)}function Ete(e){let t=Wj(e);for(;Nj(t)&&!Vj(t);){if(zj(t))return t;if(Ij(t))return null;t=Wj(t)}return null}function Bj(){return Rj??=typeof CSS<`u`&&CSS.supports&&CSS.supports(`-webkit-backdrop-filter`,`none`),Rj}function Vj(e){return/^(html|body|#document)$/.test(Oj(e))}function Hj(e){return kj(e).getComputedStyle(e)}function Uj(e){return Mj(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function Wj(e){if(Oj(e)===`html`)return e;let t=e.assignedSlot||e.parentNode||Pj(e)&&e.host||Aj(e);return Pj(t)?t.host:t}function Gj(e){let t=Wj(e);return Vj(t)?e.ownerDocument?e.ownerDocument.body:e.body:Nj(t)&&Fj(t)?t:Gj(t)}function Kj(e,t,n){t===void 0&&(t=[]),n===void 0&&(n=!0);let r=Gj(e),i=r===e.ownerDocument?.body,a=kj(r);if(i){let e=qj(a);return t.concat(a,a.visualViewport||[],Fj(r)?r:[],e&&n?Kj(e):[])}else return t.concat(r,Kj(r,[],n))}function qj(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function Jj(e){let t=Hj(e),n=parseFloat(t.width)||0,r=parseFloat(t.height)||0,i=Nj(e),a=i?e.offsetWidth:n,o=i?e.offsetHeight:r,s=VA(n)!==a||VA(r)!==o;return s&&(n=a,r=o),{width:n,height:r,$:s}}function Yj(e){return Mj(e)?e:e.contextElement}function Xj(e){let t=Yj(e);if(!Nj(t))return UA(1);let n=t.getBoundingClientRect(),{width:r,height:i,$:a}=Jj(t),o=(a?VA(n.width):n.width)/r,s=(a?VA(n.height):n.height)/i;return(!o||!Number.isFinite(o))&&(o=1),(!s||!Number.isFinite(s))&&(s=1),{x:o,y:s}}var Dte=UA(0);function Zj(e){let t=kj(e);return!Bj()||!t.visualViewport?Dte:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function Ote(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==kj(e)?!1:t}function Qj(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);let i=e.getBoundingClientRect(),a=Yj(e),o=UA(1);t&&(r?Mj(r)&&(o=Xj(r)):o=Xj(e));let s=Ote(a,n,r)?Zj(a):UA(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=kj(a),t=r&&Mj(r)?kj(r):r,n=e,i=qj(n);for(;i&&r&&t!==n;){let e=Xj(i),t=i.getBoundingClientRect(),r=Hj(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=kj(i),i=qj(n)}}return dj({width:u,height:d,x:c,y:l})}function $j(e,t){let n=Uj(e).scrollLeft;return t?t.left+n:Qj(Aj(e)).left+n}function eM(e,t){let n=e.getBoundingClientRect();return{x:n.left+t.scrollLeft-$j(e,n),y:n.top+t.scrollTop}}function kte(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e,a=i===`fixed`,o=Aj(r),s=t?Ij(t.floating):!1;if(r===o||s&&a)return n;let c={scrollLeft:0,scrollTop:0},l=UA(1),u=UA(0),d=Nj(r);if((d||!d&&!a)&&((Oj(r)!==`body`||Fj(o))&&(c=Uj(r)),d)){let e=Qj(r);l=Xj(r),u.x=e.x+r.clientLeft,u.y=e.y+r.clientTop}let f=o&&!d&&!a?eM(o,c):UA(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 Ate(e){return Array.from(e.getClientRects())}function jte(e){let t=Aj(e),n=Uj(e),r=e.ownerDocument.body,i=BA(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),a=BA(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight),o=-n.scrollLeft+$j(e),s=-n.scrollTop;return Hj(r).direction===`rtl`&&(o+=BA(t.clientWidth,r.clientWidth)-i),{width:i,height:a,x:o,y:s}}var tM=25;function nM(e,t){let n=kj(e),r=Aj(e),i=n.visualViewport,a=r.clientWidth,o=r.clientHeight,s=0,c=0;if(i){a=i.width,o=i.height;let e=Bj();(!e||e&&t===`fixed`)&&(s=i.offsetLeft,c=i.offsetTop)}let l=$j(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<=tM&&(a-=o)}else l<=tM&&(a+=l);return{width:a,height:o,x:s,y:c}}function rM(e,t){let n=Qj(e,!0,t===`fixed`),r=n.top+e.clientTop,i=n.left+e.clientLeft,a=Nj(e)?Xj(e):UA(1);return{width:e.clientWidth*a.x,height:e.clientHeight*a.y,x:i*a.x,y:r*a.y}}function iM(e,t,n){let r;if(t===`viewport`)r=nM(e,n);else if(t===`document`)r=jte(Aj(e));else if(Mj(t))r=rM(t,n);else{let n=Zj(e);r={x:t.x-n.x,y:t.y-n.y,width:t.width,height:t.height}}return dj(r)}function aM(e,t){let n=Wj(e);return n===t||!Mj(n)||Vj(n)?!1:Hj(n).position===`fixed`||aM(n,t)}function oM(e,t){let n=t.get(e);if(n)return n;let r=Kj(e,[],!1).filter(e=>Mj(e)&&Oj(e)!==`body`),i=null,a=Hj(e).position===`fixed`,o=a?Wj(e):e;for(;Mj(o)&&!Vj(o);){let t=Hj(o),n=zj(o);!n&&t.position===`fixed`&&(i=null),(a?!n&&!i:!n&&t.position===`static`&&i&&(i.position===`absolute`||i.position===`fixed`)||Fj(o)&&!n&&aM(e,o))?r=r.filter(e=>e!==o):i=t,o=Wj(o)}return t.set(e,r),r}function sM(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e,a=[...n===`clippingAncestors`?Ij(t)?[]:oM(t,this._c):[].concat(n),r],o=iM(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=iM(t,a[e],i);s=BA(n.top,s),c=zA(n.right,c),l=zA(n.bottom,l),u=BA(n.left,u)}return{width:c-u,height:l-s,x:u,y:s}}function cM(e){let{width:t,height:n}=Jj(e);return{width:t,height:n}}function lM(e,t,n){let r=Nj(t),i=Aj(t),a=n===`fixed`,o=Qj(e,!0,a,t),s={scrollLeft:0,scrollTop:0},c=UA(0);function l(){c.x=$j(i)}if(r||!r&&!a)if((Oj(t)!==`body`||Fj(i))&&(s=Uj(t)),r){let e=Qj(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?eM(i,s):UA(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 uM(e){return Hj(e).position===`static`}function dM(e,t){if(!Nj(e)||Hj(e).position===`fixed`)return null;if(t)return t(e);let n=e.offsetParent;return Aj(e)===n&&(n=n.ownerDocument.body),n}function fM(e,t){let n=kj(e);if(Ij(e))return n;if(!Nj(e)){let t=Wj(e);for(;t&&!Vj(t);){if(Mj(t)&&!uM(t))return t;t=Wj(t)}return n}let r=dM(e,t);for(;r&&Cte(r)&&uM(r);)r=dM(r,t);return r&&Vj(r)&&uM(r)&&!zj(r)?n:r||Ete(e)||n}var pM=async function(e){let t=this.getOffsetParent||fM,n=this.getDimensions,r=await n(e.floating);return{reference:lM(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function mM(e){return Hj(e).direction===`rtl`}var hM={convertOffsetParentRelativeRectToViewportRelativeRect:kte,getDocumentElement:Aj,getClippingRect:sM,getOffsetParent:fM,getElementRects:pM,getClientRects:Ate,getDimensions:cM,getScale:Xj,isElement:Mj,isRTL:mM};function gM(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function _M(e,t){let n=null,r,i=Aj(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=HA(d),h=HA(i.clientWidth-(u+f)),g=HA(i.clientHeight-(d+p)),_=HA(u),v={rootMargin:-m+`px `+-h+`px `+-g+`px `+-_+`px`,threshold:BA(0,zA(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&&!gM(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 vM(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=Yj(e),u=i||a?[...l?Kj(l):[],...t?Kj(t):[]]:[];u.forEach(e=>{i&&e.addEventListener(`scroll`,n,{passive:!0}),a&&e.addEventListener(`resize`,n)});let d=l&&s?_M(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?Qj(e):null;c&&g();function g(){let t=Qj(e);h&&!gM(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 yM=Cj,bM=wj,xM=_j,SM=Ej,CM=bj,wM=gj,TM=Tj,EM=(e,t,n)=>{let r=new Map,i={platform:hM,...n},a={...i.platform,_c:r};return hj(e,t,{...i,platform:a})},DM=typeof document<`u`?L.useLayoutEffect:function(){};function OM(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(!OM(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)&&!OM(e[n],t[n]))return!1}return!0}return e!==e&&t!==t}function kM(e){return typeof window>`u`?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function AM(e,t){let n=kM(e);return Math.round(t*n)/n}function jM(e){let t=L.useRef(e);return DM(()=>{t.current=e}),t}function MM(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]=L.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[f,p]=L.useState(r);OM(f,r)||p(r);let[m,h]=L.useState(null),[g,_]=L.useState(null),v=L.useCallback(e=>{e!==S.current&&(S.current=e,h(e))},[]),y=L.useCallback(e=>{e!==C.current&&(C.current=e,_(e))},[]),b=a||m,x=o||g,S=L.useRef(null),C=L.useRef(null),w=L.useRef(u),T=c!=null,E=jM(c),D=jM(i),O=jM(l),k=L.useCallback(()=>{if(!S.current||!C.current)return;let e={placement:t,strategy:n,middleware:f};D.current&&(e.platform=D.current),EM(S.current,C.current,e).then(e=>{let t={...e,isPositioned:O.current!==!1};A.current&&!OM(w.current,t)&&(w.current=t,Tn.flushSync(()=>{d(t)}))})},[f,t,n,D,O]);DM(()=>{l===!1&&w.current.isPositioned&&(w.current.isPositioned=!1,d(e=>({...e,isPositioned:!1})))},[l]);let A=L.useRef(!1);DM(()=>(A.current=!0,()=>{A.current=!1}),[]),DM(()=>{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=L.useMemo(()=>({reference:S,floating:C,setReference:v,setFloating:y}),[v,y]),M=L.useMemo(()=>({reference:b,floating:x}),[b,x]),N=L.useMemo(()=>{let e={position:n,left:0,top:0};if(!M.floating)return e;let t=AM(M.floating,u.x),r=AM(M.floating,u.y);return s?{...e,transform:`translate(`+t+`px, `+r+`px)`,...kM(M.floating)>=1.5&&{willChange:`transform`}}:{position:n,left:t,top:r}},[n,s,M.floating,u.x,u.y]);return L.useMemo(()=>({...u,update:k,refs:j,elements:M,floatingStyles:N}),[u,k,j,M,N])}var NM=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?{}:wM({element:r.current,padding:i}).fn(n):r?wM({element:r,padding:i}).fn(n):{}}}},PM=(e,t)=>{let n=yM(e);return{name:n.name,fn:n.fn,options:[e,t]}},FM=(e,t)=>{let n=bM(e);return{name:n.name,fn:n.fn,options:[e,t]}},IM=(e,t)=>({fn:TM(e).fn,options:[e,t]}),LM=(e,t)=>{let n=xM(e);return{name:n.name,fn:n.fn,options:[e,t]}},RM=(e,t)=>{let n=SM(e);return{name:n.name,fn:n.fn,options:[e,t]}},zM=(e,t)=>{let n=CM(e);return{name:n.name,fn:n.fn,options:[e,t]}},BM=(e,t)=>{let n=NM(e);return{name:n.name,fn:n.fn,options:[e,t]}},VM=Object.defineProperty,HM=L.forwardRef(((e,t)=>VM(e,`name`,{value:t,configurable:!0}))(function(e,t){let{children:n,width:r=10,height:i=5,...a}=e;return(0,R.jsx)(pA.svg,{...a,ref:t,width:r,height:i,viewBox:`0 0 30 10`,preserveAspectRatio:`none`,children:e.asChild?n:(0,R.jsx)(`polygon`,{points:`0,0 30,0 15,10`})})},`Arrow`)),UM=Object.defineProperty,WM=(e,t)=>UM(e,`name`,{value:t,configurable:!0});function GM(e){let[t,n]=L.useState(void 0);return MA(()=>{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}WM(GM,`useSize`);var KM=Object.defineProperty,qM=(e,t)=>KM(e,`name`,{value:t,configurable:!0}),JM=`Popper`,[YM,XM]=Jk(JM),[ZM,QM]=YM(JM),$M=qM(e=>{let{__scopePopper:t,children:n}=e,[r,i]=L.useState(null),[a,o]=L.useState(void 0);return(0,R.jsx)(ZM,{scope:t,anchor:r,onAnchorChange:i,placementState:a,setPlacementState:o,children:n})},`Popper`),eN=`PopperAnchor`,tN=L.forwardRef(qM(function(e,t){let{__scopePopper:n,virtualRef:r,...i}=e,a=QM(eN,n),o=L.useRef(null),s=a.onAnchorChange,c=Wk(t,L.useCallback(e=>{o.current=e,e&&s(e)},[s])),l=L.useRef(null);L.useEffect(()=>{if(!r)return;let e=l.current;l.current=r.current,e!==l.current&&s(l.current)});let u=a.placementState&&dN(a.placementState),d=u?.[0],f=u?.[1];return r?null:(0,R.jsx)(pA.div,{"data-radix-popper-side":d,"data-radix-popper-align":f,...i,ref:c})},`PopperAnchor`)),nN=`PopperContent`,[rN,iN]=YM(nN),aN=L.forwardRef(qM(function(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=QM(nN,n),[_,v]=L.useState(null),y=Wk(t,v),[b,x]=L.useState(null),S=GM(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(lN),altBoundary:O},{refs:A,floatingStyles:j,placement:M,isPositioned:N,middlewareData:P}=MM({strategy:`fixed`,placement:T,whileElementsMounted:qM((...e)=>vM(...e,{animationFrame:p===`always`}),`whileElementsMounted`),elements:{reference:g.anchor},middleware:[PM({mainAxis:i+w,alignmentAxis:o}),c&&FM({mainAxis:!0,crossAxis:!1,limiter:d===`partial`?IM():void 0,...k}),c&&LM({...k}),RM({...k,apply:qM(({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`)},`apply`)}),b&&BM({element:b,padding:s}),uN({arrowWidth:C,arrowHeight:w}),f&&zM({strategy:`referenceHidden`,...k,boundary:O?k.boundary:void 0})]}),F=g.setPlacementState;MA(()=>(F(M),()=>{F(void 0)}),[M,F]);let[I,ee]=dN(M),te=_A(m);MA(()=>{N&&te?.()},[N,te]);let ne=P.arrow?.x,re=P.arrow?.y,ie=P.arrow?.centerOffset!==0,[ae,oe]=L.useState();return MA(()=>{_&&oe(window.getComputedStyle(_).zIndex)},[_]),(0,R.jsx)(`div`,{ref:A.setFloating,"data-radix-popper-content-wrapper":``,style:{...j,transform:N?j.transform:`translate(0, -200%)`,minWidth:`max-content`,zIndex:ae,"--radix-popper-transform-origin":[P.transformOrigin?.x,P.transformOrigin?.y].join(` `),...P.hide?.referenceHidden&&{visibility:`hidden`,pointerEvents:`none`}},dir:e.dir,children:(0,R.jsx)(rN,{scope:n,placedSide:I,placedAlign:ee,onArrowChange:x,arrowX:ne,arrowY:re,shouldHideArrow:ie,children:(0,R.jsx)(pA.div,{"data-side":I,"data-align":ee,...h,ref:y,style:{...h.style,animation:N?h.style?.animation:`none`}})})})},`PopperContent`)),oN=`PopperArrow`,sN={top:`bottom`,right:`left`,bottom:`top`,left:`right`},cN=L.forwardRef(qM(function(e,t){let{__scopePopper:n,...r}=e,i=iN(oN,n),a=sN[i.placedSide];return(0,R.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,R.jsx)(HM,{...r,ref:t,style:{...r.style,display:`block`}})})},`PopperArrow`));function lN(e){return e!==null}qM(lN,`isNotNull`);var uN=qM(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]=dN(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}}}}),`transformOrigin`);function dN(e){let[t,n=`center`]=e.split(`-`);return[t,n]}qM(dN,`getSideAndAlignFromPlacement`);var fN=$M,pN=tN,mN=aN,hN=cN,gN=Object.defineProperty,_N=L.forwardRef(((e,t)=>gN(e,`name`,{value:t,configurable:!0}))(function(e,t){let{container:n,...r}=e,[i,a]=L.useState(!1);MA(()=>a(!0),[]);let o=n||i&&globalThis?.document?.body;return o?Tn.createPortal((0,R.jsx)(pA.div,{...r,ref:t}),o):null},`Portal`)),vN=Object.defineProperty,yN=(e,t)=>vN(e,`name`,{value:t,configurable:!0});function bN(e,t){return L.useReducer((e,n)=>t[e][n]??e,e)}yN(bN,`useStateMachine`);var xN=yN(e=>{let{present:t,children:n}=e,r=SN(t),i=typeof n==`function`?n({present:r.isPresent}):L.Children.only(n),a=wN(r.ref,EN(i));return typeof n==`function`||r.isPresent?L.cloneElement(i,{ref:a}):null},`Presence`);function SN(e){let[t,n]=L.useState(),r=L.useRef(null),i=L.useRef(e),a=L.useRef(`none`),o=L.useRef(void 0),[s,c]=bN(e?`mounted`:`unmounted`,{mounted:{UNMOUNT:`unmounted`,ANIMATION_OUT:`unmountSuspended`},unmountSuspended:{MOUNT:`mounted`,ANIMATION_END:`unmounted`},unmounted:{MOUNT:`mounted`}});return L.useEffect(()=>{s===`mounted`?(a.current=o.current??TN(r.current),o.current=void 0):a.current=`none`},[s]),MA(()=>{let t=r.current,n=i.current;if(n!==e){let r=a.current,s=TN(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]),MA(()=>{if(t){let e,n=t.ownerDocument.defaultView??window,o=yN(a=>{let o=TN(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)})}},`handleAnimationEnd`),s=yN(e=>{e.target===t&&(a.current=TN(r.current))},`handleAnimationStart`);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:L.useCallback(e=>{if(e){let t=getComputedStyle(e);r.current=t,o.current=TN(t)}else r.current=null;n(e)},[])}}yN(SN,`usePresence`);function CN(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}yN(CN,`setRef`);function wN(...e){let t=L.useRef(e);return t.current=e,L.useCallback(e=>{let n=t.current,r=!1,i=n.map(t=>{let n=CN(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():CN(n[e],null)}}},[])}yN(wN,`useStableComposedRefs`);function TN(e){return e?.animationName||`none`}yN(TN,`getAnimationName`);function EN(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)}yN(EN,`getElementRef`);var DN=Object.defineProperty,ON=(e,t)=>DN(e,`name`,{value:t,configurable:!0}),kN=L.useEffectEvent,AN=L.useInsertionEffect;function jN(e){if(typeof kN==`function`)return kN(e);let t=L.useRef(()=>{throw Error(`Cannot call an event handler while rendering.`)});return typeof AN==`function`?AN(()=>{t.current=e}):MA(()=>{t.current=e}),L.useMemo(()=>((...e)=>t.current?.(...e)),[])}ON(jN,`useEffectEvent`);var MN=Object.defineProperty,NN=(e,t)=>MN(e,`name`,{value:t,configurable:!0}),PN=L.useInsertionEffect||MA;function FN({prop:e,defaultProp:t,onChange:n=NN(()=>{},`onChange`),caller:r}){let[i,a,o]=IN({defaultProp:t,onChange:n}),s=e!==void 0;return[s?e:i,L.useCallback(t=>{if(s){let n=LN(t)?t(e):t;n!==e&&o.current?.(n)}else a(t)},[s,e,a,o])]}NN(FN,`useControllableState`);function IN({defaultProp:e,onChange:t}){let[n,r]=L.useState(e),i=L.useRef(n),a=L.useRef(t);return PN(()=>{a.current=t},[t]),L.useEffect(()=>{i.current!==n&&(a.current?.(n),i.current=n)},[n,i]),[n,r,a]}NN(IN,`useUncontrolledState`);function LN(e){return typeof e==`function`}NN(LN,`isFunction`);var RN=Symbol(`RADIX:SYNC_STATE`);function zN(e,t,n,r){let{prop:i,defaultProp:a,onChange:o,caller:s}=t,c=i!==void 0,l=jN(o),u=[{...n,state:a}];r&&u.push(r);let[d,f]=L.useReducer((t,n)=>{if(n.type===RN)return{...t,state:n.state};let r=e(t,n);return c&&!Object.is(r.state,t.state)&&l(r.state),r},...u),p=d.state,m=L.useRef(p);L.useEffect(()=>{m.current!==p&&(m.current=p,c||l(p))},[p,m,c]);let h=L.useMemo(()=>i===void 0?d:{...d,state:i},[d,i]);return L.useEffect(()=>{c&&!Object.is(i,d.state)&&f({type:RN,state:i})},[i,d.state,c]),[h,f]}NN(zN,`useControllableStateReducer`);var BN=Object.defineProperty,VN=(e,t)=>BN(e,`name`,{value:t,configurable:!0}),HN=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`}),UN=L.forwardRef(VN(function(e,t){return(0,R.jsx)(pA.span,{...e,ref:t,style:{...HN,...e.style}})},`VisuallyHidden`)),WN=Object.defineProperty,GN=(e,t)=>WN(e,`name`,{value:t,configurable:!0}),[KN,Mte]=Jk(`Tooltip`,[XM]),qN=XM(),JN=`TooltipProvider`,YN=700,XN=`tooltip.open`,[ZN,QN]=KN(JN),$N=GN(e=>{let{__scopeTooltip:t,delayDuration:n=YN,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=L.useRef(!0),s=L.useRef(!1),c=L.useRef(0);return L.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,R.jsx)(ZN,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:L.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:L.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:L.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})},`TooltipProvider`),eP=`Tooltip`,[tP,nP]=KN(eP),rP=GN(e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=QN(eP,e.__scopeTooltip),l=qN(t),[u,d]=L.useState(null),[f,p]=L.useState(void 0),m=LA(),h=L.useRef(0),g=o??c.disableHoverableContent,_=s??c.delayDuration,v=L.useRef(!1),[y,b]=FN({prop:r,defaultProp:i??!1,onChange:GN(e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(XN))):c.onClose(),a?.(e)},`onChange`),caller:eP}),x=L.useMemo(()=>y?v.current?`delayed-open`:`instant-open`:`closed`,[y]),S=L.useCallback(()=>{window.clearTimeout(h.current),h.current=0,v.current=!1,b(!0)},[b]),C=L.useCallback(()=>{window.clearTimeout(h.current),h.current=0,b(!1)},[b]),w=L.useCallback(()=>{window.clearTimeout(h.current),h.current=window.setTimeout(()=>{v.current=!0,b(!0),h.current=0},_)},[_,b]);L.useEffect(()=>()=>{h.current&&=(window.clearTimeout(h.current),0)},[]);let T=f??m;return(0,R.jsx)(fN,{...l,children:(0,R.jsx)(tP,{scope:t,contentId:T,setContentId:p,open:y,stateAttribute:x,trigger:u,onTriggerChange:d,onTriggerEnter:L.useCallback(()=>{c.isOpenDelayedRef.current?w():S()},[c.isOpenDelayedRef,w,S]),onTriggerLeave:L.useCallback(()=>{g?C():(window.clearTimeout(h.current),h.current=0)},[C,g]),onOpen:S,onClose:C,disableHoverableContent:g,children:n})})},`Tooltip`),iP=`TooltipTrigger`,aP=L.forwardRef(GN(function(e,t){let{__scopeTooltip:n,...r}=e,i=nP(iP,n),a=QN(iP,n),o=qN(n),s=Wk(t,L.useRef(null),i.onTriggerChange),c=L.useRef(!1),l=L.useRef(!1),u=L.useCallback(()=>c.current=!1,[]);return L.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,R.jsx)(pN,{asChild:!0,...o,children:(0,R.jsx)(pA.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:Fk(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:Fk(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:Fk(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:Fk(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Fk(e.onBlur,i.onClose),onClick:Fk(e.onClick,i.onClose)})})},`TooltipTrigger`)),oP=`TooltipPortal`,[sP,cP]=KN(oP,{forceMount:void 0}),lP=GN(e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=nP(oP,t);return(0,R.jsx)(sP,{scope:t,forceMount:n,children:(0,R.jsx)(xN,{present:n||a.open,children:(0,R.jsx)(_N,{asChild:!0,container:i,children:r})})})},`TooltipPortal`),uP=`TooltipContent`,dP=L.forwardRef(GN(function(e,t){let n=cP(uP,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=nP(uP,e.__scopeTooltip);return(0,R.jsx)(xN,{present:r||o.open,children:o.disableHoverableContent?(0,R.jsx)(mP,{side:i,...a,ref:t}):(0,R.jsx)(fP,{side:i,...a,ref:t})})},`TooltipContent`)),fP=L.forwardRef(GN(function(e,t){let n=nP(uP,e.__scopeTooltip),r=QN(uP,e.__scopeTooltip),i=L.useRef(null),a=Wk(t,i),[o,s]=L.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=L.useCallback(()=>{s(null),d(!1)},[d]),p=L.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=_P(r,gP(r,n.getBoundingClientRect())),a=vP(t.getBoundingClientRect()),o=bP([...i,...a]);s(o),d(!0)},[d]);return L.useEffect(()=>()=>f(),[f]),L.useEffect(()=>{if(c&&u){let e=GN(e=>p(e,u),`handleTriggerLeave`),t=GN(e=>p(e,c),`handleContentLeave`);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),L.useEffect(()=>{if(o){let e=GN(e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!yP(n,o);r?f():i&&(f(),l())},`handleTrackPointerGrace`);return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,R.jsx)(mP,{...e,ref:a})},`TooltipContentHoverable`)),pP=eA(`TooltipContent`),mP=L.forwardRef(GN(function(e,t){let{__scopeTooltip:n,children:r,"aria-label":i,id:a,onEscapeKeyDown:o,onPointerDownOutside:s,...c}=e,l=nP(uP,n),u=qN(n),{onClose:d}=l;L.useEffect(()=>(document.addEventListener(XN,d),()=>document.removeEventListener(XN,d)),[d]),L.useEffect(()=>{if(l.trigger){let e=GN(e=>{e.target instanceof Node&&e.target.contains(l.trigger)&&d()},`handleScroll`);return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[l.trigger,d]);let{setContentId:f}=l;return MA(()=>(f(a),()=>{f(void 0)}),[a,f]),(0,R.jsx)(TA,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:e=>e.preventDefault(),onDismiss:d,children:(0,R.jsxs)(mN,{"data-state":l.stateAttribute,role:i?void 0:`tooltip`,id:i?void 0:l.contentId,...u,...c,ref:t,style:{...c.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,R.jsx)(pP,{children:r}),i?(0,R.jsx)(UN,{id:l.contentId,role:`tooltip`,children:i}):null]})})},`TooltipContentImpl`)),hP=L.forwardRef(GN(function(e,t){let{__scopeTooltip:n,...r}=e,i=qN(n);return(0,R.jsx)(hN,{...i,...r,ref:t})},`TooltipArrow`));function gP(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`)}}GN(gP,`getExitSideFromRect`);function _P(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}GN(_P,`getPaddedExitPoints`);function vP(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}]}GN(vP,`getPointsFromRect`);function yP(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}GN(yP,`isPointInPolygon`);function bP(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)),xP(t)}GN(bP,`getHull`);function xP(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)}GN(xP,`getHullPresorted`);var SP=$N,CP=rP,wP=aP,TP=lP,EP=dP,DP=hP,OP=`isolate bg-elevated opacity-100 border border-border shadow-2xl shadow-overlay-shadow`,kP=`z-[110]`,AP=`${kP} ${OP}`,jP=`z-[250]`,MP=`z-[260]`,NP=`z-[250]`;function PP({children:e}){return(0,R.jsx)(SP,{delayDuration:0,skipDelayDuration:0,disableHoverableContent:!0,children:e})}function FP({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,L.useState)(!1),l=(0,L.useId)(),u=r&&(0,L.isValidElement)(t)?t:null,d=u?(0,L.cloneElement)(u,{"aria-describedby":l}):t,f=(0,L.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,R.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,Tn.createPortal)((0,R.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-shadow-ink/40 break-words ${o}`,style:{position:`fixed`,left:n,top:r},children:e}),document.body)]})}return(0,R.jsxs)(CP,{open:s&&!a,onOpenChange:c,children:[(0,R.jsx)(wP,{asChild:!0,children:d}),(0,R.jsx)(TP,{children:(0,R.jsxs)(EP,{id:l,side:n,sideOffset:5,collisionPadding:12,className:`${NP} 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-shadow-ink/40 break-words ${o}`,children:[e,(0,R.jsx)(DP,{className:`fill-elevated`})]})})]})}function IP({slug:e,size:t=14,className:n,label:r=`Open fullscreen`}){let i=cm(e);function a(t){if(t.stopPropagation(),!um(t))return;t.preventDefault();let n=!Ah(),r=t.currentTarget.closest(`[data-vt-chat]`);Ek(r,e),typeof location<`u`&&kk(e,location.pathname),n&&r&&(r.style.viewTransitionName=`thread-chat`,Dp(r)),qE(i,{viewTransition:n})}return(0,R.jsx)(FP,{label:r,children:(0,R.jsx)(`a`,{href:i,"aria-label":r,"data-expand-thread":e,onMouseDown:e=>{e.preventDefault(),e.stopPropagation()},onClick:a,className:n??`icon-hover-outline 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,R.jsx)(vee,{size:t})})})}function LP(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 RP(e,t,n=`AGENT`){if(!t.id||!Au(t)||t.state===`running`&&!t.stoppable)return;let r=t.id;return()=>LP(e,r,n)}var zP=Object.defineProperty,BP=(e,t)=>zP(e,`name`,{value:t,configurable:!0});function VP(e){let t=e+`CollectionProvider`,[n,r]=Jk(t),[i,a]=n(t,{collectionRef:{current:null},itemMap:new Map}),o=BP(e=>{let{scope:t,children:n}=e,r=L.useRef(null),a=L.useRef(new Map).current;return(0,R.jsx)(i,{scope:t,itemMap:a,collectionRef:r,children:n})},`CollectionProvider`);o.displayName=t;let s=e+`CollectionSlot`,c=Qk(s),l=L.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Wk(t,a(s,n).collectionRef);return(0,R.jsx)(c,{ref:i,children:r})});l.displayName=s;let u=e+`CollectionItemSlot`,d=`data-radix-collection-item`,f=Qk(u),p=L.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=L.useRef(null),s=Wk(t,o),c=a(u,n);return L.useEffect(()=>(c.itemMap.set(o,{ref:o,...i}),()=>void c.itemMap.delete(o))),(0,R.jsx)(f,{[d]:``,ref:s,children:r})});p.displayName=u;function m(t){let n=a(e+`CollectionConsumer`,t);return L.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 BP(m,`useCollection`),[{Provider:o,Slot:l,ItemSlot:p},m,r]}BP(VP,`createCollection`);var HP=new WeakMap,UP=class e extends Map{static{BP(this,`OrderedDict`)}#e;constructor(e){super(e),this.#e=[...super.keys()],HP.set(this,!0)}set(e,t){return HP.get(this)&&(this.has(e)?this.#e[this.#e.indexOf(e)]=e:this.#e.push(e)),super.set(e,t),this}insert(e,t,n){let r=this.has(t),i=this.#e.length,a=KP(e),o=a>=0?a:i+a,s=o<0||o>=i?-1:o;if(s===this.size||r&&s===this.size-1||s===-1)return this.set(t,n),this;let c=this.size+ +!r;a<0&&o++;let l=[...this.#e],u,d=!1;for(let e=o;e<c;e++)if(o===e){let i=l[e];l[e]===t&&(i=l[e+1]),r&&this.delete(t),u=this.get(i),this.set(t,n)}else{!d&&l[e-1]===t&&(d=!0);let n=l[d?e:e-1],r=u;u=this.get(n),this.delete(n),this.set(n,r)}return this}with(t,n,r){let i=new e(this);return i.insert(t,n,r),i}before(e){let t=this.#e.indexOf(e)-1;if(!(t<0))return this.entryAt(t)}setBefore(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r,t,n)}after(e){let t=this.#e.indexOf(e);if(t=t===-1||t===this.size-1?-1:t+1,t!==-1)return this.entryAt(t)}setAfter(e,t,n){let r=this.#e.indexOf(e);return r===-1?this:this.insert(r+1,t,n)}first(){return this.entryAt(0)}last(){return this.entryAt(-1)}clear(){return this.#e=[],super.clear()}delete(e){let t=super.delete(e);return t&&this.#e.splice(this.#e.indexOf(e),1),t}deleteAt(e){let t=this.keyAt(e);return t===void 0?!1:this.delete(t)}at(e){let t=WP(this.#e,e);if(t!==void 0)return this.get(t)}entryAt(e){let t=WP(this.#e,e);if(t!==void 0)return[t,this.get(t)]}indexOf(e){return this.#e.indexOf(e)}keyAt(e){return WP(this.#e,e)}from(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.at(r)}keyFrom(e,t){let n=this.indexOf(e);if(n===-1)return;let r=n+t;return r<0&&(r=0),r>=this.size&&(r=this.size-1),this.keyAt(r)}find(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return r;n++}}findIndex(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return n;n++}return-1}filter(t,n){let r=[],i=0;for(let e of this)Reflect.apply(t,n,[e,i,this])&&r.push(e),i++;return new e(r)}map(t,n){let r=[],i=0;for(let e of this)r.push([e[0],Reflect.apply(t,n,[e,i,this])]),i++;return new e(r)}reduce(...e){let[t,n]=e,r=0,i=n??this.at(0);for(let n of this)i=r===0&&e.length===1?n:Reflect.apply(t,this,[i,n,r,this]),r++;return i}reduceRight(...e){let[t,n]=e,r=n??this.at(-1);for(let n=this.size-1;n>=0;n--){let i=this.at(n);r=n===this.size-1&&e.length===1?i:Reflect.apply(t,this,[r,i,n,this])}return r}toSorted(t){let n=[...this.entries()].sort(t);return new e(n)}toReversed(){let t=new e;for(let e=this.size-1;e>=0;e--){let n=this.keyAt(e),r=this.get(n);t.set(n,r)}return t}toSpliced(...t){let n=[...this.entries()];return n.splice(...t),new e(n)}slice(t,n){let r=new e,i=this.size-1;if(t===void 0)return r;t<0&&(t+=this.size),n!==void 0&&n>0&&(i=n-1);for(let e=t;e<=i;e++){let t=this.keyAt(e),n=this.get(t);r.set(t,n)}return r}every(e,t){let n=0;for(let r of this){if(!Reflect.apply(e,t,[r,n,this]))return!1;n++}return!0}some(e,t){let n=0;for(let r of this){if(Reflect.apply(e,t,[r,n,this]))return!0;n++}return!1}};function WP(e,t){if(`at`in Array.prototype)return Array.prototype.at.call(e,t);let n=GP(e,t);return n===-1?void 0:e[n]}BP(WP,`at`);function GP(e,t){let n=e.length,r=KP(t),i=r>=0?r:n+r;return i<0||i>=n?-1:i}BP(GP,`toSafeIndex`);function KP(e){return e!==e||e===0?0:Math.trunc(e)}BP(KP,`toSafeInteger`);function qP(e){let t=e+`CollectionProvider`,[n,r]=Jk(t),[i,a]=n(t,{collectionElement:null,collectionRef:{current:null},collectionRefObject:{current:null},itemMap:new UP,setItemMap:BP(()=>void 0,`setItemMap`)}),o=BP(({state:e,...t})=>e?(0,R.jsx)(c,{...t,state:e}):(0,R.jsx)(s,{...t}),`CollectionProvider`);o.displayName=t;let s=BP(e=>{let t=h();return(0,R.jsx)(c,{...e,state:t})},`CollectionInit`);s.displayName=t+`Init`;let c=BP(e=>{let{scope:t,children:n,state:r}=e,a=L.useRef(null),[o,s]=L.useState(null),c=Wk(a,s),[l,u]=r;return L.useEffect(()=>{if(!o)return;let e=ZP(()=>{});return e.observe(o,{childList:!0,subtree:!0}),()=>{e.disconnect()}},[o]),(0,R.jsx)(i,{scope:t,itemMap:l,setItemMap:u,collectionRef:c,collectionRefObject:a,collectionElement:o,children:n})},`CollectionProviderImpl`);c.displayName=t+`Impl`;let l=e+`CollectionSlot`,u=Qk(l),d=L.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=Wk(t,a(l,n).collectionRef);return(0,R.jsx)(u,{ref:i,children:r})});d.displayName=l;let f=e+`CollectionItemSlot`,p=Qk(f),m=L.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,o=L.useRef(null),[s,c]=L.useState(null),l=Wk(t,o,c),{setItemMap:u}=a(f,n),d=L.useRef(i);JP(d.current,i)||(d.current=i);let m=d.current;return L.useEffect(()=>{let e=m;return u(t=>s?t.has(s)?t.set(s,{...e,element:s}).toSorted(XP):(t.set(s,{...e,element:s}),t.toSorted(XP)):t),()=>{u(e=>!s||!e.has(s)?e:(e.delete(s),new UP(e)))}},[s,m,u]),(0,R.jsx)(p,{"data-radix-collection-item":``,ref:l,children:r})});m.displayName=f;function h(){return L.useState(new UP)}BP(h,`useInitCollection`);function g(t){let{itemMap:n}=a(e+`CollectionConsumer`,t);return n}return BP(g,`useCollection`),[{Provider:o,Slot:d,ItemSlot:m},{createCollectionScope:r,useCollection:g,useInitCollection:h}]}BP(qP,`createCollection`);function JP(e,t){if(e===t)return!0;if(typeof e!=`object`||typeof t!=`object`||e==null||t==null)return!1;let n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||e[r]!==t[r])return!1;return!0}BP(JP,`shallowEqual`);function YP(e,t){return!!(t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_PRECEDING)}BP(YP,`isElementPreceding`);function XP(e,t){return!e[1].element||!t[1].element?0:YP(e[1].element,t[1].element)?-1:1}BP(XP,`sortByDocumentPosition`);function ZP(e){return new MutationObserver(t=>{for(let n of t)if(n.type===`childList`){e();return}})}BP(ZP,`getChildListObserver`);var QP=Object.defineProperty,$P=(e,t)=>QP(e,`name`,{value:t,configurable:!0}),eF=L.createContext(void 0);function tF(e){let t=L.useContext(eF);return e||t||`ltr`}$P(tF,`useDirection`);var nF=Object.defineProperty,rF=(e,t)=>nF(e,`name`,{value:t,configurable:!0}),iF=0,aF=null;function oF(e){return sF(),e.children}rF(oF,`FocusGuards`);function sF(){L.useEffect(()=>{aF||={start:cF(),end:cF()};let{start:e,end:t}=aF;return document.body.firstElementChild!==e&&document.body.insertAdjacentElement(`afterbegin`,e),document.body.lastElementChild!==t&&document.body.insertAdjacentElement(`beforeend`,t),iF++,()=>{iF===1&&(aF?.start.remove(),aF?.end.remove(),aF=null),iF=Math.max(0,iF-1)}},[])}rF(sF,`useFocusGuards`);function cF(){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}rF(cF,`createFocusGuard`);var lF=Object.defineProperty,uF=(e,t)=>lF(e,`name`,{value:t,configurable:!0}),dF=`focusScope.autoFocusOnMount`,fF=`focusScope.autoFocusOnUnmount`,pF={bubbles:!1,cancelable:!0},mF=L.forwardRef(uF(function(e,t){let{loop:n=!1,trapped:r=!1,onMountAutoFocus:i,onUnmountAutoFocus:a,...o}=e,[s,c]=L.useState(null),l=_A(i),u=_A(a),d=L.useRef(null),f=Wk(t,c),p=L.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;L.useEffect(()=>{if(r){let e=function(e){if(p.paused||!s)return;let t=e.target;s.contains(t)?d.current=t:xF(d.current,{select:!0})},t=function(e){if(p.paused||!s)return;let t=e.relatedTarget;t!==null&&(s.contains(t)||xF(d.current,{select:!0}))},n=function(e){if(document.activeElement===document.body)for(let t of e)t.removedNodes.length>0&&xF(s)};uF(e,`handleFocusIn`),uF(t,`handleFocusOut`),uF(n,`handleMutations`),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]),L.useEffect(()=>{if(s){SF.add(p);let e=document.activeElement;if(!s.contains(e)){let t=new CustomEvent(dF,pF);s.addEventListener(dF,l),s.dispatchEvent(t),t.defaultPrevented||(hF(TF(_F(s)),{select:!0}),document.activeElement===e&&xF(s))}return()=>{s.removeEventListener(dF,l),setTimeout(()=>{let t=new CustomEvent(fF,pF);s.addEventListener(fF,u),s.dispatchEvent(t),t.defaultPrevented||xF(e??document.body,{select:!0}),s.removeEventListener(fF,u),SF.remove(p)},0)}}},[s,l,u,p]);let m=L.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]=gF(t);r&&a?!e.shiftKey&&i===a?(e.preventDefault(),n&&xF(r,{select:!0})):e.shiftKey&&i===r&&(e.preventDefault(),n&&xF(a,{select:!0})):i===t&&e.preventDefault()}},[n,r,p.paused]);return(0,R.jsx)(pA.div,{tabIndex:-1,...o,ref:f,onKeyDown:m})},`FocusScope`));function hF(e,{select:t=!1}={}){let n=document.activeElement;for(let r of e)if(xF(r,{select:t}),document.activeElement!==n)return}uF(hF,`focusFirst`);function gF(e){let t=_F(e);return[vF(t,e),vF(t.reverse(),e)]}uF(gF,`getTabbableEdges`);function _F(e){let t=[],n=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:uF(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},`acceptNode`)});for(;n.nextNode();)t.push(n.currentNode);return t}uF(_F,`getTabbableCandidates`);function vF(e,t){let n=typeof t.checkVisibility==`function`&&t.checkVisibility({checkVisibilityCSS:!0});for(let r of e)if(!(n?!r.checkVisibility({checkVisibilityCSS:!0}):yF(r,{upTo:t})))return r}uF(vF,`findVisible`);function yF(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}uF(yF,`isHidden`);function bF(e){return e instanceof HTMLInputElement&&`select`in e}uF(bF,`isSelectableInput`);function xF(e,{select:t=!1}={}){if(e&&e.focus){let n=document.activeElement;e.focus({preventScroll:!0}),e!==n&&bF(e)&&t&&e.select()}}uF(xF,`focus`);var SF=CF();function CF(){let e=[];return{add(t){let n=e[0];t!==n&&n?.pause(),e=wF(e,t),e.unshift(t)},remove(t){e=wF(e,t),e[0]?.resume()}}}uF(CF,`createFocusScopesStack`);function wF(e,t){let n=[...e],r=n.indexOf(t);return r!==-1&&n.splice(r,1),n}uF(wF,`arrayRemove`);function TF(e){return e.filter(e=>e.tagName!==`A`)}uF(TF,`removeLinks`);var EF=Object.defineProperty,DF=(e,t)=>EF(e,`name`,{value:t,configurable:!0}),OF=!1;function kF(){let[e,t]=L.useState(OF);return L.useEffect(()=>{OF||(OF=!0,t(!0))},[]),e}DF(kF,`useIsHydrated`);var AF=L.useSyncExternalStore;function jF(){return()=>{}}DF(jF,`subscribe`);function MF(){return AF(jF,()=>!0,()=>!1)}DF(MF,`useIsHydratedModern`);var NF=typeof AF==`function`?MF:kF,PF=Object.defineProperty,FF=(e,t)=>PF(e,`name`,{value:t,configurable:!0}),IF=`rovingFocusGroup.onEntryFocus`,LF={bubbles:!1,cancelable:!0},RF=`RovingFocusGroup`,[zF,BF,VF]=VP(RF),[HF,UF]=Jk(RF,[VF]),[WF,GF]=HF(RF),KF=L.forwardRef(FF(function(e,t){return(0,R.jsx)(zF.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(zF.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,R.jsx)(qF,{...e,ref:t})})})},`RovingFocusGroup`)),qF=L.forwardRef(FF(function(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=L.useRef(null),p=Wk(t,f),m=tF(a),[h,g]=FN({prop:o,defaultProp:s??null,onChange:c,caller:RF}),[_,v]=L.useState(!1),y=_A(l),b=BF(n),x=L.useRef(!1),[S,C]=L.useState(0);return L.useEffect(()=>{let e=f.current;if(e)return e.addEventListener(IF,y),()=>e.removeEventListener(IF,y)},[y]),(0,R.jsx)(WF,{scope:n,orientation:r,dir:m,loop:i,currentTabStopId:h,onItemFocus:L.useCallback(e=>g(e),[g]),onItemShiftTab:L.useCallback(()=>v(!0),[]),onFocusableItemAdd:L.useCallback(()=>C(e=>e+1),[]),onFocusableItemRemove:L.useCallback(()=>C(e=>e-1),[]),children:(0,R.jsx)(pA.div,{tabIndex:_||S===0?-1:0,"data-orientation":r,...d,ref:p,style:{outline:`none`,...e.style},onMouseDown:Fk(e.onMouseDown,()=>{x.current=!0}),onFocus:Fk(e.onFocus,e=>{let t=!x.current;if(e.target===e.currentTarget&&t&&!_){let t=new CustomEvent(IF,LF);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=b().filter(e=>e.focusable);$F([e.find(e=>e.active),e.find(e=>e.id===h),...e].filter(Boolean).map(e=>e.ref.current),u)}}x.current=!1}),onBlur:Fk(e.onBlur,()=>v(!1))})})},`RovingFocusGroupImpl`)),JF=`RovingFocusGroupItem`,YF=L.forwardRef(FF(function(e,t){let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:a,children:o,...s}=e,c=LA(),l=a||c,u=GF(JF,n),d=u.currentTabStopId===l,f=BF(n),{onFocusableItemAdd:p,onFocusableItemRemove:m,currentTabStopId:h}=u,g=NF();return MA(()=>{if(!(!g||!r))return p(),()=>m()},[g,r,p,m]),L.useEffect(()=>{if(!(g||!r))return p(),()=>m()},[g,r,p,m]),(0,R.jsx)(zF.ItemSlot,{scope:n,id:l,focusable:r,active:i,children:(0,R.jsx)(pA.span,{tabIndex:d?0:-1,"data-orientation":u.orientation,...s,ref:t,onMouseDown:Fk(e.onMouseDown,e=>{r?u.onItemFocus(l):e.preventDefault()}),onFocus:Fk(e.onFocus,()=>u.onItemFocus(l)),onKeyDown:Fk(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){u.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=QF(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?eI(n,r+1):n.slice(r+1)}setTimeout(()=>$F(n))}}),children:typeof o==`function`?o({isCurrentTabStop:d,hasTabStop:h!=null}):o})})},`RovingFocusGroupItem`)),XF={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function ZF(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}FF(ZF,`getDirectionAwareKey`);function QF(e,t,n){let r=ZF(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return XF[r]}FF(QF,`getFocusIntent`);function $F(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}FF($F,`focusFirst`);function eI(e,t){return e.map((n,r)=>e[(t+r)%e.length])}FF(eI,`wrapArray`);var tI=KF,nI=YF,rI=function(e){return typeof document>`u`?null:(Array.isArray(e)?e[0]:e).ownerDocument.body},iI=new WeakMap,aI=new WeakMap,oI={},sI=0,cI=function(e){return e&&(e.host||cI(e.parentNode))},lI=function(e,t){return t.map(function(t){if(e.contains(t))return t;var n=cI(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})},uI=function(e,t,n,r){var i=lI(t,Array.isArray(e)?e:[e]);oI[n]||(oI[n]=new WeakMap);var a=oI[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=(iI.get(e)||0)+1,l=(a.get(e)||0)+1;iI.set(e,c),a.set(e,l),o.push(e),c===1&&i&&aI.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(),sI++,function(){o.forEach(function(e){var t=iI.get(e)-1,i=a.get(e)-1;iI.set(e,t),a.set(e,i),t||(aI.has(e)||e.removeAttribute(r),aI.delete(e)),i||e.removeAttribute(n)}),sI--,sI||(iI=new WeakMap,iI=new WeakMap,aI=new WeakMap,oI={})}},dI=function(e,t,n){n===void 0&&(n=`data-aria-hidden`);var r=Array.from(Array.isArray(e)?e:[e]),i=t||rI(e);return i?(r.push.apply(r,Array.from(i.querySelectorAll(`[aria-live], script`))),uI(r,i,n,`aria-hidden`)):function(){return null}},fI=Object.defineProperty,pI=(e,t)=>fI(e,`name`,{value:t,configurable:!0}),mI=[`Enter`,` `],hI=[`ArrowDown`,`PageUp`,`Home`],gI=[`ArrowUp`,`PageDown`,`End`],_I=[...hI,...gI];[...mI],[...mI];var vI=`Menu`,[yI,bI,xI]=VP(vI),[SI,CI]=Jk(vI,[xI,XM,UF]),wI=XM(),TI=UF(),[EI,DI]=SI(vI),[OI,kI]=SI(vI),AI=pI(e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=wI(t),[c,l]=L.useState(null),u=L.useRef(!1),d=_A(a),f=tF(i);return L.useEffect(()=>{let e=pI(()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},`handleKeyDown`),t=pI(()=>u.current=!1,`handlePointer`);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})}},[]),L.useEffect(()=>{if(!n)return;let e=pI(()=>d(!1),`handleBlur`);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,R.jsx)(fN,{...s,children:(0,R.jsx)(EI,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,R.jsx)(OI,{scope:t,onClose:L.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})},`Menu`),jI=L.forwardRef(pI(function(e,t){let{__scopeMenu:n,...r}=e,i=wI(n);return(0,R.jsx)(pN,{...i,...r,ref:t})},`MenuAnchor`)),MI=`MenuPortal`,[NI,PI]=SI(MI,{forceMount:void 0}),FI=pI(e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=DI(MI,t);return(0,R.jsx)(NI,{scope:t,forceMount:n,children:(0,R.jsx)(xN,{present:n||a.open,children:(0,R.jsx)(_N,{asChild:!0,container:i,children:r})})})},`MenuPortal`),II=`MenuContent`,[LI,RI]=SI(II),zI=L.forwardRef(pI(function(e,t){let n=PI(II,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=DI(II,e.__scopeMenu),o=kI(II,e.__scopeMenu);return(0,R.jsx)(yI.Provider,{scope:e.__scopeMenu,children:(0,R.jsx)(xN,{present:r||a.open,children:(0,R.jsx)(yI.Slot,{scope:e.__scopeMenu,children:o.modal?(0,R.jsx)(BI,{...i,ref:t}):(0,R.jsx)(VI,{...i,ref:t})})})})},`MenuContent`)),BI=L.forwardRef(pI(function(e,t){let n=DI(II,e.__scopeMenu),r=L.useRef(null),i=Wk(t,r);return L.useEffect(()=>{let e=r.current;if(e)return dI(e)},[]),(0,R.jsx)(UI,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:Fk(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentModal`)),VI=L.forwardRef(pI(function(e,t){let n=DI(II,e.__scopeMenu);return(0,R.jsx)(UI,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})},`MenuRootContentNonModal`)),HI=Qk(`MenuContent.ScrollLock`),UI=L.forwardRef(pI(function(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=DI(II,n),_=kI(II,n),v=wI(n),y=TI(n),b=bI(n),[x,S]=L.useState(null),C=L.useRef(null),w=Wk(t,C,g.onContentChange),T=L.useRef(0),E=L.useRef(``),D=L.useRef(0),O=L.useRef(null),k=L.useRef(`right`),A=L.useRef(0),j=m?wn:L.Fragment,M=m?{as:HI,allowPinchZoom:!0}:void 0,N=pI(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=dL(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;pI((function e(t){E.current=t,window.clearTimeout(T.current),t!==``&&(T.current=window.setTimeout(()=>e(``),1e3))}),`updateSearch`)(t),o&&setTimeout(()=>o.focus())},`handleTypeaheadSearch`);L.useEffect(()=>()=>window.clearTimeout(T.current),[]),sF();let P=L.useCallback(e=>k.current===O.current?.side&&pL(e,O.current?.area),[]);return(0,R.jsx)(LI,{scope:n,searchRef:E,onItemEnter:L.useCallback(e=>{P(e)&&e.preventDefault()},[P]),onItemLeave:L.useCallback(e=>{P(e)||(C.current?.focus(),S(null))},[P]),onTriggerLeave:L.useCallback(e=>{P(e)&&e.preventDefault()},[P]),pointerGraceTimerRef:D,onPointerGraceIntentChange:L.useCallback(e=>{O.current=e},[]),children:(0,R.jsx)(j,{...M,children:(0,R.jsx)(mF,{asChild:!0,trapped:i,onMountAutoFocus:Fk(a,e=>{e.preventDefault(),C.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,R.jsx)(TA,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:l,onPointerDownOutside:u,onFocusOutside:d,onInteractOutside:f,onDismiss:p,children:(0,R.jsx)(tI,{asChild:!0,...y,dir:_.dir,orientation:`vertical`,loop:r,currentTabStopId:x,onCurrentTabStopIdChange:S,onEntryFocus:Fk(c,e=>{_.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,R.jsx)(mN,{role:`menu`,"aria-orientation":`vertical`,"data-state":oL(g.open),"data-radix-menu-content":``,dir:_.dir,...v,...h,ref:w,style:{outline:`none`,...h.style},onKeyDown:Fk(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||!_I.includes(e.key))return;e.preventDefault();let a=b().filter(e=>!e.disabled).map(e=>e.ref.current);gI.includes(e.key)&&a.reverse(),lL(a)}),onBlur:Fk(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(T.current),E.current=``)}),onPointerMove:Fk(e.onPointerMove,mL(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}}))})})})})})})},`MenuContentImpl`)),WI=L.forwardRef(pI(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(pA.div,{role:`group`,...r,ref:t})},`MenuGroup`)),GI=L.forwardRef(pI(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(pA.div,{...r,ref:t})},`MenuLabel`)),KI=`MenuItem`,qI=`menu.itemSelect`,JI=L.forwardRef(pI(function(e,t){let{disabled:n=!1,onSelect:r,...i}=e,a=L.useRef(null),o=kI(KI,e.__scopeMenu),s=RI(KI,e.__scopeMenu),c=Wk(t,a),l=L.useRef(!1),u=pI(()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(qI,{bubbles:!0,cancelable:!0});e.addEventListener(qI,e=>r?.(e),{once:!0}),mA(e,t),t.defaultPrevented?l.current=!1:o.onClose()}},`handleSelect`);return(0,R.jsx)(YI,{...i,ref:c,disabled:n,onClick:Fk(e.onClick,u),onPointerDown:t=>{e.onPointerDown?.(t),l.current=!0},onPointerUp:Fk(e.onPointerUp,e=>{l.current||e.currentTarget?.click()}),onKeyDown:Fk(e.onKeyDown,e=>{n||e.target!==e.currentTarget||s.searchRef.current!==``&&e.key===` `||mI.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})},`MenuItem`)),YI=L.forwardRef(pI(function(e,t){let{__scopeMenu:n,disabled:r=!1,textValue:i,...a}=e,o=RI(KI,n),s=TI(n),c=L.useRef(null),l=Wk(t,c),[u,d]=L.useState(!1),[f,p]=L.useState(``);return L.useEffect(()=>{let e=c.current;e&&p((e.textContent??``).trim())},[a.children]),(0,R.jsx)(yI.ItemSlot,{scope:n,disabled:r,textValue:i??f,children:(0,R.jsx)(nI,{asChild:!0,...s,focusable:!r,children:(0,R.jsx)(pA.div,{role:`menuitem`,"data-highlighted":u?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...a,ref:l,onPointerMove:Fk(e.onPointerMove,mL(e=>{r?o.onItemLeave(e):(o.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:Fk(e.onPointerLeave,mL(e=>o.onItemLeave(e))),onFocus:Fk(e.onFocus,()=>d(!0)),onBlur:Fk(e.onBlur,()=>d(!1))})})})},`MenuItemImpl`)),[XI,ZI]=SI(`MenuRadioGroup`,{value:void 0,onValueChange:pI(()=>{},`onValueChange`)}),QI=L.forwardRef(pI(function(e,t){let{value:n,onValueChange:r,...i}=e,a=_A(r);return(0,R.jsx)(XI,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,R.jsx)(WI,{...i,ref:t})})},`MenuRadioGroup`)),$I=`MenuRadioItem`,eL=L.forwardRef(pI(function(e,t){let{value:n,...r}=e,i=ZI($I,e.__scopeMenu),a=n===i.value;return(0,R.jsx)(nL,{scope:e.__scopeMenu,checked:a,children:(0,R.jsx)(JI,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":cL(a),onSelect:Fk(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})},`MenuRadioItem`)),tL=`MenuItemIndicator`,[nL,rL]=SI(tL,{checked:!1}),iL=L.forwardRef(pI(function(e,t){let{__scopeMenu:n,forceMount:r,...i}=e,a=rL(tL,n);return(0,R.jsx)(xN,{present:r||sL(a.checked)||a.checked===!0,children:(0,R.jsx)(pA.span,{...i,ref:t,"data-state":cL(a.checked)})})},`MenuItemIndicator`)),aL=L.forwardRef(pI(function(e,t){let{__scopeMenu:n,...r}=e;return(0,R.jsx)(pA.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})},`MenuSeparator`)),[Nte,Pte]=SI(`MenuSub`);function oL(e){return e?`open`:`closed`}pI(oL,`getOpenState`);function sL(e){return e===`indeterminate`}pI(sL,`isIndeterminate`);function cL(e){return sL(e)?`indeterminate`:e?`checked`:`unchecked`}pI(cL,`getCheckedState`);function lL(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}pI(lL,`focusFirst`);function uL(e,t){return e.map((n,r)=>e[(t+r)%e.length])}pI(uL,`wrapArray`);function dL(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=uL(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}pI(dL,`getNextMatch`);function fL(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}pI(fL,`isPointInPolygon`);function pL(e,t){return t?fL({x:e.clientX,y:e.clientY},t):!1}pI(pL,`isPointerInGraceArea`);function mL(e){return t=>t.pointerType===`mouse`?e(t):void 0}pI(mL,`whenMouse`);var hL=AI,gL=jI,_L=FI,vL=zI,yL=WI,bL=GI,xL=JI,SL=QI,CL=eL,wL=iL,TL=aL,EL=Object.defineProperty,DL=(e,t)=>EL(e,`name`,{value:t,configurable:!0}),OL=`DropdownMenu`,[kL,Fte]=Jk(OL,[CI]),AL=CI(),[jL,ML]=kL(OL),NL=DL(e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:i,defaultOpen:a,onOpenChange:o,modal:s=!0}=e,c=AL(t),l=L.useRef(null),[u,d]=FN({prop:i,defaultProp:a??!1,onChange:o,caller:OL});return(0,R.jsx)(jL,{scope:t,triggerId:LA(),triggerRef:l,contentId:LA(),open:u,onOpenChange:d,onOpenToggle:L.useCallback(()=>d(e=>!e),[d]),modal:s,children:(0,R.jsx)(hL,{...c,open:u,onOpenChange:d,dir:r,modal:s,children:n})})},`DropdownMenu`),PL=`DropdownMenuTrigger`,FL=L.forwardRef(DL(function(e,t){let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,a=ML(PL,n),o=AL(n),s=Wk(t,a.triggerRef);return(0,R.jsx)(gL,{asChild:!0,...o,children:(0,R.jsx)(pA.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:Fk(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(a.onOpenToggle(),a.open||e.preventDefault())}),onKeyDown:Fk(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&a.onOpenToggle(),e.key===`ArrowDown`&&a.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})},`DropdownMenuTrigger`)),IL=DL(e=>{let{__scopeDropdownMenu:t,...n}=e,r=AL(t);return(0,R.jsx)(_L,{...r,...n})},`DropdownMenuPortal`),LL=`DropdownMenuContent`,RL=L.forwardRef(DL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=ML(LL,n),a=AL(n),o=L.useRef(!1);return(0,R.jsx)(vL,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:Fk(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:Fk(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)`}})},`DropdownMenuContent`)),zL=L.forwardRef(DL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=AL(n);return(0,R.jsx)(yL,{...i,...r,ref:t})},`DropdownMenuGroup`)),BL=L.forwardRef(DL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=AL(n);return(0,R.jsx)(bL,{...i,...r,ref:t})},`DropdownMenuLabel`)),VL=L.forwardRef(DL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=AL(n);return(0,R.jsx)(xL,{...i,...r,ref:t})},`DropdownMenuItem`)),HL=L.forwardRef(DL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=AL(n);return(0,R.jsx)(SL,{...i,...r,ref:t})},`DropdownMenuRadioGroup`)),UL=L.forwardRef(DL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=AL(n);return(0,R.jsx)(CL,{...i,...r,ref:t})},`DropdownMenuRadioItem`)),WL=L.forwardRef(DL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=AL(n);return(0,R.jsx)(wL,{...i,...r,ref:t})},`DropdownMenuItemIndicator`)),GL=L.forwardRef(DL(function(e,t){let{__scopeDropdownMenu:n,...r}=e,i=AL(n);return(0,R.jsx)(TL,{...i,...r,ref:t})},`DropdownMenuSeparator`)),KL=NL,qL=FL,JL=IL,YL=RL,XL=zL,ZL=BL,QL=VL,$L=HL,eR=UL,tR=WL,nR=GL;function rR({modal:e=!1,...t}){return(0,R.jsx)(KL,{modal:e,...t})}var iR=qL;function aR({children:e,align:t=`end`,sideOffset:n=6}){return(0,R.jsx)(JL,{children:(0,R.jsx)(YL,{align:t,sideOffset:n,className:`${AP} min-w-[184px] overflow-hidden rounded-lg p-1`,children:e})})}function oR({children:e,onSelect:t,icon:n,danger:r}){return(0,R.jsxs)(QL,{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-danger data-[highlighted]:text-danger-soft`:`text-muted data-[highlighted]:text-fg`}`,children:[n&&(0,R.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:n}),e]})}function sR(){return(0,R.jsx)(nR,{className:`my-1 h-px bg-border`})}var cR=(0,L.memo)(function({slug:e,size:t=`md`,onDone:n,doneBusy:r,onMutateStart:i,onApplied:a,onFailed:o}){let[s,c]=(0,L.useState)(`done`),[l,u]=(0,L.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,R.jsxs)(`div`,{className:`flex items-stretch overflow-hidden rounded-md border border-border-strong`,children:[(0,R.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,R.jsx)(M_,{size:p?11:12,className:`animate-spin`}),`Mark as `,s]}),(0,R.jsxs)(rR,{children:[(0,R.jsx)(iR,{"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,R.jsx)(t_,{size:p?11:12})}),(0,R.jsx)(aR,{children:BD.map(e=>(0,R.jsxs)(oR,{onSelect:()=>c(e),children:[`Mark as `,e]},e))})]})]})}),lR=Object.defineProperty,uR=(e,t)=>lR(e,`name`,{value:t,configurable:!0}),dR=`Dialog`,[fR,Ite]=Jk(dR),[pR,mR]=fR(dR),hR=uR(e=>{let{__scopeDialog:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!0}=e,s=L.useRef(null),c=L.useRef(null),[l,u]=FN({prop:r,defaultProp:i??!1,onChange:a,caller:dR}),[d,f]=L.useState(0),[p,m]=L.useState(0);return(0,R.jsx)(pR,{scope:t,triggerRef:s,contentRef:c,contentId:LA(),titleId:LA(),descriptionId:LA(),titlePresent:d>0,descriptionPresent:p>0,setTitleCount:f,setDescriptionCount:m,open:l,onOpenChange:u,onOpenToggle:L.useCallback(()=>u(e=>!e),[u]),modal:o,children:n})},`Dialog`),gR=`DialogPortal`,[_R,vR]=fR(gR,{forceMount:void 0}),yR=uR(e=>{let{__scopeDialog:t,forceMount:n,children:r,container:i}=e,a=mR(gR,t);return(0,R.jsx)(_R,{scope:t,forceMount:n,children:L.Children.map(r,e=>(0,R.jsx)(xN,{present:n||a.open,children:(0,R.jsx)(_N,{asChild:!0,container:i,children:e})}))})},`DialogPortal`),bR=`DialogOverlay`,xR=L.forwardRef(uR(function(e,t){let n=vR(bR,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=mR(bR,e.__scopeDialog);return a.modal?(0,R.jsx)(xN,{present:r||a.open,children:(0,R.jsx)(CR,{...i,ref:t})}):null},`DialogOverlay`)),SR=Qk(`DialogOverlay.RemoveScroll`),CR=L.forwardRef(uR(function(e,t){let{__scopeDialog:n,...r}=e,i=mR(bR,n),a=Wk(t,EA());return(0,R.jsx)(wn,{as:SR,allowPinchZoom:!0,shards:[i.contentRef],children:(0,R.jsx)(pA.div,{"data-state":NR(i.open),...r,ref:a,style:{pointerEvents:`auto`,...r.style}})})},`DialogOverlayImpl`)),wR=`DialogContent`,TR=L.forwardRef(uR(function(e,t){let n=vR(wR,e.__scopeDialog),{forceMount:r=n.forceMount,...i}=e,a=mR(wR,e.__scopeDialog);return(0,R.jsx)(xN,{present:r||a.open,children:a.modal?(0,R.jsx)(ER,{...i,ref:t}):(0,R.jsx)(DR,{...i,ref:t})})},`DialogContent`)),ER=L.forwardRef(uR(function(e,t){let n=mR(wR,e.__scopeDialog),r=L.useRef(null),i=Wk(t,n.contentRef,r);return L.useEffect(()=>{let e=r.current;if(e)return dI(e)},[]),(0,R.jsx)(OR,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,onCloseAutoFocus:Fk(e.onCloseAutoFocus,e=>{e.preventDefault(),n.triggerRef.current?.focus()}),onPointerDownOutside:Fk(e.onPointerDownOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0;(t.button===2||n)&&e.preventDefault()}),onFocusOutside:Fk(e.onFocusOutside,e=>e.preventDefault())})},`DialogContentModal`)),DR=L.forwardRef(uR(function(e,t){let n=mR(wR,e.__scopeDialog),r=L.useRef(!1),i=L.useRef(!1);return(0,R.jsx)(OR,{...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()}})},`DialogContentNonModal`)),OR=L.forwardRef(uR(function(e,t){let{__scopeDialog:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,...o}=e,s=mR(wR,n);return sF(),(0,R.jsx)(R.Fragment,{children:(0,R.jsx)(mF,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,R.jsx)(TA,{role:`dialog`,id:s.contentId,"aria-describedby":s.descriptionPresent?s.descriptionId:void 0,"aria-labelledby":s.titlePresent?s.titleId:void 0,"data-state":NR(s.open),...o,ref:t,deferPointerDownOutside:!0,onDismiss:()=>s.onOpenChange(!1)})})})},`DialogContentImpl`)),kR=`DialogTitle`,AR=L.forwardRef(uR(function(e,t){let{__scopeDialog:n,...r}=e,i=mR(kR,n),{setTitleCount:a}=i;return MA(()=>(a(e=>e+1),()=>a(e=>e-1)),[a]),(0,R.jsx)(pA.h2,{id:i.titleId,...r,ref:t})},`DialogTitle`)),jR=`DialogClose`,MR=L.forwardRef(uR(function(e,t){let{__scopeDialog:n,...r}=e,i=mR(jR,n);return(0,R.jsx)(pA.button,{type:`button`,...r,ref:t,onClick:Fk(e.onClick,()=>i.onOpenChange(!1))})},`DialogClose`));function NR(e){return e?`open`:`closed`}uR(NR,`getState`);var PR=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`]),FR=/[a-zA-Z_][a-zA-Z0-9_-]*/y,IR=/^-?(?:0|[1-9]\d*)(?:\.\d+)?$/;function LR(e){let t={},n=0;for(;n<e.length;){for(;/\s/.test(e[n]??``);)n++;if(n>=e.length)break;FR.lastIndex=n;let r=FR.exec(e);if(!r||Object.hasOwn(t,r[0]))return null;let i=r[0];if(n=FR.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(IR.test(a))t[i]=Number(a);else return null}if(n<e.length&&!/\s/.test(e[n]))return null}return t}function RR(e){let t=e.match(/^\s*::([a-z][a-z0-9-]*)\{([^\n]*)\}\s*$/);if(!t||!PR.has(t[1]))return null;let n=LR(t[2]);return n?{name:t[1],attrs:n}:null}var zR=/^(?:[-*+]|\d{1,3}[.)])\s+/,BR=/^!?\[([^\]]*)\]\((.+)\)$/,VR=/\s+"[^"]*"$/,HR=/\.(?:png|jpe?g|gif|webp|mp4|m4v|webm|mov)(?=$|[\s:|,;—–])/i,UR=/^[\s:|,;—–-]+/,WR=/^(["'“‘])(.*)(["'”’])$/;function GR(e){let t=e.replace(UR,``).trim(),n=WR.exec(t);return n&&(t=n[2].trim()),t||void 0}function KR(e){let t=e.trim().replace(zR,``);if(!t)return null;let n=BR.exec(t);if(n){let e=n[2].trim();return e=e.startsWith(`<`)&&e.endsWith(`>`)?e.slice(1,-1).trim():e.replace(VR,``),{target:e,caption:GR(n[1])}}let r=/^`([^`]+)`(.*)$/.exec(t);if(r)return{target:r[1].trim(),caption:GR(r[2])};let i=HR.exec(t);if(!i)return{target:t};let a=i.index+i[0].length;return{target:t.slice(0,a),caption:GR(t.slice(a))}}function qR(e){let t=[];for(let n of e.split(`
|
|
184
|
+
`)){let e=KR(n);e&&t.push(e)}return t}function JR(e,t){let n=zT(qT(e,t.dir,t.home)??e);return n?.filePath&&(HT(n)||WT(n.filePath))?n.filePath:null}function YR(e){return WT(e)}function XR(e,t){return e.caption?{label:e.caption,captioned:!0}:e.title?{label:e.title,captioned:!0}:{label:xh(t??e.target),captioned:!1}}var ZR=/\.(?:png|jpe?g|gif|webp|mp4|m4v|webm|mov)$/i;function QR(e,t){let n=t?.trim()??``,r=n!==``&&!ZR.test(n);return{path:e,label:r?n:xh(n||e),captioned:r}}var $R=String.raw`(?:[^\s\`]|[ ](?!/))+`,ez=new RegExp(String.raw`^\s*\`?(/${$R}\.(?:png|jpe?g|gif|webp))\`?\s*$`,`i`),tz=new RegExp(String.raw`^\s*\`?(/${$R}\.(?:${lu.join(`|`)}))\`?\s*$`,`i`),nz=/^\s{0,3}(?:```|~~~)/,rz=/^\s{0,3}(`{3,}|~{3,})\s*(mermaid|lightbox)\s*$/i,iz=/^\s*::codex-inline-vis\{file="([a-z0-9][a-z0-9-]{0,127}\.html)"\}\s*$/;function az(e){let t=e.split(`
|
|
185
185
|
`),n=[],r=[],i=Kl(e),a=[],o=0;for(let e of t)a.push(o),o+=e.length+1;let s=()=>{if(r.length){let e=r.join(`
|
|
186
|
-
`);e.trim()&&n.push({kind:`md`,text:e}),r=[]}};for(let e=0;e<t.length;e++){let o=t[e];if(i(a[e])){r.push(o);continue}let c=o.match(
|
|
187
|
-
`);if(c[2].toLowerCase()===`mermaid`)n.push({kind:`mermaid`,source:r});else{let e=
|
|
188
|
-
`),n=Array(t.length),r=!1;for(let e=0;e<t.length;e++)
|
|
189
|
-
`),attachments:i}}function
|
|
186
|
+
`);e.trim()&&n.push({kind:`md`,text:e}),r=[]}};for(let e=0;e<t.length;e++){let o=t[e];if(i(a[e])){r.push(o);continue}let c=o.match(rz);if(c){let r=c[1],i=RegExp(`^\\s{0,3}${r[0]==="`"?"`":`~`}{${r.length},}\\s*$`),a=e+1;for(;a<t.length&&!i.test(t[a]);)a++;if(a<t.length){s();let r=t.slice(e+1,a).join(`
|
|
187
|
+
`);if(c[2].toLowerCase()===`mermaid`)n.push({kind:`mermaid`,source:r});else{let e=qR(r);e.length>0&&n.push({kind:`lightbox`,entries:e})}e=a;continue}}if(nz.test(o)){r.push(o);continue}let l=o.match(iz);if(l){s(),n.push({kind:`visualization`,file:l[1]});continue}let u=RR(o);if(u){s(),n.push({kind:`directive`,directive:u});continue}let d=o.match(ez);if(d){s(),n.push({kind:`image`,path:d[1]});continue}let f=o.match(tz);if(f){s(),n.push({kind:`file`,path:f[1]});continue}r.push(o)}return s(),n}function oz(e){let t=e.split(`
|
|
188
|
+
`),n=Array(t.length),r=!1;for(let e=0;e<t.length;e++)nz.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(ez),r=n?null:e.match(tz);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(`
|
|
189
|
+
`),attachments:i}}function sz(e,t){return t.length?`${e}${e?`
|
|
190
190
|
`:``}${t.join(`
|
|
191
|
-
`)}`:e}function
|
|
192
|
-
`){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
|
|
191
|
+
`)}`:e}function cz(e){let t=xh(e.display??e.path??``);return e.startLine===void 0||e.endLine===void 0?t:e.startLine===e.endLine?`${t}:${e.startLine}`:`${t}:${e.startLine}-${e.endLine}`}function lz(e){return e.startsWith(`@`)?e.slice(1):e}function uz(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}var dz=`(?![0-9#]|-\\d)`;function fz(e,t){return new RegExp(uz(t)+dz).test(e)}function pz(e,t){let n=new RegExp(uz(t)+dz).exec(e);return n?n.index:-1}function Lte(e,t,n){let r=`@${e}`,i=e=>t.some(t=>t.token===e)||fz(n,e);if(!i(r))return r;for(let e=2;;e++)if(!i(`${r}#${e}`))return`${r}#${e}`}function Rte(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 mz(e,t){if(!t.length||!e)return e?[{text:e}]:[];let n=[...new Set(t)].sort((e,t)=>t.length-e.length).map(uz).join(`|`),r=RegExp(`(${n})${dz}`,`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 zte(e,t){let n=[],r=``,i=1,a=!1;for(let t of e){if(t===`
|
|
192
|
+
`){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 Bte(e,t){return t&&Th(t,e)||e}function Vte(e){return e.startLine===void 0||e.endLine===void 0?``:e.startLine===e.endLine?`, line ${e.startLine}`:`, lines ${e.startLine}-${e.endLine}`}function Hte(e,t){return e.length?`Selected context:\n\n${e.map(e=>{let n=e.text.replace(/\s+$/,``).split(`
|
|
193
193
|
`).map(e=>`> ${e}`).join(`
|
|
194
|
-
`);return`${e.token} (${
|
|
194
|
+
`);return`${e.token} (${Bte(e.path,t)}${Vte(e)}):\n${n}`}).join(`
|
|
195
195
|
|
|
196
|
-
`)}`:``}function
|
|
196
|
+
`)}`:``}function Ute(e,t,n){let{prose:r,attachments:i}=oz(e),a=Hte(t.filter(e=>fz(r,e.token)).sort((e,t)=>pz(r,e.token)-pz(r,t.token)),n);return a?sz(r.trimEnd()?`${r.trimEnd()}\n\n${a}`:a,i.map(e=>e.path)):e}var Wte=`Selected context:
|
|
197
197
|
|
|
198
|
-
`;function
|
|
198
|
+
`;function Gte(e){let t=e.lastIndexOf(Wte);if(t===-1||t!==0&&e.slice(t-2,t)!==`
|
|
199
199
|
|
|
200
200
|
`)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(`
|
|
201
201
|
`),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(`
|
|
202
|
-
`)})}return!i.length||!i.every(e=>pz(n,e.token))?null:{body:n,items:i}}function gz(e){return e.key===`Enter`&&!e.altKey&&!e.shiftKey&&!e.isComposing&&e.keyCode!==229}function Gte(e,t){return t&&gz(e)&&!e.metaKey&&!e.ctrlKey}function Kte(e,t){return t&&gz(e)&&(e.metaKey||e.ctrlKey)}function qte(e,t){return!t&&e?.runtime===`running`&&e.backend!==`codex`&&e.backend!==`acp`}function _z(e){return gz(e)}function Jte(e){return e.key===`Enter`&&e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing}function Yte(e,t,n){return e===`queueComposer`&&t===`Enter`&&n}var Xte=.5;function vz(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*Xte,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 Zte(e,t,n,r){return!e||e.top<=r&&e.bottom>r?!0:Math.abs(t-n)>1}function Qte(e,t,n,r,i=8){return n<e+i?n-e-i:r>t-i?r-t+i:0}function yz(){return[...document.querySelectorAll(`[data-queue-card][data-queue-leaving="false"]`)].flatMap(e=>{let t=e.dataset.queueCard;if(!t)return[];let{top:n,bottom:r}=(e.querySelector(`[data-queue-card-root]`)??e).getBoundingClientRect();return[{id:t,top:n,bottom:r}]})}function bz(){let e=Math.max(0,document.documentElement.scrollHeight-window.innerHeight);return e>0&&window.scrollY>=e-1}var xz=new Map,Sz=!1;function $te(e,t){return xz.set(e,t),!Sz&&typeof window<`u`&&(window.addEventListener(`keydown`,ane),Sz=!0),()=>{xz.get(e)===t&&xz.delete(e)}}var Cz=`[role="dialog"][data-state="open"], [role="dialog"][aria-modal="true"]`,wz=`[data-queue-card-root]`;function ene(e){return e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?!0:e instanceof HTMLInputElement?![`button`,`checkbox`,`radio`,`submit`,`reset`].includes(e.type):e instanceof HTMLElement&&e.isContentEditable?!0:!!e.closest(`.xterm, [role="menu"], [role="listbox"], [role="menubar"], [role="combobox"]`)}function tne(e){return e.sort((e,t)=>e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)}function Tz(){return tne([...xz.keys()].filter(e=>e.isConnected&&e.getClientRects().length>0&&xz.get(e)?.keyed()))}function Ez(e){if(!e?.isConnected)return!1;let t=e.getBoundingClientRect(),n=Math.max(t.top,0),r=Math.min(t.bottom,window.innerHeight),i=Math.max(t.left,0),a=Math.min(t.right,window.innerWidth);if(r<=n||a<=i)return!1;let o=(i+a)/2;return[.25,.5,.75].some(t=>{let i=document.elementFromPoint(o,n+(r-n)*t);return!!i&&e.contains(i)})}function nne(e){let t=xz.get(e);if(!t)return!1;for(let e=1;e<=9;e++){let n=t.row(e);if(!n)break;if(Ez(n))return!0}return!1}function Dz(e){return e.closest(Cz)??e.closest(wz)??document.body}function Oz(e){return e.find(e=>!xz.get(e)?.answered())??e[0]??null}function rne(){let e=vz(yz(),window.innerHeight,bz());return e?document.querySelector(`[data-queue-card="${CSS.escape(e)}"] ${wz}`):null}function ine(e){let t=e?.closest(`[data-question-grid]`);if(t&&xz.has(t))return t;let n=Tz().filter(nne),r=document.querySelectorAll(Cz),i=r[r.length-1];if(i)return Oz(n.filter(e=>i.contains(e)));let a=e?.closest(wz);if(a)return Oz(n.filter(e=>a.contains(e)));let o=rne(),s=o&&n.find(e=>o.contains(e))||n[0];return s?Oz(n.filter(e=>Dz(e)===Dz(s))):null}function kz(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:`nearest`,behavior:`instant`})}function ane(e){if(e.defaultPrevented||e.repeat||e.isComposing||e.metaKey||e.ctrlKey||e.altKey||!/^[1-9]$/.test(e.key))return;let t=e.target instanceof Element?e.target:null;if(t&&ene(t))return;let n=ine(t),r=n&&xz.get(n);if(!n||!r)return;let i=Number(e.key);if(!Ez(r.row(i)))return;let a=r.press(i);if(a&&(e.preventDefault(),a!==`text`)){if(a===`toggled`)return kz(n);requestAnimationFrame(()=>{let e=Dz(n),t=Tz().filter(t=>Dz(t)===e&&(n.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)!==0);kz(t.find(e=>!xz.get(e)?.answered())??(n.isConnected?n:t[0]??n))})}}function one(e){let t=e.closest(Cz)??e.closest(wz);if(!t)return!1;let n=Oz(Tz().filter(e=>t.contains(e)));return n?(kz(n),!0):!1}var sne=[`lead`,`paperclip`,`action`,`mic`,`send`],cne=28,lne=8,une=8,Az={"paperclip>send":8,"action>send":7,"paperclip>action":0,"lead>paperclip":-1,"mic>send":6,"paperclip>mic":-2,"action>mic":-3};function dne(e){let t={send:!0,paperclip:!0,lead:!!e.lead,action:!!e.action,mic:!!e.mic},n=sne.filter(e=>t[e]),r={},i=0,a=null;for(let e of[...n].reverse())r[e]=a?i+(Az[`${e}>${a}`]??Az[`paperclip>send`]):lne,i=r[e]+cne,a=e;return{right:r,reserve:i+une}}function jz(){if(typeof window>`u`||!window.isSecureContext)return null;let e=window.SpeechRecognition;return typeof e?.available==`function`&&typeof e.install==`function`?e:null}function fne(e){let t=[...new Set(e.filter(Boolean))];return t.some(e=>/^en\b/i.test(e))&&!t.includes(`en-US`)&&t.push(`en-US`),t}var pne=/\bHeadlessChrome\/|\bElectron\//,Mz=`frizz:dictation-probe`,mne=6e4;function hne(){try{return window.localStorage}catch{return null}}async function gne(){let e=jz();if(!e||pne.test(navigator.userAgent))return null;let t=hne(),n=Number(t?.getItem(Mz)??0);if(n&&Date.now()-n>mne)return null;t?.setItem(Mz,String(Date.now()));try{return await _ne(e)}finally{t?.removeItem(Mz)}}async function _ne(e){for(let t of fne(navigator.languages??[navigator.language]))try{let n=await e.available({langs:[t],processLocally:!0});if(n!==`unavailable`)return{lang:t,status:n}}catch{}return null}var Nz;function vne(){return Nz??=gne(),Nz}var yne=[`Frizz`,`queue`,`pull request`,`type check`,`worktree`,`sub-agent`,`commit to main`],bne=2,xne=/^I(?:'[a-z]+)?\b/;function Pz(e){return/^[A-Z][a-z]/.test(e)&&!xne.test(e)?e[0].toLowerCase()+e.slice(1):e}function Sne(e){return e.map(e=>e.trim()).filter(Boolean).map((e,t)=>t===0?e:Pz(e)).join(` `)}function Cne(e,t,n){if(!t)return{text:e+n,caret:e.length};let r=/(?:^|[.!?]\s*|\n\s*)$/.test(e)?t[0].toUpperCase()+t.slice(1):Pz(t),i=e&&!/\s$/.test(e)?` `:``,a=n&&!/^\s/.test(n)?` `:``,o=e+i+r;return{text:o+a+n,caret:o.length}}var Fz=null;function Iz(e){switch(e){case`not-allowed`:case`service-not-allowed`:return`Microphone access is blocked for this site — allow it in the browser's site settings to dictate`;case`audio-capture`:return`No microphone was found`;case`language-not-supported`:return`The on-device speech model is not installed — click the microphone again to download it`;case`aborted`:case`no-speech`:return null;default:return`Dictation stopped (${e})`}}function wne(e){let t=e instanceof DOMException?e.name:``;return t===`NotAllowedError`||t===`SecurityError`?Iz(`not-allowed`):t===`NotFoundError`||t===`OverconstrainedError`?Iz(`audio-capture`):`The microphone could not start: ${e instanceof Error?e.message:String(e)}`}function Lz(e){for(let t of e.getTracks())t.stop()}function Tne({read:e,write:t,enabled:n=!0}){let[r,i]=(0,L.useState)(null),[a,o]=(0,L.useState)(`idle`),[s,c]=(0,L.useState)(null),l=(0,L.useRef)(null),u=(0,L.useRef)(!0),d=(0,L.useRef)(0),f=(0,L.useRef)(e);f.current=e;let p=(0,L.useRef)(t);p.current=t,(0,L.useEffect)(()=>{if(!n)return;let e=!0;return vne().then(t=>{e&&i(t)}),()=>{e=!1}},[n]);let m=(0,L.useCallback)(()=>{d.current++;let e=l.current;if(!e){o(e=>e===`starting`?`idle`:e);return}l.current=null,Fz===e&&(Fz=null),e.recognizer.onresult=null,e.recognizer.onerror=null,e.recognizer.onend=null,e.recognizer.abort(),Lz(e.stream),c(null),o(`idle`)},[]);(0,L.useEffect)(()=>(u.current=!0,()=>{u.current=!1,m()}),[m]),(0,L.useEffect)(()=>{n||m()},[n,m]);let h=(0,L.useCallback)(async e=>{let t=jz();if(!t)return;Fz?.abort(),o(`starting`);let n=d.current,r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){u.current&&o(`idle`),Z(wne(e));return}if(!u.current||n!==d.current)return Lz(r);let a=new t;a.lang=e,a.continuous=!0,a.interimResults=!0,a.processLocally=!0;let s=window.SpeechRecognitionPhrase;if(s)try{a.phrases=yne.map(e=>new s(e,bne))}catch{}let{prose:h,start:g,end:_}=f.current(),v=h.slice(0,g),y=h.slice(_),b={recognizer:a,stream:r,lastWritten:h,abort:()=>m()};a.onresult=e=>{if(f.current().prose!==b.lastWritten)return m();let t=Array.from(e.results,e=>e[0]?.transcript??``),n=Cne(v,Sne(t),y);b.lastWritten=n.text,p.current(n.text,n.caret)},a.onerror=e=>{let t=Iz(e.error);t&&Z(t),e.error===`language-not-supported`&&(Nz=void 0,i(e=>e&&{...e,status:`downloadable`}))},a.onend=()=>{Lz(r),l.current===b&&(l.current=null,Fz===b&&(Fz=null),c(null),o(`idle`))},l.current=b,Fz=b,c(r),o(`listening`);try{a.start(r.getAudioTracks()[0])}catch(e){m(),Z(`Dictation could not start: ${e instanceof Error?e.message:String(e)}`)}},[m]),g=(0,L.useCallback)(async()=>{if(l.current){l.current.recognizer.stop();return}let e=jz();if(!e||!r||a===`installing`||a===`starting`)return;let t=r.status;try{t=await e.available({langs:[r.lang],processLocally:!0})}catch{}if(t===`unavailable`){Z(`On-device dictation is not available in this browser`);return}if(t!==`available`){o(`installing`);let t=!1;try{t=await e.install({langs:[r.lang],processLocally:!0})}catch{t=!1}if(!t){o(`idle`),Z(`The on-device speech model could not be downloaded — try again later`);return}i({lang:r.lang,status:`available`})}await h(r.lang)},[r,a,h]);return{state:r&&n?a:`unsupported`,stream:s,toggle:g,cancel:m}}var Rz=[{x:5,y1:7,y2:17,band:[100,300]},{x:9.67,y1:4,y2:20,band:[300,900]},{x:14.33,y1:6,y2:18,band:[900,2200]},{x:19,y1:8,y2:16,band:[2200,5e3]}],zz=.3;function Ene({stream:e,size:t=15}){let n=(0,L.useRef)([]);return(0,L.useEffect)(()=>{let t=new AudioContext,r=t.createMediaStreamSource(e),i=t.createAnalyser();i.fftSize=1024,i.smoothingTimeConstant=.75,i.minDecibels=-85,i.maxDecibels=-30,r.connect(i);let a=new Uint8Array(i.frequencyBinCount),o=t.sampleRate/i.fftSize,s=Rz.map(({band:[e,t]})=>[Math.max(1,Math.floor(e/o)),Math.max(2,Math.ceil(t/o))]),c=0,l=()=>{i.getByteFrequencyData(a),s.forEach(([e,t],r)=>{let i=0;for(let n=e;n<t;n++)i+=a[n];let o=i/(t-e)/255;n.current[r]?.style.setProperty(`transform`,`scaleY(${zz+(1-zz)*o})`)}),c=requestAnimationFrame(l)};return l(),()=>{cancelAnimationFrame(c),r.disconnect(),t.close()}},[e]),(0,R.jsx)(`svg`,{"data-dictation-level":!0,width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,"aria-hidden":!0,children:Rz.map((e,t)=>(0,R.jsx)(`line`,{ref:e=>{n.current[t]=e},x1:e.x,x2:e.x,y1:e.y1,y2:e.y2,style:{transformBox:`fill-box`,transformOrigin:`center`,transform:`scaleY(${zz})`}},e.x))})}var Dne=60;function One({pinnedBottom:e,visual:t}){if(!t||Math.abs(t.scale-1)>.01)return 0;let n=e-(t.offsetTop+t.height);return n>=Dne?Math.round(n):0}function Bz(e,t){let[n,r]=(0,L.useState)(0);return(0,L.useLayoutEffect)(()=>{if(!t||typeof window>`u`){r(0);return}let n=0,i=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>{let t=e.current;if(!t)return;let n=window.visualViewport;r(One({pinnedBottom:t.getBoundingClientRect().bottom,visual:n?{offsetTop:n.offsetTop,height:n.height,scale:n.scale}:null}))})};i();let a=window.visualViewport;return a?.addEventListener(`resize`,i),a?.addEventListener(`scroll`,i),window.addEventListener(`resize`,i),window.addEventListener(`focusin`,i),window.addEventListener(`focusout`,i),()=>{cancelAnimationFrame(n),a?.removeEventListener(`resize`,i),a?.removeEventListener(`scroll`,i),window.removeEventListener(`resize`,i),window.removeEventListener(`focusin`,i),window.removeEventListener(`focusout`,i)}},[e,t]),t?n:0}async function kne(e,t){let n=sm(),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 Vz={project:`project`,user:`global`,builtin:`built-in`,plugin:`plugin`},Ane=500,Hz=(0,L.createContext)(null);function jne(e,t){e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,t)}px`}function Uz({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,railLead:f,contextTokens:p,slashSuggest:m,onInterruptSubmit:h,phone:g,onUploadingChange:_}){let v=(0,L.useRef)(null),y=(0,L.useRef)(null),b=(0,L.useRef)(null),[x,S]=(0,L.useState)(!1),[C,w]=(0,L.useState)(!1),{prose:T,attachments:E}=(0,L.useMemo)(()=>sz(e),[e]),D=E.map(e=>e.path),O=(0,L.useRef)(e);O.current=e;let k=e=>t(cz(e,D)),A=e=>t(cz(T,e));async function j(e){if(!e)return;if(C){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})=>mu(e)?!0:(Z(`${e||`File`}: unsupported file type`),!1));if(!n.length)return;let r=n.filter(({file:e,name:t})=>e.size>du?(Z(`${t} is too large (max ${Math.floor(du/1e6)} MB)`),!1):!0);if(!r.length)return;let i=O.current;w(!0);let a=[];try{for(let{file:e,name:t}of r){let n=await kne(e,t);n?a.push(n):Z(`Could not attach ${t}`)}}finally{w(!1)}if(a.length&&i!==``&&O.current===``){Z(`Attachment discarded — the message was sent before the upload finished`),requestAnimationFrame(()=>v.current?.focus());return}if(a.length){let e=sz(O.current);t(cz(e.prose,[...e.attachments.map(e=>e.path),...a]))}requestAnimationFrame(()=>v.current?.focus())}(0,L.useLayoutEffect)(()=>{let e=!0,t=()=>{let t=v.current;!t||!e||jne(t,s)};t();let n=requestAnimationFrame(t);document.fonts?.ready.then(t);let r=v.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 M=(0,L.useMemo)(()=>p??[],[p]),N=(0,L.useMemo)(()=>{if(M.length===0)return null;let e=hz(T,M);return e.some(e=>e.token)?e.map((e,t)=>e.token?(0,R.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},[T,M]),P=()=>{let e=v.current,t=y.current;e&&t&&(t.scrollTop=e.scrollTop)};(0,L.useLayoutEffect)(P);let F=(0,L.useRef)(!1);(0,L.useEffect)(()=>{let e=v.current;if(!e)return;let t=()=>{F.current=e.disabled};return e.addEventListener(`focusout`,t),()=>e.removeEventListener(`focusout`,t)},[]),(0,L.useEffect)(()=>{if(l||!F.current)return;F.current=!1;let e=v.current,t=document.activeElement;e&&(!t||t.contains(e))&&e.focus({preventScroll:!0})},[l]);let[I,ee]=(0,L.useState)(null),[te,ne]=(0,L.useState)({prose:``,index:0}),re=te.prose===T?te.index:0,ie=e=>ne({prose:T,index:typeof e==`function`?e(re):e}),[ae,oe]=(0,L.useState)(null),se=!!m&&/^\/\S*$/.test(T);(0,L.useEffect)(()=>{if(!se||I!==null)return;let e=!0;return m().then(t=>{e&&ee(t)},()=>{e&&ee([])}),()=>{e=!1}},[se,I,m]);let ce=(0,L.useMemo)(()=>{if(!se||!I||ae===T)return[];let e=T.slice(1).toLowerCase(),t=I.filter(t=>t.name.toLowerCase().startsWith(e)),n=I.filter(t=>!t.name.toLowerCase().startsWith(e)&&t.name.toLowerCase().includes(e));return[...t,...n]},[se,I,ae,T]),le=ce.length>0,ue=(0,L.useMemo)(()=>{let e=new Set;for(let t of ce)t.source&&e.add(Vz[t.source]);return[...e]},[ce]),de=(0,L.useRef)(null);(0,L.useEffect)(()=>{de.current?.querySelector(`[data-suggest-index="${re}"]`)?.scrollIntoView({block:`nearest`})},[re]);function fe(e){let t=`/${e.name} `;k(t),requestAnimationFrame(()=>v.current?.setSelectionRange(t.length,t.length))}let{dictation:pe}=gr(zD),me=Tne({read:()=>{let e=v.current,t=e?.value??T,n=e!==null&&document.activeElement===e;return{prose:t,start:n?e.selectionStart:t.length,end:n?e.selectionEnd:t.length}},write:(e,t)=>{k(e),requestAnimationFrame(()=>v.current?.setSelectionRange(t,t))},enabled:pe}),he=!g&&me.state!==`unsupported`,ge=()=>{me.cancel(),n()},_e=e.trim().length>0,ve=d??null,ye=dne({action:!!ve,lead:!!f,mic:he});function be(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(le&&!e.nativeEvent.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),ie(t=>(t+(e.key===`ArrowDown`?1:-1)+ce.length)%ce.length);return}if((e.key===`Enter`||e.key===`Tab`)&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey){e.preventDefault(),e.stopPropagation(),fe(ce[re]??ce[0]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),oe(T);return}}if(e.key===`Backspace`&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&M.length>0&&t.selectionStart===t.selectionEnd){let n=t.selectionStart,r=hz(t.value.slice(0,n),M).at(-1);if(r?.token){e.preventDefault();let i=n-r.text.length;k(t.value.slice(0,i)+t.value.slice(n)),requestAnimationFrame(()=>t.setSelectionRange(i,i));return}}if(Yte(r,e.key,e.altKey)){e.preventDefault(),e.stopPropagation();let n=t.selectionStart??t.value.length,r=t.selectionEnd??n;k(t.value.slice(0,n)+`
|
|
203
|
-
`+t.value.slice(r)),requestAnimationFrame(()=>t.setSelectionRange(n+1,n+1));return}let a=_e&&!l&&!C;if(
|
|
204
|
-
`+e.slice(r)),requestAnimationFrame(()=>t.setSelectionRange(n+1,n+1)))})}if(e.key===`Escape`&&!e.nativeEvent.isComposing){if(me.state===`listening`){e.preventDefault(),e.stopPropagation(),me.cancel();return}if(e.currentTarget.closest(`[data-standalone-thread]`))return;e.preventDefault(),e.stopPropagation(),one(t)||t.blur()}}let xe=le?(0,R.jsx)(`div`,{ref:de,"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:ce.map((e,t)=>(0,R.jsxs)(`button`,{type:`button`,"data-suggest-index":t,onMouseDown:e=>e.preventDefault(),onClick:()=>fe(e),onMouseEnter:()=>ie(t),className:`flex w-full items-baseline gap-2 px-3.5 py-1.5 text-left ${t===re?`bg-panel-2`:``}`,children:[(0,R.jsxs)(`span`,{className:`shrink-0 text-[12px] font-medium text-fg`,children:[`/`,e.name]}),e.description&&(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-muted`,children:e.description}),ue.length>0&&(0,R.jsxs)(`span`,{className:`ml-auto grid shrink-0 text-[10px]`,children:[ue.map(e=>(0,R.jsx)(`span`,{"aria-hidden":!0,className:`petite-caps invisible col-start-1 row-start-1`,children:e},e)),(0,R.jsx)(`span`,{className:`petite-caps col-start-1 row-start-1 text-right text-muted-70`,children:e.source?Vz[e.source]:``})]})]},e.name))}):null,[Se,Ce]=(0,L.useState)(!1),[we,Te]=(0,L.useState)(!1),Ee=(0,L.useRef)(null),De=Bz(Ee,!!g),Oe=(0,L.useRef)(void 0),ke=(0,L.useRef)(!1);(0,L.useEffect)(()=>()=>clearTimeout(Oe.current),[]);let Ae=(0,L.useRef)(_);if(Ae.current=_,(0,L.useEffect)(()=>{Ae.current?.(C)},[C]),g){let e=_e&&!l&&!C,t=g.layout===`page`,u=!t&&(Se||we||_e||E.length>0),d=t?`px-[18px] py-[14px] text-[17px] leading-[25px]`:u?`px-3 pt-[10px] pb-1 text-[16px] leading-[22px]`:`px-[14px] py-[10px] text-[16px] leading-[20px]`,f=t?{minHeight:o,maxHeight:s}:u?{minHeight:44,maxHeight:176}:{minHeight:40,maxHeight:40},p=(0,R.jsx)(`input`,{ref:b,type:`file`,multiple:!0,accept:hu,className:`hidden`,onChange:e=>{j(e.target.files),e.target.value=``}}),m=e=>(0,R.jsx)(`button`,{type:`button`,"data-phone-attach":!0,onMouseDown:e=>e.preventDefault(),onClick:()=>b.current?.click(),disabled:l||C,title:`Attach files`,"aria-label":`Attach files`,className:`relative flex shrink-0 items-center justify-center rounded-full border border-border-strong bg-panel text-fg active:bg-hover disabled:opacity-45 ${e===42?`size-[42px]`:`size-[36px] after:absolute after:-inset-[4px] after:content-['']`}`,children:C?(0,R.jsx)(M_,{size:17,strokeWidth:2.2,className:`animate-spin`}):(0,R.jsx)(q_,{size:e===42?19:17,strokeWidth:2.2})}),h=(0,R.jsxs)(`div`,{className:t?`relative flex flex-1 flex-col`:`relative`,children:[N&&(0,R.jsx)(`div`,{ref:y,"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] ${d} text-transparent`,children:N}),(0,R.jsx)(`textarea`,{id:a,ref:v,"data-1p-ignore":!0,onScroll:N?P:void 0,"data-surface":r,"data-claims-escape":!0,value:T,autoFocus:c,disabled:l,onChange:e=>k(e.target.value),onKeyDown:be,onFocus:()=>Ce(!0),onBlur:()=>Ce(!1),onPaste:e=>{let t=[...e.clipboardData.items].filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(Boolean);t.length&&(e.preventDefault(),j(t))},placeholder:i,rows:1,spellCheck:!1,style:f,className:`relative block w-full resize-none bg-transparent ${d} text-fg outline-none placeholder:text-faint scrollbar-none disabled:opacity-60 ${t?`flex-1`:``}`})]}),_=E.length>0&&(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1.5 ${t?`px-[18px] pb-3`:`px-3 pb-1`}`,children:E.map((e,t)=>(0,R.jsx)(Wz,{attachment:e,disabled:l,onRemove:()=>A(D.filter((e,n)=>n!==t))},`${e.path}-${t}`))}),x=De>0?(0,R.jsx)(`div`,{"aria-hidden":!0,"data-keyboard-spacer":!0,style:{height:De}}):null;if(t)return(0,R.jsxs)(`div`,{ref:Ee,"data-phone-composer":`page`,className:`flex min-h-0 flex-1 flex-col ${De>0?``:`pb-[env(safe-area-inset-bottom)]`}`,children:[(0,R.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col overflow-y-auto scrollbar-none`,children:[xe,h,_]}),(0,R.jsxs)(`div`,{"data-phone-tool-row":!0,className:`flex min-w-0 shrink-0 items-center gap-2 px-2.5 py-2`,children:[m(36),g.tools]}),p,x]});let S=!u&&g.override?g.override({editReply:()=>v.current?.focus()}):null,w=t=>(0,R.jsx)(`button`,{type:`button`,"data-phone-send":!0,onMouseDown:e=>e.preventDefault(),onContextMenu:e=>e.preventDefault(),onPointerDown:()=>{if(ke.current=!1,clearTimeout(Oe.current),!e||!g.onLongPressSend)return;let t=g.onLongPressSend;Oe.current=setTimeout(()=>{ke.current=!0,navigator.vibrate?.(12),t()},Ane)},onPointerUp:()=>clearTimeout(Oe.current),onPointerLeave:()=>clearTimeout(Oe.current),onPointerCancel:()=>clearTimeout(Oe.current),onClick:()=>{if(ke.current){ke.current=!1;return}n()},disabled:!e,title:g.onLongPressSend?`Send · hold to interrupt and send now`:`Send`,"aria-label":`Send`,className:`relative flex shrink-0 select-none items-center justify-center rounded-full bg-fg text-bg [-webkit-touch-callout:none] disabled:opacity-35 ${t?`size-[36px] after:absolute after:-inset-[4px] after:content-['']`:`size-[42px]`}`,children:l?(0,R.jsx)(M_,{size:t?17:19,strokeWidth:2.4,className:`animate-spin`}):(0,R.jsx)(Xg,{size:t?17:19,strokeWidth:2.4})}),O=e=>_e?w(e):g.idlePrimary?.(e)??w(e);return(0,R.jsxs)(`div`,{ref:Ee,"data-phone-composer":`bar`,"data-phone-composer-open":u?``:void 0,className:`relative bg-bg`,children:[(0,R.jsxs)(`div`,{className:`px-2.5 pt-2 ${De>0?`pb-2.5`:`pb-[max(10px,env(safe-area-inset-bottom))]`}`,children:[S&&(0,R.jsx)(`div`,{"data-phone-bar-override":!0,className:`flex min-w-0 items-end gap-2`,children:S}),(0,R.jsxs)(`div`,{className:S?`pointer-events-none absolute h-0 w-0 overflow-hidden opacity-0`:`flex min-w-0 items-end gap-2`,children:[!u&&m(42),(0,R.jsxs)(`div`,{className:`relative min-w-0 flex-1 border border-border-strong bg-panel ${u?`rounded-[20px] pb-2`:`rounded-[21px]`}`,children:[xe,h,u&&_,u&&(0,R.jsxs)(`div`,{"data-phone-composer-toolbar":!0,className:`flex min-w-0 items-center gap-2 px-2 pt-1`,children:[m(36),(0,R.jsx)(Hz.Provider,{value:Te,children:g.tools}),(0,R.jsx)(`span`,{className:`flex-1`}),O(!0)]})]}),!u&&O(!1)]}),p]}),x]})}return(0,R.jsxs)(`div`,{"data-composer-box":!0,className:`group relative rounded-xl border bg-bg transition-colors focus-within:border-accent ${x?`border-dashed border-accent`:`border-border`}`,onDragOver:e=>{[...e.dataTransfer.items].some(e=>e.kind===`file`)&&(e.preventDefault(),S(!0))},onDragLeave:()=>S(!1),onDrop:e=>{e.preventDefault(),S(!1),j(e.dataTransfer.files)},children:[x&&(0,R.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`}),xe,(0,R.jsxs)(`div`,{className:`relative`,children:[N&&(0,R.jsx)(`div`,{ref:y,"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`} text-[13px] leading-relaxed text-transparent`,style:u?void 0:{paddingRight:ye.reserve},children:N}),(0,R.jsx)(`textarea`,{id:a,ref:v,"data-1p-ignore":!0,onScroll:N?P:void 0,"data-surface":r,"data-claims-escape":!0,value:T,autoFocus:c,disabled:l,onChange:e=>{me.cancel(),k(e.target.value)},onKeyDown:be,onPaste:e=>{let t=[...e.clipboardData.items].filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(Boolean);t.length&&(e.preventDefault(),j(t))},placeholder:i,rows:1,spellCheck:!1,style:{minHeight:o,maxHeight:s,paddingRight:u?void 0:ye.reserve},className:`relative block w-full resize-none bg-transparent px-3.5 ${u?`py-2.5 pb-3`:`py-2.5`} text-[13px] leading-relaxed text-fg outline-none placeholder:text-muted scrollbar-none disabled:opacity-60`})]}),E.length>0&&(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-3 pb-2`,style:{paddingRight:ye.reserve},children:E.map((e,t)=>(0,R.jsx)(Wz,{attachment:e,disabled:l,onRemove:()=>A(D.filter((e,n)=>n!==t))},`${e.path}-${t}`))}),u&&(0,R.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1 pl-1.5 pb-1.5`,style:{paddingRight:ye.reserve},children:u}),ve&&(0,R.jsx)(`div`,{className:`absolute bottom-2 flex items-center`,style:{right:ye.right.action},children:ve}),f&&(0,R.jsx)(`div`,{className:`absolute bottom-2 flex items-center`,style:{right:ye.right.lead},children:f}),(0,R.jsx)(`input`,{ref:b,type:`file`,multiple:!0,accept:hu,className:`hidden`,onChange:e=>{j(e.target.files),e.target.value=``}}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>b.current?.click(),disabled:l||C,title:`Attach files`,"aria-label":`Attach files`,style:{right:ye.right.paperclip},className:`icon-hover-outline absolute bottom-2 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:C?(0,R.jsx)(M_,{size:15,strokeWidth:2,className:`animate-spin`}):(0,R.jsx)(V_,{size:15,strokeWidth:2})}),he&&(0,R.jsx)(`button`,{type:`button`,"data-dictation":me.state,onMouseDown:e=>e.preventDefault(),onClick:()=>{let e=v.current;me.state===`idle`&&e&&document.activeElement!==e&&(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length)),me.toggle()},disabled:l||me.state===`installing`||me.state===`starting`,"aria-pressed":me.state===`listening`,title:me.state===`listening`?`Stop dictation`:me.state===`installing`?`Downloading the on-device speech model…`:me.state===`starting`?`Starting the microphone…`:`Dictate — transcribed on this device`,"aria-label":me.state===`listening`?`Stop dictation`:`Dictate`,style:{right:ye.right.mic},className:`icon-hover-outline absolute bottom-2 flex h-7 w-7 items-center justify-center rounded-lg transition-[color,background-color] enabled:hover:bg-panel-2/70 disabled:opacity-50 ${me.state===`listening`?`text-fg`:`text-muted enabled:hover:text-fg`}`,children:me.state===`installing`||me.state===`starting`?(0,R.jsx)(M_,{size:15,strokeWidth:2,className:`animate-spin`}):me.state===`listening`&&me.stream?(0,R.jsx)(Ene,{stream:me.stream}):(0,R.jsx)(L_,{size:15,strokeWidth:2})}),(0,R.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:ge,disabled:!_e||l||C,title:`Send (Enter · ⌘⏎ sends now)`,"aria-label":`Send`,style:{right:ye.right.send},className:`icon-hover-outline absolute bottom-2 flex h-7 w-7 items-center justify-center rounded-lg transition-[color,background-color,opacity,scale] ${_e&&!l&&!C?`bg-fg text-bg hover:opacity-90 active:scale-95`:`bg-panel-2 text-muted`}`,children:l?(0,R.jsx)(M_,{size:14,strokeWidth:2.5,className:`animate-spin`}):(0,R.jsx)(Xg,{size:14,strokeWidth:2.5})})]})}function Wz({attachment:e,disabled:t,onRemove:n}){let[r,i]=(0,L.useState)(!1),a=xh(e.path),o=(a.includes(`.`)?a.split(`.`).pop():``).toUpperCase();return(0,R.jsxs)(`div`,{className:`group/att relative h-11 w-11`,title:a,children:[e.kind===`image`&&!r?(0,R.jsx)(`img`,{src:BT(e.path),alt:a,onError:()=>i(!0),className:`h-11 w-11 rounded-md border border-border object-cover`}):(0,R.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,R.jsx)(v_,{size:15,strokeWidth:2,className:`shrink-0 text-muted`}),o&&(0,R.jsx)(`span`,{className:`-mx-1 max-w-[calc(100%+0.5rem)] truncate text-[8px] font-medium leading-none text-muted-80`,children:o})]}),(0,R.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,R.jsx)(cv,{size:10,strokeWidth:2.5})})]})}function Gz(){return ct({queryKey:[`githubStatus`],queryFn:()=>Y.githubStatus(),staleTime:3e4,refetchOnWindowFocus:!0,refetchInterval:e=>{let t=e.state.data;return t?.inRepo&&t.authed?!1:6e4}})}function Kz(){let e=Gz();return!!(e.data?.inRepo&&e.data.authed)}function qz({className:e=``,variant:t=`icon`}){return Kz()?t===`phoneChip`?(0,R.jsxs)(`button`,{type:`button`,"data-phone-github-trigger":!0,onClick:Fh,onMouseDown:e=>e.preventDefault(),title:`Investigate this issue and make recommendations`,className:`relative inline-flex h-[32px] shrink-0 items-center gap-[6px] rounded-full border border-border-strong bg-bg px-[11px] text-[13.5px] font-medium text-fg after:absolute after:inset-x-0 after:-inset-y-[6px] after:content-[''] active:bg-hover ${e}`,children:[(0,R.jsx)(E_,{"aria-hidden":!0,size:14,strokeWidth:1.9,className:`shrink-0 text-muted`}),`Issue or PR`]}):(0,R.jsx)(`button`,{type:`button`,onClick:Fh,onMouseDown:e=>e.preventDefault(),title:`Investigate this issue and make recommendations`,"aria-label":`Investigate this issue and make recommendations`,className:`icon-hover-outline flex h-7 w-7 items-center justify-center rounded-lg text-muted outline-none transition-[color,background-color] 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,R.jsx)(E_,{size:15,strokeWidth:2})}):null}var Jz=`prompt-control-type petite-caps`,Yz=Jz,Mne=Jz,Xz=`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 ${Yz} 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 Nne(e){return`minmax(6rem, 7rem) repeat(${Math.max(0,e)}, auto)`}function Zz(e){return e===`xhigh`?`X-high`:e.charAt(0).toUpperCase()+e.slice(1)}var Qz=[`ultra`,`ultracode`],$z=[`low`,`medium`,`high`,`xhigh`,`max`,...Qz];function Pne(e){return[...new Set(e.flatMap(e=>e.options.flatMap(e=>e.efforts)))].sort((e,t)=>{let n=$z.indexOf(e),r=$z.indexOf(t);return n===-1&&r===-1?e.localeCompare(t):n===-1?1:r===-1?-1:n-r})}function eB(e){let t=[];for(let n of Pne(e)){let e=Qz.includes(n)?t.find(e=>Qz.includes(e[0])):void 0;e?e.push(n):t.push([n])}return t}function tB(e){return e.efforts.length?e.efforts:[``]}function nB(e){return e.flatMap(e=>e.options.flatMap(t=>tB(t).map(n=>({provider:e.id,model:t.model,effort:n}))))}function rB(e){return JSON.stringify([e.provider,e.model,e.effort])}function Fne(e,t){return nB(e).find(e=>rB(e)===t)}function iB(e,t){return!t?.model||t.effort===void 0?!1:e.some(e=>(!t.provider||e.id===t.provider)&&e.options.some(e=>e.model===t.model&&tB(e).includes(t.effort)))}var aB=/ (\d+(?:\.\d+)*)$/;function oB(e,t,n=`Profile unknown`,r){if(!t?.model&&!t?.effort)return{name:n};let i=e.flatMap(e=>e.options).find(e=>e.model===t.model),a=r??i?.label??t.model??`Model unknown`,o=r?aB.exec(r)?.[1]:i?.edition,s=o!==void 0&&a.endsWith(` ${o}`);return{name:s?a.slice(0,-(o.length+1)):a,...s?{edition:o}:{},...t.effort?{effort:t.effort}:{}}}function sB(e,t,n=`Profile unknown`,r){let{name:i,edition:a,effort:o}=oB(e,t,n,r),s=a?`${i} ${a}`:i;return o?`${s} › ${o}`:s}function cB(e,t,n){let r=eB(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=tB(s.option),l=c.indexOf(t.effort);if(l===-1)return null;if(n===`Home`||n===`End`||n===`ArrowLeft`||n===`ArrowRight`){let e=c[n===`Home`?0:n===`End`?c.length-1:l+(n===`ArrowLeft`?-1:1)];return e===void 0?null:{provider:s.provider,model:s.option.model,effort:e}}let u=a[o+(n===`ArrowUp`?-1:1)];if(!u)return null;let d=i(t.effort),f=tB(u.option).reduce((e,t)=>e===void 0||Math.abs(i(t)-d)<Math.abs(i(e)-d)?t:e,void 0);return f===void 0?null:{provider:u.provider,model:u.option.model,effort:f}}var lB,uB=!1;function dB(){uB||typeof window>`u`||(uB=!0,window.addEventListener(`keydown`,e=>{e.key!==`Escape`||!lB||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),pB())},{capture:!0}))}function fB(e){dB();let t={dismiss:e};return lB=t,()=>{lB===t&&(lB=void 0)}}function pB(){let e=lB;return e?(lB=void 0,e.dismiss(),!0):!1}function mB(e){pB()&&e.preventDefault(),e.stopPropagation()}function hB(e,t){let n=(0,L.useRef)(t);n.current=t,(0,L.useLayoutEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),pB()||n.current())};return window.addEventListener(`keydown`,t,{capture:!0}),()=>window.removeEventListener(`keydown`,t,{capture:!0})},[e])}var gB=500,_B=1600,vB=2e3,yB=6,bB=[`settingsSet`];function xB(){let[e,t]=(0,L.useState)(`idle`),n=(0,L.useRef)(null),r=(0,L.useRef)(void 0),i=(0,L.useRef)(Promise.resolve()),a=(0,L.useRef)(0),o=(0,L.useRef)(void 0),s=(0,L.useRef)(0),c=(0,L.useRef)(()=>{}),l=pt({mutationKey:[...bB],mutationFn:e=>Y.settingsSet(e)}),u=(0,L.useRef)(l);u.current=l;let d=qe(),f=(0,L.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(()=>u.current.mutateAsync(e)).then(e=>{d.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`),_B))}).catch(i=>{--a.current,t(`error`),!(n.current||!Fm(i)||s.current>=yB)&&(s.current+=1,n.current=e,r.current=window.setTimeout(c.current,vB))}))},[]);c.current=f;let p=(0,L.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 f();r.current=window.setTimeout(f,gB)},[f]);return(0,L.useEffect)(()=>()=>{f(),o.current!==void 0&&window.clearTimeout(o.current)},[f]),{state:e,queue:p,flush:f}}function SB(){let e=ct({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()}),[t,n]=(0,L.useState)(()=>e.data??null),{state:r,queue:i,flush:a}=xB();return(0,L.useEffect)(()=>{e.data&&!t&&n(e.data)},[e.data,t]),{draft:t,update:(0,L.useCallback)((e,t)=>{n(e),i(e,t?.debounce)},[i]),saveState:r,flush:a}}function CB({state:e}){return e===`idle`?null:e===`error`?(0,R.jsx)(`span`,{className:`text-[11px] font-normal text-accent`,children:`Couldn't save`}):(0,R.jsx)(`span`,{className:`text-[11px] font-normal ${e===`saved`?`text-muted-70`:`text-muted`}`,children:e===`saving`?`Saving…`:`Saved`})}var wB=`default`;function TB(e){return e>=1e6?`${EB(e/1e6)}M`:e>=1e3?`${EB(e/1e3)}k`:String(e)}function EB(e){return Number.isInteger(e)?String(e):e.toFixed(2).replace(/0+$/,``).replace(/\.$/,``)}var DB=[{value:872e3,models:[]}];function OB(e,t){let n=e??[],r=n.find(e=>e.contextWindow!==void 0)?.contextWindow??272e3,i=`${TB(r)} (default)`,a=new Map;for(let e of n)e.maxContextWindow===void 0||e.contextWindow===void 0||e.maxContextWindow<=e.contextWindow||a.set(e.maxContextWindow,[...a.get(e.maxContextWindow)??[],e.displayName]);let o=a.size?[...a.entries()].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({value:e,models:t})):DB,s=[{value:wB,label:i}];for(let e of o){let t=o.length===1||e.models.length===0?`maximum`:`${e.models.join(`, `)} maximum`;s.push({value:String(e.value),label:`${TB(e.value)} (${t})`})}for(let e of[472e3,672e3])e>r&&o.some(t=>t.value>e)&&!s.some(t=>t.value===String(e))&&s.push({value:String(e),label:TB(e)});return t!==void 0&&!s.some(e=>e.value===String(t))&&s.push({value:String(t),label:TB(t)}),[s[0],...s.slice(1).sort((e,t)=>Number(e.value)-Number(t.value))]}var kB=[{value:`200000`,label:`200k`},{value:`350000`,label:`350k`},{value:`500000`,label:`500k (default)`},{value:`750000`,label:`750k`},{value:`1000000`,label:`1M (maximum)`}],AB={claude:`Compaction window for new Claude threads in this project. Applies on dispatch or after the worker exits, not to a running worker.`,codex:`Context window for new Codex threads in this project. Each model caps the value at its own maximum. Applies on dispatch or a cold resume, not to a running worker.`},jB=kf.options,MB={auto:`Auto`,default:`Default`,acceptEdits:`Accept edits`,plan:`Plan`,bypassPermissions:`Bypass`},NB={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)`};jB.filter(e=>e!==`plan`).map(e=>({value:e,label:MB[e],title:NB[e]}));var PB=[`auto`,`bypassPermissions`].map(e=>({value:e,label:MB[e],title:NB[e]})),FB=[{value:`fable`,label:`Fable`},{value:`opus`,label:`Opus`},{value:`sonnet`,label:`Sonnet`},{value:`haiku`,label:`Haiku`}];function IB(e=[]){return FB.map(t=>{let n=e.find(e=>e.alias===t.value);return n?{...t,label:n.label,title:`${n.label} — ${n.resolvedModel??t.value}`}:t})}new Set(bu.map(e=>e.slug));function LB(e){return e===`plan`?`auto`:e}var RB=[`low`,`medium`,`high`,`xhigh`,`max`],zB=`ultracode`,BB=new Set([`fable`,`opus`,`sonnet`]);function VB(e){return e&&BB.has(e)?[...RB,zB]:[...RB]}var HB={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-high`,max:`Max`,ultra:`Ultra`,ultracode:`Ultracode`};function UB(e){return HB[e]??e.charAt(0).toUpperCase()+e.slice(1)}function WB(e,t){let n=VB(e).map(e=>({value:e,label:UB(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function GB(e,t){let n=(e?.efforts??[]).map(e=>({value:e,label:UB(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}var KB={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.`,appearance:`Applies to this browser across all projects. System follows the device appearance.`,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.`,dictation:`Shows a microphone in the prompt box that transcribes speech on this device, in the browsers that can (Chrome and Edge on a desktop). Turn it off if you dictate with another tool. 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.`,githubPrompt:`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.`};function qB({label:e,help:t}){return(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] uppercase tracking-wide text-muted`,children:[e,(0,R.jsx)(IP,{label:t,side:`right`,clickable:!0,children:(0,R.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,R.jsx)(u_,{size:12})})})]})}function JB({label:e,help:t,children:n}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(qB,{label:e,help:t}),n]})}var YB=Object.defineProperty,XB=(e,t)=>YB(e,`name`,{value:t,configurable:!0}),ZB=`Popover`,[QB,Ine]=Yk(ZB,[ZM]),$B=ZM(),[eV,tV]=QB(ZB),nV=XB(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=$B(t),c=L.useRef(null),[l,u]=L.useState(!1),[d,f]=IN({prop:r,defaultProp:i??!1,onChange:a,caller:ZB});return(0,R.jsx)(pN,{...s,children:(0,R.jsx)(eV,{scope:t,contentId:RA(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:L.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:L.useCallback(()=>u(!0),[]),onCustomAnchorRemove:L.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),rV=`PopoverAnchor`,iV=L.forwardRef(XB(function(e,t){let{__scopePopover:n,...r}=e,i=tV(rV,n),a=$B(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return L.useEffect(()=>(o(),()=>s()),[o,s]),(0,R.jsx)(mN,{...a,...r,ref:t})},`PopoverAnchor`)),aV=`PopoverTrigger`,oV=L.forwardRef(XB(function(e,t){let{__scopePopover:n,...r}=e,i=tV(aV,n),a=$B(n),o=Gk(t,i.triggerRef),s=(0,R.jsx)(mA.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":_V(i.open),...r,ref:o,onClick:Ik(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,R.jsx)(mN,{asChild:!0,...a,children:s})},`PopoverTrigger`)),sV=`PopoverPortal`,[cV,lV]=QB(sV,{forceMount:void 0}),uV=XB(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=tV(sV,t);return(0,R.jsx)(cV,{scope:t,forceMount:n,children:(0,R.jsx)(SN,{present:n||a.open,children:(0,R.jsx)(vN,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),dV=`PopoverContent`,fV=L.forwardRef(XB(function(e,t){let n=lV(dV,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=tV(dV,e.__scopePopover);return(0,R.jsx)(SN,{present:r||a.open,children:a.modal?(0,R.jsx)(mV,{...i,ref:t}):(0,R.jsx)(hV,{...i,ref:t})})},`PopoverContent`)),pV=$k(`PopoverContent.RemoveScroll`),mV=L.forwardRef(XB(function(e,t){let n=tV(dV,e.__scopePopover),r=L.useRef(null),i=Gk(t,r),a=L.useRef(!1);return L.useEffect(()=>{let e=r.current;if(e)return fI(e)},[]),(0,R.jsx)(wn,{as:pV,allowPinchZoom:!0,children:(0,R.jsx)(gV,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Ik(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Ik(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:Ik(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),hV=L.forwardRef(XB(function(e,t){let n=tV(dV,e.__scopePopover),r=L.useRef(!1),i=L.useRef(!1);return(0,R.jsx)(gV,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),gV=L.forwardRef(XB(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=tV(dV,n),p=$B(n);return cF(),(0,R.jsx)(hF,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,R.jsx)(EA,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,R.jsx)(hN,{"data-state":_V(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)`}})})})},`PopoverContentImpl`));function _V(e){return e?`open`:`closed`}XB(_V,`getState`);var vV=nV,yV=iV,bV=oV,xV=uV,SV=fV;function CV({modal:e=!1,...t}){return(0,R.jsx)(vV,{modal:e,...t})}var wV=bV,TV=yV;function EV({children:e,side:t=`top`,align:n=`center`,sideOffset:r=6,className:i=``,...a}){return(0,R.jsx)(xV,{children:(0,R.jsx)(SV,{side:t,align:n,sideOffset:r,avoidCollisions:!0,collisionPadding:12,onEscapeKeyDown:e=>e.stopPropagation(),className:`${kP} ${PP} rounded-lg outline-none ${i}`,...a,children:e})})}function DV(e){return e===`right`?`pl-3 pr-7`:`pl-7 pr-3`}function OV(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 kV=`__frizz_empty_select_value__`,AV=e=>e===``?kV:e,jV=e=>e===kV?``:e,MV={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`},NV={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 PV({o:e,indicatorPosition:t,typography:n}){return(0,R.jsxs)(tR,{value:AV(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 ${DV(t)} ${n??``}`,children:[(0,R.jsx)(nR,{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,R.jsx)(e_,{size:13})}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]})}function FV({value:e,onValueChange:t,options:n,groups:r,placeholder:i,ariaLabel:a,title:o,disabled:s=!1,variant:c=`ghost`,indicatorPosition:l=`left`,side:u=`bottom`,menuZClass:d=AP,className:f=``}){let p=OV(e,n,r,i),m=s?NV[c]:MV[c],h=c===`readout`?Jz:``,[g,_]=(0,L.useState)(!1),v=(0,L.useRef)(g),y=(0,L.useRef)(s),b=(0,L.useRef)(void 0);return v.current=g,y.current=s,(0,L.useLayoutEffect)(()=>{let e=e=>{e.key!==`Escape`||!v.current||y.current||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),v.current=!1,b.current?.(),b.current=void 0,_(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]),(0,L.useLayoutEffect)(()=>{!s||!g||(v.current=!1,b.current?.(),b.current=void 0,_(!1))},[s,g]),(0,L.useLayoutEffect)(()=>()=>b.current?.(),[]),(0,R.jsxs)(qL,{modal:!1,open:g,onOpenChange:e=>{b.current?.(),b.current=void 0,v.current=e,_(e),e&&(b.current=fB(()=>{v.current=!1,b.current=void 0,_(!1)}))},children:[(0,R.jsx)(JL,{asChild:!0,disabled:s,children:(0,R.jsxs)(`button`,{type:`button`,"aria-label":a,title:o,className:`group inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md border px-2 py-1 text-left text-[12px] text-fg outline-none data-[placeholder]:text-muted ${s?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors`} ${m} ${c===`readout`?`select-trigger-readout`:``} ${h} ${f}`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left ${p.placeholder?`text-muted`:``}`,children:p.text}),(0,R.jsx)(t_,{className:`select-caret shrink-0 text-muted ${s?``:`transition-transform group-data-[state=open]:rotate-180`}`,size:13})]})}),(0,R.jsx)(YL,{children:(0,R.jsx)(XL,{align:`start`,side:u,sideOffset:5,onEscapeKeyDown:e=>e.stopPropagation(),className:`${d} ${kP} min-w-[var(--radix-dropdown-menu-trigger-width)] max-w-[calc(100vw-1rem)] overflow-hidden rounded-lg p-1 ${h}`,children:(0,R.jsx)(eR,{value:AV(e),onValueChange:e=>t(jV(e)),className:`max-h-[300px] min-w-0 overflow-y-auto`,children:r?r.map((e,t)=>(0,R.jsxs)(ZL,{children:[e.label&&(0,R.jsx)(QL,{className:`${DV(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,R.jsx)(PV,{o:e,indicatorPosition:l,typography:h},e.value))]},e.label||`g${t}`)):(n??[]).map(e=>(0,R.jsx)(PV,{o:e,indicatorPosition:l,typography:h},e.value))})})})]})}var IV=[{value:`auto`,label:`Automatic (default)`},{value:`5m`,label:`5 minutes`},{value:`1h`,label:`1 hour`}],LV={claude:`Claude Code`,codex:`Codex`};function RV({backend:e,open:t,onOpenChange:n}){let r=LV[e];return hB(t,()=>n(!1)),(0,R.jsxs)(CV,{modal:!0,open:t,onOpenChange:n,children:[(0,R.jsx)($L,{asChild:!0,onSelect:e=>e.preventDefault(),children:(0,R.jsx)(wV,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`${r} settings`,title:`${r} settings for new threads in this project`,className:`agent-settings-trigger -my-1 -mr-3 inline-flex size-5 shrink-0 translate-y-[calc(7px_-_0.5cap)] items-center justify-center rounded-[5px] text-muted-70 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:bg-panel-2 focus-visible:text-fg data-[state=open]:bg-panel-2 data-[state=open]:text-fg`,children:(0,R.jsx)(Q_,{"aria-hidden":`true`,size:14})})})}),(0,R.jsx)(EV,{side:`bottom`,align:`end`,sideOffset:6,className:`w-[272px] max-w-[calc(100vw-1rem)] p-4`,style:{fontVariantCaps:`normal`,letterSpacing:`normal`},"data-agent-settings-menu":e,onKeyDown:e=>e.stopPropagation(),children:(0,R.jsx)(zV,{backend:e})})]})}function zV({backend:e}){let{draft:t,update:n,saveState:r}=SB(),i=ct({queryKey:[`codexModels`],queryFn:()=>Y.codexModels(),enabled:e===`codex`});return(0,R.jsxs)(`div`,{className:`flex flex-col gap-4 text-[12px]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsxs)(`span`,{className:`text-[12px] font-medium text-fg`,children:[LV[e],` settings`]}),(0,R.jsx)(CB,{state:r})]}),t?e===`claude`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(JB,{label:`Permissions`,help:KB.permissionMode,children:(0,R.jsx)(FV,{variant:`bordered`,value:t.permissionMode===`bypassPermissions`?`bypassPermissions`:`auto`,onValueChange:e=>n({...t,permissionMode:e}),options:PB,indicatorPosition:`right`,menuZClass:NP,ariaLabel:`Claude permission mode`})}),(0,R.jsx)(JB,{label:`Prompt cache tier`,help:KB.promptCacheTtl,children:(0,R.jsx)(FV,{variant:`bordered`,value:t.promptCacheTtl??`auto`,onValueChange:e=>n({...t,promptCacheTtl:e}),options:IV,indicatorPosition:`right`,menuZClass:NP,ariaLabel:`Claude prompt cache tier`})}),(0,R.jsx)(BV,{draft:t,update:n})]}):(0,R.jsx)(JB,{label:`Context window`,help:AB.codex,children:(0,R.jsx)(FV,{variant:`bordered`,value:t.codexContextWindow===void 0?wB:String(t.codexContextWindow),onValueChange:e=>n({...t,codexContextWindow:e==="default"?void 0:Number(e)}),options:OB(i.data,t.codexContextWindow),indicatorPosition:`right`,menuZClass:NP,ariaLabel:`Codex context window`})}):(0,R.jsx)(`div`,{className:`text-[12px] text-muted`,children:`Loading…`})]})}function BV({draft:e,update:t}){let n=e.autoCompactWindow??5e5,r=String(n),i=kB.some(e=>e.value===r)?kB:[...kB,{value:r,label:TB(n)}];return(0,R.jsx)(JB,{label:`Compaction window`,help:AB.claude,children:(0,R.jsx)(FV,{variant:`bordered`,value:r,onValueChange:n=>t({...e,autoCompactWindow:Number(n)}),options:i,indicatorPosition:`right`,menuZClass:NP,ariaLabel:`Claude Code compaction window`})})}function VV(e,t){return e.efforts.length===0?``:t&&e.efforts.includes(t)?t:e.defaultEffort&&e.efforts.includes(e.defaultEffort)?e.defaultEffort:e.efforts.includes(`high`)?`high`:e.efforts[0]??``}function HV({option:e}){let t=e.edition?` ${e.edition}`:``;return!t||!e.label.endsWith(t)?(0,R.jsx)(R.Fragment,{children:e.label}):(0,R.jsxs)(R.Fragment,{children:[e.label.slice(0,-t.length),` `,(0,R.jsx)(`span`,{className:`text-edition`,children:e.edition})]})}function UV({groups:e,value:t,onValueChange:n,onClose:r,upgrade:i}){let[a,o]=(0,L.useState)(()=>({...t})),[s,c]=(0,L.useState)(!1);(0,L.useEffect)(()=>{let e=requestAnimationFrame(()=>c(!0));return()=>cancelAnimationFrame(e)},[]);let l=(0,L.useRef)(a);l.current=a;let u=(0,L.useRef)(!1);function d(i=l.current){if(u.current)return;u.current=!0;let a=iB(e,i),o=!t?.model||!a||rB({provider:i.provider??``,model:i.model??``,effort:i.effort??``})!==rB({provider:t.provider??``,model:t.model,effort:t.effort??``});a&&o&&i.provider&&i.model&&n({provider:i.provider,model:i.model,effort:i.effort??``}),r()}let f=e.find(e=>e.id===a.provider)?.options.find(e=>e.model===a.model);return(0,R.jsx)(gR,{open:!0,onOpenChange:e=>{e||d()},children:(0,R.jsxs)(bR,{children:[(0,R.jsx)(SR,{"data-mobile-model-sheet-scrim":!0,className:`fixed inset-0 z-[250] bg-scrim-50 transition-opacity duration-200 ${s?`opacity-100`:`opacity-0`}`}),(0,R.jsxs)(ER,{"data-mobile-model-sheet":!0,"aria-describedby":void 0,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),className:`fixed inset-x-0 bottom-0 z-[250] flex max-h-[86%] flex-col overflow-hidden rounded-t-[16px] border-t border-border-strong bg-panel pb-[calc(14px+env(safe-area-inset-bottom))] shadow-[0_-20px_60px_-10px_var(--sheet-shadow)] outline-none transition-transform duration-200 ease-out motion-reduce:transition-none ${s?`translate-y-0`:`translate-y-full`}`,children:[(0,R.jsx)(`div`,{className:`mx-auto mt-[10px] h-[4px] w-[36px] shrink-0 rounded-full bg-muted/35`}),(0,R.jsxs)(`div`,{className:`min-h-0 overflow-y-auto pt-2 scrollbar-none`,children:[(0,R.jsx)(jR,{className:`px-[18px] pb-2.5 pt-1 text-[16px] font-semibold text-fg`,children:`Model`}),e.map((e,t)=>(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":e.label,children:e.options.map((n,r)=>{let i=a.provider===e.id&&a.model===n.model;return(0,R.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i,"data-mobile-model-row":n.model,onClick:()=>o({provider:e.id,model:n.model,effort:VV(n,a.effort)}),className:`flex min-h-[48px] w-full items-center gap-3 px-[18px] text-left active:bg-hover ${t>0&&r===0?`border-t border-border`:``}`,children:[(0,R.jsx)(`span`,{className:`w-[78px] shrink-0 truncate text-[12.5px] text-muted`,children:r===0?e.label:``}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[15.5px] text-fg`,children:(0,R.jsx)(HV,{option:n})}),i&&(0,R.jsx)(e_,{"aria-hidden":!0,size:18,strokeWidth:2.6,className:`shrink-0 text-fg`})]},n.model)})},e.id)),e.every(e=>e.options.length===0)&&(0,R.jsx)(`div`,{className:`px-[18px] py-3 text-[14px] text-muted`,children:`No models available`}),(0,R.jsx)(`div`,{className:`px-[18px] pb-1.5 pt-4 text-[16px] font-semibold text-fg`,children:`Effort`}),f&&f.efforts.length>0?(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Effort`,className:`flex gap-1.5 overflow-x-auto px-[18px] pb-1.5 pt-1.5 scrollbar-none`,children:f.efforts.map(e=>{let t=a.effort===e;return(0,R.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-mobile-effort":e,onClick:()=>d({...a,effort:e}),className:`relative inline-flex h-[36px] shrink-0 items-center rounded-full border px-[13px] text-[14px] after:absolute after:inset-x-0 after:-inset-y-[4px] after:content-[''] ${t?`border-fg bg-fg font-semibold text-bg`:`border-border-strong text-muted active:bg-hover`}`,children:Zz(e)},e)})}):(0,R.jsx)(`div`,{className:`px-[18px] pb-1 pt-1 text-[14px] text-muted`,children:f?`Set by the agent`:`Choose a model first`}),i&&(0,R.jsxs)(`div`,{"data-mobile-model-upgrade":!0,className:`mx-[18px] mt-4 flex items-center gap-3 border-t border-border pt-3`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px] leading-[18px] text-muted`,children:i.staged?`This thread will upgrade to ${i.latest} on its next turn`:`This thread will auto-upgrade to ${i.latest} after its next compaction`}),!i.staged&&(0,R.jsx)(`button`,{type:`button`,disabled:i.blockedReason!==null||i.pending,title:i.blockedReason??void 0,onClick:()=>{i.onUpgrade(),d()},className:`flex h-[36px] shrink-0 items-center rounded-full border border-border-strong px-[13px] text-[14px] text-fg active:bg-hover disabled:opacity-45`,children:`Upgrade now`})]})]})]})]})})}function WV({groups:e,value:t,pending:n,onValueChange:r,placeholder:i,ariaLabel:a,title:o,disabled:s=!1,runningModelLabel:c,upgrade:l}){let[u,d]=(0,L.useState)(!1),f=(0,L.useContext)(Hz),p=e=>{d(e),f?.(e)};(0,L.useEffect)(()=>{s&&u&&p(!1)},[s]),(0,L.useEffect)(()=>()=>f?.(!1),[f]);let{name:m,edition:h,effort:g}=oB(e,t,i,c),_=!!(n?.model||n?.effort);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,"aria-label":a,"aria-haspopup":`dialog`,"aria-expanded":u,title:o,disabled:s,"data-phone-profile-chip":!0,"data-profile-known":iB(e,t)?`true`:`false`,onMouseDown:e=>e.preventDefault(),onClick:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),p(!0)},className:`relative inline-flex h-[32px] min-w-0 max-w-full shrink items-center gap-[5px] rounded-full border border-border-strong bg-bg px-[11px] text-[13.5px] font-medium text-fg after:absolute after:inset-x-0 after:-inset-y-[6px] after:content-[''] active:bg-hover disabled:opacity-45`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 truncate`,children:[m,h&&(0,R.jsxs)(R.Fragment,{children:[` `,(0,R.jsx)(`span`,{className:`text-edition`,children:h})]}),g&&` · ${g}`]}),_?(0,R.jsx)(M_,{"aria-hidden":!0,size:13,className:`shrink-0 animate-spin text-muted`}):(0,R.jsx)(t_,{"aria-hidden":!0,size:13,strokeWidth:2.4,className:`shrink-0 text-muted`})]}),u&&(0,R.jsx)(UV,{groups:e,value:t,onValueChange:r,onClose:()=>p(!1),upgrade:l})]})}var GV=Zz;function KV({label:e,edition:t}){let n=t?` ${t}`:``;return!n||!e.endsWith(n)?(0,R.jsx)(R.Fragment,{children:e}):(0,R.jsxs)(R.Fragment,{children:[e.slice(0,-n.length),` `,(0,R.jsx)(`span`,{className:`profile-grid-edition text-edition`,children:t})]})}function qV({name:e,edition:t,effort:n}){return(0,R.jsxs)(R.Fragment,{children:[e,t&&(0,R.jsxs)(R.Fragment,{children:[` `,(0,R.jsx)(`span`,{className:`profile-grid-edition text-edition`,children:t})]}),n&&` › ${n}`]})}function JV(e){return e.replace(/ /g,`\xA0`)}function YV(e){return Lg()?(0,R.jsx)(WV,{...e}):(0,R.jsx)(XV,{...e})}function XV({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=AP,className:f=``,agentSettings:p=!1,runningModelLabel:m,upgrade:h}){let[g,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)(null),b=(0,L.useRef)(v);b.current=v;let x=(0,L.useRef)(g),S=(0,L.useRef)(c),C=(0,L.useRef)(void 0),w=(0,L.useRef)(new Map),T=(0,L.useRef)(void 0),E=(0,L.useMemo)(()=>eB(e),[e]),D=(0,L.useMemo)(()=>nB(e),[e]),O=l?Mne:Yz,k=c?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors hover:border-border hover:bg-panel-2 hover:text-fg`,A=iB(e,t),j=A&&t?.provider&&t.model?rB({provider:t.provider,model:t.model,effort:t.effort??``}):void 0,M=n?.model||n?.effort?sB(e,n,`Pending profile`):void 0;x.current=g,S.current=c;function N(){y(null),x.current=!1,C.current=void 0,_(!1)}function P(){b.current?(b.current=null,y(null),C.current=fB(P)):N()}(0,L.useLayoutEffect)(()=>{let e=e=>{e.key!==`Escape`||!x.current||S.current||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),!pB()&&(C.current?.(),P()))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]),(0,L.useLayoutEffect)(()=>{!c||!g||(C.current?.(),N())},[c,g]),(0,L.useLayoutEffect)(()=>()=>C.current?.(),[]),(0,L.useLayoutEffect)(()=>{j===T.current&&(T.current=void 0)},[j]);function F(e){let t=rB(e);T.current!==t&&(T.current=t,r(e))}function I(t,n){if(![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(t.key))return;let r=cB(e,n,t.key);r&&(t.preventDefault(),t.stopPropagation(),w.current.get(rB(r))?.focus())}return(0,R.jsxs)(qL,{modal:!1,open:g,onOpenChange:e=>{C.current?.(),C.current=void 0,x.current=e,_(e),e?C.current=fB(P):y(null)},children:[(0,R.jsx)(JL,{asChild:!0,disabled:c,children:(0,R.jsxs)(`button`,{type:`button`,"aria-label":a,"aria-invalid":!A&&(t?.model||t?.effort)?!0:void 0,"aria-description":M?`Pending ${M}`:void 0,title:s,"data-profile-known":A?`true`:`false`,"data-profile-pending":M?`true`:void 0,className:`profile-grid-trigger group inline-flex min-w-0 max-w-full items-center gap-[3px] 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 ${k} ${f} ${O}`,children:[(0,R.jsx)(`span`,{className:`profile-grid-value min-w-0 flex-1 truncate text-left ${O}`,children:(0,R.jsx)(qV,{...oB(e,t,i,m)})}),M&&(0,R.jsx)(M_,{"aria-hidden":`true`,size:l?10:11,className:`shrink-0 animate-spin text-muted-65`}),(0,R.jsx)(t_,{"aria-hidden":`true`,size:l?11:13,className:`shrink-0 text-fg/65 transition-transform group-data-[state=open]:rotate-180`})]})}),(0,R.jsx)(YL,{children:(0,R.jsxs)(XL,{"aria-label":o,align:`start`,side:u,sideOffset:5,collisionPadding:8,onEscapeKeyDown:e=>e.stopPropagation(),onInteractOutside:e=>{(b.current||e.target instanceof Element&&e.target.closest(`[data-agent-settings-menu]`))&&e.preventDefault()},className:`profile-grid-menu ${d} ${kP} max-h-[min(360px,var(--radix-dropdown-menu-content-available-height))] max-w-[calc(100vw-1rem)] overflow-auto rounded-lg p-1.5 ${O}`,children:[e.map(t=>(0,R.jsxs)(ZL,{children:[t.label&&(0,R.jsxs)(`div`,{className:`profile-grid-header sticky left-0 flex items-baseline justify-between gap-4 px-1.5 pb-1 pt-1 first:pt-0.5`,children:[(0,R.jsx)(QL,{className:`text-left font-medium tracking-[0.07em] text-muted-55`,children:t.label}),p&&(t.id===`claude`||t.id===`codex`)&&(0,R.jsx)(RV,{backend:t.id,open:v===t.id,onOpenChange:e=>y(e?t.id:null)})]}),(0,R.jsx)(eR,{value:j,onValueChange:t=>{let n=Fne(e,t);n&&F(n)},children:t.options.map(e=>(0,R.jsxs)(`div`,{"data-profile-grid-row":e.model,className:`grid w-max items-center gap-1 py-0.5`,style:{gridTemplateColumns:Nne(E.length)},children:[(0,R.jsx)(`span`,{className:`profile-grid-model-label min-w-0 max-w-[9.5rem] truncate px-1.5 text-left text-muted ${O}`,title:e.label,children:(0,R.jsx)(KV,{label:e.label,edition:e.edition})}),e.efforts.length===0&&(()=>{let n={provider:t.id,model:e.model,effort:``},r=rB(n);return(0,R.jsx)(tR,{value:r,ref:e=>{e?w.current.set(r,e):w.current.delete(r)},onKeyDown:e=>I(e,n),onSelect:e=>{e.preventDefault(),F(n),C.current?.(),N()},"aria-label":`${e.label}, the agent's own defaults`,title:`${e.label} › the agent's own model and effort`,className:Xz,style:{gridColumn:`2 / -1`,justifySelf:`start`},children:(0,R.jsxs)(`span`,{className:`grid`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`invisible col-start-1 row-start-1 font-medium`,children:`Default`}),(0,R.jsx)(`span`,{className:`col-start-1 row-start-1`,children:`Default`})]})},`default`)})(),e.efforts.length>0&&E.map(n=>{let r=n.find(t=>e.efforts.includes(t)),i=n.reduce((e,t)=>GV(t).length>GV(e).length?t:e);if(!r)return(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`invisible cursor-default border border-transparent px-1 text-left font-medium ${O}`,children:GV(i)},i);let a={provider:t.id,model:e.model,effort:r},o=rB(a);return(0,R.jsx)(tR,{value:o,ref:e=>{e?w.current.set(o,e):w.current.delete(o)},onKeyDown:e=>I(e,a),onSelect:e=>{e.preventDefault(),F(a),C.current?.(),N()},"aria-label":`${e.label}, ${GV(r)} effort`,title:`${e.label} › ${GV(r)}`,className:Xz,children:(0,R.jsxs)(`span`,{className:`grid`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`invisible col-start-1 row-start-1 font-medium`,children:GV(r)}),(0,R.jsx)(`span`,{className:`col-start-1 row-start-1`,children:GV(r)})]})},r)})]},e.model))}),t!==e.at(-1)&&(0,R.jsx)(rR,{className:`my-1 h-px bg-border`})]},t.id)),D.length===0&&(0,R.jsx)(`div`,{className:`px-2 py-1.5 text-muted-60`,children:`No profiles available`}),h&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(rR,{className:`my-1 h-px bg-border`}),(0,R.jsxs)(`div`,{"data-profile-grid-upgrade":``,className:`flex w-0 min-w-full items-center gap-2 px-1.5 py-0.5`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 text-balance text-muted`,children:h.staged?`This thread will upgrade to ${JV(h.latest)} on its next turn`:`This thread will auto-upgrade to ${JV(h.latest)} after its next compaction`}),!h.staged&&(0,R.jsx)($L,{disabled:h.blockedReason!==null||h.pending,onSelect:e=>{e.preventDefault(),h.onUpgrade(),C.current?.(),N()},title:h.blockedReason??`Restart this thread's worker on ${h.latest}. The conversation resumes from disk on the next turn; the prompt cache is re-read once.`,className:`flex h-6 shrink-0 cursor-pointer select-none items-center rounded border border-border bg-transparent px-1.5 text-fg outline-none transition-colors data-[highlighted]:bg-panel-2 data-[highlighted]:outline data-[highlighted]:outline-1 data-[highlighted]:outline-offset-1 data-[highlighted]:outline-fg/55 data-[disabled]:cursor-not-allowed data-[disabled]:opacity-45 ${O}`,children:`Upgrade now`})]})]})]})})]})}function ZV(e,t){let n=e?.models.find(t=>t.id===e.current),r=[{value:``,label:n?`Default · ${QV(n).model}`:`Default`,title:`The model the agent opens on when Frizz asks for none`}];t&&!e?.models.some(e=>e.id===t)&&r.push(e&&!e.error?{value:t,label:`${t} (unavailable)`,title:`The agent no longer advertises this model`}:{value:t,label:t});let i=[{label:``,options:r}];for(let t of e?.models??[]){let{provider:e,model:n}=QV(t),r=i.find(t=>t.label===e);r||(r={label:e,options:[]},i.push(r)),r.options.push({value:t.id,label:n,title:t.id})}return i}function QV(e){let t=e.name.indexOf(`/`);if(t>0)return{provider:e.name.slice(0,t).trim(),model:e.name.slice(t+1).trim()};let n=e.id.indexOf(`/`);return n>0?{provider:e.id.slice(0,n),model:e.name}:{provider:`Models`,model:e.name}}function $V({agentId:e,agentLabel:t,modelId:n,onValueChange:r,disabled:i=!1,side:a=`bottom`,menuZClass:o=AP,className:s=``}){let c=ct({queryKey:[`acpAgentModels`,e],queryFn:()=>Y.acpAgentModels({agentId:e}),staleTime:6e4}),l=ZV(c.data,n),u=c.isError?c.error.message:c.data?.error,d=u?`${t} did not list its models (${u}); the thread runs on the agent's own default`:c.data?.models.length?`Model for ${t} — the list is the agent's own, read from its session`:`${t} lists no models; the thread runs on the agent's own default`;return(0,R.jsx)(FV,{variant:`readout`,side:a,value:n??``,onValueChange:e=>r(e||void 0),groups:l,placeholder:c.isPending?`Models…`:`Default`,ariaLabel:`Model for ${t}`,title:d,disabled:i||c.isPending,indicatorPosition:`right`,menuZClass:o,className:s})}async function eH(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(!tH(e))throw Error(`the browser blocked clipboard access`)}function tH(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 nH={claude:`claude auth login`,codex:`codex login`},rH={claude:`Claude`,codex:`Codex`};function iH(e){let t=e.trim();return t===`/login`?`login`:t===`/logout`?`logout`:null}function aH({backend:e,onClose:t,onAuthed:n}){let r=qe(),[i,a]=(0,L.useState)(!1),o=nH[e],s=rH[e];async function c(){try{await eH(o),a(!0),window.setTimeout(()=>a(!1),1500)}catch{Z(`Couldn't copy — select the command and copy it manually`,{duration:6e3})}}let l=pt({mutationFn:()=>Y.authStatus(),onSuccess:t=>{if(r.setQueryData([`authStatus`],t),t[e]===`signed-out`){Z(`Still signed out of ${s} — run the command, then retry`,{duration:6e3});return}n()},onError:()=>n()});return(0,R.jsx)(gR,{open:!0,onOpenChange:e=>{e||t()},children:(0,R.jsxs)(bR,{children:[(0,R.jsx)(SR,{className:`fixed inset-0 z-[210] bg-scrim-30 backdrop-blur-md backdrop-saturate-150`}),(0,R.jsxs)(ER,{"aria-modal":`true`,"aria-describedby":void 0,className:`fixed left-1/2 top-1/2 z-[210] 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-shadow-ink/50 outline-none`,children:[(0,R.jsxs)(jR,{className:`mb-1 text-[14px] font-medium`,children:[`Signed out of `,s]}),(0,R.jsxs)(`p`,{className:`mb-4 text-[12.5px] leading-relaxed text-muted`,children:[`Frizz can't start a `,s,` thread until you're signed in. Run this command in a terminal on the machine running Frizz, then retry:`]}),(0,R.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg border border-border bg-panel-2 px-3 py-2`,children:[(0,R.jsx)(`code`,{className:`flex-1 select-all font-mono-keep text-[12.5px] text-fg`,children:o}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,onClick:c,className:`icon-hover-outline 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,R.jsx)(e_,{size:14,strokeWidth:2,className:`text-success`}):(0,R.jsx)(m_,{size:14,strokeWidth:1.8})})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:t,className:`button-outline 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,R.jsxs)(`button`,{type:`button`,onClick:()=>l.mutate(),disabled:l.isPending,className:`button-outline flex items-center gap-1.5 rounded-md bg-accent-fill px-3 py-1.5 text-[12.5px] font-medium text-accent-fg outline-none transition-opacity hover:opacity-90 disabled:opacity-60`,children:[l.isPending&&(0,R.jsx)(M_,{size:13,className:`animate-spin`}),`Retry`]})]})]})]})})}function oH({backend:e,onClose:t}){let n=qe(),r=rH[e],i=pt({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,R.jsx)(gR,{open:!0,onOpenChange:e=>{!e&&!i.isPending&&t()},children:(0,R.jsxs)(bR,{children:[(0,R.jsx)(SR,{className:`fixed inset-0 z-[210] bg-scrim-30 backdrop-blur-md backdrop-saturate-150`}),(0,R.jsxs)(ER,{"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-shadow-ink/50 outline-none`,children:[(0,R.jsxs)(jR,{className:`mb-1 text-[14px] font-medium`,children:[`Sign out of `,r,`?`]}),(0,R.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,R.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:t,disabled:i.isPending,className:`button-outline 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,R.jsxs)(`button`,{type:`button`,onClick:()=>i.mutate(),disabled:i.isPending,className:`button-outline flex items-center gap-1.5 rounded-md bg-danger-button/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,R.jsx)(M_,{size:13,className:`animate-spin`}),`Sign out`]})]})]})]})})}function sH(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 cH(e,t=[],n=[]){let r=t.filter(e=>e.available).map(e=>({model:Su(e.id),label:e.label,efforts:[]}));return[{id:`claude`,label:`Claude Code`,options:IB(n).map(e=>({model:e.value,label:e.label,edition:n.find(t=>t.alias===e.value)?.edition,defaultEffort:`high`,efforts:VB(e.value)}))},{id:`codex`,label:`Codex`,options:e.map(e=>({model:e.slug,label:e.displayName,defaultEffort:e.defaultEffort,efforts:e.efforts}))},...r.length?[{id:`acp`,label:`ACP agents`,options:r}]:[]]}function lH(e,t,n=[]){let r=e.backend,i=e[r]??{},a=n.find(e=>e.available),o=i.model??(r===`claude`?`opus`:r===`codex`?t[0]?.slug??``:a?Su(a.id):``),s=r===`codex`?t.find(e=>e.slug===o):void 0,c=r===`acp`?wu(o):void 0,l=r===`acp`?Tu(o):void 0,u=r===`acp`&&c?Su(c):o,d=r===`claude`?FB.some(e=>e.value===o):r===`codex`?t.some(e=>e.slug===o):n.some(e=>e.available&&e.id===c),f=r===`claude`?`high`:s?.defaultEffort??``,p=r===`acp`?``:i.effort??f,m=r===`claude`?WB(o,{withDefault:!1}):r===`codex`?GB(s,{withDefault:!1}):[],h=r===`acp`||m.some(e=>e.value===p),g=p&&!h?[{value:p,label:`${p} (unavailable)`,title:`Saved reasoning level is not available for this model`},...m]:m;return{backend:r,model:o,pickerModel:u,effort:p,codexModel:s,...c?{acpAgentId:c}:{},...l?{acpModelId:l}:{},modelAvailable:d,effortAvailable:h,effortOptions:g}}function uH(){let e=qe(),t=ct({queryKey:[`dispatchPreferencesGet`],queryFn:()=>Y.dispatchPreferencesGet()}),n=ct({queryKey:[`codexModels`],queryFn:()=>Y.codexModels()}),r=n.data??[],i=ct({queryKey:[`claudeModels`],queryFn:()=>Y.claudeModels(),retry:!1}).data??[],a=ct({queryKey:[`acpAgents`],queryFn:()=>Y.acpAgents()}),o=a.data??[],s=pt({mutationFn:e=>Y.dispatchPreferenceSet(e),scope:{id:`dispatch-preferences`},onMutate:t=>{let n=e.getQueryData([`dispatchPreferencesGet`]);n&&e.setQueryData([`dispatchPreferencesGet`],sH(n,t))},onError:t=>{e.invalidateQueries({queryKey:[`dispatchPreferencesGet`]}),Z(`Could not save new-thread preference: ${t.message.slice(0,80)}`)}}),c=!!t.data&&!!n.data&&(a.isSuccess||a.isError);return{resolved:(0,L.useMemo)(()=>c?lH(t.data,r,o):void 0,[c,t.data,r,o]),codexList:r,claudeList:i,acpList:o,loadError:t.isError||n.isError,saveProfile:s.mutate}}var dH=`frizz-drafts:v1`,fH=80,pH=512*1024,mH=2*1024*1024,hH=new TextEncoder;function gH(e){return hH.encode(e).byteLength}function _H(){return{version:1,entries:{}}}function vH(e){if(!e)return _H();try{let t=JSON.parse(e);if(!t||typeof t!=`object`||t.version!==1)return _H();let n=t.entries;if(!n||typeof n!=`object`||Array.isArray(n))return _H();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||gH(t.value)>pH||(r[e]={value:t.value,touchedAt:t.touchedAt});return{version:1,entries:r}}catch{return _H()}}function yH(e){let t=Object.entries(e.entries).filter(([,e])=>e.value&&gH(e.value)<=pH).sort((e,t)=>t[1].touchedAt-e[1].touchedAt),n={};for(let[e,r]of t){if(Object.keys(n).length>=fH)break;n[e]=r,gH(JSON.stringify({version:1,entries:n}))>mH&&delete n[e]}return{version:1,entries:n}}var bH=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=yH(vH(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(dH,JSON.stringify(yH(e)))}catch{}for(let e of this.listeners)e()}};function xH(e,t){if(!t)return;let n=bH.get(e);n.includes(t)||bH.set(e,n?`${t}\n\n${n}`:t)}function SH(e){return encodeURIComponent(e||`unresolved-project`)}var CH={dispatch:e=>`dispatch:${SH(e)}:new`,followUp:(e,t,n)=>`followup:${SH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}`,adopt:(e,t)=>`adopt:${SH(e)}:${encodeURIComponent(t)}`,answer:(e,t,n,r,i)=>`answer:${SH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}:${encodeURIComponent(r)}:${i}`,interaction:(e,t,n,r,i,a,o)=>`interaction:${SH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}:${i}:${encodeURIComponent(a)}:${encodeURIComponent(o)}`,question:(e,t,n,r)=>`question:${SH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}`,questionPick:(e,t,n,r)=>`${CH.question(e,t,n,r)}:picks`};function wH(){return gr(X).board?.projectDir}function TH(e){return gr(X).board?.threads.find(t=>t.id===e)?.sessionId}function EH(e){let t=(0,L.useCallback)(()=>bH.get(e),[e]);return[(0,L.useSyncExternalStore)(bH.subscribe,t,t),(0,L.useCallback)(t=>bH.set(e,t),[e]),(0,L.useCallback)(()=>bH.clear(e),[e])]}function DH(e){let t=(0,L.useCallback)(()=>JSON.stringify(Object.fromEntries(e.map(e=>[e,bH.get(e)]))),[e.join(`\0`)]),n=(0,L.useSyncExternalStore)(bH.subscribe,t,t);return(0,L.useMemo)(()=>new Map(Object.entries(JSON.parse(n))),[n])}function OH(e){let{resolved:t,codexList:n,claudeList:r,acpList:i,loadError:a,saveProfile:o}=uH(),s=ut({mutationKey:[...bB]})>0,c=Kz(),l=wH(),[u,d,f]=EH(CH.dispatch(l)),p=CH.dispatch(l),m=(0,L.useRef)(``),[h,g]=(0,L.useState)(null),_=ct({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4}),[v,y]=(0,L.useState)(null),[b,x]=(0,L.useState)(null),S=(0,L.useRef)(null),C=pt({mutationFn:e=>Y.dispatch(e),onMutate:()=>Z(`Starting thread…`,{spinner:!0,sticky:!0}),onSuccess:t=>{g(null),e?.(),Z(`Thread started`,{link:{label:`Open thread`,slug:t.slug}})},onError:(e,t)=>{bH.get(p)||d(m.current||t.prompt),g(null);let n=/^AUTH_REQUIRED:(claude|codex)$/.exec(e.message);if(n){S.current=t,y(n[1]),Z(`Signed out of ${n[1]===`claude`?`Claude`:`Codex`}`,{duration:3e3});return}Z(`Dispatch failed: ${e.message.slice(0,80)}`)}});function w(e){m.current=u,f(),g(e.prompt),C.mutate(e)}function T(){if(!u.trim()||!t||s)return;let e=iH(u);if(e){if(f(),t.backend===`acp`){Z(`An ACP agent signs in through its own CLI — Frizz holds no account for it`);return}e===`login`?(S.current=null,y(t.backend)):x(t.backend);return}if(!t.modelAvailable){Z(`Saved model is unavailable — choose a model before starting the thread`);return}if(!t.effortAvailable){Z(`Saved reasoning level is unavailable for this model — choose another level`);return}let n={prompt:u.trim(),model:t.model,backend:t.backend,effort:t.effort||void 0};if(t.backend!==`acp`&&_.data?.[t.backend]===`signed-out`){S.current=n,y(t.backend);return}w(n)}let E=(0,L.useMemo)(()=>{if(!t)return(0,R.jsx)(YV,{groups:[],value:void 0,onValueChange:()=>{},placeholder:a?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort loading`,disabled:!0});let e=cH(n,i,r),s=t.acpAgentId?i.find(e=>e.id===t.acpAgentId):void 0;return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-1.5 gap-y-0.5`,children:[(0,R.jsx)(YV,{groups:e,agentSettings:!0,value:{provider:t.backend,model:t.pickerModel,effort:t.effort},onValueChange:e=>o({field:`profile`,backend:e.provider,model:e.model,effort:e.effort||void 0}),ariaLabel:`Model and effort`,title:t.modelAvailable&&t.effortAvailable?`Model and reasoning effort`:`Saved model or reasoning effort unavailable — choose a supported pair`,className:`max-w-[min(21rem,72vw)]`}),s&&(0,R.jsx)($V,{agentId:s.id,agentLabel:s.label,modelId:t.acpModelId,onValueChange:e=>o({field:`model`,backend:`acp`,value:Su(s.id,e)}),className:`max-w-[min(14rem,40vw)] px-2 py-1`})]})},[t,n,r,i,a,o]),D=(0,R.jsxs)(R.Fragment,{children:[v&&(0,R.jsx)(aH,{backend:v,onClose:()=>y(null),onAuthed:()=>{let e=S.current;S.current=null,y(null),e&&w(e)}}),b&&(0,R.jsx)(oH,{backend:b,onClose:()=>x(null)})]});return{prompt:u,setPrompt:d,submit:T,busy:C.isPending||s,footer:E,githubTriggerVisible:c,error:C.isError?C.error.message:null,pendingDispatch:h,accountModals:D}}function kH({autoFocus:e,onDispatched:t}){let n=OH(t);return(0,R.jsxs)(`div`,{className:`w-full flex flex-col gap-3`,children:[(0,R.jsx)(Uz,{surface:`newComposer`,autoFocus:e,value:n.prompt,onChange:n.setPrompt,onSubmit:n.submit,placeholder:`Describe the task…`,minHeight:96,maxHeight:340,busy:n.busy,footer:n.footer,leftAction:n.githubTriggerVisible?(0,R.jsx)(qz,{}):void 0}),n.error&&(0,R.jsx)(`span`,{className:`px-0.5 text-[11px] text-danger truncate`,children:n.error}),n.pendingDispatch&&(0,R.jsx)(AH,{prompt:n.pendingDispatch}),n.accountModals]})}function AH({prompt:e,className:t=``}){return(0,R.jsxs)(`div`,{"data-pending-dispatch":!0,role:`status`,className:`rounded-lg border border-border bg-panel-2 px-3 py-2.5 ${t}`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted`,children:[(0,R.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-accent`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{children:`Starting thread…`})]}),(0,R.jsx)(`p`,{className:`mt-1 line-clamp-2 whitespace-pre-wrap text-[12px] leading-relaxed text-fg`,children:e})]})}function jH({onDispatched:e}){let t=OH(e),n=UG(ME()),r=n.state===`verified`?n.repo:n.state===`local`?n.name:``,[i,a]=(0,L.useState)(!1),o=t.prompt.trim().length>0&&!t.busy&&!i;return(0,R.jsxs)(`div`,{"data-phone-new-thread":!0,className:`flex h-full min-h-0 flex-col`,children:[(0,R.jsxs)(`header`,{className:`flex min-h-[56px] shrink-0 items-center gap-0.5 border-b border-border py-1 pl-1 pr-2`,children:[(0,R.jsx)(NR,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Close`,"data-phone-new-thread-close":!0,className:`flex size-[44px] shrink-0 items-center justify-center rounded-full text-fg/90 active:bg-hover`,children:(0,R.jsx)(cv,{size:21,strokeWidth:2.1})})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 pl-0.5 leading-[1.25]`,children:[(0,R.jsx)(jR,{className:`truncate text-[16.5px] font-semibold tracking-[-0.01em] text-fg`,children:`New thread`}),r&&(0,R.jsx)(`div`,{className:`truncate text-[13px] text-muted`,children:r})]}),(0,R.jsx)(`button`,{type:`button`,"data-phone-start":!0,onMouseDown:e=>e.preventDefault(),onClick:t.submit,disabled:!o,className:`relative flex h-[36px] shrink-0 items-center rounded-full bg-fg px-4 text-[15px] font-semibold text-bg after:absolute after:inset-x-0 after:-inset-y-[4px] after:content-[''] disabled:opacity-35`,children:`Start`})]}),t.error&&(0,R.jsx)(`div`,{className:`shrink-0 px-[18px] pt-2 text-[13px] text-danger`,children:t.error}),t.pendingDispatch&&(0,R.jsx)(AH,{prompt:t.pendingDispatch,className:`mx-3 mt-3 shrink-0`}),(0,R.jsx)(Uz,{surface:`newComposer`,autoFocus:!0,value:t.prompt,onChange:t.setPrompt,onSubmit:t.submit,placeholder:`Describe the task…`,minHeight:120,maxHeight:1e5,busy:t.busy,onUploadingChange:a,phone:{layout:`page`,tools:(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 [&>*]:flex-initial`,children:[t.footer,t.githubTriggerVisible&&(0,R.jsx)(qz,{variant:`phoneChip`})]})}}),t.accountModals]})}function MH({onClose:e}){let t=Lg(),n=(0,L.useRef)(null),r=(0,L.useRef)(typeof document<`u`&&document.activeElement instanceof HTMLElement?document.activeElement:null);return(0,L.useEffect)(()=>()=>{let e=r.current;window.setTimeout(()=>{e?.isConnected&&e.focus({preventScroll:!0})},0)},[]),(0,R.jsx)(gR,{open:!0,onOpenChange:t=>{t||e()},children:(0,R.jsxs)(bR,{children:[(0,R.jsx)(SR,{className:`fixed inset-0 z-50 bg-scrim-30 backdrop-blur-md backdrop-saturate-150`}),(0,R.jsx)(ER,{ref:n,"aria-modal":`true`,"aria-describedby":void 0,onEscapeKeyDown:mB,onCloseAutoFocus:e=>{e.preventDefault();let t=r.current;t?.isConnected&&t.focus({preventScroll:!0})},onOpenAutoFocus:e=>{e.preventDefault(),n.current?.querySelector(`textarea`)?.focus({preventScroll:!0})},className:t?`fixed inset-0 z-50 flex flex-col bg-bg pt-[env(safe-area-inset-top)] outline-none`:`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-shadow-ink/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:t?(0,R.jsx)(jH,{onDispatched:e}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(jR,{className:`mb-1 text-[14px] font-medium`,children:`New thread`}),(0,R.jsx)(kH,{autoFocus:!0,onDispatched:e})]})})]})})}function NH({children:e,onClose:t}){return(0,R.jsx)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center bg-scrim-30 backdrop-blur-md backdrop-saturate-150`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:e})}var PH=`-mx-1.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-fg/75 outline-none transition-colors hover:bg-elevated hover:text-fg focus-visible:ring-1 focus-visible:ring-border-strong disabled:opacity-55`,FH={claude:`size-[11px] translate-y-px`,codex:`size-[10px]`,acp:`h-[11px] w-[6.65px] translate-y-px`,"acp:opencode":`size-[10px]`,"acp:cursor":`size-[10px]`,"acp:gemini":`size-[10px]`,"acp:copilot":`size-[12px] translate-y-px`,"acp:qwen":`size-[10px]`,"acp:kimi":`size-[10px]`},IH={claude:{key:`claude`,backend:`claude`,label:`Claude Code`},codex:{key:`codex`,backend:`codex`,label:`OpenAI Codex`},acp:{key:`acp`,backend:`acp`,label:`ACP agent`},"acp:opencode":{key:`acp:opencode`,backend:`acp`,label:`OpenCode`},"acp:cursor":{key:`acp:cursor`,backend:`acp`,label:`Cursor agent`},"acp:gemini":{key:`acp:gemini`,backend:`acp`,label:`Gemini CLI`},"acp:copilot":{key:`acp:copilot`,backend:`acp`,label:`GitHub Copilot CLI`},"acp:qwen":{key:`acp:qwen`,backend:`acp`,label:`Qwen Code`},"acp:kimi":{key:`acp:kimi`,backend:`acp`,label:`Kimi CLI`}};function LH(e){return Object.hasOwn(IH,e)}function RH(e,t){if(e===`claude`||e===`codex`)return IH[e];if(e!==`acp`)return;let n=wu(t),r=n?`acp:${n}`:`acp`;return LH(r)?IH[r]:IH.acp}function zH({backend:e,model:t,className:n}){let r=RH(e,t);return r?(0,R.jsx)(`span`,{role:`img`,"aria-label":r.label,className:`inline-flex shrink-0 text-muted-65 ${FH[r.key]} ${n??``}`,children:BH[r.key]()}):null}var BH={claude:UH,codex:HH,acp:VH,"acp:opencode":WH,"acp:cursor":GH,"acp:gemini":KH,"acp:copilot":qH,"acp:qwen":JH,"acp:kimi":YH};function VH(){return(0,R.jsx)(K_,{"aria-hidden":`true`,focusable:`false`,className:`size-full`,strokeWidth:2.5,viewBox:`4.75 0.75 14.5 22.5`})}function HH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.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 UH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.jsx)(`path`,{d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`})})}function WH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.jsx)(`path`,{d:`M22 24H2V0h20zM17 4.8H7v14.4h10z`})})}function GH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.jsx)(`path`,{d:`M11.503.131 1.891 5.678a.84.84 0 0 0-.42.726v11.188c0 .3.162.575.42.724l9.609 5.55a1 1 0 0 0 .998 0l9.61-5.55a.84.84 0 0 0 .42-.724V6.404a.84.84 0 0 0-.42-.726L12.497.131a1.01 1.01 0 0 0-.996 0M2.657 6.338h18.55c.263 0 .43.287.297.515L12.23 22.918c-.062.107-.229.064-.229-.06V12.335a.59.59 0 0 0-.295-.51l-9.11-5.257c-.109-.063-.064-.23.061-.23`})})}function KH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.jsx)(`path`,{d:`M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81`})})}function qH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.jsx)(`path`,{d:`M23.922 16.997C23.061 18.492 18.063 22.02 12 22.02 5.937 22.02.939 18.492.078 16.997A.641.641 0 0 1 0 16.741v-2.869a.883.883 0 0 1 .053-.22c.372-.935 1.347-2.292 2.605-2.656.167-.429.414-1.055.644-1.517a10.098 10.098 0 0 1-.052-1.086c0-1.331.282-2.499 1.132-3.368.397-.406.89-.717 1.474-.952C7.255 2.937 9.248 1.98 11.978 1.98c2.731 0 4.767.957 6.166 2.093.584.235 1.077.546 1.474.952.85.869 1.132 2.037 1.132 3.368 0 .368-.014.733-.052 1.086.23.462.477 1.088.644 1.517 1.258.364 2.233 1.721 2.605 2.656a.841.841 0 0 1 .053.22v2.869a.641.641 0 0 1-.078.256Zm-11.75-5.992h-.344a4.359 4.359 0 0 1-.355.508c-.77.947-1.918 1.492-3.508 1.492-1.725 0-2.989-.359-3.782-1.259a2.137 2.137 0 0 1-.085-.104L4 11.746v6.585c1.435.779 4.514 2.179 8 2.179 3.486 0 6.565-1.4 8-2.179v-6.585l-.098-.104s-.033.045-.085.104c-.793.9-2.057 1.259-3.782 1.259-1.59 0-2.738-.545-3.508-1.492a4.359 4.359 0 0 1-.355-.508Zm2.328 3.25c.549 0 1 .451 1 1v2c0 .549-.451 1-1 1-.549 0-1-.451-1-1v-2c0-.549.451-1 1-1Zm-5 0c.549 0 1 .451 1 1v2c0 .549-.451 1-1 1-.549 0-1-.451-1-1v-2c0-.549.451-1 1-1Zm3.313-6.185c.136 1.057.403 1.913.878 2.497.442.544 1.134.938 2.344.938 1.573 0 2.292-.337 2.657-.751.384-.435.558-1.15.558-2.361 0-1.14-.243-1.847-.705-2.319-.477-.488-1.319-.862-2.824-1.025-1.487-.161-2.192.138-2.533.529-.269.307-.437.808-.438 1.578v.021c0 .265.021.562.063.893Zm-1.626 0c.042-.331.063-.628.063-.894v-.02c-.001-.77-.169-1.271-.438-1.578-.341-.391-1.046-.69-2.533-.529-1.505.163-2.347.537-2.824 1.025-.462.472-.705 1.179-.705 2.319 0 1.211.175 1.926.558 2.361.365.414 1.084.751 2.657.751 1.21 0 1.902-.394 2.344-.938.475-.584.742-1.44.878-2.497Z`})})}function JH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.jsx)(`path`,{d:`M23.919 14.545 20.817 9.17l1.47-2.544a.56.56 0 0 0 0-.566l-1.633-2.83a.57.57 0 0 0-.49-.283h-6.207L12.487.402a.57.57 0 0 0-.49-.284H8.732a.56.56 0 0 0-.49.284L5.139 5.775h-2.94a.56.56 0 0 0-.49.284L.077 8.887a.56.56 0 0 0 0 .567L3.18 14.83l-1.47 2.545a.56.56 0 0 0 0 .566l1.634 2.83a.57.57 0 0 0 .49.283h6.205l1.47 2.545a.57.57 0 0 0 .49.284h3.266a.57.57 0 0 0 .49-.284l3.104-5.375h2.94a.57.57 0 0 0 .49-.283l1.634-2.828a.55.55 0 0 0-.004-.568M8.733.686l1.634 2.828-1.634 2.828H21.8L20.164 9.17H7.425L5.63 6.06Zm1.306 19.801-6.205-.002 1.634-2.83h3.265L2.201 6.344h3.267q3.182 5.517 6.367 11.032zm10.124-5.66L18.53 12l-6.532 11.315-1.634-2.83c2.129-3.673 4.25-7.351 6.373-11.028h3.592l3.102 5.374z`})})}function YH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.jsx)(`path`,{d:`M21.765.351C22.998.351 24 1.353 24 2.586S22.998 4.82 21.765 4.82h-1.974c-.15 0-.26-.12-.26-.26V2.586A2.237 2.237 0 0 1 21.765.35M9.41 13.388l8.447-8.377c.16-.16.07-.471-.14-.471h-4.55s-.1.02-.14.06l-9.099 9.029c-.14.14-.35.02-.35-.21V4.81c0-.15-.1-.27-.221-.27H.22c-.12 0-.22.12-.22.27v18.57c0 .15.1.27.22.27h3.137c.12 0 .22-.12.22-.27v-3.79c0-.08.03-.16.08-.21l2.826-2.796c.07-.07.16-.08.241-.03l7.546 5.551a8.9 8.9 0 0 0 4.018 1.493c.12.01.23-.11.23-.27V19.76c0-.14-.08-.25-.19-.26a5.8 5.8 0 0 1-2.355-.942l-6.533-4.73c-.14-.09-.15-.32-.03-.441`})})}var XH=3e4,ZH=45e3;function QH(e,t){return t?AbortSignal.any([t,AbortSignal.timeout(e)]):AbortSignal.timeout(e)}var $H=`text-[9px]`,eU={claude:`text-fg/75! size-[14px]! translate-y-0!`,codex:`text-fg/75! size-[12.75px]! translate-y-0!`};function tU(){let e=ct({queryKey:[`quota`],queryFn:()=>Y.quota(),staleTime:1e4}),t=ct({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4});return[`claude`,`codex`].some(n=>nU(e.data?.[n],t.data?.[n],e.isLoading))}function nU(e,t,n){return t===`signed-out`||!e&&n?!1:!!e&&e.status===`ok`&&e.windows.length>0}function rU(){let e=qe(),t=(0,L.useRef)(null),[n,r]=(0,L.useState)(!1),i=ct({queryKey:[`quota`],queryFn:({signal:e})=>Y.quota(void 0,{signal:QH(XH,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=ct({queryKey:[`authStatus`],queryFn:({signal:e})=>Y.authStatus(void 0,{signal:QH(XH,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:QH(ZH)}).then(t=>e.setQueryData([`quota`],t)),e.refetchQueries({queryKey:[`authStatus`]})]).then(()=>{}).catch(()=>{}).finally(()=>{t.current=null,r(!1)});t.current=i};return(0,R.jsxs)(`div`,{"data-quota-bar":!0,className:`flex shrink-0 items-center gap-3 ${$H}`,children:[(0,R.jsx)(iU,{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,R.jsx)(iU,{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 iU({backend:e,quota:t,auth:n,email:r,loading:i,fetching:a,onRecheck:o}){let s=rH[e];if(!nU(t,n,i))return null;let c=oU(100-cU(t.windows).usedPercent);return(0,R.jsx)(R.Fragment,{children:(0,R.jsxs)(CV,{onOpenChange:e=>{e&&o()},children:[(0,R.jsx)(wV,{asChild:!0,children:(0,R.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,R.jsx)(zH,{backend:e,className:eU[e]}),(0,R.jsxs)(`span`,{className:`tabular-nums ${lU(c)}`,children:[c,`%`]})]})}),(0,R.jsxs)(EV,{side:`bottom`,align:`start`,className:`w-[min(15rem,calc(100vw-1.5rem))] p-3 text-[11px] leading-relaxed text-fg`,children:[(0,R.jsxs)(`div`,{className:`mb-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,R.jsx)(zH,{backend:e}),(0,R.jsx)(`span`,{children:s}),t?.planType&&(0,R.jsxs)(`span`,{className:`text-muted-70`,children:[`· `,uU(t.planType),` plan`]}),a&&(0,R.jsx)(M_,{size:11,className:`animate-spin text-muted-60`,"aria-label":`Rechecking`})]}),r&&(0,R.jsx)(`div`,{"data-quota-account":!0,className:`truncate text-muted-70 select-text`,title:r,children:r})]}),(0,R.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[t.windows.map(e=>{let t=oU(100-e.usedPercent),n=dU(e);return(0,R.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`span`,{className:`text-muted-80`,children:e.label}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2 tabular-nums`,children:[(0,R.jsxs)(`span`,{className:lU(t),children:[t,`% left`]}),n&&(0,R.jsxs)(`span`,{className:`text-muted-55`,children:[`resets `,n]})]})]},e.key)}),t.detail&&(0,R.jsx)(`li`,{className:`pt-1 text-muted-55`,children:t.detail})]})]})]})})}function aU(){let e=ct({queryKey:[`quota`],queryFn:({signal:e})=>Y.quota(void 0,{signal:QH(XH,e)}),refetchInterval:3e4,staleTime:1e4}),t=ct({queryKey:[`authStatus`],queryFn:({signal:e})=>Y.authStatus(void 0,{signal:QH(XH,e)}),staleTime:3e4}),n=[`claude`,`codex`].flatMap(n=>{let r=e.data?.[n];return nU(r,t.data?.[n],e.isLoading)?r.windows.map(e=>({key:`${n}-${e.key}`,label:`${rH[n]} · ${e.label}`,left:oU(100-e.usedPercent)})):[]});return n.length===0?null:(0,R.jsx)(`ul`,{"data-quota-meters":!0,className:`m-0 flex list-none flex-col gap-[9px] p-0`,children:n.map(e=>(0,R.jsxs)(`li`,{className:`flex items-center gap-2.5 text-[13.5px] leading-[19px]`,children:[(0,R.jsx)(`span`,{className:`w-[108px] shrink-0 truncate text-muted`,children:e.label}),(0,R.jsx)(`span`,{className:`h-[5px] min-w-0 flex-1 overflow-hidden rounded-full bg-border`,"aria-hidden":!0,children:(0,R.jsx)(`span`,{className:`block h-full rounded-full ${e.left<=8?`bg-danger`:`bg-fg/75`}`,style:{width:`${e.left}%`}})}),(0,R.jsxs)(`span`,{className:`w-[64px] shrink-0 text-right tabular-nums ${e.left<=8?`text-danger`:`text-fg`}`,children:[e.left,`% left`]})]},e.key))})}function oU(e){return Math.max(0,Math.min(100,Math.round(e)))}var sU=25;function cU(e){return e.find(e=>e.key===`5h`)??e.reduce((e,t)=>t.usedPercent>e.usedPercent?t:e)}function lU(e){return e<=8?`text-danger`:e<=sU?`text-accent`:`text-fg/70`}function uU(e){return e&&e[0].toUpperCase()+e.slice(1)}function dU(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 fU=`frizz:supervisor-status-wake`,pU=`frizz:reload-after-update-restart`,mU=`frizz:update-restart-from-version`;function hU(e,t){return t.version===e?{kind:`previous-kept`}:{kind:`successor-failed`,version:t.version}}function gU(e){if(e.kind===`previous-kept`)return{summary:`Frizz kept running the previous version`,detail:`Frizz kept running the previous version, and your threads are unaffected.`};let t=e.version?`Frizz ${e.version}`:`The new version of Frizz`;return{summary:`${t} failed to start`,detail:`${t} came up but could not start its board, and the previous version is gone. Restart Frizz from the terminal (npx frizz) and check its log for the reason.`}}function _U(e){return e?.artifactDigest??e?.version??null}function vU(e,t){if(e===null||t?.state!==`ready`)return!1;let n=_U(t);return n!==null&&n!==e}var yU=3*6e4,bU={silentSince:null,silentForMs:0,stalled:!1};function xU(e,t,n=yU){if(!t.restarting||t.answered)return bU;let r=e.silentSince??t.at,i=Math.max(0,t.at-r);return{silentSince:r,silentForMs:i,stalled:i>=n}}function SU(e,t){return e.ackedAt!==null&&t.requestedAt>=e.ackedAt}function CU(e,t){return e.attempt&&!(SU(e.attempt,t)&&wU(e.attempt,t))?e:{state:t.state,message:t.message??null,attempt:null}}function wU(e,t){if(t.state!==`ready`)return!0;let n=t.artifactDigest??t.version??null;return e.build!=null&&n!==null&&n!==e.build}function TU(e,t){return t.state===`ready`&&e.attempt===null}function EU(e){return e!==null}function DU(e){return e?.updateRestart===!0&&e.updateAvailable!==!1}function OU(e){return e?.dev===!0}async function kU(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 AU(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 jU(e=fetch){return AU(`/_frizz/control/restart`,e)}function MU(e=fetch){return AU(`/_frizz/control/update-restart`,e)}var NU=8e3,PU=500,FU=[`supervisorStatus`];function IU(e,t){return e===`restarting`||t?PU:NU}var LU=lt({queryKey:FU,queryFn:async()=>{let e=Date.now(),t=await kU();return t?{...t,requestedAt:e}:null},refetchInterval:e=>IU(e.state.data?.state,X.controlPlaneRestartAttempt!==null),staleTime:e=>IU(e.state.data?.state,X.controlPlaneRestartAttempt!==null)});function RU(){return ct(LU)}var zU=null;function BU(e){zU||(zU=e,window.addEventListener(fU,()=>{e.refetchQueries({queryKey:FU,exact:!0})}))}function VU(e,t){let n=e=>{let t=e&&/^v?(\d+)\.(\d+)\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u.exec(e);return t?[Number(t[1]),Number(t[2])]:null},r=n(e),i=n(t);return r!==null&&i!==null&&(r[0]!==i[0]||r[1]!==i[1])}function HU(e){return DU(e)&&VU(e?.version,e?.updateVersion)}var UU=`Install the latest version of Frizz. Your running threads will not be affected.`,WU=`A newer version of Frizz is available. Your running threads will not be affected.`,GU=`Restart Frizz. Your running threads will not be affected.`,KU=`There is no newer version of Frizz to install.`,qU=`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)]`,JU=`absolute -top-[7px] left-4 h-3 w-3 rotate-45 border-l border-t bg-elevated`,YU=`sm:w-[min(23rem,calc(100vw-1.5rem))]`,XU=`sm:w-[min(34rem,calc(100vw-1.5rem))]`,ZU=`rounded-xl bg-elevated p-3.5 shadow-xl shadow-shadow-ink/45`;function QU({open:e,update:t,current:n=!1,version:r,updateVersion:i}){if(!e)return null;let a=n?`Frizz is up to date`:t?`Update Frizz`:`Restart Frizz`,o=t?i:void 0;return(0,R.jsxs)(`div`,{id:`update-restart-popover`,role:`tooltip`,"aria-label":a,className:`${qU} ${YU} ${ZU} border border-border-strong`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`${JU} border-border-strong`}),(0,R.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,R.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-fg/10 text-fg`,children:n?(0,R.jsx)(e_,{"aria-hidden":`true`,size:14,strokeWidth:2.25}):(0,R.jsx)(J_,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,R.jsx)(`span`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:a}),r&&(0,R.jsx)(`span`,{className:`font-mono text-[11px] leading-snug text-muted`,children:o?`${r} → ${o}`:r})]})]}),(0,R.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:n?KU:t?o?WU:UU:GU})]})}var $U={kind:`previous-kept`};function eW({update:e,message:t,outcome:n=$U,onDismiss:r,mobile:i=!1}){return(0,R.jsxs)(`div`,{role:`alert`,className:`${i?`mx-[18px] my-3 text-left font-sans`:`${qU} ${XU}`} ${ZU} border border-danger-fill/45`,children:[!i&&(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`${JU} border-danger-fill/45`}),(0,R.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,R.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-danger-fill/15 text-danger-soft`,children:(0,R.jsx)(ov,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,R.jsx)(`span`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:e?`Update failed`:`Restart failed`}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,onClick:r,className:`icon-hover-outline -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,R.jsx)(cv,{"aria-hidden":`true`,size:14,strokeWidth:2.25})})]}),(0,R.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:gU(n).detail}),(0,R.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 tW({update:e,busy:t,current:n=!1,version:r,updateVersion:i,onFocus:a,onBlur:o,onClick:s}){return(0,R.jsxs)(`button`,{type:`button`,"aria-describedby":`update-restart-popover`,"aria-label":n?`Frizz is up to date`:e?`Update Frizz`:`Restart Frizz`,disabled:t,"aria-busy":t||void 0,"aria-disabled":n||void 0,className:`relative ${PH}${n?` pointer-events-none opacity-40`:``}`,onFocus:a,onBlur:o,onClick:n?void 0:s,children:[(0,R.jsx)(J_,{size:14,"aria-hidden":`true`,className:t?`animate-spin`:void 0}),e&&!t&&VU(r,i)&&(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-[2px] top-[2px] h-[4px] w-[4px] rounded-full bg-accent`})]})}function nW(){let e=gr(X),[t,n]=(0,L.useState)(!1),[r,i]=(0,L.useState)(),[a,o]=(0,L.useState)(),s=(0,L.useRef)(null),c=RU().data??null,l=DU(c),u={version:c?.version,updateVersion:c?.updateVersion},d=s.current!==null&&e.controlPlaneState===`failed`,f=d?e.controlPlaneMessage??`Frizz did not become ready`:void 0,p=r??f,m=p&&p!==a?p:void 0,h=!r&&d&&s.current?hU(s.current.version,{version:c?.version}):$U,g=!l&&!t&&!m;return{visible:EU(c),update:l,busy:t,current:g,version:u.version,updateVersion:u.updateVersion,shownError:m,outcome:h,dismiss:()=>o(m),run:async()=>{if(t||g)return;s.current={version:c?.version},n(!0),i(void 0),o(void 0);let e=`${window.location.pathname}${window.location.search}${window.location.hash}`;l&&(X.controlPlaneState=`restarting`,X.controlPlaneMessage=null,X.controlPlaneRestartAttempt={startedAt:Date.now(),ackedAt:null,build:_U(c)});try{if(l?await MU():await jU(),l){sessionStorage.setItem(pU,e),s.current.version?sessionStorage.setItem(mU,s.current.version):sessionStorage.removeItem(mU);let t=X.controlPlaneRestartAttempt;t&&(X.controlPlaneRestartAttempt={...t,ackedAt:Date.now()}),window.dispatchEvent(new Event(fU)),n(!1)}else window.location.replace(e)}catch(e){l&&(X.controlPlaneRestartAttempt=null,X.controlPlaneState=`ready`,X.controlPlaneMessage=null);let t=e.message.slice(0,140);n(!1),i(t),Z(`${l?`Update & Restart`:`Restart Frizz`} failed`)}}}}function rW(){let[e,t]=(0,L.useState)(!1),n=(0,L.useRef)(null),r=nW();return r.visible?(0,R.jsxs)(`div`,{ref:n,className:`relative`,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[(0,R.jsx)(tW,{update:r.update,busy:r.busy,current:r.current,version:r.version,updateVersion:r.updateVersion,onFocus:()=>t(!0),onBlur:()=>t(!1),onClick:()=>{t(!1),r.run()}}),r.shownError&&(0,R.jsx)(eW,{update:r.update,message:r.shownError,outcome:r.outcome,onDismiss:r.dismiss}),(0,R.jsx)(QU,{open:e&&!r.shownError,update:r.update,current:r.current,version:r.version,updateVersion:r.updateVersion})]}):null}function iW(){return(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px shrink-0 bg-border`})}function aW({text:e,title:t,className:n}){return(0,R.jsx)(`span`,{dir:`rtl`,className:`block min-w-0 overflow-hidden text-ellipsis whitespace-nowrap ${n??``}`,title:t,children:(0,R.jsx)(`span`,{dir:`ltr`,className:`[unicode-bidi:isolate]`,children:e})})}function oW(){let e=ME(),t=UG(e),n=tU(),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,R.jsxs)(`div`,{"data-status-row":!0,className:`mb-2.5 flex min-w-0 items-center gap-3 text-[12px]`,children:[(0,R.jsx)(iC,{to:`/`,title:`All projects`,"aria-label":`All projects`,className:`${PH} -ml-px`,children:(0,R.jsx)(O_,{size:14,"aria-hidden":`true`})}),(0,R.jsx)(iW,{}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Settings`,title:`Settings`,className:PH,onClick:()=>X.showSettings=!0,children:(0,R.jsx)(Q_,{size:14,"aria-hidden":`true`})}),(0,R.jsx)(rW,{}),n&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(iW,{}),(0,R.jsx)(rU,{})]}),(0,R.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,R.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,R.jsx)(aW,{text:i})}):i?(0,R.jsx)(aW,{text:i,title:i,className:`font-semibold text-fg/90`}):(0,R.jsx)(`span`,{className:`identity-placeholder w-24`,"aria-hidden":`true`})})]})}var sW=fr({at:{}}),cW=12e3,lW=new Map;function uW(e,t=Date.now()){sW.at[e]=t;let n=lW.get(e);n!==void 0&&clearTimeout(n),lW.set(e,setTimeout(()=>{lW.delete(e),delete sW.at[e]},cW))}function dW(e){let t=lW.get(e);t!==void 0&&(clearTimeout(t),lW.delete(e)),delete sW.at[e]}function fW(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 pW(){return gr(sW).at}function mW(e,t,n=Date.now()){let r=t!==void 0&&fW(e,t,n);return!r&&e.deliveryInFlight!==!0?e:{...e,runtime:`running`,needsYou:!1,pendingAsk:void 0,pendingQuestion:!1,actionableInteraction:!1,lastUserAt:r?new Date(t).toISOString():e.lastUserAt}}function hW(e){let t=pW();return(0,L.useMemo)(()=>e.map(e=>mW(e,t[e.id])),[e,t])}var gW=0;function _W(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(gW+=1,`browser-${Date.now()}-${gW}`)}function vW({optimistic:e,request:t,success:n,failure:r}){e(),t().then(()=>n?.(),e=>r(e instanceof Error?e:Error(String(e))))}var yW=new Map;function bW(e,t){let n=(yW.get(e)??Promise.resolve()).then(t,t);return yW.set(e,n.then(()=>{},()=>{})),n}var xW=[300,800,1800,3500],SW=12e4,CW=e=>new Promise(t=>{setTimeout(t,e)});async function wW(e,t,n=CW){for(let r=0;;r++){try{await e()}catch(e){if(r>=xW.length||!Fm(e))throw e;t(),await n(xW[r]);continue}t();return}}function TW(e,t,n,r,i,a=SW,o){let s=new AbortController,c=setTimeout(()=>s.abort(Error(`Frizz did not answer this send`)),a);return Y.followUp({slug:e,sessionId:Cg(X.board,e)?.sessionId??``,message:t,deliveryId:n,freshProcess:r,interrupt:i,...o?{supersedes:o}:{}},{signal:s.signal}).finally(()=>clearTimeout(c))}function EW(e,t,n,r,i,a){return wW(()=>TW(e,t,n,r,i,SW,a),()=>uW(e))}function DW(e,t,n,r={}){let i=n.trim();if(!i)return!1;let a=_W();return vW({optimistic:()=>{r.onOptimistic?.(),lte(e,t,i,{scrollToBottom:r.scrollToBottom,deliveryId:a}),uW(t),Y.markRead({slug:t}).catch(()=>{})},request:()=>bW(t,()=>EW(t,i,a,r.freshProcess,r.interrupt,r.supersedes)),success:()=>r.onSuccess?.(),failure:n=>{zE(e,t,i,a),dW(t),r.onRollback?.({deliveryId:a,text:i,kept:Im(n)}),Z(r.failureToast?.(n.message)??`Steer failed — ${n.message.slice(0,160)}`)}}),!0}function OW(e){let t=qe(),[n,r]=(0,L.useState)(0);return{submit:(0,L.useCallback)((n,i={})=>DW(t,e,n,{...i,onOptimistic:()=>{r(e=>e+1),i.onOptimistic?.()},onSuccess:()=>{r(e=>Math.max(0,e-1)),i.onSuccess?.()},onRollback:e=>{r(e=>Math.max(0,e-1)),i.onRollback?.(e)}}),[t,e]),pending:n>0}}function kW(e,t){return new Promise(n=>{DW(e,t,`Continue exactly where you left off.`,{onSuccess:()=>{Z(`Retrying…`),n()},onRollback:()=>n(),failureToast:e=>`Retry failed: ${e.slice(0,80)}`})||n()})}function AW(e,t=`pull`){let n=/^([A-Za-z0-9][\w.-]*)\/([A-Za-z0-9][\w.-]*)#(\d+)$/.exec(e.trim());return n?`https://github.com/${n[1]}/${n[2]}/${t===`issue`?`issues`:`pull`}/${n[3]}`:null}function jW(e){return Ku(e).length>0&&Gu(e).length===0}var MW=`Waiting for an external update.`,NW=`To do`,PW=`Done`;function FW(e){let t=new Set;return e.flatMap(e=>{if(e.kind!==`pr`&&e.kind!==`issue`)return[];let n=e.value.trim();return!n||t.has(`${e.kind}:${n}`)?[]:(t.add(`${e.kind}:${n}`),[{ref:n,url:AW(n,e.kind===`issue`?`issue`:`pull`)}])})}function IW(e){let t=(e.body??``).split(/\n\s*\n/).map(e=>e.trim()).find(Boolean);return t?zW(LW(t.replace(/\s*\n\s*/g,` `))):null}function LW(e){if(e.length<=RW)return e;let t=e.slice(0,RW),n=t.lastIndexOf(` `);return`${(n>RW/2?t.slice(0,n):t).replace(/[.,;:]$/,``)}…`}var RW=240;function zW(e){let t=(e.split(/\s/,1)[0]??``).replace(/[.,:;]+$/,``);return/[^a-zA-Z]/.test(t)||/[A-Z]/.test(t.slice(1))||BW.has(t)?e:e.charAt(0).toUpperCase()+e.slice(1)}var BW=new Set([`npm`,`npx`,`pnpm`,`nub`,`nubx`,`gh`,`git`,`node`,`bun`,`tsc`,`vite`,`curl`,`ssh`]);function VW(e){return e&&UW(e)||null}var HW=new Set([...Lu,`shells`,`agents`,`timers`,`prs`,`issues`,`for`,`title`,`status`,`needs_input`,`needs-input`]);function UW(e){return e.split(`
|
|
202
|
+
`)})}return!i.length||!i.every(e=>fz(n,e.token))?null:{body:n,items:i}}function hz(e){return e.key===`Enter`&&!e.altKey&&!e.shiftKey&&!e.isComposing&&e.keyCode!==229}function Kte(e,t){return t&&hz(e)&&!e.metaKey&&!e.ctrlKey}function qte(e,t){return t&&hz(e)&&(e.metaKey||e.ctrlKey)}function Jte(e,t){return!t&&e?.runtime===`running`&&e.backend!==`codex`&&e.backend!==`acp`}function gz(e){return hz(e)}function Yte(e){return e.key===`Enter`&&e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.isComposing}function Xte(e,t,n){return e===`queueComposer`&&t===`Enter`&&n}var Zte=.5;function _z(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*Zte,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 Qte(e,t,n,r){return!e||e.top<=r&&e.bottom>r?!0:Math.abs(t-n)>1}function $te(e,t,n,r,i=8){return n<e+i?n-e-i:r>t-i?r-t+i:0}function vz(){return[...document.querySelectorAll(`[data-queue-card][data-queue-leaving="false"]`)].flatMap(e=>{let t=e.dataset.queueCard;if(!t)return[];let{top:n,bottom:r}=(e.querySelector(`[data-queue-card-root]`)??e).getBoundingClientRect();return[{id:t,top:n,bottom:r}]})}function yz(){let e=Math.max(0,document.documentElement.scrollHeight-window.innerHeight);return e>0&&window.scrollY>=e-1}var bz=new Map,xz=!1;function ene(e,t){return bz.set(e,t),!xz&&typeof window<`u`&&(window.addEventListener(`keydown`,one),xz=!0),()=>{bz.get(e)===t&&bz.delete(e)}}var Sz=`[role="dialog"][data-state="open"], [role="dialog"][aria-modal="true"]`,Cz=`[data-queue-card-root]`;function tne(e){return e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement?!0:e instanceof HTMLInputElement?![`button`,`checkbox`,`radio`,`submit`,`reset`].includes(e.type):e instanceof HTMLElement&&e.isContentEditable?!0:!!e.closest(`.xterm, [role="menu"], [role="listbox"], [role="menubar"], [role="combobox"]`)}function nne(e){return e.sort((e,t)=>e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1)}function wz(){return nne([...bz.keys()].filter(e=>e.isConnected&&e.getClientRects().length>0&&bz.get(e)?.keyed()))}function Tz(e){if(!e?.isConnected)return!1;let t=e.getBoundingClientRect(),n=Math.max(t.top,0),r=Math.min(t.bottom,window.innerHeight),i=Math.max(t.left,0),a=Math.min(t.right,window.innerWidth);if(r<=n||a<=i)return!1;let o=(i+a)/2;return[.25,.5,.75].some(t=>{let i=document.elementFromPoint(o,n+(r-n)*t);return!!i&&e.contains(i)})}function rne(e){let t=bz.get(e);if(!t)return!1;for(let e=1;e<=9;e++){let n=t.row(e);if(!n)break;if(Tz(n))return!0}return!1}function Ez(e){return e.closest(Sz)??e.closest(Cz)??document.body}function Dz(e){return e.find(e=>!bz.get(e)?.answered())??e[0]??null}function ine(){let e=_z(vz(),window.innerHeight,yz());return e?document.querySelector(`[data-queue-card="${CSS.escape(e)}"] ${Cz}`):null}function ane(e){let t=e?.closest(`[data-question-grid]`);if(t&&bz.has(t))return t;let n=wz().filter(rne),r=document.querySelectorAll(Sz),i=r[r.length-1];if(i)return Dz(n.filter(e=>i.contains(e)));let a=e?.closest(Cz);if(a)return Dz(n.filter(e=>a.contains(e)));let o=ine(),s=o&&n.find(e=>o.contains(e))||n[0];return s?Dz(n.filter(e=>Ez(e)===Ez(s))):null}function Oz(e){e.focus({preventScroll:!0}),e.scrollIntoView({block:`nearest`,behavior:`instant`})}function one(e){if(e.defaultPrevented||e.repeat||e.isComposing||e.metaKey||e.ctrlKey||e.altKey||!/^[1-9]$/.test(e.key))return;let t=e.target instanceof Element?e.target:null;if(t&&tne(t))return;let n=ane(t),r=n&&bz.get(n);if(!n||!r)return;let i=Number(e.key);if(!Tz(r.row(i)))return;let a=r.press(i);if(a&&(e.preventDefault(),a!==`text`)){if(a===`toggled`)return Oz(n);requestAnimationFrame(()=>{let e=Ez(n),t=wz().filter(t=>Ez(t)===e&&(n.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING)!==0);Oz(t.find(e=>!bz.get(e)?.answered())??(n.isConnected?n:t[0]??n))})}}function sne(e){let t=e.closest(Sz)??e.closest(Cz);if(!t)return!1;let n=Dz(wz().filter(e=>t.contains(e)));return n?(Oz(n),!0):!1}var cne=[`lead`,`paperclip`,`action`,`mic`,`send`],lne=28,une=8,dne=8,kz={"paperclip>send":8,"action>send":7,"paperclip>action":0,"lead>paperclip":-1,"mic>send":6,"paperclip>mic":-2,"action>mic":-3};function fne(e){let t={send:!0,paperclip:!0,lead:!!e.lead,action:!!e.action,mic:!!e.mic},n=cne.filter(e=>t[e]),r={},i=0,a=null;for(let e of[...n].reverse())r[e]=a?i+(kz[`${e}>${a}`]??kz[`paperclip>send`]):une,i=r[e]+lne,a=e;return{right:r,reserve:i+dne}}function Az(){if(typeof window>`u`||!window.isSecureContext)return null;let e=window.SpeechRecognition;return typeof e?.available==`function`&&typeof e.install==`function`?e:null}function pne(e){let t=[...new Set(e.filter(Boolean))];return t.some(e=>/^en\b/i.test(e))&&!t.includes(`en-US`)&&t.push(`en-US`),t}var mne=/\bHeadlessChrome\/|\bElectron\//,jz=`frizz:dictation-probe`,hne=6e4;function gne(){try{return window.localStorage}catch{return null}}async function _ne(){let e=Az();if(!e||mne.test(navigator.userAgent))return null;let t=gne(),n=Number(t?.getItem(jz)??0);if(n&&Date.now()-n>hne)return null;t?.setItem(jz,String(Date.now()));try{return await vne(e)}finally{t?.removeItem(jz)}}async function vne(e){for(let t of pne(navigator.languages??[navigator.language]))try{let n=await e.available({langs:[t],processLocally:!0});if(n!==`unavailable`)return{lang:t,status:n}}catch{}return null}var Mz;function yne(){return Mz??=_ne(),Mz}var bne=[`Frizz`,`queue`,`pull request`,`type check`,`worktree`,`sub-agent`,`commit to main`],xne=2,Sne=/^I(?:'[a-z]+)?\b/;function Nz(e){return/^[A-Z][a-z]/.test(e)&&!Sne.test(e)?e[0].toLowerCase()+e.slice(1):e}function Cne(e){return e.map(e=>e.trim()).filter(Boolean).map((e,t)=>t===0?e:Nz(e)).join(` `)}function wne(e,t,n){if(!t)return{text:e+n,caret:e.length};let r=/(?:^|[.!?]\s*|\n\s*)$/.test(e)?t[0].toUpperCase()+t.slice(1):Nz(t),i=e&&!/\s$/.test(e)?` `:``,a=n&&!/^\s/.test(n)?` `:``,o=e+i+r;return{text:o+a+n,caret:o.length}}var Pz=null;function Fz(e){switch(e){case`not-allowed`:case`service-not-allowed`:return`Microphone access is blocked for this site — allow it in the browser's site settings to dictate`;case`audio-capture`:return`No microphone was found`;case`language-not-supported`:return`The on-device speech model is not installed — click the microphone again to download it`;case`aborted`:case`no-speech`:return null;default:return`Dictation stopped (${e})`}}function Tne(e){let t=e instanceof DOMException?e.name:``;return t===`NotAllowedError`||t===`SecurityError`?Fz(`not-allowed`):t===`NotFoundError`||t===`OverconstrainedError`?Fz(`audio-capture`):`The microphone could not start: ${e instanceof Error?e.message:String(e)}`}function Iz(e){for(let t of e.getTracks())t.stop()}function Ene({read:e,write:t,enabled:n=!0}){let[r,i]=(0,L.useState)(null),[a,o]=(0,L.useState)(`idle`),[s,c]=(0,L.useState)(null),l=(0,L.useRef)(null),u=(0,L.useRef)(!0),d=(0,L.useRef)(0),f=(0,L.useRef)(e);f.current=e;let p=(0,L.useRef)(t);p.current=t,(0,L.useEffect)(()=>{if(!n)return;let e=!0;return yne().then(t=>{e&&i(t)}),()=>{e=!1}},[n]);let m=(0,L.useCallback)(()=>{d.current++;let e=l.current;if(!e){o(e=>e===`starting`?`idle`:e);return}l.current=null,Pz===e&&(Pz=null),e.recognizer.onresult=null,e.recognizer.onerror=null,e.recognizer.onend=null,e.recognizer.abort(),Iz(e.stream),c(null),o(`idle`)},[]);(0,L.useEffect)(()=>(u.current=!0,()=>{u.current=!1,m()}),[m]),(0,L.useEffect)(()=>{n||m()},[n,m]);let h=(0,L.useCallback)(async e=>{let t=Az();if(!t)return;Pz?.abort(),o(`starting`);let n=d.current,r;try{r=await navigator.mediaDevices.getUserMedia({audio:!0})}catch(e){u.current&&o(`idle`),Z(Tne(e));return}if(!u.current||n!==d.current)return Iz(r);let a=new t;a.lang=e,a.continuous=!0,a.interimResults=!0,a.processLocally=!0;let s=window.SpeechRecognitionPhrase;if(s)try{a.phrases=bne.map(e=>new s(e,xne))}catch{}let{prose:h,start:g,end:_}=f.current(),v=h.slice(0,g),y=h.slice(_),b={recognizer:a,stream:r,lastWritten:h,abort:()=>m()};a.onresult=e=>{if(f.current().prose!==b.lastWritten)return m();let t=Array.from(e.results,e=>e[0]?.transcript??``),n=wne(v,Cne(t),y);b.lastWritten=n.text,p.current(n.text,n.caret)},a.onerror=e=>{let t=Fz(e.error);t&&Z(t),e.error===`language-not-supported`&&(Mz=void 0,i(e=>e&&{...e,status:`downloadable`}))},a.onend=()=>{Iz(r),l.current===b&&(l.current=null,Pz===b&&(Pz=null),c(null),o(`idle`))},l.current=b,Pz=b,c(r),o(`listening`);try{a.start(r.getAudioTracks()[0])}catch(e){m(),Z(`Dictation could not start: ${e instanceof Error?e.message:String(e)}`)}},[m]),g=(0,L.useCallback)(async()=>{if(l.current){l.current.recognizer.stop();return}let e=Az();if(!e||!r||a===`installing`||a===`starting`)return;let t=r.status;try{t=await e.available({langs:[r.lang],processLocally:!0})}catch{}if(t===`unavailable`){Z(`On-device dictation is not available in this browser`);return}if(t!==`available`){o(`installing`);let t=!1;try{t=await e.install({langs:[r.lang],processLocally:!0})}catch{t=!1}if(!t){o(`idle`),Z(`The on-device speech model could not be downloaded — try again later`);return}i({lang:r.lang,status:`available`})}await h(r.lang)},[r,a,h]);return{state:r&&n?a:`unsupported`,stream:s,toggle:g,cancel:m}}var Lz=[{x:5,y1:7,y2:17,band:[100,300]},{x:9.67,y1:4,y2:20,band:[300,900]},{x:14.33,y1:6,y2:18,band:[900,2200]},{x:19,y1:8,y2:16,band:[2200,5e3]}],Rz=.3;function Dne({stream:e,size:t=15}){let n=(0,L.useRef)([]);return(0,L.useEffect)(()=>{let t=new AudioContext,r=t.createMediaStreamSource(e),i=t.createAnalyser();i.fftSize=1024,i.smoothingTimeConstant=.75,i.minDecibels=-85,i.maxDecibels=-30,r.connect(i);let a=new Uint8Array(i.frequencyBinCount),o=t.sampleRate/i.fftSize,s=Lz.map(({band:[e,t]})=>[Math.max(1,Math.floor(e/o)),Math.max(2,Math.ceil(t/o))]),c=0,l=()=>{i.getByteFrequencyData(a),s.forEach(([e,t],r)=>{let i=0;for(let n=e;n<t;n++)i+=a[n];let o=i/(t-e)/255;n.current[r]?.style.setProperty(`transform`,`scaleY(${Rz+(1-Rz)*o})`)}),c=requestAnimationFrame(l)};return l(),()=>{cancelAnimationFrame(c),r.disconnect(),t.close()}},[e]),(0,R.jsx)(`svg`,{"data-dictation-level":!0,width:t,height:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,"aria-hidden":!0,children:Lz.map((e,t)=>(0,R.jsx)(`line`,{ref:e=>{n.current[t]=e},x1:e.x,x2:e.x,y1:e.y1,y2:e.y2,style:{transformBox:`fill-box`,transformOrigin:`center`,transform:`scaleY(${Rz})`}},e.x))})}var One=60;function kne({pinnedBottom:e,visual:t}){if(!t||Math.abs(t.scale-1)>.01)return 0;let n=e-(t.offsetTop+t.height);return n>=One?Math.round(n):0}function zz(e,t){let[n,r]=(0,L.useState)(0);return(0,L.useLayoutEffect)(()=>{if(!t||typeof window>`u`){r(0);return}let n=0,i=()=>{cancelAnimationFrame(n),n=requestAnimationFrame(()=>{let t=e.current;if(!t)return;let n=window.visualViewport;r(kne({pinnedBottom:t.getBoundingClientRect().bottom,visual:n?{offsetTop:n.offsetTop,height:n.height,scale:n.scale}:null}))})};i();let a=window.visualViewport;return a?.addEventListener(`resize`,i),a?.addEventListener(`scroll`,i),window.addEventListener(`resize`,i),window.addEventListener(`focusin`,i),window.addEventListener(`focusout`,i),()=>{cancelAnimationFrame(n),a?.removeEventListener(`resize`,i),a?.removeEventListener(`scroll`,i),window.removeEventListener(`resize`,i),window.removeEventListener(`focusin`,i),window.removeEventListener(`focusout`,i)}},[e,t]),t?n:0}async function Ane(e,t){let n=sm(),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 Bz={project:`project`,user:`global`,builtin:`built-in`,plugin:`plugin`},jne=500,Vz=(0,L.createContext)(null);function Mne(e,t){e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,t)}px`}function Hz({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,railLead:f,contextTokens:p,slashSuggest:m,onInterruptSubmit:h,phone:g,onUploadingChange:_}){let v=(0,L.useRef)(null),y=(0,L.useRef)(null),b=(0,L.useRef)(null),[x,S]=(0,L.useState)(!1),[C,w]=(0,L.useState)(!1),{prose:T,attachments:E}=(0,L.useMemo)(()=>oz(e),[e]),D=E.map(e=>e.path),O=(0,L.useRef)(e);O.current=e;let k=e=>t(sz(e,D)),A=e=>t(sz(T,e));async function j(e){if(!e)return;if(C){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})=>mu(e)?!0:(Z(`${e||`File`}: unsupported file type`),!1));if(!n.length)return;let r=n.filter(({file:e,name:t})=>e.size>du?(Z(`${t} is too large (max ${Math.floor(du/1e6)} MB)`),!1):!0);if(!r.length)return;let i=O.current;w(!0);let a=[];try{for(let{file:e,name:t}of r){let n=await Ane(e,t);n?a.push(n):Z(`Could not attach ${t}`)}}finally{w(!1)}if(a.length&&i!==``&&O.current===``){Z(`Attachment discarded — the message was sent before the upload finished`),requestAnimationFrame(()=>v.current?.focus());return}if(a.length){let e=oz(O.current);t(sz(e.prose,[...e.attachments.map(e=>e.path),...a]))}requestAnimationFrame(()=>v.current?.focus())}(0,L.useLayoutEffect)(()=>{let e=!0,t=()=>{let t=v.current;!t||!e||Mne(t,s)};t();let n=requestAnimationFrame(t);document.fonts?.ready.then(t);let r=v.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 M=(0,L.useMemo)(()=>p??[],[p]),N=(0,L.useMemo)(()=>{if(M.length===0)return null;let e=mz(T,M);return e.some(e=>e.token)?e.map((e,t)=>e.token?(0,R.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},[T,M]),P=()=>{let e=v.current,t=y.current;e&&t&&(t.scrollTop=e.scrollTop)};(0,L.useLayoutEffect)(P);let F=(0,L.useRef)(!1);(0,L.useEffect)(()=>{let e=v.current;if(!e)return;let t=()=>{F.current=e.disabled};return e.addEventListener(`focusout`,t),()=>e.removeEventListener(`focusout`,t)},[]),(0,L.useEffect)(()=>{if(l||!F.current)return;F.current=!1;let e=v.current,t=document.activeElement;e&&(!t||t.contains(e))&&e.focus({preventScroll:!0})},[l]);let[I,ee]=(0,L.useState)(null),[te,ne]=(0,L.useState)({prose:``,index:0}),re=te.prose===T?te.index:0,ie=e=>ne({prose:T,index:typeof e==`function`?e(re):e}),[ae,oe]=(0,L.useState)(null),se=!!m&&/^\/\S*$/.test(T);(0,L.useEffect)(()=>{if(!se||I!==null)return;let e=!0;return m().then(t=>{e&&ee(t)},()=>{e&&ee([])}),()=>{e=!1}},[se,I,m]);let ce=(0,L.useMemo)(()=>{if(!se||!I||ae===T)return[];let e=T.slice(1).toLowerCase(),t=I.filter(t=>t.name.toLowerCase().startsWith(e)),n=I.filter(t=>!t.name.toLowerCase().startsWith(e)&&t.name.toLowerCase().includes(e));return[...t,...n]},[se,I,ae,T]),le=ce.length>0,ue=(0,L.useMemo)(()=>{let e=new Set;for(let t of ce)t.source&&e.add(Bz[t.source]);return[...e]},[ce]),de=(0,L.useRef)(null);(0,L.useEffect)(()=>{de.current?.querySelector(`[data-suggest-index="${re}"]`)?.scrollIntoView({block:`nearest`})},[re]);function fe(e){let t=`/${e.name} `;k(t),requestAnimationFrame(()=>v.current?.setSelectionRange(t.length,t.length))}let{dictation:pe}=gr(RD),me=Ene({read:()=>{let e=v.current,t=e?.value??T,n=e!==null&&document.activeElement===e;return{prose:t,start:n?e.selectionStart:t.length,end:n?e.selectionEnd:t.length}},write:(e,t)=>{k(e),requestAnimationFrame(()=>v.current?.setSelectionRange(t,t))},enabled:pe}),he=!g&&me.state!==`unsupported`,ge=()=>{me.cancel(),n()},_e=e.trim().length>0,ve=d??null,ye=fne({action:!!ve,lead:!!f,mic:he});function be(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(le&&!e.nativeEvent.isComposing){if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),ie(t=>(t+(e.key===`ArrowDown`?1:-1)+ce.length)%ce.length);return}if((e.key===`Enter`||e.key===`Tab`)&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey){e.preventDefault(),e.stopPropagation(),fe(ce[re]??ce[0]);return}if(e.key===`Escape`){e.preventDefault(),e.stopPropagation(),oe(T);return}}if(e.key===`Backspace`&&!e.altKey&&!e.ctrlKey&&!e.metaKey&&M.length>0&&t.selectionStart===t.selectionEnd){let n=t.selectionStart,r=mz(t.value.slice(0,n),M).at(-1);if(r?.token){e.preventDefault();let i=n-r.text.length;k(t.value.slice(0,i)+t.value.slice(n)),requestAnimationFrame(()=>t.setSelectionRange(i,i));return}}if(Xte(r,e.key,e.altKey)){e.preventDefault(),e.stopPropagation();let n=t.selectionStart??t.value.length,r=t.selectionEnd??n;k(t.value.slice(0,n)+`
|
|
203
|
+
`+t.value.slice(r)),requestAnimationFrame(()=>t.setSelectionRange(n+1,n+1));return}let a=_e&&!l&&!C;if(Kte(i,a)){e.preventDefault(),e.stopPropagation(),ge();return}if(qte(i,a)){e.preventDefault(),e.stopPropagation(),me.cancel(),(h??n)();return}if(Yte(i)){let e=t.value,n=t.selectionStart??e.length,r=t.selectionEnd??n;requestAnimationFrame(()=>{t.value===e&&(k(e.slice(0,n)+`
|
|
204
|
+
`+e.slice(r)),requestAnimationFrame(()=>t.setSelectionRange(n+1,n+1)))})}if(e.key===`Escape`&&!e.nativeEvent.isComposing){if(me.state===`listening`){e.preventDefault(),e.stopPropagation(),me.cancel();return}if(e.currentTarget.closest(`[data-standalone-thread]`))return;e.preventDefault(),e.stopPropagation(),sne(t)||t.blur()}}let xe=le?(0,R.jsx)(`div`,{ref:de,"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:ce.map((e,t)=>(0,R.jsxs)(`button`,{type:`button`,"data-suggest-index":t,onMouseDown:e=>e.preventDefault(),onClick:()=>fe(e),onMouseEnter:()=>ie(t),className:`flex w-full items-baseline gap-2 px-3.5 py-1.5 text-left ${t===re?`bg-panel-2`:``}`,children:[(0,R.jsxs)(`span`,{className:`shrink-0 text-[12px] font-medium text-fg`,children:[`/`,e.name]}),e.description&&(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-muted`,children:e.description}),ue.length>0&&(0,R.jsxs)(`span`,{className:`ml-auto grid shrink-0 text-[10px]`,children:[ue.map(e=>(0,R.jsx)(`span`,{"aria-hidden":!0,className:`petite-caps invisible col-start-1 row-start-1`,children:e},e)),(0,R.jsx)(`span`,{className:`petite-caps col-start-1 row-start-1 text-right text-muted-70`,children:e.source?Bz[e.source]:``})]})]},e.name))}):null,[Se,Ce]=(0,L.useState)(!1),[we,Te]=(0,L.useState)(!1),Ee=(0,L.useRef)(null),De=zz(Ee,!!g),Oe=(0,L.useRef)(void 0),ke=(0,L.useRef)(!1);(0,L.useEffect)(()=>()=>clearTimeout(Oe.current),[]);let Ae=(0,L.useRef)(_);if(Ae.current=_,(0,L.useEffect)(()=>{Ae.current?.(C)},[C]),g){let e=_e&&!l&&!C,t=g.layout===`page`,u=!t&&(Se||we||_e||E.length>0),d=t?`px-[18px] py-[14px] text-[17px] leading-[25px]`:u?`px-3 pt-[10px] pb-1 text-[16px] leading-[22px]`:`px-[14px] py-[10px] text-[16px] leading-[20px]`,f=t?{minHeight:o,maxHeight:s}:u?{minHeight:44,maxHeight:176}:{minHeight:40,maxHeight:40},p=(0,R.jsx)(`input`,{ref:b,type:`file`,multiple:!0,accept:hu,className:`hidden`,onChange:e=>{j(e.target.files),e.target.value=``}}),m=e=>(0,R.jsx)(`button`,{type:`button`,"data-phone-attach":!0,onMouseDown:e=>e.preventDefault(),onClick:()=>b.current?.click(),disabled:l||C,title:`Attach files`,"aria-label":`Attach files`,className:`relative flex shrink-0 items-center justify-center rounded-full border border-border-strong bg-panel text-fg active:bg-hover disabled:opacity-45 ${e===42?`size-[42px]`:`size-[36px] after:absolute after:-inset-[4px] after:content-['']`}`,children:C?(0,R.jsx)(M_,{size:17,strokeWidth:2.2,className:`animate-spin`}):(0,R.jsx)(q_,{size:e===42?19:17,strokeWidth:2.2})}),h=(0,R.jsxs)(`div`,{className:t?`relative flex flex-1 flex-col`:`relative`,children:[N&&(0,R.jsx)(`div`,{ref:y,"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] ${d} text-transparent`,children:N}),(0,R.jsx)(`textarea`,{id:a,ref:v,"data-1p-ignore":!0,onScroll:N?P:void 0,"data-surface":r,"data-claims-escape":!0,value:T,autoFocus:c,disabled:l,onChange:e=>k(e.target.value),onKeyDown:be,onFocus:()=>Ce(!0),onBlur:()=>Ce(!1),onPaste:e=>{let t=[...e.clipboardData.items].filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(Boolean);t.length&&(e.preventDefault(),j(t))},placeholder:i,rows:1,spellCheck:!1,style:f,className:`relative block w-full resize-none bg-transparent ${d} text-fg outline-none placeholder:text-faint scrollbar-none disabled:opacity-60 ${t?`flex-1`:``}`})]}),_=E.length>0&&(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1.5 ${t?`px-[18px] pb-3`:`px-3 pb-1`}`,children:E.map((e,t)=>(0,R.jsx)(Uz,{attachment:e,disabled:l,onRemove:()=>A(D.filter((e,n)=>n!==t))},`${e.path}-${t}`))}),x=De>0?(0,R.jsx)(`div`,{"aria-hidden":!0,"data-keyboard-spacer":!0,style:{height:De}}):null;if(t)return(0,R.jsxs)(`div`,{ref:Ee,"data-phone-composer":`page`,className:`flex min-h-0 flex-1 flex-col ${De>0?``:`pb-[env(safe-area-inset-bottom)]`}`,children:[(0,R.jsxs)(`div`,{className:`relative flex min-h-0 flex-1 flex-col overflow-y-auto scrollbar-none`,children:[xe,h,_]}),(0,R.jsxs)(`div`,{"data-phone-tool-row":!0,className:`flex min-w-0 shrink-0 items-center gap-2 px-2.5 py-2`,children:[m(36),g.tools]}),p,x]});let S=!u&&g.override?g.override({editReply:()=>v.current?.focus()}):null,w=t=>(0,R.jsx)(`button`,{type:`button`,"data-phone-send":!0,onMouseDown:e=>e.preventDefault(),onContextMenu:e=>e.preventDefault(),onPointerDown:()=>{if(ke.current=!1,clearTimeout(Oe.current),!e||!g.onLongPressSend)return;let t=g.onLongPressSend;Oe.current=setTimeout(()=>{ke.current=!0,navigator.vibrate?.(12),t()},jne)},onPointerUp:()=>clearTimeout(Oe.current),onPointerLeave:()=>clearTimeout(Oe.current),onPointerCancel:()=>clearTimeout(Oe.current),onClick:()=>{if(ke.current){ke.current=!1;return}n()},disabled:!e,title:g.onLongPressSend?`Send · hold to interrupt and send now`:`Send`,"aria-label":`Send`,className:`relative flex shrink-0 select-none items-center justify-center rounded-full bg-fg text-bg [-webkit-touch-callout:none] disabled:opacity-35 ${t?`size-[36px] after:absolute after:-inset-[4px] after:content-['']`:`size-[42px]`}`,children:l?(0,R.jsx)(M_,{size:t?17:19,strokeWidth:2.4,className:`animate-spin`}):(0,R.jsx)(Xg,{size:t?17:19,strokeWidth:2.4})}),O=e=>_e?w(e):g.idlePrimary?.(e)??w(e);return(0,R.jsxs)(`div`,{ref:Ee,"data-phone-composer":`bar`,"data-phone-composer-open":u?``:void 0,className:`relative bg-bg`,children:[(0,R.jsxs)(`div`,{className:`px-2.5 pt-2 ${De>0?`pb-2.5`:`pb-[max(10px,env(safe-area-inset-bottom))]`}`,children:[S&&(0,R.jsx)(`div`,{"data-phone-bar-override":!0,className:`flex min-w-0 items-end gap-2`,children:S}),(0,R.jsxs)(`div`,{className:S?`pointer-events-none absolute h-0 w-0 overflow-hidden opacity-0`:`flex min-w-0 items-end gap-2`,children:[!u&&m(42),(0,R.jsxs)(`div`,{className:`relative min-w-0 flex-1 border border-border-strong bg-panel ${u?`rounded-[20px] pb-2`:`rounded-[21px]`}`,children:[xe,h,u&&_,u&&(0,R.jsxs)(`div`,{"data-phone-composer-toolbar":!0,className:`flex min-w-0 items-center gap-2 px-2 pt-1`,children:[m(36),(0,R.jsx)(Vz.Provider,{value:Te,children:g.tools}),(0,R.jsx)(`span`,{className:`flex-1`}),O(!0)]})]}),!u&&O(!1)]}),p]}),x]})}return(0,R.jsxs)(`div`,{"data-composer-box":!0,className:`group relative rounded-xl border bg-bg transition-colors focus-within:border-accent ${x?`border-dashed border-accent`:`border-border`}`,onDragOver:e=>{[...e.dataTransfer.items].some(e=>e.kind===`file`)&&(e.preventDefault(),S(!0))},onDragLeave:()=>S(!1),onDrop:e=>{e.preventDefault(),S(!1),j(e.dataTransfer.files)},children:[x&&(0,R.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`}),xe,(0,R.jsxs)(`div`,{className:`relative`,children:[N&&(0,R.jsx)(`div`,{ref:y,"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`} text-[13px] leading-relaxed text-transparent`,style:u?void 0:{paddingRight:ye.reserve},children:N}),(0,R.jsx)(`textarea`,{id:a,ref:v,"data-1p-ignore":!0,onScroll:N?P:void 0,"data-surface":r,"data-claims-escape":!0,value:T,autoFocus:c,disabled:l,onChange:e=>{me.cancel(),k(e.target.value)},onKeyDown:be,onPaste:e=>{let t=[...e.clipboardData.items].filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(Boolean);t.length&&(e.preventDefault(),j(t))},placeholder:i,rows:1,spellCheck:!1,style:{minHeight:o,maxHeight:s,paddingRight:u?void 0:ye.reserve},className:`relative block w-full resize-none bg-transparent px-3.5 ${u?`py-2.5 pb-3`:`py-2.5`} text-[13px] leading-relaxed text-fg outline-none placeholder:text-muted scrollbar-none disabled:opacity-60`})]}),E.length>0&&(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1.5 px-3 pb-2`,style:{paddingRight:ye.reserve},children:E.map((e,t)=>(0,R.jsx)(Uz,{attachment:e,disabled:l,onRemove:()=>A(D.filter((e,n)=>n!==t))},`${e.path}-${t}`))}),u&&(0,R.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1 pl-1.5 pb-1.5`,style:{paddingRight:ye.reserve},children:u}),ve&&(0,R.jsx)(`div`,{className:`absolute bottom-2 flex items-center`,style:{right:ye.right.action},children:ve}),f&&(0,R.jsx)(`div`,{className:`absolute bottom-2 flex items-center`,style:{right:ye.right.lead},children:f}),(0,R.jsx)(`input`,{ref:b,type:`file`,multiple:!0,accept:hu,className:`hidden`,onChange:e=>{j(e.target.files),e.target.value=``}}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>b.current?.click(),disabled:l||C,title:`Attach files`,"aria-label":`Attach files`,style:{right:ye.right.paperclip},className:`icon-hover-outline absolute bottom-2 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:C?(0,R.jsx)(M_,{size:15,strokeWidth:2,className:`animate-spin`}):(0,R.jsx)(V_,{size:15,strokeWidth:2})}),he&&(0,R.jsx)(`button`,{type:`button`,"data-dictation":me.state,onMouseDown:e=>e.preventDefault(),onClick:()=>{let e=v.current;me.state===`idle`&&e&&document.activeElement!==e&&(e.focus({preventScroll:!0}),e.setSelectionRange(e.value.length,e.value.length)),me.toggle()},disabled:l||me.state===`installing`||me.state===`starting`,"aria-pressed":me.state===`listening`,title:me.state===`listening`?`Stop dictation`:me.state===`installing`?`Downloading the on-device speech model…`:me.state===`starting`?`Starting the microphone…`:`Dictate — transcribed on this device`,"aria-label":me.state===`listening`?`Stop dictation`:`Dictate`,style:{right:ye.right.mic},className:`icon-hover-outline absolute bottom-2 flex h-7 w-7 items-center justify-center rounded-lg transition-[color,background-color] enabled:hover:bg-panel-2/70 disabled:opacity-50 ${me.state===`listening`?`text-fg`:`text-muted enabled:hover:text-fg`}`,children:me.state===`installing`||me.state===`starting`?(0,R.jsx)(M_,{size:15,strokeWidth:2,className:`animate-spin`}):me.state===`listening`&&me.stream?(0,R.jsx)(Dne,{stream:me.stream}):(0,R.jsx)(L_,{size:15,strokeWidth:2})}),(0,R.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:ge,disabled:!_e||l||C,title:`Send (Enter · ⌘⏎ sends now)`,"aria-label":`Send`,style:{right:ye.right.send},className:`icon-hover-outline absolute bottom-2 flex h-7 w-7 items-center justify-center rounded-lg transition-[color,background-color,opacity,scale] ${_e&&!l&&!C?`bg-fg text-bg hover:opacity-90 active:scale-95`:`bg-panel-2 text-muted`}`,children:l?(0,R.jsx)(M_,{size:14,strokeWidth:2.5,className:`animate-spin`}):(0,R.jsx)(Xg,{size:14,strokeWidth:2.5})})]})}function Uz({attachment:e,disabled:t,onRemove:n}){let[r,i]=(0,L.useState)(!1),a=xh(e.path),o=(a.includes(`.`)?a.split(`.`).pop():``).toUpperCase();return(0,R.jsxs)(`div`,{className:`group/att relative h-11 w-11`,title:a,children:[e.kind===`image`&&!r?(0,R.jsx)(`img`,{src:BT(e.path),alt:a,onError:()=>i(!0),className:`h-11 w-11 rounded-md border border-border object-cover`}):(0,R.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,R.jsx)(v_,{size:15,strokeWidth:2,className:`shrink-0 text-muted`}),o&&(0,R.jsx)(`span`,{className:`-mx-1 max-w-[calc(100%+0.5rem)] truncate text-[8px] font-medium leading-none text-muted-80`,children:o})]}),(0,R.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,R.jsx)(cv,{size:10,strokeWidth:2.5})})]})}function Wz(){return ct({queryKey:[`githubStatus`],queryFn:()=>Y.githubStatus(),staleTime:3e4,refetchOnWindowFocus:!0,refetchInterval:e=>{let t=e.state.data;return t?.inRepo&&t.authed?!1:6e4}})}function Gz(){let e=Wz();return!!(e.data?.inRepo&&e.data.authed)}function Kz({className:e=``,variant:t=`icon`}){return Gz()?t===`phoneChip`?(0,R.jsxs)(`button`,{type:`button`,"data-phone-github-trigger":!0,onClick:Fh,onMouseDown:e=>e.preventDefault(),title:`Investigate this issue and make recommendations`,className:`relative inline-flex h-[32px] shrink-0 items-center gap-[6px] rounded-full border border-border-strong bg-bg px-[11px] text-[13.5px] font-medium text-fg after:absolute after:inset-x-0 after:-inset-y-[6px] after:content-[''] active:bg-hover ${e}`,children:[(0,R.jsx)(E_,{"aria-hidden":!0,size:14,strokeWidth:1.9,className:`shrink-0 text-muted`}),`Issue or PR`]}):(0,R.jsx)(`button`,{type:`button`,onClick:Fh,onMouseDown:e=>e.preventDefault(),title:`Investigate this issue and make recommendations`,"aria-label":`Investigate this issue and make recommendations`,className:`icon-hover-outline flex h-7 w-7 items-center justify-center rounded-lg text-muted outline-none transition-[color,background-color] 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,R.jsx)(E_,{size:15,strokeWidth:2})}):null}var qz=`prompt-control-type petite-caps`,Jz=qz,Nne=qz,Yz=`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 ${Jz} 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 Pne(e){return`minmax(6rem, 7rem) repeat(${Math.max(0,e)}, auto)`}function Xz(e){return e===`xhigh`?`X-high`:e.charAt(0).toUpperCase()+e.slice(1)}var Zz=[`ultra`,`ultracode`],Qz=[`low`,`medium`,`high`,`xhigh`,`max`,...Zz];function Fne(e){return[...new Set(e.flatMap(e=>e.options.flatMap(e=>e.efforts)))].sort((e,t)=>{let n=Qz.indexOf(e),r=Qz.indexOf(t);return n===-1&&r===-1?e.localeCompare(t):n===-1?1:r===-1?-1:n-r})}function $z(e){let t=[];for(let n of Fne(e)){let e=Zz.includes(n)?t.find(e=>Zz.includes(e[0])):void 0;e?e.push(n):t.push([n])}return t}function eB(e){return e.efforts.length?e.efforts:[``]}function tB(e){return e.flatMap(e=>e.options.flatMap(t=>eB(t).map(n=>({provider:e.id,model:t.model,effort:n}))))}function nB(e){return JSON.stringify([e.provider,e.model,e.effort])}function rB(e,t){return tB(e).find(e=>nB(e)===t)}function iB(e,t){return!t?.model||t.effort===void 0?!1:e.some(e=>(!t.provider||e.id===t.provider)&&e.options.some(e=>e.model===t.model&&eB(e).includes(t.effort)))}var aB=/ (\d+(?:\.\d+)*)$/;function oB(e,t,n=`Profile unknown`,r){if(!t?.model&&!t?.effort)return{name:n};let i=e.flatMap(e=>e.options).find(e=>e.model===t.model),a=r??i?.label??t.model??`Model unknown`,o=r?aB.exec(r)?.[1]:i?.edition,s=o!==void 0&&a.endsWith(` ${o}`);return{name:s?a.slice(0,-(o.length+1)):a,...s?{edition:o}:{},...t.effort?{effort:t.effort}:{}}}function sB(e,t,n=`Profile unknown`,r){let{name:i,edition:a,effort:o}=oB(e,t,n,r),s=a?`${i} ${a}`:i;return o?`${s} › ${o}`:s}function cB(e,t,n){let r=$z(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=eB(s.option),l=c.indexOf(t.effort);if(l===-1)return null;if(n===`Home`||n===`End`||n===`ArrowLeft`||n===`ArrowRight`){let e=c[n===`Home`?0:n===`End`?c.length-1:l+(n===`ArrowLeft`?-1:1)];return e===void 0?null:{provider:s.provider,model:s.option.model,effort:e}}let u=a[o+(n===`ArrowUp`?-1:1)];if(!u)return null;let d=i(t.effort),f=eB(u.option).reduce((e,t)=>e===void 0||Math.abs(i(t)-d)<Math.abs(i(e)-d)?t:e,void 0);return f===void 0?null:{provider:u.provider,model:u.option.model,effort:f}}var lB,uB=!1;function dB(){uB||typeof window>`u`||(uB=!0,window.addEventListener(`keydown`,e=>{e.key!==`Escape`||!lB||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),pB())},{capture:!0}))}function fB(e){dB();let t={dismiss:e};return lB=t,()=>{lB===t&&(lB=void 0)}}function pB(){let e=lB;return e?(lB=void 0,e.dismiss(),!0):!1}function mB(e){pB()&&e.preventDefault(),e.stopPropagation()}function hB(e,t){let n=(0,L.useRef)(t);n.current=t,(0,L.useLayoutEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),pB()||n.current())};return window.addEventListener(`keydown`,t,{capture:!0}),()=>window.removeEventListener(`keydown`,t,{capture:!0})},[e])}var gB=500,_B=1600,vB=2e3,yB=6,bB=[`settingsSet`];function xB(){let[e,t]=(0,L.useState)(`idle`),n=(0,L.useRef)(null),r=(0,L.useRef)(void 0),i=(0,L.useRef)(Promise.resolve()),a=(0,L.useRef)(0),o=(0,L.useRef)(void 0),s=(0,L.useRef)(0),c=(0,L.useRef)(()=>{}),l=pt({mutationKey:[...bB],mutationFn:e=>Y.settingsSet(e)}),u=(0,L.useRef)(l);u.current=l;let d=qe(),f=(0,L.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(()=>u.current.mutateAsync(e)).then(e=>{d.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`),_B))}).catch(i=>{--a.current,t(`error`),!(n.current||!Fm(i)||s.current>=yB)&&(s.current+=1,n.current=e,r.current=window.setTimeout(c.current,vB))}))},[]);c.current=f;let p=(0,L.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 f();r.current=window.setTimeout(f,gB)},[f]);return(0,L.useEffect)(()=>()=>{f(),o.current!==void 0&&window.clearTimeout(o.current)},[f]),{state:e,queue:p,flush:f}}function SB(){let e=ct({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()}),[t,n]=(0,L.useState)(()=>e.data??null),{state:r,queue:i,flush:a}=xB();return(0,L.useEffect)(()=>{e.data&&!t&&n(e.data)},[e.data,t]),{draft:t,update:(0,L.useCallback)((e,t)=>{n(e),i(e,t?.debounce)},[i]),saveState:r,flush:a}}function CB({state:e}){return e===`idle`?null:e===`error`?(0,R.jsx)(`span`,{className:`text-[11px] font-normal text-accent`,children:`Couldn't save`}):(0,R.jsx)(`span`,{className:`text-[11px] font-normal ${e===`saved`?`text-muted-70`:`text-muted`}`,children:e===`saving`?`Saving…`:`Saved`})}var wB=`default`;function TB(e){return e>=1e6?`${EB(e/1e6)}M`:e>=1e3?`${EB(e/1e3)}k`:String(e)}function EB(e){return Number.isInteger(e)?String(e):e.toFixed(2).replace(/0+$/,``).replace(/\.$/,``)}var DB=[{value:872e3,models:[]}];function OB(e,t){let n=e??[],r=n.find(e=>e.contextWindow!==void 0)?.contextWindow??272e3,i=`${TB(r)} (default)`,a=new Map;for(let e of n)e.maxContextWindow===void 0||e.contextWindow===void 0||e.maxContextWindow<=e.contextWindow||a.set(e.maxContextWindow,[...a.get(e.maxContextWindow)??[],e.displayName]);let o=a.size?[...a.entries()].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({value:e,models:t})):DB,s=[{value:wB,label:i}];for(let e of o){let t=o.length===1||e.models.length===0?`maximum`:`${e.models.join(`, `)} maximum`;s.push({value:String(e.value),label:`${TB(e.value)} (${t})`})}for(let e of[472e3,672e3])e>r&&o.some(t=>t.value>e)&&!s.some(t=>t.value===String(e))&&s.push({value:String(e),label:TB(e)});return t!==void 0&&!s.some(e=>e.value===String(t))&&s.push({value:String(t),label:TB(t)}),[s[0],...s.slice(1).sort((e,t)=>Number(e.value)-Number(t.value))]}var kB=[{value:`200000`,label:`200k`},{value:`350000`,label:`350k`},{value:`500000`,label:`500k (default)`},{value:`750000`,label:`750k`},{value:`1000000`,label:`1M (maximum)`}],AB={claude:`Compaction window for new Claude threads in this project. Applies on dispatch or after the worker exits, not to a running worker.`,codex:`Context window for new Codex threads in this project. Each model caps the value at its own maximum. Applies on dispatch or a cold resume, not to a running worker.`},jB=kf.options,MB={auto:`Auto`,default:`Default`,acceptEdits:`Accept edits`,plan:`Plan`,bypassPermissions:`Bypass`},NB={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)`};jB.filter(e=>e!==`plan`).map(e=>({value:e,label:MB[e],title:NB[e]}));var PB=[`auto`,`bypassPermissions`].map(e=>({value:e,label:MB[e],title:NB[e]})),FB=[{value:`fable`,label:`Fable`},{value:`opus`,label:`Opus`},{value:`sonnet`,label:`Sonnet`},{value:`haiku`,label:`Haiku`}];function IB(e=[]){return FB.map(t=>{let n=e.find(e=>e.alias===t.value);return n?{...t,label:n.label,title:`${n.label} — ${n.resolvedModel??t.value}`}:t})}new Set(bu.map(e=>e.slug));function LB(e){return e===`plan`?`auto`:e}var RB=[`low`,`medium`,`high`,`xhigh`,`max`],zB=`ultracode`,BB=new Set([`fable`,`opus`,`sonnet`]);function VB(e){return e&&BB.has(e)?[...RB,zB]:[...RB]}var HB={low:`Low`,medium:`Medium`,high:`High`,xhigh:`X-high`,max:`Max`,ultra:`Ultra`,ultracode:`Ultracode`};function UB(e){return HB[e]??e.charAt(0).toUpperCase()+e.slice(1)}function WB(e,t){let n=VB(e).map(e=>({value:e,label:UB(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}function GB(e,t){let n=(e?.efforts??[]).map(e=>({value:e,label:UB(e)}));return t.withDefault?[{value:``,label:`Default`},...n]:n}var KB={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.`,appearance:`Applies to this browser across all projects. System follows the device appearance.`,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.`,dictation:`Shows a microphone in the prompt box that transcribes speech on this device, in the browsers that can (Chrome and Edge on a desktop). Turn it off if you dictate with another tool. 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.`,githubPrompt:`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.`};function qB({label:e,help:t}){return(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[11px] uppercase tracking-wide text-muted`,children:[e,(0,R.jsx)(FP,{label:t,side:`right`,clickable:!0,children:(0,R.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,R.jsx)(u_,{size:12})})})]})}function JB({label:e,help:t,children:n}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,R.jsx)(qB,{label:e,help:t}),n]})}var YB=Object.defineProperty,XB=(e,t)=>YB(e,`name`,{value:t,configurable:!0}),ZB=`Popover`,[QB,Ine]=Jk(ZB,[XM]),$B=XM(),[eV,tV]=QB(ZB),nV=XB(e=>{let{__scopePopover:t,children:n,open:r,defaultOpen:i,onOpenChange:a,modal:o=!1}=e,s=$B(t),c=L.useRef(null),[l,u]=L.useState(!1),[d,f]=FN({prop:r,defaultProp:i??!1,onChange:a,caller:ZB});return(0,R.jsx)(fN,{...s,children:(0,R.jsx)(eV,{scope:t,contentId:LA(),triggerRef:c,open:d,onOpenChange:f,onOpenToggle:L.useCallback(()=>f(e=>!e),[f]),hasCustomAnchor:l,onCustomAnchorAdd:L.useCallback(()=>u(!0),[]),onCustomAnchorRemove:L.useCallback(()=>u(!1),[]),modal:o,children:n})})},`Popover`),rV=`PopoverAnchor`,iV=L.forwardRef(XB(function(e,t){let{__scopePopover:n,...r}=e,i=tV(rV,n),a=$B(n),{onCustomAnchorAdd:o,onCustomAnchorRemove:s}=i;return L.useEffect(()=>(o(),()=>s()),[o,s]),(0,R.jsx)(pN,{...a,...r,ref:t})},`PopoverAnchor`)),aV=`PopoverTrigger`,oV=L.forwardRef(XB(function(e,t){let{__scopePopover:n,...r}=e,i=tV(aV,n),a=$B(n),o=Wk(t,i.triggerRef),s=(0,R.jsx)(pA.button,{type:`button`,"aria-haspopup":`dialog`,"aria-expanded":i.open,"aria-controls":i.open?i.contentId:void 0,"data-state":_V(i.open),...r,ref:o,onClick:Fk(e.onClick,i.onOpenToggle)});return i.hasCustomAnchor?s:(0,R.jsx)(pN,{asChild:!0,...a,children:s})},`PopoverTrigger`)),sV=`PopoverPortal`,[cV,lV]=QB(sV,{forceMount:void 0}),uV=XB(e=>{let{__scopePopover:t,forceMount:n,children:r,container:i}=e,a=tV(sV,t);return(0,R.jsx)(cV,{scope:t,forceMount:n,children:(0,R.jsx)(xN,{present:n||a.open,children:(0,R.jsx)(_N,{asChild:!0,container:i,children:r})})})},`PopoverPortal`),dV=`PopoverContent`,fV=L.forwardRef(XB(function(e,t){let n=lV(dV,e.__scopePopover),{forceMount:r=n.forceMount,...i}=e,a=tV(dV,e.__scopePopover);return(0,R.jsx)(xN,{present:r||a.open,children:a.modal?(0,R.jsx)(mV,{...i,ref:t}):(0,R.jsx)(hV,{...i,ref:t})})},`PopoverContent`)),pV=Qk(`PopoverContent.RemoveScroll`),mV=L.forwardRef(XB(function(e,t){let n=tV(dV,e.__scopePopover),r=L.useRef(null),i=Wk(t,r),a=L.useRef(!1);return L.useEffect(()=>{let e=r.current;if(e)return dI(e)},[]),(0,R.jsx)(wn,{as:pV,allowPinchZoom:!0,children:(0,R.jsx)(gV,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Fk(e.onCloseAutoFocus,e=>{e.preventDefault(),a.current||n.triggerRef.current?.focus()}),onPointerDownOutside:Fk(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:Fk(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1})})})},`PopoverContentModal`)),hV=L.forwardRef(XB(function(e,t){let n=tV(dV,e.__scopePopover),r=L.useRef(!1),i=L.useRef(!1);return(0,R.jsx)(gV,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:t=>{e.onCloseAutoFocus?.(t),t.defaultPrevented||(r.current||n.triggerRef.current?.focus(),t.preventDefault()),r.current=!1,i.current=!1},onInteractOutside:t=>{e.onInteractOutside?.(t),t.defaultPrevented||(r.current=!0,t.detail.originalEvent.type===`pointerdown`&&(i.current=!0));let a=t.target;n.triggerRef.current?.contains(a)&&t.preventDefault(),t.detail.originalEvent.type===`focusin`&&i.current&&t.preventDefault()}})},`PopoverContentNonModal`)),gV=L.forwardRef(XB(function(e,t){let{__scopePopover:n,trapFocus:r,onOpenAutoFocus:i,onCloseAutoFocus:a,disableOutsidePointerEvents:o,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onInteractOutside:u,...d}=e,f=tV(dV,n),p=$B(n);return sF(),(0,R.jsx)(mF,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:i,onUnmountAutoFocus:a,children:(0,R.jsx)(TA,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:s,onPointerDownOutside:c,onFocusOutside:l,onDismiss:()=>f.onOpenChange(!1),deferPointerDownOutside:!0,children:(0,R.jsx)(mN,{"data-state":_V(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)`}})})})},`PopoverContentImpl`));function _V(e){return e?`open`:`closed`}XB(_V,`getState`);var vV=nV,yV=iV,bV=oV,xV=uV,SV=fV;function CV({modal:e=!1,...t}){return(0,R.jsx)(vV,{modal:e,...t})}var wV=bV,TV=yV;function EV({children:e,side:t=`top`,align:n=`center`,sideOffset:r=6,className:i=``,...a}){return(0,R.jsx)(xV,{children:(0,R.jsx)(SV,{side:t,align:n,sideOffset:r,avoidCollisions:!0,collisionPadding:12,onEscapeKeyDown:e=>e.stopPropagation(),className:`${OP} ${NP} rounded-lg outline-none ${i}`,...a,children:e})})}function DV(e){return e===`right`?`pl-3 pr-7`:`pl-7 pr-3`}function OV(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 kV=`__frizz_empty_select_value__`,AV=e=>e===``?kV:e,jV=e=>e===kV?``:e,MV={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`},NV={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 PV({o:e,indicatorPosition:t,typography:n}){return(0,R.jsxs)(eR,{value:AV(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 ${DV(t)} ${n??``}`,children:[(0,R.jsx)(tR,{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,R.jsx)(e_,{size:13})}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left`,children:e.label})]})}function FV({value:e,onValueChange:t,options:n,groups:r,placeholder:i,ariaLabel:a,title:o,disabled:s=!1,variant:c=`ghost`,indicatorPosition:l=`left`,side:u=`bottom`,menuZClass:d=kP,className:f=``}){let p=OV(e,n,r,i),m=s?NV[c]:MV[c],h=c===`readout`?qz:``,[g,_]=(0,L.useState)(!1),v=(0,L.useRef)(g),y=(0,L.useRef)(s),b=(0,L.useRef)(void 0);return v.current=g,y.current=s,(0,L.useLayoutEffect)(()=>{let e=e=>{e.key!==`Escape`||!v.current||y.current||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),v.current=!1,b.current?.(),b.current=void 0,_(!1))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]),(0,L.useLayoutEffect)(()=>{!s||!g||(v.current=!1,b.current?.(),b.current=void 0,_(!1))},[s,g]),(0,L.useLayoutEffect)(()=>()=>b.current?.(),[]),(0,R.jsxs)(KL,{modal:!1,open:g,onOpenChange:e=>{b.current?.(),b.current=void 0,v.current=e,_(e),e&&(b.current=fB(()=>{v.current=!1,b.current=void 0,_(!1)}))},children:[(0,R.jsx)(qL,{asChild:!0,disabled:s,children:(0,R.jsxs)(`button`,{type:`button`,"aria-label":a,title:o,className:`group inline-flex min-w-0 max-w-full items-center gap-1.5 rounded-md border px-2 py-1 text-left text-[12px] text-fg outline-none data-[placeholder]:text-muted ${s?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors`} ${m} ${c===`readout`?`select-trigger-readout`:``} ${h} ${f}`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-left ${p.placeholder?`text-muted`:``}`,children:p.text}),(0,R.jsx)(t_,{className:`select-caret shrink-0 text-muted ${s?``:`transition-transform group-data-[state=open]:rotate-180`}`,size:13})]})}),(0,R.jsx)(JL,{children:(0,R.jsx)(YL,{align:`start`,side:u,sideOffset:5,onEscapeKeyDown:e=>e.stopPropagation(),className:`${d} ${OP} min-w-[var(--radix-dropdown-menu-trigger-width)] max-w-[calc(100vw-1rem)] overflow-hidden rounded-lg p-1 ${h}`,children:(0,R.jsx)($L,{value:AV(e),onValueChange:e=>t(jV(e)),className:`max-h-[300px] min-w-0 overflow-y-auto`,children:r?r.map((e,t)=>(0,R.jsxs)(XL,{children:[e.label&&(0,R.jsx)(ZL,{className:`${DV(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,R.jsx)(PV,{o:e,indicatorPosition:l,typography:h},e.value))]},e.label||`g${t}`)):(n??[]).map(e=>(0,R.jsx)(PV,{o:e,indicatorPosition:l,typography:h},e.value))})})})]})}var IV=[{value:`auto`,label:`Automatic (default)`},{value:`5m`,label:`5 minutes`},{value:`1h`,label:`1 hour`}],LV={claude:`Claude Code`,codex:`Codex`};function RV({backend:e,open:t,onOpenChange:n}){let r=LV[e];return hB(t,()=>n(!1)),(0,R.jsxs)(CV,{modal:!0,open:t,onOpenChange:n,children:[(0,R.jsx)(QL,{asChild:!0,onSelect:e=>e.preventDefault(),children:(0,R.jsx)(wV,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`${r} settings`,title:`${r} settings for new threads in this project`,className:`agent-settings-trigger -my-1 -mr-3 inline-flex size-5 shrink-0 translate-y-[calc(7px_-_0.5cap)] items-center justify-center rounded-[5px] text-muted-70 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:bg-panel-2 focus-visible:text-fg data-[state=open]:bg-panel-2 data-[state=open]:text-fg`,children:(0,R.jsx)(Q_,{"aria-hidden":`true`,size:14})})})}),(0,R.jsx)(EV,{side:`bottom`,align:`end`,sideOffset:6,className:`w-[272px] max-w-[calc(100vw-1rem)] p-4`,style:{fontVariantCaps:`normal`,letterSpacing:`normal`},"data-agent-settings-menu":e,onKeyDown:e=>e.stopPropagation(),children:(0,R.jsx)(zV,{backend:e})})]})}function zV({backend:e}){let{draft:t,update:n,saveState:r}=SB(),i=ct({queryKey:[`codexModels`],queryFn:()=>Y.codexModels(),enabled:e===`codex`});return(0,R.jsxs)(`div`,{className:`flex flex-col gap-4 text-[12px]`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsxs)(`span`,{className:`text-[12px] font-medium text-fg`,children:[LV[e],` settings`]}),(0,R.jsx)(CB,{state:r})]}),t?e===`claude`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(JB,{label:`Permissions`,help:KB.permissionMode,children:(0,R.jsx)(FV,{variant:`bordered`,value:t.permissionMode===`bypassPermissions`?`bypassPermissions`:`auto`,onValueChange:e=>n({...t,permissionMode:e}),options:PB,indicatorPosition:`right`,menuZClass:MP,ariaLabel:`Claude permission mode`})}),(0,R.jsx)(JB,{label:`Prompt cache tier`,help:KB.promptCacheTtl,children:(0,R.jsx)(FV,{variant:`bordered`,value:t.promptCacheTtl??`auto`,onValueChange:e=>n({...t,promptCacheTtl:e}),options:IV,indicatorPosition:`right`,menuZClass:MP,ariaLabel:`Claude prompt cache tier`})}),(0,R.jsx)(BV,{draft:t,update:n})]}):(0,R.jsx)(JB,{label:`Context window`,help:AB.codex,children:(0,R.jsx)(FV,{variant:`bordered`,value:t.codexContextWindow===void 0?wB:String(t.codexContextWindow),onValueChange:e=>n({...t,codexContextWindow:e==="default"?void 0:Number(e)}),options:OB(i.data,t.codexContextWindow),indicatorPosition:`right`,menuZClass:MP,ariaLabel:`Codex context window`})}):(0,R.jsx)(`div`,{className:`text-[12px] text-muted`,children:`Loading…`})]})}function BV({draft:e,update:t}){let n=e.autoCompactWindow??5e5,r=String(n),i=kB.some(e=>e.value===r)?kB:[...kB,{value:r,label:TB(n)}];return(0,R.jsx)(JB,{label:`Compaction window`,help:AB.claude,children:(0,R.jsx)(FV,{variant:`bordered`,value:r,onValueChange:n=>t({...e,autoCompactWindow:Number(n)}),options:i,indicatorPosition:`right`,menuZClass:MP,ariaLabel:`Claude Code compaction window`})})}function VV(e,t){return e.efforts.length===0?``:t&&e.efforts.includes(t)?t:e.defaultEffort&&e.efforts.includes(e.defaultEffort)?e.defaultEffort:e.efforts.includes(`high`)?`high`:e.efforts[0]??``}function HV({option:e}){let t=e.edition?` ${e.edition}`:``;return!t||!e.label.endsWith(t)?(0,R.jsx)(R.Fragment,{children:e.label}):(0,R.jsxs)(R.Fragment,{children:[e.label.slice(0,-t.length),` `,(0,R.jsx)(`span`,{className:`text-edition`,children:e.edition})]})}function UV({groups:e,value:t,onValueChange:n,onClose:r,upgrade:i}){let[a,o]=(0,L.useState)(()=>({...t})),[s,c]=(0,L.useState)(!1);(0,L.useEffect)(()=>{let e=requestAnimationFrame(()=>c(!0));return()=>cancelAnimationFrame(e)},[]);let l=(0,L.useRef)(a);l.current=a;let u=(0,L.useRef)(!1);function d(i=l.current){if(u.current)return;u.current=!0;let a=iB(e,i),o=!t?.model||!a||nB({provider:i.provider??``,model:i.model??``,effort:i.effort??``})!==nB({provider:t.provider??``,model:t.model,effort:t.effort??``});a&&o&&i.provider&&i.model&&n({provider:i.provider,model:i.model,effort:i.effort??``}),r()}let f=e.find(e=>e.id===a.provider)?.options.find(e=>e.model===a.model);return(0,R.jsx)(hR,{open:!0,onOpenChange:e=>{e||d()},children:(0,R.jsxs)(yR,{children:[(0,R.jsx)(xR,{"data-mobile-model-sheet-scrim":!0,className:`fixed inset-0 z-[250] bg-scrim-50 transition-opacity duration-200 ${s?`opacity-100`:`opacity-0`}`}),(0,R.jsxs)(TR,{"data-mobile-model-sheet":!0,"aria-describedby":void 0,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),className:`fixed inset-x-0 bottom-0 z-[250] flex max-h-[86%] flex-col overflow-hidden rounded-t-[16px] border-t border-border-strong bg-panel pb-[calc(14px+env(safe-area-inset-bottom))] shadow-[0_-20px_60px_-10px_var(--sheet-shadow)] outline-none transition-transform duration-200 ease-out motion-reduce:transition-none ${s?`translate-y-0`:`translate-y-full`}`,children:[(0,R.jsx)(`div`,{className:`mx-auto mt-[10px] h-[4px] w-[36px] shrink-0 rounded-full bg-muted/35`}),(0,R.jsxs)(`div`,{className:`min-h-0 overflow-y-auto pt-2 scrollbar-none`,children:[(0,R.jsx)(AR,{className:`px-[18px] pb-2.5 pt-1 text-[16px] font-semibold text-fg`,children:`Model`}),e.map((e,t)=>(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":e.label,children:e.options.map((n,r)=>{let i=a.provider===e.id&&a.model===n.model;return(0,R.jsxs)(`button`,{type:`button`,role:`radio`,"aria-checked":i,"data-mobile-model-row":n.model,onClick:()=>o({provider:e.id,model:n.model,effort:VV(n,a.effort)}),className:`flex min-h-[48px] w-full items-center gap-3 px-[18px] text-left active:bg-hover ${t>0&&r===0?`border-t border-border`:``}`,children:[(0,R.jsx)(`span`,{className:`w-[78px] shrink-0 truncate text-[12.5px] text-muted`,children:r===0?e.label:``}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[15.5px] text-fg`,children:(0,R.jsx)(HV,{option:n})}),i&&(0,R.jsx)(e_,{"aria-hidden":!0,size:18,strokeWidth:2.6,className:`shrink-0 text-fg`})]},n.model)})},e.id)),e.every(e=>e.options.length===0)&&(0,R.jsx)(`div`,{className:`px-[18px] py-3 text-[14px] text-muted`,children:`No models available`}),(0,R.jsx)(`div`,{className:`px-[18px] pb-1.5 pt-4 text-[16px] font-semibold text-fg`,children:`Effort`}),f&&f.efforts.length>0?(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Effort`,className:`flex gap-1.5 overflow-x-auto px-[18px] pb-1.5 pt-1.5 scrollbar-none`,children:f.efforts.map(e=>{let t=a.effort===e;return(0,R.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":t,"data-mobile-effort":e,onClick:()=>d({...a,effort:e}),className:`relative inline-flex h-[36px] shrink-0 items-center rounded-full border px-[13px] text-[14px] after:absolute after:inset-x-0 after:-inset-y-[4px] after:content-[''] ${t?`border-fg bg-fg font-semibold text-bg`:`border-border-strong text-muted active:bg-hover`}`,children:Xz(e)},e)})}):(0,R.jsx)(`div`,{className:`px-[18px] pb-1 pt-1 text-[14px] text-muted`,children:f?`Set by the agent`:`Choose a model first`}),i&&(0,R.jsxs)(`div`,{"data-mobile-model-upgrade":!0,className:`mx-[18px] mt-4 flex items-center gap-3 border-t border-border pt-3`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 text-[13px] leading-[18px] text-muted`,children:i.staged?`This thread will upgrade to ${i.latest} on its next turn`:`This thread will auto-upgrade to ${i.latest} after its next compaction`}),!i.staged&&(0,R.jsx)(`button`,{type:`button`,disabled:i.blockedReason!==null||i.pending,title:i.blockedReason??void 0,onClick:()=>{i.onUpgrade(),d()},className:`flex h-[36px] shrink-0 items-center rounded-full border border-border-strong px-[13px] text-[14px] text-fg active:bg-hover disabled:opacity-45`,children:`Upgrade now`})]})]})]})]})})}function WV({groups:e,value:t,pending:n,onValueChange:r,placeholder:i,ariaLabel:a,title:o,disabled:s=!1,runningModelLabel:c,upgrade:l}){let[u,d]=(0,L.useState)(!1),f=(0,L.useContext)(Vz),p=e=>{d(e),f?.(e)};(0,L.useEffect)(()=>{s&&u&&p(!1)},[s]),(0,L.useEffect)(()=>()=>f?.(!1),[f]);let{name:m,edition:h,effort:g}=oB(e,t,i,c),_=!!(n?.model||n?.effort);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,"aria-label":a,"aria-haspopup":`dialog`,"aria-expanded":u,title:o,disabled:s,"data-phone-profile-chip":!0,"data-profile-known":iB(e,t)?`true`:`false`,onMouseDown:e=>e.preventDefault(),onClick:()=>{document.activeElement instanceof HTMLElement&&document.activeElement.blur(),p(!0)},className:`relative inline-flex h-[32px] min-w-0 max-w-full shrink items-center gap-[5px] rounded-full border border-border-strong bg-bg px-[11px] text-[13.5px] font-medium text-fg after:absolute after:inset-x-0 after:-inset-y-[6px] after:content-[''] active:bg-hover disabled:opacity-45`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 truncate`,children:[m,h&&(0,R.jsxs)(R.Fragment,{children:[` `,(0,R.jsx)(`span`,{className:`text-edition`,children:h})]}),g&&` · ${g}`]}),_?(0,R.jsx)(M_,{"aria-hidden":!0,size:13,className:`shrink-0 animate-spin text-muted`}):(0,R.jsx)(t_,{"aria-hidden":!0,size:13,strokeWidth:2.4,className:`shrink-0 text-muted`})]}),u&&(0,R.jsx)(UV,{groups:e,value:t,onValueChange:r,onClose:()=>p(!1),upgrade:l})]})}var GV=Xz;function KV({label:e,edition:t}){let n=t?` ${t}`:``;return!n||!e.endsWith(n)?(0,R.jsx)(R.Fragment,{children:e}):(0,R.jsxs)(R.Fragment,{children:[e.slice(0,-n.length),` `,(0,R.jsx)(`span`,{className:`profile-grid-edition text-edition`,children:t})]})}function qV({name:e,edition:t,effort:n}){return(0,R.jsxs)(R.Fragment,{children:[e,t&&(0,R.jsxs)(R.Fragment,{children:[` `,(0,R.jsx)(`span`,{className:`profile-grid-edition text-edition`,children:t})]}),n&&` › ${n}`]})}function JV(e){return e.replace(/ /g,`\xA0`)}function YV(e){return Lg()?(0,R.jsx)(WV,{...e}):(0,R.jsx)(XV,{...e})}function XV({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=kP,className:f=``,agentSettings:p=!1,runningModelLabel:m,upgrade:h}){let[g,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)(null),b=(0,L.useRef)(v);b.current=v;let x=(0,L.useRef)(g),S=(0,L.useRef)(c),C=(0,L.useRef)(void 0),w=(0,L.useRef)(new Map),T=(0,L.useRef)(void 0),E=(0,L.useMemo)(()=>$z(e),[e]),D=(0,L.useMemo)(()=>tB(e),[e]),O=l?Nne:Jz,k=c?`cursor-not-allowed opacity-45`:`cursor-pointer transition-colors hover:border-border hover:bg-panel-2 hover:text-fg`,A=iB(e,t),j=A&&t?.provider&&t.model?nB({provider:t.provider,model:t.model,effort:t.effort??``}):void 0,M=n?.model||n?.effort?sB(e,n,`Pending profile`):void 0;x.current=g,S.current=c;function N(){y(null),x.current=!1,C.current=void 0,_(!1)}function P(){b.current?(b.current=null,y(null),C.current=fB(P)):N()}(0,L.useLayoutEffect)(()=>{let e=e=>{e.key!==`Escape`||!x.current||S.current||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),!pB()&&(C.current?.(),P()))};return window.addEventListener(`keydown`,e,{capture:!0}),()=>window.removeEventListener(`keydown`,e,{capture:!0})},[]),(0,L.useLayoutEffect)(()=>{!c||!g||(C.current?.(),N())},[c,g]),(0,L.useLayoutEffect)(()=>()=>C.current?.(),[]),(0,L.useLayoutEffect)(()=>{j===T.current&&(T.current=void 0)},[j]);function F(e){let t=nB(e);T.current!==t&&(T.current=t,r(e))}function I(t,n){if(![`ArrowLeft`,`ArrowRight`,`ArrowUp`,`ArrowDown`,`Home`,`End`].includes(t.key))return;let r=cB(e,n,t.key);r&&(t.preventDefault(),t.stopPropagation(),w.current.get(nB(r))?.focus())}return(0,R.jsxs)(KL,{modal:!1,open:g,onOpenChange:e=>{C.current?.(),C.current=void 0,x.current=e,_(e),e?C.current=fB(P):y(null)},children:[(0,R.jsx)(qL,{asChild:!0,disabled:c,children:(0,R.jsxs)(`button`,{type:`button`,"aria-label":a,"aria-invalid":!A&&(t?.model||t?.effort)?!0:void 0,"aria-description":M?`Pending ${M}`:void 0,title:s,"data-profile-known":A?`true`:`false`,"data-profile-pending":M?`true`:void 0,className:`profile-grid-trigger group inline-flex min-w-0 max-w-full items-center gap-[3px] 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 ${k} ${f} ${O}`,children:[(0,R.jsx)(`span`,{className:`profile-grid-value min-w-0 flex-1 truncate text-left ${O}`,children:(0,R.jsx)(qV,{...oB(e,t,i,m)})}),M&&(0,R.jsx)(M_,{"aria-hidden":`true`,size:l?10:11,className:`shrink-0 animate-spin text-muted-65`}),(0,R.jsx)(t_,{"aria-hidden":`true`,size:l?11:13,className:`shrink-0 text-fg/65 transition-transform group-data-[state=open]:rotate-180`})]})}),(0,R.jsx)(JL,{children:(0,R.jsxs)(YL,{"aria-label":o,align:`start`,side:u,sideOffset:5,collisionPadding:8,onEscapeKeyDown:e=>e.stopPropagation(),onInteractOutside:e=>{(b.current||e.target instanceof Element&&e.target.closest(`[data-agent-settings-menu]`))&&e.preventDefault()},className:`profile-grid-menu ${d} ${OP} max-h-[min(360px,var(--radix-dropdown-menu-content-available-height))] max-w-[calc(100vw-1rem)] overflow-auto rounded-lg p-1.5 ${O}`,children:[e.map(t=>(0,R.jsxs)(XL,{children:[t.label&&(0,R.jsxs)(`div`,{className:`profile-grid-header sticky left-0 flex items-baseline justify-between gap-4 px-1.5 pb-1 pt-1 first:pt-0.5`,children:[(0,R.jsx)(ZL,{className:`text-left font-medium tracking-[0.07em] text-muted-55`,children:t.label}),p&&(t.id===`claude`||t.id===`codex`)&&(0,R.jsx)(RV,{backend:t.id,open:v===t.id,onOpenChange:e=>y(e?t.id:null)})]}),(0,R.jsx)($L,{value:j,onValueChange:t=>{let n=rB(e,t);n&&F(n)},children:t.options.map(e=>(0,R.jsxs)(`div`,{"data-profile-grid-row":e.model,className:`grid w-max items-center gap-1 py-0.5`,style:{gridTemplateColumns:Pne(E.length)},children:[(0,R.jsx)(`span`,{className:`profile-grid-model-label min-w-0 max-w-[9.5rem] truncate px-1.5 text-left text-muted ${O}`,title:e.label,children:(0,R.jsx)(KV,{label:e.label,edition:e.edition})}),e.efforts.length===0&&(()=>{let n={provider:t.id,model:e.model,effort:``},r=nB(n);return(0,R.jsx)(eR,{value:r,ref:e=>{e?w.current.set(r,e):w.current.delete(r)},onKeyDown:e=>I(e,n),onSelect:e=>{e.preventDefault(),F(n),C.current?.(),N()},"aria-label":`${e.label}, the agent's own defaults`,title:`${e.label} › the agent's own model and effort`,className:Yz,style:{gridColumn:`2 / -1`,justifySelf:`start`},children:(0,R.jsxs)(`span`,{className:`grid`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`invisible col-start-1 row-start-1 font-medium`,children:`Default`}),(0,R.jsx)(`span`,{className:`col-start-1 row-start-1`,children:`Default`})]})},`default`)})(),e.efforts.length>0&&E.map(n=>{let r=n.find(t=>e.efforts.includes(t)),i=n.reduce((e,t)=>GV(t).length>GV(e).length?t:e);if(!r)return(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`invisible cursor-default border border-transparent px-1 text-left font-medium ${O}`,children:GV(i)},i);let a={provider:t.id,model:e.model,effort:r},o=nB(a);return(0,R.jsx)(eR,{value:o,ref:e=>{e?w.current.set(o,e):w.current.delete(o)},onKeyDown:e=>I(e,a),onSelect:e=>{e.preventDefault(),F(a),C.current?.(),N()},"aria-label":`${e.label}, ${GV(r)} effort`,title:`${e.label} › ${GV(r)}`,className:Yz,children:(0,R.jsxs)(`span`,{className:`grid`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`invisible col-start-1 row-start-1 font-medium`,children:GV(r)}),(0,R.jsx)(`span`,{className:`col-start-1 row-start-1`,children:GV(r)})]})},r)})]},e.model))}),t!==e.at(-1)&&(0,R.jsx)(nR,{className:`my-1 h-px bg-border`})]},t.id)),D.length===0&&(0,R.jsx)(`div`,{className:`px-2 py-1.5 text-muted-60`,children:`No profiles available`}),h&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(nR,{className:`my-1 h-px bg-border`}),(0,R.jsxs)(`div`,{"data-profile-grid-upgrade":``,className:`flex w-0 min-w-full items-center gap-2 px-1.5 py-0.5`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 text-balance text-muted`,children:h.staged?`This thread will upgrade to ${JV(h.latest)} on its next turn`:`This thread will auto-upgrade to ${JV(h.latest)} after its next compaction`}),!h.staged&&(0,R.jsx)(QL,{disabled:h.blockedReason!==null||h.pending,onSelect:e=>{e.preventDefault(),h.onUpgrade(),C.current?.(),N()},title:h.blockedReason??`Restart this thread's worker on ${h.latest}. The conversation resumes from disk on the next turn; the prompt cache is re-read once.`,className:`flex h-6 shrink-0 cursor-pointer select-none items-center rounded border border-border bg-transparent px-1.5 text-fg outline-none transition-colors data-[highlighted]:bg-panel-2 data-[highlighted]:outline data-[highlighted]:outline-1 data-[highlighted]:outline-offset-1 data-[highlighted]:outline-fg/55 data-[disabled]:cursor-not-allowed data-[disabled]:opacity-45 ${O}`,children:`Upgrade now`})]})]})]})})]})}function ZV(e,t){let n=e?.models.find(t=>t.id===e.current),r=[{value:``,label:n?`Default · ${QV(n).model}`:`Default`,title:`The model the agent opens on when Frizz asks for none`}];t&&!e?.models.some(e=>e.id===t)&&r.push(e&&!e.error?{value:t,label:`${t} (unavailable)`,title:`The agent no longer advertises this model`}:{value:t,label:t});let i=[{label:``,options:r}];for(let t of e?.models??[]){let{provider:e,model:n}=QV(t),r=i.find(t=>t.label===e);r||(r={label:e,options:[]},i.push(r)),r.options.push({value:t.id,label:n,title:t.id})}return i}function QV(e){let t=e.name.indexOf(`/`);if(t>0)return{provider:e.name.slice(0,t).trim(),model:e.name.slice(t+1).trim()};let n=e.id.indexOf(`/`);return n>0?{provider:e.id.slice(0,n),model:e.name}:{provider:`Models`,model:e.name}}function $V({agentId:e,agentLabel:t,modelId:n,onValueChange:r,disabled:i=!1,side:a=`bottom`,menuZClass:o=kP,className:s=``}){let c=ct({queryKey:[`acpAgentModels`,e],queryFn:()=>Y.acpAgentModels({agentId:e}),staleTime:6e4}),l=ZV(c.data,n),u=c.isError?c.error.message:c.data?.error,d=u?`${t} did not list its models (${u}); the thread runs on the agent's own default`:c.data?.models.length?`Model for ${t} — the list is the agent's own, read from its session`:`${t} lists no models; the thread runs on the agent's own default`;return(0,R.jsx)(FV,{variant:`readout`,side:a,value:n??``,onValueChange:e=>r(e||void 0),groups:l,placeholder:c.isPending?`Models…`:`Default`,ariaLabel:`Model for ${t}`,title:d,disabled:i||c.isPending,indicatorPosition:`right`,menuZClass:o,className:s})}async function eH(e){if(navigator.clipboard?.writeText)try{await navigator.clipboard.writeText(e);return}catch{}if(!tH(e))throw Error(`the browser blocked clipboard access`)}function tH(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 nH={claude:`claude auth login`,codex:`codex login`},rH={claude:`Claude`,codex:`Codex`};function iH(e){let t=e.trim();return t===`/login`?`login`:t===`/logout`?`logout`:null}function aH({backend:e,onClose:t,onAuthed:n}){let r=qe(),[i,a]=(0,L.useState)(!1),o=nH[e],s=rH[e];async function c(){try{await eH(o),a(!0),window.setTimeout(()=>a(!1),1500)}catch{Z(`Couldn't copy — select the command and copy it manually`,{duration:6e3})}}let l=pt({mutationFn:()=>Y.authStatus(),onSuccess:t=>{if(r.setQueryData([`authStatus`],t),t[e]===`signed-out`){Z(`Still signed out of ${s} — run the command, then retry`,{duration:6e3});return}n()},onError:()=>n()});return(0,R.jsx)(hR,{open:!0,onOpenChange:e=>{e||t()},children:(0,R.jsxs)(yR,{children:[(0,R.jsx)(xR,{className:`fixed inset-0 z-[210] bg-scrim-30 backdrop-blur-md backdrop-saturate-150`}),(0,R.jsxs)(TR,{"aria-modal":`true`,"aria-describedby":void 0,className:`fixed left-1/2 top-1/2 z-[210] 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-shadow-ink/50 outline-none`,children:[(0,R.jsxs)(AR,{className:`mb-1 text-[14px] font-medium`,children:[`Signed out of `,s]}),(0,R.jsxs)(`p`,{className:`mb-4 text-[12.5px] leading-relaxed text-muted`,children:[`Frizz can't start a `,s,` thread until you're signed in. Run this command in a terminal on the machine running Frizz, then retry:`]}),(0,R.jsxs)(`div`,{className:`mb-4 flex items-center gap-2 rounded-lg border border-border bg-panel-2 px-3 py-2`,children:[(0,R.jsx)(`code`,{className:`flex-1 select-all font-mono-keep text-[12.5px] text-fg`,children:o}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Copy command`,onClick:c,className:`icon-hover-outline 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,R.jsx)(e_,{size:14,strokeWidth:2,className:`text-success`}):(0,R.jsx)(m_,{size:14,strokeWidth:1.8})})]}),(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:t,className:`button-outline 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,R.jsxs)(`button`,{type:`button`,onClick:()=>l.mutate(),disabled:l.isPending,className:`button-outline flex items-center gap-1.5 rounded-md bg-accent-fill px-3 py-1.5 text-[12.5px] font-medium text-accent-fg outline-none transition-opacity hover:opacity-90 disabled:opacity-60`,children:[l.isPending&&(0,R.jsx)(M_,{size:13,className:`animate-spin`}),`Retry`]})]})]})]})})}function oH({backend:e,onClose:t}){let n=qe(),r=rH[e],i=pt({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,R.jsx)(hR,{open:!0,onOpenChange:e=>{!e&&!i.isPending&&t()},children:(0,R.jsxs)(yR,{children:[(0,R.jsx)(xR,{className:`fixed inset-0 z-[210] bg-scrim-30 backdrop-blur-md backdrop-saturate-150`}),(0,R.jsxs)(TR,{"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-shadow-ink/50 outline-none`,children:[(0,R.jsxs)(AR,{className:`mb-1 text-[14px] font-medium`,children:[`Sign out of `,r,`?`]}),(0,R.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,R.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:t,disabled:i.isPending,className:`button-outline 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,R.jsxs)(`button`,{type:`button`,onClick:()=>i.mutate(),disabled:i.isPending,className:`button-outline flex items-center gap-1.5 rounded-md bg-danger-button/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,R.jsx)(M_,{size:13,className:`animate-spin`}),`Sign out`]})]})]})]})})}function sH(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 cH(e,t=[],n=[]){let r=t.filter(e=>e.available).map(e=>({model:Su(e.id),label:e.label,efforts:[]}));return[{id:`claude`,label:`Claude Code`,options:IB(n).map(e=>({model:e.value,label:e.label,edition:n.find(t=>t.alias===e.value)?.edition,defaultEffort:`high`,efforts:VB(e.value)}))},{id:`codex`,label:`Codex`,options:e.map(e=>({model:e.slug,label:e.displayName,defaultEffort:e.defaultEffort,efforts:e.efforts}))},...r.length?[{id:`acp`,label:`ACP agents`,options:r}]:[]]}function lH(e,t,n=[]){let r=e.backend,i=e[r]??{},a=n.find(e=>e.available),o=i.model??(r===`claude`?`opus`:r===`codex`?t[0]?.slug??``:a?Su(a.id):``),s=r===`codex`?t.find(e=>e.slug===o):void 0,c=r===`acp`?wu(o):void 0,l=r===`acp`?Tu(o):void 0,u=r===`acp`&&c?Su(c):o,d=r===`claude`?FB.some(e=>e.value===o):r===`codex`?t.some(e=>e.slug===o):n.some(e=>e.available&&e.id===c),f=r===`claude`?`high`:s?.defaultEffort??``,p=r===`acp`?``:i.effort??f,m=r===`claude`?WB(o,{withDefault:!1}):r===`codex`?GB(s,{withDefault:!1}):[],h=r===`acp`||m.some(e=>e.value===p),g=p&&!h?[{value:p,label:`${p} (unavailable)`,title:`Saved reasoning level is not available for this model`},...m]:m;return{backend:r,model:o,pickerModel:u,effort:p,codexModel:s,...c?{acpAgentId:c}:{},...l?{acpModelId:l}:{},modelAvailable:d,effortAvailable:h,effortOptions:g}}function uH(){let e=qe(),t=ct({queryKey:[`dispatchPreferencesGet`],queryFn:()=>Y.dispatchPreferencesGet()}),n=ct({queryKey:[`codexModels`],queryFn:()=>Y.codexModels()}),r=n.data??[],i=ct({queryKey:[`claudeModels`],queryFn:()=>Y.claudeModels(),retry:!1}).data??[],a=ct({queryKey:[`acpAgents`],queryFn:()=>Y.acpAgents()}),o=a.data??[],s=pt({mutationFn:e=>Y.dispatchPreferenceSet(e),scope:{id:`dispatch-preferences`},onMutate:t=>{let n=e.getQueryData([`dispatchPreferencesGet`]);n&&e.setQueryData([`dispatchPreferencesGet`],sH(n,t))},onError:t=>{e.invalidateQueries({queryKey:[`dispatchPreferencesGet`]}),Z(`Could not save new-thread preference: ${t.message.slice(0,80)}`)}}),c=!!t.data&&!!n.data&&(a.isSuccess||a.isError);return{resolved:(0,L.useMemo)(()=>c?lH(t.data,r,o):void 0,[c,t.data,r,o]),codexList:r,claudeList:i,acpList:o,loadError:t.isError||n.isError,saveProfile:s.mutate}}var dH=`frizz-drafts:v1`,fH=80,pH=512*1024,mH=2*1024*1024,hH=new TextEncoder;function gH(e){return hH.encode(e).byteLength}function _H(){return{version:1,entries:{}}}function vH(e){if(!e)return _H();try{let t=JSON.parse(e);if(!t||typeof t!=`object`||t.version!==1)return _H();let n=t.entries;if(!n||typeof n!=`object`||Array.isArray(n))return _H();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||gH(t.value)>pH||(r[e]={value:t.value,touchedAt:t.touchedAt});return{version:1,entries:r}}catch{return _H()}}function yH(e){let t=Object.entries(e.entries).filter(([,e])=>e.value&&gH(e.value)<=pH).sort((e,t)=>t[1].touchedAt-e[1].touchedAt),n={};for(let[e,r]of t){if(Object.keys(n).length>=fH)break;n[e]=r,gH(JSON.stringify({version:1,entries:n}))>mH&&delete n[e]}return{version:1,entries:n}}var bH=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=yH(vH(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(dH,JSON.stringify(yH(e)))}catch{}for(let e of this.listeners)e()}};function xH(e,t){if(!t)return;let n=bH.get(e);n.includes(t)||bH.set(e,n?`${t}\n\n${n}`:t)}function SH(e){return encodeURIComponent(e||`unresolved-project`)}var CH={dispatch:e=>`dispatch:${SH(e)}:new`,followUp:(e,t,n)=>`followup:${SH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}`,adopt:(e,t)=>`adopt:${SH(e)}:${encodeURIComponent(t)}`,answer:(e,t,n,r,i)=>`answer:${SH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n??`unowned`)}:${encodeURIComponent(r)}:${i}`,interaction:(e,t,n,r,i,a,o)=>`interaction:${SH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}:${i}:${encodeURIComponent(a)}:${encodeURIComponent(o)}`,question:(e,t,n,r)=>`question:${SH(e)}:${encodeURIComponent(t)}:${encodeURIComponent(n)}:${encodeURIComponent(r)}`,questionPick:(e,t,n,r)=>`${CH.question(e,t,n,r)}:picks`};function wH(){return gr(X).board?.projectDir}function TH(e){return gr(X).board?.threads.find(t=>t.id===e)?.sessionId}function EH(e){let t=(0,L.useCallback)(()=>bH.get(e),[e]);return[(0,L.useSyncExternalStore)(bH.subscribe,t,t),(0,L.useCallback)(t=>bH.set(e,t),[e]),(0,L.useCallback)(()=>bH.clear(e),[e])]}function DH(e){let t=(0,L.useCallback)(()=>JSON.stringify(Object.fromEntries(e.map(e=>[e,bH.get(e)]))),[e.join(`\0`)]),n=(0,L.useSyncExternalStore)(bH.subscribe,t,t);return(0,L.useMemo)(()=>new Map(Object.entries(JSON.parse(n))),[n])}function OH(e){let{resolved:t,codexList:n,claudeList:r,acpList:i,loadError:a,saveProfile:o}=uH(),s=ut({mutationKey:[...bB]})>0,c=Gz(),l=wH(),[u,d,f]=EH(CH.dispatch(l)),p=CH.dispatch(l),m=(0,L.useRef)(``),[h,g]=(0,L.useState)(null),_=ct({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4}),[v,y]=(0,L.useState)(null),[b,x]=(0,L.useState)(null),S=(0,L.useRef)(null),C=pt({mutationFn:e=>Y.dispatch(e),onMutate:()=>Z(`Starting thread…`,{spinner:!0,sticky:!0}),onSuccess:t=>{g(null),e?.(),Z(`Thread started`,{link:{label:`Open thread`,slug:t.slug}})},onError:(e,t)=>{bH.get(p)||d(m.current||t.prompt),g(null);let n=/^AUTH_REQUIRED:(claude|codex)$/.exec(e.message);if(n){S.current=t,y(n[1]),Z(`Signed out of ${n[1]===`claude`?`Claude`:`Codex`}`,{duration:3e3});return}Z(`Dispatch failed: ${e.message.slice(0,80)}`)}});function w(e){m.current=u,f(),g(e.prompt),C.mutate(e)}function T(){if(!u.trim()||!t||s)return;let e=iH(u);if(e){if(f(),t.backend===`acp`){Z(`An ACP agent signs in through its own CLI — Frizz holds no account for it`);return}e===`login`?(S.current=null,y(t.backend)):x(t.backend);return}if(!t.modelAvailable){Z(`Saved model is unavailable — choose a model before starting the thread`);return}if(!t.effortAvailable){Z(`Saved reasoning level is unavailable for this model — choose another level`);return}let n={prompt:u.trim(),model:t.model,backend:t.backend,effort:t.effort||void 0};if(t.backend!==`acp`&&_.data?.[t.backend]===`signed-out`){S.current=n,y(t.backend);return}w(n)}let E=(0,L.useMemo)(()=>{if(!t)return(0,R.jsx)(YV,{groups:[],value:void 0,onValueChange:()=>{},placeholder:a?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort loading`,disabled:!0});let e=cH(n,i,r),s=t.acpAgentId?i.find(e=>e.id===t.acpAgentId):void 0;return(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-wrap items-center gap-x-1.5 gap-y-0.5`,children:[(0,R.jsx)(YV,{groups:e,agentSettings:!0,value:{provider:t.backend,model:t.pickerModel,effort:t.effort},onValueChange:e=>o({field:`profile`,backend:e.provider,model:e.model,effort:e.effort||void 0}),ariaLabel:`Model and effort`,title:t.modelAvailable&&t.effortAvailable?`Model and reasoning effort`:`Saved model or reasoning effort unavailable — choose a supported pair`,className:`max-w-[min(21rem,72vw)]`}),s&&(0,R.jsx)($V,{agentId:s.id,agentLabel:s.label,modelId:t.acpModelId,onValueChange:e=>o({field:`model`,backend:`acp`,value:Su(s.id,e)}),className:`max-w-[min(14rem,40vw)] px-2 py-1`})]})},[t,n,r,i,a,o]),D=(0,R.jsxs)(R.Fragment,{children:[v&&(0,R.jsx)(aH,{backend:v,onClose:()=>y(null),onAuthed:()=>{let e=S.current;S.current=null,y(null),e&&w(e)}}),b&&(0,R.jsx)(oH,{backend:b,onClose:()=>x(null)})]});return{prompt:u,setPrompt:d,submit:T,busy:C.isPending||s,footer:E,githubTriggerVisible:c,error:C.isError?C.error.message:null,pendingDispatch:h,accountModals:D}}function kH({autoFocus:e,onDispatched:t}){let n=OH(t);return(0,R.jsxs)(`div`,{className:`w-full flex flex-col gap-3`,children:[(0,R.jsx)(Hz,{surface:`newComposer`,autoFocus:e,value:n.prompt,onChange:n.setPrompt,onSubmit:n.submit,placeholder:`Describe the task…`,minHeight:96,maxHeight:340,busy:n.busy,footer:n.footer,leftAction:n.githubTriggerVisible?(0,R.jsx)(Kz,{}):void 0}),n.error&&(0,R.jsx)(`span`,{className:`px-0.5 text-[11px] text-danger truncate`,children:n.error}),n.pendingDispatch&&(0,R.jsx)(AH,{prompt:n.pendingDispatch}),n.accountModals]})}function AH({prompt:e,className:t=``}){return(0,R.jsxs)(`div`,{"data-pending-dispatch":!0,role:`status`,className:`rounded-lg border border-border bg-panel-2 px-3 py-2.5 ${t}`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 text-[11px] text-muted`,children:[(0,R.jsx)(`span`,{className:`inline-block h-1.5 w-1.5 animate-pulse rounded-full bg-accent`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{children:`Starting thread…`})]}),(0,R.jsx)(`p`,{className:`mt-1 line-clamp-2 whitespace-pre-wrap text-[12px] leading-relaxed text-fg`,children:e})]})}function jH({onDispatched:e}){let t=OH(e),n=UG(ME()),r=n.state===`verified`?n.repo:n.state===`local`?n.name:``,[i,a]=(0,L.useState)(!1),o=t.prompt.trim().length>0&&!t.busy&&!i;return(0,R.jsxs)(`div`,{"data-phone-new-thread":!0,className:`flex h-full min-h-0 flex-col`,children:[(0,R.jsxs)(`header`,{className:`flex min-h-[56px] shrink-0 items-center gap-0.5 border-b border-border py-1 pl-1 pr-2`,children:[(0,R.jsx)(MR,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Close`,"data-phone-new-thread-close":!0,className:`flex size-[44px] shrink-0 items-center justify-center rounded-full text-fg/90 active:bg-hover`,children:(0,R.jsx)(cv,{size:21,strokeWidth:2.1})})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 pl-0.5 leading-[1.25]`,children:[(0,R.jsx)(AR,{className:`truncate text-[16.5px] font-semibold tracking-[-0.01em] text-fg`,children:`New thread`}),r&&(0,R.jsx)(`div`,{className:`truncate text-[13px] text-muted`,children:r})]}),(0,R.jsx)(`button`,{type:`button`,"data-phone-start":!0,onMouseDown:e=>e.preventDefault(),onClick:t.submit,disabled:!o,className:`relative flex h-[36px] shrink-0 items-center rounded-full bg-fg px-4 text-[15px] font-semibold text-bg after:absolute after:inset-x-0 after:-inset-y-[4px] after:content-[''] disabled:opacity-35`,children:`Start`})]}),t.error&&(0,R.jsx)(`div`,{className:`shrink-0 px-[18px] pt-2 text-[13px] text-danger`,children:t.error}),t.pendingDispatch&&(0,R.jsx)(AH,{prompt:t.pendingDispatch,className:`mx-3 mt-3 shrink-0`}),(0,R.jsx)(Hz,{surface:`newComposer`,autoFocus:!0,value:t.prompt,onChange:t.setPrompt,onSubmit:t.submit,placeholder:`Describe the task…`,minHeight:120,maxHeight:1e5,busy:t.busy,onUploadingChange:a,phone:{layout:`page`,tools:(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 [&>*]:flex-initial`,children:[t.footer,t.githubTriggerVisible&&(0,R.jsx)(Kz,{variant:`phoneChip`})]})}}),t.accountModals]})}function MH({onClose:e}){let t=Lg(),n=(0,L.useRef)(null),r=(0,L.useRef)(typeof document<`u`&&document.activeElement instanceof HTMLElement?document.activeElement:null);return(0,L.useEffect)(()=>()=>{let e=r.current;window.setTimeout(()=>{e?.isConnected&&e.focus({preventScroll:!0})},0)},[]),(0,R.jsx)(hR,{open:!0,onOpenChange:t=>{t||e()},children:(0,R.jsxs)(yR,{children:[(0,R.jsx)(xR,{className:`fixed inset-0 z-50 bg-scrim-30 backdrop-blur-md backdrop-saturate-150`}),(0,R.jsx)(TR,{ref:n,"aria-modal":`true`,"aria-describedby":void 0,onEscapeKeyDown:mB,onCloseAutoFocus:e=>{e.preventDefault();let t=r.current;t?.isConnected&&t.focus({preventScroll:!0})},onOpenAutoFocus:e=>{e.preventDefault(),n.current?.querySelector(`textarea`)?.focus({preventScroll:!0})},className:t?`fixed inset-0 z-50 flex flex-col bg-bg pt-[env(safe-area-inset-top)] outline-none`:`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-shadow-ink/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:t?(0,R.jsx)(jH,{onDispatched:e}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(AR,{className:`mb-1 text-[14px] font-medium`,children:`New thread`}),(0,R.jsx)(kH,{autoFocus:!0,onDispatched:e})]})})]})})}function NH({children:e,onClose:t}){return(0,R.jsx)(`div`,{className:`fixed inset-0 z-[200] flex items-center justify-center bg-scrim-30 backdrop-blur-md backdrop-saturate-150`,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:e})}var PH=`-mx-1.5 inline-flex h-6 w-6 shrink-0 items-center justify-center rounded-md text-fg/75 outline-none transition-colors hover:bg-elevated hover:text-fg focus-visible:ring-1 focus-visible:ring-border-strong disabled:opacity-55`,FH={claude:`size-[11px] translate-y-px`,codex:`size-[10px]`,acp:`h-[11px] w-[6.65px] translate-y-px`,"acp:opencode":`size-[10px]`,"acp:cursor":`size-[10px]`,"acp:gemini":`size-[10px]`,"acp:copilot":`size-[12px] translate-y-px`,"acp:qwen":`size-[10px]`,"acp:kimi":`size-[10px]`},IH={claude:{key:`claude`,backend:`claude`,label:`Claude Code`},codex:{key:`codex`,backend:`codex`,label:`OpenAI Codex`},acp:{key:`acp`,backend:`acp`,label:`ACP agent`},"acp:opencode":{key:`acp:opencode`,backend:`acp`,label:`OpenCode`},"acp:cursor":{key:`acp:cursor`,backend:`acp`,label:`Cursor agent`},"acp:gemini":{key:`acp:gemini`,backend:`acp`,label:`Gemini CLI`},"acp:copilot":{key:`acp:copilot`,backend:`acp`,label:`GitHub Copilot CLI`},"acp:qwen":{key:`acp:qwen`,backend:`acp`,label:`Qwen Code`},"acp:kimi":{key:`acp:kimi`,backend:`acp`,label:`Kimi CLI`}};function LH(e){return Object.hasOwn(IH,e)}function RH(e,t){if(e===`claude`||e===`codex`)return IH[e];if(e!==`acp`)return;let n=wu(t),r=n?`acp:${n}`:`acp`;return LH(r)?IH[r]:IH.acp}function zH({backend:e,model:t,className:n}){let r=RH(e,t);return r?(0,R.jsx)(`span`,{role:`img`,"aria-label":r.label,className:`inline-flex shrink-0 text-muted-65 ${FH[r.key]} ${n??``}`,children:BH[r.key]()}):null}var BH={claude:UH,codex:HH,acp:VH,"acp:opencode":WH,"acp:cursor":GH,"acp:gemini":KH,"acp:copilot":qH,"acp:qwen":JH,"acp:kimi":YH};function VH(){return(0,R.jsx)(K_,{"aria-hidden":`true`,focusable:`false`,className:`size-full`,strokeWidth:2.5,viewBox:`4.75 0.75 14.5 22.5`})}function HH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.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 UH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.jsx)(`path`,{d:`m4.7144 15.9555 4.7174-2.6471.079-.2307-.079-.1275h-.2307l-.7893-.0486-2.6956-.0729-2.3375-.0971-2.2646-.1214-.5707-.1215-.5343-.7042.0546-.3522.4797-.3218.686.0608 1.5179.1032 2.2767.1578 1.6514.0972 2.4468.255h.3886l.0546-.1579-.1336-.0971-.1032-.0972L6.973 9.8356l-2.55-1.6879-1.3356-.9714-.7225-.4918-.3643-.4614-.1578-1.0078.6557-.7225.8803.0607.2246.0607.8925.686 1.9064 1.4754 2.4893 1.8336.3643.3035.1457-.1032.0182-.0728-.164-.2733-1.3539-2.4467-1.445-2.4893-.6435-1.032-.17-.6194c-.0607-.255-.1032-.4674-.1032-.7285L6.287.1335 6.6997 0l.9957.1336.419.3642.6192 1.4147 1.0018 2.2282 1.5543 3.0296.4553.8985.2429.8318.091.255h.1579v-.1457l.1275-1.706.2368-2.0947.2307-2.6957.0789-.7589.3764-.9107.7468-.4918.5828.2793.4797.686-.0668.4433-.2853 1.8517-.5586 2.9021-.3643 1.9429h.2125l.2429-.2429.9835-1.3053 1.6514-2.0643.7286-.8196.85-.9046.5464-.4311h1.0321l.759 1.1293-.34 1.1657-1.0625 1.3478-.8804 1.1414-1.2628 1.7-.7893 1.36.0729.1093.1882-.0183 2.8535-.607 1.5421-.2794 1.8396-.3157.8318.3886.091.3946-.3278.8075-1.967.4857-2.3072.4614-3.4364.8136-.0425.0304.0486.0607 1.5482.1457.6618.0364h1.621l3.0175.2247.7892.522.4736.6376-.079.4857-1.2142.6193-1.6393-.3886-3.825-.9107-1.3113-.3279h-.1822v.1093l1.0929 1.0686 2.0035 1.8092 2.5075 2.3314.1275.5768-.3218.4554-.34-.0486-2.2039-1.6575-.85-.7468-1.9246-1.621h-.1275v.17l.4432.6496 2.3436 3.5214.1214 1.0807-.17.3521-.6071.2125-.6679-.1214-1.3721-1.9246L14.38 17.959l-1.1414-1.9428-.1397.079-.674 7.2552-.3156.3703-.7286.2793-.6071-.4614-.3218-.7468.3218-1.4753.3886-1.9246.3157-1.53.2853-1.9004.17-.6314-.0121-.0425-.1397.0182-1.4328 1.9672-2.1796 2.9446-1.7243 1.8456-.4128.164-.7164-.3704.0667-.6618.4008-.5889 2.386-3.0357 1.4389-1.882.929-1.0868-.0062-.1579h-.0546l-6.3385 4.1164-1.1293.1457-.4857-.4554.0608-.7467.2307-.2429 1.9064-1.3114Z`})})}function WH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.jsx)(`path`,{d:`M22 24H2V0h20zM17 4.8H7v14.4h10z`})})}function GH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.jsx)(`path`,{d:`M11.503.131 1.891 5.678a.84.84 0 0 0-.42.726v11.188c0 .3.162.575.42.724l9.609 5.55a1 1 0 0 0 .998 0l9.61-5.55a.84.84 0 0 0 .42-.724V6.404a.84.84 0 0 0-.42-.726L12.497.131a1.01 1.01 0 0 0-.996 0M2.657 6.338h18.55c.263 0 .43.287.297.515L12.23 22.918c-.062.107-.229.064-.229-.06V12.335a.59.59 0 0 0-.295-.51l-9.11-5.257c-.109-.063-.064-.23.061-.23`})})}function KH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.jsx)(`path`,{d:`M11.04 19.32Q12 21.51 12 24q0-2.49.93-4.68.96-2.19 2.58-3.81t3.81-2.55Q21.51 12 24 12q-2.49 0-4.68-.93a12.3 12.3 0 0 1-3.81-2.58 12.3 12.3 0 0 1-2.58-3.81Q12 2.49 12 0q0 2.49-.96 4.68-.93 2.19-2.55 3.81a12.3 12.3 0 0 1-3.81 2.58Q2.49 12 0 12q2.49 0 4.68.96 2.19.93 3.81 2.55t2.55 3.81`})})}function qH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.jsx)(`path`,{d:`M23.922 16.997C23.061 18.492 18.063 22.02 12 22.02 5.937 22.02.939 18.492.078 16.997A.641.641 0 0 1 0 16.741v-2.869a.883.883 0 0 1 .053-.22c.372-.935 1.347-2.292 2.605-2.656.167-.429.414-1.055.644-1.517a10.098 10.098 0 0 1-.052-1.086c0-1.331.282-2.499 1.132-3.368.397-.406.89-.717 1.474-.952C7.255 2.937 9.248 1.98 11.978 1.98c2.731 0 4.767.957 6.166 2.093.584.235 1.077.546 1.474.952.85.869 1.132 2.037 1.132 3.368 0 .368-.014.733-.052 1.086.23.462.477 1.088.644 1.517 1.258.364 2.233 1.721 2.605 2.656a.841.841 0 0 1 .053.22v2.869a.641.641 0 0 1-.078.256Zm-11.75-5.992h-.344a4.359 4.359 0 0 1-.355.508c-.77.947-1.918 1.492-3.508 1.492-1.725 0-2.989-.359-3.782-1.259a2.137 2.137 0 0 1-.085-.104L4 11.746v6.585c1.435.779 4.514 2.179 8 2.179 3.486 0 6.565-1.4 8-2.179v-6.585l-.098-.104s-.033.045-.085.104c-.793.9-2.057 1.259-3.782 1.259-1.59 0-2.738-.545-3.508-1.492a4.359 4.359 0 0 1-.355-.508Zm2.328 3.25c.549 0 1 .451 1 1v2c0 .549-.451 1-1 1-.549 0-1-.451-1-1v-2c0-.549.451-1 1-1Zm-5 0c.549 0 1 .451 1 1v2c0 .549-.451 1-1 1-.549 0-1-.451-1-1v-2c0-.549.451-1 1-1Zm3.313-6.185c.136 1.057.403 1.913.878 2.497.442.544 1.134.938 2.344.938 1.573 0 2.292-.337 2.657-.751.384-.435.558-1.15.558-2.361 0-1.14-.243-1.847-.705-2.319-.477-.488-1.319-.862-2.824-1.025-1.487-.161-2.192.138-2.533.529-.269.307-.437.808-.438 1.578v.021c0 .265.021.562.063.893Zm-1.626 0c.042-.331.063-.628.063-.894v-.02c-.001-.77-.169-1.271-.438-1.578-.341-.391-1.046-.69-2.533-.529-1.505.163-2.347.537-2.824 1.025-.462.472-.705 1.179-.705 2.319 0 1.211.175 1.926.558 2.361.365.414 1.084.751 2.657.751 1.21 0 1.902-.394 2.344-.938.475-.584.742-1.44.878-2.497Z`})})}function JH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.jsx)(`path`,{d:`M23.919 14.545 20.817 9.17l1.47-2.544a.56.56 0 0 0 0-.566l-1.633-2.83a.57.57 0 0 0-.49-.283h-6.207L12.487.402a.57.57 0 0 0-.49-.284H8.732a.56.56 0 0 0-.49.284L5.139 5.775h-2.94a.56.56 0 0 0-.49.284L.077 8.887a.56.56 0 0 0 0 .567L3.18 14.83l-1.47 2.545a.56.56 0 0 0 0 .566l1.634 2.83a.57.57 0 0 0 .49.283h6.205l1.47 2.545a.57.57 0 0 0 .49.284h3.266a.57.57 0 0 0 .49-.284l3.104-5.375h2.94a.57.57 0 0 0 .49-.283l1.634-2.828a.55.55 0 0 0-.004-.568M8.733.686l1.634 2.828-1.634 2.828H21.8L20.164 9.17H7.425L5.63 6.06Zm1.306 19.801-6.205-.002 1.634-2.83h3.265L2.201 6.344h3.267q3.182 5.517 6.367 11.032zm10.124-5.66L18.53 12l-6.532 11.315-1.634-2.83c2.129-3.673 4.25-7.351 6.373-11.028h3.592l3.102 5.374z`})})}function YH(){return(0,R.jsx)(`svg`,{"aria-hidden":`true`,focusable:`false`,viewBox:`0 0 24 24`,className:`size-full`,fill:`currentColor`,children:(0,R.jsx)(`path`,{d:`M21.765.351C22.998.351 24 1.353 24 2.586S22.998 4.82 21.765 4.82h-1.974c-.15 0-.26-.12-.26-.26V2.586A2.237 2.237 0 0 1 21.765.35M9.41 13.388l8.447-8.377c.16-.16.07-.471-.14-.471h-4.55s-.1.02-.14.06l-9.099 9.029c-.14.14-.35.02-.35-.21V4.81c0-.15-.1-.27-.221-.27H.22c-.12 0-.22.12-.22.27v18.57c0 .15.1.27.22.27h3.137c.12 0 .22-.12.22-.27v-3.79c0-.08.03-.16.08-.21l2.826-2.796c.07-.07.16-.08.241-.03l7.546 5.551a8.9 8.9 0 0 0 4.018 1.493c.12.01.23-.11.23-.27V19.76c0-.14-.08-.25-.19-.26a5.8 5.8 0 0 1-2.355-.942l-6.533-4.73c-.14-.09-.15-.32-.03-.441`})})}var XH=3e4,ZH=45e3;function QH(e,t){return t?AbortSignal.any([t,AbortSignal.timeout(e)]):AbortSignal.timeout(e)}var $H=`text-[9px]`,eU={claude:`text-fg/75! size-[14px]! translate-y-0!`,codex:`text-fg/75! size-[12.75px]! translate-y-0!`};function tU(){let e=ct({queryKey:[`quota`],queryFn:()=>Y.quota(),staleTime:1e4}),t=ct({queryKey:[`authStatus`],queryFn:()=>Y.authStatus(),staleTime:3e4});return[`claude`,`codex`].some(n=>nU(e.data?.[n],t.data?.[n],e.isLoading))}function nU(e,t,n){return t===`signed-out`||!e&&n?!1:!!e&&e.status===`ok`&&e.windows.length>0}function rU(){let e=qe(),t=(0,L.useRef)(null),[n,r]=(0,L.useState)(!1),i=ct({queryKey:[`quota`],queryFn:({signal:e})=>Y.quota(void 0,{signal:QH(XH,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=ct({queryKey:[`authStatus`],queryFn:({signal:e})=>Y.authStatus(void 0,{signal:QH(XH,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:QH(ZH)}).then(t=>e.setQueryData([`quota`],t)),e.refetchQueries({queryKey:[`authStatus`]})]).then(()=>{}).catch(()=>{}).finally(()=>{t.current=null,r(!1)});t.current=i};return(0,R.jsxs)(`div`,{"data-quota-bar":!0,className:`flex shrink-0 items-center gap-3 ${$H}`,children:[(0,R.jsx)(iU,{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,R.jsx)(iU,{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 iU({backend:e,quota:t,auth:n,email:r,loading:i,fetching:a,onRecheck:o}){let s=rH[e];if(!nU(t,n,i))return null;let c=oU(100-cU(t.windows).usedPercent);return(0,R.jsx)(R.Fragment,{children:(0,R.jsxs)(CV,{onOpenChange:e=>{e&&o()},children:[(0,R.jsx)(wV,{asChild:!0,children:(0,R.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,R.jsx)(zH,{backend:e,className:eU[e]}),(0,R.jsxs)(`span`,{className:`tabular-nums ${lU(c)}`,children:[c,`%`]})]})}),(0,R.jsxs)(EV,{side:`bottom`,align:`start`,className:`w-[min(15rem,calc(100vw-1.5rem))] p-3 text-[11px] leading-relaxed text-fg`,children:[(0,R.jsxs)(`div`,{className:`mb-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5 font-medium`,children:[(0,R.jsx)(zH,{backend:e}),(0,R.jsx)(`span`,{children:s}),t?.planType&&(0,R.jsxs)(`span`,{className:`text-muted-70`,children:[`· `,uU(t.planType),` plan`]}),a&&(0,R.jsx)(M_,{size:11,className:`animate-spin text-muted-60`,"aria-label":`Rechecking`})]}),r&&(0,R.jsx)(`div`,{"data-quota-account":!0,className:`truncate text-muted-70 select-text`,title:r,children:r})]}),(0,R.jsxs)(`ul`,{className:`flex flex-col gap-1`,children:[t.windows.map(e=>{let t=oU(100-e.usedPercent),n=dU(e);return(0,R.jsxs)(`li`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`span`,{className:`text-muted-80`,children:e.label}),(0,R.jsxs)(`span`,{className:`flex items-center gap-2 tabular-nums`,children:[(0,R.jsxs)(`span`,{className:lU(t),children:[t,`% left`]}),n&&(0,R.jsxs)(`span`,{className:`text-muted-55`,children:[`resets `,n]})]})]},e.key)}),t.detail&&(0,R.jsx)(`li`,{className:`pt-1 text-muted-55`,children:t.detail})]})]})]})})}function aU(){let e=ct({queryKey:[`quota`],queryFn:({signal:e})=>Y.quota(void 0,{signal:QH(XH,e)}),refetchInterval:3e4,staleTime:1e4}),t=ct({queryKey:[`authStatus`],queryFn:({signal:e})=>Y.authStatus(void 0,{signal:QH(XH,e)}),staleTime:3e4}),n=[`claude`,`codex`].flatMap(n=>{let r=e.data?.[n];return nU(r,t.data?.[n],e.isLoading)?r.windows.map(e=>({key:`${n}-${e.key}`,label:`${rH[n]} · ${e.label}`,left:oU(100-e.usedPercent)})):[]});return n.length===0?null:(0,R.jsx)(`ul`,{"data-quota-meters":!0,className:`m-0 flex list-none flex-col gap-[9px] p-0`,children:n.map(e=>(0,R.jsxs)(`li`,{className:`flex items-center gap-2.5 text-[13.5px] leading-[19px]`,children:[(0,R.jsx)(`span`,{className:`w-[108px] shrink-0 truncate text-muted`,children:e.label}),(0,R.jsx)(`span`,{className:`h-[5px] min-w-0 flex-1 overflow-hidden rounded-full bg-border`,"aria-hidden":!0,children:(0,R.jsx)(`span`,{className:`block h-full rounded-full ${e.left<=8?`bg-danger`:`bg-fg/75`}`,style:{width:`${e.left}%`}})}),(0,R.jsxs)(`span`,{className:`w-[64px] shrink-0 text-right tabular-nums ${e.left<=8?`text-danger`:`text-fg`}`,children:[e.left,`% left`]})]},e.key))})}function oU(e){return Math.max(0,Math.min(100,Math.round(e)))}var sU=25;function cU(e){return e.find(e=>e.key===`5h`)??e.reduce((e,t)=>t.usedPercent>e.usedPercent?t:e)}function lU(e){return e<=8?`text-danger`:e<=sU?`text-accent`:`text-fg/70`}function uU(e){return e&&e[0].toUpperCase()+e.slice(1)}function dU(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 fU=`frizz:supervisor-status-wake`,pU=`frizz:reload-after-update-restart`,mU=`frizz:update-restart-from-version`;function hU(e,t){return t.version===e?{kind:`previous-kept`}:{kind:`successor-failed`,version:t.version}}function gU(e){if(e.kind===`previous-kept`)return{summary:`Frizz kept running the previous version`,detail:`Frizz kept running the previous version, and your threads are unaffected.`};let t=e.version?`Frizz ${e.version}`:`The new version of Frizz`;return{summary:`${t} failed to start`,detail:`${t} came up but could not start its board, and the previous version is gone. Restart Frizz from the terminal (npx frizz) and check its log for the reason.`}}function _U(e){return e?.artifactDigest??e?.version??null}function vU(e,t){if(e===null||t?.state!==`ready`)return!1;let n=_U(t);return n!==null&&n!==e}var yU=3*6e4,bU={silentSince:null,silentForMs:0,stalled:!1};function xU(e,t,n=yU){if(!t.restarting||t.answered)return bU;let r=e.silentSince??t.at,i=Math.max(0,t.at-r);return{silentSince:r,silentForMs:i,stalled:i>=n}}function SU(e,t){return e.ackedAt!==null&&t.requestedAt>=e.ackedAt}function CU(e,t){return e.attempt&&!(SU(e.attempt,t)&&wU(e.attempt,t))?e:{state:t.state,message:t.message??null,attempt:null}}function wU(e,t){if(t.state!==`ready`)return!0;let n=t.artifactDigest??t.version??null;return e.build!=null&&n!==null&&n!==e.build}function TU(e,t){return t.state===`ready`&&e.attempt===null}function EU(e){return e!==null}function DU(e){return e?.updateRestart===!0&&e.updateAvailable!==!1}function OU(e){return e?.dev===!0}async function kU(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 AU(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 jU(e=fetch){return AU(`/_frizz/control/restart`,e)}function MU(e=fetch){return AU(`/_frizz/control/update-restart`,e)}var NU=8e3,PU=500,FU=[`supervisorStatus`];function IU(e,t){return e===`restarting`||t?PU:NU}var LU=lt({queryKey:FU,queryFn:async()=>{let e=Date.now(),t=await kU();return t?{...t,requestedAt:e}:null},refetchInterval:e=>IU(e.state.data?.state,X.controlPlaneRestartAttempt!==null),staleTime:e=>IU(e.state.data?.state,X.controlPlaneRestartAttempt!==null)});function RU(){return ct(LU)}var zU=null;function BU(e){zU||(zU=e,window.addEventListener(fU,()=>{e.refetchQueries({queryKey:FU,exact:!0})}))}function VU(e,t){let n=e=>{let t=e&&/^v?(\d+)\.(\d+)\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/u.exec(e);return t?[Number(t[1]),Number(t[2])]:null},r=n(e),i=n(t);return r!==null&&i!==null&&(r[0]!==i[0]||r[1]!==i[1])}function HU(e){return DU(e)&&VU(e?.version,e?.updateVersion)}var UU=`Install the latest version of Frizz. Your running threads will not be affected.`,WU=`A newer version of Frizz is available. Your running threads will not be affected.`,GU=`Restart Frizz. Your running threads will not be affected.`,KU=`There is no newer version of Frizz to install.`,qU=`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)]`,JU=`absolute -top-[7px] left-4 h-3 w-3 rotate-45 border-l border-t bg-elevated`,YU=`sm:w-[min(23rem,calc(100vw-1.5rem))]`,XU=`sm:w-[min(34rem,calc(100vw-1.5rem))]`,ZU=`rounded-xl bg-elevated p-3.5 shadow-xl shadow-shadow-ink/45`;function QU({open:e,update:t,current:n=!1,version:r,updateVersion:i}){if(!e)return null;let a=n?`Frizz is up to date`:t?`Update Frizz`:`Restart Frizz`,o=t?i:void 0;return(0,R.jsxs)(`div`,{id:`update-restart-popover`,role:`tooltip`,"aria-label":a,className:`${qU} ${YU} ${ZU} border border-border-strong`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`${JU} border-border-strong`}),(0,R.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,R.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-fg/10 text-fg`,children:n?(0,R.jsx)(e_,{"aria-hidden":`true`,size:14,strokeWidth:2.25}):(0,R.jsx)(J_,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,R.jsx)(`span`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:a}),r&&(0,R.jsx)(`span`,{className:`font-mono text-[11px] leading-snug text-muted`,children:o?`${r} → ${o}`:r})]})]}),(0,R.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:n?KU:t?o?WU:UU:GU})]})}var $U={kind:`previous-kept`};function eW({update:e,message:t,outcome:n=$U,onDismiss:r,mobile:i=!1}){return(0,R.jsxs)(`div`,{role:`alert`,className:`${i?`mx-[18px] my-3 text-left font-sans`:`${qU} ${XU}`} ${ZU} border border-danger-fill/45`,children:[!i&&(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`${JU} border-danger-fill/45`}),(0,R.jsxs)(`div`,{className:`relative flex items-center gap-2.5`,children:[(0,R.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-danger-fill/15 text-danger-soft`,children:(0,R.jsx)(ov,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,R.jsx)(`span`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:e?`Update failed`:`Restart failed`}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,onClick:r,className:`icon-hover-outline -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,R.jsx)(cv,{"aria-hidden":`true`,size:14,strokeWidth:2.25})})]}),(0,R.jsx)(`p`,{className:`relative mt-2.5 text-[12px] leading-relaxed text-muted`,children:gU(n).detail}),(0,R.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 tW({update:e,busy:t,current:n=!1,version:r,updateVersion:i,onFocus:a,onBlur:o,onClick:s}){return(0,R.jsxs)(`button`,{type:`button`,"aria-describedby":`update-restart-popover`,"aria-label":n?`Frizz is up to date`:e?`Update Frizz`:`Restart Frizz`,disabled:t,"aria-busy":t||void 0,"aria-disabled":n||void 0,className:`relative ${PH}${n?` pointer-events-none opacity-40`:``}`,onFocus:a,onBlur:o,onClick:n?void 0:s,children:[(0,R.jsx)(J_,{size:14,"aria-hidden":`true`,className:t?`animate-spin`:void 0}),e&&!t&&VU(r,i)&&(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`absolute right-[2px] top-[2px] h-[4px] w-[4px] rounded-full bg-accent`})]})}function nW(){let e=gr(X),[t,n]=(0,L.useState)(!1),[r,i]=(0,L.useState)(),[a,o]=(0,L.useState)(),s=(0,L.useRef)(null),c=RU().data??null,l=DU(c),u={version:c?.version,updateVersion:c?.updateVersion},d=s.current!==null&&e.controlPlaneState===`failed`,f=d?e.controlPlaneMessage??`Frizz did not become ready`:void 0,p=r??f,m=p&&p!==a?p:void 0,h=!r&&d&&s.current?hU(s.current.version,{version:c?.version}):$U,g=!l&&!t&&!m;return{visible:EU(c),update:l,busy:t,current:g,version:u.version,updateVersion:u.updateVersion,shownError:m,outcome:h,dismiss:()=>o(m),run:async()=>{if(t||g)return;s.current={version:c?.version},n(!0),i(void 0),o(void 0);let e=`${window.location.pathname}${window.location.search}${window.location.hash}`;l&&(X.controlPlaneState=`restarting`,X.controlPlaneMessage=null,X.controlPlaneRestartAttempt={startedAt:Date.now(),ackedAt:null,build:_U(c)});try{if(l?await MU():await jU(),l){sessionStorage.setItem(pU,e),s.current.version?sessionStorage.setItem(mU,s.current.version):sessionStorage.removeItem(mU);let t=X.controlPlaneRestartAttempt;t&&(X.controlPlaneRestartAttempt={...t,ackedAt:Date.now()}),window.dispatchEvent(new Event(fU)),n(!1)}else window.location.replace(e)}catch(e){l&&(X.controlPlaneRestartAttempt=null,X.controlPlaneState=`ready`,X.controlPlaneMessage=null);let t=e.message.slice(0,140);n(!1),i(t),Z(`${l?`Update & Restart`:`Restart Frizz`} failed`)}}}}function rW(){let[e,t]=(0,L.useState)(!1),n=(0,L.useRef)(null),r=nW();return r.visible?(0,R.jsxs)(`div`,{ref:n,className:`relative`,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[(0,R.jsx)(tW,{update:r.update,busy:r.busy,current:r.current,version:r.version,updateVersion:r.updateVersion,onFocus:()=>t(!0),onBlur:()=>t(!1),onClick:()=>{t(!1),r.run()}}),r.shownError&&(0,R.jsx)(eW,{update:r.update,message:r.shownError,outcome:r.outcome,onDismiss:r.dismiss}),(0,R.jsx)(QU,{open:e&&!r.shownError,update:r.update,current:r.current,version:r.version,updateVersion:r.updateVersion})]}):null}function iW(){return(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`h-3 w-px shrink-0 bg-border`})}function aW({text:e,title:t,className:n}){return(0,R.jsx)(`span`,{dir:`rtl`,className:`block min-w-0 overflow-hidden text-ellipsis whitespace-nowrap ${n??``}`,title:t,children:(0,R.jsx)(`span`,{dir:`ltr`,className:`[unicode-bidi:isolate]`,children:e})})}function oW(){let e=ME(),t=UG(e),n=tU(),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,R.jsxs)(`div`,{"data-status-row":!0,className:`mb-2.5 flex min-w-0 items-center gap-3 text-[12px]`,children:[(0,R.jsx)(iC,{to:`/`,title:`All projects`,"aria-label":`All projects`,className:`${PH} -ml-px`,children:(0,R.jsx)(O_,{size:14,"aria-hidden":`true`})}),(0,R.jsx)(iW,{}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Settings`,title:`Settings`,className:PH,onClick:()=>X.showSettings=!0,children:(0,R.jsx)(Q_,{size:14,"aria-hidden":`true`})}),(0,R.jsx)(rW,{}),n&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(iW,{}),(0,R.jsx)(rU,{})]}),(0,R.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,R.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,R.jsx)(aW,{text:i})}):i?(0,R.jsx)(aW,{text:i,title:i,className:`font-semibold text-fg/90`}):(0,R.jsx)(`span`,{className:`identity-placeholder w-24`,"aria-hidden":`true`})})]})}var sW=fr({at:{}}),cW=12e3,lW=new Map;function uW(e,t=Date.now()){sW.at[e]=t;let n=lW.get(e);n!==void 0&&clearTimeout(n),lW.set(e,setTimeout(()=>{lW.delete(e),delete sW.at[e]},cW))}function dW(e){let t=lW.get(e);t!==void 0&&(clearTimeout(t),lW.delete(e)),delete sW.at[e]}function fW(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 pW(){return gr(sW).at}function mW(e,t,n=Date.now()){let r=t!==void 0&&fW(e,t,n);return!r&&e.deliveryInFlight!==!0?e:{...e,runtime:`running`,needsYou:!1,pendingAsk:void 0,pendingQuestion:!1,actionableInteraction:!1,lastUserAt:r?new Date(t).toISOString():e.lastUserAt}}function hW(e){let t=pW();return(0,L.useMemo)(()=>e.map(e=>mW(e,t[e.id])),[e,t])}var gW=0;function _W(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():(gW+=1,`browser-${Date.now()}-${gW}`)}function vW({optimistic:e,request:t,success:n,failure:r}){e(),t().then(()=>n?.(),e=>r(e instanceof Error?e:Error(String(e))))}var yW=new Map;function bW(e,t){let n=(yW.get(e)??Promise.resolve()).then(t,t);return yW.set(e,n.then(()=>{},()=>{})),n}var xW=[300,800,1800,3500],SW=12e4,CW=e=>new Promise(t=>{setTimeout(t,e)});async function wW(e,t,n=CW){for(let r=0;;r++){try{await e()}catch(e){if(r>=xW.length||!Fm(e))throw e;t(),await n(xW[r]);continue}t();return}}function TW(e,t,n,r,i,a=SW,o){let s=new AbortController,c=setTimeout(()=>s.abort(Error(`Frizz did not answer this send`)),a);return Y.followUp({slug:e,sessionId:Cg(X.board,e)?.sessionId??``,message:t,deliveryId:n,freshProcess:r,interrupt:i,...o?{supersedes:o}:{}},{signal:s.signal}).finally(()=>clearTimeout(c))}function EW(e,t,n,r,i,a){return wW(()=>TW(e,t,n,r,i,SW,a),()=>uW(e))}function DW(e,t,n,r={}){let i=n.trim();if(!i)return!1;let a=_W();return vW({optimistic:()=>{r.onOptimistic?.(),lte(e,t,i,{scrollToBottom:r.scrollToBottom,deliveryId:a}),uW(t),Y.markRead({slug:t}).catch(()=>{})},request:()=>bW(t,()=>EW(t,i,a,r.freshProcess,r.interrupt,r.supersedes)),success:()=>r.onSuccess?.(),failure:n=>{zE(e,t,i,a),dW(t),r.onRollback?.({deliveryId:a,text:i,kept:Im(n)}),Z(r.failureToast?.(n.message)??`Steer failed — ${n.message.slice(0,160)}`)}}),!0}function OW(e){let t=qe(),[n,r]=(0,L.useState)(0);return{submit:(0,L.useCallback)((n,i={})=>DW(t,e,n,{...i,onOptimistic:()=>{r(e=>e+1),i.onOptimistic?.()},onSuccess:()=>{r(e=>Math.max(0,e-1)),i.onSuccess?.()},onRollback:e=>{r(e=>Math.max(0,e-1)),i.onRollback?.(e)}}),[t,e]),pending:n>0}}function kW(e,t){return new Promise(n=>{DW(e,t,`Continue exactly where you left off.`,{onSuccess:()=>{Z(`Retrying…`),n()},onRollback:()=>n(),failureToast:e=>`Retry failed: ${e.slice(0,80)}`})||n()})}function AW(e,t=`pull`){let n=/^([A-Za-z0-9][\w.-]*)\/([A-Za-z0-9][\w.-]*)#(\d+)$/.exec(e.trim());return n?`https://github.com/${n[1]}/${n[2]}/${t===`issue`?`issues`:`pull`}/${n[3]}`:null}function jW(e){return Ku(e).length>0&&Gu(e).length===0}var MW=`Waiting for an external update.`,NW=`Awaiting human`,PW=`Done`;function FW(e){let t=new Set;return e.flatMap(e=>{if(e.kind!==`pr`&&e.kind!==`issue`)return[];let n=e.value.trim();return!n||t.has(`${e.kind}:${n}`)?[]:(t.add(`${e.kind}:${n}`),[{ref:n,url:AW(n,e.kind===`issue`?`issue`:`pull`)}])})}function IW(e){let t=(e.body??``).split(/\n\s*\n/).map(e=>e.trim()).find(Boolean);return t?zW(LW(t.replace(/\s*\n\s*/g,` `))):null}function LW(e){if(e.length<=RW)return e;let t=e.slice(0,RW),n=t.lastIndexOf(` `);return`${(n>RW/2?t.slice(0,n):t).replace(/[.,;:]$/,``)}…`}var RW=240;function zW(e){let t=(e.split(/\s/,1)[0]??``).replace(/[.,:;]+$/,``);return/[^a-zA-Z]/.test(t)||/[A-Z]/.test(t.slice(1))||BW.has(t)?e:e.charAt(0).toUpperCase()+e.slice(1)}var BW=new Set([`npm`,`npx`,`pnpm`,`nub`,`nubx`,`gh`,`git`,`node`,`bun`,`tsc`,`vite`,`curl`,`ssh`]);function VW(e){return e&&UW(e)||null}var HW=new Set([...Lu,`shells`,`agents`,`timers`,`prs`,`issues`,`for`,`title`,`status`,`needs_input`,`needs-input`]);function UW(e){return e.split(`
|
|
205
205
|
`).filter(e=>{let t=/^\s*([a-z][a-z_-]*):/i.exec(e)?.[1]?.toLowerCase();return!(t&&HW.has(t))}).join(`
|
|
206
|
-
`).trim()}function WW(e){let t=t=>e.filter(e=>e.kind===t&&e.value.trim()).length,n=[GW(t(`step`),`step from you`,`steps from you`),GW(t(`question`),`answer from you`,`answers from you`),...FW(e).map(e=>e.ref),GW(t(`shell`),`background shell`,`background shells`),GW(t(`agent`),`sub-agent`,`sub-agents`),GW(t(`timer`),`timer`,`timers`)].filter(e=>e!==null);return n.length>0?`waiting on ${KW(n)}`:null}function GW(e,t,n){return e<=0?null:e===1?`a ${t}`:`${e} ${n}`}function KW(e){return e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function qW(e){let t=e.find(e=>e.kind===`pr`);if(t)return`PR ${t.value}`;let n=e.find(e=>e.kind===`issue`);return n?`Issue ${n.value}`:null}var JW=fr({at:{}}),YW=12e3,XW=new Map;function ZW(e,t=Date.now()){JW.at[e]=t;let n=XW.get(e);n!==void 0&&clearTimeout(n),XW.set(e,setTimeout(()=>{XW.delete(e),delete JW.at[e]},YW))}function QW(e){let t=XW.get(e);t!==void 0&&(clearTimeout(t),XW.delete(e)),delete JW.at[e]}function $W(){return JW.at}function eG(){return gr(JW).at}function tG(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 nG(e){let t=eG();return(0,L.useMemo)(()=>e.map(e=>tG(e,t[e.id])),[e,t])}var rG=`flex h-[19px] w-[19px] items-center justify-center rounded text-muted opacity-70 outline-none transition-[color,opacity] hover:bg-panel-2 hover:text-fg hover:opacity-100`,iG=`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 aG(){let e=gr(X),t=nG(hW(FE(ME()?.threads??[]))),n=bO(t,gr(zD).queueOrder),r=tO(iO(t)),i=e.sidebarCollapsed,a=n.active,o=n.snoozed,s=n.inactive,c=(0,L.useRef)(null),[l,u]=(0,L.useState)(null),d=(0,L.useRef)(null),f=(0,L.useCallback)(()=>{let e=yz(),t=d.current;if(t)if(Zte(e.find(e=>e.id===t.id),window.scrollY,t.landedY,40))d.current=null;else{u(t.id);return}let n=vz(e,window.innerHeight,bz());u(e=>e===n?e:n)},[]);(0,L.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,L.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=Qte(n.top,n.bottom,r.top,r.bottom);Math.abs(i)>.5&&(e.scrollTop+=i)},[l]);let p=(0,L.useCallback)(e=>{d.current={id:e,landedY:Nh(e)??window.scrollY},u(e)},[]);return(0,R.jsx)(`aside`,{className:iG,children:(0,R.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,R.jsxs)(`div`,{className:`mb-5 shrink-0 px-0.5`,children:[(0,R.jsx)(oW,{}),(0,R.jsx)(kH,{})]}),(0,R.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,R.jsxs)(`section`,{"aria-label":`Pinned`,children:[(0,R.jsx)(oG,{label:`Pinned`,count:n.pinned.length}),n.pinned.map(e=>(0,R.jsxs)(`div`,{children:[(0,R.jsx)(pG,{t:e,active:l===e.id,onQueueNavigate:p}),(0,R.jsx)(vG,{t:e})]},e.id)),a.length>0&&(0,R.jsx)(`hr`,{className:`my-3 border-border/50`})]}),a.length>0?(()=>{let{running:e,rested:t}=yO(a),n=e=>t=>(0,R.jsxs)(`div`,{children:[(0,R.jsx)(pG,{t,active:l===t.id,onQueueNavigate:p,restedAge:e}),(0,R.jsx)(vG,{t})]},t.id);return(0,R.jsxs)(R.Fragment,{children:[t.length>0&&(0,R.jsx)(oG,{label:`Queue`,count:t.length}),t.map(n(!0)),e.length>0&&t.length>0&&(0,R.jsx)(`hr`,{className:`my-3 border-border/50`}),e.length>0&&(0,R.jsx)(oG,{label:`Running`,count:e.length}),e.map(n(!1))]})})():n.pinned.length===0?(0,R.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,R.jsxs)(`section`,{"aria-label":`Snoozed`,children:[(0,R.jsx)(`hr`,{className:`my-3 border-border/50`}),(0,R.jsx)(oG,{label:`Snoozed`,count:o.length,collapsed:i.snoozed,onToggle:()=>X.sidebarCollapsed.snoozed=!X.sidebarCollapsed.snoozed}),!i.snoozed&&o.map(e=>(0,R.jsxs)(`div`,{children:[(0,R.jsx)(pG,{t:e,active:l===e.id,onQueueNavigate:p}),(0,R.jsx)(vG,{t:e})]},e.id))]}),s.length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`hr`,{className:`my-3 border-border/50`}),(0,R.jsx)(oG,{label:`Done`,count:s.length,collapsed:i.inactive,onToggle:()=>X.sidebarCollapsed.inactive=!X.sidebarCollapsed.inactive}),!i.inactive&&(0,R.jsx)(lG,{threads:s,railRef:c,activeId:l,onQueueNavigate:p})]}),r.length>0&&(0,R.jsxs)(`section`,{"aria-label":`External`,children:[(0,R.jsx)(`hr`,{className:`my-3 border-border/50`}),(0,R.jsx)(oG,{label:`External`,count:r.length,collapsed:i.external,onToggle:()=>X.sidebarCollapsed.external=!X.sidebarCollapsed.external}),!i.external&&r.map(e=>(0,R.jsx)(pG,{t:e,active:l===e.id,onQueueNavigate:p,restedAge:!0},e.id))]})]})]})})}function oG({label:e,count:t,collapsed:n,onToggle:r}){let i=(0,R.jsxs)(R.Fragment,{children:[r?(0,R.jsx)(r_,{size:11,className:`transition-transform ${n?``:`rotate-90`}`}):(0,R.jsx)(`span`,{className:`w-[11px] shrink-0`,"aria-hidden":!0}),(0,R.jsx)(`span`,{children:e}),(0,R.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,R.jsx)(`button`,{onClick:r,className:`${a} transition-colors hover:text-fg`,children:i}):(0,R.jsx)(`div`,{className:a,children:i})}var sG=27,cG=8;function lG({threads:e,railRef:t,activeId:n,onQueueNavigate:r}){let i=(0,L.useRef)(null),[a,o]=(0,L.useState)(0),s=yD({count:e.length,getScrollElement:()=>t.current,getItemKey:t=>e[t]?.id??t,estimateSize:()=>sG,overscan:cG,scrollMargin:a});return(0,L.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,R.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,R.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,R.jsx)(pG,{t:i,active:n===i.id,onQueueNavigate:r}),(0,R.jsx)(vG,{t:i})]},i.id):null})})}var uG=16,dG=12;function fG({title:e,children:t}){let n=e.trimEnd(),r=n.lastIndexOf(` `)+1,i=n.length-r<=uG?r:n.length-dG;return i>=n.length?(0,R.jsxs)(R.Fragment,{children:[e,t]}):(0,R.jsxs)(R.Fragment,{children:[n.slice(0,i),(0,R.jsxs)(`span`,{className:`whitespace-nowrap`,children:[n.slice(i),t]})]})}var pG=(0,L.memo)(function({t:e,legacy:t,active:n=!1,onQueueNavigate:r,restedAge:i=!1}){let a=!t&&e.foreign===!0,o=!t&&_f(e),s=!t&&gO(e)===`archived`,c=o||s,l=!t&&XD(e),u=!t&&_O(e),d=!t&&aO(e);return(0,R.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-hover after:opacity-0 after:transition-opacity hover:after:opacity-100 ${t?`opacity-80`:c?`sidebar-row-dim`:``}`,children:[(0,R.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,R.jsx)(`span`,{"data-sidebar-scroll-marker":!0,className:`absolute inset-y-0 left-1 w-[2px] rounded-full bg-accent`})}),(0,R.jsxs)(`button`,{onClick:()=>{if(e.needsYou&&tg(e.id)){r?.(e.id);return}Xh(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,R.jsx)(`span`,{className:`w-4 h-[19px] shrink-0 flex items-center justify-center`,children:(0,R.jsx)(CG,{t:e,legacy:t})}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 flex flex-col`,children:(0,R.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-3`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-[13px] leading-[19px] ${l?`text-provisional`:c?`text-fg/75`:`text-fg/90`}`,children:(0,R.jsxs)(fG,{title:UD(e),children:[!t&&(0,R.jsx)(zH,{backend:e.backend,model:e.model,className:`ml-1`}),a&&(0,R.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,R.jsx)(yG,{status:e.archived?`archived`:e.status})]})}),i&&(0,R.jsx)(mG,{t:e,yieldsToRetry:!0}),d&&!i&&(0,R.jsx)(gG,{})]})})]}),t&&(0,R.jsx)(`div`,{className:`absolute right-1 top-1 hidden group-hover:flex items-stretch rounded-md bg-panel shadow-sm shadow-shadow-ink/30`,children:(0,R.jsx)(lR,{slug:e.id,size:`sm`})}),!t&&(0,R.jsxs)(`div`,{className:`absolute right-1.5 top-1 hidden items-center gap-0.5 bg-bg group-hover:flex group-focus-within:flex before:pointer-events-none before:absolute before:inset-y-0 before:right-full before:w-3 before:bg-linear-to-r before:from-transparent before:to-bg`,children:[!a&&!d&&(0,R.jsx)(_G,{t:e,className:`-mr-0.5`}),(0,R.jsx)(LP,{slug:e.id,size:12,className:rG}),u&&(0,R.jsx)(hG,{slug:e.id}),!a&&d&&(0,R.jsx)(_G,{t:e})]})]})});function mG({t:e,yieldsToRetry:t}){let n=RO(),r=$D(e),i=EO(r,n);return!r||!i?null:(0,R.jsx)(`time`,{dateTime:r,"data-rail-rested-age":!0,title:CO(r,n)??void 0,"aria-label":`Rested ${CO(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 hG({slug:e}){let t=qe(),[n,r]=(0,L.useState)(!1);return(0,R.jsx)(IP,{label:`Retry — resume this session where it left off`,children:(0,R.jsx)(`button`,{"data-sidebar-retry":e,"aria-label":`Retry exited session`,disabled:n,onMouseDown:e=>e.preventDefault(),onClick:n=>{n.stopPropagation(),r(!0),kW(t,e).finally(()=>r(!1))},className:`${rG} disabled:opacity-50`,children:n?(0,R.jsx)(M_,{size:13,className:`animate-spin`}):(0,R.jsx)(X_,{size:13})})})}function gG(){return(0,R.jsx)(`span`,{"aria-hidden":!0,"data-rail-pin-mark":!0,className:`-ml-1 flex h-[19px] w-[19px] shrink-0 items-center justify-center self-start text-muted opacity-55 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0`,children:(0,R.jsx)(W_,{size:12,fill:`currentColor`})})}function _G({t:e,className:t=``}){let n=aO(e),[r,i]=(0,L.useState)(!1);return(0,R.jsx)(IP,{label:n?`Unpin — return this thread to the rail's bands`:`Pin — keep this thread at the very top`,children:(0,R.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:`${rG} disabled:opacity-50 ${t}`,children:n?(0,R.jsx)(U_,{size:12,fill:`currentColor`}):(0,R.jsx)(W_,{size:12})})})}function vG({t:e}){let t=vk(e.subAgents??[],`rail`);return t.length===0?null:(0,R.jsx)(`div`,{className:`flex flex-col`,children:t.map(t=>(0,R.jsx)(xk,{kind:`AGENT`,label:t.label,state:t.state,density:`rail`,depth:t.depth,startedAt:t.startedAt,parentSlug:e.id,onOpen:()=>Jh(e.id,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}),onDismiss:zP(e.id,t),title:t.subagentType?`[${t.subagentType}] ${t.label}`:t.label},t.id))})}function yG({status:e}){let t=e===`archived`?`Done`:e;return(0,R.jsx)(`span`,{className:`petite-caps ml-1.5 inline-block rounded border px-1 align-[2px] leading-[14px] text-[9.5px] ${HD[e]??`text-muted border-border`}`,children:t})}function bG(e,t,n=null){return[[t,WW(e.lastFence?.kind===`awaiting`?e.lastFence.hints:[]),n].filter(e=>!!e).join(` — `),xG(e)].filter(e=>!!e).join(`
|
|
206
|
+
`).trim()}function WW(e){let t=t=>e.filter(e=>e.kind===t&&e.value.trim()).length,n=[GW(t(`step`),`step from you`,`steps from you`),GW(t(`question`),`answer from you`,`answers from you`),...FW(e).map(e=>e.ref),GW(t(`shell`),`background shell`,`background shells`),GW(t(`agent`),`sub-agent`,`sub-agents`),GW(t(`timer`),`timer`,`timers`)].filter(e=>e!==null);return n.length>0?`waiting on ${KW(n)}`:null}function GW(e,t,n){return e<=0?null:e===1?`a ${t}`:`${e} ${n}`}function KW(e){return e.length<=1?e.join(``):`${e.slice(0,-1).join(`, `)} and ${e[e.length-1]}`}function qW(e){let t=e.find(e=>e.kind===`pr`);if(t)return`PR ${t.value}`;let n=e.find(e=>e.kind===`issue`);return n?`Issue ${n.value}`:null}var JW=fr({at:{}}),YW=12e3,XW=new Map;function ZW(e,t=Date.now()){JW.at[e]=t;let n=XW.get(e);n!==void 0&&clearTimeout(n),XW.set(e,setTimeout(()=>{XW.delete(e),delete JW.at[e]},YW))}function QW(e){let t=XW.get(e);t!==void 0&&(clearTimeout(t),XW.delete(e)),delete JW.at[e]}function $W(){return JW.at}function eG(){return gr(JW).at}function tG(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 nG(e){let t=eG();return(0,L.useMemo)(()=>e.map(e=>tG(e,t[e.id])),[e,t])}var rG=`flex h-[19px] w-[19px] items-center justify-center rounded text-muted opacity-70 outline-none transition-[color,opacity] hover:bg-panel-2 hover:text-fg hover:opacity-100`,iG=`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 aG(){let e=gr(X),t=nG(hW(FE(ME()?.threads??[]))),n=yO(t,gr(RD).queueOrder),r=eO(rO(t)),i=e.sidebarCollapsed,a=n.active,o=n.snoozed,s=n.inactive,c=(0,L.useRef)(null),[l,u]=(0,L.useState)(null),d=(0,L.useRef)(null),f=(0,L.useCallback)(()=>{let e=vz(),t=d.current;if(t)if(Qte(e.find(e=>e.id===t.id),window.scrollY,t.landedY,40))d.current=null;else{u(t.id);return}let n=_z(e,window.innerHeight,yz());u(e=>e===n?e:n)},[]);(0,L.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,L.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=$te(n.top,n.bottom,r.top,r.bottom);Math.abs(i)>.5&&(e.scrollTop+=i)},[l]);let p=(0,L.useCallback)(e=>{d.current={id:e,landedY:Nh(e)??window.scrollY},u(e)},[]);return(0,R.jsx)(`aside`,{className:iG,children:(0,R.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,R.jsxs)(`div`,{className:`mb-5 shrink-0 px-0.5`,children:[(0,R.jsx)(oW,{}),(0,R.jsx)(kH,{})]}),(0,R.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,R.jsxs)(`section`,{"aria-label":`Pinned`,children:[(0,R.jsx)(oG,{label:`Pinned`,count:n.pinned.length}),n.pinned.map(e=>(0,R.jsxs)(`div`,{children:[(0,R.jsx)(pG,{t:e,active:l===e.id,onQueueNavigate:p}),(0,R.jsx)(vG,{t:e})]},e.id)),a.length>0&&(0,R.jsx)(`hr`,{className:`my-3 border-border/50`})]}),a.length>0?(()=>{let{running:e,rested:t}=vO(a),n=e=>t=>(0,R.jsxs)(`div`,{children:[(0,R.jsx)(pG,{t,active:l===t.id,onQueueNavigate:p,restedAge:e}),(0,R.jsx)(vG,{t})]},t.id);return(0,R.jsxs)(R.Fragment,{children:[t.length>0&&(0,R.jsx)(oG,{label:`Queue`,count:t.length}),t.map(n(!0)),e.length>0&&t.length>0&&(0,R.jsx)(`hr`,{className:`my-3 border-border/50`}),e.length>0&&(0,R.jsx)(oG,{label:`Running`,count:e.length}),e.map(n(!1))]})})():n.pinned.length===0?(0,R.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,R.jsxs)(`section`,{"aria-label":`Snoozed`,children:[(0,R.jsx)(`hr`,{className:`my-3 border-border/50`}),(0,R.jsx)(oG,{label:`Snoozed`,count:o.length,collapsed:i.snoozed,onToggle:()=>X.sidebarCollapsed.snoozed=!X.sidebarCollapsed.snoozed}),!i.snoozed&&o.map(e=>(0,R.jsxs)(`div`,{children:[(0,R.jsx)(pG,{t:e,active:l===e.id,onQueueNavigate:p}),(0,R.jsx)(vG,{t:e})]},e.id))]}),s.length>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`hr`,{className:`my-3 border-border/50`}),(0,R.jsx)(oG,{label:`Done`,count:s.length,collapsed:i.inactive,onToggle:()=>X.sidebarCollapsed.inactive=!X.sidebarCollapsed.inactive}),!i.inactive&&(0,R.jsx)(lG,{threads:s,railRef:c,activeId:l,onQueueNavigate:p})]}),r.length>0&&(0,R.jsxs)(`section`,{"aria-label":`External`,children:[(0,R.jsx)(`hr`,{className:`my-3 border-border/50`}),(0,R.jsx)(oG,{label:`External`,count:r.length,collapsed:i.external,onToggle:()=>X.sidebarCollapsed.external=!X.sidebarCollapsed.external}),!i.external&&r.map(e=>(0,R.jsx)(pG,{t:e,active:l===e.id,onQueueNavigate:p,restedAge:!0},e.id))]})]})]})})}function oG({label:e,count:t,collapsed:n,onToggle:r}){let i=(0,R.jsxs)(R.Fragment,{children:[r?(0,R.jsx)(r_,{size:11,className:`transition-transform ${n?``:`rotate-90`}`}):(0,R.jsx)(`span`,{className:`w-[11px] shrink-0`,"aria-hidden":!0}),(0,R.jsx)(`span`,{children:e}),(0,R.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,R.jsx)(`button`,{onClick:r,className:`${a} transition-colors hover:text-fg`,children:i}):(0,R.jsx)(`div`,{className:a,children:i})}var sG=27,cG=8;function lG({threads:e,railRef:t,activeId:n,onQueueNavigate:r}){let i=(0,L.useRef)(null),[a,o]=(0,L.useState)(0),s=vD({count:e.length,getScrollElement:()=>t.current,getItemKey:t=>e[t]?.id??t,estimateSize:()=>sG,overscan:cG,scrollMargin:a});return(0,L.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,R.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,R.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,R.jsx)(pG,{t:i,active:n===i.id,onQueueNavigate:r}),(0,R.jsx)(vG,{t:i})]},i.id):null})})}var uG=16,dG=12;function fG({title:e,children:t}){let n=e.trimEnd(),r=n.lastIndexOf(` `)+1,i=n.length-r<=uG?r:n.length-dG;return i>=n.length?(0,R.jsxs)(R.Fragment,{children:[e,t]}):(0,R.jsxs)(R.Fragment,{children:[n.slice(0,i),(0,R.jsxs)(`span`,{className:`whitespace-nowrap`,children:[n.slice(i),t]})]})}var pG=(0,L.memo)(function({t:e,legacy:t,active:n=!1,onQueueNavigate:r,restedAge:i=!1}){let a=!t&&e.foreign===!0,o=!t&&_f(e),s=!t&&hO(e)===`archived`,c=o||s,l=!t&&YD(e),u=!t&&gO(e),d=!t&&iO(e);return(0,R.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-hover after:opacity-0 after:transition-opacity hover:after:opacity-100 ${t?`opacity-80`:c?`sidebar-row-dim`:``}`,children:[(0,R.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,R.jsx)(`span`,{"data-sidebar-scroll-marker":!0,className:`absolute inset-y-0 left-1 w-[2px] rounded-full bg-accent`})}),(0,R.jsxs)(`button`,{onClick:()=>{if(e.needsYou&&tg(e.id)){r?.(e.id);return}Xh(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,R.jsx)(`span`,{className:`w-4 h-[19px] shrink-0 flex items-center justify-center`,children:(0,R.jsx)(CG,{t:e,legacy:t})}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 flex flex-col`,children:(0,R.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-3`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 break-words text-[13px] leading-[19px] ${l?`text-provisional`:c?`text-fg/75`:`text-fg/90`}`,children:(0,R.jsxs)(fG,{title:HD(e),children:[!t&&(0,R.jsx)(zH,{backend:e.backend,model:e.model,className:`ml-1`}),a&&(0,R.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,R.jsx)(yG,{status:e.archived?`archived`:e.status})]})}),i&&(0,R.jsx)(mG,{t:e,yieldsToRetry:!0}),d&&!i&&(0,R.jsx)(gG,{})]})})]}),t&&(0,R.jsx)(`div`,{className:`absolute right-1 top-1 hidden group-hover:flex items-stretch rounded-md bg-panel shadow-sm shadow-shadow-ink/30`,children:(0,R.jsx)(cR,{slug:e.id,size:`sm`})}),!t&&(0,R.jsxs)(`div`,{className:`absolute right-1.5 top-1 hidden items-center gap-0.5 bg-bg group-hover:flex group-focus-within:flex before:pointer-events-none before:absolute before:inset-y-0 before:right-full before:w-3 before:bg-linear-to-r before:from-transparent before:to-bg`,children:[!a&&!d&&(0,R.jsx)(_G,{t:e,className:`-mr-0.5`}),(0,R.jsx)(IP,{slug:e.id,size:12,className:rG}),u&&(0,R.jsx)(hG,{slug:e.id}),!a&&d&&(0,R.jsx)(_G,{t:e})]})]})});function mG({t:e,yieldsToRetry:t}){let n=LO(),r=QD(e),i=TO(r,n);return!r||!i?null:(0,R.jsx)(`time`,{dateTime:r,"data-rail-rested-age":!0,title:SO(r,n)??void 0,"aria-label":`Rested ${SO(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 hG({slug:e}){let t=qe(),[n,r]=(0,L.useState)(!1);return(0,R.jsx)(FP,{label:`Retry — resume this session where it left off`,children:(0,R.jsx)(`button`,{"data-sidebar-retry":e,"aria-label":`Retry exited session`,disabled:n,onMouseDown:e=>e.preventDefault(),onClick:n=>{n.stopPropagation(),r(!0),kW(t,e).finally(()=>r(!1))},className:`${rG} disabled:opacity-50`,children:n?(0,R.jsx)(M_,{size:13,className:`animate-spin`}):(0,R.jsx)(X_,{size:13})})})}function gG(){return(0,R.jsx)(`span`,{"aria-hidden":!0,"data-rail-pin-mark":!0,className:`-ml-1 flex h-[19px] w-[19px] shrink-0 items-center justify-center self-start text-muted opacity-55 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0`,children:(0,R.jsx)(W_,{size:12,fill:`currentColor`})})}function _G({t:e,className:t=``}){let n=iO(e),[r,i]=(0,L.useState)(!1);return(0,R.jsx)(FP,{label:n?`Unpin — return this thread to the rail's bands`:`Pin — keep this thread at the very top`,children:(0,R.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:`${rG} disabled:opacity-50 ${t}`,children:n?(0,R.jsx)(U_,{size:12,fill:`currentColor`}):(0,R.jsx)(W_,{size:12})})})}function vG({t:e}){let t=_k(e.subAgents??[],`rail`);return t.length===0?null:(0,R.jsx)(`div`,{className:`flex flex-col`,children:t.map(t=>(0,R.jsx)(bk,{kind:`AGENT`,label:t.label,state:t.state,density:`rail`,depth:t.depth,startedAt:t.startedAt,parentSlug:e.id,onOpen:()=>Jh(e.id,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}),onDismiss:RP(e.id,t),title:t.subagentType?`[${t.subagentType}] ${t.label}`:t.label},t.id))})}function yG({status:e}){let t=e===`archived`?`Done`:e;return(0,R.jsx)(`span`,{className:`petite-caps ml-1.5 inline-block rounded border px-1 align-[2px] leading-[14px] text-[9.5px] ${VD[e]??`text-muted border-border`}`,children:t})}function bG(e,t,n=null){return[[t,WW(e.lastFence?.kind===`awaiting`?e.lastFence.hints:[]),n].filter(e=>!!e).join(` — `),xG(e)].filter(e=>!!e).join(`
|
|
207
207
|
|
|
208
|
-
`)}function xG(e){return e.lastFence?.kind===`awaiting`?IW(e.lastFence):null}var SG=7;function CG({t:e,legacy:t}){let{node:n,tip:r}=t?RG(e):wG(e),i=t?void 0:
|
|
209
|
-
`),children:(0,R.jsx)(`span`,{"data-rail-glyph":i,className:`flex items-center justify-center`,children:n})}):i?(0,R.jsx)(`span`,{"data-rail-glyph":i,className:`flex items-center justify-center`,children:n}):n}function wG(e){let t=FG(e);if(
|
|
208
|
+
`)}function xG(e){return e.lastFence?.kind===`awaiting`?IW(e.lastFence):null}var SG=7;function CG({t:e,legacy:t}){let{node:n,tip:r}=t?RG(e):wG(e),i=t?void 0:hO(e);return r?(0,R.jsx)(FP,{label:r,side:`left`,multiline:r.includes(`
|
|
209
|
+
`),children:(0,R.jsx)(`span`,{"data-rail-glyph":i,className:`flex items-center justify-center`,children:n})}):i?(0,R.jsx)(`span`,{"data-rail-glyph":i,className:`flex items-center justify-center`,children:n}):n}function wG(e){let t=FG(e);if(hO(e)===`snoozed`)return t;let n=gf(e),r=n?ND(n,e.snoozePrompt):null;return r?{node:t.node,tip:TG(t.tip,r)}:t}function TG(e,t){if(!e)return t;let[n,...r]=e.split(`
|
|
210
210
|
|
|
211
211
|
`);return[`${n}\n${t}`,...r].join(`
|
|
212
212
|
|
|
213
|
-
`)}var EG=(0,R.jsx)(zO,{children:(0,R.jsx)(`span`,{"aria-hidden":!0,className:`frizz-rail-dot`,"data-running-indicator":`thread-background`})}),DG=(0,R.jsx)(IG,{children:(0,R.jsx)(`span`,{"aria-hidden":!0,className:`frizz-rail-dot`})}),OG=9,kG=(0,R.jsx)(E_,{size:OG,className:`text-muted-70`,style:{transform:`translateX(${OG/24}px)`}}),AG=(0,R.jsx)(IG,{children:kG}),jG=(0,R.jsx)(h_,{size:11,className:`text-muted-70`}),MG=(0,R.jsx)(IG,{children:(0,R.jsx)(D_,{size:9,className:`text-muted-70`})}),NG=(0,R.jsx)(IG,{children:(0,R.jsx)(Jg,{size:9,className:`text-muted/70`})});function PG(e,t=Date.now()){let n=(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`).map(e=>Date.parse(e.timer?.fireAt??``)).filter(e=>Number.isFinite(e)).sort((e,t)=>e-t)[0];return n===void 0?null:n>t?`fires in ${KO(n-t)}`:`firing…`}function FG(e){let t=gO(e);if(t===`archived`)return{node:(0,R.jsx)(IG,{children:(0,R.jsx)(e_,{size:10,strokeWidth:3,className:`text-muted-75`})}),tip:`Done`};if(t===`needs-input`)return{node:(0,R.jsx)(IG,{children:(0,R.jsx)(LG,{ch:`?`,muted:!0})}),tip:`Needs your input`};if(t===`working`)return fO(e)?{node:(0,R.jsx)(zO,{children:(0,R.jsx)(LG,{ch:`?`,muted:!0})}),tip:`Working — a question is waiting on your answer`}:dO(e)?{node:(0,R.jsx)(zO,{children:jG}),tip:`At rest — waiting on its sub-agents`}:{node:(0,R.jsx)(zO,{}),tip:`Working`};if(t===`background`){let t=e.lastFence?.kind===`awaiting`&&WW(e.lastFence.hints)!==null;return{node:uO(e)?EG:DG,tip:bG(e,t?`At rest`:`At rest — a background shell is still running`)}}if(t===`done`)return{node:(0,R.jsx)(IG,{children:(0,R.jsx)(e_,{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,R.jsx)(IG,{accent:!0,children:(0,R.jsx)(LG,{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 ${AO(t.resumesAt)}`:`continuing automatically once the window resets`:`won't resume by itself — Retry to continue`;return{node:(0,R.jsx)(IG,{accent:!0,children:(0,R.jsx)(D_,{size:9,className:`text-accent`})}),tip:`Paused by the ${t?.backend===`codex`?`Codex`:`Claude`} ${n} — ${r}`}}if(t===`pr`){let t=bG(e,lO(e)?`At rest — checks are running`:`At rest`);return uO(e)?{node:(0,R.jsx)(zO,{children:kG}),tip:t}:{node:AG,tip:t}}if(t===`timer`)return{node:MG,tip:bG(e,e.lastFence?.kind===`awaiting`&&WW(e.lastFence.hints)!==null?`At rest`:`At rest — waiting on a timer`,PG(e))};if(t===`snoozed`){let t=MG,n=AG,r=mO(e)?n:NG,i=gf(e);if(i){let t=PD(i,e.snoozePrompt)??`Snoozed until a scheduled check`;return{node:r,tip:bG(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`){if(a)return{node:mO(e)?n:DG,tip:a};if(e.waitStatus===`watching`){let r=(e.bgShells??[]).some(e=>e.state===`running`);return{node:mO(e)?n:r?DG:t,tip:`Snoozed until its watch reports back`}}return{node:t,tip:(typeof e.revalidate==`string`?FD(e.revalidate):null)??`Auto-snoozed until a scheduled check`}}let o=e.lastFence.hints.find(e=>e.kind===`pr`||e.kind===`issue`||e.kind===`shell`||e.kind===`agent`||e.kind===`timer`)?.kind;return{node:mO(e)?n:o===`shell`||o===`agent`?DG:t,tip:bG(e,a??`Snoozed`,o===`timer`?PG(e):null)}}return{node:(0,R.jsx)(IG,{children:jG}),tip:bG(e,`At rest`)}}function IG({accent:e,children:t}){return(0,R.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 LG({ch:e,muted:t}){return(0,R.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 RG(e){if(e.runtime===`running`||e.runtime===`spawning`||e.runtime===`perm-prompt`)return{node:(0,R.jsx)(zG,{}),tip:`Working`};let t=(e.subAgents??[]).some(e=>e.state===`running`);return e.runtime===`turn-idle`&&t&&!e.humanBlocked?{node:(0,R.jsx)(zG,{}),tip:`Working`}:Sf(e)?{node:(0,R.jsx)(BG,{}),tip:`Needs your input`}:e.status===`needs-human`?{node:(0,R.jsx)(VG,{}),tip:`Awaiting you — open to read & reply`}:e.status===`blocked`&&e.mechanism===`timer`?{node:(0,R.jsx)(av,{size:8,className:`text-muted-70`}),tip:`Waiting on a timer`}:e.status===`blocked`&&e.mechanism===`threads`?{node:(0,R.jsx)(c_,{size:8,className:`text-muted-70`}),tip:`Waiting on other work`}:{node:(0,R.jsx)(HG,{}),tip:null}}function zG(){return(0,R.jsx)(`span`,{className:`block rounded-full border border-muted/70 border-t-transparent animate-spin`,style:{width:8,height:8}})}function BG(){return(0,R.jsx)(`span`,{className:`block rounded-full bg-planning`,style:{width:SG,height:SG}})}function VG(){return(0,R.jsx)(`span`,{className:`block rounded-full bg-needs-human`,style:{width:SG,height:SG}})}function HG(){return(0,R.jsx)(`span`,{className:`block rounded-full bg-muted/30`,style:{width:SG,height:SG}})}function UG(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 WG=new Set([`agent`,`follow up`,`interrupt`,`send message`,`spawn agent`,`wait for agents`]),GG=new Set([`poll process`,`wait`]);function KG(e){return(e.split(`__`).pop()||e).replaceAll(`_`,` `).trim()}function qG(e){return KG(e).toLowerCase()}function JG(e){return e.prompt!==void 0||e.agentId!==void 0||e.sendTo!==void 0||e.sendBody!==void 0||e.backgroundState!==void 0&&!QG(e)&&!YG(e)||ZG(e)||XG(e)||WG.has(qG(e.name))}function YG(e){return e.backgroundState===`background`&&cK(e)}function XG(e){return e.ask!==void 0&&e.ask.length>0&&e.status!==void 0&&e.status!==`pending`}function ZG(e){return e.sentImages!==void 0&&e.sentImages.length>0}function QG(e){return e.backgroundState===`unknown`&&GG.has(qG(e.name))}function $G(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=>!JG(e))?t:null}return e.text.trim()||e.tools.length===0?null:e.tools.every(e=>!JG(e))?e.tools:null}function eK(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 tK(e){if(e.role!==`assistant`||e.kind||e.queued)return null;if(!e.parts?.length)return nK(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 nK(n.tools)}return null}function nK(e){let t=[];for(let n=e.length-1;n>=0&&!JG(e[n]);n--)t.unshift(e[n]);return t.length>0?t:null}function rK(e){if(e.role!==`assistant`||e.kind||e.queued)return null;let t=[],n=e=>{for(let n of e){if(JG(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 iK(e,t){return aK(e,new Set(t))}function aK(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 oK(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 sK(e){let t=[],n=null;return e.forEach((e,r)=>{if(eK(e))return;if(e.queued){t.push({message:e,messageIndex:r});return}let i=$G(e);if(i&&n){n.message=oK(n.message,i,e.at);return}let a=n?rK(e):null,o=a?iK(e,a):e;a&&n&&(n.message=oK(n.message,a,e.at));let s={message:o,messageIndex:r};t.push(s),tK(o)?(s.runStartedAt=o.at,n=s):n=null}),t}function cK(e){return e.status===`completed`||e.status===`failed`||e.status===`cancelled`}function lK(e){let t=uK(e);if(!t)return;let n=t.tools.filter(e=>!YG(e));return n.some(e=>!cK(e))?n.at(-1):void 0}function uK(e){let t=dK(e);if(!t)return;let n=tK(t.message);return n?{tools:n,at:t.message.at}:void 0}function dK(e){for(let t=e.length-1;t>=0;t--)if(!e[t].message.queued)return e[t]}function fK(e){let t=dK(e);if(t)return tK(t.message)?t.runStartedAt??t.message.at:t.message.at}function pK(e){let t=tK(e);return t?aK(e,new Set(t)):e}function mK(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].message;if(!r.queued){tK(r)&&(t=r);break}}if(!t)return[...e];let n=[];for(let r of e){let e=r.message===t?pK(r.message):r.message;eK(e)||n.push(e===r.message?r:{...r,message:e})}return n}function hK(e){return e.detail?.trim()||void 0}var gK={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 _K(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=gK[i.toLowerCase()];return a?a+(r===-1?``:n.slice(r)):n.charAt(0).toUpperCase()+n.slice(1)}function vK(e,t,n){let r=t?.trim().replace(/[\\/]+$/,``);if(!r||!gh(r))return e;let i=wh(r);return i?nee(e.replace(i,``),n?.trim().replace(/[\\/]+$/,``)||/^([A-Za-z]:[\\/]Users[\\/][^\\/]+|\/(?:Users|home)\/[^/]+)(?=[\\/]|$)/.exec(r)?.[1]):e}function yK(e,t,n=uh().home){return vK(bK(e),t,n)}function bK(e){let t=qG(e.name),n=hK(e),r=n?` ${n}`:``;return t===`bash`||t===`exec`||t===`run command`?_K(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 ${KG(e.name)||`a tool`}`}var xK=new Set([`edit`,`multiedit`,`write`,`apply patch`]);function SK(e){let t=new Set;for(let n of e){for(let e of n.edits??(n.edit?[n.edit]:[])){let n=e.file.trim();n&&!CK.test(n)&&t.add(n)}if(n.edit||n.edits?.length)continue;let e=n.detail?.trim();e&&!CK.test(e)&&xK.has(qG(n.name))&&t.add(e)}return t.size}var CK=/\$\{/;function wK(e,t=0){let n=`Ran ${e} tool ${e===1?`call`:`calls`}`;return t===0?n:`${n}, edited ${t} file${t===1?``:`s`}`}function TK(e){return e>0?`${wK(e)}. Thinking…`:`Thinking…`}function EK(e){return e.replace(/```[\w-]*/g,` `).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\*\*|__|`/g,``).replace(/(^|\s)[*_](\S[^*_]*?\S|\S)[*_](?=\s|$|[.,;:!?])/g,`$1$2`).replace(/\s+/g,` `).trim()}var DK=/^(?:```[\w-]*\s*|#{1,6}\s+|>\s*|[-*+]\s+|\d+[.)]\s+)+/,OK=/\n|\s(?:```|[-*+]\s|\d+[.)]\s|#{1,6}\s|>\s)/;function kK(e,t=!1){let n=(e??``).trim().replace(DK,``),r=t?null:OK.exec(n);if(r&&(n=n.slice(0,r.index)),!n.trim())return null;let i=/^(\*\*|__)(.{1,60}?)\1\s*/.exec(n);if(i){let e=EK(i[2]),t=EK(n.slice(i[0].length));if(e)return t?{lead:e,text:t}:{text:e}}let a=EK(n);return a?{text:a}:null}function AK(e){let t=e.split(`
|
|
214
|
-
`).map(e=>e.trim()).find(Boolean);return t&&EK(t)||null}function jK(e){return e.length>1?`${e.length} questions`:e.length===1?AK(e[0]):null}function MK(e,t){let n;for(let r of e.watches??[]){if(r.kind!==`timer`||r.state!==`armed`||!r.timer)continue;let e=Date.parse(r.timer.fireAt);!Number.isFinite(e)||e<=t||(!n||e<n.ms)&&(n={at:r.timer.fireAt,ms:e})}return n?.at}function NK(e,t=Date.now()){return gf(e,t)??MK(e,t)}function PK(e){return(e.subAgents??[]).filter(e=>e.state===`running`).length}function FK(e){return e>0?`${e} ${e===1?`agent`:`agents`}`:``}function IK(e,t,n,r=Date.now(),i){let a=e.lastFence?.kind===`awaiting`&&/^`{3,}awaiting\b/.test((e.lastAssistant??``).trimStart())?e.lastFence:void 0,o=()=>{if(a){let e=IW(a);if(e)return kK(e);let t=WW(a.hints);if(t)return{text:`${t.charAt(0).toUpperCase()}${t.slice(1)}`}}return kK(e.lastAssistantLine,!0)??kK(e.lastAssistant)};if(t===`needs-input`){let t=jK((e.questions??[]).map(e=>e.spec.question));if(t)return{text:t};let n=jK((e.pendingAsk?.questions??[]).map(e=>e.question));if(n)return{text:n};if(e.runtime===`perm-prompt`)return{text:`Waiting on a permission prompt`};let r=e.lastFence?.kind===`awaiting`?qW(e.lastFence.hints):null;return r?{text:r}:o()}if(n)return e.liveTool?{text:yK(e.liveTool,i)}:e.activity?{text:e.activity}:o();if(t===`snoozed`&&gf(e,r)!==void 0)return{text:`Snoozed by you`};let s=e.lastFence?.kind===`awaiting`?qW(e.lastFence.hints):null;return s?{text:s}:(t===`snoozed`||t===`timer`)&&MK(e,r)?{text:`Waiting on a timer`}:o()??(e.activity?{text:e.activity}:null)}var LK={planning:`Being designed`,planned:`Roadmap`,active:`Active`,"needs-human":`Awaiting you`,blocked:`Blocked`,done:`Done`,dismissed:`Dismissed`,archived:`Done`};function RK({status:e}){let t=eO(FE(ME()?.threads??[])).filter(t=>e===`archived`?t.archived:t.status===e);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`header`,{className:`shrink-0 flex items-center gap-2 px-4 h-10 border-b border-border`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:LK[e]??e}),(0,R.jsx)(`span`,{className:`text-[11px] text-muted tabular-nums`,children:t.length})]}),(0,R.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto py-1.5`,children:[t.length===0&&(0,R.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted`,children:`No threads.`}),t.map(e=>(0,R.jsxs)(`button`,{className:`w-full text-left px-4 py-2 hover:bg-panel-2/60`,onClick:()=>qh(`thread`,e.id),children:[(0,R.jsx)(`div`,{className:`leading-snug`,children:UD(e)}),e.statusText&&(0,R.jsx)(`div`,{className:`text-[11px] text-muted mt-0.5`,children:e.statusText})]},e.id))]})]})}function zK(e){let t=e.kind===`session`&&e.foreign!==!0,n=t&&(e.state===`archived`||e.archived===!0),r=t,i=t&&!n;return{lifecycle:r,done:n,snooze:i,archive:i}}function BK(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=>Au(e)&&t(e))||e.bgShells?.some(t))}function VK(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=[HK(`agent`,`sub-agent`,e.subAgents,e.subAgentCount),HK(`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 HK(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 UK(e,t){let n=e.trim();if(!(!n||n===t.trim()))return n}function WK(e,t){let n=e.trim();return!n||n===t||n===`Untitled thread`||n===`Spinning up a thread…`?``:n}function GK(e){return e.kind!==`session`||e.foreign||e.backend===`codex`||e.backend===`acp`||e.claudeRuntime!==void 0&&e.claudeRuntime!==`broker`?{show:!1,enabled:!1,label:``}:e.runtime===`exited`||e.runtime===`none`?{show:!0,enabled:!1,label:`Resume this Claude thread to rename it with Claude`}:e.runtime===`spawning`?{show:!0,enabled:!1,label:`Rename with Claude once this thread has started`}:{show:!0,enabled:!0,label:`Rename with Claude — a fresh title from the opening request`}}function KK(){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(),t.dataset.localImage===`true`?JK(t,n):YK(n))};document.addEventListener(`click`,e);let t=qK();return document.addEventListener(`error`,t,!0),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`error`,t,!0)}}function qK(){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 JK(e,t){if(!(e instanceof HTMLImageElement)){Rh([$R(t,e.textContent)],0);return}let n=e.closest(`[data-frizz-msg]`)??e.closest(`.md-body, .md-inline`),r=n?[...n.querySelectorAll(`img[data-local-image="true"][data-local-path]`)]:[e];Rh(r.map(e=>$R(e.dataset.localPath,e.alt)),Math.max(r.indexOf(e),0))}function YK(e,t=!1){if(!t&&KT(e)){og(e);return}if(!t&&X.splitFileViewer){cg(e);return}if(Ig()){t?window.open(BT(e),`_blank`,`noopener`):og(e);return}XK(e,t)}async function XK(e,t){try{let n=await Y.openLocalFile({path:e,...t?{image:!0}:{}});n.action===`copy`&&(await eH(n.path),Z(`Copied local path`))}catch(e){Z(`Could not open local file: ${e.message.slice(0,100)}`)}}function ZK(e,t){return new Promise(n=>{DW(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 QK(){return OU(RU().data??null)}function $K(e){return e.kind!==`session`||e.foreign||e.claudeRuntime!==`broker`?!1:e.runtime!==`exited`}function eq(e,t){return!t||e.kind!==`session`||e.foreign||e.backend===`codex`||e.backend===`acp`?!1:e.runtime!==`exited`}async function tq(e){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))}}function nq(e){let t=gO(e);return t===`needs-input`?`needs-you`:e.runtime===`running`||e.runtime===`spawning`?`working`:t===`archived`?`done`:t===`snoozed`&&gf(e)!==void 0?`snoozed`:`rested`}var rq={"needs-you":`Needs you`,working:`Working`,rested:`Rested`,snoozed:`Snoozed`,done:`Done`};function iq(e,t,n,r){if(t===`working`){let t=Date.parse(n??e.lastUserAt??e.spawnedAt??``);return Number.isFinite(t)&&qO(Math.max(0,r-t))||null}return EO($D(e),r)}function aq(e){let t=e?.trim();if(t)return(HB[t]??t).toLowerCase()}function oq(e){if(e>=1e6){let t=Math.round(e/1e5)/10;return`${Number.isInteger(t)?t:t.toFixed(1)}M`}return e>=1e3?`${Math.round(e/1e3)}k`:String(e)}function sq(e){return!e||e.window<=0?null:`Context ${Math.max(0,Math.min(100,Math.floor(e.tokens/e.window*100)))}% · ${oq(e.tokens)} of ${oq(e.window)}`}function cq(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role===`user`&&!n.queued&&n.at)return n.at}}function lq(e){try{let t=new URL(e).hostname.replace(/^\[|\]$/g,``);return t===`localhost`||t.endsWith(`.localhost`)||t===`::1`||/^127(?:\.\d{1,3}){3}$/.test(t)||t===`0.0.0.0`}catch{return!1}}function uq(e){try{let t=new URL(e),n=`${t.pathname===`/`?``:t.pathname}${t.search}${t.hash}`;return`${t.host}${n}`}catch{return e}}function dq({title:e,onRequestClose:t,children:n,footer:r,className:i=``,dataAttr:a}){let[o,s]=(0,L.useState)(!1),c=(0,L.useRef)(null);(0,L.useEffect)(()=>{let e=requestAnimationFrame(()=>s(!0));return()=>cancelAnimationFrame(e)},[]);let l=a?{[a]:``}:{};return(0,R.jsx)(gR,{open:!0,onOpenChange:e=>{e||t()},children:(0,R.jsxs)(bR,{children:[(0,R.jsx)(SR,{className:`fixed inset-0 z-[80] bg-scrim-50 transition-opacity duration-200 motion-reduce:transition-none ${o?`opacity-100`:`opacity-0`}`}),(0,R.jsxs)(ER,{ref:c,...l,"aria-describedby":void 0,onOpenAutoFocus:e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})},onEscapeKeyDown:mB,className:`fixed inset-x-0 bottom-0 z-[80] flex max-h-[86%] flex-col overflow-hidden rounded-t-[14px] border-t border-border-strong bg-panel pb-[calc(14px+env(safe-area-inset-bottom))] shadow-[0_-20px_60px_-10px_var(--sheet-shadow)] outline-none transition-transform duration-200 ease-out motion-reduce:transition-none ${o?`translate-y-0`:`translate-y-full`} ${i}`,children:[(0,R.jsx)(jR,{className:`sr-only`,children:e}),(0,R.jsx)(`div`,{"aria-hidden":!0,className:`mx-auto mt-[6px] mb-[6px] h-[5px] w-[36px] shrink-0 rounded-full bg-muted/35`}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:n}),r]})]})})}var fq={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 pq({checked:e,onChange:t,disabled:n,label:r,size:i=`sm`,testId:a}){let o=fq[i];return(0,R.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-focus-ink-60 disabled:cursor-default disabled:opacity-45 ${o.track} ${o.onCap} ${e?`bg-fg`:`bg-border hover:bg-border-strong`}`,children:(0,R.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 mq({size:e=12,className:t=``}){return(0,R.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,R.jsx)(`path`,{d:`M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,R.jsx)(`path`,{d:`M12 7a5 5 0 1 0 5 5`}),(0,R.jsx)(`path`,{d:`M13 3.055a9 9 0 1 0 7.941 7.945`}),(0,R.jsx)(`path`,{d:`M15 6v3h3l3 -3h-3v-3l-3 3`}),(0,R.jsx)(`path`,{d:`M15 9l-3 3`})]})}function hq({thread:e}){let[t,n]=(0,L.useState)(`closed`),r=(0,L.useRef)(null),i=(0,L.useRef)(void 0);(0,L.useEffect)(()=>()=>clearTimeout(i.current),[]);let a=t!==`closed`,[o,s]=(0,L.useState)(null);(0,L.useLayoutEffect)(()=>{if(!a)return;let e=r.current?.closest(`[data-queue-card-root], [role="dialog"], main`);if(!e){s(null);return}let t=e.getBoundingClientRect().left+e.clientLeft,n=r.current?.closest(`[data-composer-box]`)?.getBoundingClientRect();s({surface:e,left:Math.max(12,n?n.left-t:0),right:Math.max(12,n?t+e.clientWidth-n.right:0)})},[a]);let c=o?{collisionBoundary:o.surface,collisionPadding:{top:12,bottom:12,left:o.left,right:o.right}}:{},l=e.recurringPrompt,u=l?.stopHook===!0||l?.heartbeat===!0||l?.postCompaction===!0;function d(){clearTimeout(i.current),i.current=setTimeout(()=>n(e=>e===`closed`?`preview`:e),gq)}function f(){clearTimeout(i.current),n(e=>e===`preview`?`closed`:e)}let p=e=>{r.current?.contains(e.detail.originalEvent.target)&&e.preventDefault()};return(0,R.jsxs)(CV,{open:t!==`closed`,onOpenChange:e=>{e||(clearTimeout(i.current),n(`closed`))},children:[(0,R.jsx)(TV,{asChild:!0,children:(0,R.jsx)(`button`,{ref:r,type:`button`,"data-recurring-prompt":!0,"data-recurring-prompt-on":u?`true`:`false`,"aria-label":u?`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`&&d()},onPointerLeave:e=>{e.pointerType===`mouse`&&f()},onFocus:()=>n(e=>e===`closed`?`preview`:e),onBlur:f,className:`group/goal icon-hover-outline flex h-7 w-7 items-center justify-center rounded-lg outline-none transition-[color,background-color] hover:bg-panel-2/70`,children:(0,R.jsx)(mq,{size:15,className:u?`text-attention-90`:`text-muted group-hover/goal:text-fg group-focus-visible/goal:text-fg`})})}),t===`preview`?(0,R.jsx)(EV,{side:`top`,align:`end`,...c,"data-recurring-preview":!0,onPointerDownOutside:p,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,R.jsx)(_q,{armed:l})}):(0,R.jsx)(EV,{side:`top`,align:`end`,...c,className:`w-[min(46rem,calc(100vw-1.5rem),var(--radix-popper-available-width,46rem))] p-3 text-[11px] leading-relaxed text-fg`,onPointerDownOutside:p,onOpenAutoFocus:e=>e.preventDefault(),onDragOver:e=>e.stopPropagation(),onDragLeave:e=>e.stopPropagation(),onDrop:e=>{e.stopPropagation(),e.dataTransfer.files.length>0&&e.preventDefault()},children:(0,R.jsx)(Dq,{thread:e,armed:l,close:()=>n(`closed`)})})]})}var gq=260;function _q({armed:e}){let t=e?.prompt?.trim(),n=e?Eq({stopHook:e.stopHook===!0,heartbeat:e.heartbeat===!0,postCompaction:e.postCompaction===!0,seconds:e.intervalSeconds??bq}):[];return(0,R.jsxs)(`div`,{"data-recurring-preview-body":!0,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Goal`}),(0,R.jsx)(`span`,{className:`text-muted-70`,children:n.length>0?`sent ${n.join(`, `)}`:t?`no trigger is on`:`not set`})]}),(0,R.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 vq=1,yq=1440,bq=600;function xq(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(yq,Math.max(vq,n))*60:t}var Sq=null;function Cq(e){return{prompt:e.text.trim(),stopHook:e.stopHook,heartbeat:e.heartbeat,postCompaction:e.postCompaction,seconds:e.seconds}}function wq(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 Tq(e,t){return!e.archived&&!t}function Eq(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 Dq({thread:e,armed:t,close:n,heading:r=!0}){let i=Tq(e,t)?nd:``,a=Sq?.slug===e.id?Sq.draft:null,[o,s]=(0,L.useState)(a?.text??t?.prompt??i),[c,l]=(0,L.useState)(a?.stopHook??t?.stopHook??!1),[u,d]=(0,L.useState)(a?.heartbeat??t?.heartbeat??!1),[f,p]=(0,L.useState)(a?.postCompaction??t?.postCompaction??!1),[m,h]=(0,L.useState)(a?.seconds??t?.intervalSeconds??bq),g=c||u||f,[_,v]=(0,L.useState)(String(Math.round((a?.seconds??t?.intervalSeconds??bq)/60))),y=(0,L.useRef)(null),b=(0,L.useRef)({prompt:t?.prompt??i,stopHook:t?.stopHook??!1,heartbeat:t?.heartbeat??!1,postCompaction:t?.postCompaction??!1,seconds:t?.intervalSeconds??bq}),x=e=>({text:o,stopHook:c,heartbeat:u,postCompaction:f,seconds:xq(_,m),...e}),S=(0,L.useRef)(x());S.current=x(),(0,L.useEffect)(()=>()=>{let n=S.current;if(wq(n,b.current)){Sq?.slug===e.id&&(Sq=null);return}if(n.text.trim()===``&&!t){Sq={slug:e.id,draft:n};return}w(n)},[]);let C=(0,L.useRef)(Promise.resolve(!0));function w(t){let n=C.current.catch(()=>!1).then(async()=>{let n=await T(t);return n?Sq?.slug===e.id&&(Sq=null):Sq={slug:e.id,draft:t},n});return C.current=n,n}async function T(t){let n=t.text.trim()||null;if(wq(t,b.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}}),b.current={...Cq(t),prompt:n??``};let r=Eq(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 E(){if(wq(x(),b.current)||o.trim()===``&&!t){n();return}w(x()).then(e=>{e&&n()})}function D(){let e=xq(_,m);v(String(Math.round(e/60))),h(e)}let O=[{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),k=O.reduce((e,t)=>e&&Date.parse(e.at)>=Date.parse(t.at)?e:t,void 0),A=k===void 0?null:O.length>1?`Last sent ${ZO(k.at)}`:`Last sent ${k.how} ${ZO(k.at)}`;return(0,R.jsxs)(`section`,{"data-recurring-panel":!0,children:[r?(0,R.jsxs)(`div`,{className:`mb-2 flex items-center gap-3`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Goal`}),A&&(0,R.jsx)(`span`,{className:`ml-auto truncate text-muted-55`,children:A})]}):A?(0,R.jsx)(`div`,{className:`mb-2 truncate text-muted-55`,children:A}):null,(0,R.jsx)(`textarea`,{ref:y,"data-recurring-text":!0,"data-1p-ignore":!0,value:o,maxLength:$u,onChange:e=>s(e.target.value),onKeyDown:e=>{_z({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())},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 ${g?`text-fg`:`text-muted`}`}),(0,R.jsxs)(`div`,{className:`mt-3 grid grid-cols-[auto_auto_1fr] items-baseline gap-x-2.5 gap-y-2`,children:[(0,R.jsx)(pq,{testId:`stop-hook`,label:`Stop hook`,checked:c,onChange:e=>{l(e),e&&!o.trim()&&requestAnimationFrame(()=>y.current?.focus())}}),(0,R.jsx)(`span`,{className:`font-medium ${c?`text-fg`:`text-muted`}`,children:`Stop hook`}),(0,R.jsx)(`span`,{className:`text-muted`,children:`every rest — unless it signed off or parked on a wait`}),(0,R.jsx)(pq,{testId:`heartbeat`,label:`Heartbeat`,checked:u,onChange:e=>{d(e),e&&!o.trim()&&requestAnimationFrame(()=>y.current?.focus())}}),(0,R.jsx)(`span`,{className:`font-medium ${u?`text-fg`:`text-muted`}`,children:`Heartbeat`}),u?(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted`,children:[`every`,(0,R.jsx)(`input`,{type:`number`,"data-recurring-minutes":!0,inputMode:`numeric`,min:vq,max:yq,value:_,onChange:e=>v(e.target.value),onBlur:D,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),D())},"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,R.jsx)(`span`,{className:`text-muted`,children:`on a clock, even mid-turn`}),(0,R.jsx)(pq,{testId:`post-compaction`,label:`Compaction`,checked:f,onChange:e=>{p(e),e&&!o.trim()&&requestAnimationFrame(()=>y.current?.focus())}}),(0,R.jsx)(`span`,{className:`font-medium ${f?`text-fg`:`text-muted`}`,children:`Compaction`}),(0,R.jsx)(`span`,{className:`text-muted`,children:`when the context is summarized away — link the doc to re-read`})]})]})}function Oq({open:e,onOpenChange:t,title:n,children:r,footer:i,className:a=`w-[640px] max-w-[92vw] max-h-[82vh]`,onOpenAutoFocus:o}){return(0,R.jsx)(gR,{open:e,onOpenChange:t,children:(0,R.jsxs)(bR,{children:[(0,R.jsx)(SR,{className:`overlay-in fixed inset-0 z-[200] bg-scrim-55 backdrop-blur-[1px]`}),(0,R.jsxs)(ER,{"aria-modal":`true`,onEscapeKeyDown:mB,onOpenAutoFocus:o,className:`pop-in fixed left-1/2 top-1/2 z-[200] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border bg-panel shadow-2xl shadow-shadow-ink/50 outline-none ${a}`,children:[(0,R.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border px-4`,children:[(0,R.jsx)(jR,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:n}),(0,R.jsx)(NR,{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,R.jsx)(cv,{size:15})})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:r}),i&&(0,R.jsx)(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3`,children:i})]})]})})}function kq({thread:e,onSnoozed:t}){let[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(``),[f,p]=(0,L.useState)(``),[m,h]=(0,L.useState)(``),g=(0,L.useId)(),_=(0,L.useId)(),v=(0,L.useId)(),y=gf(e),b=e.snoozePrompt?.trim(),x=(0,L.useMemo)(()=>kD(new Date(Date.now()+6e4)),[c]),S=(0,L.useMemo)(()=>SD.map(e=>{let t=jD(DD(e.value));return e.value===`tomorrow`?{value:e.value,label:`Tomorrow`,wake:t.replace(/^Tomorrow at /,``)}:{value:e.value,label:e.label,wake:t}}),[n]),C=y?b?`Bumps ${jD(y)}`:`Snoozed until ${jD(y)}`:null,w=C?b?`${C}\n${b}`:C:`Snooze`;async function T(n,r=null){s(!0);try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:n,prompt:n?r:null}),n?(Z(`${r?`Bump scheduled`:`Snoozed`} · ${jD(n)}`),t?.()):Z(`Snooze cleared`),l(!1),h(``)}catch(e){let t=e instanceof Error?e.message:`Snooze failed`;Z(t.slice(0,100)),h(t)}finally{s(!1)}}function E(){d(kD(new Date(y??DD(`1d`)))),p(e.snoozePrompt??``),h(``),l(!0)}function D(){let e=AD(u);if(!e.ok){h(e.message);return}let t=f.trim();if(t.length>4e3){h(`Prompt is too long (${t.length}/${Zu})`);return}T(e.until,t||null)}return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(iR,{open:n,onOpenChange:e=>{r(e),e||a(!0)},children:[(0,R.jsx)(IP,{label:w,multiline:!!b,disabled:n||i,children:(0,R.jsx)(aR,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,disabled:o,"data-snooze-menu":!0,"data-snoozed":y?`true`:`false`,"aria-label":C??`Snooze`,"aria-description":y&&b?b:void 0,onMouseDown:e=>e.preventDefault(),onBlur:()=>a(!1),onPointerLeave:()=>a(!1),className:`${y?Mk.replace(/(^| )text-muted( |$)/,`$1text-attention-90$2`):Mk} ${n?`bg-panel-2`:``}`,children:o?(0,R.jsx)(M_,{size:14,strokeWidth:2,className:`animate-spin`}):(0,R.jsx)(Jg,{size:14,strokeWidth:2})})})}),(0,R.jsxs)(oR,{align:`end`,children:[(0,R.jsx)(`div`,{className:`px-2.5 pb-1 pt-1.5 text-[11px] text-muted-60`,children:C??`Snooze`}),y&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(sR,{onSelect:()=>void T(null),icon:(0,R.jsx)(uee,{size:12}),children:`Wake now`}),(0,R.jsx)(cR,{})]}),S.map(e=>(0,R.jsx)(sR,{onSelect:()=>void T(DD(e.value)),icon:(0,R.jsx)(Jg,{size:12}),children:(0,R.jsxs)(`span`,{"data-snooze-preset":e.value,className:`flex min-w-0 flex-1 items-center justify-between gap-6`,children:[(0,R.jsx)(`span`,{children:e.label}),(0,R.jsx)(`span`,{className:`text-[10.5px] text-muted-55`,children:e.wake})]})},e.value)),(0,R.jsx)(cR,{}),(0,R.jsx)(sR,{onSelect:E,children:`Custom time & prompt…`})]})]}),(0,R.jsx)(Oq,{open:c,onOpenChange:e=>{o||l(e)},title:`Snooze thread`,className:`w-[360px] max-w-[92vw]`,footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>l(!1),className:`button-outline 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,R.jsxs)(`button`,{type:`submit`,form:v,disabled:o,className:`button-outline 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:[o&&(0,R.jsx)(M_,{size:12,className:`animate-spin`}),f.trim()?`Snooze & bump`:`Snooze`]})]}),children:(0,R.jsxs)(`form`,{id:v,className:`flex flex-col gap-2.5 p-4`,onSubmit:e=>{e.preventDefault(),D()},children:[(0,R.jsx)(`label`,{htmlFor:g,className:`text-[11px] font-medium text-muted`,children:`Wake at this local time`}),(0,R.jsx)(`input`,{id:g,type:`datetime-local`,required:!0,min:x,value:u,onChange:e=>{d(e.target.value),h(``)},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,R.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,R.jsxs)(`label`,{htmlFor:_,className:`mt-1 text-[11px] font-medium text-muted`,children:[`Then send this prompt `,(0,R.jsx)(`span`,{className:`font-normal text-muted-55`,children:`(optional)`})]}),(0,R.jsx)(`textarea`,{id:_,"data-1p-ignore":!0,autoFocus:!0,rows:3,maxLength:Zu,placeholder:`e.g. Check whether CI went green and land it if so.`,value:f,onChange:e=>{p(e.target.value),h(``)},onKeyDown:e=>{_z({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(),D())},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,R.jsx)(`p`,{className:`min-h-4 text-[10.5px] text-muted-65`,children:f.trim()?`frizz will resume this thread with the prompt at the wake time.`:`Leave empty to just bring the card back to your queue.`}),m&&(0,R.jsx)(`p`,{role:`alert`,className:`text-[11px] text-danger`,children:m})]})})]})}function Aq({thread:e,onArchived:t,onDismissCancel:n,onSnoozed:r}){let i=zK(e);return i.lifecycle?(0,R.jsxs)(`span`,{"data-thread-lifecycle":!0,role:`group`,"aria-label":`Thread lifecycle actions`,className:`flex shrink-0 items-center gap-0.5`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,"data-lifecycle-rule":!0,className:`mx-2.5 h-4 w-px shrink-0 bg-border`}),i.done?(0,R.jsx)(jq,{}):(0,R.jsxs)(R.Fragment,{children:[i.snooze&&(0,R.jsx)(kq,{thread:e,onSnoozed:r}),(0,R.jsx)(Mq,{thread:e,onArchived:t,onDismissCancel:n,iconOnly:!0})]})]}):null}function jq(){let e=`Marked done — send a message to reopen it`;return(0,R.jsx)(IP,{label:e,children:(0,R.jsxs)(`span`,{"data-thread-done":!0,"aria-label":e,className:`flex h-7 items-center gap-1 rounded-md px-2 text-[12px] font-medium text-muted`,children:[(0,R.jsx)(e_,{size:12}),`Done`]})})}function Mq({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=``,iconSize:a=12,iconOnly:o=!1}){let[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(void 0),p=(r,i)=>{c(!0),i&&t?.(),(r||BK(e))&&ZW(e.id),Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:r}).then(r=>{if(r.needsConfirmation){QW(e.id),i&&n?.(),f(r.hold),u(!0),c(!1);return}u(!1),Z(`Done`),i||t?.()}).catch(t=>{QW(e.id),i&&n?.(),Z(`Couldn’t finish: ${t.message.slice(0,80)}`),c(!1)})},m=!!t&&!!n&&BK(e);return(0,R.jsxs)(R.Fragment,{children:[o?(0,R.jsx)(IP,{label:`Mark as done`,children:(0,R.jsx)(`button`,{type:`button`,onClick:()=>p(!1,m),disabled:s,"aria-label":`Mark as done`,onMouseDown:e=>e.preventDefault(),className:Mk,children:(0,R.jsx)(e_,{size:15,strokeWidth:2})})}):(0,R.jsxs)(`button`,{type:`button`,onClick:()=>p(!1,m),disabled:s,"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-focus-ink-60 disabled:opacity-45 ${r}`,children:[(0,R.jsx)(e_,{size:a,className:i}),`Mark as done`]}),(0,R.jsx)(Oq,{open:l,onOpenChange:e=>{s||u(e)},title:d?.cutOff?`Mark an unfinished thread done?`:`End this session?`,className:`w-[390px] max-w-[92vw]`,footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>u(!1),className:`button-outline 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,R.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>p(!0,!1),className:`button-outline 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:[s&&(0,R.jsx)(M_,{size:12,className:`animate-spin`}),d?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,R.jsx)(Nq,{hold:d})})]})}function Nq({hold:e}){let t=VK(e);return(0,R.jsxs)(`div`,{"data-completion-hold":!0,className:`flex flex-col gap-2 p-4 text-[12px] leading-relaxed text-muted`,children:[(0,R.jsx)(`p`,{children:t.lead}),t.groups.map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-fg/70`,children:e.heading}),(0,R.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[e.items.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:ek,children:`⤷`}),(0,R.jsx)(`span`,{className:`min-w-0 truncate text-fg/80`,children:e.label}),e.stale&&(0,R.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-60`,children:`no recent output`})]},`${e.label}-${t}`)),e.overflow>0&&(0,R.jsxs)(`li`,{className:`pl-[15px] text-muted-60`,children:[`+`,e.overflow,` more`]})]})]},e.kind)),(0,R.jsx)(`p`,{children:t.trailer})]})}function Pq({slug:e,onClose:t,onArchived:n,initialView:r=`actions`}){let i=gr(X),a=i.board?.threads.find(t=>t.id===e),[o,s]=(0,L.useState)(r),c=kg(t);if((0,L.useEffect)(()=>{i.board&&!a&&c()},[i.board,a,c]),!a)return null;let l=UD(a);return(0,R.jsx)(dq,{title:`Thread actions: ${l}`,onRequestClose:()=>c(),dataAttr:`data-thread-actions-sheet`,children:o===`actions`?(0,R.jsx)(Fq,{thread:a,title:l,setView:s,dismiss:c,onArchived:n}):o===`snooze`?(0,R.jsx)(Lq,{thread:a,back:()=>s(`actions`),custom:()=>s(`snooze-custom`),dismiss:c}):o===`snooze-custom`?(0,R.jsx)(Rq,{thread:a,back:()=>s(`snooze`),dismiss:c}):o===`goal`?(0,R.jsx)(zq,{thread:a,back:()=>s(`actions`)}):o===`files`?(0,R.jsx)(Bq,{thread:a,back:r===`files`?void 0:()=>s(`actions`),dismiss:c}):(0,R.jsx)(Uq,{thread:a,back:()=>s(`actions`),dismiss:c})})}function Fq({thread:e,title:t,setView:n,dismiss:r,onArchived:i}){let a=qe(),o=QK(),s=gr(zD).snoozePreset,c=zK(e),l=e.kind===`session`&&e.foreign!==!0,u=gf(e),d=e.recurringPrompt?.stopHook===!0||e.recurringPrompt?.heartbeat===!0||e.recurringPrompt?.postCompaction===!0,f=e.links??[],p=e.runtime===`running`||e.runtime===`spawning`,m=l&&_O(e),h=eq(e,o),g=$K(e),_=Wq(e),v=[sq(e.context),_].filter(Boolean).join(` · `);return(0,R.jsxs)(`div`,{"data-thread-actions-list":!0,children:[(0,R.jsx)(qq,{children:t}),c.snooze&&(0,R.jsx)(Kq,{data:`snooze`,icon:(0,R.jsx)(Jg,{size:19}),label:`Snooze`,value:u?jD(u):TD(s),chevron:!0,onClick:()=>n(`snooze`)}),l&&(0,R.jsx)(Kq,{data:`goal`,icon:(0,R.jsx)(mq,{size:19,className:d?`text-attention-90`:void 0}),label:`Goal`,value:d?`on`:`off`,chevron:!0,onClick:()=>n(`goal`)}),f.length>0&&(0,R.jsx)(Kq,{data:`files`,icon:(0,R.jsx)(v_,{size:19}),label:`Files and links`,value:String(f.length),chevron:!0,onClick:()=>n(`files`)}),p&&c.archive&&(0,R.jsx)(Mq,{thread:e,iconSize:19,iconClassName:`shrink-0 text-muted`,onArchived:()=>r(i),className:`${Gq} !gap-[14px] !font-normal`}),(0,R.jsx)(`div`,{className:`my-1 h-px bg-border`}),l&&(0,R.jsx)(Kq,{data:`rename`,icon:(0,R.jsx)(H_,{size:19}),label:`Rename`,onClick:()=>n(`rename`)}),(0,R.jsx)(Kq,{data:`copy-link`,icon:(0,R.jsx)(m_,{size:19}),label:`Copy link`,onClick:()=>{let t=new URL(HE(`/thread/${encodeURIComponent(e.id)}`),location.origin).href;r(()=>{eH(t).then(()=>Z(`Link copied`)).catch(e=>Z(`Couldn’t copy: ${e.message.slice(0,80)}`))})}}),m&&(0,R.jsx)(Kq,{data:`retry`,icon:(0,R.jsx)(X_,{size:19}),label:`Retry`,onClick:()=>r(()=>void kW(a,e.id))}),h&&(0,R.jsx)(Kq,{data:`restart-worker`,icon:(0,R.jsx)(J_,{size:19}),label:`Restart worker`,onClick:()=>r(()=>void ZK(a,e.id))}),g&&(0,R.jsx)(Kq,{data:`reload-plugins`,icon:(0,R.jsx)(K_,{size:19}),label:`Reload plugins`,onClick:()=>r(()=>void tq(e))}),v&&(0,R.jsx)(`div`,{"data-thread-actions-foot":!0,className:`px-[18px] pt-2.5 text-[12.5px] leading-[17px] text-muted`,children:v})]})}function Iq(e,t){let[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(``);async function o(n,i=null){r(!0),a(``);try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:n,prompt:n?i:null}),t(()=>Z(n?`${i?`Bump scheduled`:`Snoozed`} · ${jD(n)}`:`Snooze cleared`))}catch(e){let t=e instanceof Error?e.message:`Snooze failed`;Z(t.slice(0,100)),a(t)}finally{r(!1)}}return{busy:n,error:i,setError:a,apply:o}}function Lq({thread:e,back:t,custom:n,dismiss:r}){let i=gr(zD).snoozePreset,a=gf(e),{busy:o,apply:s}=Iq(e,r),c=e=>{zD.snoozePreset=e,s(DD(e))};return(0,R.jsxs)(`div`,{"data-thread-actions-snooze":!0,children:[(0,R.jsx)(Jq,{back:t,children:`Snooze`}),a&&(0,R.jsxs)(`p`,{className:`px-[18px] pb-2 text-[13px] text-muted`,children:[`Snoozed until `,jD(a).replace(/^(Today|Tomorrow)/,e=>e.toLowerCase())]}),SD.map(e=>(0,R.jsx)(Kq,{data:`snooze-${e.value}`,disabled:o,icon:(0,R.jsx)(Jg,{size:19}),label:e.label,value:e.detail,trailing:e.value===i?(0,R.jsx)(e_,{size:16,className:`text-fg/80`}):(0,R.jsx)(`span`,{className:`w-4`}),onClick:()=>c(e.value)},e.value)),(0,R.jsx)(`div`,{className:`my-1 h-px bg-border`}),(0,R.jsx)(Kq,{data:`snooze-custom`,disabled:o,icon:(0,R.jsx)(H_,{size:19}),label:`Custom time & prompt…`,chevron:!0,onClick:n}),a&&(0,R.jsx)(Kq,{data:`snooze-wake`,disabled:o,icon:(0,R.jsx)(X_,{size:19}),label:`Wake now`,onClick:()=>void s(null)})]})}function Rq({thread:e,back:t,dismiss:n}){let r=gr(zD).snoozePreset,i=gf(e),{busy:a,error:o,setError:s,apply:c}=Iq(e,n),[l,u]=(0,L.useState)(()=>kD(new Date(i??DD(r)))),[d,f]=(0,L.useState)(e.snoozePrompt??``),p=(0,L.useMemo)(()=>kD(new Date(Date.now()+6e4)),[]),m=(0,L.useId)(),h=(0,L.useId)(),g=()=>{let e=AD(l);if(!e.ok)return s(e.message);let t=d.trim();if(t.length>4e3)return s(`Prompt is too long (${t.length}/${Zu})`);c(e.until,t||null)};return(0,R.jsxs)(`form`,{"data-thread-actions-snooze-custom":!0,className:`flex flex-col`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,R.jsx)(Jq,{back:t,children:`Custom snooze`}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 px-[18px]`,children:[(0,R.jsx)(`label`,{htmlFor:m,className:`text-[13px] font-medium text-muted`,children:`Wake at this local time`}),(0,R.jsx)(`input`,{id:m,type:`datetime-local`,required:!0,min:p,value:l,onChange:e=>{u(e.target.value),s(``)},className:`h-11 w-full rounded-lg border border-border bg-bg px-3 text-[16px] text-fg outline-none focus:border-border-strong`}),(0,R.jsxs)(`label`,{htmlFor:h,className:`mt-2 text-[13px] font-medium text-muted`,children:[`Then send this prompt `,(0,R.jsx)(`span`,{className:`font-normal text-muted-70`,children:`(optional)`})]}),(0,R.jsx)(`textarea`,{id:h,"data-1p-ignore":!0,rows:3,maxLength:Zu,placeholder:`e.g. Check whether CI went green and land it if so.`,value:d,onChange:e=>{f(e.target.value),s(``)},className:`w-full resize-none rounded-lg border border-border bg-bg px-3 py-2 text-[16px] leading-[22px] text-fg outline-none placeholder:text-muted-50 focus:border-border-strong`}),(0,R.jsx)(`p`,{className:`text-[12.5px] text-muted`,children:d.trim()?`Frizz will resume this thread with the prompt at the wake time.`:`Leave it empty to just bring the thread back to your queue.`}),o&&(0,R.jsx)(`p`,{role:`alert`,className:`text-[13px] text-danger`,children:o}),(0,R.jsxs)(`button`,{type:`submit`,disabled:a,className:`mt-1 flex h-[46px] items-center justify-center gap-2 rounded-xl bg-fg text-[15.5px] font-semibold text-bg outline-none disabled:opacity-45`,children:[a&&(0,R.jsx)(M_,{size:16,className:`animate-spin`}),d.trim()?`Snooze and bump`:`Snooze`]})]})]})}function zq({thread:e,back:t}){return(0,R.jsxs)(`div`,{"data-thread-actions-goal":!0,children:[(0,R.jsx)(Jq,{back:t,children:`Goal`}),(0,R.jsx)(`div`,{className:`px-[18px] text-[13.5px] leading-relaxed text-fg [&_input]:!text-[16px] [&_textarea]:!min-h-[6rem] [&_textarea]:!text-[16px] [&_textarea]:!leading-[22px]`,children:(0,R.jsx)(Dq,{thread:e,armed:e.recurringPrompt,close:t,heading:!1})})]})}function Bq({thread:e,back:t,dismiss:n}){let r=[...e.links??[]].reverse();return(0,R.jsxs)(`div`,{"data-thread-actions-files":!0,children:[t?(0,R.jsx)(Jq,{back:t,count:r.length,children:`Files and links`}):(0,R.jsx)(qq,{count:r.length,children:`Files and links`}),r.length===0&&(0,R.jsx)(`p`,{className:`px-[18px] pb-2 text-[14px] text-muted`,children:`Nothing registered yet.`}),r.map(e=>(0,R.jsx)(Vq,{link:e,dismiss:n},e.id))]})}function Vq({link:e,dismiss:t}){let n=e.kind===`link`,r=n&&lq(e.target),i=gr(X).board?.projectDir,a=n?r?`${uq(e.target)} — not reachable from this phone`:uq(e.target):Hq(e.target,i),o=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`flex h-[21px] w-[19px] shrink-0 items-center justify-center text-muted`,children:n?(0,R.jsx)(g_,{size:19}):(0,R.jsx)(v_,{size:19})}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{"data-link-label":!0,className:`block truncate text-[15.5px] leading-[21px] text-fg`,children:e.label}),(0,R.jsx)(`span`,{"data-link-destination":!0,className:`block truncate text-[12.5px] leading-[17px] text-muted`,children:a})]}),!r&&(0,R.jsx)(r_,{size:15,className:`shrink-0 self-center text-muted-70`})]}),s=`flex min-h-[56px] w-full items-start gap-[14px] px-[18px] py-[9px] text-left outline-none focus-visible:bg-hover`;return r?(0,R.jsx)(`div`,{"data-thread-link":e.id,"data-link-unreachable":!0,title:e.target,className:s,children:o}):n?(0,R.jsx)(`a`,{"data-thread-link":e.id,title:e.target,href:e.target,target:`_blank`,rel:`noopener noreferrer`,className:`${s} active:bg-hover`,onClick:()=>t(),children:o}):(0,R.jsx)(`button`,{type:`button`,"data-thread-link":e.id,title:e.target,className:`${s} active:bg-hover`,onClick:()=>t(()=>YK(e.target)),children:o})}function Hq(e,t){if(t&&e.startsWith(`${t.replace(/\/+$/,``)}/`))return e.slice(t.replace(/\/+$/,``).length+1);let n=e.split(`/`).filter(Boolean);return n.length>2?`…/${n.slice(-2).join(`/`)}`:e}function Uq({thread:e,back:t,dismiss:n}){let r=UD(e),[i,a]=(0,L.useState)(()=>WK(r,e.id)),o=(0,L.useRef)(null),s=pt({mutationFn:t=>Y.renameThread({slug:e.id,title:t})}),c=pt({mutationFn:()=>Y.aiRenameThread({slug:e.id})}),l=GK(e);(0,L.useEffect)(()=>{let e=requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>cancelAnimationFrame(e)},[]);let u=()=>{let e=UK(i,r);if(!e)return t();s.mutate(e,{onSuccess:()=>n(()=>Z(`Thread renamed`)),onError:e=>Z(e instanceof Error?e.message:`Could not rename thread`)})};return(0,R.jsxs)(`form`,{"data-thread-actions-rename":!0,onSubmit:e=>{e.preventDefault(),u()},children:[(0,R.jsx)(Jq,{back:t,children:`Rename`}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 px-[18px]`,children:[(0,R.jsx)(`input`,{ref:o,"aria-label":`Thread title`,value:i,maxLength:200,onChange:e=>a(e.target.value),"data-claims-escape":!0,className:`h-11 w-full rounded-lg border border-border bg-bg px-3 text-[16px] text-fg outline-none focus:border-border-strong`}),(0,R.jsxs)(`button`,{type:`submit`,disabled:s.isPending,className:`flex h-[46px] items-center justify-center gap-2 rounded-xl bg-fg text-[15.5px] font-semibold text-bg outline-none disabled:opacity-45`,children:[s.isPending&&(0,R.jsx)(M_,{size:16,className:`animate-spin`}),`Save`]})]}),l.show&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`mt-3 mb-1 h-px bg-border`}),(0,R.jsx)(Kq,{data:`ai-rename`,disabled:c.isPending,icon:c.isPending?(0,R.jsx)(M_,{size:19,className:`animate-spin`}):(0,R.jsx)(Z_,{size:19}),label:c.isPending?`Claude is naming it…`:`Rename with Claude`,onClick:()=>{if(!l.enabled)return Z(l.label);c.mutate(void 0,{onSuccess:({title:e})=>n(()=>Z(`Renamed to “${e}”`)),onError:e=>Z(e instanceof Error?e.message:`Could not rename with Claude`,{duration:7e3})})}})]})]})}function Wq(e){let t=!!(e&&!e.foreign&&e.kind===`session`),n=ct({queryKey:[`threadProfileOptions`,e?.id??``],queryFn:()=>Y.threadProfileOptions({slug:e.id}),enabled:t,staleTime:5e3});if(!e)return null;let r=e.model?.trim(),i=e.effort?.trim();if(!r&&!i&&!e.runningModelLabel)return null;let a=oB([{id:e.backend??`claude`,label:``,options:n.data?.options??[]}],{model:r,effort:i},``,e.runningModelLabel);return[[a.name,a.edition].filter(Boolean).join(` `)||null,aq(a.effort)].filter(Boolean).join(` · `)||null}var Gq=`flex min-h-[50px] w-full items-center gap-[14px] px-[18px] text-left text-[15.5px] leading-[21px] text-fg outline-none transition-colors active:bg-hover focus-visible:bg-hover disabled:opacity-45`;function Kq({icon:e,label:t,value:n,chevron:r,trailing:i,onClick:a,disabled:o,data:s}){return(0,R.jsxs)(`button`,{type:`button`,"data-thread-action":s,disabled:o,onClick:a,className:Gq,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`flex w-[19px] shrink-0 items-center justify-center text-muted`,children:e}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),(n||r||i)&&(0,R.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 text-[14px] text-muted`,children:[n,r&&(0,R.jsx)(r_,{size:15,className:`text-muted-70`}),i]})]})}function qq({children:e,count:t}){return(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2 px-[18px] pb-2.5 pt-1`,children:[(0,R.jsx)(`span`,{"data-thread-actions-title":!0,className:`min-w-0 flex-1 truncate text-[16px] font-semibold leading-[22px]`,children:e}),t!==void 0&&(0,R.jsx)(`span`,{className:`shrink-0 text-[12.5px] text-muted`,children:t})]})}function Jq({children:e,back:t,count:n}){return(0,R.jsxs)(`div`,{className:`flex items-center gap-0.5 pb-1 pl-[6px] pr-[18px]`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":`Back`,onClick:t,className:`flex size-11 shrink-0 items-center justify-center rounded-full text-fg/85 outline-none active:bg-hover focus-visible:bg-hover`,children:(0,R.jsx)(n_,{size:21})}),(0,R.jsx)(`span`,{"data-thread-actions-title":!0,className:`min-w-0 flex-1 truncate text-[16px] font-semibold leading-[22px]`,children:e}),n!==void 0&&(0,R.jsx)(`span`,{className:`shrink-0 text-[12.5px] text-muted`,children:n})]})}function Yq({t:e}){let{node:t,tip:n}=wG(e),r=n?.split(`
|
|
213
|
+
`)}var EG=(0,R.jsx)(RO,{children:(0,R.jsx)(`span`,{"aria-hidden":!0,className:`frizz-rail-dot`,"data-running-indicator":`thread-background`})}),DG=(0,R.jsx)(IG,{children:(0,R.jsx)(`span`,{"aria-hidden":!0,className:`frizz-rail-dot`})}),OG=9,kG=(0,R.jsx)(E_,{size:OG,className:`text-muted-70`,style:{transform:`translateX(${OG/24}px)`}}),AG=(0,R.jsx)(IG,{children:kG}),jG=(0,R.jsx)(h_,{size:11,className:`text-muted-70`}),MG=(0,R.jsx)(IG,{children:(0,R.jsx)(D_,{size:9,className:`text-muted-70`})}),NG=(0,R.jsx)(IG,{children:(0,R.jsx)(Jg,{size:9,className:`text-muted/70`})});function PG(e,t=Date.now()){let n=(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`).map(e=>Date.parse(e.timer?.fireAt??``)).filter(e=>Number.isFinite(e)).sort((e,t)=>e-t)[0];return n===void 0?null:n>t?`fires in ${GO(n-t)}`:`firing…`}function FG(e){let t=hO(e);if(t===`archived`)return{node:(0,R.jsx)(IG,{children:(0,R.jsx)(e_,{size:10,strokeWidth:3,className:`text-muted-75`})}),tip:`Done`};if(t===`needs-input`)return{node:(0,R.jsx)(IG,{children:(0,R.jsx)(LG,{ch:`?`,muted:!0})}),tip:`Needs your input`};if(t===`working`)return dO(e)?{node:(0,R.jsx)(RO,{children:(0,R.jsx)(LG,{ch:`?`,muted:!0})}),tip:`Working — a question is waiting on your answer`}:uO(e)?{node:(0,R.jsx)(RO,{children:jG}),tip:`At rest — waiting on its sub-agents`}:{node:(0,R.jsx)(RO,{}),tip:`Working`};if(t===`background`){let t=e.lastFence?.kind===`awaiting`&&WW(e.lastFence.hints)!==null;return{node:lO(e)?EG:DG,tip:bG(e,t?`At rest`:`At rest — a background shell is still running`)}}if(t===`done`)return{node:(0,R.jsx)(IG,{children:(0,R.jsx)(e_,{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,R.jsx)(IG,{accent:!0,children:(0,R.jsx)(LG,{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 ${kO(t.resumesAt)}`:`continuing automatically once the window resets`:`won't resume by itself — Retry to continue`;return{node:(0,R.jsx)(IG,{accent:!0,children:(0,R.jsx)(D_,{size:9,className:`text-accent`})}),tip:`Paused by the ${t?.backend===`codex`?`Codex`:`Claude`} ${n} — ${r}`}}if(t===`pr`){let t=bG(e,cO(e)?`At rest — checks are running`:`At rest`);return lO(e)?{node:(0,R.jsx)(RO,{children:kG}),tip:t}:{node:AG,tip:t}}if(t===`timer`)return{node:MG,tip:bG(e,e.lastFence?.kind===`awaiting`&&WW(e.lastFence.hints)!==null?`At rest`:`At rest — waiting on a timer`,PG(e))};if(t===`snoozed`){let t=MG,n=AG,r=pO(e)?n:NG,i=gf(e);if(i){let t=ND(i,e.snoozePrompt)??`Snoozed until a scheduled check`;return{node:r,tip:bG(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`){if(a)return{node:pO(e)?n:DG,tip:a};if(e.waitStatus===`watching`){let r=(e.bgShells??[]).some(e=>e.state===`running`);return{node:pO(e)?n:r?DG:t,tip:`Snoozed until its watch reports back`}}return{node:t,tip:(typeof e.revalidate==`string`?PD(e.revalidate):null)??`Auto-snoozed until a scheduled check`}}let o=e.lastFence.hints.find(e=>e.kind===`pr`||e.kind===`issue`||e.kind===`shell`||e.kind===`agent`||e.kind===`timer`)?.kind;return{node:pO(e)?n:o===`shell`||o===`agent`?DG:t,tip:bG(e,a??`Snoozed`,o===`timer`?PG(e):null)}}return{node:(0,R.jsx)(IG,{children:jG}),tip:bG(e,`At rest`)}}function IG({accent:e,children:t}){return(0,R.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 LG({ch:e,muted:t}){return(0,R.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 RG(e){if(e.runtime===`running`||e.runtime===`spawning`||e.runtime===`perm-prompt`)return{node:(0,R.jsx)(zG,{}),tip:`Working`};let t=(e.subAgents??[]).some(e=>e.state===`running`);return e.runtime===`turn-idle`&&t&&!e.humanBlocked?{node:(0,R.jsx)(zG,{}),tip:`Working`}:Sf(e)?{node:(0,R.jsx)(BG,{}),tip:`Needs your input`}:e.status===`needs-human`?{node:(0,R.jsx)(VG,{}),tip:`Awaiting you — open to read & reply`}:e.status===`blocked`&&e.mechanism===`timer`?{node:(0,R.jsx)(av,{size:8,className:`text-muted-70`}),tip:`Waiting on a timer`}:e.status===`blocked`&&e.mechanism===`threads`?{node:(0,R.jsx)(c_,{size:8,className:`text-muted-70`}),tip:`Waiting on other work`}:{node:(0,R.jsx)(HG,{}),tip:null}}function zG(){return(0,R.jsx)(`span`,{className:`block rounded-full border border-muted/70 border-t-transparent animate-spin`,style:{width:8,height:8}})}function BG(){return(0,R.jsx)(`span`,{className:`block rounded-full bg-planning`,style:{width:SG,height:SG}})}function VG(){return(0,R.jsx)(`span`,{className:`block rounded-full bg-needs-human`,style:{width:SG,height:SG}})}function HG(){return(0,R.jsx)(`span`,{className:`block rounded-full bg-muted/30`,style:{width:SG,height:SG}})}function UG(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 WG=new Set([`agent`,`follow up`,`interrupt`,`send message`,`spawn agent`,`wait for agents`]),GG=new Set([`poll process`,`wait`]);function KG(e){return(e.split(`__`).pop()||e).replaceAll(`_`,` `).trim()}function qG(e){return KG(e).toLowerCase()}function JG(e){return e.prompt!==void 0||e.agentId!==void 0||e.sendTo!==void 0||e.sendBody!==void 0||e.backgroundState!==void 0&&!QG(e)&&!YG(e)||ZG(e)||XG(e)||WG.has(qG(e.name))}function YG(e){return e.backgroundState===`background`&&cK(e)}function XG(e){return e.ask!==void 0&&e.ask.length>0&&e.status!==void 0&&e.status!==`pending`}function ZG(e){return e.sentImages!==void 0&&e.sentImages.length>0}function QG(e){return e.backgroundState===`unknown`&&GG.has(qG(e.name))}function $G(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=>!JG(e))?t:null}return e.text.trim()||e.tools.length===0?null:e.tools.every(e=>!JG(e))?e.tools:null}function eK(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 tK(e){if(e.role!==`assistant`||e.kind||e.queued)return null;if(!e.parts?.length)return nK(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 nK(n.tools)}return null}function nK(e){let t=[];for(let n=e.length-1;n>=0&&!JG(e[n]);n--)t.unshift(e[n]);return t.length>0?t:null}function rK(e){if(e.role!==`assistant`||e.kind||e.queued)return null;let t=[],n=e=>{for(let n of e){if(JG(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 iK(e,t){return aK(e,new Set(t))}function aK(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 oK(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 sK(e){let t=[],n=null;return e.forEach((e,r)=>{if(eK(e))return;if(e.queued){t.push({message:e,messageIndex:r});return}let i=$G(e);if(i&&n){n.message=oK(n.message,i,e.at);return}let a=n?rK(e):null,o=a?iK(e,a):e;a&&n&&(n.message=oK(n.message,a,e.at));let s={message:o,messageIndex:r};t.push(s),tK(o)?(s.runStartedAt=o.at,n=s):n=null}),t}function cK(e){return e.status===`completed`||e.status===`failed`||e.status===`cancelled`}function lK(e){let t=uK(e);if(!t)return;let n=t.tools.filter(e=>!YG(e));return n.some(e=>!cK(e))?n.at(-1):void 0}function uK(e){let t=dK(e);if(!t)return;let n=tK(t.message);return n?{tools:n,at:t.message.at}:void 0}function dK(e){for(let t=e.length-1;t>=0;t--)if(!e[t].message.queued)return e[t]}function fK(e){let t=dK(e);if(t)return tK(t.message)?t.runStartedAt??t.message.at:t.message.at}function pK(e){let t=tK(e);return t?aK(e,new Set(t)):e}function mK(e){let t;for(let n=e.length-1;n>=0;n--){let r=e[n].message;if(!r.queued){tK(r)&&(t=r);break}}if(!t)return[...e];let n=[];for(let r of e){let e=r.message===t?pK(r.message):r.message;eK(e)||n.push(e===r.message?r:{...r,message:e})}return n}function hK(e){return e.detail?.trim()||void 0}var gK={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 _K(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=gK[i.toLowerCase()];return a?a+(r===-1?``:n.slice(r)):n.charAt(0).toUpperCase()+n.slice(1)}function vK(e,t,n){let r=t?.trim().replace(/[\\/]+$/,``);if(!r||!gh(r))return e;let i=wh(r);return i?nee(e.replace(i,``),n?.trim().replace(/[\\/]+$/,``)||/^([A-Za-z]:[\\/]Users[\\/][^\\/]+|\/(?:Users|home)\/[^/]+)(?=[\\/]|$)/.exec(r)?.[1]):e}function yK(e,t,n=uh().home){return vK(bK(e),t,n)}function bK(e){let t=qG(e.name),n=hK(e),r=n?` ${n}`:``;return t===`bash`||t===`exec`||t===`run command`?_K(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 ${KG(e.name)||`a tool`}`}var xK=new Set([`edit`,`multiedit`,`write`,`apply patch`]);function SK(e){let t=new Set;for(let n of e){for(let e of n.edits??(n.edit?[n.edit]:[])){let n=e.file.trim();n&&!CK.test(n)&&t.add(n)}if(n.edit||n.edits?.length)continue;let e=n.detail?.trim();e&&!CK.test(e)&&xK.has(qG(n.name))&&t.add(e)}return t.size}var CK=/\$\{/;function wK(e,t=0){let n=`Ran ${e} tool ${e===1?`call`:`calls`}`;return t===0?n:`${n}, edited ${t} file${t===1?``:`s`}`}function TK(e){return e>0?`${wK(e)}. Thinking…`:`Thinking…`}function EK(e){return e.replace(/```[\w-]*/g,` `).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\*\*|__|`/g,``).replace(/(^|\s)[*_](\S[^*_]*?\S|\S)[*_](?=\s|$|[.,;:!?])/g,`$1$2`).replace(/\s+/g,` `).trim()}var DK=/^(?:```[\w-]*\s*|#{1,6}\s+|>\s*|[-*+]\s+|\d+[.)]\s+)+/,OK=/\n|\s(?:```|[-*+]\s|\d+[.)]\s|#{1,6}\s|>\s)/;function kK(e,t=!1){let n=(e??``).trim().replace(DK,``),r=t?null:OK.exec(n);if(r&&(n=n.slice(0,r.index)),!n.trim())return null;let i=/^(\*\*|__)(.{1,60}?)\1\s*/.exec(n);if(i){let e=EK(i[2]),t=EK(n.slice(i[0].length));if(e)return t?{lead:e,text:t}:{text:e}}let a=EK(n);return a?{text:a}:null}function AK(e){let t=e.split(`
|
|
214
|
+
`).map(e=>e.trim()).find(Boolean);return t&&EK(t)||null}function jK(e){return e.length>1?`${e.length} questions`:e.length===1?AK(e[0]):null}function MK(e,t){let n;for(let r of e.watches??[]){if(r.kind!==`timer`||r.state!==`armed`||!r.timer)continue;let e=Date.parse(r.timer.fireAt);!Number.isFinite(e)||e<=t||(!n||e<n.ms)&&(n={at:r.timer.fireAt,ms:e})}return n?.at}function NK(e,t=Date.now()){return gf(e,t)??MK(e,t)}function PK(e){return(e.subAgents??[]).filter(e=>e.state===`running`).length}function FK(e){return e>0?`${e} ${e===1?`agent`:`agents`}`:``}function IK(e,t,n,r=Date.now(),i){let a=e.lastFence?.kind===`awaiting`&&/^`{3,}awaiting\b/.test((e.lastAssistant??``).trimStart())?e.lastFence:void 0,o=()=>{if(a){let e=IW(a);if(e)return kK(e);let t=WW(a.hints);if(t)return{text:`${t.charAt(0).toUpperCase()}${t.slice(1)}`}}return kK(e.lastAssistantLine,!0)??kK(e.lastAssistant)};if(t===`needs-input`){let t=jK((e.questions??[]).map(e=>e.spec.question));if(t)return{text:t};let n=jK((e.pendingAsk?.questions??[]).map(e=>e.question));if(n)return{text:n};if(e.runtime===`perm-prompt`)return{text:`Waiting on a permission prompt`};let r=e.lastFence?.kind===`awaiting`?qW(e.lastFence.hints):null;return r?{text:r}:o()}if(n)return e.liveTool?{text:yK(e.liveTool,i)}:e.activity?{text:e.activity}:o();if(t===`snoozed`&&gf(e,r)!==void 0)return{text:`Snoozed by you`};let s=e.lastFence?.kind===`awaiting`?qW(e.lastFence.hints):null;return s?{text:s}:(t===`snoozed`||t===`timer`)&&MK(e,r)?{text:`Waiting on a timer`}:o()??(e.activity?{text:e.activity}:null)}var LK={planning:`Being designed`,planned:`Roadmap`,active:`Active`,"needs-human":`Awaiting you`,blocked:`Blocked`,done:`Done`,dismissed:`Dismissed`,archived:`Done`};function RK({status:e}){let t=$D(FE(ME()?.threads??[])).filter(t=>e===`archived`?t.archived:t.status===e);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`header`,{className:`shrink-0 flex items-center gap-2 px-4 h-10 border-b border-border`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:LK[e]??e}),(0,R.jsx)(`span`,{className:`text-[11px] text-muted tabular-nums`,children:t.length})]}),(0,R.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto py-1.5`,children:[t.length===0&&(0,R.jsx)(`p`,{className:`px-4 py-6 text-sm text-muted`,children:`No threads.`}),t.map(e=>(0,R.jsxs)(`button`,{className:`w-full text-left px-4 py-2 hover:bg-panel-2/60`,onClick:()=>qh(`thread`,e.id),children:[(0,R.jsx)(`div`,{className:`leading-snug`,children:HD(e)}),e.statusText&&(0,R.jsx)(`div`,{className:`text-[11px] text-muted mt-0.5`,children:e.statusText})]},e.id))]})]})}function zK(e){let t=e.kind===`session`&&e.foreign!==!0,n=t&&(e.state===`archived`||e.archived===!0),r=t,i=t&&!n;return{lifecycle:r,done:n,snooze:i,archive:i}}function BK(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=>Au(e)&&t(e))||e.bgShells?.some(t))}function VK(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=[HK(`agent`,`sub-agent`,e.subAgents,e.subAgentCount),HK(`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 HK(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 UK(e,t){let n=e.trim();if(!(!n||n===t.trim()))return n}function WK(e,t){let n=e.trim();return!n||n===t||n===`Untitled thread`||n===`Spinning up a thread…`?``:n}function GK(e){return e.kind!==`session`||e.foreign||e.backend===`codex`||e.backend===`acp`||e.claudeRuntime!==void 0&&e.claudeRuntime!==`broker`?{show:!1,enabled:!1,label:``}:e.runtime===`exited`||e.runtime===`none`?{show:!0,enabled:!1,label:`Resume this Claude thread to rename it with Claude`}:e.runtime===`spawning`?{show:!0,enabled:!1,label:`Rename with Claude once this thread has started`}:{show:!0,enabled:!0,label:`Rename with Claude — a fresh title from the opening request`}}function KK(){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(),t.dataset.localImage===`true`?JK(t,n):YK(n))};document.addEventListener(`click`,e);let t=qK();return document.addEventListener(`error`,t,!0),()=>{document.removeEventListener(`click`,e),document.removeEventListener(`error`,t,!0)}}function qK(){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 JK(e,t){if(!(e instanceof HTMLImageElement)){Rh([QR(t,e.textContent)],0);return}let n=e.closest(`[data-frizz-msg]`)??e.closest(`.md-body, .md-inline`),r=n?[...n.querySelectorAll(`img[data-local-image="true"][data-local-path]`)]:[e];Rh(r.map(e=>QR(e.dataset.localPath,e.alt)),Math.max(r.indexOf(e),0))}function YK(e,t=!1){if(!t&&KT(e)){og(e);return}if(!t&&X.splitFileViewer){cg(e);return}if(Ig()){t?window.open(BT(e),`_blank`,`noopener`):og(e);return}XK(e,t)}async function XK(e,t){try{let n=await Y.openLocalFile({path:e,...t?{image:!0}:{}});n.action===`copy`&&(await eH(n.path),Z(`Copied local path`))}catch(e){Z(`Could not open local file: ${e.message.slice(0,100)}`)}}function ZK(e,t){return new Promise(n=>{DW(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 QK(){return OU(RU().data??null)}function $K(e){return e.kind!==`session`||e.foreign||e.claudeRuntime!==`broker`?!1:e.runtime!==`exited`}function eq(e,t){return!t||e.kind!==`session`||e.foreign||e.backend===`codex`||e.backend===`acp`?!1:e.runtime!==`exited`}async function tq(e){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))}}function nq(e){let t=hO(e);return t===`needs-input`?`needs-you`:e.runtime===`running`||e.runtime===`spawning`?`working`:t===`archived`?`done`:t===`snoozed`&&gf(e)!==void 0?`snoozed`:`rested`}var rq={"needs-you":`Needs you`,working:`Working`,rested:`Rested`,snoozed:`Snoozed`,done:`Done`};function iq(e,t,n,r){if(t===`working`){let t=Date.parse(n??e.lastUserAt??e.spawnedAt??``);return Number.isFinite(t)&&KO(Math.max(0,r-t))||null}return TO(QD(e),r)}function aq(e){let t=e?.trim();if(t)return(HB[t]??t).toLowerCase()}function oq(e){if(e>=1e6){let t=Math.round(e/1e5)/10;return`${Number.isInteger(t)?t:t.toFixed(1)}M`}return e>=1e3?`${Math.round(e/1e3)}k`:String(e)}function sq(e){return!e||e.window<=0?null:`Context ${Math.max(0,Math.min(100,Math.floor(e.tokens/e.window*100)))}% · ${oq(e.tokens)} of ${oq(e.window)}`}function cq(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.role===`user`&&!n.queued&&n.at)return n.at}}function lq(e){try{let t=new URL(e).hostname.replace(/^\[|\]$/g,``);return t===`localhost`||t.endsWith(`.localhost`)||t===`::1`||/^127(?:\.\d{1,3}){3}$/.test(t)||t===`0.0.0.0`}catch{return!1}}function uq(e){try{let t=new URL(e),n=`${t.pathname===`/`?``:t.pathname}${t.search}${t.hash}`;return`${t.host}${n}`}catch{return e}}function dq({title:e,onRequestClose:t,children:n,footer:r,className:i=``,dataAttr:a}){let[o,s]=(0,L.useState)(!1),c=(0,L.useRef)(null);(0,L.useEffect)(()=>{let e=requestAnimationFrame(()=>s(!0));return()=>cancelAnimationFrame(e)},[]);let l=a?{[a]:``}:{};return(0,R.jsx)(hR,{open:!0,onOpenChange:e=>{e||t()},children:(0,R.jsxs)(yR,{children:[(0,R.jsx)(xR,{className:`fixed inset-0 z-[80] bg-scrim-50 transition-opacity duration-200 motion-reduce:transition-none ${o?`opacity-100`:`opacity-0`}`}),(0,R.jsxs)(TR,{ref:c,...l,"aria-describedby":void 0,onOpenAutoFocus:e=>{e.preventDefault(),c.current?.focus({preventScroll:!0})},onEscapeKeyDown:mB,className:`fixed inset-x-0 bottom-0 z-[80] flex max-h-[86%] flex-col overflow-hidden rounded-t-[14px] border-t border-border-strong bg-panel pb-[calc(14px+env(safe-area-inset-bottom))] shadow-[0_-20px_60px_-10px_var(--sheet-shadow)] outline-none transition-transform duration-200 ease-out motion-reduce:transition-none ${o?`translate-y-0`:`translate-y-full`} ${i}`,children:[(0,R.jsx)(AR,{className:`sr-only`,children:e}),(0,R.jsx)(`div`,{"aria-hidden":!0,className:`mx-auto mt-[6px] mb-[6px] h-[5px] w-[36px] shrink-0 rounded-full bg-muted/35`}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:n}),r]})]})})}var fq={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 pq({checked:e,onChange:t,disabled:n,label:r,size:i=`sm`,testId:a}){let o=fq[i];return(0,R.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-focus-ink-60 disabled:cursor-default disabled:opacity-45 ${o.track} ${o.onCap} ${e?`bg-fg`:`bg-border hover:bg-border-strong`}`,children:(0,R.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 mq({size:e=12,className:t=``}){return(0,R.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,R.jsx)(`path`,{d:`M11 12a1 1 0 1 0 2 0a1 1 0 1 0 -2 0`}),(0,R.jsx)(`path`,{d:`M12 7a5 5 0 1 0 5 5`}),(0,R.jsx)(`path`,{d:`M13 3.055a9 9 0 1 0 7.941 7.945`}),(0,R.jsx)(`path`,{d:`M15 6v3h3l3 -3h-3v-3l-3 3`}),(0,R.jsx)(`path`,{d:`M15 9l-3 3`})]})}function hq({thread:e}){let[t,n]=(0,L.useState)(`closed`),r=(0,L.useRef)(null),i=(0,L.useRef)(void 0);(0,L.useEffect)(()=>()=>clearTimeout(i.current),[]);let a=t!==`closed`,[o,s]=(0,L.useState)(null);(0,L.useLayoutEffect)(()=>{if(!a)return;let e=r.current?.closest(`[data-queue-card-root], [role="dialog"], main`);if(!e){s(null);return}let t=e.getBoundingClientRect().left+e.clientLeft,n=r.current?.closest(`[data-composer-box]`)?.getBoundingClientRect();s({surface:e,left:Math.max(12,n?n.left-t:0),right:Math.max(12,n?t+e.clientWidth-n.right:0)})},[a]);let c=o?{collisionBoundary:o.surface,collisionPadding:{top:12,bottom:12,left:o.left,right:o.right}}:{},l=e.recurringPrompt,u=l?.stopHook===!0||l?.heartbeat===!0||l?.postCompaction===!0;function d(){clearTimeout(i.current),i.current=setTimeout(()=>n(e=>e===`closed`?`preview`:e),gq)}function f(){clearTimeout(i.current),n(e=>e===`preview`?`closed`:e)}let p=e=>{r.current?.contains(e.detail.originalEvent.target)&&e.preventDefault()};return(0,R.jsxs)(CV,{open:t!==`closed`,onOpenChange:e=>{e||(clearTimeout(i.current),n(`closed`))},children:[(0,R.jsx)(TV,{asChild:!0,children:(0,R.jsx)(`button`,{ref:r,type:`button`,"data-recurring-prompt":!0,"data-recurring-prompt-on":u?`true`:`false`,"aria-label":u?`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`&&d()},onPointerLeave:e=>{e.pointerType===`mouse`&&f()},onFocus:()=>n(e=>e===`closed`?`preview`:e),onBlur:f,className:`group/goal icon-hover-outline flex h-7 w-7 items-center justify-center rounded-lg outline-none transition-[color,background-color] hover:bg-panel-2/70`,children:(0,R.jsx)(mq,{size:15,className:u?`text-attention-90`:`text-muted group-hover/goal:text-fg group-focus-visible/goal:text-fg`})})}),t===`preview`?(0,R.jsx)(EV,{side:`top`,align:`end`,...c,"data-recurring-preview":!0,onPointerDownOutside:p,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,R.jsx)(_q,{armed:l})}):(0,R.jsx)(EV,{side:`top`,align:`end`,...c,className:`w-[min(46rem,calc(100vw-1.5rem),var(--radix-popper-available-width,46rem))] p-3 text-[11px] leading-relaxed text-fg`,onPointerDownOutside:p,onOpenAutoFocus:e=>e.preventDefault(),onDragOver:e=>e.stopPropagation(),onDragLeave:e=>e.stopPropagation(),onDrop:e=>{e.stopPropagation(),e.dataTransfer.files.length>0&&e.preventDefault()},children:(0,R.jsx)(Dq,{thread:e,armed:l,close:()=>n(`closed`)})})]})}var gq=260;function _q({armed:e}){let t=e?.prompt?.trim(),n=e?Eq({stopHook:e.stopHook===!0,heartbeat:e.heartbeat===!0,postCompaction:e.postCompaction===!0,seconds:e.intervalSeconds??bq}):[];return(0,R.jsxs)(`div`,{"data-recurring-preview-body":!0,children:[(0,R.jsxs)(`div`,{className:`mb-1 flex items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Goal`}),(0,R.jsx)(`span`,{className:`text-muted-70`,children:n.length>0?`sent ${n.join(`, `)}`:t?`no trigger is on`:`not set`})]}),(0,R.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 vq=1,yq=1440,bq=600;function xq(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(yq,Math.max(vq,n))*60:t}var Sq=null;function Cq(e){return{prompt:e.text.trim(),stopHook:e.stopHook,heartbeat:e.heartbeat,postCompaction:e.postCompaction,seconds:e.seconds}}function wq(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 Tq(e,t){return!e.archived&&!t}function Eq(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 Dq({thread:e,armed:t,close:n,heading:r=!0}){let i=Tq(e,t)?nd:``,a=Sq?.slug===e.id?Sq.draft:null,[o,s]=(0,L.useState)(a?.text??t?.prompt??i),[c,l]=(0,L.useState)(a?.stopHook??t?.stopHook??!1),[u,d]=(0,L.useState)(a?.heartbeat??t?.heartbeat??!1),[f,p]=(0,L.useState)(a?.postCompaction??t?.postCompaction??!1),[m,h]=(0,L.useState)(a?.seconds??t?.intervalSeconds??bq),g=c||u||f,[_,v]=(0,L.useState)(String(Math.round((a?.seconds??t?.intervalSeconds??bq)/60))),y=(0,L.useRef)(null),b=(0,L.useRef)({prompt:t?.prompt??i,stopHook:t?.stopHook??!1,heartbeat:t?.heartbeat??!1,postCompaction:t?.postCompaction??!1,seconds:t?.intervalSeconds??bq}),x=e=>({text:o,stopHook:c,heartbeat:u,postCompaction:f,seconds:xq(_,m),...e}),S=(0,L.useRef)(x());S.current=x(),(0,L.useEffect)(()=>()=>{let n=S.current;if(wq(n,b.current)){Sq?.slug===e.id&&(Sq=null);return}if(n.text.trim()===``&&!t){Sq={slug:e.id,draft:n};return}w(n)},[]);let C=(0,L.useRef)(Promise.resolve(!0));function w(t){let n=C.current.catch(()=>!1).then(async()=>{let n=await T(t);return n?Sq?.slug===e.id&&(Sq=null):Sq={slug:e.id,draft:t},n});return C.current=n,n}async function T(t){let n=t.text.trim()||null;if(wq(t,b.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}}),b.current={...Cq(t),prompt:n??``};let r=Eq(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 E(){if(wq(x(),b.current)||o.trim()===``&&!t){n();return}w(x()).then(e=>{e&&n()})}function D(){let e=xq(_,m);v(String(Math.round(e/60))),h(e)}let O=[{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),k=O.reduce((e,t)=>e&&Date.parse(e.at)>=Date.parse(t.at)?e:t,void 0),A=k===void 0?null:O.length>1?`Last sent ${XO(k.at)}`:`Last sent ${k.how} ${XO(k.at)}`;return(0,R.jsxs)(`section`,{"data-recurring-panel":!0,children:[r?(0,R.jsxs)(`div`,{className:`mb-2 flex items-center gap-3`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Goal`}),A&&(0,R.jsx)(`span`,{className:`ml-auto truncate text-muted-55`,children:A})]}):A?(0,R.jsx)(`div`,{className:`mb-2 truncate text-muted-55`,children:A}):null,(0,R.jsx)(`textarea`,{ref:y,"data-recurring-text":!0,"data-1p-ignore":!0,value:o,maxLength:$u,onChange:e=>s(e.target.value),onKeyDown:e=>{gz({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())},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 ${g?`text-fg`:`text-muted`}`}),(0,R.jsxs)(`div`,{className:`mt-3 grid grid-cols-[auto_auto_1fr] items-baseline gap-x-2.5 gap-y-2`,children:[(0,R.jsx)(pq,{testId:`stop-hook`,label:`Stop hook`,checked:c,onChange:e=>{l(e),e&&!o.trim()&&requestAnimationFrame(()=>y.current?.focus())}}),(0,R.jsx)(`span`,{className:`font-medium ${c?`text-fg`:`text-muted`}`,children:`Stop hook`}),(0,R.jsx)(`span`,{className:`text-muted`,children:`every rest — unless it signed off or parked on a wait`}),(0,R.jsx)(pq,{testId:`heartbeat`,label:`Heartbeat`,checked:u,onChange:e=>{d(e),e&&!o.trim()&&requestAnimationFrame(()=>y.current?.focus())}}),(0,R.jsx)(`span`,{className:`font-medium ${u?`text-fg`:`text-muted`}`,children:`Heartbeat`}),u?(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 text-muted`,children:[`every`,(0,R.jsx)(`input`,{type:`number`,"data-recurring-minutes":!0,inputMode:`numeric`,min:vq,max:yq,value:_,onChange:e=>v(e.target.value),onBlur:D,onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),D())},"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,R.jsx)(`span`,{className:`text-muted`,children:`on a clock, even mid-turn`}),(0,R.jsx)(pq,{testId:`post-compaction`,label:`Compaction`,checked:f,onChange:e=>{p(e),e&&!o.trim()&&requestAnimationFrame(()=>y.current?.focus())}}),(0,R.jsx)(`span`,{className:`font-medium ${f?`text-fg`:`text-muted`}`,children:`Compaction`}),(0,R.jsx)(`span`,{className:`text-muted`,children:`when the context is summarized away — link the doc to re-read`})]})]})}function Oq({open:e,onOpenChange:t,title:n,children:r,footer:i,className:a=`w-[640px] max-w-[92vw] max-h-[82vh]`,onOpenAutoFocus:o}){return(0,R.jsx)(hR,{open:e,onOpenChange:t,children:(0,R.jsxs)(yR,{children:[(0,R.jsx)(xR,{className:`overlay-in fixed inset-0 z-[200] bg-scrim-55 backdrop-blur-[1px]`}),(0,R.jsxs)(TR,{"aria-modal":`true`,onEscapeKeyDown:mB,onOpenAutoFocus:o,className:`pop-in fixed left-1/2 top-1/2 z-[200] flex -translate-x-1/2 -translate-y-1/2 flex-col overflow-hidden rounded-xl border border-border bg-panel shadow-2xl shadow-shadow-ink/50 outline-none ${a}`,children:[(0,R.jsxs)(`header`,{className:`flex h-11 shrink-0 items-center gap-2 border-b border-border px-4`,children:[(0,R.jsx)(AR,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:n}),(0,R.jsx)(MR,{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,R.jsx)(cv,{size:15})})]}),(0,R.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:r}),i&&(0,R.jsx)(`footer`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-border px-4 py-3`,children:i})]})]})})}function kq({thread:e,onSnoozed:t}){let[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(``),[f,p]=(0,L.useState)(``),[m,h]=(0,L.useState)(``),g=(0,L.useId)(),_=(0,L.useId)(),v=(0,L.useId)(),y=gf(e),b=e.snoozePrompt?.trim(),x=(0,L.useMemo)(()=>OD(new Date(Date.now()+6e4)),[c]),S=(0,L.useMemo)(()=>xD.map(e=>{let t=AD(ED(e.value));return e.value===`tomorrow`?{value:e.value,label:`Tomorrow`,wake:t.replace(/^Tomorrow at /,``)}:{value:e.value,label:e.label,wake:t}}),[n]),C=y?b?`Bumps ${AD(y)}`:`Snoozed until ${AD(y)}`:null,w=C?b?`${C}\n${b}`:C:`Snooze`;async function T(n,r=null){s(!0);try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:n,prompt:n?r:null}),n?(Z(`${r?`Bump scheduled`:`Snoozed`} · ${AD(n)}`),t?.()):Z(`Snooze cleared`),l(!1),h(``)}catch(e){let t=e instanceof Error?e.message:`Snooze failed`;Z(t.slice(0,100)),h(t)}finally{s(!1)}}function E(){d(OD(new Date(y??ED(`1d`)))),p(e.snoozePrompt??``),h(``),l(!0)}function D(){let e=kD(u);if(!e.ok){h(e.message);return}let t=f.trim();if(t.length>4e3){h(`Prompt is too long (${t.length}/${Zu})`);return}T(e.until,t||null)}return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(rR,{open:n,onOpenChange:e=>{r(e),e||a(!0)},children:[(0,R.jsx)(FP,{label:w,multiline:!!b,disabled:n||i,children:(0,R.jsx)(iR,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,disabled:o,"data-snooze-menu":!0,"data-snoozed":y?`true`:`false`,"aria-label":C??`Snooze`,"aria-description":y&&b?b:void 0,onMouseDown:e=>e.preventDefault(),onBlur:()=>a(!1),onPointerLeave:()=>a(!1),className:`${y?jk.replace(/(^| )text-muted( |$)/,`$1text-attention-90$2`):jk} ${n?`bg-panel-2`:``}`,children:o?(0,R.jsx)(M_,{size:14,strokeWidth:2,className:`animate-spin`}):(0,R.jsx)(Jg,{size:14,strokeWidth:2})})})}),(0,R.jsxs)(aR,{align:`end`,children:[(0,R.jsx)(`div`,{className:`px-2.5 pb-1 pt-1.5 text-[11px] text-muted-60`,children:C??`Snooze`}),y&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(oR,{onSelect:()=>void T(null),icon:(0,R.jsx)(uee,{size:12}),children:`Wake now`}),(0,R.jsx)(sR,{})]}),S.map(e=>(0,R.jsx)(oR,{onSelect:()=>void T(ED(e.value)),icon:(0,R.jsx)(Jg,{size:12}),children:(0,R.jsxs)(`span`,{"data-snooze-preset":e.value,className:`flex min-w-0 flex-1 items-center justify-between gap-6`,children:[(0,R.jsx)(`span`,{children:e.label}),(0,R.jsx)(`span`,{className:`text-[10.5px] text-muted-55`,children:e.wake})]})},e.value)),(0,R.jsx)(sR,{}),(0,R.jsx)(oR,{onSelect:E,children:`Custom time & prompt…`})]})]}),(0,R.jsx)(Oq,{open:c,onOpenChange:e=>{o||l(e)},title:`Snooze thread`,className:`w-[360px] max-w-[92vw]`,footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>l(!1),className:`button-outline 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,R.jsxs)(`button`,{type:`submit`,form:v,disabled:o,className:`button-outline 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:[o&&(0,R.jsx)(M_,{size:12,className:`animate-spin`}),f.trim()?`Snooze & bump`:`Snooze`]})]}),children:(0,R.jsxs)(`form`,{id:v,className:`flex flex-col gap-2.5 p-4`,onSubmit:e=>{e.preventDefault(),D()},children:[(0,R.jsx)(`label`,{htmlFor:g,className:`text-[11px] font-medium text-muted`,children:`Wake at this local time`}),(0,R.jsx)(`input`,{id:g,type:`datetime-local`,required:!0,min:x,value:u,onChange:e=>{d(e.target.value),h(``)},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,R.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,R.jsxs)(`label`,{htmlFor:_,className:`mt-1 text-[11px] font-medium text-muted`,children:[`Then send this prompt `,(0,R.jsx)(`span`,{className:`font-normal text-muted-55`,children:`(optional)`})]}),(0,R.jsx)(`textarea`,{id:_,"data-1p-ignore":!0,autoFocus:!0,rows:3,maxLength:Zu,placeholder:`e.g. Check whether CI went green and land it if so.`,value:f,onChange:e=>{p(e.target.value),h(``)},onKeyDown:e=>{gz({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(),D())},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,R.jsx)(`p`,{className:`min-h-4 text-[10.5px] text-muted-65`,children:f.trim()?`frizz will resume this thread with the prompt at the wake time.`:`Leave empty to just bring the card back to your queue.`}),m&&(0,R.jsx)(`p`,{role:`alert`,className:`text-[11px] text-danger`,children:m})]})})]})}function Aq({thread:e,onArchived:t,onDismissCancel:n,onSnoozed:r}){let i=zK(e);return i.lifecycle?(0,R.jsxs)(`span`,{"data-thread-lifecycle":!0,role:`group`,"aria-label":`Thread lifecycle actions`,className:`flex shrink-0 items-center gap-0.5`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,"data-lifecycle-rule":!0,className:`mx-2.5 h-4 w-px shrink-0 bg-border`}),i.done?(0,R.jsx)(jq,{}):(0,R.jsxs)(R.Fragment,{children:[i.snooze&&(0,R.jsx)(kq,{thread:e,onSnoozed:r}),(0,R.jsx)(Mq,{thread:e,onArchived:t,onDismissCancel:n,iconOnly:!0})]})]}):null}function jq(){let e=`Marked done — send a message to reopen it`;return(0,R.jsx)(FP,{label:e,children:(0,R.jsxs)(`span`,{"data-thread-done":!0,"aria-label":e,className:`flex h-7 items-center gap-1 rounded-md px-2 text-[12px] font-medium text-muted`,children:[(0,R.jsx)(e_,{size:12}),`Done`]})})}function Mq({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=``,iconSize:a=12,iconOnly:o=!1}){let[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(void 0),p=(r,i)=>{c(!0),i&&t?.(),(r||BK(e))&&ZW(e.id),Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:r}).then(r=>{if(r.needsConfirmation){QW(e.id),i&&n?.(),f(r.hold),u(!0),c(!1);return}u(!1),Z(`Done`),i||t?.()}).catch(t=>{QW(e.id),i&&n?.(),Z(`Couldn’t finish: ${t.message.slice(0,80)}`),c(!1)})},m=!!t&&!!n&&BK(e);return(0,R.jsxs)(R.Fragment,{children:[o?(0,R.jsx)(FP,{label:`Mark as done`,children:(0,R.jsx)(`button`,{type:`button`,onClick:()=>p(!1,m),disabled:s,"aria-label":`Mark as done`,onMouseDown:e=>e.preventDefault(),className:jk,children:(0,R.jsx)(e_,{size:15,strokeWidth:2})})}):(0,R.jsxs)(`button`,{type:`button`,onClick:()=>p(!1,m),disabled:s,"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-focus-ink-60 disabled:opacity-45 ${r}`,children:[(0,R.jsx)(e_,{size:a,className:i}),`Mark as done`]}),(0,R.jsx)(Oq,{open:l,onOpenChange:e=>{s||u(e)},title:d?.cutOff?`Mark an unfinished thread done?`:`End this session?`,className:`w-[390px] max-w-[92vw]`,footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,disabled:s,onClick:()=>u(!1),className:`button-outline 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,R.jsxs)(`button`,{type:`button`,disabled:s,onClick:()=>p(!0,!1),className:`button-outline 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:[s&&(0,R.jsx)(M_,{size:12,className:`animate-spin`}),d?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,R.jsx)(Nq,{hold:d})})]})}function Nq({hold:e}){let t=VK(e);return(0,R.jsxs)(`div`,{"data-completion-hold":!0,className:`flex flex-col gap-2 p-4 text-[12px] leading-relaxed text-muted`,children:[(0,R.jsx)(`p`,{children:t.lead}),t.groups.map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(`div`,{className:`text-[11px] font-medium uppercase tracking-wide text-fg/70`,children:e.heading}),(0,R.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[e.items.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:$O,children:`⤷`}),(0,R.jsx)(`span`,{className:`min-w-0 truncate text-fg/80`,children:e.label}),e.stale&&(0,R.jsx)(`span`,{className:`shrink-0 text-[11px] text-muted-60`,children:`no recent output`})]},`${e.label}-${t}`)),e.overflow>0&&(0,R.jsxs)(`li`,{className:`pl-[15px] text-muted-60`,children:[`+`,e.overflow,` more`]})]})]},e.kind)),(0,R.jsx)(`p`,{children:t.trailer})]})}function Pq({slug:e,onClose:t,onArchived:n,initialView:r=`actions`}){let i=gr(X),a=i.board?.threads.find(t=>t.id===e),[o,s]=(0,L.useState)(r),c=kg(t);if((0,L.useEffect)(()=>{i.board&&!a&&c()},[i.board,a,c]),!a)return null;let l=HD(a);return(0,R.jsx)(dq,{title:`Thread actions: ${l}`,onRequestClose:()=>c(),dataAttr:`data-thread-actions-sheet`,children:o===`actions`?(0,R.jsx)(Fq,{thread:a,title:l,setView:s,dismiss:c,onArchived:n}):o===`snooze`?(0,R.jsx)(Lq,{thread:a,back:()=>s(`actions`),custom:()=>s(`snooze-custom`),dismiss:c}):o===`snooze-custom`?(0,R.jsx)(Rq,{thread:a,back:()=>s(`snooze`),dismiss:c}):o===`goal`?(0,R.jsx)(zq,{thread:a,back:()=>s(`actions`)}):o===`files`?(0,R.jsx)(Bq,{thread:a,back:r===`files`?void 0:()=>s(`actions`),dismiss:c}):(0,R.jsx)(Uq,{thread:a,back:()=>s(`actions`),dismiss:c})})}function Fq({thread:e,title:t,setView:n,dismiss:r,onArchived:i}){let a=qe(),o=QK(),s=gr(RD).snoozePreset,c=zK(e),l=e.kind===`session`&&e.foreign!==!0,u=gf(e),d=e.recurringPrompt?.stopHook===!0||e.recurringPrompt?.heartbeat===!0||e.recurringPrompt?.postCompaction===!0,f=e.links??[],p=e.runtime===`running`||e.runtime===`spawning`,m=l&&gO(e),h=eq(e,o),g=$K(e),_=Wq(e),v=[sq(e.context),_].filter(Boolean).join(` · `);return(0,R.jsxs)(`div`,{"data-thread-actions-list":!0,children:[(0,R.jsx)(qq,{children:t}),c.snooze&&(0,R.jsx)(Kq,{data:`snooze`,icon:(0,R.jsx)(Jg,{size:19}),label:`Snooze`,value:u?AD(u):wD(s),chevron:!0,onClick:()=>n(`snooze`)}),l&&(0,R.jsx)(Kq,{data:`goal`,icon:(0,R.jsx)(mq,{size:19,className:d?`text-attention-90`:void 0}),label:`Goal`,value:d?`on`:`off`,chevron:!0,onClick:()=>n(`goal`)}),f.length>0&&(0,R.jsx)(Kq,{data:`files`,icon:(0,R.jsx)(v_,{size:19}),label:`Files and links`,value:String(f.length),chevron:!0,onClick:()=>n(`files`)}),p&&c.archive&&(0,R.jsx)(Mq,{thread:e,iconSize:19,iconClassName:`shrink-0 text-muted`,onArchived:()=>r(i),className:`${Gq} !gap-[14px] !font-normal`}),(0,R.jsx)(`div`,{className:`my-1 h-px bg-border`}),l&&(0,R.jsx)(Kq,{data:`rename`,icon:(0,R.jsx)(H_,{size:19}),label:`Rename`,onClick:()=>n(`rename`)}),(0,R.jsx)(Kq,{data:`copy-link`,icon:(0,R.jsx)(m_,{size:19}),label:`Copy link`,onClick:()=>{let t=new URL(HE(`/thread/${encodeURIComponent(e.id)}`),location.origin).href;r(()=>{eH(t).then(()=>Z(`Link copied`)).catch(e=>Z(`Couldn’t copy: ${e.message.slice(0,80)}`))})}}),m&&(0,R.jsx)(Kq,{data:`retry`,icon:(0,R.jsx)(X_,{size:19}),label:`Retry`,onClick:()=>r(()=>void kW(a,e.id))}),h&&(0,R.jsx)(Kq,{data:`restart-worker`,icon:(0,R.jsx)(J_,{size:19}),label:`Restart worker`,onClick:()=>r(()=>void ZK(a,e.id))}),g&&(0,R.jsx)(Kq,{data:`reload-plugins`,icon:(0,R.jsx)(K_,{size:19}),label:`Reload plugins`,onClick:()=>r(()=>void tq(e))}),v&&(0,R.jsx)(`div`,{"data-thread-actions-foot":!0,className:`px-[18px] pt-2.5 text-[12.5px] leading-[17px] text-muted`,children:v})]})}function Iq(e,t){let[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(``);async function o(n,i=null){r(!0),a(``);try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:n,prompt:n?i:null}),t(()=>Z(n?`${i?`Bump scheduled`:`Snoozed`} · ${AD(n)}`:`Snooze cleared`))}catch(e){let t=e instanceof Error?e.message:`Snooze failed`;Z(t.slice(0,100)),a(t)}finally{r(!1)}}return{busy:n,error:i,setError:a,apply:o}}function Lq({thread:e,back:t,custom:n,dismiss:r}){let i=gr(RD).snoozePreset,a=gf(e),{busy:o,apply:s}=Iq(e,r),c=e=>{RD.snoozePreset=e,s(ED(e))};return(0,R.jsxs)(`div`,{"data-thread-actions-snooze":!0,children:[(0,R.jsx)(Jq,{back:t,children:`Snooze`}),a&&(0,R.jsxs)(`p`,{className:`px-[18px] pb-2 text-[13px] text-muted`,children:[`Snoozed until `,AD(a).replace(/^(Today|Tomorrow)/,e=>e.toLowerCase())]}),xD.map(e=>(0,R.jsx)(Kq,{data:`snooze-${e.value}`,disabled:o,icon:(0,R.jsx)(Jg,{size:19}),label:e.label,value:e.detail,trailing:e.value===i?(0,R.jsx)(e_,{size:16,className:`text-fg/80`}):(0,R.jsx)(`span`,{className:`w-4`}),onClick:()=>c(e.value)},e.value)),(0,R.jsx)(`div`,{className:`my-1 h-px bg-border`}),(0,R.jsx)(Kq,{data:`snooze-custom`,disabled:o,icon:(0,R.jsx)(H_,{size:19}),label:`Custom time & prompt…`,chevron:!0,onClick:n}),a&&(0,R.jsx)(Kq,{data:`snooze-wake`,disabled:o,icon:(0,R.jsx)(X_,{size:19}),label:`Wake now`,onClick:()=>void s(null)})]})}function Rq({thread:e,back:t,dismiss:n}){let r=gr(RD).snoozePreset,i=gf(e),{busy:a,error:o,setError:s,apply:c}=Iq(e,n),[l,u]=(0,L.useState)(()=>OD(new Date(i??ED(r)))),[d,f]=(0,L.useState)(e.snoozePrompt??``),p=(0,L.useMemo)(()=>OD(new Date(Date.now()+6e4)),[]),m=(0,L.useId)(),h=(0,L.useId)(),g=()=>{let e=kD(l);if(!e.ok)return s(e.message);let t=d.trim();if(t.length>4e3)return s(`Prompt is too long (${t.length}/${Zu})`);c(e.until,t||null)};return(0,R.jsxs)(`form`,{"data-thread-actions-snooze-custom":!0,className:`flex flex-col`,onSubmit:e=>{e.preventDefault(),g()},children:[(0,R.jsx)(Jq,{back:t,children:`Custom snooze`}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 px-[18px]`,children:[(0,R.jsx)(`label`,{htmlFor:m,className:`text-[13px] font-medium text-muted`,children:`Wake at this local time`}),(0,R.jsx)(`input`,{id:m,type:`datetime-local`,required:!0,min:p,value:l,onChange:e=>{u(e.target.value),s(``)},className:`h-11 w-full rounded-lg border border-border bg-bg px-3 text-[16px] text-fg outline-none focus:border-border-strong`}),(0,R.jsxs)(`label`,{htmlFor:h,className:`mt-2 text-[13px] font-medium text-muted`,children:[`Then send this prompt `,(0,R.jsx)(`span`,{className:`font-normal text-muted-70`,children:`(optional)`})]}),(0,R.jsx)(`textarea`,{id:h,"data-1p-ignore":!0,rows:3,maxLength:Zu,placeholder:`e.g. Check whether CI went green and land it if so.`,value:d,onChange:e=>{f(e.target.value),s(``)},className:`w-full resize-none rounded-lg border border-border bg-bg px-3 py-2 text-[16px] leading-[22px] text-fg outline-none placeholder:text-muted-50 focus:border-border-strong`}),(0,R.jsx)(`p`,{className:`text-[12.5px] text-muted`,children:d.trim()?`Frizz will resume this thread with the prompt at the wake time.`:`Leave it empty to just bring the thread back to your queue.`}),o&&(0,R.jsx)(`p`,{role:`alert`,className:`text-[13px] text-danger`,children:o}),(0,R.jsxs)(`button`,{type:`submit`,disabled:a,className:`mt-1 flex h-[46px] items-center justify-center gap-2 rounded-xl bg-fg text-[15.5px] font-semibold text-bg outline-none disabled:opacity-45`,children:[a&&(0,R.jsx)(M_,{size:16,className:`animate-spin`}),d.trim()?`Snooze and bump`:`Snooze`]})]})]})}function zq({thread:e,back:t}){return(0,R.jsxs)(`div`,{"data-thread-actions-goal":!0,children:[(0,R.jsx)(Jq,{back:t,children:`Goal`}),(0,R.jsx)(`div`,{className:`px-[18px] text-[13.5px] leading-relaxed text-fg [&_input]:!text-[16px] [&_textarea]:!min-h-[6rem] [&_textarea]:!text-[16px] [&_textarea]:!leading-[22px]`,children:(0,R.jsx)(Dq,{thread:e,armed:e.recurringPrompt,close:t,heading:!1})})]})}function Bq({thread:e,back:t,dismiss:n}){let r=[...e.links??[]].reverse();return(0,R.jsxs)(`div`,{"data-thread-actions-files":!0,children:[t?(0,R.jsx)(Jq,{back:t,count:r.length,children:`Files and links`}):(0,R.jsx)(qq,{count:r.length,children:`Files and links`}),r.length===0&&(0,R.jsx)(`p`,{className:`px-[18px] pb-2 text-[14px] text-muted`,children:`Nothing registered yet.`}),r.map(e=>(0,R.jsx)(Vq,{link:e,dismiss:n},e.id))]})}function Vq({link:e,dismiss:t}){let n=e.kind===`link`,r=n&&lq(e.target),i=gr(X).board?.projectDir,a=n?r?`${uq(e.target)} — not reachable from this phone`:uq(e.target):Hq(e.target,i),o=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`flex h-[21px] w-[19px] shrink-0 items-center justify-center text-muted`,children:n?(0,R.jsx)(g_,{size:19}):(0,R.jsx)(v_,{size:19})}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(`span`,{"data-link-label":!0,className:`block truncate text-[15.5px] leading-[21px] text-fg`,children:e.label}),(0,R.jsx)(`span`,{"data-link-destination":!0,className:`block truncate text-[12.5px] leading-[17px] text-muted`,children:a})]}),!r&&(0,R.jsx)(r_,{size:15,className:`shrink-0 self-center text-muted-70`})]}),s=`flex min-h-[56px] w-full items-start gap-[14px] px-[18px] py-[9px] text-left outline-none focus-visible:bg-hover`;return r?(0,R.jsx)(`div`,{"data-thread-link":e.id,"data-link-unreachable":!0,title:e.target,className:s,children:o}):n?(0,R.jsx)(`a`,{"data-thread-link":e.id,title:e.target,href:e.target,target:`_blank`,rel:`noopener noreferrer`,className:`${s} active:bg-hover`,onClick:()=>t(),children:o}):(0,R.jsx)(`button`,{type:`button`,"data-thread-link":e.id,title:e.target,className:`${s} active:bg-hover`,onClick:()=>t(()=>YK(e.target)),children:o})}function Hq(e,t){if(t&&e.startsWith(`${t.replace(/\/+$/,``)}/`))return e.slice(t.replace(/\/+$/,``).length+1);let n=e.split(`/`).filter(Boolean);return n.length>2?`…/${n.slice(-2).join(`/`)}`:e}function Uq({thread:e,back:t,dismiss:n}){let r=HD(e),[i,a]=(0,L.useState)(()=>WK(r,e.id)),o=(0,L.useRef)(null),s=pt({mutationFn:t=>Y.renameThread({slug:e.id,title:t})}),c=pt({mutationFn:()=>Y.aiRenameThread({slug:e.id})}),l=GK(e);(0,L.useEffect)(()=>{let e=requestAnimationFrame(()=>{o.current?.focus(),o.current?.select()});return()=>cancelAnimationFrame(e)},[]);let u=()=>{let e=UK(i,r);if(!e)return t();s.mutate(e,{onSuccess:()=>n(()=>Z(`Thread renamed`)),onError:e=>Z(e instanceof Error?e.message:`Could not rename thread`)})};return(0,R.jsxs)(`form`,{"data-thread-actions-rename":!0,onSubmit:e=>{e.preventDefault(),u()},children:[(0,R.jsx)(Jq,{back:t,children:`Rename`}),(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 px-[18px]`,children:[(0,R.jsx)(`input`,{ref:o,"aria-label":`Thread title`,value:i,maxLength:200,onChange:e=>a(e.target.value),"data-claims-escape":!0,className:`h-11 w-full rounded-lg border border-border bg-bg px-3 text-[16px] text-fg outline-none focus:border-border-strong`}),(0,R.jsxs)(`button`,{type:`submit`,disabled:s.isPending,className:`flex h-[46px] items-center justify-center gap-2 rounded-xl bg-fg text-[15.5px] font-semibold text-bg outline-none disabled:opacity-45`,children:[s.isPending&&(0,R.jsx)(M_,{size:16,className:`animate-spin`}),`Save`]})]}),l.show&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`mt-3 mb-1 h-px bg-border`}),(0,R.jsx)(Kq,{data:`ai-rename`,disabled:c.isPending,icon:c.isPending?(0,R.jsx)(M_,{size:19,className:`animate-spin`}):(0,R.jsx)(Z_,{size:19}),label:c.isPending?`Claude is naming it…`:`Rename with Claude`,onClick:()=>{if(!l.enabled)return Z(l.label);c.mutate(void 0,{onSuccess:({title:e})=>n(()=>Z(`Renamed to “${e}”`)),onError:e=>Z(e instanceof Error?e.message:`Could not rename with Claude`,{duration:7e3})})}})]})]})}function Wq(e){let t=!!(e&&!e.foreign&&e.kind===`session`),n=ct({queryKey:[`threadProfileOptions`,e?.id??``],queryFn:()=>Y.threadProfileOptions({slug:e.id}),enabled:t,staleTime:5e3});if(!e)return null;let r=e.model?.trim(),i=e.effort?.trim();if(!r&&!i&&!e.runningModelLabel)return null;let a=oB([{id:e.backend??`claude`,label:``,options:n.data?.options??[]}],{model:r,effort:i},``,e.runningModelLabel);return[[a.name,a.edition].filter(Boolean).join(` `)||null,aq(a.effort)].filter(Boolean).join(` · `)||null}var Gq=`flex min-h-[50px] w-full items-center gap-[14px] px-[18px] text-left text-[15.5px] leading-[21px] text-fg outline-none transition-colors active:bg-hover focus-visible:bg-hover disabled:opacity-45`;function Kq({icon:e,label:t,value:n,chevron:r,trailing:i,onClick:a,disabled:o,data:s}){return(0,R.jsxs)(`button`,{type:`button`,"data-thread-action":s,disabled:o,onClick:a,className:Gq,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`flex w-[19px] shrink-0 items-center justify-center text-muted`,children:e}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),(n||r||i)&&(0,R.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 text-[14px] text-muted`,children:[n,r&&(0,R.jsx)(r_,{size:15,className:`text-muted-70`}),i]})]})}function qq({children:e,count:t}){return(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2 px-[18px] pb-2.5 pt-1`,children:[(0,R.jsx)(`span`,{"data-thread-actions-title":!0,className:`min-w-0 flex-1 truncate text-[16px] font-semibold leading-[22px]`,children:e}),t!==void 0&&(0,R.jsx)(`span`,{className:`shrink-0 text-[12.5px] text-muted`,children:t})]})}function Jq({children:e,back:t,count:n}){return(0,R.jsxs)(`div`,{className:`flex items-center gap-0.5 pb-1 pl-[6px] pr-[18px]`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":`Back`,onClick:t,className:`flex size-11 shrink-0 items-center justify-center rounded-full text-fg/85 outline-none active:bg-hover focus-visible:bg-hover`,children:(0,R.jsx)(n_,{size:21})}),(0,R.jsx)(`span`,{"data-thread-actions-title":!0,className:`min-w-0 flex-1 truncate text-[16px] font-semibold leading-[22px]`,children:e}),n!==void 0&&(0,R.jsx)(`span`,{className:`shrink-0 text-[12.5px] text-muted`,children:n})]})}function Yq({t:e}){let{node:t,tip:n}=wG(e),r=n?.split(`
|
|
215
215
|
|
|
216
|
-
`)[0]??`At rest`;return(0,R.jsx)(`span`,{className:`inline-flex`,"data-mobile-thread-indicator":gO(e),role:`img`,"aria-label":r,children:t})}var Xq=76,Zq=10;function Qq({open:e,onOpenChange:t,onSnooze:n,onDone:r,snoozeLabel:i,children:a}){let[o,s]=(0,L.useState)(0),c=(0,L.useRef)(null),l=e?-152:0,u=c.current?.claimed?o:l;return(0,R.jsxs)(`div`,{className:`relative overflow-hidden`,style:{touchAction:`pan-y`},children:[(0,R.jsxs)(`div`,{className:`absolute inset-y-0 right-0 flex`,"aria-hidden":!e,children:[(0,R.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:Xq},children:[(0,R.jsx)(p_,{size:19}),(0,R.jsx)(`span`,{className:`text-[11.5px]`,children:i})]}),(0,R.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:Xq},children:[(0,R.jsx)(e_,{size:19,strokeWidth:2.6}),(0,R.jsx)(`span`,{className:`text-[11.5px] font-medium`,children:`Done`})]})]}),(0,R.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)<Zq||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})]})}var $q=500,eJ=8;function tJ(e){let t=(0,L.useRef)(null),n=(0,L.useRef)(null),r=(0,L.useRef)(!1),i=()=>{t.current&&clearTimeout(t.current),t.current=null,n.current=null};return{onPointerDown:i=>{i.pointerType===`mouse`&&i.button!==0||(r.current=!1,n.current={x:i.clientX,y:i.clientY},t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{t.current=null,r.current=!0,navigator.vibrate?.(10),e()},$q))},onPointerMove:e=>{let t=n.current;t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>eJ&&i()},onPointerUp:i,onPointerCancel:i,onPointerLeave:i,onClickCapture:e=>{r.current&&(r.current=!1,e.preventDefault(),e.stopPropagation())},onContextMenu:e=>e.preventDefault()}}function nJ({t:e,tab:t,last:n,openSwipe:r,onOpenSwipe:i,onLongPress:a}){let o=tJ(a),s=gr(zD).snoozePreset,c=RO(),l=gO(e),u=$D(e),d=(l===`background`||l===`pr`)&&uO(e),f=e.runtime===`running`||e.runtime===`spawning`||l===`working`||d,p=t===`snoozed`?DO(NK(e,c),c):null,m=t===`snoozed`?p?`wakes ${p}`:null:f?null:EO(u,c),h=gr(X).board?.projectDir,g=IK(e,l,f,c,h),_=FK(PK(e));return(0,R.jsxs)(`div`,{className:l===`snoozed`?`mobile-row-dim`:void 0,children:[(0,R.jsx)(Qq,{open:r,onOpenChange:i,snoozeLabel:TD(s),onSnooze:async()=>{try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:DD(s),prompt:null}),Z(`Snoozed · ${TD(s)}`)}catch(e){Z(e instanceof Error?e.message.slice(0,100):`Snooze failed`)}},onDone:async()=>{ZW(e.id);try{let t=await Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:!1});if(t.needsConfirmation){QW(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){QW(e.id),Z(t instanceof Error?t.message.slice(0,100):`Could not mark as done`)}},children:(0,R.jsxs)(`button`,{"data-mobile-thread-row":e.id,...o,onClick:()=>Xh(e.id),style:{WebkitTouchCallout:`none`,WebkitUserSelect:`none`,userSelect:`none`},className:`flex w-full items-start gap-3 px-4 py-[11px] text-left active:bg-hover`,children:[(0,R.jsx)(`span`,{className:`flex h-[21px] w-[18px] shrink-0 items-center justify-center`,children:(0,R.jsx)(Yq,{t:e})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-px`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2.5`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[15.5px] font-medium leading-[21px] tracking-[-0.005em] text-fg`,children:UD(e)}),m?(0,R.jsx)(`span`,{"data-mobile-row-right":!0,className:`shrink-0 text-[12px] leading-[21px] tabular-nums text-faint`,children:m}):null]}),g||_?(0,R.jsxs)(`span`,{"data-mobile-row-line":!0,className:`flex min-w-0 text-[13.5px] leading-[19px] text-muted`,children:[g?(0,R.jsxs)(`span`,{className:`min-w-0 truncate`,children:[g.lead?(0,R.jsxs)(`span`,{className:`font-semibold text-fg`,children:[g.lead,` `]}):null,g.text]}):null,_?(0,R.jsx)(`span`,{className:`shrink-0 whitespace-pre`,children:g?` · ${_}`:_}):null]}):null]})]})}),n?null:(0,R.jsx)(`div`,{className:`ml-[46px] h-px bg-border/70`})]})}function rJ({label:e}){return(0,R.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center px-10 pb-24 text-center`,children:(0,R.jsx)(`p`,{className:`m-0 text-[15px] text-muted`,children:e})})}function iJ({band:e,label:t,active:n,onClick:r,children:i}){return(0,R.jsx)(`button`,{role:`tab`,"aria-selected":n,"data-mobile-tab":e,onClick:r,className:`-mb-px flex h-[44px] items-center border-b-2 ${n?`border-fg text-fg`:`border-transparent text-muted`}`,children:(0,R.jsxs)(`span`,{className:`flex items-baseline gap-1.5`,children:[(0,R.jsxs)(`span`,{className:`grid text-[14.5px] leading-[20px]`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1 font-semibold`,children:t}),(0,R.jsx)(`span`,{className:`col-start-1 row-start-1 ${n?`font-semibold`:``}`,children:t})]}),i]})})}var aJ=`pointer-events-none absolute right-[9.5px] top-[10.5px] size-[5px] rounded-full bg-accent`,oJ=`text-[12.5px] font-medium tabular-nums text-muted`;function sJ(){let e=ME(),t=gr(X),n=HU(RU().data??null),[r,i]=(0,L.useState)(`queue`),[a,o]=(0,L.useState)(null),[s,c]=(0,L.useState)(null),l=nG(hW(FE(e?.threads??[]))),u=gr(zD).queueOrder,d=(0,L.useMemo)(()=>bO(l,u),[l,u]),f=(0,L.useMemo)(()=>{let e=d.active.filter(Sf),t=d.active.filter(e=>!Sf(e));return[...d.pinned,...e,...t]},[d.pinned,d.active]),p=(0,L.useMemo)(()=>l.filter(Cf).length,[l]),m=(0,L.useMemo)(()=>l.filter(xf).length,[l]),h=r===`queue`?f:r===`snoozed`?d.snoozed:d.inactive,g=t.view.startsWith(`status:`)?t.view.slice(7):null,_=UG(e),v=_.state===`verified`?_.label:_.state===`local`?_.name:`Frizz`;return(0,R.jsxs)(`div`,{"data-mobile-board":!0,className:`relative min-h-dvh bg-bg`,children:[(0,R.jsxs)(`div`,{className:`fixed inset-x-0 top-0 z-30 bg-bg pt-[env(safe-area-inset-top)]`,children:[(0,R.jsxs)(`div`,{className:`flex h-[56px] items-center gap-0.5 pr-0.5`,children:[(0,R.jsx)(`a`,{href:`/`,"aria-label":`Projects`,"data-mobile-projects":!0,className:`flex size-[44px] shrink-0 items-center justify-center rounded-full text-fg/85 active:bg-hover-strong`,children:(0,R.jsx)(Yg,{size:21,strokeWidth:2.1})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 pl-0.5`,children:[(0,R.jsx)(`div`,{"data-mobile-board-title":!0,className:`truncate text-[16.5px] font-semibold leading-[21px] tracking-[-0.01em] text-fg`,children:v}),e?(0,R.jsxs)(`div`,{"data-mobile-board-subtitle":!0,className:`truncate text-[13px] leading-[17px] text-muted`,children:[p>0?(0,R.jsxs)(`span`,{className:`font-semibold text-accent`,children:[p,` need you`]}):null,p>0&&m>0?` · `:null,m>0?`${m} working`:null,p===0&&m===0?`Nothing needs you`:null]}):null]}),(0,R.jsxs)(`button`,{"aria-label":n?`Settings, update available`:`Settings`,"data-mobile-settings":!0,onClick:()=>X.showSettings=!0,className:`relative flex size-[44px] shrink-0 items-center justify-center rounded-full text-fg/85 active:bg-hover-strong`,children:[(0,R.jsx)(Q_,{size:21,strokeWidth:1.9}),n?(0,R.jsx)(`span`,{"data-mobile-update-notification":!0,"aria-hidden":!0,className:aJ}):null]})]}),(0,R.jsxs)(`div`,{role:`tablist`,"aria-label":`Bands`,className:`flex gap-[22px] border-b border-border/70 px-[18px]`,children:[(0,R.jsxs)(iJ,{band:`queue`,label:`Queue`,active:r===`queue`,onClick:()=>i(`queue`),children:[p>0?(0,R.jsx)(`span`,{className:`text-[12.5px] font-bold tabular-nums text-accent`,children:p}):null,f.length>0?(0,R.jsx)(`span`,{className:oJ,children:p>0?`· ${f.length}`:f.length}):null]}),(0,R.jsx)(iJ,{band:`snoozed`,label:`Snoozed`,active:r===`snoozed`,onClick:()=>i(`snoozed`),children:d.snoozed.length>0?(0,R.jsx)(`span`,{className:oJ,children:d.snoozed.length}):null}),(0,R.jsx)(iJ,{band:`done`,label:`Done`,active:r===`done`,onClick:()=>i(`done`)})]})]}),(0,R.jsx)(`div`,{className:`flex min-h-dvh flex-col pb-[calc(82px+env(safe-area-inset-bottom))] pt-[calc(101px+env(safe-area-inset-top))]`,children:g?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(RK,{status:g})}):h.length===0?(0,R.jsx)(rJ,{label:e?r===`queue`?`Nothing in the queue. Tap New thread to start one.`:r===`snoozed`?`Nothing snoozed.`:`Nothing finished yet.`:`Loading…`}):(0,R.jsx)(`div`,{children:h.map((e,t)=>(0,R.jsx)(nJ,{t:e,tab:r,last:t===h.length-1,openSwipe:a===e.id,onOpenSwipe:t=>o(t?e.id:null),onLongPress:()=>{o(null),c(e.id)}},e.id))})}),(0,R.jsxs)(`button`,{"data-mobile-new-thread":!0,onClick:()=>X.showNewThread=!0,className:`button-outline fixed bottom-[calc(16px+env(safe-area-inset-bottom))] right-4 z-30 flex h-[50px] items-center gap-1.5 rounded-full bg-fg pl-4 pr-5 text-[15px] font-semibold text-bg shadow-lg shadow-shadow-ink/50 active:opacity-85`,children:[(0,R.jsx)(q_,{size:20,strokeWidth:2.4}),`New thread`]}),s?(0,R.jsx)(Pq,{slug:s,onClose:()=>c(null)}):null]})}var cJ={schedule:(e,t)=>window.setTimeout(e,t),cancel:e=>window.clearTimeout(e)},lJ=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??cJ,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 uJ(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var dJ=uJ();function fJ(e){dJ=e}var pJ={exec:()=>null};function mJ(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(hJ.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var hJ={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`)},gJ=/^(?:[ \t]*(?:\n|$))+/,_J=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,vJ=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,yJ=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,bJ=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,xJ=/(?:[*+-]|\d{1,9}[.)])/,SJ=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,CJ=mJ(SJ).replace(/bull/g,xJ).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(),wJ=mJ(SJ).replace(/bull/g,xJ).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(),TJ=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,EJ=/^[^\n]+/,DJ=/(?!\s*\])(?:\\.|[^\[\]\\])+/,OJ=mJ(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,DJ).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),kJ=mJ(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,xJ).getRegex(),AJ=`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`,jJ=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,MJ=mJ(`^ {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`,jJ).replace(`tag`,AJ).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),NJ=mJ(TJ).replace(`hr`,yJ).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`,AJ).getRegex(),PJ={blockquote:mJ(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,NJ).getRegex(),code:_J,def:OJ,fences:vJ,heading:bJ,hr:yJ,html:MJ,lheading:CJ,list:kJ,newline:gJ,paragraph:NJ,table:pJ,text:EJ},FJ=mJ(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,yJ).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`,AJ).getRegex(),IJ={...PJ,lheading:wJ,table:FJ,paragraph:mJ(TJ).replace(`hr`,yJ).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,FJ).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`,AJ).getRegex()},LJ={...PJ,html:mJ(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,jJ).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:pJ,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:mJ(TJ).replace(`hr`,yJ).replace(`heading`,` *#{1,6} *[^
|
|
216
|
+
`)[0]??`At rest`;return(0,R.jsx)(`span`,{className:`inline-flex`,"data-mobile-thread-indicator":hO(e),role:`img`,"aria-label":r,children:t})}var Xq=76,Zq=10;function Qq({open:e,onOpenChange:t,onSnooze:n,onDone:r,snoozeLabel:i,children:a}){let[o,s]=(0,L.useState)(0),c=(0,L.useRef)(null),l=e?-152:0,u=c.current?.claimed?o:l;return(0,R.jsxs)(`div`,{className:`relative overflow-hidden`,style:{touchAction:`pan-y`},children:[(0,R.jsxs)(`div`,{className:`absolute inset-y-0 right-0 flex`,"aria-hidden":!e,children:[(0,R.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:Xq},children:[(0,R.jsx)(p_,{size:19}),(0,R.jsx)(`span`,{className:`text-[11.5px]`,children:i})]}),(0,R.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:Xq},children:[(0,R.jsx)(e_,{size:19,strokeWidth:2.6}),(0,R.jsx)(`span`,{className:`text-[11.5px] font-medium`,children:`Done`})]})]}),(0,R.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)<Zq||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})]})}var $q=500,eJ=8;function tJ(e){let t=(0,L.useRef)(null),n=(0,L.useRef)(null),r=(0,L.useRef)(!1),i=()=>{t.current&&clearTimeout(t.current),t.current=null,n.current=null};return{onPointerDown:i=>{i.pointerType===`mouse`&&i.button!==0||(r.current=!1,n.current={x:i.clientX,y:i.clientY},t.current&&clearTimeout(t.current),t.current=setTimeout(()=>{t.current=null,r.current=!0,navigator.vibrate?.(10),e()},$q))},onPointerMove:e=>{let t=n.current;t&&Math.hypot(e.clientX-t.x,e.clientY-t.y)>eJ&&i()},onPointerUp:i,onPointerCancel:i,onPointerLeave:i,onClickCapture:e=>{r.current&&(r.current=!1,e.preventDefault(),e.stopPropagation())},onContextMenu:e=>e.preventDefault()}}function nJ({t:e,tab:t,last:n,openSwipe:r,onOpenSwipe:i,onLongPress:a}){let o=tJ(a),s=gr(RD).snoozePreset,c=LO(),l=hO(e),u=QD(e),d=(l===`background`||l===`pr`)&&lO(e),f=e.runtime===`running`||e.runtime===`spawning`||l===`working`||d,p=t===`snoozed`?EO(NK(e,c),c):null,m=t===`snoozed`?p?`wakes ${p}`:null:f?null:TO(u,c),h=gr(X).board?.projectDir,g=IK(e,l,f,c,h),_=FK(PK(e));return(0,R.jsxs)(`div`,{className:l===`snoozed`?`mobile-row-dim`:void 0,children:[(0,R.jsx)(Qq,{open:r,onOpenChange:i,snoozeLabel:wD(s),onSnooze:async()=>{try{await Y.setThreadSnooze({slug:e.id,sessionId:e.sessionId??``,until:ED(s),prompt:null}),Z(`Snoozed · ${wD(s)}`)}catch(e){Z(e instanceof Error?e.message.slice(0,100):`Snooze failed`)}},onDone:async()=>{ZW(e.id);try{let t=await Y.completeThread({slug:e.id,sessionId:e.sessionId??``,terminateLive:!1});if(t.needsConfirmation){QW(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){QW(e.id),Z(t instanceof Error?t.message.slice(0,100):`Could not mark as done`)}},children:(0,R.jsxs)(`button`,{"data-mobile-thread-row":e.id,...o,onClick:()=>Xh(e.id),style:{WebkitTouchCallout:`none`,WebkitUserSelect:`none`,userSelect:`none`},className:`flex w-full items-start gap-3 px-4 py-[11px] text-left active:bg-hover`,children:[(0,R.jsx)(`span`,{className:`flex h-[21px] w-[18px] shrink-0 items-center justify-center`,children:(0,R.jsx)(Yq,{t:e})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-px`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2.5`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[15.5px] font-medium leading-[21px] tracking-[-0.005em] text-fg`,children:HD(e)}),m?(0,R.jsx)(`span`,{"data-mobile-row-right":!0,className:`shrink-0 text-[12px] leading-[21px] tabular-nums text-faint`,children:m}):null]}),g||_?(0,R.jsxs)(`span`,{"data-mobile-row-line":!0,className:`flex min-w-0 text-[13.5px] leading-[19px] text-muted`,children:[g?(0,R.jsxs)(`span`,{className:`min-w-0 truncate`,children:[g.lead?(0,R.jsxs)(`span`,{className:`font-semibold text-fg`,children:[g.lead,` `]}):null,g.text]}):null,_?(0,R.jsx)(`span`,{className:`shrink-0 whitespace-pre`,children:g?` · ${_}`:_}):null]}):null]})]})}),n?null:(0,R.jsx)(`div`,{className:`ml-[46px] h-px bg-border/70`})]})}function rJ({label:e}){return(0,R.jsx)(`div`,{className:`flex flex-1 flex-col items-center justify-center px-10 pb-24 text-center`,children:(0,R.jsx)(`p`,{className:`m-0 text-[15px] text-muted`,children:e})})}function iJ({band:e,label:t,active:n,onClick:r,children:i}){return(0,R.jsx)(`button`,{role:`tab`,"aria-selected":n,"data-mobile-tab":e,onClick:r,className:`-mb-px flex h-[44px] items-center border-b-2 ${n?`border-fg text-fg`:`border-transparent text-muted`}`,children:(0,R.jsxs)(`span`,{className:`flex items-baseline gap-1.5`,children:[(0,R.jsxs)(`span`,{className:`grid text-[14.5px] leading-[20px]`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`invisible col-start-1 row-start-1 font-semibold`,children:t}),(0,R.jsx)(`span`,{className:`col-start-1 row-start-1 ${n?`font-semibold`:``}`,children:t})]}),i]})})}var aJ=`pointer-events-none absolute right-[9.5px] top-[10.5px] size-[5px] rounded-full bg-accent`,oJ=`text-[12.5px] font-medium tabular-nums text-muted`;function sJ(){let e=ME(),t=gr(X),n=HU(RU().data??null),[r,i]=(0,L.useState)(`queue`),[a,o]=(0,L.useState)(null),[s,c]=(0,L.useState)(null),l=nG(hW(FE(e?.threads??[]))),u=gr(RD).queueOrder,d=(0,L.useMemo)(()=>yO(l,u),[l,u]),f=(0,L.useMemo)(()=>{let e=d.active.filter(Sf),t=d.active.filter(e=>!Sf(e));return[...d.pinned,...e,...t]},[d.pinned,d.active]),p=(0,L.useMemo)(()=>l.filter(Cf).length,[l]),m=(0,L.useMemo)(()=>l.filter(xf).length,[l]),h=r===`queue`?f:r===`snoozed`?d.snoozed:d.inactive,g=t.view.startsWith(`status:`)?t.view.slice(7):null,_=UG(e),v=_.state===`verified`?_.label:_.state===`local`?_.name:`Frizz`;return(0,R.jsxs)(`div`,{"data-mobile-board":!0,className:`relative min-h-dvh bg-bg`,children:[(0,R.jsxs)(`div`,{className:`fixed inset-x-0 top-0 z-30 bg-bg pt-[env(safe-area-inset-top)]`,children:[(0,R.jsxs)(`div`,{className:`flex h-[56px] items-center gap-0.5 pr-0.5`,children:[(0,R.jsx)(`a`,{href:`/`,"aria-label":`Projects`,"data-mobile-projects":!0,className:`flex size-[44px] shrink-0 items-center justify-center rounded-full text-fg/85 active:bg-hover-strong`,children:(0,R.jsx)(Yg,{size:21,strokeWidth:2.1})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 pl-0.5`,children:[(0,R.jsx)(`div`,{"data-mobile-board-title":!0,className:`truncate text-[16.5px] font-semibold leading-[21px] tracking-[-0.01em] text-fg`,children:v}),e?(0,R.jsxs)(`div`,{"data-mobile-board-subtitle":!0,className:`truncate text-[13px] leading-[17px] text-muted`,children:[p>0?(0,R.jsxs)(`span`,{className:`font-semibold text-accent`,children:[p,` need you`]}):null,p>0&&m>0?` · `:null,m>0?`${m} working`:null,p===0&&m===0?`Nothing needs you`:null]}):null]}),(0,R.jsxs)(`button`,{"aria-label":n?`Settings, update available`:`Settings`,"data-mobile-settings":!0,onClick:()=>X.showSettings=!0,className:`relative flex size-[44px] shrink-0 items-center justify-center rounded-full text-fg/85 active:bg-hover-strong`,children:[(0,R.jsx)(Q_,{size:21,strokeWidth:1.9}),n?(0,R.jsx)(`span`,{"data-mobile-update-notification":!0,"aria-hidden":!0,className:aJ}):null]})]}),(0,R.jsxs)(`div`,{role:`tablist`,"aria-label":`Bands`,className:`flex gap-[22px] border-b border-border/70 px-[18px]`,children:[(0,R.jsxs)(iJ,{band:`queue`,label:`Queue`,active:r===`queue`,onClick:()=>i(`queue`),children:[p>0?(0,R.jsx)(`span`,{className:`text-[12.5px] font-bold tabular-nums text-accent`,children:p}):null,f.length>0?(0,R.jsx)(`span`,{className:oJ,children:p>0?`· ${f.length}`:f.length}):null]}),(0,R.jsx)(iJ,{band:`snoozed`,label:`Snoozed`,active:r===`snoozed`,onClick:()=>i(`snoozed`),children:d.snoozed.length>0?(0,R.jsx)(`span`,{className:oJ,children:d.snoozed.length}):null}),(0,R.jsx)(iJ,{band:`done`,label:`Done`,active:r===`done`,onClick:()=>i(`done`)})]})]}),(0,R.jsx)(`div`,{className:`flex min-h-dvh flex-col pb-[calc(82px+env(safe-area-inset-bottom))] pt-[calc(101px+env(safe-area-inset-top))]`,children:g?(0,R.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:(0,R.jsx)(RK,{status:g})}):h.length===0?(0,R.jsx)(rJ,{label:e?r===`queue`?`Nothing in the queue. Tap New thread to start one.`:r===`snoozed`?`Nothing snoozed.`:`Nothing finished yet.`:`Loading…`}):(0,R.jsx)(`div`,{children:h.map((e,t)=>(0,R.jsx)(nJ,{t:e,tab:r,last:t===h.length-1,openSwipe:a===e.id,onOpenSwipe:t=>o(t?e.id:null),onLongPress:()=>{o(null),c(e.id)}},e.id))})}),(0,R.jsxs)(`button`,{"data-mobile-new-thread":!0,onClick:()=>X.showNewThread=!0,className:`button-outline fixed bottom-[calc(16px+env(safe-area-inset-bottom))] right-4 z-30 flex h-[50px] items-center gap-1.5 rounded-full bg-fg pl-4 pr-5 text-[15px] font-semibold text-bg shadow-lg shadow-shadow-ink/50 active:opacity-85`,children:[(0,R.jsx)(q_,{size:20,strokeWidth:2.4}),`New thread`]}),s?(0,R.jsx)(Pq,{slug:s,onClose:()=>c(null)}):null]})}var cJ={schedule:(e,t)=>window.setTimeout(e,t),cancel:e=>window.clearTimeout(e)},lJ=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??cJ,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 uJ(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var dJ=uJ();function fJ(e){dJ=e}var pJ={exec:()=>null};function mJ(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(hJ.caret,`$1`),n=n.replace(e,i),r},getRegex:()=>new RegExp(n,t)};return r}var hJ={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`)},gJ=/^(?:[ \t]*(?:\n|$))+/,_J=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,vJ=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,yJ=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,bJ=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,xJ=/(?:[*+-]|\d{1,9}[.)])/,SJ=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,CJ=mJ(SJ).replace(/bull/g,xJ).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(),wJ=mJ(SJ).replace(/bull/g,xJ).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(),TJ=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,EJ=/^[^\n]+/,DJ=/(?!\s*\])(?:\\.|[^\[\]\\])+/,OJ=mJ(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace(`label`,DJ).replace(`title`,/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),kJ=mJ(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,xJ).getRegex(),AJ=`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`,jJ=/<!--(?:-?>|[\s\S]*?(?:-->|$))/,MJ=mJ(`^ {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`,jJ).replace(`tag`,AJ).replace(`attribute`,/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),NJ=mJ(TJ).replace(`hr`,yJ).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`,AJ).getRegex(),PJ={blockquote:mJ(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace(`paragraph`,NJ).getRegex(),code:_J,def:OJ,fences:vJ,heading:bJ,hr:yJ,html:MJ,lheading:CJ,list:kJ,newline:gJ,paragraph:NJ,table:pJ,text:EJ},FJ=mJ(`^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)`).replace(`hr`,yJ).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`,AJ).getRegex(),IJ={...PJ,lheading:wJ,table:FJ,paragraph:mJ(TJ).replace(`hr`,yJ).replace(`heading`,` {0,3}#{1,6}(?:\\s|$)`).replace(`|lheading`,``).replace(`table`,FJ).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`,AJ).getRegex()},LJ={...PJ,html:mJ(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:"[^"]*"|'[^']*'|\\s[^'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace(`comment`,jJ).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:pJ,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:mJ(TJ).replace(`hr`,yJ).replace(`heading`,` *#{1,6} *[^
|
|
217
217
|
]`).replace(`lheading`,CJ).replace(`|table`,``).replace(`blockquote`,` {0,3}>`).replace(`|fences`,``).replace(`|list`,``).replace(`|html`,``).replace(`|tag`,``).getRegex()},RJ=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,zJ=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,BJ=/^( {2,}|\\)\n(?!\s*$)/,VJ=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/,HJ=/[\p{P}\p{S}]/u,UJ=/[\s\p{P}\p{S}]/u,WJ=/[^\s\p{P}\p{S}]/u,GJ=mJ(/^((?![*_])punctSpace)/,`u`).replace(/punctSpace/g,UJ).getRegex(),KJ=/(?!~)[\p{P}\p{S}]/u,qJ=/(?!~)[\s\p{P}\p{S}]/u,JJ=/(?:[^\s\p{P}\p{S}]|~)/u,YJ=/\[[^[\]]*?\]\((?:\\.|[^\\\(\)]|\((?:\\.|[^\\\(\)])*\))*\)|`[^`]*?`|<[^<>]*?>/g,XJ=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,ZJ=mJ(XJ,`u`).replace(/punct/g,HJ).getRegex(),QJ=mJ(XJ,`u`).replace(/punct/g,KJ).getRegex(),$J=`^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)`,eY=mJ($J,`gu`).replace(/notPunctSpace/g,WJ).replace(/punctSpace/g,UJ).replace(/punct/g,HJ).getRegex(),tY=mJ($J,`gu`).replace(/notPunctSpace/g,JJ).replace(/punctSpace/g,qJ).replace(/punct/g,KJ).getRegex(),nY=mJ(`^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)`,`gu`).replace(/notPunctSpace/g,WJ).replace(/punctSpace/g,UJ).replace(/punct/g,HJ).getRegex(),rY=mJ(/\\(punct)/,`gu`).replace(/punct/g,HJ).getRegex(),iY=mJ(/^<(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(),aY=mJ(jJ).replace(`(?:-->|$)`,`-->`).getRegex(),oY=mJ(`^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`,aY).replace(`attribute`,/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),sY=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,cY=mJ(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace(`label`,sY).replace(`href`,/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace(`title`,/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),lY=mJ(/^!?\[(label)\]\[(ref)\]/).replace(`label`,sY).replace(`ref`,DJ).getRegex(),uY=mJ(/^!?\[(ref)\](?:\[\])?/).replace(`ref`,DJ).getRegex(),dY={_backpedal:pJ,anyPunctuation:rY,autolink:iY,blockSkip:YJ,br:BJ,code:zJ,del:pJ,emStrongLDelim:ZJ,emStrongRDelimAst:eY,emStrongRDelimUnd:nY,escape:RJ,link:cY,nolink:uY,punctuation:GJ,reflink:lY,reflinkSearch:mJ(`reflink|nolink(?!\\()`,`g`).replace(`reflink`,lY).replace(`nolink`,uY).getRegex(),tag:oY,text:VJ,url:pJ},fY={...dY,link:mJ(/^!?\[(label)\]\((.*?)\)/).replace(`label`,sY).getRegex(),reflink:mJ(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace(`label`,sY).getRegex()},pY={...dY,emStrongRDelimAst:tY,emStrongLDelim:QJ,url:mJ(/^((?: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.!#$%&'*+\/=?_`{\|}~-]+@)))/},mY={...pY,br:mJ(BJ).replace(`{2,}`,`*`).getRegex(),text:mJ(pY.text).replace(`\\b_`,`\\b_| {2,}\\n`).replace(/\{2,\}/g,`*`).getRegex()},hY={normal:PJ,gfm:IJ,pedantic:LJ},gY={normal:dY,gfm:pY,breaks:mY,pedantic:fY},_Y={"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`},vY=e=>_Y[e];function yY(e,t){if(t){if(hJ.escapeTest.test(e))return e.replace(hJ.escapeReplace,vY)}else if(hJ.escapeTestNoEncode.test(e))return e.replace(hJ.escapeReplaceNoEncode,vY);return e}function bY(e){try{e=encodeURI(e).replace(hJ.percentDecode,`%`)}catch{return null}return e}function xY(e,t){let n=e.replace(hJ.findPipe,(e,t,n)=>{let r=!1,i=t;for(;--i>=0&&n[i]===`\\`;)r=!r;return r?`|`:` |`}).split(hJ.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(hJ.slashPipe,`|`);return n}function SY(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 CY(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 wY(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 TY(e,t,n){let r=e.match(n.other.indentCodeCompensation);if(r===null)return t;let i=r[1];return t.split(`
|
|
218
218
|
`).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(`
|
|
219
219
|
`)}var EY=class{options;rules;lexer;constructor(e){this.options=e||dJ}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:SY(e,`
|
|
@@ -293,44 +293,44 @@ Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error
|
|
|
293
293
|
`&&!t)break;o++}i(e.slice(a,o),`str`),a=o;continue}if(PX(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(MX(n)){let n=a+1;for(;n<r&&NX(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(AX(e,n))?`key`:e[n]===`(`?`fn`:`plain`),a=n;continue}if(FX.has(n)){i(n,`punct`),a++;continue}if(IX.has(n)){let t=a+1;for(;t<r&&IX.has(e[t]);)t++;i(e.slice(a,t),`op`),a=t;continue}let o=a+1;for(;o<r&&!MX(e[o])&&!PX(e[o])&&!t.quotes.includes(e[o])&&!FX.has(e[o])&&!IX.has(e[o])&&!(t.line&&e.startsWith(t.line,o));)o++;i(e.slice(a,o),`plain`),a=o}return n}function RX(e){let t=[[]];for(let n of e){let e=n.text.split(`
|
|
294
294
|
`);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 zX(e,t){if(e===``)return[];let n=OX[t];return n?RX(LX(e,n)):e.split(`
|
|
295
295
|
`).map(e=>e?[{text:e,kind:`plain`}]:[])}var BX={".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`},VX={Dockerfile:`shell`,Makefile:`shell`,".gitignore":`shell`,".env":`shell`,".bashrc":`shell`,".zshrc":`shell`};function HX(e){let t=xh(e),n=t.lastIndexOf(`.`),r=n>0?t.slice(n).toLowerCase():``,i=VX[t]??BX[r]??`text`;return jX.has(i)?i:`text`}function UX(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 WX(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(...UX(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 GX=3,KX=e=>e===``?[]:e.split(`
|
|
296
|
-
`);function qX(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 JX(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]-GX),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+GX),!(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-GX)))}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 YX(e,t,n){let r=HX(n),i=zX(e,r),a=zX(t,r),o=KX(e),s=KX(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=WX(o,s).map(e=>qX(e,i,a)),u=l.filter(e=>e.type===`add`).length,d=l.filter(e=>e.type===`del`).length,{hunks:f,collapsedAfter:p}=JX(l);return{file:n,lang:r,status:c,hunks:f,collapsedAfter:p,additions:u,deletions:d}}var XX=`a, button, input, select, textarea, summary, label, [role="button"], [role="link"]`;function ZX(e){let t=e;return typeof t?.closest==`function`&&t.closest(XX)!=null}function QX({children:e,className:t,controls:n,expanded:r,label:i,meta:a,onToggle:o,chevronSize:s=12}){function c(e){if(ZX(e.target))return;let t=typeof window>`u`?null:window.getSelection();t&&!t.isCollapsed&&t.toString().trim()!==``||o()}return(0,L.createElement)(`div`,{className:`${t} w-full cursor-pointer text-left`,"data-expanded":r,onClick:c},(0,L.createElement)(`span`,{className:`flex min-w-0 items-center gap-2`},e),(0,L.createElement)(`span`,{className:`flex shrink-0 items-center gap-1.5`},a,(0,L.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-focus-ink-60`},(0,L.createElement)(r_,{"aria-hidden":!0,size:s,className:`relative -top-px shrink-0 transition-transform ${r?`rotate-90`:``}`}))))}function $X({path:e,className:t=``,children:n}){return(0,R.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),YK(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 eZ({edits:e,meta:t}){let{compactDiffs:n}=gr(zD),r=(0,L.useId)(),i=e[0].file,a=(0,L.useMemo)(()=>e.map(e=>YX(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,L.useState)(null);(0,L.useEffect)(()=>l(null),[n]);let u=c??!n;return(0,R.jsxs)(`div`,{className:`frizz-diff`,children:[(0,R.jsxs)(QX,{className:`frizz-diff-header`,controls:r,expanded:u,label:`${u?`Collapse`:`Expand`} Edit diff: ${i}`,onToggle:()=>l(!u),meta:t,chevronSize:11,children:[(0,R.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Edit`}),(0,R.jsx)(`span`,{className:`frizz-diff-file`,children:(0,R.jsx)($X,{path:i,className:`text-inherit no-underline`,children:xh(i)})}),o>0&&(0,R.jsxs)(`span`,{className:`frizz-diff-add tabular-nums shrink-0`,children:[`+`,o]}),s>0&&(0,R.jsxs)(`span`,{className:`frizz-diff-del tabular-nums shrink-0`,children:[`−`,s]})]}),(0,R.jsx)(`div`,{id:r,className:`frizz-diff-body`,hidden:!u,children:u&&a.map((e,t)=>(0,R.jsx)(`div`,{className:t>0?`frizz-diff-editsep`:void 0,children:(0,R.jsx)(tZ,{hunks:e.hunks,collapsedAfter:e.collapsedAfter})},t))})]})}function tZ({hunks:e,collapsedAfter:t}){let n=0,r=[];return e.forEach((e,t)=>{let i=e.collapsedBefore-n;i>0&&r.push((0,R.jsx)(nZ,{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,R.jsxs)(`div`,{className:`frizz-diff-line`,"data-type":n.type,children:[(0,R.jsx)(`span`,{className:`frizz-diff-gutter`,children:e}),(0,R.jsx)(`span`,{className:`frizz-diff-sign`,children:i}),(0,R.jsx)(`span`,{className:`frizz-diff-code`,children:n.tokens.map((e,t)=>(0,R.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,R.jsx)(nZ,{n:t},`safter`)),(0,R.jsx)(R.Fragment,{children:r})}function nZ({n:e}){return(0,R.jsxs)(`div`,{className:`frizz-diff-sep`,children:[e,` unchanged line`,e===1?``:`s`]})}function rZ(e){return(0,L.useMemo)(()=>({__html:e}),[e])}var iZ=/^[\w.@+-]+\.[a-z][a-z0-9]{0,7}$/i,aZ=/^(?:[A-Za-z]:\\|\\\\)?[\w.@+~-]+(?:\\[\w.@+~-]+)*(?::\d+(?::\d+)?)?$/;function oZ(e){let t=e.trim();return!t||t.length>1024||/\s/.test(t)||/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?!1:t===`~`||t.startsWith(`~/`)||t.startsWith(`/`)||t.includes(`/`)||t.includes(`\\`)&&aZ.test(t)?!0:iZ.test(t)}var sZ=new Map,cZ=new Set,lZ=0,uZ=new Set,dZ=e=>(uZ.add(e),()=>{uZ.delete(e)}),fZ=()=>lZ,pZ=128;async function mZ(e){let t=[...new Set(e)].filter(e=>!sZ.has(e)&&!cZ.has(e));if(!t.length)return;for(let e of t)cZ.add(e);let n=[];for(let e=0;e<t.length;e+=pZ)n.push(t.slice(e,e+pZ));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)sZ.has(t.input)||(sZ.set(t.input,t.path),i=!0);for(let e of t)cZ.delete(e);if(i){lZ+=1;for(let e of uZ)e()}}function hZ(e,t){e.setAttribute(`data-local-path`,t),e.setAttribute(`title`,`Open ${t}`),e.classList.add(`local-file-code`)}function gZ(e,t){(0,L.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(!oZ(t))continue;let r=sZ.get(t);r===void 0?n.push(t):r&&hZ(e,r)}n.length&&mZ(n)},[e,t,(0,L.useSyncExternalStore)(dZ,fZ,fZ)])}function _Z(e,t,n){let r=e.length;if(r===0||!(t>0))return[];let{gap:i,target:a,maxHeight:o,maxPerRow:s}=n,c=(t,n)=>{let r=0;for(let i=t;i<n;i++)r+=e[i];return r},l=(e,n)=>Math.max(0,t-i*(n-e-1))/c(e,n),u=Array(r+1).fill(1/0),d=Array(r+1).fill(0);u[0]=0;for(let e=1;e<=r;e++)for(let t=1;t<=Math.min(s,e);t++){let n=e-t,r=u[n]+(l(n,e)-a)**2;r<u[e]&&(u[e]=r,d[e]=n)}let f=[];for(let e=r;e>0;e=d[e]){let n=d[e],r=l(n,e),a=Math.min(r,o);f.unshift({start:n,end:e,height:a,width:a<r?a*c(n,e)+i*(e-n-1):t})}return f}var vZ={scale:1,x:0,y:0},yZ=(e,t,n)=>Math.min(Math.max(e,t),n);function bZ(e,t,n,r,i){let a=t*n/2;return 2*a<=i-r?yZ(0,r+a,i-a):yZ(e,i-a,r+a)}function xZ(e,t){let n=yZ(e.scale,1,t.max);return n===1?vZ:{scale:n,x:bZ(e.x,t.width,n,t.left,t.right),y:bZ(e.y,t.height,n,t.top,t.bottom)}}function SZ(e,t,n,r){let i=yZ(e.scale*t,1,r.max),a=i/e.scale;return xZ({scale:i,x:n.x-(n.x-e.x)*a,y:n.y-(n.y-e.y)*a},r)}function CZ(e,t,n,r){return xZ({scale:e.scale,x:e.x+t,y:e.y+n},r)}function wZ(e,t,n,r,i,a){let o=yZ(e.scale*(i/Math.max(n,1)),1,a.max),s=o/e.scale;return xZ({scale:o,x:r.x-(t.x-e.x)*s,y:r.y-(t.y-e.y)*s},a)}function TZ(e,t){return yZ(t/Math.max(e,1),2,4)}function EZ(e,t){return yZ(2*t/Math.max(e,1),4,12)}var DZ=6,OZ=420,kZ=16/10,AZ=.4,jZ=3,MZ=(e,t,n)=>Math.min(Math.max(e,t),n),NZ=e=>MZ(e/4,112,180);function PZ({entries:e,baseDir:t,framed:n=!0}){let r=xX(),i=(0,L.useMemo)(()=>t?{...r,dir:t}:r,[r,t]),a=(0,L.useMemo)(()=>e.map(e=>{let t=YR(e.target,i);return{entry:e,path:t,...ZR(e,t)}}),[e,i]),[o,s]=(0,L.useState)({}),[c,l]=(0,L.useState)({}),[u,d]=(0,L.useState)(null),f=zZ(u),p=a.filter(e=>e.path!==null&&!c[e.path]),m=a.filter(e=>!p.includes(e)),h=e=>MZ(o[e.path]||kZ,AZ,jZ),g=_Z(p.map(h),f,{gap:DZ,target:NZ(f),maxHeight:OZ,maxPerRow:8}),_=a.some(e=>e.entry.caption),v=p.map(e=>({path:e.path,label:e.label,captioned:e.captioned}));if(p.length===0)return(0,R.jsx)(`div`,{"data-lightbox-gallery":!0,className:`flex flex-col gap-1`,children:m.map((e,t)=>(0,R.jsx)(RZ,{tile:e},t))});let y=(0,R.jsxs)(`div`,{ref:d,"data-lightbox-gallery":!0,className:`flex w-full min-w-0 flex-col gap-1.5`,children:[g.map(e=>(0,R.jsx)(`div`,{"data-lightbox-row":!0,className:`mx-auto flex max-w-full gap-1.5`,style:{width:e.width},children:p.slice(e.start,e.end).map((t,n)=>(0,R.jsx)(IZ,{tile:t,ratio:h(t),labelled:_,onOpen:()=>Rh(v,e.start+n),onShape:e=>s(n=>n[t.path]===e?n:{...n,[t.path]:e}),onBroken:()=>l(e=>({...e,[t.path]:!0}))},e.start+n))},e.start)),m.map((e,t)=>(0,R.jsx)(RZ,{tile:e},t))]});return n?(0,R.jsx)(VY,{children:y}):(0,R.jsx)(`div`,{className:UY,children:y})}function FZ(e){return{flex:`${e} 1 0%`}}function IZ({tile:e,ratio:t,labelled:n,onOpen:r,onShape:i,onBroken:a}){let o=XR(e.path),s=(e,t)=>{e>0&&t>0&&i(e/t)};return(0,R.jsxs)(`button`,{type:`button`,"data-lightbox-tile":!0,"data-lightbox-video":o||void 0,onClick:r,"aria-label":`${o?`Play`:`View`} ${e.label}`,className:`group flex min-w-0 flex-col gap-1 rounded-md text-left outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60 focus-visible:ring-offset-2 focus-visible:ring-offset-panel-2 ${o?`cursor-pointer`:`cursor-zoom-in`}`,style:FZ(t),children:[(0,R.jsx)(`span`,{className:`relative block w-full overflow-hidden rounded-md`,style:{aspectRatio:t},children:o?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`video`,{src:`${BT(e.path)}#t=0.001`,preload:`metadata`,muted:!0,playsInline:!0,disablePictureInPicture:!0,tabIndex:-1,"aria-hidden":!0,onLoadedMetadata:e=>s(e.currentTarget.videoWidth,e.currentTarget.videoHeight),onError:a,className:`pointer-events-none block h-full w-full object-contain transition-[filter] group-hover:brightness-110`}),(0,R.jsx)(LZ,{})]}):(0,R.jsx)(`img`,{src:BT(e.path),alt:e.label,draggable:!1,onLoad:e=>s(e.currentTarget.naturalWidth,e.currentTarget.naturalHeight),onError:a,className:`block h-full w-full object-contain transition-[filter] group-hover:brightness-110`})}),n&&(0,R.jsx)(`span`,{title:e.label,className:`block truncate font-sans text-[11px] leading-4 text-muted`,children:e.label})]})}function LZ(){return(0,R.jsx)(`span`,{"data-lightbox-play":!0,"aria-hidden":!0,className:`pointer-events-none absolute left-1/2 top-1/2 flex h-8 w-8 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-black/55 text-white/90 ring-1 ring-white/15 backdrop-blur-sm transition-colors group-hover:bg-black/70 group-hover:text-white`,children:(0,R.jsx)(G_,{size:14,strokeWidth:sQ,absoluteStrokeWidth:!0,fill:`currentColor`})})}function RZ({tile:e}){return(0,R.jsx)(`div`,{"data-lightbox-missing":!0,className:`break-all font-mono-keep text-[12px] text-muted-70`,children:e.path??e.entry.target})}function zZ(e){let[t,n]=(0,L.useState)(0);return(0,L.useLayoutEffect)(()=>{if(!e)return;n(e.clientWidth);let t=new ResizeObserver(([e])=>n(e.contentRect.width));return t.observe(e),()=>t.disconnect()},[e]),t}function BZ(e,t,n){let[r,i]=(0,L.useState)([]),a=(0,L.useRef)(null);return(0,L.useLayoutEffect)(()=>{let n=e.current;if(a.current&&a.current.root===n&&a.current.html===t)return;a.current={root:n,html:t};let r=[];for(let e of n?.querySelectorAll(`pre > code.language-lightbox`)??[]){let t=e.closest(`.md-code`)??e.parentElement,n=document.createElement(`div`);n.className=`md-lightbox`,t.replaceWith(n),r.push({host:n,entries:JR(e.textContent??``)})}i(e=>e.length===0&&r.length===0?e:r)}),r.map(({host:e,entries:t},r)=>(0,Tn.createPortal)((0,R.jsx)(PZ,{entries:t,baseDir:n}),e,String(r)))}function VZ(){let{lightbox:e}=gr(X);return e?(0,R.jsx)(eQ,{images:e.images,index:e.index}):null}var HZ={x:0,y:0},UZ=e=>({path:e,zoom:vZ,pull:HZ,animate:!1,max:1/0,panning:!1}),WZ={mouse:4,touch:10},GZ=48,KZ=96,qZ=300,JZ=40,YZ=1.5,XZ=1.1,ZZ=`transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1)`,QZ=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),$Z=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y);function eQ({images:e,index:t}){Ag(Lg(),!1,zh);let n=(0,L.useRef)(document.activeElement instanceof HTMLElement?document.activeElement:null),r=(0,L.useRef)(null),i=(0,L.useRef)(null),[a,o]=(0,L.useState)(null),s=(0,L.useCallback)(e=>{i.current=e,o(e)},[]),c=(0,L.useRef)(null),l=(0,L.useRef)(null),u=e[t],d=u?.path??``,f=XR(d),p=(0,L.useRef)(UZ(d)),[m,h]=(0,L.useState)(p.current),g=()=>p.current.path===d?p.current:UZ(d),_=e=>{let t={...g(),...e};p.current=t,h(t)},v=m.path===d?m:UZ(d),y=(0,L.useRef)(new Map),b=(0,L.useRef)(`mouse`),x=(0,L.useRef)(null),S=(0,L.useRef)(!1),C=(0,L.useRef)(null),w=()=>{let e=c.current,t=i.current;if(!e||!t||!e.naturalWidth)return null;let n=e.getBoundingClientRect(),r=new DOMMatrixReadOnly(getComputedStyle(e).transform),a=n.width/r.a,o=n.height/r.d;if(!a||!o)return null;let s={x:n.left+n.width/2-r.e,y:n.top+n.height/2-r.f},l=t.getBoundingClientRect();return{centre:s,bounds:{width:a,height:o,left:l.left-s.x,right:l.right-s.x,top:l.top-s.y,bottom:l.bottom-s.y,max:EZ(a,e.naturalWidth)},detail:TZ(a,e.naturalWidth)}},T=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),E=(e,t)=>{let n=w();n&&_({zoom:e(g().zoom,n),animate:t,max:n.bounds.max})},D=e=>E((t,n)=>t.scale>1?vZ:SZ(vZ,n.detail,T(e,n.centre),n.bounds),!0),O=e=>E((t,n)=>SZ(t,e,{x:(n.bounds.left+n.bounds.right)/2,y:(n.bounds.top+n.bounds.bottom)/2},n.bounds),!0);if((0,L.useEffect)(()=>{if(!a)return;let e=e=>{let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?a.clientHeight:1;if(e.ctrlKey||e.metaKey){e.preventDefault();let n=Math.exp(MZ(-e.deltaY*t*.01,-.5,.5));E((t,r)=>SZ(t,n,T({x:e.clientX,y:e.clientY},r.centre),r.bounds),!1)}else g().zoom.scale>1&&(e.preventDefault(),E((n,r)=>CZ(n,-e.deltaX*t,-e.deltaY*t,r.bounds),!1))},t=null,n=e=>{e.preventDefault();let n=e;if(e.type===`gesturestart`)t=g().zoom;else if(e.type===`gesturechange`&&t&&y.current.size===0){let e=t;E((t,r)=>SZ(e,n.scale,T({x:n.clientX,y:n.clientY},r.centre),r.bounds),!1)}},r=new ResizeObserver(()=>{g().zoom.scale>1&&E((e,t)=>xZ(e,t.bounds),!1)});a.addEventListener(`wheel`,e,{passive:!1});for(let e of[`gesturestart`,`gesturechange`,`gestureend`])a.addEventListener(e,n);return r.observe(a),()=>{a.removeEventListener(`wheel`,e);for(let e of[`gesturestart`,`gesturechange`,`gestureend`])a.removeEventListener(e,n);r.disconnect()}},[a,d]),!u)return null;let k=e.length>1,A=v.zoom.scale>1,j=t=>{let n=!t.ctrlKey&&!t.metaKey&&!t.altKey;if(t.key===`ArrowLeft`)Bh(-1);else if(t.key===`ArrowRight`)Bh(1);else if(t.key===`Home`)Bh(-e.length);else if(t.key===`End`)Bh(e.length);else if(n&&(t.key===`+`||t.key===`=`))O(YZ);else if(n&&(t.key===`-`||t.key===`_`))O(1/YZ);else if(n&&t.key===`0`)_({zoom:vZ,animate:!0});else if(n&&t.key===` `&&f&&t.target!==l.current){let e=l.current;e?.paused?e.play().catch(()=>void 0):e?.pause()}else return;t.preventDefault(),t.stopPropagation()},M=e=>{e.target===e.currentTarget&&zh()},N=e=>{if(!(e.pointerType===`mouse`&&e.button!==0)&&!e.target.closest(`button, video`)){if(y.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),y.current.size===1)b.current=e.pointerType,S.current=!1,x.current={kind:`press`,id:e.pointerId,x:e.clientX,y:e.clientY};else if(y.current.size===2){let e=w(),[t,n]=[...y.current.values()];S.current=!0,C.current=null,x.current=e?{kind:`pinch`,start:g().zoom,mid:T(QZ(t,n),e.centre),distance:$Z(t,n)}:null,g().pull!==HZ&&_({pull:HZ,animate:!0})}}},P=n=>{if(!y.current.has(n.pointerId))return;y.current.set(n.pointerId,{x:n.clientX,y:n.clientY});let r=x.current;if(r?.kind===`pinch`){let e=r,[t,n]=[...y.current.values()];E((r,i)=>wZ(e.start,e.mid,e.distance,T(QZ(t,n),i.centre),$Z(t,n),i.bounds),!1);return}if(!(!r||r.id!==n.pointerId)){if(r.kind===`press`){if(Math.hypot(n.clientX-r.x,n.clientY-r.y)<(n.pointerType===`mouse`?WZ.mouse:WZ.touch))return;if(S.current=!0,C.current=null,g().zoom.scale>1)r={kind:`pan`,id:r.id,x:r.x,y:r.y};else if(n.pointerType!==`mouse`){let e=n.clientX-r.x,t=n.clientY-r.y;r={kind:`swipe`,id:r.id,x:r.x,y:r.y,axis:Math.abs(e)>Math.abs(t)?`x`:`y`}}else r=null;if(x.current=r,!r)return;i.current?.setPointerCapture(n.pointerId),r.kind===`pan`&&_({panning:!0})}if(r.kind===`pan`){let e=n.clientX-r.x,t=n.clientY-r.y;r.x=n.clientX,r.y=n.clientY,E((n,r)=>CZ(n,e,t,r.bounds),!1)}else if(r.kind===`swipe`){let i=n.clientX-r.x,a=n.clientY-r.y,o=i>0&&t===0||i<0&&t===e.length-1;_({pull:r.axis===`x`?{x:o?i/4:i,y:0}:{x:0,y:a},animate:!1})}}},F=e=>{if(!y.current.delete(e.pointerId))return;let t=x.current;if(t?.kind===`pinch`){let[e]=[...y.current.entries()];g().zoom.scale<XZ&&_({zoom:vZ,animate:!0}),x.current=e&&g().zoom.scale>1?{kind:`pan`,id:e[0],x:e[1].x,y:e[1].y}:null;return}if(!t||t.id!==e.pointerId)return;x.current=null;let n=e.type===`pointercancel`;if(t.kind===`pan`&&_({panning:!1}),t.kind===`swipe`){let r=e.clientX-t.x,i=e.clientY-t.y;if(_({pull:HZ,animate:!0}),n)return;t.axis===`x`&&Math.abs(r)>GZ?Bh(r<0?1:-1):t.axis===`y`&&Math.abs(i)>KZ&&zh();return}if(t.kind===`press`&&!n&&e.pointerType!==`mouse`){let t=C.current;t&&e.timeStamp-t.t<qZ&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<JZ?(C.current=null,S.current=!0,D({x:e.clientX,y:e.clientY})):C.current={t:e.timeStamp,x:e.clientX,y:e.clientY}}},I=e=>{if(S.current){S.current=!1;return}if(e.target.closest(`button, video`))return;let t=b.current===`mouse`;e.target===c.current?t&&D({x:e.clientX,y:e.clientY}):g().zoom.scale>1?t&&_({zoom:vZ,animate:!0}):zh()},ee=1-Math.min(Math.abs(v.pull.y)/(KZ*3),.6);return(0,R.jsx)(gR,{open:!0,onOpenChange:e=>{e||zh()},children:(0,R.jsxs)(bR,{children:[(0,R.jsx)(SR,{className:`overlay-in fixed inset-0 z-[200] bg-black/95 backdrop-blur-md`,style:{opacity:ee}}),(0,R.jsxs)(ER,{ref:r,"data-lightbox":!0,"aria-modal":`true`,"aria-describedby":void 0,onEscapeKeyDown:mB,onOpenAutoFocus:e=>{e.preventDefault(),r.current?.focus({preventScroll:!0})},onCloseAutoFocus:e=>{e.preventDefault(),n.current?.isConnected&&n.current.focus({preventScroll:!0})},onKeyDown:j,className:`overlay-in fixed inset-0 z-[200] flex flex-col text-white outline-none`,children:[(0,R.jsxs)(`header`,{onClick:M,className:`flex shrink-0 items-center gap-3 pb-2 pl-[max(env(safe-area-inset-left),16px)] pr-[max(env(safe-area-inset-right),16px)] pt-[max(env(safe-area-inset-top),12px)]`,style:{opacity:ee},children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(jR,{className:`truncate text-[13px] font-medium leading-5 text-white/90 ${u.captioned?``:`font-mono-keep`}`,children:u.label}),(0,R.jsx)(`div`,{className:`truncate font-mono-keep text-[11px] leading-4 text-white/45`,children:u.path})]}),(0,R.jsxs)(`div`,{"data-lightbox-actions":!0,className:`flex shrink-0 items-center gap-4`,children:[k&&(0,R.jsxs)(`span`,{"data-lightbox-counter":!0,className:`text-[12px] tabular-nums text-white/60`,children:[t+1,` / `,e.length]}),!f&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(cQ,{label:`Zoom out`,trim:iQ,onClick:()=>O(1/YZ),disabled:!A,className:`pointer-coarse:hidden`,children:(0,R.jsx)(uv,{size:16,strokeWidth:sQ,absoluteStrokeWidth:!0})}),(0,R.jsx)(cQ,{label:`Zoom in`,trim:iQ,onClick:()=>O(YZ),disabled:v.zoom.scale>=v.max-1e-6,className:`pointer-coarse:hidden`,children:(0,R.jsx)(lv,{size:16,strokeWidth:sQ,absoluteStrokeWidth:!0})})]}),(0,R.jsx)(cQ,{label:f?`Open in default player`:`Open in default viewer`,trim:aQ,onClick:()=>YK(u.path,!0),children:(0,R.jsx)(g_,{size:16,strokeWidth:sQ,absoluteStrokeWidth:!0})}),(0,R.jsx)(cQ,{label:`Close`,trim:oQ,onClick:zh,children:(0,R.jsx)(cv,{size:18,strokeWidth:sQ,absoluteStrokeWidth:!0})})]})]}),(0,R.jsxs)(`div`,{ref:s,"data-lightbox-stage":!0,onClick:I,onPointerDown:N,onPointerMove:P,onPointerUp:F,onPointerCancel:F,className:`relative flex min-h-0 flex-1 items-center justify-center overflow-hidden px-3 pb-[max(env(safe-area-inset-bottom),16px)] sm:px-16 ${A?v.panning?`cursor-grabbing`:`cursor-grab`:``}`,style:{touchAction:`none`},children:[f?(0,R.jsx)(rQ,{image:u,view:v,videoRef:l},u.path):(0,R.jsx)(nQ,{image:u,view:v,pictureRef:c},u.path),k&&t>0&&(0,R.jsx)(lQ,{side:`left`,onClick:()=>Bh(-1)}),k&&t<e.length-1&&(0,R.jsx)(lQ,{side:`right`,onClick:()=>Bh(1)})]})]})]})})}function tQ({what:e,path:t}){return(0,R.jsxs)(`div`,{className:`pointer-events-none max-w-md text-center`,children:[(0,R.jsxs)(`div`,{className:`text-[13px] text-white/70`,children:[e,` unavailable`]}),(0,R.jsx)(`div`,{className:`mt-1 break-all font-mono-keep text-[11px] text-white/45`,children:t})]})}function nQ({image:e,view:t,pictureRef:n}){let[r,i]=(0,L.useState)(!1);if(r)return(0,R.jsx)(tQ,{what:`Image`,path:e.path});let{scale:a,x:o,y:s}=t.zoom;return(0,R.jsx)(`img`,{ref:n,src:BT(e.path),alt:e.label,draggable:!1,onError:()=>i(!0),className:`block max-h-full max-w-full select-none object-contain ${a>1?``:`cursor-zoom-in`}`,style:{transform:`translate(${o+t.pull.x}px, ${s+t.pull.y}px) scale(${a})`,transition:t.animate?ZZ:`none`,borderRadius:6/a,boxShadow:`0 0 0 ${1/a}px rgb(255 255 255 / 0.1)`}})}function rQ({image:e,view:t,videoRef:n}){let[r,i]=(0,L.useState)(!1);return r?(0,R.jsx)(tQ,{what:`Video`,path:e.path}):(0,R.jsx)(`video`,{ref:n,src:BT(e.path),"aria-label":e.label,controls:!0,autoPlay:!0,playsInline:!0,preload:`auto`,onError:()=>i(!0),className:`block max-h-full max-w-full rounded-md bg-black`,style:{transform:`translate(${t.pull.x}px, ${t.pull.y}px)`,transition:t.animate?ZZ:`none`,boxShadow:`0 0 0 1px rgb(255 255 255 / 0.1)`}})}var iQ=`-mx-[11.25px]`,aQ=`-mx-[11.25px] pointer-coarse:-mx-[15.25px]`,oQ=`-mx-[12.75px] pointer-coarse:-mx-[16.75px]`,sQ=1.5;function cQ({label:e,trim:t,onClick:n,disabled:r,className:i=``,children:a}){return(0,R.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-disabled":r||void 0,onClick:()=>{r||n()},className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-white/70 outline-none transition-colors hover:bg-white/10 hover:text-white focus-visible:ring-1 focus-visible:ring-white/60 aria-disabled:cursor-default aria-disabled:text-white/25 aria-disabled:hover:bg-transparent aria-disabled:hover:text-white/25 pointer-coarse:h-11 pointer-coarse:w-11 ${t} ${i}`,children:a})}function lQ({side:e,onClick:t}){return(0,R.jsx)(`button`,{type:`button`,"data-lightbox-page":e,"aria-label":e===`left`?`Previous image`:`Next image`,onClick:t,className:`absolute top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/55 text-white/85 outline-none ring-1 ring-white/15 backdrop-blur-sm transition-colors hover:bg-black/75 hover:text-white focus-visible:ring-white/60 pointer-coarse:hidden ${e===`left`?`left-3`:`right-3`}`,children:(0,R.jsx)(e===`left`?n_:r_,{size:20,strokeWidth:sQ,absoluteStrokeWidth:!0})})}function uQ({as:e=`div`,className:t,html:n}){let r=rZ(n),i=(0,L.useRef)(null);gZ(i,n);let a=BZ(i,n);return(0,R.jsxs)(R.Fragment,{children:[(0,L.createElement)(e,{ref:i,className:t,dangerouslySetInnerHTML:r}),a]})}function dQ({text:e,language:t,className:n=``,...r}){let i=rZ((0,L.useMemo)(()=>PT(e,t),[e,t]));return(0,R.jsx)(`pre`,{...r,className:`hljs ${n}`,dangerouslySetInnerHTML:i})}var fQ=`Todos`,pQ={pending:{Icon:iv,className:`text-muted-50`},in_progress:{Icon:nv,className:`text-accent`},completed:{Icon:tv,className:`text-muted-75`}},mQ={pending:`text-fg/75`,in_progress:`text-fg`,completed:`text-muted-70`};function hQ({status:e}){let{Icon:t,className:n}=pQ[e];return(0,R.jsx)(t,{"aria-hidden":`true`,size:`1em`,strokeWidth:2,className:`frizz-todo-mark shrink-0 ${n}`})}var gQ={pending:`to do`,in_progress:`in progress`,completed:`done`};function _Q({todos:e,note:t,meta:n}){let[r,i]=(0,L.useState)(!1),a=(0,L.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,R.jsxs)(`div`,{className:`frizz-bash`,"data-todo-card":!0,children:[(0,R.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`} `:``}${fQ}${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-focus-ink-60`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:fQ}),u&&(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-[11.5px]`,title:u,"data-todo-headline":!0,children:[s&&(0,R.jsx)(hQ,{status:`in_progress`}),(0,R.jsx)(`span`,{className:`min-w-0 truncate text-muted`,children:u})]})]}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[l&&(0,R.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,R.jsx)(r_,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${r?`rotate-90`:``}`})]})]}),c&&(0,R.jsxs)(`div`,{id:a,hidden:!r,children:[r&&e.length>0&&(0,R.jsx)(`ul`,{className:`frizz-todo-list`,children:e.map((e,t)=>(0,R.jsxs)(`li`,{className:`frizz-todo-row`,"data-current":e.status===`in_progress`?`true`:void 0,children:[(0,R.jsx)(hQ,{status:e.status}),(0,R.jsx)(`span`,{className:`min-w-0 ${mQ[e.status]}`,children:e.text}),(0,R.jsx)(`span`,{className:`sr-only`,children:` — ${gQ[e.status]}`})]},t))}),r&&t&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`frizz-bash-output-label petite-caps`,children:`note`}),(0,R.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body`,children:t})]})]})]})}var vQ=/^```question(?:[ \t]+([A-Za-z][^\r\n]*?))?[ \t]*\r?\n(?:([\s\S]*?)\r?\n)??```[ \t]*$/gm,yQ=/^qst_[a-z0-9]+$/;function bQ(e){let t=(e??``).toLowerCase().split(/\s+/).filter(Boolean),n=e=>t.includes(e),r=t.find(e=>yQ.test(e));return{kind:n(`multi`)?`multi`:`question`,danger:n(`danger`),...r?{registeredId:r}:{}}}function xQ(e){let t=[],n=Kl(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{kind:a,danger:o,registeredId:s}=bQ(i[1]);if(i[2]===void 0&&!s){vQ.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}),SQ(t)}function SQ(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=PQ(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=CQ(r.text,a);o!==null&&(e[t]={...n,text:n.text.replace(/\s+$/,``)+`
|
|
296
|
+
`);function qX(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 JX(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]-GX),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+GX),!(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-GX)))}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 YX(e,t,n){let r=HX(n),i=zX(e,r),a=zX(t,r),o=KX(e),s=KX(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=WX(o,s).map(e=>qX(e,i,a)),u=l.filter(e=>e.type===`add`).length,d=l.filter(e=>e.type===`del`).length,{hunks:f,collapsedAfter:p}=JX(l);return{file:n,lang:r,status:c,hunks:f,collapsedAfter:p,additions:u,deletions:d}}var XX=`a, button, input, select, textarea, summary, label, [role="button"], [role="link"]`;function ZX(e){let t=e;return typeof t?.closest==`function`&&t.closest(XX)!=null}function QX({children:e,className:t,controls:n,expanded:r,label:i,meta:a,onToggle:o,chevronSize:s=12}){function c(e){if(ZX(e.target))return;let t=typeof window>`u`?null:window.getSelection();t&&!t.isCollapsed&&t.toString().trim()!==``||o()}return(0,L.createElement)(`div`,{className:`${t} w-full cursor-pointer text-left`,"data-expanded":r,onClick:c},(0,L.createElement)(`span`,{className:`flex min-w-0 items-center gap-2`},e),(0,L.createElement)(`span`,{className:`flex shrink-0 items-center gap-1.5`},a,(0,L.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-focus-ink-60`},(0,L.createElement)(r_,{"aria-hidden":!0,size:s,className:`relative -top-px shrink-0 transition-transform ${r?`rotate-90`:``}`}))))}function $X({path:e,className:t=``,children:n}){return(0,R.jsx)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),YK(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 eZ({edits:e,meta:t}){let{compactDiffs:n}=gr(RD),r=(0,L.useId)(),i=e[0].file,a=(0,L.useMemo)(()=>e.map(e=>YX(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,L.useState)(null);(0,L.useEffect)(()=>l(null),[n]);let u=c??!n;return(0,R.jsxs)(`div`,{className:`frizz-diff`,children:[(0,R.jsxs)(QX,{className:`frizz-diff-header`,controls:r,expanded:u,label:`${u?`Collapse`:`Expand`} Edit diff: ${i}`,onToggle:()=>l(!u),meta:t,chevronSize:11,children:[(0,R.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Edit`}),(0,R.jsx)(`span`,{className:`frizz-diff-file`,children:(0,R.jsx)($X,{path:i,className:`text-inherit no-underline`,children:xh(i)})}),o>0&&(0,R.jsxs)(`span`,{className:`frizz-diff-add tabular-nums shrink-0`,children:[`+`,o]}),s>0&&(0,R.jsxs)(`span`,{className:`frizz-diff-del tabular-nums shrink-0`,children:[`−`,s]})]}),(0,R.jsx)(`div`,{id:r,className:`frizz-diff-body`,hidden:!u,children:u&&a.map((e,t)=>(0,R.jsx)(`div`,{className:t>0?`frizz-diff-editsep`:void 0,children:(0,R.jsx)(tZ,{hunks:e.hunks,collapsedAfter:e.collapsedAfter})},t))})]})}function tZ({hunks:e,collapsedAfter:t}){let n=0,r=[];return e.forEach((e,t)=>{let i=e.collapsedBefore-n;i>0&&r.push((0,R.jsx)(nZ,{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,R.jsxs)(`div`,{className:`frizz-diff-line`,"data-type":n.type,children:[(0,R.jsx)(`span`,{className:`frizz-diff-gutter`,children:e}),(0,R.jsx)(`span`,{className:`frizz-diff-sign`,children:i}),(0,R.jsx)(`span`,{className:`frizz-diff-code`,children:n.tokens.map((e,t)=>(0,R.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,R.jsx)(nZ,{n:t},`safter`)),(0,R.jsx)(R.Fragment,{children:r})}function nZ({n:e}){return(0,R.jsxs)(`div`,{className:`frizz-diff-sep`,children:[e,` unchanged line`,e===1?``:`s`]})}function rZ(e){return(0,L.useMemo)(()=>({__html:e}),[e])}var iZ=/^[\w.@+-]+\.[a-z][a-z0-9]{0,7}$/i,aZ=/^(?:[A-Za-z]:\\|\\\\)?[\w.@+~-]+(?:\\[\w.@+~-]+)*(?::\d+(?::\d+)?)?$/;function oZ(e){let t=e.trim();return!t||t.length>1024||/\s/.test(t)||/^[a-z][a-z0-9+.-]*:\/\//i.test(t)?!1:t===`~`||t.startsWith(`~/`)||t.startsWith(`/`)||t.includes(`/`)||t.includes(`\\`)&&aZ.test(t)?!0:iZ.test(t)}var sZ=new Map,cZ=new Set,lZ=0,uZ=new Set,dZ=e=>(uZ.add(e),()=>{uZ.delete(e)}),fZ=()=>lZ,pZ=128;async function mZ(e){let t=[...new Set(e)].filter(e=>!sZ.has(e)&&!cZ.has(e));if(!t.length)return;for(let e of t)cZ.add(e);let n=[];for(let e=0;e<t.length;e+=pZ)n.push(t.slice(e,e+pZ));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)sZ.has(t.input)||(sZ.set(t.input,t.path),i=!0);for(let e of t)cZ.delete(e);if(i){lZ+=1;for(let e of uZ)e()}}function hZ(e,t){e.setAttribute(`data-local-path`,t),e.setAttribute(`title`,`Open ${t}`),e.classList.add(`local-file-code`)}function gZ(e,t){(0,L.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(!oZ(t))continue;let r=sZ.get(t);r===void 0?n.push(t):r&&hZ(e,r)}n.length&&mZ(n)},[e,t,(0,L.useSyncExternalStore)(dZ,fZ,fZ)])}function _Z(e,t,n){let r=e.length;if(r===0||!(t>0))return[];let{gap:i,target:a,maxHeight:o,maxPerRow:s}=n,c=(t,n)=>{let r=0;for(let i=t;i<n;i++)r+=e[i];return r},l=(e,n)=>Math.max(0,t-i*(n-e-1))/c(e,n),u=Array(r+1).fill(1/0),d=Array(r+1).fill(0);u[0]=0;for(let e=1;e<=r;e++)for(let t=1;t<=Math.min(s,e);t++){let n=e-t,r=u[n]+(l(n,e)-a)**2;r<u[e]&&(u[e]=r,d[e]=n)}let f=[];for(let e=r;e>0;e=d[e]){let n=d[e],r=l(n,e),a=Math.min(r,o);f.unshift({start:n,end:e,height:a,width:a<r?a*c(n,e)+i*(e-n-1):t})}return f}var vZ={scale:1,x:0,y:0},yZ=(e,t,n)=>Math.min(Math.max(e,t),n);function bZ(e,t,n,r,i){let a=t*n/2;return 2*a<=i-r?yZ(0,r+a,i-a):yZ(e,i-a,r+a)}function xZ(e,t){let n=yZ(e.scale,1,t.max);return n===1?vZ:{scale:n,x:bZ(e.x,t.width,n,t.left,t.right),y:bZ(e.y,t.height,n,t.top,t.bottom)}}function SZ(e,t,n,r){let i=yZ(e.scale*t,1,r.max),a=i/e.scale;return xZ({scale:i,x:n.x-(n.x-e.x)*a,y:n.y-(n.y-e.y)*a},r)}function CZ(e,t,n,r){return xZ({scale:e.scale,x:e.x+t,y:e.y+n},r)}function wZ(e,t,n,r,i,a){let o=yZ(e.scale*(i/Math.max(n,1)),1,a.max),s=o/e.scale;return xZ({scale:o,x:r.x-(t.x-e.x)*s,y:r.y-(t.y-e.y)*s},a)}function TZ(e,t){return yZ(t/Math.max(e,1),2,4)}function EZ(e,t){return yZ(2*t/Math.max(e,1),4,12)}var DZ=6,OZ=420,kZ=16/10,AZ=.4,jZ=3,MZ=(e,t,n)=>Math.min(Math.max(e,t),n),NZ=e=>MZ(e/4,112,180);function PZ({entries:e,baseDir:t,framed:n=!0}){let r=xX(),i=(0,L.useMemo)(()=>t?{...r,dir:t}:r,[r,t]),a=(0,L.useMemo)(()=>e.map(e=>{let t=JR(e.target,i);return{entry:e,path:t,...XR(e,t)}}),[e,i]),[o,s]=(0,L.useState)({}),[c,l]=(0,L.useState)({}),[u,d]=(0,L.useState)(null),f=zZ(u),p=a.filter(e=>e.path!==null&&!c[e.path]),m=a.filter(e=>!p.includes(e)),h=e=>MZ(o[e.path]||kZ,AZ,jZ),g=_Z(p.map(h),f,{gap:DZ,target:NZ(f),maxHeight:OZ,maxPerRow:8}),_=a.some(e=>e.entry.caption),v=p.map(e=>({path:e.path,label:e.label,captioned:e.captioned}));if(p.length===0)return(0,R.jsx)(`div`,{"data-lightbox-gallery":!0,className:`flex flex-col gap-1`,children:m.map((e,t)=>(0,R.jsx)(RZ,{tile:e},t))});let y=(0,R.jsxs)(`div`,{ref:d,"data-lightbox-gallery":!0,className:`flex w-full min-w-0 flex-col gap-1.5`,children:[g.map(e=>(0,R.jsx)(`div`,{"data-lightbox-row":!0,className:`mx-auto flex max-w-full gap-1.5`,style:{width:e.width},children:p.slice(e.start,e.end).map((t,n)=>(0,R.jsx)(IZ,{tile:t,ratio:h(t),labelled:_,onOpen:()=>Rh(v,e.start+n),onShape:e=>s(n=>n[t.path]===e?n:{...n,[t.path]:e}),onBroken:()=>l(e=>({...e,[t.path]:!0}))},e.start+n))},e.start)),m.map((e,t)=>(0,R.jsx)(RZ,{tile:e},t))]});return n?(0,R.jsx)(VY,{children:y}):(0,R.jsx)(`div`,{className:UY,children:y})}function FZ(e){return{flex:`${e} 1 0%`}}function IZ({tile:e,ratio:t,labelled:n,onOpen:r,onShape:i,onBroken:a}){let o=YR(e.path),s=(e,t)=>{e>0&&t>0&&i(e/t)};return(0,R.jsxs)(`button`,{type:`button`,"data-lightbox-tile":!0,"data-lightbox-video":o||void 0,onClick:r,"aria-label":`${o?`Play`:`View`} ${e.label}`,className:`group flex min-w-0 flex-col gap-1 rounded-md text-left outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60 focus-visible:ring-offset-2 focus-visible:ring-offset-panel-2 ${o?`cursor-pointer`:`cursor-zoom-in`}`,style:FZ(t),children:[(0,R.jsx)(`span`,{className:`relative block w-full overflow-hidden rounded-md`,style:{aspectRatio:t},children:o?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`video`,{src:`${BT(e.path)}#t=0.001`,preload:`metadata`,muted:!0,playsInline:!0,disablePictureInPicture:!0,tabIndex:-1,"aria-hidden":!0,onLoadedMetadata:e=>s(e.currentTarget.videoWidth,e.currentTarget.videoHeight),onError:a,className:`pointer-events-none block h-full w-full object-contain transition-[filter] group-hover:brightness-110`}),(0,R.jsx)(LZ,{})]}):(0,R.jsx)(`img`,{src:BT(e.path),alt:e.label,draggable:!1,onLoad:e=>s(e.currentTarget.naturalWidth,e.currentTarget.naturalHeight),onError:a,className:`block h-full w-full object-contain transition-[filter] group-hover:brightness-110`})}),n&&(0,R.jsx)(`span`,{title:e.label,className:`block truncate font-sans text-[11px] leading-4 text-muted`,children:e.label})]})}function LZ(){return(0,R.jsx)(`span`,{"data-lightbox-play":!0,"aria-hidden":!0,className:`pointer-events-none absolute left-1/2 top-1/2 flex h-8 w-8 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full bg-black/55 text-white/90 ring-1 ring-white/15 backdrop-blur-sm transition-colors group-hover:bg-black/70 group-hover:text-white`,children:(0,R.jsx)(G_,{size:14,strokeWidth:sQ,absoluteStrokeWidth:!0,fill:`currentColor`})})}function RZ({tile:e}){return(0,R.jsx)(`div`,{"data-lightbox-missing":!0,className:`break-all font-mono-keep text-[12px] text-muted-70`,children:e.path??e.entry.target})}function zZ(e){let[t,n]=(0,L.useState)(0);return(0,L.useLayoutEffect)(()=>{if(!e)return;n(e.clientWidth);let t=new ResizeObserver(([e])=>n(e.contentRect.width));return t.observe(e),()=>t.disconnect()},[e]),t}function BZ(e,t,n){let[r,i]=(0,L.useState)([]),a=(0,L.useRef)(null);return(0,L.useLayoutEffect)(()=>{let n=e.current;if(a.current&&a.current.root===n&&a.current.html===t)return;a.current={root:n,html:t};let r=[];for(let e of n?.querySelectorAll(`pre > code.language-lightbox`)??[]){let t=e.closest(`.md-code`)??e.parentElement,n=document.createElement(`div`);n.className=`md-lightbox`,t.replaceWith(n),r.push({host:n,entries:qR(e.textContent??``)})}i(e=>e.length===0&&r.length===0?e:r)}),r.map(({host:e,entries:t},r)=>(0,Tn.createPortal)((0,R.jsx)(PZ,{entries:t,baseDir:n}),e,String(r)))}function VZ(){let{lightbox:e}=gr(X);return e?(0,R.jsx)(eQ,{images:e.images,index:e.index}):null}var HZ={x:0,y:0},UZ=e=>({path:e,zoom:vZ,pull:HZ,animate:!1,max:1/0,panning:!1}),WZ={mouse:4,touch:10},GZ=48,KZ=96,qZ=300,JZ=40,YZ=1.5,XZ=1.1,ZZ=`transform 180ms cubic-bezier(0.2, 0.8, 0.2, 1)`,QZ=(e,t)=>({x:(e.x+t.x)/2,y:(e.y+t.y)/2}),$Z=(e,t)=>Math.hypot(e.x-t.x,e.y-t.y);function eQ({images:e,index:t}){Ag(Lg(),!1,zh);let n=(0,L.useRef)(document.activeElement instanceof HTMLElement?document.activeElement:null),r=(0,L.useRef)(null),i=(0,L.useRef)(null),[a,o]=(0,L.useState)(null),s=(0,L.useCallback)(e=>{i.current=e,o(e)},[]),c=(0,L.useRef)(null),l=(0,L.useRef)(null),u=e[t],d=u?.path??``,f=YR(d),p=(0,L.useRef)(UZ(d)),[m,h]=(0,L.useState)(p.current),g=()=>p.current.path===d?p.current:UZ(d),_=e=>{let t={...g(),...e};p.current=t,h(t)},v=m.path===d?m:UZ(d),y=(0,L.useRef)(new Map),b=(0,L.useRef)(`mouse`),x=(0,L.useRef)(null),S=(0,L.useRef)(!1),C=(0,L.useRef)(null),w=()=>{let e=c.current,t=i.current;if(!e||!t||!e.naturalWidth)return null;let n=e.getBoundingClientRect(),r=new DOMMatrixReadOnly(getComputedStyle(e).transform),a=n.width/r.a,o=n.height/r.d;if(!a||!o)return null;let s={x:n.left+n.width/2-r.e,y:n.top+n.height/2-r.f},l=t.getBoundingClientRect();return{centre:s,bounds:{width:a,height:o,left:l.left-s.x,right:l.right-s.x,top:l.top-s.y,bottom:l.bottom-s.y,max:EZ(a,e.naturalWidth)},detail:TZ(a,e.naturalWidth)}},T=(e,t)=>({x:e.x-t.x,y:e.y-t.y}),E=(e,t)=>{let n=w();n&&_({zoom:e(g().zoom,n),animate:t,max:n.bounds.max})},D=e=>E((t,n)=>t.scale>1?vZ:SZ(vZ,n.detail,T(e,n.centre),n.bounds),!0),O=e=>E((t,n)=>SZ(t,e,{x:(n.bounds.left+n.bounds.right)/2,y:(n.bounds.top+n.bounds.bottom)/2},n.bounds),!0);if((0,L.useEffect)(()=>{if(!a)return;let e=e=>{let t=e.deltaMode===WheelEvent.DOM_DELTA_LINE?16:e.deltaMode===WheelEvent.DOM_DELTA_PAGE?a.clientHeight:1;if(e.ctrlKey||e.metaKey){e.preventDefault();let n=Math.exp(MZ(-e.deltaY*t*.01,-.5,.5));E((t,r)=>SZ(t,n,T({x:e.clientX,y:e.clientY},r.centre),r.bounds),!1)}else g().zoom.scale>1&&(e.preventDefault(),E((n,r)=>CZ(n,-e.deltaX*t,-e.deltaY*t,r.bounds),!1))},t=null,n=e=>{e.preventDefault();let n=e;if(e.type===`gesturestart`)t=g().zoom;else if(e.type===`gesturechange`&&t&&y.current.size===0){let e=t;E((t,r)=>SZ(e,n.scale,T({x:n.clientX,y:n.clientY},r.centre),r.bounds),!1)}},r=new ResizeObserver(()=>{g().zoom.scale>1&&E((e,t)=>xZ(e,t.bounds),!1)});a.addEventListener(`wheel`,e,{passive:!1});for(let e of[`gesturestart`,`gesturechange`,`gestureend`])a.addEventListener(e,n);return r.observe(a),()=>{a.removeEventListener(`wheel`,e);for(let e of[`gesturestart`,`gesturechange`,`gestureend`])a.removeEventListener(e,n);r.disconnect()}},[a,d]),!u)return null;let k=e.length>1,A=v.zoom.scale>1,j=t=>{let n=!t.ctrlKey&&!t.metaKey&&!t.altKey;if(t.key===`ArrowLeft`)Bh(-1);else if(t.key===`ArrowRight`)Bh(1);else if(t.key===`Home`)Bh(-e.length);else if(t.key===`End`)Bh(e.length);else if(n&&(t.key===`+`||t.key===`=`))O(YZ);else if(n&&(t.key===`-`||t.key===`_`))O(1/YZ);else if(n&&t.key===`0`)_({zoom:vZ,animate:!0});else if(n&&t.key===` `&&f&&t.target!==l.current){let e=l.current;e?.paused?e.play().catch(()=>void 0):e?.pause()}else return;t.preventDefault(),t.stopPropagation()},M=e=>{e.target===e.currentTarget&&zh()},N=e=>{if(!(e.pointerType===`mouse`&&e.button!==0)&&!e.target.closest(`button, video`)){if(y.current.set(e.pointerId,{x:e.clientX,y:e.clientY}),y.current.size===1)b.current=e.pointerType,S.current=!1,x.current={kind:`press`,id:e.pointerId,x:e.clientX,y:e.clientY};else if(y.current.size===2){let e=w(),[t,n]=[...y.current.values()];S.current=!0,C.current=null,x.current=e?{kind:`pinch`,start:g().zoom,mid:T(QZ(t,n),e.centre),distance:$Z(t,n)}:null,g().pull!==HZ&&_({pull:HZ,animate:!0})}}},P=n=>{if(!y.current.has(n.pointerId))return;y.current.set(n.pointerId,{x:n.clientX,y:n.clientY});let r=x.current;if(r?.kind===`pinch`){let e=r,[t,n]=[...y.current.values()];E((r,i)=>wZ(e.start,e.mid,e.distance,T(QZ(t,n),i.centre),$Z(t,n),i.bounds),!1);return}if(!(!r||r.id!==n.pointerId)){if(r.kind===`press`){if(Math.hypot(n.clientX-r.x,n.clientY-r.y)<(n.pointerType===`mouse`?WZ.mouse:WZ.touch))return;if(S.current=!0,C.current=null,g().zoom.scale>1)r={kind:`pan`,id:r.id,x:r.x,y:r.y};else if(n.pointerType!==`mouse`){let e=n.clientX-r.x,t=n.clientY-r.y;r={kind:`swipe`,id:r.id,x:r.x,y:r.y,axis:Math.abs(e)>Math.abs(t)?`x`:`y`}}else r=null;if(x.current=r,!r)return;i.current?.setPointerCapture(n.pointerId),r.kind===`pan`&&_({panning:!0})}if(r.kind===`pan`){let e=n.clientX-r.x,t=n.clientY-r.y;r.x=n.clientX,r.y=n.clientY,E((n,r)=>CZ(n,e,t,r.bounds),!1)}else if(r.kind===`swipe`){let i=n.clientX-r.x,a=n.clientY-r.y,o=i>0&&t===0||i<0&&t===e.length-1;_({pull:r.axis===`x`?{x:o?i/4:i,y:0}:{x:0,y:a},animate:!1})}}},F=e=>{if(!y.current.delete(e.pointerId))return;let t=x.current;if(t?.kind===`pinch`){let[e]=[...y.current.entries()];g().zoom.scale<XZ&&_({zoom:vZ,animate:!0}),x.current=e&&g().zoom.scale>1?{kind:`pan`,id:e[0],x:e[1].x,y:e[1].y}:null;return}if(!t||t.id!==e.pointerId)return;x.current=null;let n=e.type===`pointercancel`;if(t.kind===`pan`&&_({panning:!1}),t.kind===`swipe`){let r=e.clientX-t.x,i=e.clientY-t.y;if(_({pull:HZ,animate:!0}),n)return;t.axis===`x`&&Math.abs(r)>GZ?Bh(r<0?1:-1):t.axis===`y`&&Math.abs(i)>KZ&&zh();return}if(t.kind===`press`&&!n&&e.pointerType!==`mouse`){let t=C.current;t&&e.timeStamp-t.t<qZ&&Math.hypot(e.clientX-t.x,e.clientY-t.y)<JZ?(C.current=null,S.current=!0,D({x:e.clientX,y:e.clientY})):C.current={t:e.timeStamp,x:e.clientX,y:e.clientY}}},I=e=>{if(S.current){S.current=!1;return}if(e.target.closest(`button, video`))return;let t=b.current===`mouse`;e.target===c.current?t&&D({x:e.clientX,y:e.clientY}):g().zoom.scale>1?t&&_({zoom:vZ,animate:!0}):zh()},ee=1-Math.min(Math.abs(v.pull.y)/(KZ*3),.6);return(0,R.jsx)(hR,{open:!0,onOpenChange:e=>{e||zh()},children:(0,R.jsxs)(yR,{children:[(0,R.jsx)(xR,{className:`overlay-in fixed inset-0 z-[200] bg-black/95 backdrop-blur-md`,style:{opacity:ee}}),(0,R.jsxs)(TR,{ref:r,"data-lightbox":!0,"aria-modal":`true`,"aria-describedby":void 0,onEscapeKeyDown:mB,onOpenAutoFocus:e=>{e.preventDefault(),r.current?.focus({preventScroll:!0})},onCloseAutoFocus:e=>{e.preventDefault(),n.current?.isConnected&&n.current.focus({preventScroll:!0})},onKeyDown:j,className:`overlay-in fixed inset-0 z-[200] flex flex-col text-white outline-none`,children:[(0,R.jsxs)(`header`,{onClick:M,className:`flex shrink-0 items-center gap-3 pb-2 pl-[max(env(safe-area-inset-left),16px)] pr-[max(env(safe-area-inset-right),16px)] pt-[max(env(safe-area-inset-top),12px)]`,style:{opacity:ee},children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(AR,{className:`truncate text-[13px] font-medium leading-5 text-white/90 ${u.captioned?``:`font-mono-keep`}`,children:u.label}),(0,R.jsx)(`div`,{className:`truncate font-mono-keep text-[11px] leading-4 text-white/45`,children:u.path})]}),(0,R.jsxs)(`div`,{"data-lightbox-actions":!0,className:`flex shrink-0 items-center gap-4`,children:[k&&(0,R.jsxs)(`span`,{"data-lightbox-counter":!0,className:`text-[12px] tabular-nums text-white/60`,children:[t+1,` / `,e.length]}),!f&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(cQ,{label:`Zoom out`,trim:iQ,onClick:()=>O(1/YZ),disabled:!A,className:`pointer-coarse:hidden`,children:(0,R.jsx)(uv,{size:16,strokeWidth:sQ,absoluteStrokeWidth:!0})}),(0,R.jsx)(cQ,{label:`Zoom in`,trim:iQ,onClick:()=>O(YZ),disabled:v.zoom.scale>=v.max-1e-6,className:`pointer-coarse:hidden`,children:(0,R.jsx)(lv,{size:16,strokeWidth:sQ,absoluteStrokeWidth:!0})})]}),(0,R.jsx)(cQ,{label:f?`Open in default player`:`Open in default viewer`,trim:aQ,onClick:()=>YK(u.path,!0),children:(0,R.jsx)(g_,{size:16,strokeWidth:sQ,absoluteStrokeWidth:!0})}),(0,R.jsx)(cQ,{label:`Close`,trim:oQ,onClick:zh,children:(0,R.jsx)(cv,{size:18,strokeWidth:sQ,absoluteStrokeWidth:!0})})]})]}),(0,R.jsxs)(`div`,{ref:s,"data-lightbox-stage":!0,onClick:I,onPointerDown:N,onPointerMove:P,onPointerUp:F,onPointerCancel:F,className:`relative flex min-h-0 flex-1 items-center justify-center overflow-hidden px-3 pb-[max(env(safe-area-inset-bottom),16px)] sm:px-16 ${A?v.panning?`cursor-grabbing`:`cursor-grab`:``}`,style:{touchAction:`none`},children:[f?(0,R.jsx)(rQ,{image:u,view:v,videoRef:l},u.path):(0,R.jsx)(nQ,{image:u,view:v,pictureRef:c},u.path),k&&t>0&&(0,R.jsx)(lQ,{side:`left`,onClick:()=>Bh(-1)}),k&&t<e.length-1&&(0,R.jsx)(lQ,{side:`right`,onClick:()=>Bh(1)})]})]})]})})}function tQ({what:e,path:t}){return(0,R.jsxs)(`div`,{className:`pointer-events-none max-w-md text-center`,children:[(0,R.jsxs)(`div`,{className:`text-[13px] text-white/70`,children:[e,` unavailable`]}),(0,R.jsx)(`div`,{className:`mt-1 break-all font-mono-keep text-[11px] text-white/45`,children:t})]})}function nQ({image:e,view:t,pictureRef:n}){let[r,i]=(0,L.useState)(!1);if(r)return(0,R.jsx)(tQ,{what:`Image`,path:e.path});let{scale:a,x:o,y:s}=t.zoom;return(0,R.jsx)(`img`,{ref:n,src:BT(e.path),alt:e.label,draggable:!1,onError:()=>i(!0),className:`block max-h-full max-w-full select-none object-contain ${a>1?``:`cursor-zoom-in`}`,style:{transform:`translate(${o+t.pull.x}px, ${s+t.pull.y}px) scale(${a})`,transition:t.animate?ZZ:`none`,borderRadius:6/a,boxShadow:`0 0 0 ${1/a}px rgb(255 255 255 / 0.1)`}})}function rQ({image:e,view:t,videoRef:n}){let[r,i]=(0,L.useState)(!1);return r?(0,R.jsx)(tQ,{what:`Video`,path:e.path}):(0,R.jsx)(`video`,{ref:n,src:BT(e.path),"aria-label":e.label,controls:!0,autoPlay:!0,playsInline:!0,preload:`auto`,onError:()=>i(!0),className:`block max-h-full max-w-full rounded-md bg-black`,style:{transform:`translate(${t.pull.x}px, ${t.pull.y}px)`,transition:t.animate?ZZ:`none`,boxShadow:`0 0 0 1px rgb(255 255 255 / 0.1)`}})}var iQ=`-mx-[11.25px]`,aQ=`-mx-[11.25px] pointer-coarse:-mx-[15.25px]`,oQ=`-mx-[12.75px] pointer-coarse:-mx-[16.75px]`,sQ=1.5;function cQ({label:e,trim:t,onClick:n,disabled:r,className:i=``,children:a}){return(0,R.jsx)(`button`,{type:`button`,"aria-label":e,title:e,"aria-disabled":r||void 0,onClick:()=>{r||n()},className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-md text-white/70 outline-none transition-colors hover:bg-white/10 hover:text-white focus-visible:ring-1 focus-visible:ring-white/60 aria-disabled:cursor-default aria-disabled:text-white/25 aria-disabled:hover:bg-transparent aria-disabled:hover:text-white/25 pointer-coarse:h-11 pointer-coarse:w-11 ${t} ${i}`,children:a})}function lQ({side:e,onClick:t}){return(0,R.jsx)(`button`,{type:`button`,"data-lightbox-page":e,"aria-label":e===`left`?`Previous image`:`Next image`,onClick:t,className:`absolute top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-black/55 text-white/85 outline-none ring-1 ring-white/15 backdrop-blur-sm transition-colors hover:bg-black/75 hover:text-white focus-visible:ring-white/60 pointer-coarse:hidden ${e===`left`?`left-3`:`right-3`}`,children:(0,R.jsx)(e===`left`?n_:r_,{size:20,strokeWidth:sQ,absoluteStrokeWidth:!0})})}function uQ({as:e=`div`,className:t,html:n}){let r=rZ(n),i=(0,L.useRef)(null);gZ(i,n);let a=BZ(i,n);return(0,R.jsxs)(R.Fragment,{children:[(0,L.createElement)(e,{ref:i,className:t,dangerouslySetInnerHTML:r}),a]})}function dQ({text:e,language:t,className:n=``,...r}){let i=rZ((0,L.useMemo)(()=>PT(e,t),[e,t]));return(0,R.jsx)(`pre`,{...r,className:`hljs ${n}`,dangerouslySetInnerHTML:i})}var fQ=`Todos`,pQ={pending:{Icon:iv,className:`text-muted-50`},in_progress:{Icon:nv,className:`text-accent`},completed:{Icon:tv,className:`text-muted-75`}},mQ={pending:`text-fg/75`,in_progress:`text-fg`,completed:`text-muted-70`};function hQ({status:e}){let{Icon:t,className:n}=pQ[e];return(0,R.jsx)(t,{"aria-hidden":`true`,size:`1em`,strokeWidth:2,className:`frizz-todo-mark shrink-0 ${n}`})}var gQ={pending:`to do`,in_progress:`in progress`,completed:`done`};function _Q({todos:e,note:t,meta:n}){let[r,i]=(0,L.useState)(!1),a=(0,L.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,R.jsxs)(`div`,{className:`frizz-bash`,"data-todo-card":!0,children:[(0,R.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`} `:``}${fQ}${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-focus-ink-60`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:fQ}),u&&(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 text-[11.5px]`,title:u,"data-todo-headline":!0,children:[s&&(0,R.jsx)(hQ,{status:`in_progress`}),(0,R.jsx)(`span`,{className:`min-w-0 truncate text-muted`,children:u})]})]}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[l&&(0,R.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,R.jsx)(r_,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${r?`rotate-90`:``}`})]})]}),c&&(0,R.jsxs)(`div`,{id:a,hidden:!r,children:[r&&e.length>0&&(0,R.jsx)(`ul`,{className:`frizz-todo-list`,children:e.map((e,t)=>(0,R.jsxs)(`li`,{className:`frizz-todo-row`,"data-current":e.status===`in_progress`?`true`:void 0,children:[(0,R.jsx)(hQ,{status:e.status}),(0,R.jsx)(`span`,{className:`min-w-0 ${mQ[e.status]}`,children:e.text}),(0,R.jsx)(`span`,{className:`sr-only`,children:` — ${gQ[e.status]}`})]},t))}),r&&t&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`frizz-bash-output-label petite-caps`,children:`note`}),(0,R.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body`,children:t})]})]})]})}var vQ=/^```question(?:[ \t]+([A-Za-z][^\r\n]*?))?[ \t]*\r?\n(?:([\s\S]*?)\r?\n)??```[ \t]*$/gm,yQ=/^qst_[a-z0-9]+$/;function bQ(e){let t=(e??``).toLowerCase().split(/\s+/).filter(Boolean),n=e=>t.includes(e),r=t.find(e=>yQ.test(e));return{kind:n(`multi`)?`multi`:`question`,danger:n(`danger`),...r?{registeredId:r}:{}}}function xQ(e){let t=[],n=Kl(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{kind:a,danger:o,registeredId:s}=bQ(i[1]);if(i[2]===void 0&&!s){vQ.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}),SQ(t)}function SQ(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=PQ(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=CQ(r.text,a);o!==null&&(e[t]={...n,text:n.text.replace(/\s+$/,``)+`
|
|
297
297
|
|
|
298
298
|
`+o.run},o.rest.trim()?e[t+1]={kind:`prose`,text:o.rest}:e.splice(t+1,1))}return e}function CQ(e,t){let n=e.split(`
|
|
299
299
|
`).map(e=>e.replace(/\r$/,``)),r=0;for(;r<n.length&&n[r].trim()===``;)r++;if(r>=n.length||!TQ.test(n[r]))return null;let i=OQ(n[r]);if(t===null?!AQ(i):!kQ(t,i))return null;let a=r,o=i;for(let e=r+1;e<n.length;e++){let t=n[e];if(TQ.test(t)){if(!kQ(o,OQ(t)))break;o=OQ(t),a=e;continue}if(t.trim()===``)continue;if(EQ.test(t)){a=e;break}let r=n.findIndex((t,n)=>n>e&&TQ.test(t));if(r===-1||!kQ(o,OQ(n[r])))break}let s=n.slice(r,a+1);return s.filter(e=>TQ.test(e)).length<(t===null?2:1)?null:{run:s.join(`
|
|
300
300
|
`),rest:n.slice(a+1).join(`
|
|
301
301
|
`)}}function wQ(e){return e.includes("```question")&&xQ(e).some(e=>e.kind===`question`)}var TQ=/^\s*(?:[-*+]\s+)?([A-Z]|\d+)[.)]\s+\S/,EQ=/^\s*recommendation\b/i;function DQ(e){return e.trim().replace(/^[-*+]\s+/,``)}function OQ(e){return DQ(e).match(/^([A-Za-z]|\d+)[.)]/)?.[1].toUpperCase()??``}function kQ(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 AQ=e=>e===`A`||e===`1`,jQ=/(^|[^a-z])recommended([^a-z]|$)/i;function MQ(e){return e.replace(/\s{2,}/g,` `).trim()}function NQ(e){if(!jQ.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:MQ(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:MQ(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:MQ(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=MQ((i[1]??``)+e.slice(i[0].length));if(t)return{label:t,recommended:!0}}return{label:e,recommended:!1}}function PQ(e,t,n=!1){let r=e.split(`
|
|
302
|
-
`).map(e=>e.replace(/\r$/,``)),i=e=>r.findIndex((t,n)=>n>e&&TQ.test(t)),a=e=>{let t=[];for(let n=e;n<r.length;n++){if(TQ.test(r[n])){t.push(n);continue}if(t.length===0||r[n].trim()===``)continue;if(EQ.test(r[n]))break;let e=i(n);if(e===-1||!kQ(OQ(r[t[t.length-1]]),OQ(r[e])))break}return t},o=e=>{for(let t=e.length-1;t>0;t--)if(!kQ(OQ(r[e[t-1]]),OQ(r[e[t]])))return AQ(OQ(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:[],
|
|
302
|
+
`).map(e=>e.replace(/\r$/,``)),i=e=>r.findIndex((t,n)=>n>e&&TQ.test(t)),a=e=>{let t=[];for(let n=e;n<r.length;n++){if(TQ.test(r[n])){t.push(n);continue}if(t.length===0||r[n].trim()===``)continue;if(EQ.test(r[n]))break;let e=i(n);if(e===-1||!kQ(OQ(r[t[t.length-1]]),OQ(r[e])))break}return t},o=e=>{for(let t=e.length-1;t>0;t--)if(!kQ(OQ(r[e[t-1]]),OQ(r[e[t]])))return AQ(OQ(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:[],recommendedIdxs:[]};let c=s[0],l=s[s.length-1],u=[],d=[],f,p=[];for(let[e,n]of s.entries()){let{label:i,recommended:a,note:o}=NQ(DQ(r[n]));a&&(t===`multi`||d.length===0)&&(d.length===0&&(f=o),d.push(u.length)),u.push(i);let c=e===0?[]:r.slice(s[e-1]+1,n).filter(e=>e.trim());p.push(c.length?c.join(`
|
|
303
303
|
`):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(`
|
|
304
304
|
`),g,_=[];for(let e of r.slice(l+1))g===void 0&&EQ.test(e)?g=e.trim():_.push(e);let v=m(_).join(`
|
|
305
|
-
`)||void 0;
|
|
305
|
+
`)||void 0;if(d.length===0&&g){let e=IQ(g,u);e!==null&&(d=[e],f=g)}return{kind:t,danger:n,contextMd:h,options:u,recommendedIdxs:d,recommendedNote:f,recommendation:g,trailingMd:v,...p.some(Boolean)?{optionHeadings:p}:{}}}var FQ=/^[*_`~\s]+/;function IQ(e,t){if(!e)return null;let n=e.replace(/^\s*recommendation\s*:?\s*/i,``).replace(FQ,``).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(FQ,``).match(/^([A-Za-z]|\d+)[.)]/);return t?t[1].toUpperCase()===r:!1});return i===-1?null:i}function LQ(e){return`${e+1}.`}function RQ(e){let t=e.match(/^\s*([A-Za-z]{1,2}|\d+)[.)]\s+/);return t?{id:t[1].toUpperCase(),rest:e.slice(t[0].length)}:{rest:e}}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:[]}:Uu(e)}function UQ(e){let t=[],n=Kl(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-attention`},risk:{border:`border-border-strong`,head:`text-danger`},danger:{border:`border-danger-fill/45`,head:`text-danger`}},XQ=`card-icon-offset`;function ZQ({icon:e,className:t}){let n=(0,L.useRef)(null);return(0,L.useLayoutEffect)(()=>{let e=n.current;if(!e||typeof e.getBBox!=`function`)return;let t=e.getBBox(),r=e.viewBox.baseVal;if(!r||r.width===0||t.width===0)return;let i=e.getBoundingClientRect().width/r.width,a=(Number(e.getAttribute(`stroke-width`))||0)/2;e.style.marginLeft=`${-Math.max(0,t.x-a-r.x)*i}px`,e.style.marginRight=`${-Math.max(0,r.x+r.width-(t.x+t.width)-a)*i}px`},[e]),(0,R.jsx)(e,{ref:n,"aria-hidden":`true`,size:16,className:`shrink-0 ${XQ} ${t}`})}function QQ({icon:e,label:t,head:n=YQ.neutral.head,aside:r}){return(0,R.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[e&&(0,R.jsx)(ZQ,{icon:e,className:n}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 text-[16px] font-semibold leading-6 tracking-tight ${n}`,children:t}),r&&(0,R.jsx)(`span`,{className:`shrink-0 leading-6`,children:r})]})}var $Q=`inline-flex shrink-0 items-center gap-1 rounded-full bg-fg/[0.08] py-0.5 pl-[7px] pr-2 text-[11px] font-medium leading-4 text-fg/85`;function e$({icon:e,children:t}){return(0,R.jsxs)(`span`,{"data-card-chip":!0,className:$Q,children:[e&&(0,R.jsx)(e,{"aria-hidden":`true`,size:12,className:`shrink-0`}),t]})}function t$({icon:e,chip:t,label:n,head:r,aside:i,ruled:a}){let o=n!=null&&n!==!1;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(e$,{icon:e,children:t}),i&&(0,R.jsx)(`span`,{className:`ml-auto shrink-0`,children:i})]}),o&&(0,R.jsx)(`div`,{"data-card-title":!0,className:`mt-1.5 min-w-0 text-[16px] font-semibold leading-6 tracking-tight ${r}`,children:n})]}),a&&(0,R.jsx)(`div`,{"aria-hidden":!0,"data-card-rule":!0,className:`-mx-4 border-t border-border ${o?`mt-3.5`:`mt-[17px]`}`})]})}function n$({children:e,ruled:t=!1}){return(0,R.jsx)(`div`,{className:`card-md ${t?`mt-3`:`mt-1`} min-w-0 text-fg/75`,children:e})}function r$({tone:e=`neutral`,icon:t,chip:n,label:r,aside:i,children:a,className:o=``,surface:s=`inset`,...c}){let{border:l,head:u}=YQ[e];return(0,R.jsxs)(`div`,{...c,className:`min-w-0 ${KQ} border ${s===`question`?`border-question-border bg-question`:`${l} bg-panel-2`} p-4 ${o}`,children:[n==null?(0,R.jsx)(QQ,{icon:t,label:r,head:u,aside:i}):(0,R.jsx)(t$,{icon:t,chip:n,label:r,head:u,aside:i,ruled:a!=null}),a!=null&&(0,R.jsx)(n$,{ruled:n!=null,children:a})]})}var i$=`block min-w-0 text-[13px] leading-5 text-fg/75`;function a$({children:e,className:t=``,...n}){return(0,R.jsx)(`div`,{...n,"data-card-actions":!0,className:`-mx-4 -mb-4 mt-3 flex flex-wrap items-center justify-start gap-x-2.5 gap-y-2 border-t border-border bg-fg/[0.03] px-4 py-2.5 ${JQ} ${t}`,children:e})}var o$=`min-w-0 flex-1 text-[11px] leading-snug text-muted-70`,s$=`text-accent underline underline-offset-2 decoration-accent/40 hover:decoration-accent`,c$=`flex shrink-0 items-center gap-1 rounded-md text-[11px] font-medium outline-none transition-colors focus-visible:ring-1 focus-visible:ring-focus-ink-60 bg-fg px-2.5 py-1 text-bg hover:opacity-90`;function l$(e,t,n){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||(n??(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`)||wQ(t))}function u$({thread:e}){return e.crashed===!0?(0,R.jsx)(r$,{"data-rested-card":`stalled`,icon:ov,label:`Stalled`,children:(0,R.jsx)(`p`,{className:i$,children:`The agent's process exited mid-turn. Retry, in the header, re-sends the last message.`})}):(0,R.jsx)(r$,{"data-rested-card":`bare`,icon:c_,label:`Rested without a sign-off`,children:(0,R.jsx)(`p`,{className:i$,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 d$(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 f$({error:e}){return(0,R.jsxs)(r$,{"data-codex-error":e.code??`unknown`,tone:e.retrying?`caution`:`danger`,icon:ov,label:e.retrying?`Codex retrying`:`Codex request failed`,children:[e.code&&(0,R.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75 font-mono [overflow-wrap:anywhere]`,children:e.code}),(0,R.jsx)(`p`,{className:`${i$} whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.message}),e.details&&(0,R.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75 whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.details})]})}var p$=/^(\d+)\.\s+(.*)$/;function m$(e,t){let n=t.startsWith(` `)?t.slice(2):t;e.answer=e.answer?`${e.answer}\n${n}`:n}function h$(e){if(!e)return null;let t=e.replace(/\r\n?/g,`
|
|
306
306
|
`).split(`
|
|
307
307
|
`),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(p$);if(i)r.push({n:Number(i[1]),answer:i[2]});else if(r.length>0)m$(r[r.length-1],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 g$=Xd,_$=RegExp(`^(\\d+)\\.\\s+(⤷\\s+)?[“"]`),v$=/[”"]\s+→\s+/;function y$(e){if(!e)return null;let t=e.replace(/\r\n?/g,`
|
|
308
308
|
`).split(`
|
|
309
309
|
`),n=0;for(;n<t.length&&!t[n].trim();)n++;if(n>=t.length||t[n].trim()!==g$)return null;n++;let r=[],i=null,a=(e,t,n)=>{let i={n:e.n,answer:n},a=t.trim();a&&(i.question=a),e.followUp&&(i.followUp=!0),r.push(i)};for(;n<t.length;n++){let e=t[n];if(i){if(_$.test(e))return null;let t=e.match(v$);t?(a(i,[...i.lines,e.slice(0,t.index)].join(`
|
|
310
310
|
`),e.slice(t.index+t[0].length)),i=null):i.lines.push(e);continue}let o=e.match(_$);if(o){let t=e.slice(o[0].length),n={n:Number(o[1]),followUp:!!o[2],lines:[]},r=t.match(v$);r?a(n,t.slice(0,r.index),t.slice(r.index+r[0].length)):i={...n,lines:[t]}}else if(r.length>0)m$(r[r.length-1],e);else if(e.trim())return null}if(i||r.length===0)return null;for(let e of r)e.answer=e.answer.replace(/\s+$/,``);return r}function b$(e){return y$(e)??h$(e)}function x$(e){return e.filter(e=>e.answer!==$d).map(e=>qd(e.answer)?{...e,answer:Jd}:e)}function S$(e){let t=e.split(`
|
|
311
311
|
`),n=[];for(;n.length<t.length&&t[n.length].startsWith(`- [x] `);)n.push(t[n.length].slice(Qd.length));return n.length===0?{picks:n,note:e}:{picks:n,note:t.slice(n.length).join(`
|
|
312
|
-
`).trim()}}var C$=e=>e.displayText??e.text;function w$(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`?!1:b$(C$(e))!==null}var T$=e=>`${e.question??``}${e.answer}`;function E$(e,t){let n=t?b$(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 b$(C$(t))??[])r.add(T$(e));if(r.size===0)return n;let i=n.filter(e=>!r.has(T$(e)));return i.length>0?i:null}function D$(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=xQ(t.text).filter(e=>e.kind===`question`);if(r.length>0)return r}return null}var O$=e=>e.kind===`question`?PQ(e.text,e.questionKind,e.danger).contextMd.trim():``;function k$(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=PQ(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 A$(e,t){let n=e[t];if(!n||n.role!==`user`||n.kind===`event`)return null;let r=C$(n),i=y$(r);if(i)return i;let a=h$(r),o=D$(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=O$(o[e.n-1]);return t?{...e,question:t}:{...e}}):o?k$(r,o):null}function j$(e){return e.map((t,n)=>A$(e,n))}function M$(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function N$(e,t){for(let n=t+1;n<e.length;n++)if(M$(e[n]))return n-1;return e.length-1}function P$(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(!M$(r))continue;let i=r.at?Date.parse(r.at):NaN;if(!(!Number.isFinite(i)||i<=n))return t-1}return r}function F$(e){let t=new Map;return e.forEach((e,n)=>{if(!(e.role!==`assistant`||!e.text||!e.text.includes("```awaiting"))){for(let r of UQ(e.text))if(!(r.kind!==`fence`||r.fenceKind!==`awaiting`))for(let e of Ku(r.hints))t.set(e,n)}}),t}function I$(e,t,n={}){let r=new Map,i=n.claims===!1||t.length===0?void 0:F$(e);for(let n of t){let t=P$(e,n.askedAt),a=n.id?i?.get(n.id.toLowerCase()):void 0;a!==void 0&&a>t&&(t=N$(e,a));let o=r.get(t);o?o.push(n):r.set(t,[n])}return r}function L$(e,t){for(let n=t;n>=0;n--)if(R$(e[n]))return n+1;return 0}function R$(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function z$(e,t){let n=new Map;for(let[r,i]of I$(e,t,{claims:!1}))for(let t=L$(e,r);t<e.length;t++){if(R$(e[t]))continue;let r=n.get(t);r?r.push(...i):n.set(t,[...i])}return n}var B$=12;function V$(e){return e.replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[*_~`]/g,``).replace(/\s+/g,` `).trim().toLowerCase()}function H$(e){let t=e.indexOf(`?`);return t===-1?void 0:e.slice(0,t+1)}function U$(e,t){if(t.length===0)return!1;let n=V$(PQ(e,`question`).contextMd);if(n.length<B$)return!1;let r=H$(n);return t.some(({spec:e})=>{let t=V$(e.question);if(t.length<B$)return!1;if(n.includes(t)||t.startsWith(n))return!0;let i=H$(t);return i!==void 0&&i.length>=B$&&n.includes(i)?!0:r!==void 0&&r.length>=B$&&t.includes(r)})}function W$(e,t){if(t.length===0||!e.includes("```question"))return!1;let n=xQ(e).filter(e=>e.kind===`question`);return n.length>0&&n.every(e=>e.kind===`question`&&G$(e,t)!==void 0)}function G$(e,t){return e.registeredId?t.find(t=>t.id.toLowerCase()===e.registeredId):t.find(t=>U$(e.text,[t]))}function K$(e){return e.includes("```question")?xQ(e).flatMap(e=>e.kind===`question`&&e.registeredId&&e.text.trim()===``?[e.registeredId]:[]):[]}function q$(e,t){let n=new Map,r=new Set;if(t.length===0)return{placed:n,placedIds:r};let i=new Map,a=t=>{let n=i.get(t);if(n===void 0){let r=e[t];n=r.role===`assistant`&&r.text?K$(r.text):[],i.set(t,n)}return n};for(let[i,o]of I$(e,t))for(let t of o){let o=t.id.toLowerCase(),s=-1;for(let t=L$(e,i);t<e.length;t++)R$(e[t])||a(t).includes(o)&&(s=t);if(s<0)continue;let c=n.get(s);c?c.push(t):n.set(s,[t]),r.add(t.id)}return{placed:n,placedIds:r}}function J$(e,t){if(t.length===0)return!1;let n=e.length-1;for(let r of I$(e,t).keys())if(r>=n)return!0;let r=L$(e,n);for(let n of q$(e,t).placed.keys())if(n>=r)return!0;return!1}function Y$(e,t){if(t<=0)return e;let n=new Map,r=new Set;for(let[i,a]of e.placed)if(!(i<t)){n.set(i,a);for(let e of a)r.add(e.id)}return{placed:n,placedIds:r}}function X$(e,t){let n=new Set;for(let r of t.placed.keys())n.add(N$(e,r));return n}function Z$(e,t){for(let n=0;n<e.length;n++){let r=e[n].at?Date.parse(e[n].at):NaN;if(Number.isFinite(r)&&r>t)return n}return e.length}function Q$(e,t){let n=t;for(;n>0&&e[n].kind===`event`;)n--;return n}function $$(e,t){let n=new Map,r=new Map;if(t.length===0||e.length===0)return{placed:n,anchored:r};let i=new Map;for(let e of t){let t=e.pending?`pending`:e.settledAt,n=i.get(t);n?n.push(e):i.set(t,[e])}let a=(e,t,n)=>{let r=e.get(t);r?r.push(...n):e.set(t,[...n])};for(let[t,o]of i){let i=t===`pending`?1/0:Date.parse(t),s=Number.isFinite(i)?Z$(e,i):e.length;if(s===0)continue;let c=e.slice(0,s),l=q$(c,o);for(let[e,t]of l.placed)a(n,e,t);let u=o.filter(e=>!l.placedIds.has(e.id));for(let[e,t]of I$(c,u))e<0||a(r,Q$(c,e),t)}let o=(e,t)=>Date.parse(e.askedAt)-Date.parse(t.askedAt);for(let e of n.values())e.sort(o);for(let e of r.values())e.sort(o);return{placed:n,anchored:r}}function e1({h:e=14}){return(0,R.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0`,style:{height:e}})}function t1({icon:e,children:t,sourceId:n,ariaLabel:r,marker:i,at:a,onClick:o,ariaExpanded:s,ariaControls:c}){let l=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`h-px flex-1 bg-border/70 transition-colors group-hover/wake:bg-border`}),(0,R.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,R.jsx)(e,{"aria-hidden":`true`,size:12,className:r1}),t,(0,R.jsx)(n1,{at:a})]}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`h-px flex-1 bg-border/70 transition-colors group-hover/wake:bg-border`})]});return o?(0,R.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-focus-ink-60`,children:l}):(0,R.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 n1({at:e}){let t=
|
|
312
|
+
`).trim()}}var C$=e=>e.displayText??e.text;function w$(e){return e.role!==`user`||e.kind===`event`||e.kind===`reasoning`?!1:b$(C$(e))!==null}var T$=e=>`${e.question??``}${e.answer}`;function E$(e,t){let n=t?b$(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 b$(C$(t))??[])r.add(T$(e));if(r.size===0)return n;let i=n.filter(e=>!r.has(T$(e)));return i.length>0?i:null}function D$(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=xQ(t.text).filter(e=>e.kind===`question`);if(r.length>0)return r}return null}var O$=e=>e.kind===`question`?PQ(e.text,e.questionKind,e.danger).contextMd.trim():``;function k$(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=PQ(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 A$(e,t){let n=e[t];if(!n||n.role!==`user`||n.kind===`event`)return null;let r=C$(n),i=y$(r);if(i)return i;let a=h$(r),o=D$(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=O$(o[e.n-1]);return t?{...e,question:t}:{...e}}):o?k$(r,o):null}function j$(e){return e.map((t,n)=>A$(e,n))}function M$(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function N$(e,t){for(let n=t+1;n<e.length;n++)if(M$(e[n]))return n-1;return e.length-1}function P$(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(!M$(r))continue;let i=r.at?Date.parse(r.at):NaN;if(!(!Number.isFinite(i)||i<=n))return t-1}return r}function F$(e){let t=new Map;return e.forEach((e,n)=>{if(!(e.role!==`assistant`||!e.text||!e.text.includes("```awaiting"))){for(let r of UQ(e.text))if(!(r.kind!==`fence`||r.fenceKind!==`awaiting`))for(let e of Ku(r.hints))t.set(e,n)}}),t}function I$(e,t,n={}){let r=new Map,i=n.claims===!1||t.length===0?void 0:F$(e);for(let n of t){let t=P$(e,n.askedAt),a=n.id?i?.get(n.id.toLowerCase()):void 0;a!==void 0&&a>t&&(t=N$(e,a));let o=r.get(t);o?o.push(n):r.set(t,[n])}return r}function L$(e,t){for(let n=t;n>=0;n--)if(R$(e[n]))return n+1;return 0}function R$(e){return e.role===`user`&&e.kind!==`event`&&e.kind!==`reasoning`}function z$(e,t){let n=new Map;for(let[r,i]of I$(e,t,{claims:!1}))for(let t=L$(e,r);t<e.length;t++){if(R$(e[t]))continue;let r=n.get(t);r?r.push(...i):n.set(t,[...i])}return n}var B$=12;function V$(e){return e.replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/[*_~`]/g,``).replace(/\s+/g,` `).trim().toLowerCase()}function H$(e){let t=e.indexOf(`?`);return t===-1?void 0:e.slice(0,t+1)}function U$(e,t){if(t.length===0)return!1;let n=V$(PQ(e,`question`).contextMd);if(n.length<B$)return!1;let r=H$(n);return t.some(({spec:e})=>{let t=V$(e.question);if(t.length<B$)return!1;if(n.includes(t)||t.startsWith(n))return!0;let i=H$(t);return i!==void 0&&i.length>=B$&&n.includes(i)?!0:r!==void 0&&r.length>=B$&&t.includes(r)})}function W$(e,t){if(t.length===0||!e.includes("```question"))return!1;let n=xQ(e).filter(e=>e.kind===`question`);return n.length>0&&n.every(e=>e.kind===`question`&&G$(e,t)!==void 0)}function G$(e,t){return e.registeredId?t.find(t=>t.id.toLowerCase()===e.registeredId):t.find(t=>U$(e.text,[t]))}function K$(e){return e.includes("```question")?xQ(e).flatMap(e=>e.kind===`question`&&e.registeredId&&e.text.trim()===``?[e.registeredId]:[]):[]}function q$(e,t){let n=new Map,r=new Set;if(t.length===0)return{placed:n,placedIds:r};let i=new Map,a=t=>{let n=i.get(t);if(n===void 0){let r=e[t];n=r.role===`assistant`&&r.text?K$(r.text):[],i.set(t,n)}return n};for(let[i,o]of I$(e,t))for(let t of o){let o=t.id.toLowerCase(),s=-1;for(let t=L$(e,i);t<e.length;t++)R$(e[t])||a(t).includes(o)&&(s=t);if(s<0)continue;let c=n.get(s);c?c.push(t):n.set(s,[t]),r.add(t.id)}return{placed:n,placedIds:r}}function J$(e,t){if(t.length===0)return!1;let n=e.length-1;for(let r of I$(e,t).keys())if(r>=n)return!0;let r=L$(e,n);for(let n of q$(e,t).placed.keys())if(n>=r)return!0;return!1}function Y$(e,t){if(t<=0)return e;let n=new Map,r=new Set;for(let[i,a]of e.placed)if(!(i<t)){n.set(i,a);for(let e of a)r.add(e.id)}return{placed:n,placedIds:r}}function X$(e,t){let n=new Set;for(let r of t.placed.keys())n.add(N$(e,r));return n}function Z$(e,t){for(let n=0;n<e.length;n++){let r=e[n].at?Date.parse(e[n].at):NaN;if(Number.isFinite(r)&&r>t)return n}return e.length}function Q$(e,t){let n=t;for(;n>0&&e[n].kind===`event`;)n--;return n}function $$(e,t){let n=new Map,r=new Map;if(t.length===0||e.length===0)return{placed:n,anchored:r};let i=new Map;for(let e of t){let t=e.pending?`pending`:e.settledAt,n=i.get(t);n?n.push(e):i.set(t,[e])}let a=(e,t,n)=>{let r=e.get(t);r?r.push(...n):e.set(t,[...n])};for(let[t,o]of i){let i=t===`pending`?1/0:Date.parse(t),s=Number.isFinite(i)?Z$(e,i):e.length;if(s===0)continue;let c=e.slice(0,s),l=q$(c,o);for(let[e,t]of l.placed)a(n,e,t);let u=o.filter(e=>!l.placedIds.has(e.id));for(let[e,t]of I$(c,u))e<0||a(r,Q$(c,e),t)}let o=(e,t)=>Date.parse(e.askedAt)-Date.parse(t.askedAt);for(let e of n.values())e.sort(o);for(let e of r.values())e.sort(o);return{placed:n,anchored:r}}function e1({h:e=14}){return(0,R.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0`,style:{height:e}})}function t1({icon:e,children:t,sourceId:n,ariaLabel:r,marker:i,at:a,onClick:o,ariaExpanded:s,ariaControls:c}){let l=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`h-px flex-1 bg-border/70 transition-colors group-hover/wake:bg-border`}),(0,R.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,R.jsx)(e,{"aria-hidden":`true`,size:12,className:r1}),t,(0,R.jsx)(n1,{at:a})]}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`h-px flex-1 bg-border/70 transition-colors group-hover/wake:bg-border`})]});return o?(0,R.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-focus-ink-60`,children:l}):(0,R.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 n1({at:e}){let t=DO(e,LO());return t?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,R.jsx)(`span`,{title:OO(e)??void 0,className:`shrink-0 tabular-nums`,children:t})]}):null}var r1=`shrink-0 translate-y-[0.04em]`;function i1(e,t,n){return e===1?n?`New ${t} from @${n}`:`New ${t}`:`${e} new items`}var a1=`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-focus-ink-60`;function o1({steer:e,text:t,sourceId:n,at:r,wrap:i}){let a=hd(t);if(a)return(0,R.jsx)(m1,{wake:a,sourceId:n,at:r});let o=bd(t);if(o)return(0,R.jsx)(c1,{wake:o,sourceId:n});let s=wd(t);if(s)return(0,R.jsx)(f1,{window:s.window,sourceId:n,at:r});let c=Sd(t);if(c)return(0,R.jsx)(p1,{capped:c.capped,to:c.to,sourceId:n,at:r});let l=Od(t);if(l)return(0,R.jsx)(u1,{wake:l,sourceId:n,at:r});let u=Ad(t);if(u)return(0,R.jsx)(d1,{watchRef:u.ref,sourceId:n,at:r});let d=tf(t);if(d)return(0,R.jsx)(l1,{count:d.count,sourceId:n,at:r});let f=lp(t),p=sp(t),m=e??np(f||p?t.split(`
|
|
313
313
|
`).filter(e=>!lp(e)&&!sp(e)).join(`
|
|
314
314
|
`):t);return!m&&!f&&!p?(0,R.jsx)(`div`,{"data-frizz-msg":n,"data-frizz-wake":!0,className:`min-w-0 max-w-[85%]`,children:(0,R.jsx)(r$,{icon:Zg,label:`Frizz`,children:(0,R.jsx)(s1,{text:Bf(t),wrap:i})})}):f||p?(0,R.jsxs)(`div`,{"data-frizz-wake":!0,className:`flex flex-col`,children:[f&&(0,R.jsx)(h1,{wake:f,sourceId:n,at:r}),p&&(0,R.jsxs)(R.Fragment,{children:[f&&(0,R.jsx)(e1,{}),(0,R.jsx)(g1,{wake:p,sourceId:f?void 0:n,at:r})]}),m&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(e1,{}),(0,R.jsx)(_1,{steer:m,text:t,at:r})]})]}):(0,R.jsx)(_1,{steer:m,text:t,sourceId:n,at:r})}function s1({text:e,wrap:t}){let n=rZ(SX(e));return(0,R.jsx)(`div`,{className:`md-body [overflow-wrap:anywhere]${t?` ${GQ}`:``}`,dangerouslySetInnerHTML:n})}function c1({wake:e,sourceId:t}){let[n,r]=(0,L.useState)(!1),i=(0,L.useId)();return(0,R.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,R.jsxs)(t1,{icon:Jg,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,R.jsx)(`span`,{className:`shrink-0`,children:`Timer`}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,R.jsx)(`span`,{className:`shrink-0`,children:n?`Click to collapse`:`Click to expand`})]}),n&&(0,R.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 l1({count:e,sourceId:t,at:n}){let r=`${e} question${e===1?``:`s`} cancelled — the worker decides ${e===1?`it`:`them`} itself`;return(0,R.jsx)(t1,{icon:N_,sourceId:t,marker:`event`,ariaLabel:r,at:n,children:(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function u1({wake:e,sourceId:t,at:n}){let[r,i]=(0,L.useState)(!1),a=(0,L.useId)(),o=e.kind===`expired`?`Wait expired — nothing resolved`:`Wait over — its work finished`;return e.items.length?(0,R.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,R.jsxs)(t1,{icon:D_,marker:`event`,at:n,onClick:()=>i(e=>!e),ariaExpanded:r,ariaControls:a,ariaLabel:`${r?`Collapse`:`Expand`} what this wait named`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:o}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,R.jsx)(`span`,{className:`shrink-0`,children:r?`Click to collapse`:`Click to expand`})]}),r&&(0,R.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(`
|
|
315
315
|
`)})]}):(0,R.jsx)(t1,{icon:D_,sourceId:t,marker:`event`,ariaLabel:o,at:n,children:(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:o})})}function d1({watchRef:e,sourceId:t,at:n}){let r=AW(e);return(0,R.jsx)(t1,{icon:E_,sourceId:t,marker:`event`,ariaLabel:`Watcher on ${e} expired`,at:n,children:(0,R.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`Watcher on`,` `,r?(0,R.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer`,className:a1,children:e}):e,` `,`expired`]})})}function f1({window:e,sourceId:t,at:n}){let r=`${e===`weekly`?`Weekly usage limit`:e===`session`?`Session usage limit`:`Usage limit`} reset — resuming`;return(0,R.jsx)(t1,{icon:D_,sourceId:t,marker:`limit-resume`,ariaLabel:r,at:n,children:(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function p1({capped:e,to:t,sourceId:n,at:r}){let i=`${e} limit — switched to ${t}`;return(0,R.jsx)(t1,{icon:D_,sourceId:n,marker:`limit-model-switch`,ariaLabel:i,at:r,children:(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:i})})}function m1({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,R.jsx)(t1,{icon:rv,sourceId:t,marker:`event`,ariaLabel:r,at:n,children:(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:r})})}function h1({wake:e,sourceId:t,at:n}){let r=AW(e.ref),i=r?(0,R.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:a1,children:e.ref}):(0,R.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,R.jsxs)(t1,{icon:E_,sourceId:t,marker:`github`,at:n,ariaLabel:r?void 0:`${o}${e.ref}${s}${c?` · ${c}`:``}`,children:[(0,R.jsxs)(`span`,{className:`min-w-0 truncate`,children:[o,i,s]}),c&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,R.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:c})]})]})}function g1({wake:e,sourceId:t,at:n}){let r=AW(e.ref),i=r?(0,R.jsx)(`a`,{href:r,target:`_blank`,rel:`noreferrer noopener`,className:a1,children:e.ref}):(0,R.jsx)(`span`,{children:e.ref});return(0,R.jsx)(t1,{icon:E_,sourceId:t,marker:`github`,at:n,ariaLabel:r?void 0:`PR updated on ${e.ref}: ${e.detail}`,children:(0,R.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`PR updated on `,i,`: ${e.detail}`]})})}function _1({steer:e,text:t,sourceId:n,at:r}){let i=AW(e.ref),a=e.items.length+e.omitted,o=Xf(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`:i1(a,e.items[0]?.label??`item`,s?.actor),u=c?(0,R.jsx)(`a`,{href:c,target:`_blank`,rel:`noreferrer noopener`,className:a1,children:e.ref}):(0,R.jsx)(`span`,{children:e.ref});return(0,R.jsx)(t1,{icon:E_,sourceId:n,marker:`github`,at:s?.at??r,ariaLabel:c?void 0:`${l} on ${e.ref}`,children:(0,R.jsxs)(`span`,{className:`min-w-0 truncate`,children:[l,` on `,u]})})}function v1({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,R.jsx)(t1,{icon:ev,sourceId:t,marker:`rest`,ariaLabel:e,at:n,children:e})}let i=r?`Goal${e.every?` · every ${e.every}`:``}`:`Goal · at rest`;return(0,R.jsx)(t1,{icon:r?av:Y_,sourceId:t,marker:r?`schedule`:`rest`,ariaLabel:i,at:n,children:i})}var y1=/(^|[^\w/.@-])(https?:\/\/[^\s<>`]+|www\.[a-z0-9-]+(?:\.[a-z0-9-]+)+(?:[^\s<>`]*)?)/gi,b1=new Set([`.`,`,`,`:`,`;`,`!`,`?`,`*`,`_`,`~`,`'`,`"`]),x1={")":`(`,"]":`[`,"}":`{`};function S1(e){let t=e;for(;;){let e=t[t.length-1];if(e!==void 0&&b1.has(e)){t=t.slice(0,-1);continue}let n=e===void 0?void 0:x1[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 C1(e,t){if(t===``)return;let n=0;for(let r of Tm(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:bm(r.href)}),n=r.start+r.text.length;n<t.length&&e.push({kind:`text`,text:t.slice(n)})}function w1(e){let t=[],n=0;y1.lastIndex=0;for(let r=y1.exec(e);r;r=y1.exec(e)){let[,i,a]=r,o=S1(a);if(/^https?:\/\/$/i.test(o)||o===``)continue;let s=r.index+i.length;y1.lastIndex=s+o.length;let c=/^www\./i.test(o)?`http://${o}`:o;s>n&&C1(t,e.slice(n,s)),t.push({kind:`link`,text:o,href:c,ghRef:bm(c)}),n=s+o.length}return n<e.length&&C1(t,e.slice(n)),t}function T1({text:e}){let t=(0,L.useMemo)(()=>w1(e),[e,bX()]),n=(0,L.useMemo)(()=>t.flatMap(e=>e.kind===`link`&&e.ghRef?[e.ghRef]:[]),[t]);return(0,L.useEffect)(()=>{n.length>0&&eh(n)},[n]),(0,R.jsx)(R.Fragment,{children:t.map((e,t)=>e.kind===`text`?e.text:(0,R.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 E1({answers:e,queued:t,sourceId:n}){return(0,R.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,R.jsxs)(`div`,{className:`w-full min-w-0 ${KQ} rounded-br-sm border border-border-strong bg-elevated p-4`,children:[(0,R.jsx)(QQ,{icon:gee,label:`Answers`}),(0,R.jsx)(n$,{children:(0,R.jsx)(`div`,{className:`flex flex-col gap-2.5`,children:x$(e).map((e,t)=>(0,R.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,R.jsx)(`div`,{title:e.question,className:`line-clamp-2 min-w-0 [overflow-wrap:anywhere] text-[11px] leading-snug text-muted`,children:e.question}),(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[!e.question&&(0,R.jsx)(`span`,{className:`mt-1.5 shrink-0 text-[10px] uppercase tabular-nums tracking-wide text-muted-70`,children:e.n}),(0,R.jsx)(O1,{answer:e.answer})]})]},t))})})]})})}var D1=`min-w-0 [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`;function O1({answer:e}){let{picks:t,note:n}=S$(e);return t.length===0?(0,R.jsx)(`span`,{className:`${D1} flex-1 whitespace-pre-wrap`,children:(0,R.jsx)(T1,{text:e})}):(0,R.jsxs)(`div`,{className:`${D1} flex flex-1 flex-col`,children:[(0,R.jsx)(`ul`,{className:`flex flex-col gap-1`,children:t.map((e,t)=>(0,R.jsxs)(`li`,{className:`flex items-baseline gap-2`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`mt-px flex h-3.5 w-3.5 shrink-0 self-start items-center justify-center rounded-[3px] border border-control-strong text-fg`,children:(0,R.jsx)(e_,{size:10,strokeWidth:3})}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1`,children:(0,R.jsx)(T1,{text:e})})]},t))}),n&&(0,R.jsx)(`div`,{className:`mt-1.5 whitespace-pre-wrap border-t border-border pt-1.5`,children:(0,R.jsx)(T1,{text:n})})]})}function k1(e){return e.sourceId??`legacy-${z1(e.text)}`}function A1(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 j1=e=>xQ(e).filter(e=>e.kind===`question`).map(e=>e.kind===`question`?PQ(e.text,e.questionKind,e.danger):PQ(``,`question`));function M1(){let e=new Set;return(t,n)=>{let r=k1(t);return e.has(r)&&(r=`${r}#${n}`),e.add(r),r}}function N1(e){let t=A1(e),n=M1(),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=j1(a.text);o.length>0&&r.push({idx:i,identity:n(a,i),blocks:o,isLive:i===t})}return r}function P1(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())&&j1(n.text).length>0)return t}}return-1}function F1(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}. ${Zd(t)}`).join(`
|
|
316
316
|
`)}`:`${Xd}\n${t.map((e,t)=>`${t+1}. “${e.question}” → ${Zd(e.answer)}`).join(`
|
|
317
317
|
`)}`}function I1(e,t,n,r={}){let i=OW(e),[a,o]=(0,L.useState)({}),s=(0,L.useMemo)(()=>N1(t),[t]),c=(0,L.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,L.useMemo)(()=>P1(t)!==-1,[t]),u=wH(),d=TH(e),f=(0,L.useCallback)((t,n)=>CH.answer(u,e,d,t,n),[u,e,d]),p=(0,L.useMemo)(()=>s.flatMap(e=>e.blocks.map((t,n)=>f(e.identity,n))),[s,f]),m=DH(p),h=(0,L.useRef)(n);h.current=n;let g=(0,L.useRef)(r.onSendFailed);g.current=r.onSendFailed;let _=(0,L.useCallback)((e,t)=>({...a[`${e}::${t}`]??{chosen:null,text:``},text:m.get(f(e,t))??``}),[a,m,f]),v=(0,L.useMemo)(()=>{let e=new Map;for(let t of s)e.set(t.identity,t);return e},[s]),y=(0,L.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,L.useCallback)((e,t,n)=>{let r=v.get(e)?.blocks[t];bH.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,L.useCallback)((e,t={})=>{i.submit(e,{...t,scrollToBottom:S,onRollback:e=>{t.onRollback?.(e),g.current?.()}})&&h.current?.()},[i,S]),w=(0,L.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:R1(t),answer:c(e,n)})).filter(e=>e.answer!==``));if(l.length===0)return;let u=n.find(e=>e.isLive),d=F1({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,bH.get(e)]);C(d,{onOptimistic:()=>{r.forEach(e=>bH.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&&!bH.get(e)&&bH.set(e,t)})}})},[a,s,_,C,p,f]),T=(0,L.useCallback)(e=>{let t=v.get(k1(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,L.useMemo)(()=>c?T(c):void 0,[c,T]),answeringForMessage:T,answerable:l,anyAnswered:x,sending:i.pending,sendAnswers:w,sendMessage:C}}function L1(e){let t=e.split(`
|
|
318
|
-
`).map(e=>e.trim()).find(e=>e.length>0)??``;return t.length>120?`${t.slice(0,117)}…`:t}function R1(e){return L1(e.contextMd)||L1(e.options.join(` / `))||`earlier question`}function z1(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 B1({raw:e,question:t,questionKind:n,danger:r,interactive:i,wrap:a,aside:o,label:s,settled:c}){let l=(0,L.useMemo)(()=>t??PQ(e??``,n??`question`,r),[t,e,n,r]),u=SX(l.contextMd),d=SX(l.trailingMd??``),f=l.
|
|
318
|
+
`).map(e=>e.trim()).find(e=>e.length>0)??``;return t.length>120?`${t.slice(0,117)}…`:t}function R1(e){return L1(e.contextMd)||L1(e.options.join(` / `))||`earlier question`}function z1(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 B1({raw:e,question:t,questionKind:n,danger:r,interactive:i,wrap:a,aside:o,label:s,settled:c}){let l=(0,L.useMemo)(()=>t??PQ(e??``,n??`question`,r),[t,e,n,r]),u=SX(l.contextMd),d=SX(l.trailingMd??``),f=l.recommendedIdxs,p=wX(l.recommendation??``),m=l.kind===`multi`,h=l.danger,g=i?.answer.chosen??null,_=i?.answer.chosenSet??[],v=i?.answer.text??``,y=(0,L.useRef)(null),b=(0,L.useRef)(null);(0,L.useLayoutEffect)(()=>{let e=y.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`)},[v]);let x=(0,L.useRef)({interactive:i,isMulti:m,chosen:g,chosenSet:_,freetext:v,count:l.options.length});x.current={interactive:i,isMulti:m,chosen:g,chosenSet:_,freetext:v,count:l.options.length};let S=!!i;(0,L.useEffect)(()=>{let e=b.current;if(!(!e||!S))return ene(e,{press:e=>{let t=x.current;return!t.interactive||t.count===0?!1:e===t.count+1&&y.current?(y.current.focus(),`text`):e>t.count?!1:(t.interactive.onChip(e-1,l.options[e-1]??``),t.isMulti?`toggled`:`picked`)},keyed:()=>x.current.count>0,row:t=>{let n=x.current;return!n.interactive||n.count===0?null:t===n.count+1?y.current?.parentElement??null:t<=n.count?e.querySelectorAll(`:scope > [data-question-option]`)[t-1]??null:null},answered:()=>{let e=x.current;return e.isMulti?e.chosenSet.length>0||!!e.freetext.trim():e.chosen!==null||!!e.freetext.trim()}})},[S,l]);let C=h?ov:void 0,w=s??(l.secret?`Secret`:m?`Select multiple`:`Question`);return(0,R.jsxs)(r$,{tone:h?`risk`:`neutral`,surface:`question`,icon:C,label:w,aside:o,children:[u&&(0,R.jsx)(`div`,{className:`text-fg`,children:(0,R.jsx)(uQ,{className:`md-body${a?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:u})}),(l.options.length>0||i)&&(0,R.jsxs)(`div`,{ref:b,tabIndex:-1,onKeyDown:e=>{!i||e.target!==e.currentTarget||gz({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())},"data-question-grid":!0,className:`group/qgrid mt-2 grid grid-cols-1 gap-1.5 outline-none`,children:[l.options.map((e,t)=>(0,R.jsxs)(L.Fragment,{children:[l.optionHeadings?.[t]&&(0,R.jsx)(V1,{md:l.optionHeadings[t],wrap:a}),(0,R.jsx)(H1,{label:e,index:t,bodyMd:l.optionBodies?.[t],wrap:a,multi:m,recommended:f.includes(t),recTitle:f[0]===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,R.jsxs)(`div`,{className:`relative col-span-full${l.options.length>0?` flex items-baseline`:``}`,children:[l.options.length>0&&(0,R.jsx)(`span`,{className:`pointer-events-none relative z-10 ml-[13px] -mr-[29px] flex`,children:(0,R.jsx)(W1,{n:l.options.length+1,live:!0})}),l.secret?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`input`,{type:`password`,"data-secret-answer":!0,"data-surface":`questionAnswer`,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,"aria-label":`Secret value`,value:v,onChange:e=>i.onText(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){e.preventDefault(),b.current?.focus();return}e.key===`Enter`&&!e.nativeEvent.isComposing&&(e.preventDefault(),i.onSubmit())},placeholder:`Paste the value…`,className:`block w-full rounded-md border py-1.5 pl-3 pr-3 text-[12px] leading-snug text-fg/90 outline-none placeholder:text-muted-80 transition-colors ${v.trim()?`border-selection-border bg-selection`:`border-border bg-transparent hover:bg-panel-2 focus:border-accent`}`}),(0,R.jsx)(`div`,{className:`mt-1.5 max-w-[60%] text-[11px] leading-snug text-muted-70`,children:`Held in memory on the machine running Frizz and handed to one command, once. The worker never sees it.`})]}):(0,R.jsx)(`textarea`,{ref:y,"data-1p-ignore":!0,rows:1,"data-surface":`questionAnswer`,value:v,onChange:e=>i.onText(e.target.value),onKeyDown:e=>{if(e.stopPropagation(),e.key===`Escape`){e.preventDefault(),b.current?.focus();return}gz({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?`Something else…`:`Type your answer…`,className:`block w-full min-w-0 flex-1 resize-none overflow-hidden rounded-md border py-1.5 pr-3 ${l.options.length>0?U1:`pl-3`} text-[12px] leading-snug text-fg/90 outline-none placeholder:text-muted-80 transition-colors ${v.trim()&&(m||g===null)?`border-selection-border bg-selection`:`border-border bg-transparent hover:bg-panel-2 focus:border-accent`}`})]})]}),c?.text&&(0,R.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:l.secret?`••••••••••••`:c.text}),c&&c.chosenIdxs.length===0&&!c.text&&(0,R.jsx)(`div`,{className:`mt-2 text-[11px] text-muted-70`,children:`Not answered`}),l.trailingMd&&(0,R.jsx)(`div`,{"data-question-note":!0,className:`mt-2 text-muted-70`,children:(0,R.jsx)(uQ,{className:`md-body${a?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:d})}),l.recommendation&&f.length===0&&(0,R.jsx)(uQ,{className:`md-inline mt-1.5 text-[11px] text-muted-70`,html:p})]})}function V1({md:e,wrap:t}){let n=wX(e.split(`
|
|
319
319
|
`).join(` `));return(0,R.jsx)(`div`,{className:`mt-1 text-fg`,children:(0,R.jsx)(uQ,{className:`md-body${t?` ${GQ}`:``}`,html:n})})}function H1({label:e,index:t,bodyMd:n,wrap:r,selected:i,settledPick:a,disabled:o,multi:s,recommended:c,recTitle:l,onClick:u}){let{id:d,rest:f}=RQ(e),p=wX(f),m=o&&d&&/^\d+$/.test(d)?Number(d):t+1,h=SX(n??``),g=(0,L.useId)();return(0,R.jsxs)(`div`,{"data-question-option":!0,title:l,onClick:e=>{o||e.target.closest(`a, button, img[data-local-path], .local-file-action, .local-file-code`)||window.getSelection()?.toString()||u()},className:`relative flex items-baseline gap-2 rounded-md border px-3 py-1.5 text-[12px] leading-snug transition-colors ${i?`border-selection-border bg-selection text-fg`:a?`border-border-strong border-l-2 border-l-accent/40 bg-bg/50 pl-[11px] text-fg`:o?`border-border text-muted-80`:`border-border text-fg/90 hover:bg-elevated hover:border-border-strong`}`,children:[(0,R.jsx)(`button`,{type:`button`,disabled:o,"aria-labelledby":g,"aria-keyshortcuts":o||m>9?void 0:String(m),onClick:u,onMouseDown:e=>e.preventDefault(),className:`absolute inset-0 rounded-md outline-none`}),(0,R.jsx)(W1,{n:m,live:!o,selected:i}),s&&(0,R.jsx)(`span`,{"aria-hidden":!0,className:`mt-px flex h-3.5 w-3.5 shrink-0 self-start items-center justify-center rounded-[3px] border ${i?`border-accent bg-accent-fill text-on-accent`:a?`border-control-strong text-fg`:`border-control-strong`}`,children:(i||a)&&(0,R.jsx)(e_,{size:10,strokeWidth:3})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`div`,{id:g,children:[c&&(0,R.jsx)(`span`,{className:`pointer-events-none float-right ml-2 mt-px rounded-full border border-border-strong px-1.5 py-px text-[9.5px] leading-none uppercase tracking-wide text-muted`,children:`Recommended`}),(0,R.jsx)(uQ,{as:`span`,className:`md-inline`,html:p})]}),n!==void 0&&(0,R.jsx)(uQ,{className:`md-body mt-1.5 opacity-90${r?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:h})]})]})}var U1=`pl-9`;function W1({n:e,live:t,selected:n=!1}){return!t||e>9?(0,R.jsxs)(`span`,{"aria-hidden":!0,className:`w-4 shrink-0 text-center text-[11px] tabular-nums text-muted`,children:[e,`.`]}):(0,R.jsx)(`span`,{"aria-hidden":!0,className:`pointer-events-none flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-b-2 text-[10.5px] font-medium leading-none tabular-nums transition-colors ${n?`border-accent bg-accent-fill text-on-accent`:`border-border-strong bg-panel text-muted group-focus-visible/qgrid:border-control-strong group-focus-visible/qgrid:text-fg`} pointer-coarse:border-transparent pointer-coarse:bg-transparent pointer-coarse:font-normal ${n?`pointer-coarse:text-fg`:`pointer-coarse:text-muted`}`,children:e})}function G1({blocks:e,answering:t,onClose:n}){let[r,i]=(0,L.useState)(0),[a,o]=(0,L.useState)(!1);(0,L.useEffect)(()=>{let e=requestAnimationFrame(()=>o(!0));return()=>cancelAnimationFrame(e)},[]),(0,L.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,Tn.createPortal)((0,R.jsxs)(`div`,{"data-mobile-answer-sheet":!0,className:`fixed inset-0 z-[80] flex flex-col justify-end`,children:[(0,R.jsx)(`button`,{"aria-label":`Close`,onClick:n,className:`absolute inset-0 bg-scrim-50 transition-opacity duration-200 ${a?`opacity-100`:`opacity-0`}`}),(0,R.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_var(--sheet-shadow)] transition-transform duration-200 ease-out motion-reduce:transition-none ${a?`translate-y-0`:`translate-y-full`}`,children:[(0,R.jsx)(`div`,{className:`mx-auto mt-[6px] h-[5px] w-[36px] shrink-0 rounded-full bg-muted/35`}),(0,R.jsxs)(`div`,{className:`flex h-[48px] shrink-0 items-center gap-2 border-b border-border/70 px-3`,children:[(0,R.jsx)(`button`,{onClick:n,className:`flex h-[44px] items-center px-2 text-[16px] text-fg/85`,children:`Cancel`}),(0,R.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,R.jsx)(`span`,{className:`flex h-[44px] w-[44px] items-center justify-center`,children:(0,R.jsx)(cv,{size:19,className:`opacity-0`,"aria-hidden":!0})})]}),(0,R.jsx)(`div`,{"data-mobile-answer-body":!0,className:`min-h-0 flex-1 overflow-y-auto px-3 py-3`,children:(0,R.jsx)(B1,{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,R.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,R.jsx)(`div`,{className:`flex items-center gap-1.5`,children:e.map((e,t)=>(0,R.jsx)(`span`,{className:`size-[6px] rounded-full ${t===r?`bg-accent`:`bg-muted/35`}`},e.bi))}):null,(0,R.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[r>0?(0,R.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,R.jsx)(`button`,{onClick:()=>c?l():i(e=>e+1),disabled:c?!t.anyAnswered||t.sending:!1,className:`button-outline flex h-[50px] flex-1 items-center justify-center rounded-[14px] bg-accent-fill px-5 text-[17px] font-semibold text-on-accent transition-[filter,opacity] active:brightness-90 disabled:opacity-40`,children:c?t.sending?`Sending…`:`Send answers`:`Continue`})]})]})]})]}),document.body);function l(){t.onSubmit(),n()}}var K1=(0,L.createContext)(null);function q1(){return(0,L.useContext)(K1)}function J1({questions:e}){let t=q1();return e.length===0?null:(0,R.jsx)(`div`,{"data-compact-questions":!0,className:`min-w-0 overflow-hidden rounded-[12px] border border-border-strong bg-panel pb-2.5 text-[14px] leading-5`,children:e.map((e,n)=>(0,R.jsx)(`div`,{"data-question-id":e.id,className:n>0?`mt-2.5 border-t border-border`:void 0,children:(0,R.jsx)(Y1,{q:e,n:t?.numberOf(e.id)??n+1})},e.id))})}function Y1({q:e,n:t}){let n=SX(e.spec.question),r=e.spec.options??[];return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex gap-2 px-3.5 pb-1 pt-[11px] font-semibold`,children:[(0,R.jsx)(`span`,{className:`shrink-0 tabular-nums text-accent`,children:t}),(0,R.jsx)(uQ,{className:`min-w-0 flex-1 ${X1}`,html:n})]}),r.map((e,t)=>(0,R.jsxs)(`div`,{"data-compact-option":!0,className:`flex gap-2 py-0.5 pl-[30px] pr-3.5 text-muted`,children:[(0,R.jsx)(`span`,{className:`w-3 shrink-0 font-bold tabular-nums`,children:t+1}),(0,R.jsxs)(`span`,{className:`min-w-0`,children:[e.label,e.recommended&&(0,R.jsx)(`span`,{className:`ml-1 text-[11px] font-semibold text-accent`,children:`RECOMMENDED`})]})]},t))]})}var X1=`md-inline break-words [&_p+*]:mt-2 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5 [&_li+li]:mt-1 [&_pre]:overflow-x-auto [&_pre]:text-[0.85em] [&_code]:text-[0.9em] [&_a]:underline`;function Z1({count:e,onAnswer:t,onReply:n}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,"data-phone-answer-reply":!0,onClick:n,"aria-label":`Write a reply instead`,title:`Write a reply instead`,className:`flex size-[42px] shrink-0 items-center justify-center rounded-full border border-border-strong bg-panel text-fg active:bg-hover`,children:(0,R.jsx)(mee,{"aria-hidden":!0,size:19,strokeWidth:1.8})}),(0,R.jsx)(`button`,{type:`button`,"data-phone-answer-open":!0,onClick:t,className:`flex h-[42px] min-w-0 flex-1 items-center justify-center rounded-full bg-fg px-4 text-[15px] font-semibold text-bg active:opacity-90`,children:e>1?`Answer ${e} questions`:`Answer`})]})}function Q1(e,t){let n=t.description?.trim(),r=n&&!n.includes(`
|
|
320
320
|
`)?n:void 0,i=[r?void 0:n,t.preview?.trim()].filter(Boolean).join(`
|
|
321
321
|
|
|
322
|
-
`)||void 0;return{line:`${LQ(e)} ${t.label}${r?` — ${r}`:``}`,...i?{body:i}:{}}}var $1=`root`;function e0(e,t,n){return`${e}/${t}.${n}`}function t0(e){let t=e.options??[],n=t.
|
|
323
|
-
`)?t:void 0}function h0(e,t){let n=e.options??[];if(t.chosen===null&&t.chosenSet.length===0)return``;let r=e=>n[e]?{index:e,label:n[e].label}:null;return JSON.stringify({chosen:t.chosen===null?null:r(t.chosen),chosenSet:t.chosenSet.flatMap(e=>{let t=r(e);return t?[t]:[]})})}function g0(e,t){let n={chosen:null,chosenSet:[]};if(!t)return n;try{let r=JSON.parse(t);if(!r||typeof r!=`object`)return n;let{chosen:i,chosenSet:a}=r;if(!Array.isArray(a))return n;let o=e.options??[],s=e=>{if(!e||typeof e!=`object`)return null;let{index:t,label:n}=e;return typeof t==`number`&&Number.isInteger(t)&&t>=0&&typeof n==`string`&&o[t]?.label===n?t:null},c=new Set(a.map(s).filter(e=>e!==null));return e.kind===`multi`?{chosen:null,chosenSet:o.flatMap((e,t)=>c.has(t)?[t]:[])}:{chosen:s(i),chosenSet:[]}}catch{return n}}function _0(e,t){let[n,...r]=t.split(`/`);if(n!==`root`)return;let i=e;for(let e of r){if(!/^\d+\.\d+$/.test(e))return;let[t,n]=e.split(`.`).map(Number);i=i?.options?.[t]?.followUps?.[n]}return i}function v0(e){let t=e instanceof Error?e.message:`The answer could not be sent.`;return t.length>240?`${t.slice(0,239)}…`:t}var y0=(0,L.createContext)(null);function b0(e){let t=e?.id,n=e?.questions??[],r=wH(),[i,a]=(0,L.useState)(()=>new Map),[o,s]=(0,L.useState)(),c=(0,L.useContext)(B8),l=DH((0,L.useMemo)(()=>t?n.flatMap(e=>e.spec.secret?[]:j0(e).flatMap(n=>[CH.question(r,t,e.id,n),CH.questionPick(r,t,e.id,n)])):[],[r,t,n])),u=(e,n)=>{if(e.spec.secret)return{chosen:null,chosenSet:[],text:i.get(e.id)??``};let a=_0(e.spec,n),o=a?g0(a,t?l.get(CH.questionPick(r,t,e.id,n))??``:``):void 0;return{chosen:o?.chosen??null,chosenSet:o?.chosenSet??[],text:(t?l.get(CH.question(r,t,e.id,n)):void 0)??``}},d=e=>new Map(j0(e).map(t=>[t,u(e,t)])),f=n.flatMap(e=>{let t=a0(e,d(e));return t?[{q:e,answer:t}]:[]}),p=f.map(e=>e.answer),m=qe(),h=pt({mutationFn:async e=>Y.answerQuestions({slug:t,answers:e.answers}),onSuccess:(e,t)=>{for(let n of e.answered){a(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t});for(let e of t.drafts.find(e=>e.id===n)?.keys??[])bH.clear(e)}},onError:e=>{c?.cancel(),t&&dW(t),s(v0(e))},onSettled:()=>{t&&m.invalidateQueries({queryKey:S0(t)})}}),g=pt({mutationFn:async e=>Y.dismissQuestions({slug:t,ids:[e]}),onError:e=>s(v0(e))}),_=()=>{if(!t||p.length===0||h.isPending)return;s(void 0),c?.dismiss(),uW(t);let e=S0(t);m.cancelQueries({queryKey:e});let n=new Date().toISOString(),i=new Set(f.map(e=>e.q.id));m.setQueryData(e,e=>[...(e??[]).filter(e=>!i.has(e.id)),...f.map(({q:e,answer:t})=>({id:e.id,spec:e.spec,askedAt:e.askedAt,settledAt:n,pending:!0,answer:e.spec.secret?{...t,text:`(secret sent)`}:t}))]),h.mutate({answers:p,drafts:f.map(({q:e})=>({id:e.id,keys:e.spec.secret?[]:j0(e).flatMap(n=>[CH.question(r,t,e.id,n),CH.questionPick(r,t,e.id,n)])}))})};return{slug:t,answerFor:u,answersOf:d,onChip:(e,n,i,a)=>{let o=_0(e.spec,n);if(!t||!o||e.spec.secret||!o.options?.[a])return;let s=CH.questionPick(r,t,e.id,n),c=g0(o,bH.get(s)),l=i?{...c,chosenSet:c.chosenSet.includes(a)?c.chosenSet.filter(e=>e!==a):[...c.chosenSet,a]}:{...c,chosen:c.chosen===a?null:a};bH.set(s,h0(o,l))},onText:(e,n,i,o)=>{if(t){if(e.spec.secret){a(t=>t.get(e.id)===o?t:new Map(t).set(e.id,o));return}bH.set(CH.question(r,t,e.id,n),o),i||bH.clear(CH.questionPick(r,t,e.id,n))}},dismiss:e=>g.mutate(e),dismissing:g.isPending,submit:()=>_(),staged:p.length,sending:h.isPending,error:o}}var x0=[],S0=e=>[`settledQuestions`,e];function C0(e){let t=e?.id,n=qe(),r=ct({queryKey:S0(t??``),queryFn:async()=>(await Y.threadSettledQuestions({slug:t})).questions,enabled:!!t,refetchOnWindowFocus:!1}),i=(e?.questions??[]).map(e=>e.id).join(` `),a=(0,L.useRef)(i);return(0,L.useEffect)(()=>{let e=a.current;if(a.current=i,!t||e===i)return;let r=new Set(i.split(` `));e.split(` `).some(e=>e&&!r.has(e))&&n.invalidateQueries({queryKey:S0(t)})},[i,n,t]),r.data??x0}var w0=[];function T0(e,t){let n=e?.questions??w0;if(t.length===0||n.length===0)return n;let r=new Set(t.map(e=>e.id));return n.some(e=>r.has(e.id))?n.filter(e=>!r.has(e.id)):n}function E0({s:e,wrap:t}){let n=(0,L.useMemo)(()=>o0(e.spec,e.answer),[e.spec,e.answer]),r=e=>(0,R.jsx)(B1,{question:e.question,label:e.depth>1?`Follow-up`:e.question.secret?`Secret`:`Question`,settled:e.settled,wrap:t},e.path),i=n.slice(1);return(0,R.jsxs)(`article`,{"data-question-id":e.id,"data-settled-question":!0,"aria-label":`Answered question`,className:`flex min-w-0 flex-col gap-2 opacity-60`,children:[r(n[0]),i.length>0&&(0,R.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:i.map(e=>(0,R.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:r(e)},e.path))})]})}function D0({questions:e,wrap:t,className:n=``}){return e.length===0?null:(0,R.jsx)(`section`,{"data-settled-questions":!0,"aria-label":`${e.length} answered question${e.length===1?``:`s`}`,className:`flex min-w-0 flex-col gap-3 ${n}`,children:e.map(e=>(0,R.jsx)(E0,{s:e,wrap:t},e.id))})}function O0({thread:e,children:t}){let n=b0(e);return(0,R.jsx)(y0.Provider,{value:n,children:t})}function k0({q:e,answering:t}){let n=(0,L.useContext)(y0),r=q1(),i=t??n;if(!i||!i.slug)return null;if(r)return(0,R.jsx)(J1,{questions:[e]});let a=r0(e.spec,i.answersOf(e)),o=t=>(0,R.jsx)(B1,{question:t.question,label:t.depth>1?`Follow-up`:void 0,aside:t.depth===1&&!e.spec.danger?(0,R.jsx)(`button`,{type:`button`,"data-dismiss-question":!0,"aria-label":`Dismiss this question`,title:`Dismiss — the worker decides it itself`,disabled:i.dismissing,onClick:()=>i.dismiss(e.id),className:`icon-hover-outline 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,R.jsx)(cv,{size:16})}):void 0,interactive:{answer:i.answerFor(e,t.path),onChip:n=>i.onChip(e,t.path,t.spec.kind===`multi`,n),onText:n=>i.onText(e,t.path,t.spec.kind===`multi`,n),onSubmit:i.submit}},t.path),s=a.slice(1);return(0,R.jsxs)(`article`,{"data-question-id":e.id,className:`flex min-w-0 flex-col gap-2`,children:[o(a[0]),s.length>0&&(0,R.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:s.map(e=>(0,R.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:o(e)},e.path))})]})}function A0({thread:e,questions:t,inFlight:n=null,showSend:r=!1,className:i=``}){let a=e?.id,o=t??e?.questions??[],s=(0,L.useContext)(y0),c=b0(s?void 0:e),l=s??c,u=q1();return!a||o.length===0&&(!r||u)?!a||!n?.length?null:(0,R.jsx)(`section`,{"data-answers-in-flight":!0,"aria-label":`Your answer, on its way to the worker`,className:`flex min-w-0 flex-col items-end ${i}`,children:(0,R.jsx)(E1,{answers:n,queued:!0})}):u?(0,R.jsxs)(`section`,{"data-registered-questions":!0,"aria-label":`${o.length} question${o.length===1?``:`s`} waiting for an answer`,className:`flex min-w-0 flex-col gap-3 ${i}`,children:[(0,R.jsx)(J1,{questions:o}),l.error&&(0,R.jsx)(`div`,{role:`alert`,className:`break-words text-[13px] leading-snug text-danger-soft`,children:l.error}),l.sending&&(0,R.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[13px] leading-snug text-muted`,children:`Sending…`})]}):(0,R.jsxs)(`section`,{"data-registered-questions":!0,"aria-label":o.length>0?`${o.length} question${o.length===1?``:`s`} waiting for an answer`:`Send the answers above`,className:`flex min-w-0 flex-col gap-3 ${i}`,children:[o.map(e=>(0,R.jsx)(k0,{q:e,answering:l},e.id)),l.error&&(0,R.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-danger-soft`,children:l.error}),l.sending&&(0,R.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[11px] leading-snug text-muted`,children:`Sending…`}),(0,R.jsx)(`div`,{className:`flex justify-start`,children:(0,R.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:l.staged===0||l.sending,onClick:l.submit,onMouseDown:e=>e.preventDefault(),className:`button-outline 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 j0(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,$1),t}function M0({questions:e,onClose:t}){let n=(0,L.useContext)(y0),r=kg(t),i=n?c0(e,n.answersOf):[],[a,o]=(0,L.useState)(()=>n?d0(i,n.answersOf):null),[s,c]=(0,L.useState)(!1),l=e.length===0;if((0,L.useEffect)(()=>{l&&r()},[l,r]),!n||!n.slug||l)return null;let u=a===null?-1:i.findIndex(e=>e.key===a),d=u===-1?void 0:i[u],f=e=>{c(!1),o(e)},p=d?u:i.length,m=(0,R.jsx)(`span`,{"aria-hidden":!0,className:`flex gap-[5px]`,children:Array.from({length:i.length+1},(e,t)=>(0,R.jsx)(`i`,{className:`size-[6px] rounded-full ${t<=p?`bg-fg`:`bg-border-strong`}`},t))});return(0,R.jsxs)(dq,{title:d?`Question ${u+1} of ${i.length}`:`Review your answers`,onRequestClose:()=>r(),dataAttr:`data-answer-sheet`,footer:d?(0,R.jsx)(B0,{a:n,step:d,first:u===0,writing:s,onBack:()=>f(i[u-1]?.key??d.key),onNext:()=>f(u0(i,d.key))}):(0,R.jsx)(H0,{a:n,onSent:()=>r()}),children:[(0,R.jsxs)(`div`,{"data-answer-step":d?d.key:`review`,className:`flex items-center gap-2 px-[18px] pb-1 text-[12.5px] text-muted`,children:[m,(0,R.jsxs)(`span`,{children:[d?`Question ${u+1} of ${i.length}`:`Review`,d&&d.depth>1&&` · follow-up`,d?.spec.danger&&(0,R.jsx)(`span`,{className:`text-danger-soft`,children:` · destructive`})]})]}),d?(0,R.jsx)(N0,{a:n,step:d,writing:s,onWrite:()=>c(!0),onPick:t=>{let r=l0(e,n.answersOf,d,t);n.answerFor(d.q,d.path).chosen!==t&&n.onChip(d.q,d.path,!1,t),f(r)}},d.key):(0,R.jsx)(V0,{a:n,steps:i,onChange:e=>f(e)})]})}function N0({a:e,step:t,writing:n,onWrite:r,onPick:i}){let a=SX(t.spec.question),o=e.answerFor(t.q,t.path),s=t.spec.options??[],c=t.spec.kind===`multi`,l=s.length===0||n||!c&&o.chosen===null&&o.text.trim()!==``;return(0,R.jsxs)(`div`,{"data-answer-question":!0,children:[(0,R.jsx)(uQ,{className:`px-[18px] pb-3 pt-1 text-[17px] font-semibold leading-[23px] text-fg ${X1}`,html:a}),s.length>0&&(0,R.jsxs)(`div`,{role:c?`group`:`radiogroup`,className:`border-b border-border`,children:[s.map((n,r)=>(0,R.jsx)(F0,{option:n,multi:c,on:c?(o.chosenSet??[]).includes(r):o.chosen===r,onClick:()=>c?e.onChip(t.q,t.path,!0,r):i(r)},r)),!l&&(0,R.jsxs)(`button`,{type:`button`,"data-answer-write":!0,onClick:r,className:`${P0} text-left`,children:[(0,R.jsx)(L0,{multi:c,on:!1,dashed:!0}),(0,R.jsx)(`span`,{className:`text-[15.5px] font-medium leading-[21px] text-muted`,children:c?`Add a note…`:`Write a different answer…`})]})]}),l&&t.spec.secret&&(0,R.jsx)(z0,{a:e,step:t,text:o.text}),l&&!t.spec.secret&&(0,R.jsx)(R0,{a:e,step:t,autoFocus:n,placeholder:s.length===0?`Type your answer…`:c?`Add a note…`:`Write a different answer…`})]})}var P0=`flex w-full items-start gap-3 border-t border-border px-[18px] py-3 outline-none active:bg-hover focus-visible:bg-hover`;function F0({option:e,multi:t,on:n,onClick:r}){let i=m0(e.description),a=[i?void 0:e.description?.trim(),e.preview?.trim()].filter(Boolean).join(`
|
|
322
|
+
`)||void 0;return{line:`${LQ(e)} ${t.label}${r?` — ${r}`:``}`,...i?{body:i}:{}}}var $1=`root`;function e0(e,t,n){return`${e}/${t}.${n}`}function t0(e){let t=e.options??[],n=t.map((e,t)=>Q1(t,e));return{question:{kind:e.kind,danger:e.danger===!0,...e.secret?{secret:!0}:{},contextMd:e.question,options:n.map(e=>e.line),recommendedIdxs:t.flatMap((e,t)=>e.recommended?[t]:[]),...n.some(e=>e.body)?{optionBodies:n.map(e=>e.body)}:{}},optionLabels:t.map(e=>e.label)}}function n0(e,t){return!t||e.kind===`multi`?null:t.chosen}function r0(e,t){let n=[],r=(e,i,a)=>{let{question:o,optionLabels:s}=t0(e);n.push({path:i,spec:e,question:o,optionLabels:s,depth:a});let c=n0(e,t.get(i));c!==null&&(e.options?.[c]?.followUps??[]).forEach((e,t)=>r(e,e0(i,c,t),a+1))};return r(e,$1,1),n}function i0(e,t){return t?t.text.trim()?!0:e.kind===`multi`?(t.chosenSet??[]).length>0:t.chosen!==null:!1}function a0(e,t){if(!i0(e.spec,t.get(`root`)))return;let n=(r,i)=>{let a=t.get(i),o=(r.options??[]).map(e=>e.label),s=n0(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,e0(i,s,t)));return{questionId:e.id,question:r.question,chosen:c,...l?{text:l}:{},...u.length>0?{followUps:u}:{}}};return n(e.spec,$1)}function o0(e,t){let n=[],r=(e,t,i,a)=>{let o=e.options??[],{question:s}=t0(e),c=[],l=[];for(let e of t.chosen){let t=o.findIndex(t=>t.label===e);t===-1?l.push(e):c.includes(t)||c.push(t)}c.sort((e,t)=>e-t);let u=[l.join(`, `),t.text?.trim()].filter(Boolean).join(` — `)||void 0;if(n.push({path:i,question:{...s,options:c.map(e=>s.options[e]),recommendedIdxs:c.flatMap((e,t)=>s.recommendedIdxs.includes(e)?[t]:[]),...s.optionBodies?{optionBodies:c.map(e=>s.optionBodies[e])}:{}},settled:{chosenIdxs:c.map((e,t)=>t),...u?{text:u}:{}},depth:a}),e.kind===`multi`||c.length!==1)return;let d=c[0];(o[d]?.followUps??[]).forEach((e,n)=>{let o=t.followUps?.[n];o&&r(e,o,e0(i,d,n),a+1)})};return r(e,t,$1,1),n}var s0=(e,t)=>`${e}|${t}`;function c0(e,t){return e.flatMap(e=>r0(e.spec,t(e)).map(t=>({key:s0(e.id,t.path),q:e,path:t.path,spec:t.spec,depth:t.depth})))}function l0(e,t,n,r){return u0(c0(e,e=>{let i=t(e);if(e.id!==n.q.id)return i;let a=i.get(n.path)??{chosen:null,chosenSet:[],text:``};return new Map(i).set(n.path,{...a,chosen:r})}),n.key)}function u0(e,t){let n=e.findIndex(e=>e.key===t);return n===-1?null:e[n+1]?.key??null}function d0(e,t){return e.find(e=>!i0(e.spec,t(e.q).get(e.path)))?.key??null}var f0=`••••••••`;function p0(e,t){if(!t||!i0(e,t))return null;if(e.secret)return f0;let n=(e.options??[]).map(e=>e.label),r=t.text.trim();return e.kind===`multi`?[(t.chosenSet??[]).slice().sort((e,t)=>e-t).flatMap(e=>n[e]===void 0?[]:[n[e]]).join(`, `),r].filter(Boolean).join(` — `):t.chosen!==null&&n[t.chosen]!==void 0?n[t.chosen]:r||null}function m0(e){let t=e?.trim();return t&&!t.includes(`
|
|
323
|
+
`)?t:void 0}function h0(e,t){let n=e.options??[];if(t.chosen===null&&t.chosenSet.length===0)return``;let r=e=>n[e]?{index:e,label:n[e].label}:null;return JSON.stringify({chosen:t.chosen===null?null:r(t.chosen),chosenSet:t.chosenSet.flatMap(e=>{let t=r(e);return t?[t]:[]})})}function g0(e,t){let n={chosen:null,chosenSet:[]};if(!t)return n;try{let r=JSON.parse(t);if(!r||typeof r!=`object`)return n;let{chosen:i,chosenSet:a}=r;if(!Array.isArray(a))return n;let o=e.options??[],s=e=>{if(!e||typeof e!=`object`)return null;let{index:t,label:n}=e;return typeof t==`number`&&Number.isInteger(t)&&t>=0&&typeof n==`string`&&o[t]?.label===n?t:null},c=new Set(a.map(s).filter(e=>e!==null));return e.kind===`multi`?{chosen:null,chosenSet:o.flatMap((e,t)=>c.has(t)?[t]:[])}:{chosen:s(i),chosenSet:[]}}catch{return n}}function _0(e,t){let[n,...r]=t.split(`/`);if(n!==`root`)return;let i=e;for(let e of r){if(!/^\d+\.\d+$/.test(e))return;let[t,n]=e.split(`.`).map(Number);i=i?.options?.[t]?.followUps?.[n]}return i}function v0(e){let t=e instanceof Error?e.message:`The answer could not be sent.`;return t.length>240?`${t.slice(0,239)}…`:t}var y0=(0,L.createContext)(null);function b0(e){let t=e?.id,n=e?.questions??[],r=wH(),[i,a]=(0,L.useState)(()=>new Map),[o,s]=(0,L.useState)(),c=(0,L.useContext)(H8),l=DH((0,L.useMemo)(()=>t?n.flatMap(e=>e.spec.secret?[]:j0(e).flatMap(n=>[CH.question(r,t,e.id,n),CH.questionPick(r,t,e.id,n)])):[],[r,t,n])),u=(e,n)=>{if(e.spec.secret)return{chosen:null,chosenSet:[],text:i.get(e.id)??``};let a=_0(e.spec,n),o=a?g0(a,t?l.get(CH.questionPick(r,t,e.id,n))??``:``):void 0;return{chosen:o?.chosen??null,chosenSet:o?.chosenSet??[],text:(t?l.get(CH.question(r,t,e.id,n)):void 0)??``}},d=e=>new Map(j0(e).map(t=>[t,u(e,t)])),f=n.flatMap(e=>{let t=a0(e,d(e));return t?[{q:e,answer:t}]:[]}),p=f.map(e=>e.answer),m=qe(),h=pt({mutationFn:async e=>Y.answerQuestions({slug:t,answers:e.answers}),onSuccess:(e,t)=>{for(let n of e.answered){a(e=>{if(!e.has(n))return e;let t=new Map(e);return t.delete(n),t});for(let e of t.drafts.find(e=>e.id===n)?.keys??[])bH.clear(e)}},onError:e=>{c?.cancel(),t&&dW(t),s(v0(e))},onSettled:()=>{t&&m.invalidateQueries({queryKey:S0(t)})}}),g=pt({mutationFn:async e=>Y.dismissQuestions({slug:t,ids:[e]}),onError:e=>s(v0(e))}),_=()=>{if(!t||p.length===0||h.isPending)return;s(void 0),c?.dismiss(),uW(t);let e=S0(t);m.cancelQueries({queryKey:e});let n=new Date().toISOString(),i=new Set(f.map(e=>e.q.id));m.setQueryData(e,e=>[...(e??[]).filter(e=>!i.has(e.id)),...f.map(({q:e,answer:t})=>({id:e.id,spec:e.spec,askedAt:e.askedAt,settledAt:n,pending:!0,answer:e.spec.secret?{...t,text:`(secret sent)`}:t}))]),h.mutate({answers:p,drafts:f.map(({q:e})=>({id:e.id,keys:e.spec.secret?[]:j0(e).flatMap(n=>[CH.question(r,t,e.id,n),CH.questionPick(r,t,e.id,n)])}))})};return{slug:t,answerFor:u,answersOf:d,onChip:(e,n,i,a)=>{let o=_0(e.spec,n);if(!t||!o||e.spec.secret||!o.options?.[a])return;let s=CH.questionPick(r,t,e.id,n),c=g0(o,bH.get(s)),l=i?{...c,chosenSet:c.chosenSet.includes(a)?c.chosenSet.filter(e=>e!==a):[...c.chosenSet,a]}:{...c,chosen:c.chosen===a?null:a};bH.set(s,h0(o,l))},onText:(e,n,i,o)=>{if(t){if(e.spec.secret){a(t=>t.get(e.id)===o?t:new Map(t).set(e.id,o));return}bH.set(CH.question(r,t,e.id,n),o),i||bH.clear(CH.questionPick(r,t,e.id,n))}},dismiss:e=>g.mutate(e),dismissing:g.isPending,submit:()=>_(),staged:p.length,sending:h.isPending,error:o}}var x0=[],S0=e=>[`settledQuestions`,e];function C0(e){let t=e?.id,n=qe(),r=ct({queryKey:S0(t??``),queryFn:async()=>(await Y.threadSettledQuestions({slug:t})).questions,enabled:!!t,refetchOnWindowFocus:!1}),i=(e?.questions??[]).map(e=>e.id).join(` `),a=(0,L.useRef)(i);return(0,L.useEffect)(()=>{let e=a.current;if(a.current=i,!t||e===i)return;let r=new Set(i.split(` `));e.split(` `).some(e=>e&&!r.has(e))&&n.invalidateQueries({queryKey:S0(t)})},[i,n,t]),r.data??x0}var w0=[];function T0(e,t){let n=e?.questions??w0;if(t.length===0||n.length===0)return n;let r=new Set(t.map(e=>e.id));return n.some(e=>r.has(e.id))?n.filter(e=>!r.has(e.id)):n}function E0({s:e,wrap:t}){let n=(0,L.useMemo)(()=>o0(e.spec,e.answer),[e.spec,e.answer]),r=e=>(0,R.jsx)(B1,{question:e.question,label:e.depth>1?`Follow-up`:e.question.secret?`Secret`:`Question`,settled:e.settled,wrap:t},e.path),i=n.slice(1);return(0,R.jsxs)(`article`,{"data-question-id":e.id,"data-settled-question":!0,"aria-label":`Answered question`,className:`flex min-w-0 flex-col gap-2 opacity-60`,children:[r(n[0]),i.length>0&&(0,R.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:i.map(e=>(0,R.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:r(e)},e.path))})]})}function D0({questions:e,wrap:t,className:n=``}){return e.length===0?null:(0,R.jsx)(`section`,{"data-settled-questions":!0,"aria-label":`${e.length} answered question${e.length===1?``:`s`}`,className:`flex min-w-0 flex-col gap-3 ${n}`,children:e.map(e=>(0,R.jsx)(E0,{s:e,wrap:t},e.id))})}function O0({thread:e,children:t}){let n=b0(e);return(0,R.jsx)(y0.Provider,{value:n,children:t})}function k0({q:e,answering:t}){let n=(0,L.useContext)(y0),r=q1(),i=t??n;if(!i||!i.slug)return null;if(r)return(0,R.jsx)(J1,{questions:[e]});let a=r0(e.spec,i.answersOf(e)),o=t=>(0,R.jsx)(B1,{question:t.question,label:t.depth>1?`Follow-up`:void 0,aside:t.depth===1&&!e.spec.danger?(0,R.jsx)(`button`,{type:`button`,"data-dismiss-question":!0,"aria-label":`Dismiss this question`,title:`Dismiss — the worker decides it itself`,disabled:i.dismissing,onClick:()=>i.dismiss(e.id),className:`icon-hover-outline 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,R.jsx)(cv,{size:16})}):void 0,interactive:{answer:i.answerFor(e,t.path),onChip:n=>i.onChip(e,t.path,t.spec.kind===`multi`,n),onText:n=>i.onText(e,t.path,t.spec.kind===`multi`,n),onSubmit:i.submit}},t.path),s=a.slice(1);return(0,R.jsxs)(`article`,{"data-question-id":e.id,className:`flex min-w-0 flex-col gap-2`,children:[o(a[0]),s.length>0&&(0,R.jsx)(`div`,{className:`ml-3 flex flex-col gap-2 border-l border-border pl-3`,children:s.map(e=>(0,R.jsx)(`div`,{className:e.depth>2?`ml-3 border-l border-border pl-3`:void 0,children:o(e)},e.path))})]})}function A0({thread:e,questions:t,inFlight:n=null,showSend:r=!1,className:i=``}){let a=e?.id,o=t??e?.questions??[],s=(0,L.useContext)(y0),c=b0(s?void 0:e),l=s??c,u=q1();return!a||o.length===0&&(!r||u)?!a||!n?.length?null:(0,R.jsx)(`section`,{"data-answers-in-flight":!0,"aria-label":`Your answer, on its way to the worker`,className:`flex min-w-0 flex-col items-end ${i}`,children:(0,R.jsx)(E1,{answers:n,queued:!0})}):u?(0,R.jsxs)(`section`,{"data-registered-questions":!0,"aria-label":`${o.length} question${o.length===1?``:`s`} waiting for an answer`,className:`flex min-w-0 flex-col gap-3 ${i}`,children:[(0,R.jsx)(J1,{questions:o}),l.error&&(0,R.jsx)(`div`,{role:`alert`,className:`break-words text-[13px] leading-snug text-danger-soft`,children:l.error}),l.sending&&(0,R.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[13px] leading-snug text-muted`,children:`Sending…`})]}):(0,R.jsxs)(`section`,{"data-registered-questions":!0,"aria-label":o.length>0?`${o.length} question${o.length===1?``:`s`} waiting for an answer`:`Send the answers above`,className:`flex min-w-0 flex-col gap-3 ${i}`,children:[o.map(e=>(0,R.jsx)(k0,{q:e,answering:l},e.id)),l.error&&(0,R.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-danger-soft`,children:l.error}),l.sending&&(0,R.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[11px] leading-snug text-muted`,children:`Sending…`}),(0,R.jsx)(`div`,{className:`flex justify-start`,children:(0,R.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:l.staged===0||l.sending,onClick:l.submit,onMouseDown:e=>e.preventDefault(),className:`button-outline 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 j0(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,$1),t}function M0({questions:e,onClose:t}){let n=(0,L.useContext)(y0),r=kg(t),i=n?c0(e,n.answersOf):[],[a,o]=(0,L.useState)(()=>n?d0(i,n.answersOf):null),[s,c]=(0,L.useState)(!1),l=e.length===0;if((0,L.useEffect)(()=>{l&&r()},[l,r]),!n||!n.slug||l)return null;let u=a===null?-1:i.findIndex(e=>e.key===a),d=u===-1?void 0:i[u],f=e=>{c(!1),o(e)},p=d?u:i.length,m=(0,R.jsx)(`span`,{"aria-hidden":!0,className:`flex gap-[5px]`,children:Array.from({length:i.length+1},(e,t)=>(0,R.jsx)(`i`,{className:`size-[6px] rounded-full ${t<=p?`bg-fg`:`bg-border-strong`}`},t))});return(0,R.jsxs)(dq,{title:d?`Question ${u+1} of ${i.length}`:`Review your answers`,onRequestClose:()=>r(),dataAttr:`data-answer-sheet`,footer:d?(0,R.jsx)(B0,{a:n,step:d,first:u===0,writing:s,onBack:()=>f(i[u-1]?.key??d.key),onNext:()=>f(u0(i,d.key))}):(0,R.jsx)(H0,{a:n,onSent:()=>r()}),children:[(0,R.jsxs)(`div`,{"data-answer-step":d?d.key:`review`,className:`flex items-center gap-2 px-[18px] pb-1 text-[12.5px] text-muted`,children:[m,(0,R.jsxs)(`span`,{children:[d?`Question ${u+1} of ${i.length}`:`Review`,d&&d.depth>1&&` · follow-up`,d?.spec.danger&&(0,R.jsx)(`span`,{className:`text-danger-soft`,children:` · destructive`})]})]}),d?(0,R.jsx)(N0,{a:n,step:d,writing:s,onWrite:()=>c(!0),onPick:t=>{let r=l0(e,n.answersOf,d,t);n.answerFor(d.q,d.path).chosen!==t&&n.onChip(d.q,d.path,!1,t),f(r)}},d.key):(0,R.jsx)(V0,{a:n,steps:i,onChange:e=>f(e)})]})}function N0({a:e,step:t,writing:n,onWrite:r,onPick:i}){let a=SX(t.spec.question),o=e.answerFor(t.q,t.path),s=t.spec.options??[],c=t.spec.kind===`multi`,l=s.length===0||n||!c&&o.chosen===null&&o.text.trim()!==``;return(0,R.jsxs)(`div`,{"data-answer-question":!0,children:[(0,R.jsx)(uQ,{className:`px-[18px] pb-3 pt-1 text-[17px] font-semibold leading-[23px] text-fg ${X1}`,html:a}),s.length>0&&(0,R.jsxs)(`div`,{role:c?`group`:`radiogroup`,className:`border-b border-border`,children:[s.map((n,r)=>(0,R.jsx)(F0,{option:n,multi:c,on:c?(o.chosenSet??[]).includes(r):o.chosen===r,onClick:()=>c?e.onChip(t.q,t.path,!0,r):i(r)},r)),!l&&(0,R.jsxs)(`button`,{type:`button`,"data-answer-write":!0,onClick:r,className:`${P0} text-left`,children:[(0,R.jsx)(L0,{multi:c,on:!1,dashed:!0}),(0,R.jsx)(`span`,{className:`text-[15.5px] font-medium leading-[21px] text-muted`,children:c?`Add a note…`:`Write a different answer…`})]})]}),l&&t.spec.secret&&(0,R.jsx)(z0,{a:e,step:t,text:o.text}),l&&!t.spec.secret&&(0,R.jsx)(R0,{a:e,step:t,autoFocus:n,placeholder:s.length===0?`Type your answer…`:c?`Add a note…`:`Write a different answer…`})]})}var P0=`flex w-full items-start gap-3 border-t border-border px-[18px] py-3 outline-none active:bg-hover focus-visible:bg-hover`;function F0({option:e,multi:t,on:n,onClick:r}){let i=m0(e.description),a=[i?void 0:e.description?.trim(),e.preview?.trim()].filter(Boolean).join(`
|
|
324
324
|
|
|
325
|
-
`);return(0,R.jsxs)(`button`,{type:`button`,role:t?`checkbox`:`radio`,"aria-checked":n,"data-answer-option":!0,"data-on":n||void 0,onClick:e=>{e.target.closest(`[data-lightbox-tile], img[data-local-path]`)||r()},className:`${P0} text-left`,children:[(0,R.jsx)(L0,{multi:t,on:n}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`span`,{className:`block text-[15.5px] font-medium leading-[21px] text-fg`,children:[e.label,e.recommended&&(0,R.jsx)(`span`,{className:`ml-1.5 text-[11px] font-bold tracking-[0.02em] text-accent`,children:`RECOMMENDED`})]}),i&&(0,R.jsx)(`span`,{className:`mt-px block text-[13px] leading-[18px] text-muted`,children:i}),a&&(0,R.jsx)(I0,{md:a})]})]})}function I0({md:e}){return(0,R.jsx)(`div`,{className:`card-md mt-1 text-muted`,children:(0,R.jsx)(uQ,{className:`md-body`,html:SX(e)})})}function L0({multi:e,on:t,dashed:n=!1}){return(0,R.jsx)(`span`,{"aria-hidden":!0,className:`mt-[0.5px] flex size-5 shrink-0 items-center justify-center border-[1.5px] ${e?`rounded-[5px]`:`rounded-full`} ${n?`border-dashed`:``} ${t?e?`border-fg bg-fg text-bg`:`border-fg`:`border-border-strong`}`,children:t&&(e?(0,R.jsx)(e_,{size:14,strokeWidth:3}):(0,R.jsx)(`span`,{className:`size-2.5 rounded-full bg-fg`}))})}function R0({a:e,step:t,autoFocus:n,placeholder:r}){let i=(0,L.useRef)(null),a=e.answerFor(t.q,t.path).text,o=t.spec.kind===`multi`;return(0,L.useLayoutEffect)(()=>{let e=i.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`)},[a]),(0,L.useEffect)(()=>{n&&i.current?.focus()},[n]),(0,R.jsx)(`div`,{className:`px-[18px] ${(t.spec.options??[]).length===0?``:`pt-3`}`,children:(0,R.jsx)(`textarea`,{ref:i,"data-answer-text":!0,"data-1p-ignore":!0,"data-claims-escape":!0,rows:(t.spec.options??[]).length===0?3:1,value:a,placeholder:r,onChange:n=>e.onText(t.q,t.path,o,n.target.value),onFocus:()=>{o||e.onText(t.q,t.path,!1,a)},className:`block max-h-[40vh] w-full resize-none overflow-y-auto rounded-[12px] border border-border-strong bg-bg px-3 py-[11px] text-[16px] leading-[22px] text-fg outline-none placeholder:text-faint focus:border-fg/40`})})}function z0({a:e,step:t,text:n}){return(0,R.jsxs)(`div`,{className:`px-[18px]`,children:[(0,R.jsx)(`input`,{type:`password`,"data-answer-text":!0,"data-secret-answer":!0,"data-claims-escape":!0,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,"aria-label":`Secret value`,value:n,placeholder:`Paste the value…`,onChange:n=>e.onText(t.q,t.path,!1,n.target.value),className:`block w-full rounded-[12px] border border-border-strong bg-bg px-3 py-[11px] text-[16px] leading-[22px] text-fg outline-none placeholder:text-faint focus:border-fg/40`}),(0,R.jsx)(`div`,{className:`mt-2 text-[13px] leading-[18px] text-muted`,children:`Held in memory on the machine running Frizz and handed to one command, once. The worker never sees it.`})]})}function B0({a:e,step:t,first:n,writing:r,onBack:i,onNext:a}){let o=e.answerFor(t.q,t.path),s=i0(t.spec,o),c=t.spec.options??[],l=t.spec.kind!==`multi`&&o.chosen===null&&o.text.trim()!==``,u=t.spec.kind===`multi`||c.length===0||r||l;return(0,R.jsxs)(K0,{children:[(0,R.jsx)(`button`,{type:`button`,"data-answer-back":!0,disabled:n,onClick:i,className:`${U0} ${W0} disabled:opacity-35`,children:`Back`}),(0,R.jsx)(`span`,{className:`flex-1`}),!(u&&s)&&(0,R.jsx)(`button`,{type:`button`,"data-answer-skip":!0,onClick:a,className:`${U0} ${W0}`,children:s?`Next`:`Skip`}),u&&(0,R.jsx)(`button`,{type:`button`,"data-answer-continue":!0,disabled:!s,onClick:a,className:`${U0} ${G0} px-6 disabled:opacity-35`,children:`Continue`})]})}function V0({a:e,steps:t,onChange:n}){let r=t.map(t=>({s:t,said:p0(t.spec,e.answerFor(t.q,t.path))})),i=r.filter(e=>e.said!==null).length;return(0,R.jsxs)(`div`,{"data-answer-review":!0,children:[(0,R.jsx)(`div`,{className:`px-[18px] pb-3 pt-1 text-[17px] font-semibold leading-[23px] text-fg`,children:i===0?`No answers yet`:`${i} answer${i===1?``:`s`}`}),(0,R.jsx)(`div`,{className:`border-b border-border`,children:r.map(({s:e,said:t})=>(0,R.jsxs)(`button`,{type:`button`,"data-answer-change":e.key,onClick:()=>n(e.key),className:`block w-full border-t border-border px-[18px] py-2.5 text-left outline-none active:bg-hover focus-visible:bg-hover`,children:[(0,R.jsx)(`span`,{className:`line-clamp-2 block text-[13px] leading-[18px] text-muted`,children:q0(e.spec.question)}),(0,R.jsxs)(`span`,{className:`mt-0.5 flex items-baseline justify-between gap-2.5`,children:[(0,R.jsx)(`span`,{className:`min-w-0 break-words text-[15.5px] leading-[21px] ${t===null?`text-muted`:`font-medium text-fg`}`,children:t??`Skipped`}),(0,R.jsx)(`span`,{className:`shrink-0 text-[13.5px] text-muted`,children:`Change`})]})]},e.key))})]})}function H0({a:e,onSent:t}){return(0,R.jsx)(K0,{children:(0,R.jsx)(`button`,{type:`button`,"data-answer-send":!0,disabled:e.staged===0||e.sending,onClick:()=>{e.submit(),t()},className:`${U0} ${G0} flex-1 disabled:opacity-35`,children:e.sending?`Sending…`:`Send answers`})})}var U0=`flex h-[46px] shrink-0 items-center justify-center rounded-[12px] text-[15.5px] font-semibold outline-none`,W0=`px-[18px] text-muted active:bg-hover focus-visible:bg-hover`,G0=`bg-fg text-bg active:opacity-90`;function K0({children:e}){let t=(0,L.useRef)(null),[n,r]=(0,L.useState)(!1);(0,L.useEffect)(()=>{let e=0,n=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e=document.activeElement;r((e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement)&&t.current?.parentElement?.contains(e)===!0)})};return n(),document.addEventListener(`focusin`,n),document.addEventListener(`focusout`,n),()=>{cancelAnimationFrame(e),document.removeEventListener(`focusin`,n),document.removeEventListener(`focusout`,n)}},[]);let i=Bz(t,n);return(0,R.jsxs)(`div`,{ref:t,"data-answer-footer":!0,className:`shrink-0`,children:[(0,R.jsx)(`div`,{className:`flex items-center gap-2.5 px-[18px] pt-3.5`,children:e}),i>0&&(0,R.jsx)(`div`,{"aria-hidden":!0,style:{height:i}})]})}function q0(e){return(e.trim().split(/\n\s*\n/)[0]??``).replace(/[`*_~]/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\s+/g,` `).trim()}function J0(e){let t=e?Date.parse(e):NaN;return Number.isFinite(t)?t:null}function Y0(e,t){return new Date(e).toDateString()===new Date(t).toDateString()}function X0(e,t,n){let r=null;return e.map(e=>{let i=J0(t(e)),a=J0(n(e))??i;if(i===null)return null;let o=r===null||!Y0(r,i)?`day`:i-r>=12e5?`time`:null;return r=Math.max(r??0,a??i),o})}function Z0(e,t,n=new Date,r){let i=new Date(Date.parse(e)),a=i.toLocaleTimeString(r,{hour:`numeric`,minute:`2-digit`});if(t===`time`)return{day:null,time:a};let o=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),s=Math.round((o(n)-o(i))/864e5);return{day:s===0?`Today`:s===1?`Yesterday`:s>1&&s<7?i.toLocaleDateString(r,{weekday:`long`}):i.toLocaleDateString(r,i.getFullYear()===n.getFullYear()?{month:`short`,day:`numeric`}:{month:`short`,day:`numeric`,year:`numeric`}),time:a}}function Q0(e){return(0,L.useSyncExternalStore)(e=>pr(X,e),()=>e?$0(e)!==`codex`:!1,()=>!1)}function $0(e){return Cg(X.board,e)?.backend}function e2(e,t,n,r){let i=CH.followUp(e,t,n);return xH(i,r),i}function t2(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 n2(e){let t=qe(),n=wH(),[r,i]=(0,L.useState)(!1);return{unqueue:(0,L.useCallback)(a=>{if(!e||r)return;let o=Cg(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}zE(t,e,a.rawText,a.deliveryId),e2(n,e,o,a.text),t2(a.from)},e=>{i(!1),Z(`Couldn't unqueue — ${(e instanceof Error?e.message:String(e)).slice(0,160)}`)})},[r,n,t,e]),pending:r}}function Lne(e){let t=qe(),n=wH(),[r,i]=(0,L.useState)(!1),a=(0,L.useCallback)(n=>{!e||r||DW(t,e,n.text,{supersedes:n.deliveryId,failureToast:e=>`Retry failed — ${e.slice(0,160)}`})},[r,t,e]),o=(0,L.useCallback)(async t=>{if(!e)return!1;i(!0);try{return await Y.dismissFailedFollowUp({slug:e,deliveryId:t}),!0}catch(e){return Z(`Couldn't dismiss — ${(e instanceof Error?e.message:String(e)).slice(0,160)}`),!1}finally{i(!1)}},[e]);return{retry:a,edit:(0,L.useCallback)(t=>{!e||r||(e2(n,e,Cg(X.board,e)?.sessionId,t.text),t2(t.from),o(t.deliveryId))},[o,r,n,e]),dismiss:(0,L.useCallback)(t=>{!e||r||o(t.deliveryId)},[o,r,e]),pending:r}}var r2=new Map;function i2(e,t){let n=(r2.get(e)??[]).filter(e=>e.deliveryId!==t.deliveryId);n.push(t),r2.set(e,n.slice(-8))}var a2=e=>e.replace(/\s+/g,` `).trim();function o2(e,t){let n=r2.get(e);if(!n?.length)return;let r=a2(t);for(let t=n.length-1;t>=0;t--){let i=a2(n[t].text);if(!i||!r.includes(i))continue;let[a]=n.splice(t,1);return n.length||r2.delete(e),a.deliveryId}}function s2(e){return(0,L.useSyncExternalStore)(e=>pr(X,e),()=>{if(!e)return!1;let t=Cg(X.board,e);return t?.backend!==`codex`&&t?.runtime===`running`},()=>!1)}function c2(e){let[t,n]=(0,L.useState)(!1);return{deliverNow:(0,L.useCallback)(()=>{if(!e||t)return;let r=Cg(X.board,e)?.sessionId;if(!r){Z(`This thread has no live session to interrupt`);return}n(!0),Y.deliverQueuedNow({slug:e,sessionId:r}).then(e=>{n(!1),e.interrupted||Z(e.reason??`That message could not be pushed through`)},e=>{n(!1),Z(`Couldn't push it through — ${(e instanceof Error?e.message:String(e)).slice(0,160)}`)})},[t,e]),pending:t}}function l2(e){return e.project?`${nm(e.project)}/thread/${e.slug}`:am(`/thread/${e.slug}`)}function u2({peer:e,text:t,queued:n,sourceId:r,at:i,wrap:a}){let o=gr(X),[s,c]=(0,L.useState)(!1),l=(0,L.useId)(),u=e.thread,d=u&&!u.project?Cg(o.board,u.slug):void 0,f=d?UD(d):u?.title,p=rZ(SX(t));return(0,R.jsxs)(`div`,{"data-frizz-msg":r,"data-session-message":!0,className:`flex flex-col ${n?`opacity-50`:``}`,children:[(0,R.jsxs)(t1,{icon:I_,marker:`session-message`,at:i,children:[u?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:`Message from`}),(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:`«`}),(0,R.jsx)(`a`,{href:l2(u),"data-session-peer-link":!0,title:`Open the thread that sent this`,onMouseDown:e=>e.preventDefault(),className:`min-w-0 truncate ${a1}`,children:f}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`»`})]})]}):(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name?`Message from session ${e.name}`:`Message from another session`}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,R.jsx)(`button`,{type:`button`,"data-session-message-toggle":!0,onClick:()=>c(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-expanded":s,"aria-controls":l,className:`shrink-0 rounded-sm outline-none transition-colors hover:text-fg focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:s?`Click to collapse`:`Click to expand`})]}),s&&(0,R.jsx)(`div`,{id:l,className:`card-md mt-1.5 border-l border-border/70 pl-3 text-muted`,children:(0,R.jsx)(`div`,{className:`md-body [overflow-wrap:anywhere]${a?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,dangerouslySetInnerHTML:p})})]})}function d2(e){return e.displayText??e.text}function f2(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.sessionPeer)return t}return-1}function p2(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.sessionPeer)&&!(n.wake&&!w$(n)))return t}return 0}var m2=`icon-label-nudge`,h2=`frizz-theme`,g2=`#0d0e10`,_2=`#f7f7f7`,v2=new Set,y2={preference:`system`,resolved:`dark`},b2,x2;function S2(e){return e===`light`||e===`dark`||e===`system`?e:`system`}function C2(e,t=w2()){return e===`system`?t?`dark`:`light`:e}function w2(){try{return b2?.matches??window.matchMedia(`(prefers-color-scheme: dark)`).matches}catch{return!1}}function T2(){try{return S2(localStorage.getItem(h2))}catch{return`system`}}function E2(e){let t=document.documentElement;t.dataset.theme=e.resolved,t.style.colorScheme=e.resolved,document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,e.resolved===`dark`?g2:_2)}function D2(e,t=w2()){let n={preference:e,resolved:C2(e,t)},r=n.preference!==y2.preference||n.resolved!==y2.resolved;if(r&&(y2=n),E2(n),r)for(let e of v2)e()}function O2(){return y2}function k2(e){D2(S2(e));try{localStorage.setItem(h2,y2.preference)}catch{}}function A2(e){return v2.add(e),()=>v2.delete(e)}function j2(){if(x2||typeof window>`u`)return x2;try{b2=window.matchMedia(`(prefers-color-scheme: dark)`)}catch{b2=void 0}D2(T2());let e=e=>{y2.preference===`system`&&D2(`system`,e.matches)};b2?.addEventListener(`change`,e);let t=e=>{try{if(e.storageArea&&e.storageArea!==localStorage)return}catch{return}e.key===`frizz-theme`?D2(S2(e.newValue)):e.key===null&&D2(`system`)};return window.addEventListener(`storage`,t),x2=()=>{b2?.removeEventListener(`change`,e),window.removeEventListener(`storage`,t),x2=void 0,b2=void 0},x2}function M2(e,t,n){return{type:`frizz-inline-vis-theme`,requestId:e,colorScheme:t,vars:n}}function N2(e,t){return typeof e==`object`&&!!e&&e.type===`frizz-inline-vis-applied`&&e.requestId===t}var P2=new Set([`planning`,`planned`,`active`,`needs-human`,`blocked`]);function F2(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&&P2.has(e.status))}var I2=`sticky top-0 z-10 flex min-w-0 shrink-0 items-center gap-2.5 border-b border-border bg-panel px-3 ${dv} 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`,L2=`flex min-w-0 flex-1 items-center gap-2.5 pl-1 max-[640px]:basis-full`,R2=`flex shrink-0 items-center max-[640px]:w-full`;function z2(e){return e?.trim()?{kind:`profile-error`,message:`Profile controls unavailable: ${e.trim().slice(0,160)}`}:null}function B2(e){if(e.foreign)return`Read-only external thread`;if(e.permissionChangePending||e.permissionPending)return`A permission change is already in progress`;if(e.profileChangePending)return`A model and effort change is already in progress`;if(e.runtimeControlPending)return`Another runtime control is already in progress`;if(e.pendingAsk||e.runtime===`perm-prompt`)return`Resolve the current terminal approval or question first`;if(e.backend===`codex`||e.backend===`acp`)return null;let t=[...e.subAgents??[],...e.bgShells??[]].filter(e=>e.state===`running`||e.state===`stale`).length;return t>0?`Wait for ${t} unresolved background operation${t===1?``:`s`}`:e.runtime===`running`||e.runtime===`spawning`?`Wait for the current turn to finish`:null}function V2(e){return e.permissionChangePending===!0||e.permissionPending!==void 0||e.profileChangePending===!0||e.runtimeControlPending===!0}function H2(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 U2(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 W2(e){let t=gr(X).board?.threads.find(t=>t.id===e),n=ct({queryKey:[`threadProfileOptions`,e],queryFn:()=>Y.threadProfileOptions({slug:e}),enabled:!!(t&&!t.foreign&&t.kind===`session`),staleTime:5e3}),r=pt({mutationFn:t=>Y.setThreadProfile({slug:e,model:t.model,...t.effort?{effort:t.effort}:{}})}),i=pt({mutationFn:t=>Y.setThreadPermission({slug:e,permissionMode:t})}),a=pt({mutationFn:t=>Y.upgradeThreadModel({slug:e,sessionId:t})}),o=r.isPending||i.isPending||a.isPending,s=t?.backend===`codex`?`codex`:t?.backend===`acp`?`acp`:`claude`,c=ct({queryKey:[`acpAgents`],queryFn:()=>Y.acpAgents(),enabled:!!t&&s===`acp`});if(!t||t.foreign||t.kind!==`session`)return{busy:o,footer:null,phoneTools:null,status:null};let l=o||V2(t),u=t.model?.trim(),d=t.effort?.trim(),f=s===`acp`?wu(u):void 0,p=s===`acp`?Tu(u):void 0,m=r.isPending?r.variables:void 0,h=t.profilePendingModel??m?.model,g=t.profilePendingEffort??m?.effort,_=s===`acp`&&m?Tu(m.model):void 0,v=n.data?.options??[],{modelSelectable:y}=U2(v,u,d,t.runtime===`exited`),b=n.data!==void 0,x=c.data?.find(e=>e.id===f)?.label??f,S=[{id:s,label:s===`codex`?`Codex`:`Claude Code`,options:v}],C=z2(n.isError?n.error.message:void 0),w=t.permissionMode?LB(t.permissionMode):`auto`,T=PB.some(e=>e.value===w)?w:`auto`,E=i.isPending?i.variables:T,D=B2(t);function O(e){e!==T&&i.mutate(e,{onSuccess:e=>Z(H2(e.effect,`claude`)),onError:e=>Z(`Permission change failed: ${e.message.slice(0,120)}`)})}let k=s===`claude`?B2(t):null;function A(){t?.sessionId&&a.mutate(t.sessionId,{onSuccess:e=>Z(`${e.label} from the next turn — the worker restarts then`),onError:e=>Z(`Upgrade failed: ${e.message.slice(0,120)}`)})}function j(e){r.mutate(e,{onSuccess:e=>Z(s===`acp`?e.effect===`next-resume`?`Model saved for the next resume`:`Model applied`:e.effect===`next-resume`?`Model and effort saved for the next resume`:`Model and effort applied`),onError:e=>Z(`Profile change failed: ${e.message.slice(0,120)}`)})}let M=(0,R.jsxs)(R.Fragment,{children:[s!==`acp`&&(0,R.jsx)(YV,{groups:S,value:{provider:s,model:u,effort:d},pending:h||g?{provider:s,model:h,effort:g}:void 0,onValueChange:({model:e,effort:t})=>j({model:e,effort:t}),placeholder:n.isPending?`Profile loading…`:`Profile unknown`,ariaLabel:`Thread model and effort`,menuAriaLabel:`Choose ${s===`codex`?`Codex`:`Claude Code`} model and effort`,title:y?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:l||!b||!y||n.isError,compact:!0,side:`top`,className:`min-w-0 max-w-[min(72%,20rem)] px-1.5 py-0.5`,runningModelLabel:t.runningModelLabel,upgrade:t.modelUpgrade&&t.runningModelLabel?{latest:t.modelUpgrade.label,staged:t.modelUpgrade.staged,blockedReason:k,pending:a.isPending,onUpgrade:A}:void 0}),s===`acp`&&f&&(0,R.jsx)($V,{agentId:f,agentLabel:x??f,modelId:_??p,onValueChange:e=>j({model:Su(f,e),effort:``}),disabled:l,side:`top`,className:`min-w-0 max-w-[min(72%,20rem)] px-1.5 py-0.5`})]});return{busy:l,footer:(0,R.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:[M,s===`claude`&&(0,R.jsx)(FV,{variant:`readout`,side:`top`,value:E,onValueChange:e=>O(e),options:PB,ariaLabel:`Thread permission mode`,title:D?`${D} — changing permissions restarts this thread's worker process`:E===`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:l||D!==null,className:`shrink-0`}),h&&g&&(0,R.jsxs)(`span`,{className:`min-w-0 truncate text-[9px] text-muted-50`,children:[`→ `,h,` · `,g,` pending`]})]}),phoneTools:M,status:C?(0,R.jsx)(`div`,{"data-thread-control-error":``,className:`px-1 pt-1 text-[9.5px] leading-tight text-muted-65`,children:C.message}):null}}function G2(e,t=zD.queueOrder){let n=bO(e,t),r=n.active.filter(Sf),i=n.active.filter(e=>!Sf(e));return[...n.pinned,...r,...i]}function K2(e,t,n=zD.queueOrder,r=$W()){return G2(e.map(e=>tG(e,r[e.id])),n).find(e=>e.id!==t&&e.needsYou===!0)}function q2(e){let t=K2(X.board?.threads??[],e);if(JE()){t&&window.addEventListener(`popstate`,()=>setTimeout(()=>Xh(t.id),0),{once:!0}),history.back();return}if(t){Xh(t.id);return}let n=X.drawers.filter(e=>!e.closing).map(e=>e.id);n.length&&_g(n)}var J2=new Map;async function Y2(e,t={}){let n=e.id,r=t.terminateLive===!0,i=r||BK(e),a=UD(e),o=()=>{ZW(n),q2(n),Z(`“${a}” marked done`,{action:{label:`Undo`,run:()=>void X2(n)}})};i&&o();let s=Y.completeThread({slug:n,sessionId:e.sessionId??``,terminateLive:r});J2.set(n,s);try{let e=await s;return e.needsConfirmation?(QW(n),i?(Z(e.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`,{link:{label:`Open`,slug:n}}),{kind:`declined`}):{kind:`needs-confirmation`,hold:e.hold}):(i||o(),{kind:`done`})}catch(e){return QW(n),Z(`Couldn’t finish: ${e.message.slice(0,80)}`,i?{link:{label:`Open`,slug:n}}:void 0),{kind:`failed`}}finally{J2.get(n)===s&&J2.delete(n)}}async function X2(e){await J2.get(e)?.catch(()=>void 0);try{await Y.setThreadState({slug:e,state:`open`}),QW(e),Xh(e)}catch(e){Z(`Couldn’t undo: ${e.message.slice(0,80)}`)}}function Z2({thread:e,compact:t}){let[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(null);async function o(t){r(!0),t&&a(null);let n=await Y2(e,{terminateLive:t});n.kind===`needs-confirmation`&&a({hold:n.hold}),n.kind!==`done`&&r(!1)}let s=VK(i?.hold);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,"data-phone-done":!0,onMouseDown:e=>e.preventDefault(),onClick:()=>void o(!1),disabled:n,"aria-label":`Mark as done`,className:`flex shrink-0 items-center justify-center gap-1 rounded-full bg-fg font-semibold text-bg disabled:opacity-45 ${t?`relative h-[36px] pl-[11px] pr-[14px] text-[14px] after:absolute after:inset-x-0 after:-inset-y-[4px] after:content-['']`:`h-[42px] pl-[13px] pr-[16px] text-[15px]`}`,children:[n&&!i?(0,R.jsx)(M_,{"aria-hidden":!0,size:t?15:17,className:`animate-spin`}):(0,R.jsx)(e_,{"aria-hidden":!0,size:t?15:17,strokeWidth:2.6,className:`translate-y-[0.1em]`}),`Done`]}),(0,R.jsx)(Oq,{open:i!==null,onOpenChange:e=>{!e&&!n&&a(null)},title:i?.hold?.cutOff?`Mark an unfinished thread done?`:`End this session?`,className:`w-[390px] max-w-[92vw]`,footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>a(null),className:`button-outline h-[40px] rounded-md px-4 text-[14px] text-muted outline-none disabled:opacity-45`,children:`Cancel`}),(0,R.jsxs)(`button`,{type:`button`,"data-phone-done-confirm":!0,disabled:n,onClick:()=>void o(!0),className:`button-outline flex h-[40px] items-center gap-1.5 rounded-md bg-fg px-4 text-[14px] font-medium text-bg outline-none disabled:opacity-45`,children:[n&&(0,R.jsx)(M_,{size:14,className:`animate-spin`}),i?.hold?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,R.jsxs)(`div`,{"data-completion-hold":!0,className:`flex flex-col gap-2 p-4 text-[14px] leading-relaxed text-muted`,children:[(0,R.jsx)(`p`,{children:s.lead}),s.groups.map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(`div`,{className:`text-[12px] font-medium text-fg/70`,children:e.heading}),(0,R.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[e.items.map((e,t)=>(0,R.jsxs)(`li`,{className:`min-w-0 truncate text-fg/80`,children:[e.label,e.stale&&(0,R.jsx)(`span`,{className:`text-muted-60`,children:` · no recent output`})]},`${e.label}-${t}`)),e.overflow>0&&(0,R.jsxs)(`li`,{className:`text-muted-60`,children:[`+`,e.overflow,` more`]})]})]},e.kind)),(0,R.jsx)(`p`,{children:s.trailer})]})})]})}var Q2=new Map;function $2(e){let t=Q2.get(e);if(t)return t;let n=Y.threadSkills({slug:e}).then(e=>e.skills,()=>(Q2.delete(e),[]));return Q2.set(e,n),n}function e4({slug:e,surface:t,className:n,id:r,above:i,submitOverride:a,phoneBarOverride:o,phoneChrome:s}){let c=gr(X),l=c.board?.threads.find(t=>t.id===e),u=l?.foreign?`Send a message to take over this session…`:l?.pendingQuestion||(l?.questions?.length??0)>0?`Or skip the questions and reply…`:`Reply to the agent…`,d=wH(),f=CH.followUp(d,e,l?.sessionId),[p,m,h]=EH(f),g=W2(e),_=OW(e),[v,y]=(0,L.useState)(null),b=(0,L.useMemo)(()=>()=>$2(e),[e]),[x,S]=(0,L.useState)(null),C=c.composerContext[e],w=(0,L.useMemo)(()=>C?.map(e=>e.token)??[],[C]);(0,L.useEffect)(()=>{let t=X.composerContext[e];if(!t?.length)return;let{prose:n}=sz(p),r=t.filter(e=>pz(n,e.token));r.length!==t.length&&(X.composerContext[e]=r)},[e,p,C]);let T=qte(l,a!==void 0),E=Lg(),D=(s??E)&&t===`chatComposer`,O=l?.runtime===`running`||l?.runtime===`spawning`,k=l?.lastFence?.kind===`awaiting`&&Gu(l.lastFence.hints).length>0,A=l?zK(l).archive&&!O&&!k:!1,j=l&&l.kind===`session`&&l.foreign!==!0?(0,R.jsx)(hq,{thread:l}):void 0;function M(t=!1){let n=p.trim();if(!n)return;let r=iH(n);if(r){if(h(),l?.backend===`acp`){Z(`An ACP agent signs in through its own CLI — Frizz holds no account for it`);return}let e=l?.backend===`codex`?`codex`:`claude`;r===`login`?y(e):S(e);return}let i=fg(e),o=Hte(n,i,d),s={onOptimistic:h,supersedes:o2(f,o),onRollback:t=>{xH(f,p),pg(e,i),i2(f,{...t,text:p})}};a?a(o,s):_.submit(o,{...s,interrupt:t})}return D?(0,R.jsxs)(`div`,{"data-thread-composer-box":t,"data-thread-action-bar":``,"data-phone-thread-bar":``,children:[(0,R.jsx)(Uz,{contextTokens:w,id:r,surface:t,value:p,onChange:m,onSubmit:()=>M(),onInterruptSubmit:T?()=>M(!0):void 0,slashSuggest:b,placeholder:l?.foreign?u:O?`Steer…`:`Reply…`,busy:g.busy,phone:{layout:`bar`,tools:g.phoneTools,idlePrimary:A&&l?e=>(0,R.jsx)(Z2,{thread:l,compact:e}):void 0,override:o,onLongPressSend:T?()=>M(!0):void 0}}),g.status,v&&(0,R.jsx)(aH,{backend:v,onClose:()=>y(null),onAuthed:()=>y(null)}),x&&(0,R.jsx)(oH,{backend:x,onClose:()=>S(null)})]}):(0,R.jsxs)(`div`,{"data-thread-composer-box":t,...t===`chatComposer`?{"data-thread-action-bar":``}:{},className:n,children:[i,(0,R.jsx)(Uz,{contextTokens:w,id:r,surface:t,value:p,onChange:m,onSubmit:()=>M(),onInterruptSubmit:T?()=>M(!0):void 0,slashSuggest:b,placeholder:u,busy:g.busy,footer:g.footer,railLead:j}),g.status,v&&(0,R.jsx)(aH,{backend:v,onClose:()=>y(null),onAuthed:()=>y(null)}),x&&(0,R.jsx)(oH,{backend:x,onClose:()=>S(null)})]})}function t4({slug:e,above:t,phoneBarOverride:n,phoneChrome:r}){return gr(X).board?.threads.find(t=>t.id===e)?(0,R.jsx)(e4,{slug:e,surface:`chatComposer`,id:`followup-input`,className:`shrink-0 px-3 py-3`,above:t,phoneBarOverride:n,phoneChrome:r}):null}function n4(e,t=[]){let n=vk(e.subAgents??[],`card`),r=bk(e.bgShells??[],t),i=(e.watches??[]).filter(e=>e.kind===`github`),a=i.filter(e=>e.subject!==`issue`),o=i.filter(e=>e.subject===`issue`),s=e.links??[],c=s.filter(e=>e.kind===`file`),l=s.filter(e=>e.kind===`link`);return[{key:`agent`,n:n.length,one:`agent`,many:`agents`,states:n.map(e=>e.state)},{key:`shell`,n:r.length,one:`shell`,many:`shells`,states:r.map(e=>e.state)},{key:`pr`,n:a.length,one:`PR`,many:`PRs`,states:[`running`]},{key:`issue`,n:o.length,one:`issue`,many:`issues`,states:[`running`]},{key:`file`,n:c.length,one:`file`,many:`files`,states:[]},{key:`link`,n:l.length,one:`link`,many:`links`,states:[]}].filter(e=>e.n>0)}function r4(e){return vk(e,`card`).length>0}function i4({slug:e,subAgents:t,className:n=`px-1 pt-1.5`}){let r=vk(t,`card`);return r.length===0?null:(0,R.jsx)(`div`,{"data-queue-subagents":!0,className:`flex min-w-0 flex-col gap-0.5 ${n}`,children:r.map((t,n)=>(0,R.jsx)(xk,{kind:`AGENT`,label:t.label,state:t.state,density:`card`,depth:t.depth,startedAt:t.startedAt,parentSlug:e,onOpen:t.id?()=>Jh(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:zP(e,t)},t.id??`${t.startedAt}-${n}`))})}function a4({thread:e,transcriptShells:t=[]}){let[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(void 0);(0,L.useEffect)(()=>()=>clearTimeout(i.current),[]);let a=n4(e,t),o=(0,L.useRef)(null),s=(0,L.useRef)(null),c=a.length===0;if((0,L.useEffect)(()=>{c&&(clearTimeout(i.current),r(!1))},[c]),c)return null;let l=a.map(e=>`${e.n} ${e.n===1?e.one:e.many}`),u=()=>{clearTimeout(i.current),r(!0)},d=()=>{clearTimeout(i.current),i.current=setTimeout(()=>r(!1),150)},f=()=>{u(),requestAnimationFrame(()=>o.current?.querySelector(`button, a[href], [tabindex]:not([tabindex='-1'])`)?.focus())};return(0,R.jsx)(`div`,{"data-queue-ops-summary":!0,className:`-mt-2 flex h-7 min-w-0 items-center justify-end`,children:(0,R.jsxs)(CV,{open:n,onOpenChange:r,children:[(0,R.jsx)(TV,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`${l.join(`, `)} — show them`,"aria-haspopup":`dialog`,"aria-expanded":n,onMouseEnter:u,onMouseLeave:d,onFocus:u,ref:s,onClick:e=>{e.stopPropagation(),e.detail===0?f():u()},onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),f())},onMouseDown:e=>e.preventDefault(),className:`flex min-w-0 items-center gap-3 rounded-md px-1.5 py-0.5 text-[11.5px] outline-none transition-colors focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${n?`bg-panel-2 text-fg/85`:`text-muted-70 hover:bg-panel-2 hover:text-fg/85`}`,children:a.map(e=>(0,R.jsxs)(`span`,{"data-ops-count":e.key,className:`flex items-baseline gap-1.5 whitespace-nowrap`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`relative block h-[1em] w-[1em] shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`,children:(0,R.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,R.jsx)(o4,{kind:e.key,states:e.states})})}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:`tabular-nums text-fg/85`,children:e.n}),` `,e.n===1?e.one:e.many]})]},e.key))})}),(0,R.jsxs)(EV,{side:`top`,align:`end`,sideOffset:4,"data-queue-ops-panel":!0,"aria-label":`Running for this thread`,onMouseEnter:u,onMouseLeave:d,onOpenAutoFocus:e=>e.preventDefault(),onEscapeKeyDown:e=>{e.stopPropagation(),o.current?.contains(document.activeElement)&&s.current?.focus()},ref:o,onClick:e=>e.stopPropagation(),className:`flex w-[440px] max-w-[calc(100vw-1.5rem)] flex-col px-3 py-2`,children:[(0,R.jsx)(i4,{slug:e.id,subAgents:e.subAgents??[],className:``}),(0,R.jsx)(J5,{slug:e.id,includeAgents:!1,transcriptShells:t,className:r4(e.subAgents??[])?`pt-0.5`:``})]})]})})}function o4({kind:e,states:t}){switch(e){case`agent`:return(0,R.jsx)(s4,{hue:`agent`,states:t});case`shell`:return(0,R.jsx)(s4,{hue:`shell`,states:t});case`pr`:case`issue`:return(0,R.jsx)(s4,{hue:`github`,states:t});case`file`:return(0,R.jsx)(v_,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`});case`link`:return(0,R.jsx)(g_,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`})}}function s4({hue:e,states:t}){return t.some(BO)?(0,R.jsx)(`span`,{className:`frizz-live-dot frizz-live-dot--${e}`}):(0,R.jsx)(`span`,{className:t.includes(`rested`)?ak:rk})}function c4({slug:e,onClose:t}){let n=Cg(ME(),e),[r,i]=(0,L.useState)(!1),a=RO(),o=RE(e,{poll:n?.runtime===`running`||n?.runtime===`spawning`}),s=(0,L.useMemo)(()=>cq(o.data?.messages??[]),[o.data]),c=Wq(n);if(!n)return null;let l=nq(n),u=iq(n,l,s,a),d=l===`needs-you`?`font-semibold text-accent`:l===`working`?`font-semibold text-live`:``,f=UD(n);return(0,R.jsxs)(`header`,{"data-thread-header":!0,"data-mobile-thread-header":!0,className:`flex min-h-14 shrink-0 items-center gap-0.5 border-b border-border bg-panel py-1 pl-1 pr-[5px]`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":`Back`,"data-mobile-thread-back":!0,onClick:()=>{JE()?history.back():t()},className:`flex size-11 shrink-0 items-center justify-center rounded-full text-fg/90 outline-none active:bg-hover focus-visible:bg-hover`,children:(0,R.jsx)(Yg,{size:21,strokeWidth:2.1})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 pl-0.5 leading-[1.25]`,children:[(0,R.jsx)(`div`,{"data-mobile-thread-title":!0,className:`truncate text-[16.5px] font-semibold tracking-[-0.01em]`,title:f,children:f}),(0,R.jsxs)(`div`,{"data-mobile-thread-subtitle":!0,"data-state":l,className:`truncate text-[13px] text-muted`,children:[(0,R.jsx)(`span`,{className:d,children:rq[l]}),u&&(0,R.jsxs)(R.Fragment,{children:[` · `,u]}),c&&(0,R.jsxs)(R.Fragment,{children:[` · `,c]})]})]}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Thread actions`,"aria-haspopup":`dialog`,"aria-expanded":r,"data-mobile-thread-more":!0,onClick:()=>i(!0),className:`flex size-11 shrink-0 items-center justify-center rounded-full text-fg/90 outline-none active:bg-hover focus-visible:bg-hover`,children:(0,R.jsx)(h_,{size:21,strokeWidth:2.1})}),r&&(0,R.jsx)(Pq,{slug:e,onClose:()=>i(!1),onArchived:()=>q2(e)})]})}function l4({thread:e}){let[t,n]=(0,L.useState)(!1);if(!$K(e))return null;async function r(){n(!0);try{await tq(e)}finally{n(!1)}}return(0,R.jsx)(IP,{label:`Reload plugins — hooks, skills, agents and MCP re-read from disk, same conversation`,side:`top`,children:(0,R.jsx)(`button`,{type:`button`,"data-reload-plugins":!0,disabled:t,"aria-label":`Reload plugins`,onMouseDown:e=>e.preventDefault(),onClick:()=>void r(),className:Mk,children:(0,R.jsx)(K_,{size:14,strokeWidth:2})})})}function u4({thread:e}){let t=qe(),[n,r]=(0,L.useState)(!1);return eq(e,QK())?(0,R.jsx)(IP,{label:`Restart worker — same conversation, fresh process on current tooling`,side:`top`,children:(0,R.jsx)(`button`,{type:`button`,disabled:n,"aria-label":`Restart worker`,onMouseDown:e=>e.preventDefault(),onClick:()=>{r(!0),ZK(t,e.id).finally(()=>r(!1))},className:`${Mk} mx-[2px]`,children:n?(0,R.jsx)(M_,{size:14,strokeWidth:2,className:`animate-spin`}):(0,R.jsx)(J_,{size:14,strokeWidth:2})})}):null}function d4(e){return jk(e)??HE(`/`)}function f4(e){qE(d4(e),{viewTransition:!Ah()})}function p4({slug:e,label:t=`Exit fullscreen`}){let n=d4(e);function r(t){um(t)&&(t.preventDefault(),f4(e))}return(0,R.jsx)(IP,{label:t,children:(0,R.jsx)(`a`,{href:n,"aria-label":t,"data-standalone-return":!0,onMouseDown:e=>e.preventDefault(),onClick:r,className:Mk,children:(0,R.jsx)(R_,{size:14})})})}function m4({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,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[a&&(0,R.jsx)(g4,{label:o?`Expand`:`Collapse`,icon:o?a_:i_,size:13,onClick:a}),(0,R.jsx)(l4,{thread:e}),(0,R.jsx)(u4,{thread:e}),r&&(0,R.jsx)(g4,{label:`Frizz document`,icon:v_,size:14,onClick:r}),t&&(0,R.jsx)(LP,{slug:e.id}),n&&(0,R.jsx)(p4,{slug:e.id}),d?_O(e)?(0,R.jsx)(h4,{slug:e.id}):null:(0,R.jsx)(`div`,{className:`ml-1`,children:(0,R.jsx)(lR,{slug:e.id,onDone:i,doneBusy:s,onMutateStart:c,onApplied:l,onFailed:u})})]})}function h4({slug:e}){let t=qe(),[n,r]=(0,L.useState)(!1);return(0,R.jsx)(IP,{label:`Retry — resume this session where it left off`,children:(0,R.jsxs)(`button`,{onClick:()=>{r(!0),kW(t,e).finally(()=>r(!1))},disabled:n,"aria-label":`Retry exited session`,"data-header-pill":!0,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,R.jsx)(M_,{size:12,className:`animate-spin`}):(0,R.jsx)(X_,{size:12}),`Retry`]})})}function g4({label:e,icon:t,size:n,busy:r,...i}){return(0,R.jsx)(IP,{label:e,children:(0,R.jsx)(`button`,{...i,"aria-label":e,onMouseDown:e=>e.preventDefault(),className:Mk,children:r?(0,R.jsx)(M_,{size:n,strokeWidth:2,className:`animate-spin`}):(0,R.jsx)(t,{size:n,strokeWidth:2})})})}function _4({at:e,fallbackAt:t,className:n=``}){let r=RO(),i=xO(e,t),a=SO(i,r);return!a||!i?null:(0,R.jsx)(`time`,{dateTime:i,className:n,children:a})}var v4=1.25,y4=7.5-v4/2,b4=2*Math.PI*y4;function x4(e,t){return Math.max(0,Math.min(100,Math.floor(e/t*100)))}var S4=150;function C4(e){return!!e.context&&e.context.window>0}function w4({thread:e}){let[t,n]=(0,L.useState)(!1),r=(0,L.useRef)(void 0),i=(0,L.useRef)(null),a=(0,L.useRef)(null);(0,L.useEffect)(()=>()=>clearTimeout(r.current),[]);let o=e.context;if(!o||!C4(e))return null;let s=()=>{clearTimeout(r.current),n(!0)},c=()=>{clearTimeout(r.current),r.current=setTimeout(()=>n(!1),S4)},l=e=>{i.current?.contains(e.target)&&e.preventDefault()},u=O4(e,o.tokens),d=x4(o.tokens,o.window),f=Math.max(0,Math.min(1,o.tokens/o.window)),p=`Context ${d}% full`,m=`${o.tokens.toLocaleString()} of ${o.window.toLocaleString()} tokens`;return(0,R.jsxs)(CV,{open:t,onOpenChange:n,children:[(0,R.jsx)(TV,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,"data-context-meter":!0,"data-context-percent":d,"aria-label":`${p}\n${m}`,"aria-haspopup":`dialog`,"aria-expanded":t,onMouseEnter:s,onMouseLeave:c,onFocus:s,ref:i,onClick:e=>{e.stopPropagation(),s(),e.detail===0&&requestAnimationFrame(()=>a.current?.querySelector(`button:not(:disabled)`)?.focus())},className:`flex shrink-0 items-baseline gap-1 rounded-sm outline-none transition-colors hover:text-fg/85 focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${t?`text-fg/85`:``}`,children:[(0,R.jsxs)(`svg`,{viewBox:`0 0 16 16`,className:`-mt-[1em] h-[1.05em] w-[1.05em] shrink-0 self-baseline translate-y-[calc(0.525em_-_0.5cap)]`,"aria-hidden":!0,children:[(0,R.jsx)(`circle`,{cx:`8`,cy:`8`,r:y4,fill:`none`,stroke:`currentColor`,strokeOpacity:.3,strokeWidth:v4}),(0,R.jsx)(`circle`,{cx:`8`,cy:`8`,r:y4,fill:`none`,stroke:`currentColor`,strokeWidth:v4,strokeDasharray:`${b4*f} ${b4}`,transform:`rotate(-90 8 8)`})]}),(0,R.jsxs)(`span`,{children:[d,`% context`]})]})}),(0,R.jsxs)(EV,{side:`bottom`,align:`start`,sideOffset:5,ref:a,"data-context-panel":!0,"aria-label":p,onInteractOutside:e=>l({target:e.detail.originalEvent.target,preventDefault:()=>e.preventDefault()}),onMouseEnter:s,onMouseLeave:c,onOpenAutoFocus:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),className:`flex w-max max-w-[min(22rem,calc(100vw-1.5rem))] flex-col gap-2 px-3 py-2 text-[11px] leading-relaxed text-fg`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[(0,R.jsx)(`span`,{children:p}),(0,R.jsx)(`span`,{className:`text-muted`,children:m})]}),Ff(e)&&(0,R.jsx)(k4,{thread:e,compacting:u,onRequested:()=>n(!1)})]})]})}function T4(e){return e.runtime===`running`||e.runtime===`spawning`||e.runtime===`perm-prompt`}var E4=new Map,D4=2*6e4;function O4(e,t){let n=e.sessionId;if(!n)return!1;let r=E4.get(n);return r?!T4(e)&&(r.tokens!==t||e.lastActivityAt!==r.activity)||Date.now()-r.at>D4?(E4.delete(n),!1):!0:!1}function k4({thread:e,compacting:t,onRequested:n}){let[r,i]=(0,L.useState)(!1),a=e.context?.tokens??0,o=T4(e)&&!t;return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`button`,{type:`button`,"data-compact-now":!0,disabled:o||r||t||!e.sessionId,onClick:()=>{let t=e.sessionId;t&&(i(!0),Y.compactThread({slug:e.id,sessionId:t}).then(()=>{E4.set(t,{tokens:a,activity:e.lastActivityAt,at:Date.now()}),Z(`Compacting context`),n()}).catch(e=>Z(`Couldn’t compact: ${e.message.slice(0,80)}`)).finally(()=>i(!1)))},onMouseDown:e=>e.preventDefault(),className:`flex items-center justify-center gap-1 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-focus-ink-60 disabled:opacity-45 disabled:hover:bg-panel-2/60 disabled:hover:text-fg/80`,children:[(r||t)&&(0,R.jsx)(M_,{size:12,className:`animate-spin`}),t?`Compacting…`:`Compact now`]}),o&&(0,R.jsx)(`span`,{className:`text-muted`,children:`Available once the current turn ends`})]})}function A4({thread:e}){return(0,R.jsxs)(`div`,{"data-thread-header-facts":!0,className:`mt-0.5 flex min-w-0 items-center gap-1.5 text-[11px] leading-tight text-muted-75 empty:hidden`,children:[(0,R.jsx)(_4,{at:$D(e),fallbackAt:e.spawnedAt,className:`min-w-0 truncate`}),C4(e)&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`hidden shrink-0 text-muted-45 [time+&]:inline`,children:`·`}),(0,R.jsx)(w4,{thread:e})]})]})}function j4({thread:e,hidden:t=!1}){let n=pt({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=GK(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,R.jsx)(IP,{label:i,children:(0,R.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-danger hover:bg-danger-fill/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,R.jsx)(M_,{size:12,className:`animate-spin`}):(0,R.jsx)(Z_,{size:12})})})}function M4({thread:e,className:t=``}){let n=e.id,r=pt({mutationFn:e=>Y.renameThread({slug:n,title:e})}),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(``),c=(0,L.useRef)(null);(0,L.useEffect)(()=>{if(!i)return;let e=requestAnimationFrame(()=>{c.current?.focus(),c.current?.select()});return()=>cancelAnimationFrame(e)},[i]),(0,L.useEffect)(()=>{a(!1),s(``)},[n]);let l=e.kind===`session`&&e.foreign!==!0,u=UD(e);function d(){a(!1),s(``)}function f(){let e=UK(o,u);if(a(!1),!e){s(``);return}r.mutate(e,{onSuccess:()=>{s(``),Z(`Thread renamed`)},onError:t=>{s(e),a(!0),Z(t instanceof Error?t.message:`Could not rename thread`)}})}return(0,R.jsxs)(`div`,{className:`group/thread-title flex min-w-0 items-center gap-2`,children:[i?(0,R.jsx)(`input`,{ref:c,"aria-label":`Thread title`,value:o,maxLength:200,onChange:e=>s(e.target.value),onBlur:f,"data-claims-escape":!0,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),f()):e.key===`Escape`&&(e.preventDefault(),d())},className:`min-w-0 flex-1 -mx-1.5 -my-px rounded-md border border-border bg-elevated px-1.5 py-0 font-semibold text-[15px] text-fg outline-none focus:border-accent ${t}`}):l?(0,R.jsx)(`button`,{type:`button`,title:`Edit title`,"aria-label":`Edit thread title: ${u}`,disabled:r.isPending,onClick:()=>{s(WK(u,n)),a(!0)},className:`min-w-0 max-w-full shrink truncate rounded px-0.5 -mx-0.5 font-semibold text-[15px] text-left outline-none transition-colors hover:bg-panel-2 focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:cursor-not-allowed disabled:opacity-40 ${t}`,children:u}):(0,R.jsx)(`div`,{className:`min-w-0 max-w-full shrink truncate px-0.5 -mx-0.5 font-semibold text-[15px] ${t}`,title:u,children:u}),(0,R.jsx)(j4,{thread:e,hidden:i})]})}var N4=new Set([`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]);function P4(e,t){let n=e.lastIndexOf(t);if(n<=0)return{model:e};let r=e.slice(n+1);return N4.has(r)?{model:e.slice(0,n),effort:r}:{model:e}}function F4(e){let t=e?.trim();if(!t)return`Profile unknown`;if(t.startsWith(`frizz:`)){let{model:e,effort:n}=P4(t.slice(6).replace(/^frizz-/,``),`-`);return n?`${e} › ${n}`:e}let n=t.split(/\s+/),{model:r,effort:i}=P4(n.at(-1)??t,`/`);if(!i)return t;let a=n.slice(0,-1).join(` `);return`${a?`${a} · `:``}${r} › ${i}`}function I4(e){return e?.trim()?F4(e):void 0}function L4(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 R4={completed:`finished`,killed:`stopped`,failed:`failed`};function z4(e){let t=R4[e.agentStatus??`completed`],n=e.agentElapsedMs===void 0?void 0:YO(e.agentElapsedMs);return{outcome:t,tail:`${t}${n?` · ${n}`:``}`}}var B4=e=>e===void 0?void 0:WO(e),V4=e=>{if(e!==void 0)return YO(e)||void 0};function H4(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=B4(n);return{label:t===`completed`?void 0:R4[t],duration:V4(n),tone:r?`failed`:`muted`,title:`${e?`Stopped`:r?`Failed`:`Ran for`}${e||r?` after`:``} ${i??`an unknown time`}`}}if(r){let e=B4(i);return{label:void 0,duration:V4(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=B4(o);return{label:c?R4.killed:s?R4.failed:void 0,duration:V4(o),tone:s?`failed`:`muted`,title:`${c?`Stopped after`:s?`Failed after`:`Ran for`} ${l??`an unknown time`}`}}var U4=`group flex min-w-0 items-baseline gap-1.5 rounded-sm text-left text-[11.5px] outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60`,W4=`${nk} -mt-[1em] self-baseline`,G4=`h-[1em] w-[1em] shrink-0 translate-y-[calc(0.5em_-_0.5cap)] text-muted-45`;function K4({links:e}){return e.length?(0,R.jsx)(`div`,{"data-thread-links":!0,"aria-label":`Registered links`,className:`mt-2 flex min-w-0 flex-col gap-0.5 border-t border-border pt-1.5`,children:e.map(e=>{let t=e.kind===`link`,n=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:ek,children:`⤷`}),(0,R.jsx)(`span`,{className:W4,children:(0,R.jsx)(t?g_:v_,{"aria-hidden":!0,className:G4})}),(0,R.jsx)(`span`,{"data-link-kind":!0,className:tk,children:t?`Link`:`File`}),(0,R.jsx)(`span`,{"data-link-label":!0,className:`min-w-0 flex-1 truncate text-muted-70 group-hover:text-fg/80 group-hover:underline`,children:e.label}),t&&(0,R.jsx)(`span`,{"data-link-destination":!0,className:`font-mono-keep ml-auto -mb-[0.5em] max-w-[45%] min-w-0 truncate text-right text-[10px] text-muted-45`,children:e.target})]});return t?(0,R.jsx)(`a`,{"data-thread-link":e.id,href:e.target,target:`_blank`,rel:`noopener noreferrer`,title:e.target,className:U4,onClick:e=>e.stopPropagation(),children:n},e.id):(0,R.jsx)(`button`,{"data-thread-link":e.id,type:`button`,title:e.target,className:`${U4} cursor-pointer`,onClick:t=>{t.stopPropagation(),YK(e.target)},children:n},e.id)})}):null}var q4=`text-[14px] leading-5 text-muted`,J4=`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 Y4(e){return`${J4} ${e?`-mx-[0.208em] rotate-90`:`-mx-[0.333em]`}`}var $=L.createElement;function X4({payload:e}){return e.kind===`command-approval`?$(L.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,$(Z4,{label:`Redacted command preview`,text:e.command.preview}),e.command.actions?$(Q4,{actions:e.command.actions}):null,e.capabilities?$(e3,{capabilities:e.capabilities}):null):e.kind===`file-approval`?$(L.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},i3(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-attention/35 bg-attention-fill/[0.06] px-2.5 py-2`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-attention-soft-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-attention-soft-75`},e.scopeLabel):null):null,e.diffPreview?$(Z4,{label:`Plain-text diff preview`,text:e.diffPreview}):null,e.changes?$($4,{changes:e.changes}):null):$(L.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?$(e3,{capabilities:e.capabilities}):null)}function Z4({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-focus-ink-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 Q4({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`},r3(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,$(Z4,{label:`${r3(e.kind)} command detail`,text:e.commandPreview})))))}function $4({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`},i3(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?$(Z4,{label:`${i3(e.operation)} plain-text diff`,text:e.diffPreview}):null))))}function e3({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`},$(t3,{capability:e})))))}function t3({capability:e}){if(e.kind===`network`){let t=e.enabled===!0?`Enable network access`:e.enabled===!1?`Disable network access`:`Network access request`;return $(L.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},t),e.hosts.length>0?$(n3,{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 $(L.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},t),$(n3,{label:`Paths`,values:e.resources}))}return e.kind===`glob-scan`?$(L.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`?$(L.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},`Future command policy amendment`),$(n3,{label:`Command prefix tokens`,values:e.prefixes})):$(L.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},e.access===`allow`?`Allow future network hosts`:`Deny future network hosts`),$(n3,{label:`Hosts`,values:e.hosts}))}function n3({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 r3(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 i3(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 a3(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 o3={semantic:`approve`,label:`Approve once`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`},s3={semantic:`approve`,label:`Approve for session`,order:20,tone:`primary`,durable:!0,scope:`Persists for later matching requests in this thread session.`},c3={semantic:`approve`,label:`Grant for turn`,order:10,tone:`primary`,durable:!1,scope:`Applies to this turn only.`},l3={semantic:`approve`,label:`Grant for session`,order:20,tone:`primary`,durable:!0,scope:`Persists until this thread session ends.`},u3={semantic:`deny`,label:`Deny`,order:70,tone:`danger`,durable:!1,scope:`Rejects this request.`},d3={semantic:`decline`,label:`Decline`,order:70,tone:`danger`,durable:!1,scope:`Declines this request.`},f3={semantic:`cancel`,label:`Cancel request`,order:80,tone:`neutral`,durable:!1,scope:`Cancels this pending request.`};function p3(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`?o3:n===`acceptForSession`&&r===`approve`?s3:(n===`decline`||n===`deny`)&&r===`deny`?u3:n===`cancel`&&r===`cancel`?f3:void 0;if(e.kind===`permission-approval`)return n===`grant-turn`&&r===`approve`?c3:n===`grant-session`&&r===`approve`?l3:(n===`deny`||n===`decline`)&&r===`deny`?u3:n===`cancel`&&r===`cancel`?f3: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`?d3:n===`cancel`&&r===`cancel`?f3: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 d3;if(n===`cancel`&&r===`cancel`)return f3}function m3(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=p3(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 h3(e){switch(e){case`claude`:return`Claude`;case`codex`:return`Codex`;case`acp`:return`ACP agent`;case`frizz`:return`Frizz`}}function g3(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 _3(e,t){let n=e.options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t));return n<0?``:String(n)}function v3(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?``:_3(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 y3(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 b3(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=Tl(i,a);e?r[i.id]=`Value ${e}.`:n[i.id]=a}}if(Object.keys(r).length>0)return{errors:r};let i=zl.safeParse(n);return i.success?{errors:r,values:i.data}:{errors:r,formError:`The response is too large or contains invalid values.`}}function x3(e,t){return JSON.stringify([e,t??null])}function S3(e,t){try{let n=new URL(e,t);return n.protocol===`http:`||n.protocol===`https:`?n.toString():null}catch{return null}}function C3(e,t){let n=e.getAttribute(`href`);if(!n)return!1;let r=S3(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 w3(e=()=>location.href){return t=>{if(t.defaultPrevented||t.button!==0)return;let n=E3(t);n&&C3(n,e())}}function T3(){let e=w3();return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)}function E3(e){let t=typeof e.composedPath==`function`?e.composedPath():[];for(let e of t)if(D3(e))return e;let n=e.target?.closest?.(`a[href]`);return D3(n)?n:null}function D3(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 O3(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)=>`${LQ(t)} ${e.label}`),recommendedIdx:null},...e?{optionFieldId:e.id}:{},optionValues:r.map(e=>e.value),...t?{notesFieldId:t.id}:{}}}function k3(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=O3(r,a);if(!e)return null;n.push(e)}else if(r.input===`text`||r.input===`multiline`){let e=O3(void 0,r);if(!e)return null;n.push(e)}else return null}return n.length>0?n:null}function A3(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)=>`${LQ(t)} ${e.label}${e.description?` — ${e.description}`:``}`),recommendedIdx:null},chosenIdxs:n,text:r}}function j3(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 M3(e){let t=e instanceof Error?e.message:`The request could not be updated.`;return t.length>240?`${t.slice(0,239)}…`:t}function N3(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`frizz-response-${Date.now()}-${Math.random().toString(36).slice(2)}`}function P3({thread:e,className:t=``,autoFocusFirst:n=!1}){let r=LE(e),i=Qee(e),a=(0,L.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,R.jsxs)(`div`,{"data-interactions-error":!0,role:`alert`,className:`${KQ} border border-attention-fill/35 bg-attention-fill/[0.07] p-4 text-[12px] text-attention-soft ${t}`,children:[(0,R.jsx)(`div`,{className:`font-medium`,children:`Pending requests could not be loaded.`}),(0,R.jsx)(`div`,{className:`mt-1 break-words text-attention-soft-75`,children:M3(i.error)}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void i.refetch(),className:`mt-2 rounded-md border border-attention/40 px-2 py-1 text-[11px] hover:bg-attention-fill/10`,children:`Try again`})]}):a.length===0?null:(0,R.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,R.jsx)(I3,{record:e,autoFocus:n&&t===0,siblings:a},e.id))}):null}function F3({record:e,questions:t,autoFocus:n,siblings:r}){let i=qe(),a=B3(e,r),o=(0,L.useRef)(null),s=(0,L.useRef)(new Map),c=wH(),l=a3(e.delivery?.effect),u=(0,L.useMemo)(()=>m3(e).find(e=>e.semantic===`answer`),[e]),d=DH(t.flatMap(t=>t.notesFieldId?[CH.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId)]:[])),[f,p]=(0,L.useState)(()=>t.map(()=>({chosen:null,chosenSet:[]}))),m=t.map((t,n)=>({chosen:f[n]?.chosen??null,chosenSet:f[n]?.chosenSet??[],text:t.notesFieldId?d.get(CH.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId))??``:``})),h=j3(t,m),[g,_]=(0,L.useState)(),[v,y]=(0,L.useState)(!1);(0,L.useEffect)(()=>{if(!n)return;let e=document.activeElement;e&&e!==document.body||requestAnimationFrame(()=>o.current?.focus())},[n,e.id]);let b=pt({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=>{y(!0),EC(i,t.interaction),i.invalidateQueries({queryKey:wC(e.owner.threadSlug,e.owner.sessionId)}),i.invalidateQueries({queryKey:TC(e.owner.threadSlug,e.owner.sessionId,e.id)})},onError:t=>{DC(i,e),a.rollback(),_(M3(t))}}),x=()=>{if(!u||!h||b.isPending||v||!l.actionsEnabled)return;_(void 0);let e=x3(u.id,h),t=s.current.get(e)??N3();s.current.set(e,t),a.release(!0),b.mutate({decisionId:u.id,values:h,responseId:t})},S=(t,n)=>{t.notesFieldId&&bH.set(CH.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId),n)};return(0,R.jsxs)(`article`,{ref:o,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,R.jsx)(B1,{question:e.question,interactive:l.actionsEnabled&&!v?{answer:m[t],onChip:n=>{p(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=>{S(e,n),e.question.kind!==`multi`&&p(e=>e[t]?.chosen===null||e[t]===void 0?e:e.map((e,n)=>n===t?{...e,chosen:null}:e))},onSubmit:x}:void 0},e.optionFieldId??e.notesFieldId??t)),g&&(0,R.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-danger-soft`,children:g}),(l.status||b.isPending||v)&&(0,R.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[11px] leading-snug text-muted`,children:l.status??(v?`Answer sent.`:`Sending…`)}),l.actionsEnabled&&!v&&(0,R.jsx)(`div`,{className:`flex justify-start`,children:(0,R.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:!h||b.isPending,onClick:x,onMouseDown:e=>e.preventDefault(),className:`button-outline 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 I3({record:e,autoFocus:t=!1,siblings:n}){let r=(0,L.useMemo)(()=>k3(e),[e]),i=n??[e];return r?(0,R.jsx)(F3,{record:e,questions:r,autoFocus:t,siblings:i}):(0,R.jsx)(V3,{record:e,autoFocus:t,siblings:i})}function L3(e){return e.semantic!==`cancel`}var R3=new Set,z3=new Set;function B3(e,t){let n=(0,L.useContext)(B8),r=e.owner.threadSlug;return{release:i=>{R3.add(e.id),i&&t.every(t=>t.id===e.id||R3.has(t.id)||t.delivery?.effect===`sending`)&&(z3.add(r),uW(r),n?.dismiss())},rollback:()=>{R3.delete(e.id),z3.delete(r)&&(dW(r),n?.cancel())}}}function V3({record:e,autoFocus:t=!1,siblings:n}){let r=qe(),i=B3(e,n),a=(0,L.useId)(),o=(0,L.useRef)(null),s=(0,L.useRef)(new Map),c=e.payload.kind===`mcp-elicitation-form`||e.payload.kind===`agent-question`?e.payload.fields:[],l=c.some(e=>e.secret),u=wH(),d=c.filter(e=>!e.secret&&(e.input===`text`||e.input===`multiline`)).map(t=>CH.interaction(u,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.id)),f=DH(d),[p,m]=(0,L.useState)(()=>v3(c)),h=(0,L.useMemo)(()=>{let t={...p};return c.forEach(n=>{if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=CH.interaction(u,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id);t[n.id]=f.get(r)??``}}),t},[c,p,f,u,e.id,e.owner]),[g,_]=(0,L.useState)({}),[v,y]=(0,L.useState)(),[b,x]=(0,L.useState)(),[S,C]=(0,L.useState)(!1),[w,T]=(0,L.useState)(),[E,D]=(0,L.useState)(!1),O=a3(e.delivery?.effect),k=(0,L.useMemo)(()=>m3(e),[e]).filter(e=>!(l&&e.requiresValues)),A=e.allowedDecisions.length-k.length,j=(0,L.useCallback)(t=>{for(let n of c)if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=t[n.id];typeof r==`string`&&bH.set(CH.interaction(u,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id),r)}m(t)},[c,u,e.id,e.owner]);(0,L.useEffect)(()=>{if(!t)return;let e=document.activeElement;e&&e!==document.body||requestAnimationFrame(()=>o.current?.focus())},[t,e.id]),(0,L.useEffect)(()=>{O.actionsEnabled||(T(void 0),D(!1))},[O.actionsEnabled]);let M=pt({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,n)=>{t.waitingForProvider||s.current.delete(x3(n.decision.id,n.values)),y(void 0),T(void 0),D(!1),C(!0),d.forEach(e=>bH.clear(e)),x(t.waitingForProvider?`Response sent. Waiting for the provider to acknowledge it…`:`Request completed.`),EC(r,t.interaction),r.setQueryData(TC(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t.interaction}),r.invalidateQueries({queryKey:wC(e.owner.threadSlug,e.owner.sessionId),exact:!0}),t.waitingForProvider&&window.setTimeout(()=>{r.invalidateQueries({queryKey:wC(e.owner.threadSlug,e.owner.sessionId),exact:!0})},1e3)},onError:t=>{x(void 0),i.rollback(),y(M3(t)),DC(r,e),Y.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{EC(r,t),r.setQueryData(TC(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t}),t.delivery?.effect===`sending`?(y(void 0),x(void 0),C(!0)):t.delivery?.effect===`reconnect-required`?(y(void 0),x(void 0)):(t.lifecycle!==`pending`||t.recordRevision!==e.recordRevision)&&(y(void 0),x(t.lifecycle===`expired`?`This request expired.`:`This request changed in another client.`),r.invalidateQueries({queryKey:wC(e.owner.threadSlug,e.owner.sessionId),exact:!0})),r.invalidateQueries({queryKey:wC(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}});function N(e){if(!e.requiresValues){_({});return}let t=b3(c,h);return _(t.errors),t.formError?(y(t.formError),null):t.values?t.values:null}function P(e,t=!1){if(!O.actionsEnabled||M.isPending||S)return;y(void 0);let n=N(e);if(n===null)return;if(e.durable&&!t){T(e),D(!1);return}let r=x3(e.id,n),a=s.current.get(r)??N3();s.current.set(r,a),i.release(L3(e)),M.mutate({decision:e,values:n,responseId:a})}let F=k.find(e=>e.requiresValues&&e.tone===`primary`);function I(e){e.preventDefault(),O.actionsEnabled&&F&&P(F)}return(0,R.jsxs)(`article`,{ref:o,tabIndex:-1,"aria-labelledby":a,"data-interaction-id":e.id,"data-interaction-kind":e.payload.kind,"data-delivery-effect":e.delivery?.effect,className:`min-w-0 ${KQ} border border-question-border bg-question outline-none focus-visible:ring-2 focus-visible:ring-focus-accent-60`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 border-b border-question-border px-4 py-3`,children:[(0,R.jsx)($_,{"aria-hidden":`true`,size:16,className:`shrink-0 text-accent`}),(0,R.jsx)(`h3`,{id:a,className:`min-w-0 flex-1 break-words text-[14px] font-semibold leading-snug text-fg`,children:e.payload.title})]}),(0,R.jsx)(`form`,{onSubmit:I,onKeyDown:e=>{e.target instanceof HTMLButtonElement||_z({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(),O.actionsEnabled&&F&&P(F))},className:`min-w-0 px-4 py-3.5`,noValidate:!0,children:(0,R.jsxs)(`fieldset`,{disabled:!O.actionsEnabled,className:`min-w-0 border-0 p-0`,children:[(0,R.jsx)(`legend`,{className:`sr-only`,children:`Interaction request`}),(0,R.jsx)(U3,{record:e,instanceId:a,draft:h,setDraft:j,errors:g,autoFocus:t}),l&&(0,R.jsxs)(`div`,{"data-secret-fallback":!0,className:`mt-3 rounded-md border border-attention-fill/35 bg-attention-fill/[0.07] p-3 text-[12px] leading-snug text-attention-soft-90`,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(j_,{"aria-hidden":`true`,size:14,className:`mt-0.5 shrink-0`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`font-medium`,children:`Secret input is unavailable in this page.`}),(0,R.jsx)(`div`,{className:`mt-1 text-attention-soft-70`,children:`Frizz will not persist or send secret values through the current RPC.`})]})]}),(0,R.jsx)(`div`,{className:`mt-2 font-medium`,children:`Use the provider's trusted secret-input flow. The thread terminal cannot answer this typed request.`})]}),A>0&&(0,R.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-md border border-attention-fill/25 bg-attention-fill/[0.05] px-3 py-2 text-[11px] leading-snug text-attention-soft-75`,children:[(0,R.jsx)(ov,{"aria-hidden":`true`,size:13,className:`mt-0.5 shrink-0`}),(0,R.jsxs)(`span`,{children:[A===1?`One advertised choice`:`${A} advertised choices`,` cannot be safely labeled or delivered in Frizz and is not shown.`]})]}),w&&(0,R.jsxs)(`div`,{"data-durable-confirmation":!0,role:`group`,"aria-label":`Confirm ${w.label}`,className:`mt-3 rounded-md border border-attention/45 bg-attention-fill/[0.08] p-3`,children:[(0,R.jsx)(`div`,{className:`text-[12px] font-semibold text-attention-soft`,children:`This approval persists beyond the current request.`}),(0,R.jsx)(`div`,{className:`mt-1 text-[11px] leading-snug text-attention-soft-75`,children:w.scope}),(0,R.jsxs)(`label`,{className:`mt-2.5 flex cursor-pointer items-start gap-2 text-[11px] leading-snug text-fg/85`,children:[(0,R.jsx)(`input`,{type:`checkbox`,autoFocus:!0,checked:E,onChange:e=>D(e.target.checked),className:`mt-0.5 accent-[var(--color-accent)]`}),(0,R.jsx)(`span`,{children:`I understand this may authorize later matching actions in this session.`})]}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-start gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>{T(void 0),D(!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,R.jsxs)(`button`,{type:`button`,disabled:!E||M.isPending,onClick:()=>P(w,!0),className:`rounded-md border border-attention/50 bg-attention-fill/15 px-2.5 py-1.5 text-[11px] font-semibold text-attention-faint hover:bg-attention-fill/25 disabled:opacity-35`,children:[`Confirm `,w.label.toLowerCase()]})]})]}),v&&(0,R.jsx)(`div`,{role:`alert`,className:`mt-3 break-words text-[11px] leading-snug text-danger-soft`,children:v}),(O.status??b)&&(0,R.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`mt-3 text-[11px] leading-snug text-muted`,children:O.status??b}),O.actionsEnabled&&!w&&!S&&k.length>0&&(0,R.jsxs)(`div`,{className:`mt-4 flex flex-wrap justify-start gap-2`,children:[k.map(e=>(0,R.jsxs)(`button`,{type:e===F?`submit`:`button`,"data-interaction-decision":e.id,disabled:M.isPending,"aria-describedby":e.durable?`${a}-scope-${e.id}`:void 0,onClick:e===F?void 0:()=>P(e),className:H3(e),children:[M.isPending?`Sending…`:e.label,e.durable&&(0,R.jsx)(`span`,{className:`sr-only`,children:`; persistent approval`})]},e.id)),k.filter(e=>e.durable).map(e=>(0,R.jsx)(`span`,{id:`${a}-scope-${e.id}`,className:`sr-only`,children:e.scope},`scope-${e.id}`))]}),!W3.has(e.payload.kind)&&(0,R.jsx)(q3,{record:e})]})})]})}function H3(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-focus-ink-50 disabled:opacity-40`;return e.tone===`primary`?`${t} border-border-strong bg-panel-2 text-fg hover:bg-inset`:e.tone===`danger`?`${t} border-danger/35 bg-danger-fill/[0.07] text-danger-faint hover:bg-danger-fill/15`:`${t} border-border bg-panel text-muted hover:bg-panel-2 hover:text-fg`}function U3({record:e,instanceId:t,draft:n,setDraft:r,errors:i,autoFocus:a}){let o=e.payload,s=(e,t)=>r(y3(n,e,t)),c;return c=o.kind===`command-approval`||o.kind===`file-approval`||o.kind===`permission-approval`?(0,R.jsx)(X4,{payload:o}):o.kind===`mcp-elicitation-url`?(0,R.jsx)(K3,{url:o.url}):(0,R.jsx)(J3,{instanceId:t,fields:o.fields,draft:n,setValue:s,errors:i,autoFocus:a}),(0,R.jsxs)(R.Fragment,{children:[`message`in o&&o.message&&(0,R.jsx)(G3,{text:o.message}),(0,R.jsx)(`div`,{className:`message`in o&&o.message?`mt-3`:``,children:c})]})}var W3=new Set([`command-approval`,`file-approval`,`permission-approval`]);function G3({text:e}){return e.length>600||e.split(`
|
|
326
|
-
`).length>6?(0,R.jsxs)(`details`,{className:`rounded-md border border-border/70 bg-panel/60`,children:[(0,R.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-focus-ink-50`,children:`Request message`}),(0,R.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,R.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-[12px] leading-relaxed text-fg/80`,children:e})}function K3({url:e}){let t=S3(e,location.href);return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] font-medium text-fg`,children:`Open this page to continue`}),(0,R.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,R.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,R.jsx)(g_,{"aria-hidden":`true`,size:12}),`Open page`]}):(0,R.jsx)(`div`,{role:`alert`,className:`mt-1.5 break-words text-[11px] text-danger-soft`,children:`This request did not provide a safe http(s) URL.`})]})}function q3({record:e}){return(0,R.jsxs)(`details`,{className:`mt-3 border-t border-border/50 pt-2 text-[10.5px] text-muted-70`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer w-fit outline-none hover:text-muted focus-visible:ring-1 focus-visible:ring-focus-ink-50`,children:`Request details`}),(0,R.jsxs)(`dl`,{className:`mt-2 grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1`,children:[(0,R.jsx)(`dt`,{children:`Provider`}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:h3(e.provider.kind)}),e.provider.name&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`dt`,{children:`Reported name`}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.provider.name})]}),e.provider.version&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`dt`,{children:`Reported version`}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.provider.version})]}),(0,R.jsx)(`dt`,{children:`Source`}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:g3(e.source.kind)}),e.source.label&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`dt`,{children:`Reported source`}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.source.label})]}),(0,R.jsx)(`dt`,{children:`Scope`}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:`This thread · this request`}),e.expiresAt&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`dt`,{children:`Expires`}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.expiresAt})]})]})]})}function J3({instanceId:e,fields:t,draft:n,setValue:r,errors:i,autoFocus:a}){let o=t.findIndex(e=>!e.secret);return(0,R.jsxs)(`fieldset`,{className:`min-w-0`,children:[(0,R.jsx)(`legend`,{className:`sr-only`,children:`Requested information`}),(0,R.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:t.map((t,s)=>(0,R.jsx)(Y3,{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 Y3({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,R.jsxs)(R.Fragment,{children:[t.label,t.required&&(0,R.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-focus-accent-40`,f;if(t.secret)f=(0,R.jsx)(`div`,{className:`mt-1 text-[11px] text-attention-soft-70`,children:`Use the secure fallback below.`});else if(t.input===`multiline`)f=(0,R.jsx)(`textarea`,{id:o,name:t.id,"data-1p-ignore":!0,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,R.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,R.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,R.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,R.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,R.jsx)(`span`,{children:u})]});else if(t.input===`select`)f=(0,R.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,R.jsx)(`option`,{value:``,children:`Choose an option…`}),t.options.map((e,t)=>(0,R.jsx)(`option`,{value:String(t),children:e.label},t))]});else if(t.input===`multi-select`){let e=Array.isArray(n)?n:[];f=(0,R.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,R.jsx)(`legend`,{className:`px-1 text-[11px] font-medium text-fg/85`,children:u}),(0,R.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t.options.map((n,i)=>{let o=String(i);return(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-[12px] text-fg/85`,children:[(0,R.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,R.jsx)(`span`,{children:n.label})]},o)})})]})}return(0,R.jsxs)(`div`,{className:`min-w-0`,children:[t.secret?(0,R.jsx)(`div`,{className:`text-[11px] font-medium text-fg/85`,children:u}):t.input!==`boolean`&&t.input!==`multi-select`?(0,R.jsx)(`label`,{htmlFor:o,className:`block text-[11px] font-medium text-fg/85`,children:u}):null,t.description&&(0,R.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,R.jsx)(`div`,{id:c,role:`alert`,className:`mt-1 text-[10.5px] text-danger-soft`,children:i})]})}function X3({steps:e}){return(0,R.jsx)(`div`,{"data-awaiting-steps":!0,className:`md-body ${GQ} mt-[var(--md-step)] first:mt-0`,children:(0,R.jsx)(`ol`,{children:e.map((e,t)=>(0,R.jsx)(Z3,{md:e},t))})})}function Z3({md:e}){return(0,R.jsx)(`li`,{children:(0,R.jsx)(uQ,{className:`md-body`,html:SX(e)})})}function Q3({slug:e,onReplied:t,onReplyFailed:n}){let r=OW(e),[i,a]=(0,L.useState)(!1);return(0,R.jsx)(a$,{"data-awaiting-steps-reply":!0,children:(0,R.jsx)(`button`,{type:`button`,"data-steps-done":!0,disabled:i,onClick:()=>{a(!0),r.submit(`Done`,{onOptimistic:()=>t?.(),onRollback:()=>{a(!1),n?.()}})||a(!1)},onMouseDown:e=>e.preventDefault(),className:`${c$} disabled:opacity-60`,children:PW})})}function $3(e){return(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).length}function e6(e,t={}){let n=(e.subAgents??[]).filter(e=>Au(e)&&e.state===`running`).length,r=(e.bgShells??[]).filter(e=>e.state===`running`).length,i=t.watchers===!1?0:$3(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 t6(e){return(e.subAgents??[]).some(e=>Au(e)&&e.state===`running`)}function n6(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length}function r6(e){return t6(e)||n6(e)>0}function i6(e,t){return Yu(t)??(a6(e)?`Background shells running`:`Awaiting`)}function a6(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length>0&&!t6(e)&&$3(e)===0&&o6(e).length===0}function o6(e){return(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`)}var s6={id:``,subAgents:[],bgShells:[],watches:[]},c6=[];function l6(e,t){if(t.length===0||e?.runtime!==`turn-idle`||e.lastFence?.kind!==`awaiting`)return!1;let n=Gu(e.lastFence.hints);return n.length===t.length&&n.every((e,n)=>e===t[n])}function u6(e,t){let n=new Set((e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).map(e=>e.target));return FW(t).filter(e=>!n.has(e.ref))}function d6({watch:e}){return(0,L.useEffect)(()=>{e.url&&eh([e.ref])},[e.url,e.ref]),e.url?(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-gh-ref":e.ref,className:`${s$} text-[12px]`,children:e.ref}):(0,R.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.ref})}var f6={mergeable:`no conflicts`,blocked:`merge blocked`,conflicting:`has conflicts`,unknown:null};function p6(e){return e.state!==`open`||e.merge===`blocked`&&e.checks!==`passing`&&e.checks!==`none`?null:f6[e.merge]}var m6=`shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`;function h6({tone:e}){return(0,R.jsx)(`span`,{"aria-hidden":!0,className:`inline-block size-3 rounded-full border ${e} border-t-transparent motion-safe:animate-spin ${m6}`})}function g6(){return(0,R.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 16 16`,width:12,height:12,fill:`none`,stroke:`currentColor`,overflow:`visible`,className:m6,style:{color:QO.fgAttention},children:[(0,R.jsx)(`circle`,{cx:`8`,cy:`8`,r:`4`,fill:`currentColor`,stroke:`none`}),(0,R.jsxs)(`g`,{strokeWidth:`2`,className:`origin-center motion-safe:animate-spin`,children:[(0,R.jsx)(`circle`,{cx:`8`,cy:`8`,r:`7`,opacity:`0.25`}),(0,R.jsx)(`path`,{d:`M15 8A7 7 0 0 1 8 15`})]})]})}function _6({status:e}){return e?e.state===`merged`?(0,R.jsx)(S_,{size:12,className:m6,style:{color:QO.fgDone}}):e.state===`closed`?(0,R.jsx)(C_,{size:12,className:m6,style:{color:QO.fgDanger}}):e.checks===`failing`?(0,R.jsx)(f_,{size:12,className:m6,style:{color:QO.fgDanger}}):e.checks===`passing`?(0,R.jsx)(s_,{size:12,className:m6,style:{color:QO.fgSuccess}}):e.gated>0&&e.running===0?(0,R.jsx)(o_,{size:12,className:m6,style:{color:QO.fgAttention}}):e.checks===`running`?(0,R.jsx)(g6,{}):(0,R.jsx)(c_,{size:12,className:`${m6} text-muted-60`}):(0,R.jsx)(c_,{size:12,className:`${m6} text-muted-60`})}function v6(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 y6(e){if(!e)return`Checking…`;if(e.state===`merged`)return`Merged`;if(e.state===`closed`)return`Closed`;let t=v6(e),n=p6(e);return[t||`No checks`,n].filter(e=>e!==null).join(` · `)}function b6(e){if(!e)return`Checking…`;if(e.state===`open`&&e.failed===0){if(e.merge===`conflicting`)return`conflicts`;if(e.merge===`blocked`&&e.checks===`passing`)return`blocked`}return uk(e)}var x6=`group relative flex items-baseline rounded-sm px-2 text-[12px] leading-5`,S6=`ml-1.5 font-medium text-fg/90`,C6=`${S6} line-clamp-2 break-words`,w6=`${S6} min-w-0 flex-1 truncate`,T6=`ml-3 min-w-0 truncate text-right text-muted-70`,E6=`min-w-1/2 flex-1`,D6=`outline-none after:absolute after:inset-0 after:rounded-sm focus-visible:after:ring-1 focus-visible:after:ring-fg/60`;function O6(){return(0,R.jsx)(r_,{size:13,"aria-hidden":!0,className:`${m6} ml-[3px] -mr-[4px] text-muted-35 transition-colors group-hover:text-muted-70`})}function k6({mark:e,name:t,status:n,onOpen:r,onPrewarm:i,href:a,ghRef:o,title:s,testKind:c,testId:l,indent:u,dismiss:d,oneLine:f}){let p=u!==void 0,m=f?`${S6} truncate`:C6,h=p?w6:d?`${m} min-w-0`:`${m} ${E6}`,g=a?(0,R.jsx)(`a`,{href:a,target:`_blank`,rel:`noreferrer noopener`,title:s,"data-gh-ref":o,onMouseDown:e=>e.stopPropagation(),className:`${h} ${D6} group-hover:underline group-hover:decoration-fg/40 group-hover:underline-offset-2`,children:t}):r?(0,R.jsx)(`button`,{type:`button`,onClick:r,onMouseDown:e=>e.stopPropagation(),title:s,className:`${h} ${D6} text-left group-hover:underline group-hover:decoration-fg/40 group-hover:underline-offset-2`,children:t}):(0,R.jsx)(`span`,{className:h,title:s,children:t}),_=!!(a||r),v=d&&(0,R.jsx)(`button`,{type:`button`,onClick:d.onDismiss,onMouseDown:e=>e.stopPropagation(),title:d.title,"aria-label":d.label,className:`relative ml-0.5 shrink-0 self-start mt-[2.5px] 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-focus-ink-60`,children:(0,R.jsx)(cv,{size:11})});return(0,R.jsxs)(`div`,{"data-wait-row":l,"data-wait-kind":c,onMouseEnter:i,onFocus:i,style:p?{paddingLeft:8+u}:void 0,className:`${x6} ${_?`cursor-pointer transition-colors hover:bg-fg/[0.045]`:``}`,children:[(0,R.jsx)(`span`,{className:`flex shrink-0`,children:e}),v?(0,R.jsxs)(`span`,{className:`flex items-baseline ${E6}`,children:[g,v]}):g,(0,R.jsx)(`span`,{"data-wait-status":!0,className:T6,children:n}),_?(0,R.jsx)(O6,{}):(0,R.jsx)(`span`,{"aria-hidden":!0,className:`w-3 shrink-0`})]})}function A6({status:e}){return e?e.state===`closed`?e.stateReason===`not_planned`||e.stateReason===`duplicate`?(0,R.jsx)(d_,{size:12,className:`${m6} text-muted`}):(0,R.jsx)(s_,{size:12,className:m6,style:{color:QO.fgDone}}):(0,R.jsx)(l_,{size:12,className:m6,style:{color:QO.fgSuccess}}):(0,R.jsx)(c_,{size:12,className:`${m6} text-muted-60`})}function j6(e){if(!e)return`Checking…`;if(e.state===`closed`){let t=e.stateReason===`not_planned`?`not planned`:e.stateReason===`duplicate`?`duplicate`:null;return t?`Closed as ${t}`:`Closed`}return`Open · ${e.comments} comment${e.comments===1?``:`s`}`}function M6({watch:e}){if(e.subject===`issue`)return(0,R.jsx)(N6,{watch:e});let t=e.github,n=AW(e.target);return(0,L.useEffect)(()=>{n&&eh([e.target])},[n,e.target]),(0,R.jsx)(k6,{testKind:`github`,testId:e.target,mark:(0,R.jsx)(_6,{status:t}),name:e.target,href:n??void 0,ghRef:n?e.target:void 0,title:n?`Open ${e.target} on GitHub — ${y6(t)}`:e.target,status:t&&t.state===`open`&&t.failed>0&&n?(0,R.jsx)(`a`,{href:`${n}/checks`,target:`_blank`,rel:`noreferrer noopener`,title:`View the failing checks on ${e.target}`,onMouseDown:e=>e.stopPropagation(),className:`relative underline underline-offset-2 ${$O}`,children:b6(t)}):b6(t)})}function N6({watch:e}){let t=e.issue,n=AW(e.target,`issue`);return(0,L.useEffect)(()=>{n&&eh([e.target])},[n,e.target]),(0,R.jsx)(k6,{testKind:`github`,testId:`issue:${e.target}`,mark:(0,R.jsx)(A6,{status:t}),name:t?.title?`${e.target} ${t.title}`:e.target,href:n??void 0,ghRef:n?e.target:void 0,title:n?`Open ${e.target} on GitHub — ${j6(t)}`:e.target,status:t?dk(t):`Checking…`})}function P6(e,t){return(e.bgShells??[]).find(e=>e.id===t||e.taskId===t||e.label===t)}function F6(e){return(e.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`)}function I6({watch:e,thread:t,slug:n,now:r}){let i=P6(t,e.target);if(i)return(0,R.jsx)(R6,{shell:i,slug:n,now:r,testId:e.target});let a=JO(e.createdAt,r);return(0,R.jsx)(k6,{testKind:`shell`,testId:e.target,mark:(0,R.jsx)(rv,{size:12,className:`${m6} text-shell`}),name:e.target,title:e.target,status:a})}function L6(e,t,n,r,i){if(!e||t&&n)return;let a=t?`running`:`settled`;return{onDismiss:e,title:pk[a],label:`${mk[a]} ${hk[r]}: ${i}`}}function R6({shell:e,slug:t,now:n,testId:r,onDismiss:i}){let a=JO(e.startedAt,n),o=e.state===`running`,s=e.id&&!e.outputUnavailable,c=o?`running for ${a}`:sk;return(0,R.jsx)(k6,{testKind:`shell`,testId:r??e.id??e.label,mark:(0,R.jsx)(rv,{size:12,className:`${m6} ${o?`text-shell`:`text-muted-60`}`}),name:e.label,onOpen:s?()=>Yh(t,e.id,{label:e.label,startedAt:e.startedAt}):void 0,title:s?`Read this shell's output — ${c}`:o?e.label:`${e.label} — ${c}`,status:a,dismiss:L6(i,o,!!s,`SHELL`,e.label)})}function z6({watch:e,now:t}){let n=Date.parse(e.timer?.fireAt??``),r=Number.isFinite(n)?n>t?`in ${KO(n-t)}`:`firing…`:`armed`,i=e.timer?.prompt;return(0,R.jsx)(k6,{testKind:`timer`,testId:e.target,mark:(0,R.jsx)(p_,{size:12,className:`${m6} text-muted-60`}),name:i||e.target,oneLine:!0,title:[i,e.timer?.fireAt?`One-off timer, set for ${e.timer.fireAt}`:e.target].filter(Boolean).join(`
|
|
325
|
+
`);return(0,R.jsxs)(`button`,{type:`button`,role:t?`checkbox`:`radio`,"aria-checked":n,"data-answer-option":!0,"data-on":n||void 0,onClick:e=>{e.target.closest(`[data-lightbox-tile], img[data-local-path]`)||r()},className:`${P0} text-left`,children:[(0,R.jsx)(L0,{multi:t,on:n}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,R.jsxs)(`span`,{className:`block text-[15.5px] font-medium leading-[21px] text-fg`,children:[e.label,e.recommended&&(0,R.jsx)(`span`,{className:`ml-1.5 text-[11px] font-bold tracking-[0.02em] text-accent`,children:`RECOMMENDED`})]}),i&&(0,R.jsx)(`span`,{className:`mt-px block text-[13px] leading-[18px] text-muted`,children:i}),a&&(0,R.jsx)(I0,{md:a})]})]})}function I0({md:e}){return(0,R.jsx)(`div`,{className:`card-md mt-1 text-muted`,children:(0,R.jsx)(uQ,{className:`md-body`,html:SX(e)})})}function L0({multi:e,on:t,dashed:n=!1}){return(0,R.jsx)(`span`,{"aria-hidden":!0,className:`mt-[0.5px] flex size-5 shrink-0 items-center justify-center border-[1.5px] ${e?`rounded-[5px]`:`rounded-full`} ${n?`border-dashed`:``} ${t?e?`border-fg bg-fg text-bg`:`border-fg`:`border-border-strong`}`,children:t&&(e?(0,R.jsx)(e_,{size:14,strokeWidth:3}):(0,R.jsx)(`span`,{className:`size-2.5 rounded-full bg-fg`}))})}function R0({a:e,step:t,autoFocus:n,placeholder:r}){let i=(0,L.useRef)(null),a=e.answerFor(t.q,t.path).text,o=t.spec.kind===`multi`;return(0,L.useLayoutEffect)(()=>{let e=i.current;e&&(e.style.height=`auto`,e.style.height=`${e.scrollHeight+e.offsetHeight-e.clientHeight}px`)},[a]),(0,L.useEffect)(()=>{n&&i.current?.focus()},[n]),(0,R.jsx)(`div`,{className:`px-[18px] ${(t.spec.options??[]).length===0?``:`pt-3`}`,children:(0,R.jsx)(`textarea`,{ref:i,"data-answer-text":!0,"data-1p-ignore":!0,"data-claims-escape":!0,rows:(t.spec.options??[]).length===0?3:1,value:a,placeholder:r,onChange:n=>e.onText(t.q,t.path,o,n.target.value),onFocus:()=>{o||e.onText(t.q,t.path,!1,a)},className:`block max-h-[40vh] w-full resize-none overflow-y-auto rounded-[12px] border border-border-strong bg-bg px-3 py-[11px] text-[16px] leading-[22px] text-fg outline-none placeholder:text-faint focus:border-fg/40`})})}function z0({a:e,step:t,text:n}){return(0,R.jsxs)(`div`,{className:`px-[18px]`,children:[(0,R.jsx)(`input`,{type:`password`,"data-answer-text":!0,"data-secret-answer":!0,"data-claims-escape":!0,autoComplete:`off`,autoCorrect:`off`,autoCapitalize:`off`,spellCheck:!1,"aria-label":`Secret value`,value:n,placeholder:`Paste the value…`,onChange:n=>e.onText(t.q,t.path,!1,n.target.value),className:`block w-full rounded-[12px] border border-border-strong bg-bg px-3 py-[11px] text-[16px] leading-[22px] text-fg outline-none placeholder:text-faint focus:border-fg/40`}),(0,R.jsx)(`div`,{className:`mt-2 text-[13px] leading-[18px] text-muted`,children:`Held in memory on the machine running Frizz and handed to one command, once. The worker never sees it.`})]})}function B0({a:e,step:t,first:n,writing:r,onBack:i,onNext:a}){let o=e.answerFor(t.q,t.path),s=i0(t.spec,o),c=t.spec.options??[],l=t.spec.kind!==`multi`&&o.chosen===null&&o.text.trim()!==``,u=t.spec.kind===`multi`||c.length===0||r||l;return(0,R.jsxs)(K0,{children:[(0,R.jsx)(`button`,{type:`button`,"data-answer-back":!0,disabled:n,onClick:i,className:`${U0} ${W0} disabled:opacity-35`,children:`Back`}),(0,R.jsx)(`span`,{className:`flex-1`}),!(u&&s)&&(0,R.jsx)(`button`,{type:`button`,"data-answer-skip":!0,onClick:a,className:`${U0} ${W0}`,children:s?`Next`:`Skip`}),u&&(0,R.jsx)(`button`,{type:`button`,"data-answer-continue":!0,disabled:!s,onClick:a,className:`${U0} ${G0} px-6 disabled:opacity-35`,children:`Continue`})]})}function V0({a:e,steps:t,onChange:n}){let r=t.map(t=>({s:t,said:p0(t.spec,e.answerFor(t.q,t.path))})),i=r.filter(e=>e.said!==null).length;return(0,R.jsxs)(`div`,{"data-answer-review":!0,children:[(0,R.jsx)(`div`,{className:`px-[18px] pb-3 pt-1 text-[17px] font-semibold leading-[23px] text-fg`,children:i===0?`No answers yet`:`${i} answer${i===1?``:`s`}`}),(0,R.jsx)(`div`,{className:`border-b border-border`,children:r.map(({s:e,said:t})=>(0,R.jsxs)(`button`,{type:`button`,"data-answer-change":e.key,onClick:()=>n(e.key),className:`block w-full border-t border-border px-[18px] py-2.5 text-left outline-none active:bg-hover focus-visible:bg-hover`,children:[(0,R.jsx)(`span`,{className:`line-clamp-2 block text-[13px] leading-[18px] text-muted`,children:q0(e.spec.question)}),(0,R.jsxs)(`span`,{className:`mt-0.5 flex items-baseline justify-between gap-2.5`,children:[(0,R.jsx)(`span`,{className:`min-w-0 break-words text-[15.5px] leading-[21px] ${t===null?`text-muted`:`font-medium text-fg`}`,children:t??`Skipped`}),(0,R.jsx)(`span`,{className:`shrink-0 text-[13.5px] text-muted`,children:`Change`})]})]},e.key))})]})}function H0({a:e,onSent:t}){return(0,R.jsx)(K0,{children:(0,R.jsx)(`button`,{type:`button`,"data-answer-send":!0,disabled:e.staged===0||e.sending,onClick:()=>{e.submit(),t()},className:`${U0} ${G0} flex-1 disabled:opacity-35`,children:e.sending?`Sending…`:`Send answers`})})}var U0=`flex h-[46px] shrink-0 items-center justify-center rounded-[12px] text-[15.5px] font-semibold outline-none`,W0=`px-[18px] text-muted active:bg-hover focus-visible:bg-hover`,G0=`bg-fg text-bg active:opacity-90`;function K0({children:e}){let t=(0,L.useRef)(null),[n,r]=(0,L.useState)(!1);(0,L.useEffect)(()=>{let e=0,n=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e=document.activeElement;r((e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement)&&t.current?.parentElement?.contains(e)===!0)})};return n(),document.addEventListener(`focusin`,n),document.addEventListener(`focusout`,n),()=>{cancelAnimationFrame(e),document.removeEventListener(`focusin`,n),document.removeEventListener(`focusout`,n)}},[]);let i=zz(t,n);return(0,R.jsxs)(`div`,{ref:t,"data-answer-footer":!0,className:`shrink-0`,children:[(0,R.jsx)(`div`,{className:`flex items-center gap-2.5 px-[18px] pt-3.5`,children:e}),i>0&&(0,R.jsx)(`div`,{"aria-hidden":!0,style:{height:i}})]})}function q0(e){return(e.trim().split(/\n\s*\n/)[0]??``).replace(/[`*_~]/g,``).replace(/\[([^\]]*)\]\([^)]*\)/g,`$1`).replace(/\s+/g,` `).trim()}function J0(e){let t=e?Date.parse(e):NaN;return Number.isFinite(t)?t:null}function Y0(e,t){return new Date(e).toDateString()===new Date(t).toDateString()}function X0(e,t,n){let r=null;return e.map(e=>{let i=J0(t(e)),a=J0(n(e))??i;if(i===null)return null;let o=r===null||!Y0(r,i)?`day`:i-r>=12e5?`time`:null;return r=Math.max(r??0,a??i),o})}function Z0(e,t,n=new Date,r){let i=new Date(Date.parse(e)),a=i.toLocaleTimeString(r,{hour:`numeric`,minute:`2-digit`});if(t===`time`)return{day:null,time:a};let o=e=>new Date(e.getFullYear(),e.getMonth(),e.getDate()).getTime(),s=Math.round((o(n)-o(i))/864e5);return{day:s===0?`Today`:s===1?`Yesterday`:s>1&&s<7?i.toLocaleDateString(r,{weekday:`long`}):i.toLocaleDateString(r,i.getFullYear()===n.getFullYear()?{month:`short`,day:`numeric`}:{month:`short`,day:`numeric`,year:`numeric`}),time:a}}function Q0(e){return(0,L.useSyncExternalStore)(e=>pr(X,e),()=>e?$0(e)!==`codex`:!1,()=>!1)}function $0(e){return Cg(X.board,e)?.backend}function e2(e,t,n,r){let i=CH.followUp(e,t,n);return xH(i,r),i}function t2(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 Lne(e){let t=qe(),n=wH(),[r,i]=(0,L.useState)(!1);return{unqueue:(0,L.useCallback)(a=>{if(!e||r)return;let o=Cg(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}zE(t,e,a.rawText,a.deliveryId),e2(n,e,o,a.text),t2(a.from)},e=>{i(!1),Z(`Couldn't unqueue — ${(e instanceof Error?e.message:String(e)).slice(0,160)}`)})},[r,n,t,e]),pending:r}}function n2(e){let t=qe(),n=wH(),[r,i]=(0,L.useState)(!1),a=(0,L.useCallback)(n=>{!e||r||DW(t,e,n.text,{supersedes:n.deliveryId,failureToast:e=>`Retry failed — ${e.slice(0,160)}`})},[r,t,e]),o=(0,L.useCallback)(async t=>{if(!e)return!1;i(!0);try{return await Y.dismissFailedFollowUp({slug:e,deliveryId:t}),!0}catch(e){return Z(`Couldn't dismiss — ${(e instanceof Error?e.message:String(e)).slice(0,160)}`),!1}finally{i(!1)}},[e]);return{retry:a,edit:(0,L.useCallback)(t=>{!e||r||(e2(n,e,Cg(X.board,e)?.sessionId,t.text),t2(t.from),o(t.deliveryId))},[o,r,n,e]),dismiss:(0,L.useCallback)(t=>{!e||r||o(t.deliveryId)},[o,r,e]),pending:r}}var r2=new Map;function i2(e,t){let n=(r2.get(e)??[]).filter(e=>e.deliveryId!==t.deliveryId);n.push(t),r2.set(e,n.slice(-8))}var a2=e=>e.replace(/\s+/g,` `).trim();function o2(e,t){let n=r2.get(e);if(!n?.length)return;let r=a2(t);for(let t=n.length-1;t>=0;t--){let i=a2(n[t].text);if(!i||!r.includes(i))continue;let[a]=n.splice(t,1);return n.length||r2.delete(e),a.deliveryId}}function s2(e){return(0,L.useSyncExternalStore)(e=>pr(X,e),()=>{if(!e)return!1;let t=Cg(X.board,e);return t?.backend!==`codex`&&t?.runtime===`running`},()=>!1)}function c2(e){let[t,n]=(0,L.useState)(!1);return{deliverNow:(0,L.useCallback)(()=>{if(!e||t)return;let r=Cg(X.board,e)?.sessionId;if(!r){Z(`This thread has no live session to interrupt`);return}n(!0),Y.deliverQueuedNow({slug:e,sessionId:r}).then(e=>{n(!1),e.interrupted||Z(e.reason??`That message could not be pushed through`)},e=>{n(!1),Z(`Couldn't push it through — ${(e instanceof Error?e.message:String(e)).slice(0,160)}`)})},[t,e]),pending:t}}function l2(e){return e.project?`${nm(e.project)}/thread/${e.slug}`:am(`/thread/${e.slug}`)}function u2({peer:e,text:t,queued:n,sourceId:r,at:i,wrap:a}){let o=gr(X),[s,c]=(0,L.useState)(!1),l=(0,L.useId)(),u=e.thread,d=u&&!u.project?Cg(o.board,u.slug):void 0,f=d?HD(d):u?.title,p=rZ(SX(t));return(0,R.jsxs)(`div`,{"data-frizz-msg":r,"data-session-message":!0,className:`flex flex-col ${n?`opacity-50`:``}`,children:[(0,R.jsxs)(t1,{icon:I_,marker:`session-message`,at:i,children:[u?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:`Message from`}),(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:`«`}),(0,R.jsx)(`a`,{href:l2(u),"data-session-peer-link":!0,title:`Open the thread that sent this`,onMouseDown:e=>e.preventDefault(),className:`min-w-0 truncate ${a1}`,children:f}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`»`})]})]}):(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name?`Message from session ${e.name}`:`Message from another session`}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,R.jsx)(`button`,{type:`button`,"data-session-message-toggle":!0,onClick:()=>c(e=>!e),onMouseDown:e=>e.preventDefault(),"aria-expanded":s,"aria-controls":l,className:`shrink-0 rounded-sm outline-none transition-colors hover:text-fg focus-visible:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:s?`Click to collapse`:`Click to expand`})]}),s&&(0,R.jsx)(`div`,{id:l,className:`card-md mt-1.5 border-l border-border/70 pl-3 text-muted`,children:(0,R.jsx)(`div`,{className:`md-body [overflow-wrap:anywhere]${a?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,dangerouslySetInnerHTML:p})})]})}function d2(e){return e.displayText??e.text}function f2(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.sessionPeer)return t}return-1}function p2(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.sessionPeer)&&!(n.wake&&!w$(n)))return t}return 0}var m2=`icon-label-nudge`,h2=`frizz-theme`,g2=`#0d0e10`,_2=`#f7f7f7`,v2=new Set,y2={preference:`system`,resolved:`dark`},b2,x2;function S2(e){return e===`light`||e===`dark`||e===`system`?e:`system`}function C2(e,t=w2()){return e===`system`?t?`dark`:`light`:e}function w2(){try{return b2?.matches??window.matchMedia(`(prefers-color-scheme: dark)`).matches}catch{return!1}}function T2(){try{return S2(localStorage.getItem(h2))}catch{return`system`}}function E2(e){let t=document.documentElement;t.dataset.theme=e.resolved,t.style.colorScheme=e.resolved,document.querySelector(`meta[name="theme-color"]`)?.setAttribute(`content`,e.resolved===`dark`?g2:_2)}function D2(e,t=w2()){let n={preference:e,resolved:C2(e,t)},r=n.preference!==y2.preference||n.resolved!==y2.resolved;if(r&&(y2=n),E2(n),r)for(let e of v2)e()}function O2(){return y2}function k2(e){D2(S2(e));try{localStorage.setItem(h2,y2.preference)}catch{}}function A2(e){return v2.add(e),()=>v2.delete(e)}function j2(){if(x2||typeof window>`u`)return x2;try{b2=window.matchMedia(`(prefers-color-scheme: dark)`)}catch{b2=void 0}D2(T2());let e=e=>{y2.preference===`system`&&D2(`system`,e.matches)};b2?.addEventListener(`change`,e);let t=e=>{try{if(e.storageArea&&e.storageArea!==localStorage)return}catch{return}e.key===`frizz-theme`?D2(S2(e.newValue)):e.key===null&&D2(`system`)};return window.addEventListener(`storage`,t),x2=()=>{b2?.removeEventListener(`change`,e),window.removeEventListener(`storage`,t),x2=void 0,b2=void 0},x2}function M2(e,t,n){return{type:`frizz-inline-vis-theme`,requestId:e,colorScheme:t,vars:n}}function N2(e,t){return typeof e==`object`&&!!e&&e.type===`frizz-inline-vis-applied`&&e.requestId===t}var P2=new Set([`planning`,`planned`,`active`,`needs-human`,`blocked`]);function F2(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&&P2.has(e.status))}var I2=`sticky top-0 z-10 flex min-w-0 shrink-0 items-center gap-2.5 border-b border-border bg-panel px-3 ${dv} 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`,L2=`flex min-w-0 flex-1 items-center gap-2.5 pl-1 max-[640px]:basis-full`,R2=`flex shrink-0 items-center max-[640px]:w-full`;function z2(e){return e?.trim()?{kind:`profile-error`,message:`Profile controls unavailable: ${e.trim().slice(0,160)}`}:null}function B2(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 open approval or question first`;if(e.backend===`codex`||e.backend===`acp`)return null;let t=[...e.subAgents??[],...e.bgShells??[]].filter(e=>e.state===`running`||e.state===`stale`).length;return t>0?`Wait for ${t} unresolved background operation${t===1?``:`s`}`:e.runtime===`running`||e.runtime===`spawning`?`Wait for the current turn to finish`:null}function V2(e){return e.permissionChangePending===!0||e.permissionPending!==void 0||e.profileChangePending===!0||e.runtimeControlPending===!0}function H2(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 U2(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 W2(e){let t=gr(X).board?.threads.find(t=>t.id===e),n=ct({queryKey:[`threadProfileOptions`,e],queryFn:()=>Y.threadProfileOptions({slug:e}),enabled:!!(t&&!t.foreign&&t.kind===`session`),staleTime:5e3}),r=pt({mutationFn:t=>Y.setThreadProfile({slug:e,model:t.model,...t.effort?{effort:t.effort}:{}})}),i=pt({mutationFn:t=>Y.setThreadPermission({slug:e,permissionMode:t})}),a=pt({mutationFn:t=>Y.upgradeThreadModel({slug:e,sessionId:t})}),o=r.isPending||i.isPending||a.isPending,s=t?.backend===`codex`?`codex`:t?.backend===`acp`?`acp`:`claude`,c=ct({queryKey:[`acpAgents`],queryFn:()=>Y.acpAgents(),enabled:!!t&&s===`acp`});if(!t||t.foreign||t.kind!==`session`)return{busy:o,footer:null,phoneTools:null,status:null};let l=o||V2(t),u=t.model?.trim(),d=t.effort?.trim(),f=s===`acp`?wu(u):void 0,p=s===`acp`?Tu(u):void 0,m=r.isPending?r.variables:void 0,h=t.profilePendingModel??m?.model,g=t.profilePendingEffort??m?.effort,_=s===`acp`&&m?Tu(m.model):void 0,v=n.data?.options??[],{modelSelectable:y}=U2(v,u,d,t.runtime===`exited`),b=n.data!==void 0,x=c.data?.find(e=>e.id===f)?.label??f,S=[{id:s,label:s===`codex`?`Codex`:`Claude Code`,options:v}],C=z2(n.isError?n.error.message:void 0),w=t.permissionMode?LB(t.permissionMode):`auto`,T=PB.some(e=>e.value===w)?w:`auto`,E=i.isPending?i.variables:T,D=B2(t);function O(e){e!==T&&i.mutate(e,{onSuccess:e=>Z(H2(e.effect,`claude`)),onError:e=>Z(`Permission change failed: ${e.message.slice(0,120)}`)})}let k=s===`claude`?B2(t):null;function A(){t?.sessionId&&a.mutate(t.sessionId,{onSuccess:e=>Z(`${e.label} from the next turn — the worker restarts then`),onError:e=>Z(`Upgrade failed: ${e.message.slice(0,120)}`)})}function j(e){r.mutate(e,{onSuccess:e=>Z(s===`acp`?e.effect===`next-resume`?`Model saved for the next resume`:`Model applied`:e.effect===`next-resume`?`Model and effort saved for the next resume`:`Model and effort applied`),onError:e=>Z(`Profile change failed: ${e.message.slice(0,120)}`)})}let M=(0,R.jsxs)(R.Fragment,{children:[s!==`acp`&&(0,R.jsx)(YV,{groups:S,value:{provider:s,model:u,effort:d},pending:h||g?{provider:s,model:h,effort:g}:void 0,onValueChange:({model:e,effort:t})=>j({model:e,effort:t}),placeholder:n.isPending?`Profile loading…`:`Profile unknown`,ariaLabel:`Thread model and effort`,menuAriaLabel:`Choose ${s===`codex`?`Codex`:`Claude Code`} model and effort`,title:y?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:l||!b||!y||n.isError,compact:!0,side:`top`,className:`min-w-0 max-w-[min(72%,20rem)] px-1.5 py-0.5`,runningModelLabel:t.runningModelLabel,upgrade:t.modelUpgrade&&t.runningModelLabel?{latest:t.modelUpgrade.label,staged:t.modelUpgrade.staged,blockedReason:k,pending:a.isPending,onUpgrade:A}:void 0}),s===`acp`&&f&&(0,R.jsx)($V,{agentId:f,agentLabel:x??f,modelId:_??p,onValueChange:e=>j({model:Su(f,e),effort:``}),disabled:l,side:`top`,className:`min-w-0 max-w-[min(72%,20rem)] px-1.5 py-0.5`})]});return{busy:l,footer:(0,R.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:[M,s===`claude`&&(0,R.jsx)(FV,{variant:`readout`,side:`top`,value:E,onValueChange:e=>O(e),options:PB,ariaLabel:`Thread permission mode`,title:D?`${D} — changing permissions restarts this thread's worker process`:E===`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:l||D!==null,className:`shrink-0`}),h&&g&&(0,R.jsxs)(`span`,{className:`min-w-0 truncate text-[9px] text-muted-50`,children:[`→ `,h,` · `,g,` pending`]})]}),phoneTools:M,status:C?(0,R.jsx)(`div`,{"data-thread-control-error":``,className:`px-1 pt-1 text-[9.5px] leading-tight text-muted-65`,children:C.message}):null}}function G2(e,t=RD.queueOrder){let n=yO(e,t),r=n.active.filter(Sf),i=n.active.filter(e=>!Sf(e));return[...n.pinned,...r,...i]}function K2(e,t,n=RD.queueOrder,r=$W()){return G2(e.map(e=>tG(e,r[e.id])),n).find(e=>e.id!==t&&e.needsYou===!0)}function q2(e){let t=K2(X.board?.threads??[],e);if(JE()){t&&window.addEventListener(`popstate`,()=>setTimeout(()=>Xh(t.id),0),{once:!0}),history.back();return}if(t){Xh(t.id);return}let n=X.drawers.filter(e=>!e.closing).map(e=>e.id);n.length&&_g(n)}var J2=new Map;async function Y2(e,t={}){let n=e.id,r=t.terminateLive===!0,i=r||BK(e),a=HD(e),o=()=>{ZW(n),q2(n),Z(`“${a}” marked done`,{action:{label:`Undo`,run:()=>void X2(n)}})};i&&o();let s=Y.completeThread({slug:n,sessionId:e.sessionId??``,terminateLive:r});J2.set(n,s);try{let e=await s;return e.needsConfirmation?(QW(n),i?(Z(e.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`,{link:{label:`Open`,slug:n}}),{kind:`declined`}):{kind:`needs-confirmation`,hold:e.hold}):(i||o(),{kind:`done`})}catch(e){return QW(n),Z(`Couldn’t finish: ${e.message.slice(0,80)}`,i?{link:{label:`Open`,slug:n}}:void 0),{kind:`failed`}}finally{J2.get(n)===s&&J2.delete(n)}}async function X2(e){await J2.get(e)?.catch(()=>void 0);try{await Y.setThreadState({slug:e,state:`open`}),QW(e),Xh(e)}catch(e){Z(`Couldn’t undo: ${e.message.slice(0,80)}`)}}function Z2({thread:e,compact:t}){let[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(null);async function o(t){r(!0),t&&a(null);let n=await Y2(e,{terminateLive:t});n.kind===`needs-confirmation`&&a({hold:n.hold}),n.kind!==`done`&&r(!1)}let s=VK(i?.hold);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,"data-phone-done":!0,onMouseDown:e=>e.preventDefault(),onClick:()=>void o(!1),disabled:n,"aria-label":`Mark as done`,className:`flex shrink-0 items-center justify-center gap-1 rounded-full bg-fg font-semibold text-bg disabled:opacity-45 ${t?`relative h-[36px] pl-[11px] pr-[14px] text-[14px] after:absolute after:inset-x-0 after:-inset-y-[4px] after:content-['']`:`h-[42px] pl-[13px] pr-[16px] text-[15px]`}`,children:[n&&!i?(0,R.jsx)(M_,{"aria-hidden":!0,size:t?15:17,className:`animate-spin`}):(0,R.jsx)(e_,{"aria-hidden":!0,size:t?15:17,strokeWidth:2.6,className:`translate-y-[0.1em]`}),`Done`]}),(0,R.jsx)(Oq,{open:i!==null,onOpenChange:e=>{!e&&!n&&a(null)},title:i?.hold?.cutOff?`Mark an unfinished thread done?`:`End this session?`,className:`w-[390px] max-w-[92vw]`,footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,disabled:n,onClick:()=>a(null),className:`button-outline h-[40px] rounded-md px-4 text-[14px] text-muted outline-none disabled:opacity-45`,children:`Cancel`}),(0,R.jsxs)(`button`,{type:`button`,"data-phone-done-confirm":!0,disabled:n,onClick:()=>void o(!0),className:`button-outline flex h-[40px] items-center gap-1.5 rounded-md bg-fg px-4 text-[14px] font-medium text-bg outline-none disabled:opacity-45`,children:[n&&(0,R.jsx)(M_,{size:14,className:`animate-spin`}),i?.hold?.cutOff?`Mark done anyway`:`End session & mark done`]})]}),children:(0,R.jsxs)(`div`,{"data-completion-hold":!0,className:`flex flex-col gap-2 p-4 text-[14px] leading-relaxed text-muted`,children:[(0,R.jsx)(`p`,{children:s.lead}),s.groups.map(e=>(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(`div`,{className:`text-[12px] font-medium text-fg/70`,children:e.heading}),(0,R.jsxs)(`ul`,{className:`flex flex-col gap-0.5`,children:[e.items.map((e,t)=>(0,R.jsxs)(`li`,{className:`min-w-0 truncate text-fg/80`,children:[e.label,e.stale&&(0,R.jsx)(`span`,{className:`text-muted-60`,children:` · no recent output`})]},`${e.label}-${t}`)),e.overflow>0&&(0,R.jsxs)(`li`,{className:`text-muted-60`,children:[`+`,e.overflow,` more`]})]})]},e.kind)),(0,R.jsx)(`p`,{children:s.trailer})]})})]})}var Q2=new Map;function $2(e){let t=Q2.get(e);if(t)return t;let n=Y.threadSkills({slug:e}).then(e=>e.skills,()=>(Q2.delete(e),[]));return Q2.set(e,n),n}function e4({slug:e,surface:t,className:n,id:r,above:i,submitOverride:a,phoneBarOverride:o,phoneChrome:s}){let c=gr(X),l=c.board?.threads.find(t=>t.id===e),u=l?.foreign?`Send a message to take over this session…`:l?.pendingQuestion||(l?.questions?.length??0)>0?`Or skip the questions and reply…`:`Reply to the agent…`,d=wH(),f=CH.followUp(d,e,l?.sessionId),[p,m,h]=EH(f),g=W2(e),_=OW(e),[v,y]=(0,L.useState)(null),b=(0,L.useMemo)(()=>()=>$2(e),[e]),[x,S]=(0,L.useState)(null),C=c.composerContext[e],w=(0,L.useMemo)(()=>C?.map(e=>e.token)??[],[C]);(0,L.useEffect)(()=>{let t=X.composerContext[e];if(!t?.length)return;let{prose:n}=oz(p),r=t.filter(e=>fz(n,e.token));r.length!==t.length&&(X.composerContext[e]=r)},[e,p,C]);let T=Jte(l,a!==void 0),E=Lg(),D=(s??E)&&t===`chatComposer`,O=l?.runtime===`running`||l?.runtime===`spawning`,k=l?.lastFence?.kind===`awaiting`&&Gu(l.lastFence.hints).length>0,A=l?zK(l).archive&&!O&&!k:!1,j=l&&l.kind===`session`&&l.foreign!==!0?(0,R.jsx)(hq,{thread:l}):void 0;function M(t=!1){let n=p.trim();if(!n)return;let r=iH(n);if(r){if(h(),l?.backend===`acp`){Z(`An ACP agent signs in through its own CLI — Frizz holds no account for it`);return}let e=l?.backend===`codex`?`codex`:`claude`;r===`login`?y(e):S(e);return}let i=fg(e),o=Ute(n,i,d),s={onOptimistic:h,supersedes:o2(f,o),onRollback:t=>{xH(f,p),pg(e,i),i2(f,{...t,text:p})}};a?a(o,s):_.submit(o,{...s,interrupt:t})}return D?(0,R.jsxs)(`div`,{"data-thread-composer-box":t,"data-thread-action-bar":``,"data-phone-thread-bar":``,children:[(0,R.jsx)(Hz,{contextTokens:w,id:r,surface:t,value:p,onChange:m,onSubmit:()=>M(),onInterruptSubmit:T?()=>M(!0):void 0,slashSuggest:b,placeholder:l?.foreign?u:O?`Steer…`:`Reply…`,busy:g.busy,phone:{layout:`bar`,tools:g.phoneTools,idlePrimary:A&&l?e=>(0,R.jsx)(Z2,{thread:l,compact:e}):void 0,override:o,onLongPressSend:T?()=>M(!0):void 0}}),g.status,v&&(0,R.jsx)(aH,{backend:v,onClose:()=>y(null),onAuthed:()=>y(null)}),x&&(0,R.jsx)(oH,{backend:x,onClose:()=>S(null)})]}):(0,R.jsxs)(`div`,{"data-thread-composer-box":t,...t===`chatComposer`?{"data-thread-action-bar":``}:{},className:n,children:[i,(0,R.jsx)(Hz,{contextTokens:w,id:r,surface:t,value:p,onChange:m,onSubmit:()=>M(),onInterruptSubmit:T?()=>M(!0):void 0,slashSuggest:b,placeholder:u,busy:g.busy,footer:g.footer,railLead:j}),g.status,v&&(0,R.jsx)(aH,{backend:v,onClose:()=>y(null),onAuthed:()=>y(null)}),x&&(0,R.jsx)(oH,{backend:x,onClose:()=>S(null)})]})}function t4({slug:e,above:t,phoneBarOverride:n,phoneChrome:r}){return gr(X).board?.threads.find(t=>t.id===e)?(0,R.jsx)(e4,{slug:e,surface:`chatComposer`,id:`followup-input`,className:`shrink-0 px-3 py-3`,above:t,phoneBarOverride:n,phoneChrome:r}):null}function n4(e,t=[]){let n=_k(e.subAgents??[],`card`),r=yk(e.bgShells??[],t),i=(e.watches??[]).filter(e=>e.kind===`github`),a=i.filter(e=>e.subject!==`issue`),o=i.filter(e=>e.subject===`issue`),s=e.links??[],c=s.filter(e=>e.kind===`file`),l=s.filter(e=>e.kind===`link`);return[{key:`agent`,n:n.length,one:`agent`,many:`agents`,states:n.map(e=>e.state)},{key:`shell`,n:r.length,one:`shell`,many:`shells`,states:r.map(e=>e.state)},{key:`pr`,n:a.length,one:`PR`,many:`PRs`,states:[`running`]},{key:`issue`,n:o.length,one:`issue`,many:`issues`,states:[`running`]},{key:`file`,n:c.length,one:`file`,many:`files`,states:[]},{key:`link`,n:l.length,one:`link`,many:`links`,states:[]}].filter(e=>e.n>0)}function r4(e){return _k(e,`card`).length>0}function i4({slug:e,subAgents:t,className:n=`px-1 pt-1.5`}){let r=_k(t,`card`);return r.length===0?null:(0,R.jsx)(`div`,{"data-queue-subagents":!0,className:`flex min-w-0 flex-col gap-0.5 ${n}`,children:r.map((t,n)=>(0,R.jsx)(bk,{kind:`AGENT`,label:t.label,state:t.state,density:`card`,depth:t.depth,startedAt:t.startedAt,parentSlug:e,onOpen:t.id?()=>Jh(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:RP(e,t)},t.id??`${t.startedAt}-${n}`))})}function a4({thread:e,transcriptShells:t=[]}){let[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(void 0);(0,L.useEffect)(()=>()=>clearTimeout(i.current),[]);let a=n4(e,t),o=(0,L.useRef)(null),s=(0,L.useRef)(null),c=a.length===0;if((0,L.useEffect)(()=>{c&&(clearTimeout(i.current),r(!1))},[c]),c)return null;let l=a.map(e=>`${e.n} ${e.n===1?e.one:e.many}`),u=()=>{clearTimeout(i.current),r(!0)},d=()=>{clearTimeout(i.current),i.current=setTimeout(()=>r(!1),150)},f=()=>{u(),requestAnimationFrame(()=>o.current?.querySelector(`button, a[href], [tabindex]:not([tabindex='-1'])`)?.focus())};return(0,R.jsx)(`div`,{"data-queue-ops-summary":!0,className:`-mt-2 flex h-7 min-w-0 items-center justify-end`,children:(0,R.jsxs)(CV,{open:n,onOpenChange:r,children:[(0,R.jsx)(TV,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`${l.join(`, `)} — show them`,"aria-haspopup":`dialog`,"aria-expanded":n,onMouseEnter:u,onMouseLeave:d,onFocus:u,ref:s,onClick:e=>{e.stopPropagation(),e.detail===0?f():u()},onKeyDown:e=>{e.key===`ArrowDown`&&(e.preventDefault(),f())},onMouseDown:e=>e.preventDefault(),className:`flex min-w-0 items-center gap-3 rounded-md px-1.5 py-0.5 text-[11.5px] outline-none transition-colors focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${n?`bg-panel-2 text-fg/85`:`text-muted-70 hover:bg-panel-2 hover:text-fg/85`}`,children:a.map(e=>(0,R.jsxs)(`span`,{"data-ops-count":e.key,className:`flex items-baseline gap-1.5 whitespace-nowrap`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`relative block h-[1em] w-[1em] shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`,children:(0,R.jsx)(`span`,{className:`absolute inset-0 flex items-center justify-center`,children:(0,R.jsx)(o4,{kind:e.key,states:e.states})})}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:`tabular-nums text-fg/85`,children:e.n}),` `,e.n===1?e.one:e.many]})]},e.key))})}),(0,R.jsxs)(EV,{side:`top`,align:`end`,sideOffset:4,"data-queue-ops-panel":!0,"aria-label":`Running for this thread`,onMouseEnter:u,onMouseLeave:d,onOpenAutoFocus:e=>e.preventDefault(),onEscapeKeyDown:e=>{e.stopPropagation(),o.current?.contains(document.activeElement)&&s.current?.focus()},ref:o,onClick:e=>e.stopPropagation(),className:`flex w-[440px] max-w-[calc(100vw-1.5rem)] flex-col px-3 py-2`,children:[(0,R.jsx)(i4,{slug:e.id,subAgents:e.subAgents??[],className:``}),(0,R.jsx)(J5,{slug:e.id,includeAgents:!1,transcriptShells:t,className:r4(e.subAgents??[])?`pt-0.5`:``})]})]})})}function o4({kind:e,states:t}){switch(e){case`agent`:return(0,R.jsx)(s4,{hue:`agent`,states:t});case`shell`:return(0,R.jsx)(s4,{hue:`shell`,states:t});case`pr`:case`issue`:return(0,R.jsx)(s4,{hue:`github`,states:t});case`file`:return(0,R.jsx)(v_,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`});case`link`:return(0,R.jsx)(g_,{"aria-hidden":!0,className:`h-[1em] w-[1em] text-muted-45`})}}function s4({hue:e,states:t}){return t.some(zO)?(0,R.jsx)(`span`,{className:`frizz-live-dot frizz-live-dot--${e}`}):(0,R.jsx)(`span`,{className:t.includes(`rested`)?ik:nk})}function c4({slug:e,onClose:t}){let n=Cg(ME(),e),[r,i]=(0,L.useState)(!1),a=LO(),o=RE(e,{poll:n?.runtime===`running`||n?.runtime===`spawning`}),s=(0,L.useMemo)(()=>cq(o.data?.messages??[]),[o.data]),c=Wq(n);if(!n)return null;let l=nq(n),u=iq(n,l,s,a),d=l===`needs-you`?`font-semibold text-accent`:l===`working`?`font-semibold text-live`:``,f=HD(n);return(0,R.jsxs)(`header`,{"data-thread-header":!0,"data-mobile-thread-header":!0,className:`flex min-h-14 shrink-0 items-center gap-0.5 border-b border-border bg-panel py-1 pl-1 pr-[5px]`,children:[(0,R.jsx)(`button`,{type:`button`,"aria-label":`Back`,"data-mobile-thread-back":!0,onClick:()=>{JE()?history.back():t()},className:`flex size-11 shrink-0 items-center justify-center rounded-full text-fg/90 outline-none active:bg-hover focus-visible:bg-hover`,children:(0,R.jsx)(Yg,{size:21,strokeWidth:2.1})}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 pl-0.5 leading-[1.25]`,children:[(0,R.jsx)(`div`,{"data-mobile-thread-title":!0,className:`truncate text-[16.5px] font-semibold tracking-[-0.01em]`,title:f,children:f}),(0,R.jsxs)(`div`,{"data-mobile-thread-subtitle":!0,"data-state":l,className:`truncate text-[13px] text-muted`,children:[(0,R.jsx)(`span`,{className:d,children:rq[l]}),u&&(0,R.jsxs)(R.Fragment,{children:[` · `,u]}),c&&(0,R.jsxs)(R.Fragment,{children:[` · `,c]})]})]}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Thread actions`,"aria-haspopup":`dialog`,"aria-expanded":r,"data-mobile-thread-more":!0,onClick:()=>i(!0),className:`flex size-11 shrink-0 items-center justify-center rounded-full text-fg/90 outline-none active:bg-hover focus-visible:bg-hover`,children:(0,R.jsx)(h_,{size:21,strokeWidth:2.1})}),r&&(0,R.jsx)(Pq,{slug:e,onClose:()=>i(!1),onArchived:()=>q2(e)})]})}function l4({thread:e}){let[t,n]=(0,L.useState)(!1);if(!$K(e))return null;async function r(){n(!0);try{await tq(e)}finally{n(!1)}}return(0,R.jsx)(FP,{label:`Reload plugins — hooks, skills, agents and MCP re-read from disk, same conversation`,side:`top`,children:(0,R.jsx)(`button`,{type:`button`,"data-reload-plugins":!0,disabled:t,"aria-label":`Reload plugins`,onMouseDown:e=>e.preventDefault(),onClick:()=>void r(),className:jk,children:(0,R.jsx)(K_,{size:14,strokeWidth:2})})})}function u4({thread:e}){let t=qe(),[n,r]=(0,L.useState)(!1);return eq(e,QK())?(0,R.jsx)(FP,{label:`Restart worker — same conversation, fresh process on current tooling`,side:`top`,children:(0,R.jsx)(`button`,{type:`button`,disabled:n,"aria-label":`Restart worker`,onMouseDown:e=>e.preventDefault(),onClick:()=>{r(!0),ZK(t,e.id).finally(()=>r(!1))},className:`${jk} mx-[2px]`,children:n?(0,R.jsx)(M_,{size:14,strokeWidth:2,className:`animate-spin`}):(0,R.jsx)(J_,{size:14,strokeWidth:2})})}):null}function d4(e){return Ak(e)??HE(`/`)}function f4(e){qE(d4(e),{viewTransition:!Ah()})}function p4({slug:e,label:t=`Exit fullscreen`}){let n=d4(e);function r(t){um(t)&&(t.preventDefault(),f4(e))}return(0,R.jsx)(FP,{label:t,children:(0,R.jsx)(`a`,{href:n,"aria-label":t,"data-standalone-return":!0,onMouseDown:e=>e.preventDefault(),onClick:r,className:jk,children:(0,R.jsx)(R_,{size:14})})})}function m4({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,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[a&&(0,R.jsx)(g4,{label:o?`Expand`:`Collapse`,icon:o?a_:i_,size:13,onClick:a}),(0,R.jsx)(l4,{thread:e}),(0,R.jsx)(u4,{thread:e}),r&&(0,R.jsx)(g4,{label:`Frizz document`,icon:v_,size:14,onClick:r}),t&&(0,R.jsx)(IP,{slug:e.id}),n&&(0,R.jsx)(p4,{slug:e.id}),d?gO(e)?(0,R.jsx)(h4,{slug:e.id}):null:(0,R.jsx)(`div`,{className:`ml-1`,children:(0,R.jsx)(cR,{slug:e.id,onDone:i,doneBusy:s,onMutateStart:c,onApplied:l,onFailed:u})})]})}function h4({slug:e}){let t=qe(),[n,r]=(0,L.useState)(!1);return(0,R.jsx)(FP,{label:`Retry — resume this session where it left off`,children:(0,R.jsxs)(`button`,{onClick:()=>{r(!0),kW(t,e).finally(()=>r(!1))},disabled:n,"aria-label":`Retry exited session`,"data-header-pill":!0,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,R.jsx)(M_,{size:12,className:`animate-spin`}):(0,R.jsx)(X_,{size:12}),`Retry`]})})}function g4({label:e,icon:t,size:n,busy:r,...i}){return(0,R.jsx)(FP,{label:e,children:(0,R.jsx)(`button`,{...i,"aria-label":e,onMouseDown:e=>e.preventDefault(),className:jk,children:r?(0,R.jsx)(M_,{size:n,strokeWidth:2,className:`animate-spin`}):(0,R.jsx)(t,{size:n,strokeWidth:2})})})}function _4({at:e,fallbackAt:t,className:n=``}){let r=LO(),i=bO(e,t),a=xO(i,r);return!a||!i?null:(0,R.jsx)(`time`,{dateTime:i,className:n,children:a})}var v4=1.25,y4=7.5-v4/2,b4=2*Math.PI*y4;function x4(e,t){return Math.max(0,Math.min(100,Math.floor(e/t*100)))}var S4=150;function C4(e){return!!e.context&&e.context.window>0}function w4({thread:e}){let[t,n]=(0,L.useState)(!1),r=(0,L.useRef)(void 0),i=(0,L.useRef)(null),a=(0,L.useRef)(null);(0,L.useEffect)(()=>()=>clearTimeout(r.current),[]);let o=e.context;if(!o||!C4(e))return null;let s=()=>{clearTimeout(r.current),n(!0)},c=()=>{clearTimeout(r.current),r.current=setTimeout(()=>n(!1),S4)},l=e=>{i.current?.contains(e.target)&&e.preventDefault()},u=O4(e,o.tokens),d=x4(o.tokens,o.window),f=Math.max(0,Math.min(1,o.tokens/o.window)),p=`Context ${d}% full`,m=`${o.tokens.toLocaleString()} of ${o.window.toLocaleString()} tokens`;return(0,R.jsxs)(CV,{open:t,onOpenChange:n,children:[(0,R.jsx)(TV,{asChild:!0,children:(0,R.jsxs)(`button`,{type:`button`,"data-context-meter":!0,"data-context-percent":d,"aria-label":`${p}\n${m}`,"aria-haspopup":`dialog`,"aria-expanded":t,onMouseEnter:s,onMouseLeave:c,onFocus:s,ref:i,onClick:e=>{e.stopPropagation(),s(),e.detail===0&&requestAnimationFrame(()=>a.current?.querySelector(`button:not(:disabled)`)?.focus())},className:`flex shrink-0 items-baseline gap-1 rounded-sm outline-none transition-colors hover:text-fg/85 focus-visible:ring-1 focus-visible:ring-focus-ink-60 ${t?`text-fg/85`:``}`,children:[(0,R.jsxs)(`svg`,{viewBox:`0 0 16 16`,className:`-mt-[1em] h-[1.05em] w-[1.05em] shrink-0 self-baseline translate-y-[calc(0.525em_-_0.5cap)]`,"aria-hidden":!0,children:[(0,R.jsx)(`circle`,{cx:`8`,cy:`8`,r:y4,fill:`none`,stroke:`currentColor`,strokeOpacity:.3,strokeWidth:v4}),(0,R.jsx)(`circle`,{cx:`8`,cy:`8`,r:y4,fill:`none`,stroke:`currentColor`,strokeWidth:v4,strokeDasharray:`${b4*f} ${b4}`,transform:`rotate(-90 8 8)`})]}),(0,R.jsxs)(`span`,{children:[d,`% context`]})]})}),(0,R.jsxs)(EV,{side:`bottom`,align:`start`,sideOffset:5,ref:a,"data-context-panel":!0,"aria-label":p,onInteractOutside:e=>l({target:e.detail.originalEvent.target,preventDefault:()=>e.preventDefault()}),onMouseEnter:s,onMouseLeave:c,onOpenAutoFocus:e=>e.preventDefault(),onClick:e=>e.stopPropagation(),className:`flex w-max max-w-[min(22rem,calc(100vw-1.5rem))] flex-col gap-2 px-3 py-2 text-[11px] leading-relaxed text-fg`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col`,children:[(0,R.jsx)(`span`,{children:p}),(0,R.jsx)(`span`,{className:`text-muted`,children:m})]}),Ff(e)&&(0,R.jsx)(k4,{thread:e,compacting:u,onRequested:()=>n(!1)})]})]})}function T4(e){return e.runtime===`running`||e.runtime===`spawning`||e.runtime===`perm-prompt`}var E4=new Map,D4=2*6e4;function O4(e,t){let n=e.sessionId;if(!n)return!1;let r=E4.get(n);return r?!T4(e)&&(r.tokens!==t||e.lastActivityAt!==r.activity)||Date.now()-r.at>D4?(E4.delete(n),!1):!0:!1}function k4({thread:e,compacting:t,onRequested:n}){let[r,i]=(0,L.useState)(!1),a=e.context?.tokens??0,o=T4(e)&&!t;return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,R.jsxs)(`button`,{type:`button`,"data-compact-now":!0,disabled:o||r||t||!e.sessionId,onClick:()=>{let t=e.sessionId;t&&(i(!0),Y.compactThread({slug:e.id,sessionId:t}).then(()=>{E4.set(t,{tokens:a,activity:e.lastActivityAt,at:Date.now()}),Z(`Compacting context`),n()}).catch(e=>Z(`Couldn’t compact: ${e.message.slice(0,80)}`)).finally(()=>i(!1)))},onMouseDown:e=>e.preventDefault(),className:`flex items-center justify-center gap-1 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-focus-ink-60 disabled:opacity-45 disabled:hover:bg-panel-2/60 disabled:hover:text-fg/80`,children:[(r||t)&&(0,R.jsx)(M_,{size:12,className:`animate-spin`}),t?`Compacting…`:`Compact now`]}),o&&(0,R.jsx)(`span`,{className:`text-muted`,children:`Available once the current turn ends`})]})}function A4({thread:e}){return(0,R.jsxs)(`div`,{"data-thread-header-facts":!0,className:`mt-0.5 flex min-w-0 items-center gap-1.5 text-[11px] leading-tight text-muted-75 empty:hidden`,children:[(0,R.jsx)(_4,{at:QD(e),fallbackAt:e.spawnedAt,className:`min-w-0 truncate`}),C4(e)&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`hidden shrink-0 text-muted-45 [time+&]:inline`,children:`·`}),(0,R.jsx)(w4,{thread:e})]})]})}function j4({thread:e,hidden:t=!1}){let n=pt({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=GK(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,R.jsx)(FP,{label:i,children:(0,R.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-danger hover:bg-danger-fill/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,R.jsx)(M_,{size:12,className:`animate-spin`}):(0,R.jsx)(Z_,{size:12})})})}function M4({thread:e,className:t=``}){let n=e.id,r=pt({mutationFn:e=>Y.renameThread({slug:n,title:e})}),[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(``),c=(0,L.useRef)(null);(0,L.useEffect)(()=>{if(!i)return;let e=requestAnimationFrame(()=>{c.current?.focus(),c.current?.select()});return()=>cancelAnimationFrame(e)},[i]),(0,L.useEffect)(()=>{a(!1),s(``)},[n]);let l=e.kind===`session`&&e.foreign!==!0,u=HD(e);function d(){a(!1),s(``)}function f(){let e=UK(o,u);if(a(!1),!e){s(``);return}r.mutate(e,{onSuccess:()=>{s(``),Z(`Thread renamed`)},onError:t=>{s(e),a(!0),Z(t instanceof Error?t.message:`Could not rename thread`)}})}return(0,R.jsxs)(`div`,{className:`group/thread-title flex min-w-0 items-center gap-2`,children:[i?(0,R.jsx)(`input`,{ref:c,"aria-label":`Thread title`,value:o,maxLength:200,onChange:e=>s(e.target.value),onBlur:f,"data-claims-escape":!0,onKeyDown:e=>{e.stopPropagation(),e.key===`Enter`?(e.preventDefault(),f()):e.key===`Escape`&&(e.preventDefault(),d())},className:`min-w-0 flex-1 -mx-1.5 -my-px rounded-md border border-border bg-elevated px-1.5 py-0 font-semibold text-[15px] text-fg outline-none focus:border-accent ${t}`}):l?(0,R.jsx)(`button`,{type:`button`,title:`Edit title`,"aria-label":`Edit thread title: ${u}`,disabled:r.isPending,onClick:()=>{s(WK(u,n)),a(!0)},className:`min-w-0 max-w-full shrink truncate rounded px-0.5 -mx-0.5 font-semibold text-[15px] text-left outline-none transition-colors hover:bg-panel-2 focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:cursor-not-allowed disabled:opacity-40 ${t}`,children:u}):(0,R.jsx)(`div`,{className:`min-w-0 max-w-full shrink truncate px-0.5 -mx-0.5 font-semibold text-[15px] ${t}`,title:u,children:u}),(0,R.jsx)(j4,{thread:e,hidden:i})]})}var N4=new Set([`low`,`medium`,`high`,`xhigh`,`max`,`ultra`]);function P4(e,t){let n=e.lastIndexOf(t);if(n<=0)return{model:e};let r=e.slice(n+1);return N4.has(r)?{model:e.slice(0,n),effort:r}:{model:e}}function F4(e){let t=e?.trim();if(!t)return`Profile unknown`;if(t.startsWith(`frizz:`)){let{model:e,effort:n}=P4(t.slice(6).replace(/^frizz-/,``),`-`);return n?`${e} › ${n}`:e}let n=t.split(/\s+/),{model:r,effort:i}=P4(n.at(-1)??t,`/`);if(!i)return t;let a=n.slice(0,-1).join(` `);return`${a?`${a} · `:``}${r} › ${i}`}function I4(e){return e?.trim()?F4(e):void 0}function L4(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 R4={completed:`finished`,killed:`stopped`,failed:`failed`};function z4(e){let t=R4[e.agentStatus??`completed`],n=e.agentElapsedMs===void 0?void 0:JO(e.agentElapsedMs);return{outcome:t,tail:`${t}${n?` · ${n}`:``}`}}var B4=e=>e===void 0?void 0:UO(e),V4=e=>{if(e!==void 0)return JO(e)||void 0};function H4(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=B4(n);return{label:t===`completed`?void 0:R4[t],duration:V4(n),tone:r?`failed`:`muted`,title:`${e?`Stopped`:r?`Failed`:`Ran for`}${e||r?` after`:``} ${i??`an unknown time`}`}}if(r){let e=B4(i);return{label:void 0,duration:V4(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=B4(o);return{label:c?R4.killed:s?R4.failed:void 0,duration:V4(o),tone:s?`failed`:`muted`,title:`${c?`Stopped after`:s?`Failed after`:`Ran for`} ${l??`an unknown time`}`}}var U4=`group flex min-w-0 items-baseline gap-1.5 rounded-sm text-left text-[11.5px] outline-none focus-visible:ring-1 focus-visible:ring-focus-ink-60`,W4=`${tk} -mt-[1em] self-baseline`,G4=`h-[1em] w-[1em] shrink-0 translate-y-[calc(0.5em_-_0.5cap)] text-muted-45`;function K4({links:e}){return e.length?(0,R.jsx)(`div`,{"data-thread-links":!0,"aria-label":`Registered links`,className:`mt-2 flex min-w-0 flex-col gap-0.5 border-t border-border pt-1.5`,children:e.map(e=>{let t=e.kind===`link`,n=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:$O,children:`⤷`}),(0,R.jsx)(`span`,{className:W4,children:(0,R.jsx)(t?g_:v_,{"aria-hidden":!0,className:G4})}),(0,R.jsx)(`span`,{"data-link-kind":!0,className:ek,children:t?`Link`:`File`}),(0,R.jsx)(`span`,{"data-link-label":!0,className:`min-w-0 flex-1 truncate text-muted-70 group-hover:text-fg/80 group-hover:underline`,children:e.label}),t&&(0,R.jsx)(`span`,{"data-link-destination":!0,className:`font-mono-keep ml-auto -mb-[0.5em] max-w-[45%] min-w-0 truncate text-right text-[10px] text-muted-45`,children:e.target})]});return t?(0,R.jsx)(`a`,{"data-thread-link":e.id,href:e.target,target:`_blank`,rel:`noopener noreferrer`,title:e.target,className:U4,onClick:e=>e.stopPropagation(),children:n},e.id):(0,R.jsx)(`button`,{"data-thread-link":e.id,type:`button`,title:e.target,className:`${U4} cursor-pointer`,onClick:t=>{t.stopPropagation(),YK(e.target)},children:n},e.id)})}):null}var q4=`text-[14px] leading-5 text-muted`,J4=`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 Y4(e){return`${J4} ${e?`-mx-[0.208em] rotate-90`:`-mx-[0.333em]`}`}var $=L.createElement;function X4({payload:e}){return e.kind===`command-approval`?$(L.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,$(Z4,{label:`Redacted command preview`,text:e.command.preview}),e.command.actions?$(Q4,{actions:e.command.actions}):null,e.capabilities?$(e3,{capabilities:e.capabilities}):null):e.kind===`file-approval`?$(L.Fragment,null,$(`div`,{className:`text-[12px] text-muted`},i3(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-attention/35 bg-attention-fill/[0.06] px-2.5 py-2`},$(`h4`,{className:`text-[10px] font-medium uppercase tracking-[0.07em] text-attention-soft-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-attention-soft-75`},e.scopeLabel):null):null,e.diffPreview?$(Z4,{label:`Plain-text diff preview`,text:e.diffPreview}):null,e.changes?$($4,{changes:e.changes}):null):$(L.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?$(e3,{capabilities:e.capabilities}):null)}function Z4({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-focus-ink-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 Q4({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`},r3(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,$(Z4,{label:`${r3(e.kind)} command detail`,text:e.commandPreview})))))}function $4({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`},i3(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?$(Z4,{label:`${i3(e.operation)} plain-text diff`,text:e.diffPreview}):null))))}function e3({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`},$(t3,{capability:e})))))}function t3({capability:e}){if(e.kind===`network`){let t=e.enabled===!0?`Enable network access`:e.enabled===!1?`Disable network access`:`Network access request`;return $(L.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},t),e.hosts.length>0?$(n3,{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 $(L.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},t),$(n3,{label:`Paths`,values:e.resources}))}return e.kind===`glob-scan`?$(L.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`?$(L.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},`Future command policy amendment`),$(n3,{label:`Command prefix tokens`,values:e.prefixes})):$(L.Fragment,null,$(`div`,{className:`text-[11px] font-medium text-fg/90`},e.access===`allow`?`Allow future network hosts`:`Deny future network hosts`),$(n3,{label:`Hosts`,values:e.hosts}))}function n3({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 r3(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 i3(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 a3(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 o3={semantic:`approve`,label:`Approve once`,order:10,tone:`primary`,durable:!1,scope:`Applies only to this request.`},s3={semantic:`approve`,label:`Approve for session`,order:20,tone:`primary`,durable:!0,scope:`Persists for later matching requests in this thread session.`},c3={semantic:`approve`,label:`Grant for turn`,order:10,tone:`primary`,durable:!1,scope:`Applies to this turn only.`},l3={semantic:`approve`,label:`Grant for session`,order:20,tone:`primary`,durable:!0,scope:`Persists until this thread session ends.`},u3={semantic:`deny`,label:`Deny`,order:70,tone:`danger`,durable:!1,scope:`Rejects this request.`},d3={semantic:`decline`,label:`Decline`,order:70,tone:`danger`,durable:!1,scope:`Declines this request.`},f3={semantic:`cancel`,label:`Cancel request`,order:80,tone:`neutral`,durable:!1,scope:`Cancels this pending request.`};function p3(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`?o3:n===`acceptForSession`&&r===`approve`?s3:(n===`decline`||n===`deny`)&&r===`deny`?u3:n===`cancel`&&r===`cancel`?f3:void 0;if(e.kind===`permission-approval`)return n===`grant-turn`&&r===`approve`?c3:n===`grant-session`&&r===`approve`?l3:(n===`deny`||n===`decline`)&&r===`deny`?u3:n===`cancel`&&r===`cancel`?f3: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`?d3:n===`cancel`&&r===`cancel`?f3: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 d3;if(n===`cancel`&&r===`cancel`)return f3}function m3(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=p3(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 h3(e){switch(e){case`claude`:return`Claude`;case`codex`:return`Codex`;case`acp`:return`ACP agent`;case`frizz`:return`Frizz`}}function g3(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 _3(e,t){let n=e.options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t));return n<0?``:String(n)}function v3(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?``:_3(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 y3(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 b3(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=Tl(i,a);e?r[i.id]=`Value ${e}.`:n[i.id]=a}}if(Object.keys(r).length>0)return{errors:r};let i=zl.safeParse(n);return i.success?{errors:r,values:i.data}:{errors:r,formError:`The response is too large or contains invalid values.`}}function x3(e,t){return JSON.stringify([e,t??null])}function S3(e,t){try{let n=new URL(e,t);return n.protocol===`http:`||n.protocol===`https:`?n.toString():null}catch{return null}}function C3(e,t){let n=e.getAttribute(`href`);if(!n)return!1;let r=S3(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 w3(e=()=>location.href){return t=>{if(t.defaultPrevented||t.button!==0)return;let n=E3(t);n&&C3(n,e())}}function T3(){let e=w3();return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)}function E3(e){let t=typeof e.composedPath==`function`?e.composedPath():[];for(let e of t)if(D3(e))return e;let n=e.target?.closest?.(`a[href]`);return D3(n)?n:null}function D3(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 O3(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)=>`${LQ(t)} ${e.label}`),recommendedIdxs:[]},...e?{optionFieldId:e.id}:{},optionValues:r.map(e=>e.value),...t?{notesFieldId:t.id}:{}}}function k3(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=O3(r,a);if(!e)return null;n.push(e)}else if(r.input===`text`||r.input===`multiline`){let e=O3(void 0,r);if(!e)return null;n.push(e)}else return null}return n.length>0?n:null}function A3(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)=>`${LQ(t)} ${e.label}${e.description?` — ${e.description}`:``}`),recommendedIdxs:[]},chosenIdxs:n,text:r}}function j3(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 M3(e){let t=e instanceof Error?e.message:`The request could not be updated.`;return t.length>240?`${t.slice(0,239)}…`:t}function N3(){return typeof crypto<`u`&&typeof crypto.randomUUID==`function`?crypto.randomUUID():`frizz-response-${Date.now()}-${Math.random().toString(36).slice(2)}`}function P3({thread:e,className:t=``,autoFocusFirst:n=!1}){let r=LE(e),i=Qee(e),a=(0,L.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,R.jsxs)(`div`,{"data-interactions-error":!0,role:`alert`,className:`${KQ} border border-attention-fill/35 bg-attention-fill/[0.07] p-4 text-[12px] text-attention-soft ${t}`,children:[(0,R.jsx)(`div`,{className:`font-medium`,children:`Pending requests could not be loaded.`}),(0,R.jsx)(`div`,{className:`mt-1 break-words text-attention-soft-75`,children:M3(i.error)}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void i.refetch(),className:`mt-2 rounded-md border border-attention/40 px-2 py-1 text-[11px] hover:bg-attention-fill/10`,children:`Try again`})]}):a.length===0?null:(0,R.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,R.jsx)(I3,{record:e,autoFocus:n&&t===0,siblings:a},e.id))}):null}function F3({record:e,questions:t,autoFocus:n,siblings:r}){let i=qe(),a=B3(e,r),o=(0,L.useRef)(null),s=(0,L.useRef)(new Map),c=wH(),l=a3(e.delivery?.effect),u=(0,L.useMemo)(()=>m3(e).find(e=>e.semantic===`answer`),[e]),d=DH(t.flatMap(t=>t.notesFieldId?[CH.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId)]:[])),[f,p]=(0,L.useState)(()=>t.map(()=>({chosen:null,chosenSet:[]}))),m=t.map((t,n)=>({chosen:f[n]?.chosen??null,chosenSet:f[n]?.chosenSet??[],text:t.notesFieldId?d.get(CH.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId))??``:``})),h=j3(t,m),[g,_]=(0,L.useState)(),[v,y]=(0,L.useState)(!1);(0,L.useEffect)(()=>{if(!n)return;let e=document.activeElement;e&&e!==document.body||requestAnimationFrame(()=>o.current?.focus())},[n,e.id]);let b=pt({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=>{y(!0),EC(i,t.interaction),i.invalidateQueries({queryKey:wC(e.owner.threadSlug,e.owner.sessionId)}),i.invalidateQueries({queryKey:TC(e.owner.threadSlug,e.owner.sessionId,e.id)})},onError:t=>{DC(i,e),a.rollback(),_(M3(t)),Y.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{EC(i,t),i.setQueryData(TC(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t}),i.invalidateQueries({queryKey:wC(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}}),x=()=>{if(!u||!h||b.isPending||v||!l.actionsEnabled)return;_(void 0);let e=x3(u.id,h),t=s.current.get(e)??N3();s.current.set(e,t),a.release(!0),b.mutate({decisionId:u.id,values:h,responseId:t})},S=(t,n)=>{t.notesFieldId&&bH.set(CH.interaction(c,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.notesFieldId),n)};return(0,R.jsxs)(`article`,{ref:o,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,R.jsx)(B1,{question:e.question,interactive:l.actionsEnabled&&!v?{answer:m[t],onChip:n=>{p(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=>{S(e,n),e.question.kind!==`multi`&&p(e=>e[t]?.chosen===null||e[t]===void 0?e:e.map((e,n)=>n===t?{...e,chosen:null}:e))},onSubmit:x}:void 0},e.optionFieldId??e.notesFieldId??t)),g&&(0,R.jsx)(`div`,{role:`alert`,className:`break-words text-[11px] leading-snug text-danger-soft`,children:g}),(l.status||b.isPending||v)&&(0,R.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`text-[11px] leading-snug text-muted`,children:l.status??(v?`Answer sent.`:`Sending…`)}),l.actionsEnabled&&!v&&(0,R.jsx)(`div`,{className:`flex justify-start`,children:(0,R.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:!h||b.isPending,onClick:x,onMouseDown:e=>e.preventDefault(),className:`button-outline 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 I3({record:e,autoFocus:t=!1,siblings:n}){let r=(0,L.useMemo)(()=>k3(e),[e]),i=n??[e];return r?(0,R.jsx)(F3,{record:e,questions:r,autoFocus:t,siblings:i}):(0,R.jsx)(V3,{record:e,autoFocus:t,siblings:i})}function L3(e){return e.semantic!==`cancel`}var R3=new Set,z3=new Set;function B3(e,t){let n=(0,L.useContext)(H8),r=e.owner.threadSlug;return{release:i=>{R3.add(e.id),i&&t.every(t=>t.id===e.id||R3.has(t.id)||t.delivery?.effect===`sending`)&&(z3.add(r),uW(r),n?.dismiss())},rollback:()=>{R3.delete(e.id),z3.delete(r)&&(dW(r),n?.cancel())}}}function V3({record:e,autoFocus:t=!1,siblings:n}){let r=qe(),i=B3(e,n),a=(0,L.useId)(),o=(0,L.useRef)(null),s=(0,L.useRef)(new Map),c=e.payload.kind===`mcp-elicitation-form`||e.payload.kind===`agent-question`?e.payload.fields:[],l=c.some(e=>e.secret),u=wH(),d=c.filter(e=>!e.secret&&(e.input===`text`||e.input===`multiline`)).map(t=>CH.interaction(u,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,t.id)),f=DH(d),[p,m]=(0,L.useState)(()=>v3(c)),h=(0,L.useMemo)(()=>{let t={...p};return c.forEach(n=>{if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=CH.interaction(u,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id);t[n.id]=f.get(r)??``}}),t},[c,p,f,u,e.id,e.owner]),[g,_]=(0,L.useState)({}),[v,y]=(0,L.useState)(),[b,x]=(0,L.useState)(),[S,C]=(0,L.useState)(!1),[w,T]=(0,L.useState)(),[E,D]=(0,L.useState)(!1),O=a3(e.delivery?.effect),k=(0,L.useMemo)(()=>m3(e),[e]).filter(e=>!(l&&e.requiresValues)),A=e.allowedDecisions.length-k.length,j=(0,L.useCallback)(t=>{for(let n of c)if(!n.secret&&(n.input===`text`||n.input===`multiline`)){let r=t[n.id];typeof r==`string`&&bH.set(CH.interaction(u,e.owner.projectId,e.owner.threadSlug,e.owner.sessionId,e.owner.sessionEpoch,e.id,n.id),r)}m(t)},[c,u,e.id,e.owner]);(0,L.useEffect)(()=>{if(!t)return;let e=document.activeElement;e&&e!==document.body||requestAnimationFrame(()=>o.current?.focus())},[t,e.id]),(0,L.useEffect)(()=>{O.actionsEnabled||(T(void 0),D(!1))},[O.actionsEnabled]);let M=pt({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,n)=>{t.waitingForProvider||s.current.delete(x3(n.decision.id,n.values)),y(void 0),T(void 0),D(!1),C(!0),d.forEach(e=>bH.clear(e)),x(t.waitingForProvider?`Response sent. Waiting for the provider to acknowledge it…`:`Request completed.`),EC(r,t.interaction),r.setQueryData(TC(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t.interaction}),r.invalidateQueries({queryKey:wC(e.owner.threadSlug,e.owner.sessionId),exact:!0}),t.waitingForProvider&&window.setTimeout(()=>{r.invalidateQueries({queryKey:wC(e.owner.threadSlug,e.owner.sessionId),exact:!0})},1e3)},onError:t=>{x(void 0),i.rollback(),y(M3(t)),DC(r,e),Y.interactionGet({slug:e.owner.threadSlug,sessionId:e.owner.sessionId,interactionId:e.id}).then(({interaction:t})=>{EC(r,t),r.setQueryData(TC(e.owner.threadSlug,e.owner.sessionId,e.id),{interaction:t}),t.delivery?.effect===`sending`?(y(void 0),x(void 0),C(!0)):t.delivery?.effect===`reconnect-required`?(y(void 0),x(void 0)):(t.lifecycle!==`pending`||t.recordRevision!==e.recordRevision)&&(y(void 0),x(t.lifecycle===`expired`?`This request expired.`:`This request changed in another client.`),r.invalidateQueries({queryKey:wC(e.owner.threadSlug,e.owner.sessionId),exact:!0})),r.invalidateQueries({queryKey:wC(e.owner.threadSlug,e.owner.sessionId),exact:!0})}).catch(()=>{})}});function N(e){if(!e.requiresValues){_({});return}let t=b3(c,h);return _(t.errors),t.formError?(y(t.formError),null):t.values?t.values:null}function P(e,t=!1){if(!O.actionsEnabled||M.isPending||S)return;y(void 0);let n=N(e);if(n===null)return;if(e.durable&&!t){T(e),D(!1);return}let r=x3(e.id,n),a=s.current.get(r)??N3();s.current.set(r,a),i.release(L3(e)),M.mutate({decision:e,values:n,responseId:a})}let F=k.find(e=>e.requiresValues&&e.tone===`primary`);function I(e){e.preventDefault(),O.actionsEnabled&&F&&P(F)}return(0,R.jsxs)(`article`,{ref:o,tabIndex:-1,"aria-labelledby":a,"data-interaction-id":e.id,"data-interaction-kind":e.payload.kind,"data-delivery-effect":e.delivery?.effect,className:`min-w-0 ${KQ} border border-question-border bg-question outline-none focus-visible:ring-2 focus-visible:ring-focus-accent-60`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-3 border-b border-question-border px-4 py-3`,children:[(0,R.jsx)($_,{"aria-hidden":`true`,size:16,className:`shrink-0 text-accent`}),(0,R.jsx)(`h3`,{id:a,className:`min-w-0 flex-1 break-words text-[14px] font-semibold leading-snug text-fg`,children:e.payload.title})]}),(0,R.jsx)(`form`,{onSubmit:I,onKeyDown:e=>{e.target instanceof HTMLButtonElement||gz({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(),O.actionsEnabled&&F&&P(F))},className:`min-w-0 px-4 py-3.5`,noValidate:!0,children:(0,R.jsxs)(`fieldset`,{disabled:!O.actionsEnabled,className:`min-w-0 border-0 p-0`,children:[(0,R.jsx)(`legend`,{className:`sr-only`,children:`Interaction request`}),(0,R.jsx)(U3,{record:e,instanceId:a,draft:h,setDraft:j,errors:g,autoFocus:t}),l&&(0,R.jsxs)(`div`,{"data-secret-fallback":!0,className:`mt-3 rounded-md border border-attention-fill/35 bg-attention-fill/[0.07] p-3 text-[12px] leading-snug text-attention-soft-90`,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(j_,{"aria-hidden":`true`,size:14,className:`mt-0.5 shrink-0`}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`font-medium`,children:`Secret input is unavailable in this page.`}),(0,R.jsx)(`div`,{className:`mt-1 text-attention-soft-70`,children:`Frizz will not persist or send secret values through the current RPC.`})]})]}),(0,R.jsx)(`div`,{className:`mt-2 font-medium`,children:`Use the provider's trusted secret-input flow. The thread terminal cannot answer this typed request.`})]}),A>0&&(0,R.jsxs)(`div`,{className:`mt-3 flex items-start gap-2 rounded-md border border-attention-fill/25 bg-attention-fill/[0.05] px-3 py-2 text-[11px] leading-snug text-attention-soft-75`,children:[(0,R.jsx)(ov,{"aria-hidden":`true`,size:13,className:`mt-0.5 shrink-0`}),(0,R.jsxs)(`span`,{children:[A===1?`One advertised choice`:`${A} advertised choices`,` cannot be safely labeled or delivered in Frizz and is not shown.`]})]}),w&&(0,R.jsxs)(`div`,{"data-durable-confirmation":!0,role:`group`,"aria-label":`Confirm ${w.label}`,className:`mt-3 rounded-md border border-attention/45 bg-attention-fill/[0.08] p-3`,children:[(0,R.jsx)(`div`,{className:`text-[12px] font-semibold text-attention-soft`,children:`This approval persists beyond the current request.`}),(0,R.jsx)(`div`,{className:`mt-1 text-[11px] leading-snug text-attention-soft-75`,children:w.scope}),(0,R.jsxs)(`label`,{className:`mt-2.5 flex cursor-pointer items-start gap-2 text-[11px] leading-snug text-fg/85`,children:[(0,R.jsx)(`input`,{type:`checkbox`,autoFocus:!0,checked:E,onChange:e=>D(e.target.checked),className:`mt-0.5 accent-[var(--color-accent)]`}),(0,R.jsx)(`span`,{children:`I understand this may authorize later matching actions in this session.`})]}),(0,R.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-start gap-2`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>{T(void 0),D(!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,R.jsxs)(`button`,{type:`button`,disabled:!E||M.isPending,onClick:()=>P(w,!0),className:`rounded-md border border-attention/50 bg-attention-fill/15 px-2.5 py-1.5 text-[11px] font-semibold text-attention-faint hover:bg-attention-fill/25 disabled:opacity-35`,children:[`Confirm `,w.label.toLowerCase()]})]})]}),v&&(0,R.jsx)(`div`,{role:`alert`,className:`mt-3 break-words text-[11px] leading-snug text-danger-soft`,children:v}),(O.status??b)&&(0,R.jsx)(`div`,{role:`status`,"aria-live":`polite`,className:`mt-3 text-[11px] leading-snug text-muted`,children:O.status??b}),O.actionsEnabled&&!w&&!S&&k.length>0&&(0,R.jsxs)(`div`,{className:`mt-4 flex flex-wrap justify-start gap-2`,children:[k.map(e=>(0,R.jsxs)(`button`,{type:e===F?`submit`:`button`,"data-interaction-decision":e.id,disabled:M.isPending,"aria-describedby":e.durable?`${a}-scope-${e.id}`:void 0,onClick:e===F?void 0:()=>P(e),className:H3(e),children:[M.isPending?`Sending…`:e.label,e.durable&&(0,R.jsx)(`span`,{className:`sr-only`,children:`; persistent approval`})]},e.id)),k.filter(e=>e.durable).map(e=>(0,R.jsx)(`span`,{id:`${a}-scope-${e.id}`,className:`sr-only`,children:e.scope},`scope-${e.id}`))]}),!W3.has(e.payload.kind)&&(0,R.jsx)(q3,{record:e})]})})]})}function H3(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-focus-ink-50 disabled:opacity-40`;return e.tone===`primary`?`${t} border-border-strong bg-panel-2 text-fg hover:bg-inset`:e.tone===`danger`?`${t} border-danger/35 bg-danger-fill/[0.07] text-danger-faint hover:bg-danger-fill/15`:`${t} border-border bg-panel text-muted hover:bg-panel-2 hover:text-fg`}function U3({record:e,instanceId:t,draft:n,setDraft:r,errors:i,autoFocus:a}){let o=e.payload,s=(e,t)=>r(y3(n,e,t)),c;return c=o.kind===`command-approval`||o.kind===`file-approval`||o.kind===`permission-approval`?(0,R.jsx)(X4,{payload:o}):o.kind===`mcp-elicitation-url`?(0,R.jsx)(K3,{url:o.url}):(0,R.jsx)(J3,{instanceId:t,fields:o.fields,draft:n,setValue:s,errors:i,autoFocus:a}),(0,R.jsxs)(R.Fragment,{children:[`message`in o&&o.message&&(0,R.jsx)(G3,{text:o.message}),(0,R.jsx)(`div`,{className:`message`in o&&o.message?`mt-3`:``,children:c})]})}var W3=new Set([`command-approval`,`file-approval`,`permission-approval`]);function G3({text:e}){return e.length>600||e.split(`
|
|
326
|
+
`).length>6?(0,R.jsxs)(`details`,{className:`rounded-md border border-border/70 bg-panel/60`,children:[(0,R.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-focus-ink-50`,children:`Request message`}),(0,R.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,R.jsx)(`div`,{className:`whitespace-pre-wrap break-words text-[12px] leading-relaxed text-fg/80`,children:e})}function K3({url:e}){let t=S3(e,location.href);return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:`text-[11px] font-medium text-fg`,children:`Open this page to continue`}),(0,R.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,R.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,R.jsx)(g_,{"aria-hidden":`true`,size:12}),`Open page`]}):(0,R.jsx)(`div`,{role:`alert`,className:`mt-1.5 break-words text-[11px] text-danger-soft`,children:`This request did not provide a safe http(s) URL.`})]})}function q3({record:e}){return(0,R.jsxs)(`details`,{className:`mt-3 border-t border-border/50 pt-2 text-[10.5px] text-muted-70`,children:[(0,R.jsx)(`summary`,{className:`cursor-pointer w-fit outline-none hover:text-muted focus-visible:ring-1 focus-visible:ring-focus-ink-50`,children:`Request details`}),(0,R.jsxs)(`dl`,{className:`mt-2 grid min-w-0 grid-cols-[auto_minmax(0,1fr)] gap-x-3 gap-y-1`,children:[(0,R.jsx)(`dt`,{children:`Provider`}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:h3(e.provider.kind)}),e.provider.name&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`dt`,{children:`Reported name`}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.provider.name})]}),e.provider.version&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`dt`,{children:`Reported version`}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.provider.version})]}),(0,R.jsx)(`dt`,{children:`Source`}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:g3(e.source.kind)}),e.source.label&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`dt`,{children:`Reported source`}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.source.label})]}),(0,R.jsx)(`dt`,{children:`Scope`}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:`This thread · this request`}),e.expiresAt&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`dt`,{children:`Expires`}),(0,R.jsx)(`dd`,{className:`min-w-0 break-all text-fg/65`,children:e.expiresAt})]})]})]})}function J3({instanceId:e,fields:t,draft:n,setValue:r,errors:i,autoFocus:a}){let o=t.findIndex(e=>!e.secret);return(0,R.jsxs)(`fieldset`,{className:`min-w-0`,children:[(0,R.jsx)(`legend`,{className:`sr-only`,children:`Requested information`}),(0,R.jsx)(`div`,{className:`flex min-w-0 flex-col gap-3`,children:t.map((t,s)=>(0,R.jsx)(Y3,{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 Y3({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,R.jsxs)(R.Fragment,{children:[t.label,t.required&&(0,R.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-focus-accent-40`,f;if(t.secret)f=(0,R.jsx)(`div`,{className:`mt-1 text-[11px] text-attention-soft-70`,children:`Use the secure fallback below.`});else if(t.input===`multiline`)f=(0,R.jsx)(`textarea`,{id:o,name:t.id,"data-1p-ignore":!0,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,R.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,R.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,R.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,R.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,R.jsx)(`span`,{children:u})]});else if(t.input===`select`)f=(0,R.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,R.jsx)(`option`,{value:``,children:`Choose an option…`}),t.options.map((e,t)=>(0,R.jsx)(`option`,{value:String(t),children:e.label},t))]});else if(t.input===`multi-select`){let e=Array.isArray(n)?n:[];f=(0,R.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,R.jsx)(`legend`,{className:`px-1 text-[11px] font-medium text-fg/85`,children:u}),(0,R.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t.options.map((n,i)=>{let o=String(i);return(0,R.jsxs)(`label`,{className:`flex cursor-pointer items-start gap-2 text-[12px] text-fg/85`,children:[(0,R.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,R.jsx)(`span`,{children:n.label})]},o)})})]})}return(0,R.jsxs)(`div`,{className:`min-w-0`,children:[t.secret?(0,R.jsx)(`div`,{className:`text-[11px] font-medium text-fg/85`,children:u}):t.input!==`boolean`&&t.input!==`multi-select`?(0,R.jsx)(`label`,{htmlFor:o,className:`block text-[11px] font-medium text-fg/85`,children:u}):null,t.description&&(0,R.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,R.jsx)(`div`,{id:c,role:`alert`,className:`mt-1 text-[10.5px] text-danger-soft`,children:i})]})}function X3({steps:e}){return(0,R.jsx)(`div`,{"data-awaiting-steps":!0,className:`md-body ${GQ} mt-[var(--md-step)] first:mt-0`,children:(0,R.jsx)(`ol`,{children:e.map((e,t)=>(0,R.jsx)(Z3,{md:e},t))})})}function Z3({md:e}){return(0,R.jsx)(`li`,{children:(0,R.jsx)(uQ,{className:`md-body`,html:SX(e)})})}function Q3({slug:e,onReplied:t,onReplyFailed:n}){let r=OW(e),[i,a]=(0,L.useState)(!1);return(0,R.jsx)(a$,{"data-awaiting-steps-reply":!0,children:(0,R.jsx)(`button`,{type:`button`,"data-steps-done":!0,disabled:i,onClick:()=>{a(!0),r.submit(`Done`,{onOptimistic:()=>t?.(),onRollback:()=>{a(!1),n?.()}})||a(!1)},onMouseDown:e=>e.preventDefault(),className:`${c$} disabled:opacity-60`,children:PW})})}function $3(e){return(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).length}function e6(e,t={}){let n=(e.subAgents??[]).filter(e=>Au(e)&&e.state===`running`).length,r=(e.bgShells??[]).filter(e=>e.state===`running`).length,i=t.watchers===!1?0:$3(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 t6(e){return(e.subAgents??[]).some(e=>Au(e)&&e.state===`running`)}function n6(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length}function r6(e){return t6(e)||n6(e)>0}function i6(e,t){return Yu(t)??(a6(e)?`Background shells running`:`Awaiting`)}function a6(e){return(e.bgShells??[]).filter(e=>e.state===`running`).length>0&&!t6(e)&&$3(e)===0&&o6(e).length===0}function o6(e){return(e.watches??[]).filter(e=>e.kind===`timer`&&e.state===`armed`)}var s6={id:``,subAgents:[],bgShells:[],watches:[]},c6=[];function l6(e,t){if(t.length===0||e?.runtime!==`turn-idle`||e.lastFence?.kind!==`awaiting`)return!1;let n=Gu(e.lastFence.hints);return n.length===t.length&&n.every((e,n)=>e===t[n])}function u6(e,t){let n=new Set((e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`).map(e=>e.target));return FW(t).filter(e=>!n.has(e.ref))}function d6({watch:e}){return(0,L.useEffect)(()=>{e.url&&eh([e.ref])},[e.url,e.ref]),e.url?(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer noopener`,"data-gh-ref":e.ref,className:`${s$} text-[12px]`,children:e.ref}):(0,R.jsx)(`span`,{className:`text-[12px] text-muted`,children:e.ref})}var f6={mergeable:`no conflicts`,blocked:`merge blocked`,conflicting:`has conflicts`,unknown:null};function p6(e){return e.state!==`open`||e.merge===`blocked`&&e.checks!==`passing`&&e.checks!==`none`?null:f6[e.merge]}var m6=`shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`;function h6({tone:e}){return(0,R.jsx)(`span`,{"aria-hidden":!0,className:`inline-block size-3 rounded-full border ${e} border-t-transparent motion-safe:animate-spin ${m6}`})}function g6(){return(0,R.jsxs)(`svg`,{"aria-hidden":!0,viewBox:`0 0 16 16`,width:12,height:12,fill:`none`,stroke:`currentColor`,overflow:`visible`,className:m6,style:{color:ZO.fgAttention},children:[(0,R.jsx)(`circle`,{cx:`8`,cy:`8`,r:`4`,fill:`currentColor`,stroke:`none`}),(0,R.jsxs)(`g`,{strokeWidth:`2`,className:`origin-center motion-safe:animate-spin`,children:[(0,R.jsx)(`circle`,{cx:`8`,cy:`8`,r:`7`,opacity:`0.25`}),(0,R.jsx)(`path`,{d:`M15 8A7 7 0 0 1 8 15`})]})]})}function _6({status:e}){return e?e.state===`merged`?(0,R.jsx)(S_,{size:12,className:m6,style:{color:ZO.fgDone}}):e.state===`closed`?(0,R.jsx)(C_,{size:12,className:m6,style:{color:ZO.fgDanger}}):e.checks===`failing`?(0,R.jsx)(f_,{size:12,className:m6,style:{color:ZO.fgDanger}}):e.checks===`passing`?(0,R.jsx)(s_,{size:12,className:m6,style:{color:ZO.fgSuccess}}):e.gated>0&&e.running===0?(0,R.jsx)(o_,{size:12,className:m6,style:{color:ZO.fgAttention}}):e.checks===`running`?(0,R.jsx)(g6,{}):(0,R.jsx)(c_,{size:12,className:`${m6} text-muted-60`}):(0,R.jsx)(c_,{size:12,className:`${m6} text-muted-60`})}function v6(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 y6(e){if(!e)return`Checking…`;if(e.state===`merged`)return`Merged`;if(e.state===`closed`)return`Closed`;let t=v6(e),n=p6(e);return[t||`No checks`,n].filter(e=>e!==null).join(` · `)}function b6(e){if(!e)return`Checking…`;if(e.state===`open`&&e.failed===0){if(e.merge===`conflicting`)return`conflicts`;if(e.merge===`blocked`&&e.checks===`passing`)return`blocked`}return lk(e)}var x6=`group relative flex items-baseline rounded-sm px-2 text-[12px] leading-5`,S6=`ml-1.5 font-medium text-fg/90`,C6=`${S6} line-clamp-2 break-words`,w6=`${S6} min-w-0 flex-1 truncate`,T6=`ml-3 min-w-0 truncate text-right text-muted-70`,E6=`min-w-1/2 flex-1`,D6=`outline-none after:absolute after:inset-0 after:rounded-sm focus-visible:after:ring-1 focus-visible:after:ring-fg/60`;function O6(){return(0,R.jsx)(r_,{size:13,"aria-hidden":!0,className:`${m6} ml-[3px] -mr-[4px] text-muted-35 transition-colors group-hover:text-muted-70`})}function k6({mark:e,name:t,status:n,onOpen:r,onPrewarm:i,href:a,ghRef:o,title:s,testKind:c,testId:l,indent:u,dismiss:d,oneLine:f}){let p=u!==void 0,m=f?`${S6} truncate`:C6,h=p?w6:d?`${m} min-w-0`:`${m} ${E6}`,g=a?(0,R.jsx)(`a`,{href:a,target:`_blank`,rel:`noreferrer noopener`,title:s,"data-gh-ref":o,onMouseDown:e=>e.stopPropagation(),className:`${h} ${D6} group-hover:underline group-hover:decoration-fg/40 group-hover:underline-offset-2`,children:t}):r?(0,R.jsx)(`button`,{type:`button`,onClick:r,onMouseDown:e=>e.stopPropagation(),title:s,className:`${h} ${D6} text-left group-hover:underline group-hover:decoration-fg/40 group-hover:underline-offset-2`,children:t}):(0,R.jsx)(`span`,{className:h,title:s,children:t}),_=!!(a||r),v=d&&(0,R.jsx)(`button`,{type:`button`,onClick:d.onDismiss,onMouseDown:e=>e.stopPropagation(),title:d.title,"aria-label":d.label,className:`relative ml-0.5 shrink-0 self-start mt-[2.5px] 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-focus-ink-60`,children:(0,R.jsx)(cv,{size:11})});return(0,R.jsxs)(`div`,{"data-wait-row":l,"data-wait-kind":c,onMouseEnter:i,onFocus:i,style:p?{paddingLeft:8+u}:void 0,className:`${x6} ${_?`cursor-pointer transition-colors hover:bg-fg/[0.045]`:``}`,children:[(0,R.jsx)(`span`,{className:`flex shrink-0`,children:e}),v?(0,R.jsxs)(`span`,{className:`flex items-baseline ${E6}`,children:[g,v]}):g,(0,R.jsx)(`span`,{"data-wait-status":!0,className:T6,children:n}),_?(0,R.jsx)(O6,{}):(0,R.jsx)(`span`,{"aria-hidden":!0,className:`w-3 shrink-0`})]})}function A6({status:e}){return e?e.state===`closed`?e.stateReason===`not_planned`||e.stateReason===`duplicate`?(0,R.jsx)(d_,{size:12,className:`${m6} text-muted`}):(0,R.jsx)(s_,{size:12,className:m6,style:{color:ZO.fgDone}}):(0,R.jsx)(l_,{size:12,className:m6,style:{color:ZO.fgSuccess}}):(0,R.jsx)(c_,{size:12,className:`${m6} text-muted-60`})}function j6(e){if(!e)return`Checking…`;if(e.state===`closed`){let t=e.stateReason===`not_planned`?`not planned`:e.stateReason===`duplicate`?`duplicate`:null;return t?`Closed as ${t}`:`Closed`}return`Open · ${e.comments} comment${e.comments===1?``:`s`}`}function M6({watch:e}){if(e.subject===`issue`)return(0,R.jsx)(N6,{watch:e});let t=e.github,n=AW(e.target);return(0,L.useEffect)(()=>{n&&eh([e.target])},[n,e.target]),(0,R.jsx)(k6,{testKind:`github`,testId:e.target,mark:(0,R.jsx)(_6,{status:t}),name:e.target,href:n??void 0,ghRef:n?e.target:void 0,title:n?`Open ${e.target} on GitHub — ${y6(t)}`:e.target,status:t&&t.state===`open`&&t.failed>0&&n?(0,R.jsx)(`a`,{href:`${n}/checks`,target:`_blank`,rel:`noreferrer noopener`,title:`View the failing checks on ${e.target}`,onMouseDown:e=>e.stopPropagation(),className:`relative underline underline-offset-2 ${QO}`,children:b6(t)}):b6(t)})}function N6({watch:e}){let t=e.issue,n=AW(e.target,`issue`);return(0,L.useEffect)(()=>{n&&eh([e.target])},[n,e.target]),(0,R.jsx)(k6,{testKind:`github`,testId:`issue:${e.target}`,mark:(0,R.jsx)(A6,{status:t}),name:t?.title?`${e.target} ${t.title}`:e.target,href:n??void 0,ghRef:n?e.target:void 0,title:n?`Open ${e.target} on GitHub — ${j6(t)}`:e.target,status:t?uk(t):`Checking…`})}function P6(e,t){return(e.bgShells??[]).find(e=>e.id===t||e.taskId===t||e.label===t)}function F6(e){return(e.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`)}function I6({watch:e,thread:t,slug:n,now:r}){let i=P6(t,e.target);if(i)return(0,R.jsx)(R6,{shell:i,slug:n,now:r,testId:e.target});let a=qO(e.createdAt,r);return(0,R.jsx)(k6,{testKind:`shell`,testId:e.target,mark:(0,R.jsx)(rv,{size:12,className:`${m6} text-shell`}),name:e.target,title:e.target,status:a})}function L6(e,t,n,r,i){if(!e||t&&n)return;let a=t?`running`:`settled`;return{onDismiss:e,title:fk[a],label:`${pk[a]} ${mk[r]}: ${i}`}}function R6({shell:e,slug:t,now:n,testId:r,onDismiss:i}){let a=qO(e.startedAt,n),o=e.state===`running`,s=e.id&&!e.outputUnavailable,c=o?`running for ${a}`:ok;return(0,R.jsx)(k6,{testKind:`shell`,testId:r??e.id??e.label,mark:(0,R.jsx)(rv,{size:12,className:`${m6} ${o?`text-shell`:`text-muted-60`}`}),name:e.label,onOpen:s?()=>Yh(t,e.id,{label:e.label,startedAt:e.startedAt}):void 0,title:s?`Read this shell's output — ${c}`:o?e.label:`${e.label} — ${c}`,status:a,dismiss:L6(i,o,!!s,`SHELL`,e.label)})}function z6({watch:e,now:t}){let n=Date.parse(e.timer?.fireAt??``),r=Number.isFinite(n)?n>t?`in ${GO(n-t)}`:`firing…`:`armed`,i=e.timer?.prompt;return(0,R.jsx)(k6,{testKind:`timer`,testId:e.target,mark:(0,R.jsx)(p_,{size:12,className:`${m6} text-muted-60`}),name:i||e.target,oneLine:!0,title:[i,e.timer?.fireAt?`One-off timer, set for ${e.timer.fireAt}`:e.target].filter(Boolean).join(`
|
|
327
327
|
|
|
328
|
-
`),status:r})}function B6(e){return(e.subAgents??[]).filter(e=>Au(e)&&e.state===`running`)}function V6({agent:e,slug:t,now:n,onDismiss:r}){let i=JO(e.startedAt,n),a=e.subagentType?.replace(/^frizz:/,``),o=e.state===`stale`;return(0,R.jsx)(k6,{testKind:`agent`,testId:e.id??e.label,mark:o?(0,R.jsx)(`span`,{"aria-hidden":!0,className:`inline-block size-3 p-[3px] ${m6}`,children:(0,R.jsx)(`span`,{className:rk})}):(0,R.jsx)(h6,{tone:`border-accent`}),name:e.label,onOpen:e.id?()=>Jh(t,e.id,{label:e.label,subagentType:e.subagentType,startedAt:e.startedAt}):void 0,title:e.id?`Open this sub-agent${a?` (${a})`:``} — ${o?ik:`working for ${i}`}`:e.label,status:i,dismiss:L6(r,e.state===`running`,!!e.id,`AGENT`,e.label)})}function H6(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=P6(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 U6(e,t={}){let n=(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`),r=n.filter(e=>e.subject!==`issue`),i=n.filter(e=>e.subject===`issue`),a=F6(e);return{prs:r,issues:i,shells:[...a,...H6(e,t.hints??[],a)],agents:B6(e),timers:o6(e)}}function W6(e,t,n={}){let{prs:r,issues:i,shells:a,agents:o,timers:s}=U6(e,n);return[{head:`Sub-agents`,rows:o.map(n=>(0,R.jsx)(V6,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:a.map(n=>(0,R.jsx)(I6,{watch:n,thread:e,slug:e.id,now:t},n.id))},{head:`Pull requests`,rows:r.map(e=>(0,R.jsx)(M6,{watch:e},e.id))},{head:`Issues`,rows:i.map(e=>(0,R.jsx)(M6,{watch:e},e.id))},{head:`Timers`,rows:s.map(e=>(0,R.jsx)(z6,{watch:e,now:t},e.id))}].filter(e=>e.rows.length>0)}function G6({group:e,first:t}){let n=`px-2 text-[10.5px] uppercase tracking-wide text-muted-45 ${t?``:`mt-4`}`;return e.onToggle?(0,R.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,R.jsx)(`span`,{children:e.head}),e.count!==void 0&&(0,R.jsx)(`span`,{className:`ml-1.5 tabular-nums`,children:e.count}),(0,R.jsx)(r_,{size:10,"aria-hidden":!0,className:`${m6} ml-[5px] transition-transform ${e.collapsed?``:`rotate-90`}`})]}):(0,R.jsx)(`div`,{className:n,children:e.head})}function K6({groups:e,divider:t}){return e.length===0?null:(0,R.jsxs)(R.Fragment,{children:[t&&(0,R.jsx)(`div`,{"aria-hidden":!0,className:`-mx-4 mt-3 border-t border-border`}),(0,R.jsx)(`div`,{className:`-mx-2 mt-3 flex flex-col gap-y-px`,children:e.map((e,t)=>(0,R.jsxs)(L.Fragment,{children:[(0,R.jsx)(G6,{group:e,first:t===0}),!e.collapsed&&e.rows]},e.head))})]})}function q6(e){return e?.lastFence?.kind===`awaiting`&&jW(e.lastFence.hints)?!1:e?.awaitingBackground===!0&&e.runtime===`turn-idle`&&e.bgSnoozed!==!0}var J6=`Hides card until new activity is detected`;function Y6({thread:e,onSnooze:t,onSnoozeFailed:n}){let[r,i]=(0,L.useState)(!1);return(0,R.jsxs)(R.Fragment,{children:[(0,R.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:J6,className:`disabled:opacity-45 ${c$}`,children:[(0,R.jsx)(D_,{size:12,className:m2}),`Snooze`]}),(0,R.jsx)(`span`,{className:o$,children:J6})]})}function X6({thread:e,fence:t,onSnooze:n,onSnoozeFailed:r,onReplied:i,onReplyFailed:a}){let o=e??s6,s=t??(e?.lastFence?.kind===`awaiting`?e.lastFence:void 0),c=s?.hints??c6,l=Gu(c),u=l.length>0?Yu(c):null,d=e!==void 0&&l6(e,l),f=t6(o),p=VW(s?.body),m=SX(p??``),h=W6(o,RO(),{hints:c}),g=u6(o,c),_=e!==void 0&&l.length===0&&e.waitStatus!==`watching`&&q6(e)&&zK(e).snooze;return(0,R.jsxs)(r$,{"data-awaiting-background":!0,icon:l.length>0?_ee:a6(o)?rv:D_,chip:l.length>0?NW:void 0,label:l.length>0?u?(0,R.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:u}):null:(0,R.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:i6(o,c)}),aside:g.length===1?(0,R.jsx)(d6,{watch:g[0]}):void 0,children:[p?(0,R.jsx)(uQ,{className:`md-body ${GQ}`,html:m}):h.length===0&&!r6(o)&&l.length===0?(0,R.jsx)(`p`,{className:i$,children:MW}):null,l.length>0&&(0,R.jsx)(X3,{steps:l}),g.length>1&&(0,R.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:g.map(e=>(0,R.jsx)(d6,{watch:e},e.ref))}),h.length===0&&r6(o)&&(0,R.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75`,children:f?(0,R.jsxs)(R.Fragment,{children:[`It’s awaiting the results from `,e6(o,{watchers:!1}),` it dispatched. It returns to the queue on its own when the work comes back.`]}):(0,R.jsxs)(R.Fragment,{children:[e6(o,{watchers:!1}),` `,n6(o)===1?`is`:`are`,` still running. It resumes on its own when`,` `,n6(o)===1?`it finishes`:`one of them finishes`,`.`]})}),(0,R.jsx)(K6,{groups:h,divider:!!p}),d?(0,R.jsx)(Q3,{slug:e.id,onReplied:i,onReplyFailed:a}):_?(0,R.jsx)(a$,{"data-awaiting-snooze":!0,children:(0,R.jsx)(Y6,{thread:e,onSnooze:n,onSnoozeFailed:r})}):null]})}function Z6(e,t=Date.now()){return e!==void 0&&gf(e,t)!==void 0}function Q6(){let[e,t]=(0,L.useState)(()=>Date.now());return(0,L.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function $6({thread:e}){let t=Q6(),[n,r]=(0,L.useState)(!1),i=gf(e,t);if(!i)return null;let a=Date.parse(i),o=jD(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,R.jsxs)(r$,{"data-snooze-card":!0,icon:Jg,label:`Snoozed`,children:[(0,R.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:xte(a-t)}),(0,R.jsx)(`p`,{className:i$,children:s?(0,R.jsxs)(R.Fragment,{children:[`Resumes `,o,` and sends: “`,ND(s),`”`]}):(0,R.jsxs)(R.Fragment,{children:[`Returns to the queue `,o,`.`]})}),e.foreign!==!0&&(0,R.jsx)(a$,{children:(0,R.jsx)(`button`,{type:`button`,"data-snooze-wake-now":!0,disabled:n,onClick:()=>void c(),className:`${c$} disabled:cursor-not-allowed disabled:opacity-45`,children:`Wake now`})})]})}var e8=1500;function t8(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},e8),a},fail(t){t===n&&(i(),e(!1))},dispose(){n++,i()}}}var n8=`Could not copy terminal command`,r8={attach:`Attach command copied`,resume:`Resume command copied`},i8={attach:`Copy command to attach to this thread's live terminal`,resume:`Copy command to resume this thread in a new terminal`},a8=e=>[`terminalCommand`,e];function o8(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 s8(e){let t=o8(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 eH(n),r}function c8(e){let t=pt({mutationFn:()=>s8(e)});return e=>t.mutate(void 0,{onSuccess:t=>{e?.onSuccess?.(),Z(r8[t])},onError:t=>{e?.onError?.(),Z(t instanceof Error?`${n8}: ${t.message}`:n8,{duration:7e3})}})}function l8({slug:e}){let[t,n]=(0,L.useState)(!1),r=(0,L.useRef)(null);r.current||=t8(n,{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)});let i=qe(),a=c8(e);(0,L.useEffect)(()=>()=>r.current?.dispose(),[]);function o(){i.prefetchQuery({queryKey:a8(e),queryFn:()=>o8(e),staleTime:15e3})}function s(){let t=i.getQueryData(a8(e));if(t){eH(t.command).then(()=>{r.current?.begin(),Z(r8[t.mode])},()=>Z(n8,{duration:7e3}));return}a({onSuccess:()=>r.current?.begin()})}let c=i.getQueryData(a8(e)),l=t?c?r8[c.mode]:`Terminal command copied`:c?i8[c.mode]:`Copy terminal command`;return(0,R.jsx)(IP,{label:l,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":l,title:l,onClick:s,onPointerEnter:o,onFocus:o,className:Mk,children:t?(0,R.jsx)(e_,{size:14,strokeWidth:2.2,className:`text-fg`}):(0,R.jsx)(rv,{size:14,strokeWidth:1.8})})})}function u8(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 d8(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 f8(e){return`legacy:${e.role}:${e.kind??`message`}:${e.at??``}:${e.text}`}function p8(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??f8(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 m8(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 h8(e,t){let n=e.map(e=>e.message);return e.filter((e,r)=>!m8(n,r,t))}function g8(e,t){let n=Promise.resolve();function r(r){let i={...r,palette:{...r.palette}},a=n.then(async()=>{try{return await e(i)}finally{t(i.id)}});return n=a.then(()=>void 0,()=>void 0),a}return{enqueue:r}}function _8(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function v8(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function y8(e,t){let n=_8(e,t);if(n)try{let e=new URL(n);return e.protocol===`https:`||e.protocol===`http:`?e.href:void 0}catch{return}}function b8({directive:e,icon:t,title:n,meta:r,children:i}){return(0,R.jsxs)(`section`,{"data-codex-directive":e.name,className:`min-w-0 ${KQ} border border-border bg-panel-2/75 p-4`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center text-muted`,"aria-hidden":!0,children:t}),(0,R.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,R.jsx)(`div`,{className:`min-w-0 truncate text-[11px] font-normal leading-4 text-muted`,children:r})]}),i]})}function x8({children:e,mono:t=!1}){return(0,R.jsx)(`div`,{className:`ml-6 mt-1 break-words text-[11px] leading-4 text-muted${t?` font-mono-keep`:``}`,children:e})}function S8({directive:e}){let t=e.attrs,n=_8(t,`display_name`)??_8(t,`skill_name`)??`Artifact template`,r=_8(t,`artifact_kind`),i=_8(t,`skill_name`),a=_8(t,`skill_directory`),[o,s]=(0,L.useState)(!!a);return(0,R.jsxs)(b8,{directive:e,icon:(0,R.jsx)(hee,{size:15}),title:n,meta:r?`${r} template`:`Template`,children:[i&&(0,R.jsx)(x8,{mono:!0,children:i.startsWith(`$`)?i:`$${i}`}),o&&a&&(0,R.jsx)(`img`,{src:BT(`${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 C8({directive:e}){let t=e.attrs,n=_8(t,`file`),r=v8(t,`start`),i=v8(t,`end`)??r,a=v8(t,`priority`),o=n?`${n}${r?`:${r}${i&&i!==r?`-${i}`:``}`:``}`:`Code location unavailable`;return(0,R.jsxs)(b8,{directive:e,icon:(0,R.jsx)(P_,{size:15}),title:_8(t,`title`)??`Review finding`,meta:a===void 0?void 0:`P${a}`,children:[_8(t,`body`)&&(0,R.jsx)(x8,{children:_8(t,`body`)}),n?(0,R.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,R.jsx)(x8,{mono:!0,children:o})]})}var w8={"git-stage":[B_,`Changes staged`],"git-commit":[x_,`Commit created`],"git-create-branch":[b_,`Branch created`],"git-push":[sv,`Branch pushed`],"git-create-pr":[T_,`Pull request created`]};function T8({directive:e}){let[t,n]=w8[e.name],r=_8(e.attrs,`branch`),i=y8(e.attrs,`url`),a=`${n}${e.attrs.isDraft===!0?` as draft`:``}`;return(0,R.jsx)(b8,{directive:e,icon:(0,R.jsx)(t,{size:15}),title:i?(0,R.jsx)(`a`,{className:`text-accent underline underline-offset-2`,href:i,target:`_blank`,rel:`noopener noreferrer`,children:a}):a,meta:r&&(0,R.jsx)(`span`,{className:`font-mono-keep`,children:r})})}function E8({directive:e}){let t=_8(e.attrs,`threadId`),n=_8(e.attrs,`pendingWorktreeId`);return(0,R.jsx)(b8,{directive:e,icon:(0,R.jsx)(z_,{size:15}),title:n?`Thread setup queued`:`Thread created`,meta:(t||n)&&(0,R.jsx)(`span`,{className:`font-mono-keep`,children:t??n})})}function D8({directive:e}){let t=_8(e.attrs,`reason`);return(0,R.jsx)(b8,{directive:e,icon:(0,R.jsx)(dee,{size:15}),title:`Archive suggested`,meta:t})}function O8(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 k8({directive:e}){let t=e.attrs,n=_8(t,`mode`),r=_8(t,`name`)??`Automation`,i=O8(t.rrule),a=[r,n,_8(t,`status`),i].filter(Boolean).join(` · `);return(0,R.jsx)(b8,{directive:e,icon:(0,R.jsx)($g,{size:15}),title:`Automation suggested`,meta:a,children:_8(t,`prompt`)&&(0,R.jsx)(x8,{children:_8(t,`prompt`)})})}function A8({directive:e}){return e.name===`artifact-template`?(0,R.jsx)(S8,{directive:e}):e.name===`code-comment`?(0,R.jsx)(C8,{directive:e}):e.name.startsWith(`git-`)?(0,R.jsx)(T8,{directive:e}):e.name===`created-thread`?(0,R.jsx)(E8,{directive:e}):e.name===`archive`||e.name===`archive-thread`?(0,R.jsx)(D8,{directive:e}):(0,R.jsx)(k8,{directive:e})}var j8,M8=0;function N8(){return j8??=MS(async()=>{let{default:e}=await import(`./mermaid.core-ChLUqNEE.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])).then(({default:e})=>e),j8}function P8(){let e=getComputedStyle(document.documentElement),t=t=>e.getPropertyValue(t).trim();return{background:t(`--color-panel-2`),primaryColor:t(`--color-panel-2`),primaryTextColor:t(`--color-fg`),primaryBorderColor:t(`--color-control-strong`),lineColor:t(`--color-muted`),secondaryColor:t(`--color-border`),tertiaryColor:t(`--color-bg`),fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`}}var F8=g8(async e=>{let t=await N8();return t.initialize({startOnLoad:!1,securityLevel:`strict`,theme:e.resolved===`dark`?`dark`:`base`,themeVariables:e.palette}),t.render(e.id,e.source)},e=>document.getElementById(`d${e}`)?.remove());function I8({source:e}){let t=(0,L.useId)(),{resolved:n}=(0,L.useSyncExternalStore)(A2,O2,O2),[r,i]=(0,L.useState)({}),a=(0,L.useRef)(0),o=rZ(r.html??``);return(0,L.useEffect)(()=>{let r=!0,o=++a.current;if(i(e=>e.error?{html:e.html}:e),e.length>5e4)return i({error:`Diagram source exceeds the 50 KB rendering limit`}),()=>{r=!1};let s=`frizz-mermaid-${t.replace(/[^a-zA-Z0-9]/g,``)}-${++M8}`;return F8.enqueue({id:s,source:e,resolved:n,palette:P8()}).then(({svg:e})=>{r&&a.current===o&&i({html:e})}).catch(e=>{if(!r||a.current!==o)return;let t=e instanceof Error?e.message.split(/\n| for text:/,1)[0]:`Unknown diagram error`;i({error:t.slice(0,240)})}),()=>{r=!1}},[t,n,e]),r.error?(0,R.jsxs)(`section`,{"data-mermaid-state":`error`,className:`${KQ} border border-border bg-panel-2/75 p-4`,children:[(0,R.jsx)(`div`,{className:`text-[12px] font-medium text-fg`,children:`Diagram unavailable`}),(0,R.jsx)(`div`,{className:`mt-1 text-[11px] text-muted`,children:r.error}),(0,R.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})]}):r.html?(0,R.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:o}):(0,R.jsx)(`div`,{"data-mermaid-state":`loading`,role:`status`,"aria-label":`Rendering diagram`,className:`h-24 animate-pulse ${KQ} bg-panel-2`})}var L8=(0,L.createContext)(null),R8=(0,L.createContext)(null);function z8(){let e=(0,L.useContext)(L8),t=(0,L.useContext)(R8);return e??t}var B8=(0,L.createContext)(null);function V8(e){return e.status===`pending`&&e.backgroundState===`background`}function H8(e){let t=[];for(let n of e)for(let e of n.tools)V8(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 U8(e){return e.map(e=>{if(!e.tools.some(V8))return e;let t=e.tools.filter(e=>!V8(e)),n=e.parts?.map(e=>e.kind===`tools`?{...e,tools:e.tools.filter(e=>!V8(e))}:e).filter(e=>e.kind!==`tools`||e.tools.length>0);return{...e,tools:t,parts:n}})}function W8({slug:e,onStatusApplied:t,onClose:n,virtualized:r=!1,showReturnToQueue:i=!1}){Cg(ME(),e);let a=Lg()&&n!==void 0,{splitFileViewer:o}=gr(X);return(0,R.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[a?(0,R.jsx)(c4,{slug:e,onClose:n}):(0,R.jsx)(i5,{slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:i}),(0,R.jsx)(G8,{slug:e,virtualized:r,phone:a,railBeside:i&&o})]})}function G8({slug:e,virtualized:t,phone:n=!1,railBeside:r=!1}){let i=ME(),a=Cg(i,e),o=C0(a),s=(0,L.useMemo)(()=>T0(a,o),[a,o]),c=(0,L.useMemo)(()=>n?{numberOf:e=>s.findIndex(t=>t.id===e)+1}:null,[n,s]),[l,u]=(0,L.useState)(!1),d=a?.runtime===`running`||a?.runtime===`spawning`,f=c8(e),p=RE(e,{poll:d}),m=qe(),h=(0,L.useRef)(!1),[g,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)(null),b=(0,L.useMemo)(()=>p.data?.messages??[],[p.data]),x=(0,L.useMemo)(()=>H8(b),[b]),S=(0,L.useMemo)(()=>U8(b),[b]),C=(0,L.useMemo)(()=>y5(S),[S]),w=d?S.length:C,T=(0,L.useMemo)(()=>sK(S),[S]),E=d?uK(T):void 0,D=d?lK(T):void 0,O=D?yK(D,i?.projectDir):void 0,k=d?fK(T):void 0,A=q6(a),j=(0,L.useMemo)(()=>{let e=d?mK(T):T;return h8(e,b5(e,w,A))},[T,d,w,A]),M=d,N=(0,L.useMemo)(()=>j$(b),[b]),P=(0,L.useMemo)(()=>E$(b,a?.answersInFlight),[b,a?.answersInFlight]),F=(0,L.useMemo)(()=>f2(b),[b]),I=WQ(a,C>=0?S[C]?.text:void 0),ee=(0,L.useMemo)(()=>J$(b,s),[b,s]),te={thread:a,showWorking:M,registeredDone:I,restedCard:l$(a,C>=0?S[C]?.text:void 0,ee),errorVisible:d$(S,a?.providerError)},{answeringForMessage:ne}=I1(e,b),re=(0,L.useMemo)(()=>z$(b,s),[b,s]),ie=(0,L.useMemo)(()=>q$(b,s),[b,s]),ae=(0,L.useMemo)(()=>$$(b,o),[b,o]),oe=Vd(a?.spawnedAt),se=(0,L.useRef)(null),[ce,le]=(0,L.useState)(null),ue=p.data?.messages.length??0,de=!p.isLoading;(0,L.useEffect)(()=>{if(t)return;let e=se.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<=4&&(e.scrollTop=e.scrollHeight)},[ue,d,t]);let fe=(0,L.useCallback)(async()=>{if(h.current)return;let t=m.getQueryData([`transcript`,e]),n=t?.beforeCursor,r=t?.transcriptKey;if(!(!t?.hasEarlier||!n||!r)){h.current=!0,_(!0),y(null);try{let t=await Y.threadTranscriptEarlier({slug:e,cursor:n}),i=m.getQueryData([`transcript`,e]);if(!i?.transcriptKey||i.transcriptKey!==r||t.transcriptKey!==r){await p.refetch(),Z(`Transcript changed while loading history; refreshed the current session`);return}m.setQueryData([`transcript`,e],ow(i,t))}catch(e){let t=e instanceof Error?e.message:`Could not load earlier transcript history`;y(t)}finally{h.current=!1,_(!1)}}},[p,m,e]);return(0,R.jsx)(L8.Provider,{value:e,children:(0,R.jsx)(O0,{thread:a,children:(0,R.jsx)(K1.Provider,{value:c,children:(0,R.jsxs)(`div`,{"data-drawer-scroll-ready":p.isPending?`false`:`true`,className:`flex-1 min-h-0 flex flex-col overflow-hidden outline-none`,children:[(0,R.jsxs)(`div`,{className:`relative min-h-0 flex-1 flex flex-col`,children:[(0,R.jsx)(`div`,{ref:se,"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&&g?!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-focus-ink-60`,children:t&&ue>0?(0,R.jsx)(n5,{slug:e,transcriptRef:se,transcriptKey:p.data?.transcriptKey,messages:S,paired:N,inFlightAnswers:P,answeringForMessage:ne,placement:ie,settledPlacement:ae,openQuestions:s,fencesLive:oe,thread:a,running:d,copyTerminalCommand:f,transportFallback:p.transportFallback,isFetching:p.isFetching,refresh:()=>void p.refetch(),retryLiveUpdates:p.retryLiveUpdates,hasEarlier:p.data?.hasEarlier===!0,beforeCursor:p.data?.beforeCursor,loadingEarlier:g,earlierError:v,loadEarlier:()=>void fe(),jumpOverlay:ce,openAtLastMessage:n&&!d}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P3,{thread:a,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,R.jsx)(A0,{thread:a,inFlight:P,className:`px-6 pt-5`}),p.transportFallback&&(0,R.jsx)(X8,{fallback:p.transportFallback,isFetching:p.isFetching,onRefresh:()=>void p.refetch(),onRetryLive:p.retryLiveUpdates,className:`mx-6 mt-3`}),(0,R.jsx)(`div`,{"data-transcript-column":!0,className:`flex min-h-full flex-col px-6 py-5`,children:ue===0?(0,R.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted`,children:p.isPending?(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Y5,{}),` Loading…`]}):d?(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Y5,{}),` Session starting…`]}):F2(a)?(0,R.jsxs)(`div`,{className:`text-center`,children:[(0,R.jsx)(`p`,{className:`mb-3`,children:`No session is attached to this thread yet.`}),(0,R.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,R.jsxs)(R.Fragment,{children:[T5(j.map(e=>e.message),(e,t)=>{let n=j[t].messageIndex;return(0,R.jsx)(H5,{m:e,answering:oe?ne(e):void 0,showSendButton:!0,paired:N[n],staleAwaiting:w>=0&&n<w,restingCardShown:n===C&&A,shadowedBy:re.get(n),placed:ie.placed.get(n),settledPlaced:ae.placed.get(n),thread:a},t)},e=>!!e.queued),de&&$8(te)!==null&&(0,R.jsx)(e1,{h:e5(te,j.map(e=>e.message))}),de&&(0,R.jsx)(t5,{state:te,slug:e,retryText:F>=0?b[F]?.text:void 0,onTerminal:f,liveRuntimeStart:k,liveActivityLabel:O,liveToolRun:E}),a?.permPolicy?(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(q5,{policy:a.permPolicy,denies:a.permDenies})}):null,b.some(e=>e.queued)&&(0,R.jsx)(e1,{}),(0,R.jsx)(`div`,{className:`flex flex-col gap-3.5`,children:b.map((e,t)=>e.queued?(0,R.jsx)(H5,{m:e,paired:N[t]},`q${t}`):null)})]})})]})}),(0,R.jsx)(`div`,{ref:le,"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,R.jsx)(`div`,{"data-thread-chat-footer":!0,className:`z-10 shrink-0 border-t border-border/60 bg-panel ${n?``:`pb-[env(safe-area-inset-bottom)]`}`,children:(0,R.jsx)(t4,{slug:e,above:n||r||!a?void 0:(0,R.jsx)(a4,{thread:a,transcriptShells:x}),phoneBarOverride:n&&s.length>0?e=>(0,R.jsx)(Z1,{count:s.length,onAnswer:()=>u(!0),onReply:e.editReply}):void 0,phoneChrome:n})}),n&&l&&(0,R.jsx)(M0,{questions:s,onClose:()=>u(!1)})]})})})})}var K8=700,q8=250,J8=900,Y8=(()=>{try{return localStorage.getItem(`frizz.debugScroll`)===`1`}catch{return!1}})();function X8({fallback:e,isFetching:t,onRefresh:n,onRetryLive:r,className:i=``}){return(0,R.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] ${i}`,title:e.kind===`payload-too-large`?`Live payload ${e.actualBytes} bytes; socket limit ${e.maxBytes} bytes`:`Transcript read budget reached (${e.scope}); retry after about ${e.retryAfterMs}ms`,children:[(0,R.jsx)(ov,{size:13,className:`shrink-0 text-muted`}),(0,R.jsxs)(`div`,{className:`min-w-[180px] flex-1 leading-snug text-fg/85`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Live transcript updates paused.`}),` `,e.kind===`payload-too-large`?`The transcript is too large for push; it refreshes over HTTP each time the thread moves.`:`The live read budget was reached; the last complete copy remains visible. Retry in a moment.`]}),(0,R.jsx)(`button`,{type:`button`,disabled:t,onClick:n,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:t?`Refreshing…`:`Refresh once`}),(0,R.jsx)(`button`,{type:`button`,onClick:r,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`})]})}function Z8(e){return e?.pendingInteraction===!0}function Q8(e){return Z8(e)?void 0:e?.pendingAsk}function $8({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`:Q8(e)?`pending-ask`:e?.runtime===`perm-prompt`&&!Z8(e)?`perm-prompt`:t?`working`:e?.providerError?i?null:`provider-error`:Z6(e)?`snooze`:q6(e)?`resting`:n?`registered-done`:r?`rested`:null}function e5(e,t){return $8(e)===`working`?w5(t):14}function t5({state:e,slug:t,retryText:n,onTerminal:r,liveRuntimeStart:i,liveActivityLabel:a,liveToolRun:o,onRestingExit:s,onRestingExitFailed:c,wrap:l}){let u=e.thread;switch($8(e)){case`provider-fault`:return(0,R.jsx)(ore,{slug:t,sessionId:u.sessionId,fault:u.providerFault,retryText:n});case`provider-error`:return(0,R.jsx)(f$,{error:u.providerError});case`limit-pause`:return(0,R.jsx)(sre,{slug:t,sessionId:u.sessionId,pause:u.limitPause});case`pending-ask`:return(0,R.jsx)(lre,{ask:Q8(u),onTerminal:r});case`perm-prompt`:return(0,R.jsx)(cre,{onTerminal:r});case`working`:return(0,R.jsx)(X5,{since:u?.lastUserAt,startedAt:i,activityLabel:a,run:o});case`snooze`:return(0,R.jsx)($6,{thread:u});case`resting`:return(0,R.jsx)(X6,{thread:u,onSnooze:s,onSnoozeFailed:c,onReplied:s,onReplyFailed:c});case`registered-done`:return(0,R.jsx)(K5,{fenceKind:`done`,body:u.lastFence.body,hints:[],wrap:l});case`rested`:return(0,R.jsx)(u$,{thread:u});default:return null}}function n5({slug:e,transcriptRef:t,transcriptKey:n,messages:r,paired:i,inFlightAnswers:a,answeringForMessage:o,placement:s,settledPlacement:c,openQuestions:l,fencesLive:u,thread:d,running:f,copyTerminalCommand:p,transportFallback:m,isFetching:h,refresh:g,retryLiveUpdates:_,hasEarlier:v,beforeCursor:y,loadingEarlier:b,earlierError:x,loadEarlier:S,jumpOverlay:C,openAtLastMessage:w=!1}){let T=NE(),E=(0,L.useMemo)(()=>sK(r),[r]),D=f?uK(E):void 0,O=f?lK(E):void 0,k=O?yK(O,T):void 0,A=f?fK(E):void 0,j=(0,L.useMemo)(()=>y5(r),[r]),M=f?r.length:j,N=q6(d),P=(0,L.useMemo)(()=>{let e=f?mK(E):E;return h8(e,b5(e,M,N))},[E,f,M,N]),F=f,I=(0,L.useMemo)(()=>{let e=p8(P.map(e=>e.message),b5(P,M,N),_5),t=e=>P[e.messageIndex].runStartedAt??e.message.at,n=X0(e,t,e=>e.message.at);return e.map((e,r)=>({...e,messageIndex:P[e.messageIndex].messageIndex,timeBreak:n[r],timeBreakAt:t(e)}))},[P,M,N]),ee=(0,L.useMemo)(()=>f2(r),[r]),te=WQ(d,j>=0?r[j]?.text:void 0),ne=(0,L.useMemo)(()=>J$(r,l),[r,l]),re=l$(d,j>=0?r[j]?.text:void 0,ne),ie=d$(r,d?.providerError),ae={thread:d,showWorking:F,registeredDone:te,restedCard:re,errorVisible:ie},oe=$8(ae)!==null,se=oe||!!d?.permPolicy,ce=(0,L.useMemo)(()=>e5({thread:d,showWorking:F,registeredDone:te,restedCard:re,errorVisible:ie},P.map(e=>e.message)),[P,F,d,te,re,ie]),le=(0,L.useMemo)(()=>{let e=[],t=new Map,n=r.length-1,i=e=>{let t=-1;for(let n=0;n<I.length&&!(I[n].messageIndex>e);n++)t=n;return t},a=l.filter(e=>!s.placedIds.has(e.id));for(let[o,s]of I$(r,a)){if(o>=n){e.push(...s);continue}let r=i(o),a=t.get(r);a?a.push(...s):t.set(r,[...s])}let o=!1,c=new Set;for(let e of X$(r,s)){if(e>=n){o=!0;continue}let r=i(e);c.add(r),t.has(r)||t.set(r,[])}return{byRow:t,tail:e,tailSend:o,sendRows:c}},[I,r,l,s]),ue=(0,L.useMemo)(()=>{let e=new Map;for(let[t,n]of c.anchored){let r=-1;for(let e=0;e<I.length&&!(I[e].messageIndex>t);e++)r=e;if(r<0)continue;let i=e.get(r);i?i.push(...n):e.set(r,[...n])}return e},[I,c.anchored]),de=(0,L.useMemo)(()=>z$(r,l),[r,l]),fe=(0,L.useMemo)(()=>{let e=[{key:`head-anchor`,kind:`head-anchor`}];m&&e.push({key:`transport-fallback`,kind:`transport-fallback`}),(v||b||x)&&e.push({key:`earlier-history:${y??`complete`}`,kind:`earlier-history`});let t=le.byRow.get(-1);t&&e.push({key:`questions:head`,kind:`questions`,questions:t,send:le.sendRows.has(-1)}),I.forEach((t,n)=>{e.push({...t,kind:`message`});let r=ue.get(n);r&&e.push({key:`settled-questions:${t.key}`,kind:`settled-questions`,questions:r});let i=le.byRow.get(n);i&&e.push({key:`questions:${t.key}`,kind:`questions`,questions:i,send:le.sendRows.has(n)})}),e.push({key:`interactions`,kind:`interactions`}),se&&e.push({key:`runtime-status`,kind:`runtime-status`});let n=se||I.length>0?14:0;return r.forEach((t,r)=>{if(!t.queued)return;let i=`queued:${t.deliveryId??t.sourceId??r}`;e.push({key:i,kind:`queued`,message:t,messageIndex:r,gap:n}),n=14}),e},[y,x,v,se,b,I,r,le,ue,m]),pe=yD({count:fe.length,getScrollElement:()=>t.current,getItemKey:e=>fe[e]?.key??e,estimateSize:e=>{let t=fe[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===`settled-questions`?140: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})}}),[me,he]=(0,L.useState)(!0),ge=(0,L.useRef)(!0),_e=(0,L.useRef)(-1),ve=(0,L.useRef)(0),ye=(0,L.useRef)(null),be=(0,L.useRef)(!1),xe=(0,L.useRef)(!1),Se=(0,L.useRef)(!0),Ce=(0,L.useRef)(null),we=(0,L.useRef)(void 0),Te=(0,L.useRef)(null),Ee=(0,L.useRef)(void 0),De=(0,L.useRef)(0),Oe=(0,L.useRef)(0),ke=(0,L.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&&(Ce.current={rowKey:r,viewportTop:n.getBoundingClientRect().top-t})}S()},[S,t]),Ae=(0,L.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,L.useLayoutEffect)(()=>{if(!n||fe.length===0||we.current===n)return;we.current=n,be.current=!1,xe.current=!1,Se.current=!0;let r=Ok(e)?.candidates.map(e=>({candidate:e,index:fe.findIndex(t=>t.kind===`message`&&t.message.sourceId===e.sourceId)})).find(e=>e.index>=0),i=!r&&w&&j>=0?fe.reduce((e,t,n)=>t.kind===`message`&&t.messageIndex<=j&&t.message.role===`assistant`&&t.message.kind!==`event`?n:e,-1):-1,a=requestAnimationFrame(()=>{if(!r&&i>=0){let e=fe[i].key;pe.scrollToIndex(i,{align:`start`,behavior:`instant`}),ge.current=!1,he(!1),be.current=!0;let n=performance.now()+J8;De.current=n;let r=()=>{let i=t.current;if(!i||performance.now()>=n||performance.now()<ve.current){De.current=0,Oe.current=0,i&&i.scrollHeight-i.clientHeight-i.scrollTop<=4&&(ge.current=!0,_e.current=i.scrollHeight,he(!0));return}let a=i.querySelector(`[data-transcript-row-key="${CSS.escape(e)}"]`);a&&(i.scrollTop+=a.getBoundingClientRect().top-i.getBoundingClientRect().top),Oe.current=requestAnimationFrame(r)};r();return}if(!r){pe.scrollToEnd({behavior:`instant`}),he(!0),be.current=!0;return}pe.scrollToIndex(r.index,{align:`start`,behavior:`instant`}),ge.current=!1,he(!1),be.current=!0;let e=performance.now()+q8;De.current=e;let n=()=>{performance.now()>=e||performance.now()<ve.current||(Ae(r.candidate.sourceId,r.candidate.screenTop),a=requestAnimationFrame(n))};n()});return()=>cancelAnimationFrame(a)},[Ae,fe.length,e,n,pe]),(0,L.useEffect)(()=>()=>cancelAnimationFrame(Oe.current),[]),(0,L.useLayoutEffect)(()=>{let e=Ce.current,n=t.current;if(!e||!n||b)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(),Ce.current===e&&(Ce.current=null)})});return()=>{cancelAnimationFrame(a),cancelAnimationFrame(i)}},[b,I.length,t]);let je=(0,L.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]),Me=(0,L.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]),Ne=I[0]?.key;(0,L.useLayoutEffect)(()=>{let e=Ee.current;if(Ee.current=Ne,e===void 0||e===Ne||!be.current||ge.current||Ce.current)return;let t=Te.current;if(!t)return;Me(t);let n=()=>{if(performance.now()<ve.current)return;let e=Te.current;e&&Me(e)},r=0,i=requestAnimationFrame(()=>{n(),r=requestAnimationFrame(n)});return()=>{cancelAnimationFrame(i),cancelAnimationFrame(r)}},[Me,Ne]);let Pe=(0,L.useCallback)(()=>{let e=t.current;if(!e||Ce.current||performance.now()<De.current)return;let n=u8({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,previousScrollHeight:_e.current,following:ge.current,readerMoved:performance.now()<ve.current});if(ge.current=n.following,n.scrollTop!==null&&(e.scrollTop=n.scrollTop),_e.current=e.scrollHeight,he(e=>e===n.following?e:n.following),Y8&&!n.following&&performance.now()>=ve.current){let t=Te.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}`)}}Te.current=je()??Te.current},[je,t]);(0,L.useLayoutEffect)(Pe),(0,L.useEffect)(()=>{let e=ye.current;if(!e)return;let t=new ResizeObserver(Pe);return t.observe(e),()=>t.disconnect()},[Pe]),(0,L.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{Pe();let t=d8({armed:Se.current,scrollTop:e.scrollTop,readerMoved:be.current&&xe.current,hasEarlier:v,loading:b});Se.current=t.armed,t.shouldLoad&&ke()},r=()=>{xe.current=!0,ve.current=performance.now()+K8,requestAnimationFrame(n)},i=t=>{[`ArrowUp`,`PageUp`,`Home`,` `].includes(t.key)&&(e.scrollTop<=480&&(Se.current=!0),r())},a=t=>{t.deltaY<0&&e.scrollTop<=480&&(Se.current=!0),r()},o=()=>{e.scrollTop<=480&&(Se.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)}},[v,b,ke,Pe,t]);let Fe=pe.getVirtualItems(),Ie=pe.getTotalSize();return(0,R.jsxs)(`div`,{ref:ye,"data-virtualized-transcript":!0,"data-virtual-row-count":Fe.length,className:`relative w-full`,style:{height:Ie},children:[Fe.map(t=>{let n=fe[t.index];return n?(0,R.jsx)(`div`,{ref:pe.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`,style:{transform:`translateY(${t.start}px)`},children:n.kind===`head-anchor`?null:n.kind===`interactions`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P3,{thread:d,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,R.jsx)(A0,{thread:d,questions:le.tail,inFlight:a,showSend:le.tailSend,className:`px-6 pt-5`})]}):n.kind===`questions`?(0,R.jsx)(A0,{thread:d,questions:n.questions,showSend:n.send,className:`px-6 pt-5`}):n.kind===`settled-questions`?(0,R.jsx)(D0,{questions:n.questions,className:`px-6 pt-5`}):n.kind===`transport-fallback`?m?(0,R.jsx)(`div`,{className:`px-6 pt-3`,children:(0,R.jsx)(X8,{fallback:m,isFetching:h,onRefresh:g,onRetryLive:_})}):null:n.kind===`earlier-history`?(0,R.jsx)(`div`,{className:`flex min-h-10 items-center justify-center px-6 text-[11px] text-muted`,role:`status`,children:x?(0,R.jsxs)(`span`,{className:`flex flex-wrap items-center justify-center gap-2 text-center`,children:[(0,R.jsx)(`span`,{children:x}),(0,R.jsx)(`button`,{type:`button`,onClick:ke,className:`rounded-md border border-border px-2 py-1 text-fg/90 hover:bg-panel-2`,children:`Retry`})]}):b?(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(M_,{size:12,className:`animate-spin`}),` Loading earlier messages…`]}):(0,R.jsx)(`button`,{type:`button`,onClick:ke,className:`button-outline rounded-md px-2 py-1 outline-none hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:`Load earlier messages`})}):n.kind===`message`?(0,R.jsxs)(`div`,{className:`relative flex flex-col px-6`,style:{paddingTop:n.timeBreak&&n.timeBreakAt?n.gap===0?0:22:n.gap},children:[n.timeBreak&&n.timeBreakAt?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(g5,{at:n.timeBreakAt,kind:n.timeBreak}),(0,R.jsx)(e1,{h:6})]}):null,(0,R.jsx)(H5,{m:n.message,answering:u?o(n.message):void 0,showSendButton:!0,paired:i[n.messageIndex],staleAwaiting:M>=0&&n.messageIndex<M,restingCardShown:n.messageIndex===j&&N,shadowedBy:de.get(n.messageIndex),placed:s.placed.get(n.messageIndex),settledPlaced:c.placed.get(n.messageIndex),thread:d})]}):n.kind===`runtime-status`?(0,R.jsxs)(`div`,{className:`px-6`,style:{paddingTop:ce},children:[(0,R.jsx)(t5,{state:ae,slug:e,retryText:ee>=0?r[ee]?.text:void 0,onTerminal:p,liveRuntimeStart:A,liveActivityLabel:k,liveToolRun:D}),d?.permPolicy?(0,R.jsx)(`div`,{className:oe?`mt-3`:``,children:(0,R.jsx)(q5,{policy:d.permPolicy,denies:d.permDenies})}):null]}):(0,R.jsx)(`div`,{className:`relative flex flex-col px-6`,style:{paddingTop:n.gap},children:(0,R.jsx)(H5,{m:n.message,paired:i[n.messageIndex]})})},n.key):null}),(0,R.jsx)(r5,{overlay:C,hidden:me,onJump:()=>pe.scrollToEnd({behavior:`smooth`})})]})}function r5({overlay:e,hidden:t,onJump:n}){return!e||t?null:(0,Tn.createPortal)((0,R.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-shadow-ink/30 hover:bg-panel-2`,children:[(0,R.jsx)(fee,{size:12}),`Jump to latest`]}),e)}function i5({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1}){let i=Cg(ME(),e),a=pt({mutationFn:()=>Y.markComplete({slug:e})}),o=lX(ct({queryKey:[`threadBody`,e],queryFn:()=>Y.threadBody({slug:e})}).data?.markdown??``).trim().length>0;if(!i)return null;let s=i.kind===`session`&&i.foreign!==!0;return(0,R.jsxs)(`header`,{"data-thread-header":!0,className:I2,children:[(0,R.jsxs)(`div`,{className:L2,children:[n&&(0,R.jsx)(pv,{onClose:n}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 leading-tight`,children:[(0,R.jsx)(M4,{thread:i}),(0,R.jsx)(A4,{thread:i})]})]}),(0,R.jsx)(`div`,{className:R2,children:(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[s&&(0,R.jsx)(l8,{slug:e}),(0,R.jsx)(m4,{thread:i,collapse:r,expand:!!n,onDoc:o?()=>qh(`doc`,i.id):void 0,onDone:()=>a.mutate(void 0,{onSuccess:t}),doneBusy:a.isPending,onStatusApplied:t}),(0,R.jsx)(Aq,{thread:i,onArchived:t,onSnoozed:t})]})})]})}function a5(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||L4(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 o5(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||L4(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 s5(e){return a5(e)!==null}function c5(e){return o5(e)!==null}function l5(e){return e.kind===`event`&&!e.boundary||e.kind===`reasoning`}function u5(e){return l5(e)||s5(e)}function d5(e){return l5(e)||c5(e)}function f5(e){if(l5(e))return!0;let t=a5(e);return t!==null&&!JG(t[t.length-1])}function p5(e){if(l5(e))return!0;let t=o5(e);return t!==null&&!JG(t[0])}function m5(e){let t=a5(e);return t!==null&&ZG(t[t.length-1])}function h5(e){let t=o5(e);return t!==null&&ZG(t[0])}function g5({at:e,kind:t}){let{day:n,time:r}=Z0(e,t);return(0,R.jsxs)(`time`,{dateTime:e,className:`block select-none text-center text-[11px] leading-4 [font-variant-numeric:tabular-nums] text-muted-45`,children:[n?(0,R.jsxs)(`span`,{className:`font-medium text-muted-60`,children:[n,` `]}):null,r]})}function _5(e,t){let n=m5(e)||h5(t),r=!n&&u5(e)&&d5(t)&&!(f5(e)&&p5(t));return(n?22:r?6:14)+(e.role===`user`&&t.role!==`user`?3:0)}function v5(e,t,n){return e.kind===`event`||e.kind===`reasoning`||e.role===`user`?!1:e.parts&&e.parts.length>0?e.parts.every(r=>r.kind===`tools`?r.tools.length===0:x5(e,r.text,t,n)):(e.tools?.length??0)===0&&x5(e,e.text,t,n)}function y5(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`&&e[t].kind!==`event`)return t;return-1}function b5(e,t,n=!1){let r=new WeakSet,i=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&&i.add(n.message);return e=>v5(e,r.has(e),i.has(e))}function x5(e,t,n,r){return!e.fenceRefused&&!n&&!r?t.includes("```awaiting")?UQ(t).every(e=>e.kind===`fence`&&e.fenceKind===`awaiting`&&jW(e.hints)&&!VW(e.body)):!t.trim():UQ(t).every(t=>t.kind===`fence`&&t.fenceKind===`awaiting`&&(e.fenceRefused||r||!S5(t.hints)))}function S5(e){return Gu(e).length>0}function C5(e,t,n){return e.kind===`event`||e.kind===`reasoning`||e.role===`user`?!1:e.parts&&e.parts.length>0?e.parts.some(r=>r.kind===`text`&&!x5(e,r.text,t,n)):typeof e.text==`string`&&!x5(e,e.text,t,n)}function w5(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.queued||v5(n)))return m5(n)?22:u5(n)&&!f5(n)?6:14+(n.role===`user`?3:0)}return 0}function T5(e,t,n){let r=[],i=null;return e.forEach((e,a)=>{n?.(e,a)||v5(e)||(i!==null&&r.push((0,R.jsx)(e1,{h:_5(i,e)},`s${a}`)),r.push(t(e,a)),i=e)}),r}function Rne(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 E5(e,t=14){let n=e.filter(e=>e!=null&&e!==!1),r=[];return n.forEach((e,n)=>{n>0&&r.push((0,R.jsx)(e1,{h:typeof t==`number`?t:t(n)},`vs${n}`)),r.push(e)}),r}var zne={head:!1,tail:!1};function D5(e,t){return n=>e[n-1]?.tail||e[n]?.head?22:t}function O5(e){return{head:ZG(e[0]),tail:ZG(e[e.length-1])}}function k5(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}):XG(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 A5(e){return e.split(`__`).pop()||e}function j5(e){let t=X.board?.projectDir;return t&&e.startsWith(t+`/`)?e.slice(t.length+1):e}function Bne({tools:e,at:t}){let[n,r]=(0,L.useState)(!1),i=(0,L.useId)(),a=e.reduce((e,t)=>e+t.count,0),o=wK(a,SK(e));return(0,R.jsxs)(`div`,{"data-tool-activity":!0,"data-tool-activity-state":`settled`,className:`flex min-w-0 flex-col`,children:[(0,R.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-focus-ink-60 ${q4}`,children:[(0,R.jsx)(`span`,{"data-tool-activity-label":!0,title:o,className:`min-w-0 truncate text-muted`,children:o}),(0,R.jsx)(r_,{"data-tool-activity-chevron":!0,"aria-hidden":`true`,size:13,className:Y4(n)})]}),n&&(0,R.jsx)(`div`,{id:i,className:`mt-1.5 flex flex-col`,children:E5(e.map((e,n)=>(0,R.jsx)(N5,{t:e,startedAt:t},n)),6)}),!n&&(0,R.jsx)(`div`,{id:i,hidden:!0})]})}function M5({tools:e,at:t}){let n=[];for(let t of e){let e=JG(t),r=n[n.length-1];r?.exceptional===e?r.tools.push(t):n.push({exceptional:e,tools:[t]})}return(0,R.jsx)(`div`,{className:`flex flex-col`,children:E5(n.map((e,n)=>e.exceptional?(0,R.jsx)(`div`,{className:`flex flex-col`,children:E5(e.tools.map((e,n)=>(0,R.jsx)(N5,{t:e,startedAt:t},n)),D5(e.tools.map(e=>O5([e])),6))},`exceptions-${n}`):(0,R.jsx)(Bne,{tools:e.tools,at:t},`activity-${n}`)),D5(n.map(e=>O5(e.tools)),6))})}function N5({t:e,startedAt:t}){let n=(0,L.useContext)(L8),r=ME(),i=bte(e,(n?Cg(r,n):void 0)?.bgShells??[]);return e.edits&&e.status!==`failed`&&e.status!==`cancelled`?(0,R.jsx)(eZ,{edits:e.edits,meta:(0,R.jsx)(I5,{status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,durationMs:e.durationMs})}):e.command?(0,R.jsx)(B5,{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,R.jsx)(Gne,{name:e.name,detail:e.detail,outputImage:e.outputImage,output:e.output,status:e.status,durationMs:e.durationMs}):e.read?(0,R.jsx)(Jne,{detail:e.detail,read:e.read,status:e.status,durationMs:e.durationMs}):e.prompt||e.agentId?(0,R.jsx)(Xne,{detail:e.detail,prompt:e.prompt,subagentType:e.subagentType,agentId:e.agentId,agentStatus:e.agentStatus,agentElapsedMs:e.agentElapsedMs,status:e.status,durationMs:e.durationMs}):e.sendTo!==void 0||e.sendBody!==void 0?(0,R.jsx)(Zne,{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,R.jsx)(Kne,{images:e.sentImages??[],files:e.sentFiles??[],caption:e.caption,status:e.status,durationMs:e.durationMs}):e.todos?(0,R.jsx)(_Q,{todos:e.todos,note:e.input,meta:(0,R.jsx)(I5,{status:e.status,durationMs:e.durationMs})}):XG(e)?(0,R.jsx)(Vne,{ask:e.ask??[],askAnswers:e.askAnswers}):e.input||e.output?(0,R.jsx)(B5,{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,R.jsx)(Wne,{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 Vne({ask:e,askAnswers:t}){return(0,R.jsx)(`div`,{"data-settled-ask":!0,className:`flex flex-col gap-1.5`,children:e.map((e,n)=>{let r=A3(e,t?.[n]);return(0,R.jsx)(B1,{question:r.question,settled:{chosenIdxs:r.chosenIdxs,text:r.text}},n)})})}function P5({tone:e,indicator:t,label:n,duration:r,title:i}){return(0,R.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,R.jsx)(`span`,{children:[n,r].filter(Boolean).join(` · `)})]})}function Hne(e,t,n){let[r,i]=(0,L.useState)(()=>Date.now()),a=HO(e,t),o=yte(e,t,n,r);return(0,L.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(VO-(Date.now()-e),0));return()=>clearTimeout(t)},[a,o,n]),o}function F5({status:e,backgroundState:t,liveBackgroundState:n,startedAt:r}){let i=Hne(e,t,r),a=n===`running`?(0,R.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--shell`,"data-running-indicator":`tool-disclosure`}):n===`stale`?(0,R.jsx)(`span`,{className:rk,title:sk}):vte(e,t)||i?(0,R.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--shell`,"data-running-indicator":`tool-disclosure`}):null;return a?(0,R.jsx)(`span`,{className:`frizz-tool-mark -mr-1 flex w-[9px] shrink-0 justify-center`,children:a}):null}function I5({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:WO(i),c=[o,s].filter(Boolean).join(` · `);return(0,R.jsx)(P5,{tone:e===`failed`?`frizz-tool-failed`:e===`cancelled`?`text-attention`:`text-muted-55`,title:c,label:a,duration:s})}function Une(e,t,n){let r=t?Date.parse(t):NaN,i=e===`pending`&&Number.isFinite(r),[a,o]=(0,L.useState)(()=>Date.now());return(0,L.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 L5(e,t,n){let r=t&&t!==X.board?.projectDir?`in ${j5(t)}`:void 0;return[e,t?r:n!==void 0&&!e?.includes(String(n))?`session ${n}`:void 0].filter(Boolean).join(` · `)||void 0}function R5(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.includes(`…`)}function Wne({name:e,detail:t,count:n,status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,cwd:s,sessionId:c,durationMs:l,startedAt:u}){let d=L5(t,s,c),f=d?j5(d):void 0,p=t&&R5(t)?t:void 0;return(0,R.jsx)(`div`,{className:`frizz-bash`,title:d,children:(0,R.jsxs)(`div`,{className:`frizz-bash-header`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(F5,{status:r,backgroundState:i,liveBackgroundState:a,startedAt:u}),(0,R.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:A5(e)}),f&&(p?(0,R.jsx)(`span`,{className:`min-w-0 truncate`,onClick:e=>e.stopPropagation(),children:(0,R.jsx)($X,{path:p,className:`text-[11.5px] text-muted`,children:f})}):(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:f}))]}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,R.jsx)(I5,{status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,durationMs:l}),n>1&&(0,R.jsxs)(`span`,{className:`tabular-nums text-[11px] text-muted-45`,children:[`×`,n]})]})]})})}function Gne({name:e,detail:t,outputImage:n,output:r,status:i,durationMs:a}){let[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(!1),u=(0,L.useId)(),d=A5(e),f=t?j5(t):void 0;return(0,R.jsxs)(`div`,{"data-tool-image":!0,className:`frizz-bash`,children:[(0,R.jsxs)(QX,{className:`frizz-bash-header`,controls:u,expanded:o,label:`${o?`Collapse`:`Expand`} ${d}${t?`: ${t}`:``}`,onToggle:()=>s(e=>!e),meta:(0,R.jsx)(I5,{status:i,durationMs:a}),children:[(0,R.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:d}),f&&(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,title:t,children:f})]}),(0,R.jsx)(`div`,{id:u,hidden:!o,children:o&&(0,R.jsxs)(R.Fragment,{children:[c?(0,R.jsx)(`div`,{className:`frizz-bash-body break-all text-muted-70`,children:n}):(0,R.jsx)(`div`,{className:`flex justify-center bg-panel-2 p-1.5`,children:(0,R.jsx)(`img`,{src:BT(n),alt:f?`${d}: ${f}`:d,"data-local-path":n,"data-local-image":`true`,onError:()=>l(!0),className:`cursor-zoom-in block max-h-[420px] max-w-full w-auto rounded-md object-contain`})}),r&&(0,R.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body`,children:r})]})})]})}function Kne({images:e,files:t,caption:n,status:r,durationMs:i}){let[a,o]=(0,L.useState)(!0),s=(0,L.useId)(),c=(0,L.useMemo)(()=>e.map(e=>({target:e,title:n??`Delivered image`})),[e,n]),l=[e.length?`${e.length} image${e.length===1?``:`s`}`:``,t.length?`${t.length} file${t.length===1?``:`s`}`:``].filter(Boolean).join(` · `);return(0,R.jsxs)(`div`,{className:`frizz-bash`,children:[(0,R.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${l?`: ${l}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-60`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Sent to you`}),l&&(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:l})]}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,R.jsx)(I5,{status:r,durationMs:i}),(0,R.jsx)(r_,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${a?`rotate-90`:``}`})]})]}),(0,R.jsx)(`div`,{id:s,hidden:!a,children:a&&(0,R.jsxs)(R.Fragment,{children:[e.length>0&&(0,R.jsx)(PZ,{entries:c,framed:!1}),(t.length>0||n)&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-2.5 pb-2.5 pt-1.5`,children:[t.length>0&&(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map((e,t)=>(0,R.jsx)(G5,{path:e},`f${t}`))}),n&&(0,R.jsx)(`div`,{className:`max-w-[65%] text-[12px] leading-snug text-muted`,children:n})]})]})})]})}var z5=16;function B5({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,L.useState)(!1),[m,h]=(0,L.useState)(!1),[g,_]=(0,L.useState)(!1),v=(0,L.useId)(),y=Une(i,d,l),b=(0,L.useMemo)(()=>e.split(`
|
|
328
|
+
`),status:r})}function B6(e){return(e.subAgents??[]).filter(e=>Au(e)&&e.state===`running`)}function V6({agent:e,slug:t,now:n,onDismiss:r}){let i=qO(e.startedAt,n),a=e.subagentType?.replace(/^frizz:/,``),o=e.state===`stale`;return(0,R.jsx)(k6,{testKind:`agent`,testId:e.id??e.label,mark:o?(0,R.jsx)(`span`,{"aria-hidden":!0,className:`inline-block size-3 p-[3px] ${m6}`,children:(0,R.jsx)(`span`,{className:nk})}):(0,R.jsx)(h6,{tone:`border-accent`}),name:e.label,onOpen:e.id?()=>Jh(t,e.id,{label:e.label,subagentType:e.subagentType,startedAt:e.startedAt}):void 0,title:e.id?`Open this sub-agent${a?` (${a})`:``} — ${o?rk:`working for ${i}`}`:e.label,status:i,dismiss:L6(r,e.state===`running`,!!e.id,`AGENT`,e.label)})}function H6(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=P6(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 U6(e,t={}){let n=(e.watches??[]).filter(e=>e.kind===`github`&&e.state===`armed`),r=n.filter(e=>e.subject!==`issue`),i=n.filter(e=>e.subject===`issue`),a=F6(e);return{prs:r,issues:i,shells:[...a,...H6(e,t.hints??[],a)],agents:B6(e),timers:o6(e)}}function W6(e,t,n={}){let{prs:r,issues:i,shells:a,agents:o,timers:s}=U6(e,n);return[{head:`Sub-agents`,rows:o.map(n=>(0,R.jsx)(V6,{agent:n,slug:e.id,now:t},n.id??n.label))},{head:`Background shells`,rows:a.map(n=>(0,R.jsx)(I6,{watch:n,thread:e,slug:e.id,now:t},n.id))},{head:`Pull requests`,rows:r.map(e=>(0,R.jsx)(M6,{watch:e},e.id))},{head:`Issues`,rows:i.map(e=>(0,R.jsx)(M6,{watch:e},e.id))},{head:`Timers`,rows:s.map(e=>(0,R.jsx)(z6,{watch:e,now:t},e.id))}].filter(e=>e.rows.length>0)}function G6({group:e,first:t}){let n=`px-2 text-[10.5px] uppercase tracking-wide text-muted-45 ${t?``:`mt-4`}`;return e.onToggle?(0,R.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,R.jsx)(`span`,{children:e.head}),e.count!==void 0&&(0,R.jsx)(`span`,{className:`ml-1.5 tabular-nums`,children:e.count}),(0,R.jsx)(r_,{size:10,"aria-hidden":!0,className:`${m6} ml-[5px] transition-transform ${e.collapsed?``:`rotate-90`}`})]}):(0,R.jsx)(`div`,{className:n,children:e.head})}function K6({groups:e,divider:t}){return e.length===0?null:(0,R.jsxs)(R.Fragment,{children:[t&&(0,R.jsx)(`div`,{"aria-hidden":!0,className:`-mx-4 mt-3 border-t border-border`}),(0,R.jsx)(`div`,{className:`-mx-2 mt-3 flex flex-col gap-y-px`,children:e.map((e,t)=>(0,R.jsxs)(L.Fragment,{children:[(0,R.jsx)(G6,{group:e,first:t===0}),!e.collapsed&&e.rows]},e.head))})]})}function q6(e){return e?.lastFence?.kind===`awaiting`&&jW(e.lastFence.hints)?!1:e?.awaitingBackground===!0&&e.runtime===`turn-idle`&&e.bgSnoozed!==!0}var J6=`Hides card until new activity is detected`;function Y6({thread:e,onSnooze:t,onSnoozeFailed:n}){let[r,i]=(0,L.useState)(!1);return(0,R.jsxs)(R.Fragment,{children:[(0,R.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:J6,className:`disabled:opacity-45 ${c$}`,children:[(0,R.jsx)(D_,{size:12,className:m2}),`Snooze`]}),(0,R.jsx)(`span`,{className:o$,children:J6})]})}function X6({thread:e,fence:t,onSnooze:n,onSnoozeFailed:r,onReplied:i,onReplyFailed:a}){let o=e??s6,s=t??(e?.lastFence?.kind===`awaiting`?e.lastFence:void 0),c=s?.hints??c6,l=Gu(c),u=l.length>0?Yu(c):null,d=e!==void 0&&l6(e,l),f=t6(o),p=VW(s?.body),m=SX(p??``),h=W6(o,LO(),{hints:c}),g=u6(o,c),_=e!==void 0&&l.length===0&&e.waitStatus!==`watching`&&q6(e)&&zK(e).snooze;return(0,R.jsxs)(r$,{"data-awaiting-background":!0,icon:l.length>0?_ee:a6(o)?rv:D_,chip:l.length>0?NW:void 0,label:l.length>0?u?(0,R.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:u}):null:(0,R.jsx)(`span`,{className:`[overflow-wrap:anywhere]`,children:i6(o,c)}),aside:g.length===1?(0,R.jsx)(d6,{watch:g[0]}):void 0,children:[p?(0,R.jsx)(uQ,{className:`md-body ${GQ}`,html:m}):h.length===0&&!r6(o)&&l.length===0?(0,R.jsx)(`p`,{className:i$,children:MW}):null,l.length>0&&(0,R.jsx)(X3,{steps:l}),g.length>1&&(0,R.jsx)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-0.5`,children:g.map(e=>(0,R.jsx)(d6,{watch:e},e.ref))}),h.length===0&&r6(o)&&(0,R.jsx)(`p`,{className:`block min-w-0 text-[13px] leading-5 text-fg/75`,children:f?(0,R.jsxs)(R.Fragment,{children:[`It’s awaiting the results from `,e6(o,{watchers:!1}),` it dispatched. It returns to the queue on its own when the work comes back.`]}):(0,R.jsxs)(R.Fragment,{children:[e6(o,{watchers:!1}),` `,n6(o)===1?`is`:`are`,` still running. It resumes on its own when`,` `,n6(o)===1?`it finishes`:`one of them finishes`,`.`]})}),(0,R.jsx)(K6,{groups:h,divider:!!p}),d?(0,R.jsx)(Q3,{slug:e.id,onReplied:i,onReplyFailed:a}):_?(0,R.jsx)(a$,{"data-awaiting-snooze":!0,children:(0,R.jsx)(Y6,{thread:e,onSnooze:n,onSnoozeFailed:r})}):null]})}function Z6(e,t=Date.now()){return e!==void 0&&gf(e,t)!==void 0}function Q6(){let[e,t]=(0,L.useState)(()=>Date.now());return(0,L.useEffect)(()=>{let e=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(e)},[]),e}function $6({thread:e}){let t=Q6(),[n,r]=(0,L.useState)(!1),i=gf(e,t);if(!i)return null;let a=Date.parse(i),o=AD(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,R.jsxs)(r$,{"data-snooze-card":!0,icon:Jg,label:`Snoozed`,children:[(0,R.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:Ste(a-t)}),(0,R.jsx)(`p`,{className:i$,children:s?(0,R.jsxs)(R.Fragment,{children:[`Resumes `,o,` and sends: “`,MD(s),`”`]}):(0,R.jsxs)(R.Fragment,{children:[`Returns to the queue `,o,`.`]})}),e.foreign!==!0&&(0,R.jsx)(a$,{children:(0,R.jsx)(`button`,{type:`button`,"data-snooze-wake-now":!0,disabled:n,onClick:()=>void c(),className:`${c$} disabled:cursor-not-allowed disabled:opacity-45`,children:`Wake now`})})]})}function e8(e){return e?.foreign&&e.pendingInteraction!==!0?e.pendingAsk:void 0}function t8(e,t){return e?.actionableInteraction===!0?!1:t||e?.runtime===`perm-prompt`}var n8=1500;function r8(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},n8),a},fail(t){t===n&&(i(),e(!1))},dispose(){n++,i()}}}var i8=`Could not copy terminal command`,a8={attach:`Attach command copied`,resume:`Resume command copied`},o8={attach:`Copy command to attach to this thread's live terminal`,resume:`Copy command to resume this thread in a new terminal`},s8=e=>[`terminalCommand`,e];function c8(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 l8(e){let t=c8(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 eH(n),r}function u8(e){let t=pt({mutationFn:()=>l8(e)});return e=>t.mutate(void 0,{onSuccess:t=>{e?.onSuccess?.(),Z(a8[t])},onError:t=>{e?.onError?.(),Z(t instanceof Error?`${i8}: ${t.message}`:i8,{duration:7e3})}})}function d8({slug:e}){let[t,n]=(0,L.useState)(!1),r=(0,L.useRef)(null);r.current||=r8(n,{setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e)});let i=qe(),a=u8(e);(0,L.useEffect)(()=>()=>r.current?.dispose(),[]);function o(){i.prefetchQuery({queryKey:s8(e),queryFn:()=>c8(e),staleTime:15e3})}function s(){let t=i.getQueryData(s8(e));if(t){eH(t.command).then(()=>{r.current?.begin(),Z(a8[t.mode])},()=>Z(i8,{duration:7e3}));return}a({onSuccess:()=>r.current?.begin()})}let c=i.getQueryData(s8(e)),l=t?c?a8[c.mode]:`Terminal command copied`:c?o8[c.mode]:`Copy terminal command`;return(0,R.jsx)(FP,{label:l,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":l,title:l,onClick:s,onPointerEnter:o,onFocus:o,className:jk,children:t?(0,R.jsx)(e_,{size:14,strokeWidth:2.2,className:`text-fg`}):(0,R.jsx)(rv,{size:14,strokeWidth:1.8})})})}function f8(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 p8(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 m8(e){return`legacy:${e.role}:${e.kind??`message`}:${e.at??``}:${e.text}`}function h8(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??m8(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 g8(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 _8(e,t){let n=e.map(e=>e.message);return e.filter((e,r)=>!g8(n,r,t))}function v8(e,t){let n=Promise.resolve();function r(r){let i={...r,palette:{...r.palette}},a=n.then(async()=>{try{return await e(i)}finally{t(i.id)}});return n=a.then(()=>void 0,()=>void 0),a}return{enqueue:r}}function y8(e,t){let n=e[t];return typeof n==`string`&&n?n:void 0}function b8(e,t){let n=e[t];return typeof n==`number`&&Number.isFinite(n)?n:void 0}function x8(e,t){let n=y8(e,t);if(n)try{let e=new URL(n);return e.protocol===`https:`||e.protocol===`http:`?e.href:void 0}catch{return}}function S8({directive:e,icon:t,title:n,meta:r,children:i}){return(0,R.jsxs)(`section`,{"data-codex-directive":e.name,className:`min-w-0 ${KQ} border border-border bg-panel-2/75 p-4`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`flex h-4 w-4 shrink-0 items-center justify-center text-muted`,"aria-hidden":!0,children:t}),(0,R.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,R.jsx)(`div`,{className:`min-w-0 truncate text-[11px] font-normal leading-4 text-muted`,children:r})]}),i]})}function C8({children:e,mono:t=!1}){return(0,R.jsx)(`div`,{className:`ml-6 mt-1 break-words text-[11px] leading-4 text-muted${t?` font-mono-keep`:``}`,children:e})}function w8({directive:e}){let t=e.attrs,n=y8(t,`display_name`)??y8(t,`skill_name`)??`Artifact template`,r=y8(t,`artifact_kind`),i=y8(t,`skill_name`),a=y8(t,`skill_directory`),[o,s]=(0,L.useState)(!!a);return(0,R.jsxs)(S8,{directive:e,icon:(0,R.jsx)(hee,{size:15}),title:n,meta:r?`${r} template`:`Template`,children:[i&&(0,R.jsx)(C8,{mono:!0,children:i.startsWith(`$`)?i:`$${i}`}),o&&a&&(0,R.jsx)(`img`,{src:BT(`${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 T8({directive:e}){let t=e.attrs,n=y8(t,`file`),r=b8(t,`start`),i=b8(t,`end`)??r,a=b8(t,`priority`),o=n?`${n}${r?`:${r}${i&&i!==r?`-${i}`:``}`:``}`:`Code location unavailable`;return(0,R.jsxs)(S8,{directive:e,icon:(0,R.jsx)(P_,{size:15}),title:y8(t,`title`)??`Review finding`,meta:a===void 0?void 0:`P${a}`,children:[y8(t,`body`)&&(0,R.jsx)(C8,{children:y8(t,`body`)}),n?(0,R.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,R.jsx)(C8,{mono:!0,children:o})]})}var E8={"git-stage":[B_,`Changes staged`],"git-commit":[x_,`Commit created`],"git-create-branch":[b_,`Branch created`],"git-push":[sv,`Branch pushed`],"git-create-pr":[T_,`Pull request created`]};function D8({directive:e}){let[t,n]=E8[e.name],r=y8(e.attrs,`branch`),i=x8(e.attrs,`url`),a=`${n}${e.attrs.isDraft===!0?` as draft`:``}`;return(0,R.jsx)(S8,{directive:e,icon:(0,R.jsx)(t,{size:15}),title:i?(0,R.jsx)(`a`,{className:`text-accent underline underline-offset-2`,href:i,target:`_blank`,rel:`noopener noreferrer`,children:a}):a,meta:r&&(0,R.jsx)(`span`,{className:`font-mono-keep`,children:r})})}function O8({directive:e}){let t=y8(e.attrs,`threadId`),n=y8(e.attrs,`pendingWorktreeId`);return(0,R.jsx)(S8,{directive:e,icon:(0,R.jsx)(z_,{size:15}),title:n?`Thread setup queued`:`Thread created`,meta:(t||n)&&(0,R.jsx)(`span`,{className:`font-mono-keep`,children:t??n})})}function k8({directive:e}){let t=y8(e.attrs,`reason`);return(0,R.jsx)(S8,{directive:e,icon:(0,R.jsx)(dee,{size:15}),title:`Archive suggested`,meta:t})}function A8(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 j8({directive:e}){let t=e.attrs,n=y8(t,`mode`),r=y8(t,`name`)??`Automation`,i=A8(t.rrule),a=[r,n,y8(t,`status`),i].filter(Boolean).join(` · `);return(0,R.jsx)(S8,{directive:e,icon:(0,R.jsx)($g,{size:15}),title:`Automation suggested`,meta:a,children:y8(t,`prompt`)&&(0,R.jsx)(C8,{children:y8(t,`prompt`)})})}function M8({directive:e}){return e.name===`artifact-template`?(0,R.jsx)(w8,{directive:e}):e.name===`code-comment`?(0,R.jsx)(T8,{directive:e}):e.name.startsWith(`git-`)?(0,R.jsx)(D8,{directive:e}):e.name===`created-thread`?(0,R.jsx)(O8,{directive:e}):e.name===`archive`||e.name===`archive-thread`?(0,R.jsx)(k8,{directive:e}):(0,R.jsx)(j8,{directive:e})}var N8,P8=0;function F8(){return N8??=MS(async()=>{let{default:e}=await import(`./mermaid.core-8ofZrJs5.js`);return{default:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19])).then(({default:e})=>e),N8}function I8(){let e=getComputedStyle(document.documentElement),t=t=>e.getPropertyValue(t).trim();return{background:t(`--color-panel-2`),primaryColor:t(`--color-panel-2`),primaryTextColor:t(`--color-fg`),primaryBorderColor:t(`--color-control-strong`),lineColor:t(`--color-muted`),secondaryColor:t(`--color-border`),tertiaryColor:t(`--color-bg`),fontFamily:`ui-monospace, SFMono-Regular, Menlo, monospace`}}var L8=v8(async e=>{let t=await F8();return t.initialize({startOnLoad:!1,securityLevel:`strict`,theme:e.resolved===`dark`?`dark`:`base`,themeVariables:e.palette}),t.render(e.id,e.source)},e=>document.getElementById(`d${e}`)?.remove());function R8({source:e}){let t=(0,L.useId)(),{resolved:n}=(0,L.useSyncExternalStore)(A2,O2,O2),[r,i]=(0,L.useState)({}),a=(0,L.useRef)(0),o=rZ(r.html??``);return(0,L.useEffect)(()=>{let r=!0,o=++a.current;if(i(e=>e.error?{html:e.html}:e),e.length>5e4)return i({error:`Diagram source exceeds the 50 KB rendering limit`}),()=>{r=!1};let s=`frizz-mermaid-${t.replace(/[^a-zA-Z0-9]/g,``)}-${++P8}`;return L8.enqueue({id:s,source:e,resolved:n,palette:I8()}).then(({svg:e})=>{r&&a.current===o&&i({html:e})}).catch(e=>{if(!r||a.current!==o)return;let t=e instanceof Error?e.message.split(/\n| for text:/,1)[0]:`Unknown diagram error`;i({error:t.slice(0,240)})}),()=>{r=!1}},[t,n,e]),r.error?(0,R.jsxs)(`section`,{"data-mermaid-state":`error`,className:`${KQ} border border-border bg-panel-2/75 p-4`,children:[(0,R.jsx)(`div`,{className:`text-[12px] font-medium text-fg`,children:`Diagram unavailable`}),(0,R.jsx)(`div`,{className:`mt-1 text-[11px] text-muted`,children:r.error}),(0,R.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})]}):r.html?(0,R.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:o}):(0,R.jsx)(`div`,{"data-mermaid-state":`loading`,role:`status`,"aria-label":`Rendering diagram`,className:`h-24 animate-pulse ${KQ} bg-panel-2`})}var z8=(0,L.createContext)(null),B8=(0,L.createContext)(null);function V8(){let e=(0,L.useContext)(z8),t=(0,L.useContext)(B8);return e??t}var H8=(0,L.createContext)(null);function U8(e){return e.status===`pending`&&e.backgroundState===`background`}function W8(e){let t=[];for(let n of e)for(let e of n.tools)U8(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 G8(e){return e.map(e=>{if(!e.tools.some(U8))return e;let t=e.tools.filter(e=>!U8(e)),n=e.parts?.map(e=>e.kind===`tools`?{...e,tools:e.tools.filter(e=>!U8(e))}:e).filter(e=>e.kind!==`tools`||e.tools.length>0);return{...e,tools:t,parts:n}})}function K8({slug:e,onStatusApplied:t,onClose:n,virtualized:r=!1,showReturnToQueue:i=!1}){Cg(ME(),e);let a=Lg()&&n!==void 0,{splitFileViewer:o}=gr(X);return(0,R.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[a?(0,R.jsx)(c4,{slug:e,onClose:n}):(0,R.jsx)(i5,{slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:i}),(0,R.jsx)(q8,{slug:e,virtualized:r,phone:a,railBeside:i&&o})]})}function q8({slug:e,virtualized:t,phone:n=!1,railBeside:r=!1}){let i=ME(),a=Cg(i,e),o=C0(a),s=(0,L.useMemo)(()=>T0(a,o),[a,o]),c=(0,L.useMemo)(()=>n?{numberOf:e=>s.findIndex(t=>t.id===e)+1}:null,[n,s]),[l,u]=(0,L.useState)(!1),d=a?.runtime===`running`||a?.runtime===`spawning`,f=u8(e),p=RE(e,{poll:d}),m=qe(),h=(0,L.useRef)(!1),[g,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)(null),b=(0,L.useMemo)(()=>p.data?.messages??[],[p.data]),x=(0,L.useMemo)(()=>W8(b),[b]),S=(0,L.useMemo)(()=>G8(b),[b]),C=(0,L.useMemo)(()=>y5(S),[S]),w=d?S.length:C,T=(0,L.useMemo)(()=>sK(S),[S]),E=d?uK(T):void 0,D=d?lK(T):void 0,O=D?yK(D,i?.projectDir):void 0,k=d?fK(T):void 0,A=q6(a),j=(0,L.useMemo)(()=>{let e=d?mK(T):T;return _8(e,b5(e,w,A))},[T,d,w,A]),M=d,N=(0,L.useMemo)(()=>j$(b),[b]),P=(0,L.useMemo)(()=>E$(b,a?.answersInFlight),[b,a?.answersInFlight]),F=(0,L.useMemo)(()=>f2(b),[b]),I=WQ(a,C>=0?S[C]?.text:void 0),ee=(0,L.useMemo)(()=>J$(b,s),[b,s]),te={thread:a,showWorking:M,registeredDone:I,restedCard:l$(a,C>=0?S[C]?.text:void 0,ee),errorVisible:d$(S,a?.providerError)},{answeringForMessage:ne}=I1(e,b),re=(0,L.useMemo)(()=>z$(b,s),[b,s]),ie=(0,L.useMemo)(()=>q$(b,s),[b,s]),ae=(0,L.useMemo)(()=>$$(b,o),[b,o]),oe=Vd(a?.spawnedAt),se=(0,L.useRef)(null),[ce,le]=(0,L.useState)(null),ue=p.data?.messages.length??0,de=!p.isLoading;(0,L.useEffect)(()=>{if(t)return;let e=se.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<=4&&(e.scrollTop=e.scrollHeight)},[ue,d,t]);let fe=(0,L.useCallback)(async()=>{if(h.current)return;let t=m.getQueryData([`transcript`,e]),n=t?.beforeCursor,r=t?.transcriptKey;if(!(!t?.hasEarlier||!n||!r)){h.current=!0,_(!0),y(null);try{let t=await Y.threadTranscriptEarlier({slug:e,cursor:n}),i=m.getQueryData([`transcript`,e]);if(!i?.transcriptKey||i.transcriptKey!==r||t.transcriptKey!==r){await p.refetch(),Z(`Transcript changed while loading history; refreshed the current session`);return}m.setQueryData([`transcript`,e],ow(i,t))}catch(e){let t=e instanceof Error?e.message:`Could not load earlier transcript history`;y(t)}finally{h.current=!1,_(!1)}}},[p,m,e]);return(0,R.jsx)(z8.Provider,{value:e,children:(0,R.jsx)(O0,{thread:a,children:(0,R.jsx)(K1.Provider,{value:c,children:(0,R.jsxs)(`div`,{"data-drawer-scroll-ready":p.isPending?`false`:`true`,className:`flex-1 min-h-0 flex flex-col overflow-hidden outline-none`,children:[(0,R.jsxs)(`div`,{className:`relative min-h-0 flex-1 flex flex-col`,children:[(0,R.jsx)(`div`,{ref:se,"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&&g?!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-focus-ink-60`,children:t&&ue>0?(0,R.jsx)(n5,{slug:e,transcriptRef:se,transcriptKey:p.data?.transcriptKey,messages:S,paired:N,inFlightAnswers:P,answeringForMessage:ne,placement:ie,settledPlacement:ae,openQuestions:s,fencesLive:oe,thread:a,running:d,copyTerminalCommand:f,transportFallback:p.transportFallback,isFetching:p.isFetching,refresh:()=>void p.refetch(),retryLiveUpdates:p.retryLiveUpdates,hasEarlier:p.data?.hasEarlier===!0,beforeCursor:p.data?.beforeCursor,loadingEarlier:g,earlierError:v,loadEarlier:()=>void fe(),jumpOverlay:ce,openAtLastMessage:n&&!d}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P3,{thread:a,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,R.jsx)(A0,{thread:a,inFlight:P,className:`px-6 pt-5`}),p.transportFallback&&(0,R.jsx)(Q8,{fallback:p.transportFallback,isFetching:p.isFetching,onRefresh:()=>void p.refetch(),onRetryLive:p.retryLiveUpdates,className:`mx-6 mt-3`}),(0,R.jsx)(`div`,{"data-transcript-column":!0,className:`flex min-h-full flex-col px-6 py-5`,children:ue===0?(0,R.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted`,children:p.isPending?(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Y5,{}),` Loading…`]}):d?(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(Y5,{}),` Session starting…`]}):F2(a)?(0,R.jsxs)(`div`,{className:`text-center`,children:[(0,R.jsx)(`p`,{className:`mb-3`,children:`No session is attached to this thread yet.`}),(0,R.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,R.jsxs)(R.Fragment,{children:[T5(j.map(e=>e.message),(e,t)=>{let n=j[t].messageIndex;return(0,R.jsx)(H5,{m:e,answering:oe?ne(e):void 0,showSendButton:!0,paired:N[n],staleAwaiting:w>=0&&n<w,restingCardShown:n===C&&A,shadowedBy:re.get(n),placed:ie.placed.get(n),settledPlaced:ae.placed.get(n),thread:a},t)},e=>!!e.queued),de&&$8(te)!==null&&(0,R.jsx)(e1,{h:e5(te,j.map(e=>e.message))}),de&&(0,R.jsx)(t5,{state:te,slug:e,retryText:F>=0?b[F]?.text:void 0,onTerminal:f,liveRuntimeStart:k,liveActivityLabel:O,liveToolRun:E}),a?.permPolicy?(0,R.jsx)(`div`,{className:`mt-3`,children:(0,R.jsx)(q5,{policy:a.permPolicy,denies:a.permDenies})}):null,b.some(e=>e.queued)&&(0,R.jsx)(e1,{}),(0,R.jsx)(`div`,{className:`flex flex-col gap-3.5`,children:b.map((e,t)=>e.queued?(0,R.jsx)(H5,{m:e,paired:N[t]},`q${t}`):null)})]})})]})}),(0,R.jsx)(`div`,{ref:le,"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,R.jsx)(`div`,{"data-thread-chat-footer":!0,className:`z-10 shrink-0 border-t border-border/60 bg-panel ${n?``:`pb-[env(safe-area-inset-bottom)]`}`,children:(0,R.jsx)(t4,{slug:e,above:n||r||!a?void 0:(0,R.jsx)(a4,{thread:a,transcriptShells:x}),phoneBarOverride:n&&s.length>0?e=>(0,R.jsx)(Z1,{count:s.length,onAnswer:()=>u(!0),onReply:e.editReply}):void 0,phoneChrome:n})}),n&&l&&(0,R.jsx)(M0,{questions:s,onClose:()=>u(!1)})]})})})})}var J8=700,Y8=250,X8=900,Z8=(()=>{try{return localStorage.getItem(`frizz.debugScroll`)===`1`}catch{return!1}})();function Q8({fallback:e,isFetching:t,onRefresh:n,onRetryLive:r,className:i=``}){return(0,R.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] ${i}`,title:e.kind===`payload-too-large`?`Live payload ${e.actualBytes} bytes; socket limit ${e.maxBytes} bytes`:`Transcript read budget reached (${e.scope}); retry after about ${e.retryAfterMs}ms`,children:[(0,R.jsx)(ov,{size:13,className:`shrink-0 text-muted`}),(0,R.jsxs)(`div`,{className:`min-w-[180px] flex-1 leading-snug text-fg/85`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:`Live transcript updates paused.`}),` `,e.kind===`payload-too-large`?`The transcript is too large for push; it refreshes over HTTP each time the thread moves.`:`The live read budget was reached; the last complete copy remains visible. Retry in a moment.`]}),(0,R.jsx)(`button`,{type:`button`,disabled:t,onClick:n,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:t?`Refreshing…`:`Refresh once`}),(0,R.jsx)(`button`,{type:`button`,onClick:r,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`})]})}function $8({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`:e8(e)?`pending-ask`:t8(e,t)?`working`:e?.providerError?i?null:`provider-error`:Z6(e)?`snooze`:q6(e)?`resting`:n?`registered-done`:r?`rested`:null}function e5(e,t){return $8(e)===`working`?w5(t):14}function t5({state:e,slug:t,retryText:n,onTerminal:r,liveRuntimeStart:i,liveActivityLabel:a,liveToolRun:o,onRestingExit:s,onRestingExitFailed:c,wrap:l}){let u=e.thread;switch($8(e)){case`provider-fault`:return(0,R.jsx)(ore,{slug:t,sessionId:u.sessionId,fault:u.providerFault,retryText:n});case`provider-error`:return(0,R.jsx)(f$,{error:u.providerError});case`limit-pause`:return(0,R.jsx)(sre,{slug:t,sessionId:u.sessionId,pause:u.limitPause});case`pending-ask`:return(0,R.jsx)(cre,{ask:e8(u),onTerminal:r});case`working`:return(0,R.jsx)(X5,{since:u?.lastUserAt,startedAt:i,activityLabel:a,run:o});case`snooze`:return(0,R.jsx)($6,{thread:u});case`resting`:return(0,R.jsx)(X6,{thread:u,onSnooze:s,onSnoozeFailed:c,onReplied:s,onReplyFailed:c});case`registered-done`:return(0,R.jsx)(K5,{fenceKind:`done`,body:u.lastFence.body,hints:[],wrap:l});case`rested`:return(0,R.jsx)(u$,{thread:u});default:return null}}function n5({slug:e,transcriptRef:t,transcriptKey:n,messages:r,paired:i,inFlightAnswers:a,answeringForMessage:o,placement:s,settledPlacement:c,openQuestions:l,fencesLive:u,thread:d,running:f,copyTerminalCommand:p,transportFallback:m,isFetching:h,refresh:g,retryLiveUpdates:_,hasEarlier:v,beforeCursor:y,loadingEarlier:b,earlierError:x,loadEarlier:S,jumpOverlay:C,openAtLastMessage:w=!1}){let T=NE(),E=(0,L.useMemo)(()=>sK(r),[r]),D=f?uK(E):void 0,O=f?lK(E):void 0,k=O?yK(O,T):void 0,A=f?fK(E):void 0,j=(0,L.useMemo)(()=>y5(r),[r]),M=f?r.length:j,N=q6(d),P=(0,L.useMemo)(()=>{let e=f?mK(E):E;return _8(e,b5(e,M,N))},[E,f,M,N]),F=f,I=(0,L.useMemo)(()=>{let e=h8(P.map(e=>e.message),b5(P,M,N),_5),t=e=>P[e.messageIndex].runStartedAt??e.message.at,n=X0(e,t,e=>e.message.at);return e.map((e,r)=>({...e,messageIndex:P[e.messageIndex].messageIndex,timeBreak:n[r],timeBreakAt:t(e)}))},[P,M,N]),ee=(0,L.useMemo)(()=>f2(r),[r]),te=WQ(d,j>=0?r[j]?.text:void 0),ne=(0,L.useMemo)(()=>J$(r,l),[r,l]),re=l$(d,j>=0?r[j]?.text:void 0,ne),ie=d$(r,d?.providerError),ae={thread:d,showWorking:F,registeredDone:te,restedCard:re,errorVisible:ie},oe=$8(ae)!==null,se=oe||!!d?.permPolicy,ce=(0,L.useMemo)(()=>e5({thread:d,showWorking:F,registeredDone:te,restedCard:re,errorVisible:ie},P.map(e=>e.message)),[P,F,d,te,re,ie]),le=(0,L.useMemo)(()=>{let e=[],t=new Map,n=r.length-1,i=e=>{let t=-1;for(let n=0;n<I.length&&!(I[n].messageIndex>e);n++)t=n;return t},a=l.filter(e=>!s.placedIds.has(e.id));for(let[o,s]of I$(r,a)){if(o>=n){e.push(...s);continue}let r=i(o),a=t.get(r);a?a.push(...s):t.set(r,[...s])}let o=!1,c=new Set;for(let e of X$(r,s)){if(e>=n){o=!0;continue}let r=i(e);c.add(r),t.has(r)||t.set(r,[])}return{byRow:t,tail:e,tailSend:o,sendRows:c}},[I,r,l,s]),ue=(0,L.useMemo)(()=>{let e=new Map;for(let[t,n]of c.anchored){let r=-1;for(let e=0;e<I.length&&!(I[e].messageIndex>t);e++)r=e;if(r<0)continue;let i=e.get(r);i?i.push(...n):e.set(r,[...n])}return e},[I,c.anchored]),de=(0,L.useMemo)(()=>z$(r,l),[r,l]),fe=(0,L.useMemo)(()=>{let e=[{key:`head-anchor`,kind:`head-anchor`}];m&&e.push({key:`transport-fallback`,kind:`transport-fallback`}),(v||b||x)&&e.push({key:`earlier-history:${y??`complete`}`,kind:`earlier-history`});let t=le.byRow.get(-1);t&&e.push({key:`questions:head`,kind:`questions`,questions:t,send:le.sendRows.has(-1)}),I.forEach((t,n)=>{e.push({...t,kind:`message`});let r=ue.get(n);r&&e.push({key:`settled-questions:${t.key}`,kind:`settled-questions`,questions:r});let i=le.byRow.get(n);i&&e.push({key:`questions:${t.key}`,kind:`questions`,questions:i,send:le.sendRows.has(n)})}),e.push({key:`interactions`,kind:`interactions`}),se&&e.push({key:`runtime-status`,kind:`runtime-status`});let n=se||I.length>0?14:0;return r.forEach((t,r)=>{if(!t.queued)return;let i=`queued:${t.deliveryId??t.sourceId??r}`;e.push({key:i,kind:`queued`,message:t,messageIndex:r,gap:n}),n=14}),e},[y,x,v,se,b,I,r,le,ue,m]),pe=vD({count:fe.length,getScrollElement:()=>t.current,getItemKey:e=>fe[e]?.key??e,estimateSize:e=>{let t=fe[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===`settled-questions`?140: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})}}),[me,he]=(0,L.useState)(!0),ge=(0,L.useRef)(!0),_e=(0,L.useRef)(-1),ve=(0,L.useRef)(0),ye=(0,L.useRef)(null),be=(0,L.useRef)(!1),xe=(0,L.useRef)(!1),Se=(0,L.useRef)(!0),Ce=(0,L.useRef)(null),we=(0,L.useRef)(void 0),Te=(0,L.useRef)(null),Ee=(0,L.useRef)(void 0),De=(0,L.useRef)(0),Oe=(0,L.useRef)(0),ke=(0,L.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&&(Ce.current={rowKey:r,viewportTop:n.getBoundingClientRect().top-t})}S()},[S,t]),Ae=(0,L.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,L.useLayoutEffect)(()=>{if(!n||fe.length===0||we.current===n)return;we.current=n,be.current=!1,xe.current=!1,Se.current=!0;let r=Dk(e)?.candidates.map(e=>({candidate:e,index:fe.findIndex(t=>t.kind===`message`&&t.message.sourceId===e.sourceId)})).find(e=>e.index>=0),i=!r&&w&&j>=0?fe.reduce((e,t,n)=>t.kind===`message`&&t.messageIndex<=j&&t.message.role===`assistant`&&t.message.kind!==`event`?n:e,-1):-1,a=requestAnimationFrame(()=>{if(!r&&i>=0){let e=fe[i].key;pe.scrollToIndex(i,{align:`start`,behavior:`instant`}),ge.current=!1,he(!1),be.current=!0;let n=performance.now()+X8;De.current=n;let r=()=>{let i=t.current;if(!i||performance.now()>=n||performance.now()<ve.current){De.current=0,Oe.current=0,i&&i.scrollHeight-i.clientHeight-i.scrollTop<=4&&(ge.current=!0,_e.current=i.scrollHeight,he(!0));return}let a=i.querySelector(`[data-transcript-row-key="${CSS.escape(e)}"]`);a&&(i.scrollTop+=a.getBoundingClientRect().top-i.getBoundingClientRect().top),Oe.current=requestAnimationFrame(r)};r();return}if(!r){pe.scrollToEnd({behavior:`instant`}),he(!0),be.current=!0;return}pe.scrollToIndex(r.index,{align:`start`,behavior:`instant`}),ge.current=!1,he(!1),be.current=!0;let e=performance.now()+Y8;De.current=e;let n=()=>{performance.now()>=e||performance.now()<ve.current||(Ae(r.candidate.sourceId,r.candidate.screenTop),a=requestAnimationFrame(n))};n()});return()=>cancelAnimationFrame(a)},[Ae,fe.length,e,n,pe]),(0,L.useEffect)(()=>()=>cancelAnimationFrame(Oe.current),[]),(0,L.useLayoutEffect)(()=>{let e=Ce.current,n=t.current;if(!e||!n||b)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(),Ce.current===e&&(Ce.current=null)})});return()=>{cancelAnimationFrame(a),cancelAnimationFrame(i)}},[b,I.length,t]);let je=(0,L.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]),Me=(0,L.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]),Ne=I[0]?.key;(0,L.useLayoutEffect)(()=>{let e=Ee.current;if(Ee.current=Ne,e===void 0||e===Ne||!be.current||ge.current||Ce.current)return;let t=Te.current;if(!t)return;Me(t);let n=()=>{if(performance.now()<ve.current)return;let e=Te.current;e&&Me(e)},r=0,i=requestAnimationFrame(()=>{n(),r=requestAnimationFrame(n)});return()=>{cancelAnimationFrame(i),cancelAnimationFrame(r)}},[Me,Ne]);let Pe=(0,L.useCallback)(()=>{let e=t.current;if(!e||Ce.current||performance.now()<De.current)return;let n=f8({scrollTop:e.scrollTop,scrollHeight:e.scrollHeight,clientHeight:e.clientHeight,previousScrollHeight:_e.current,following:ge.current,readerMoved:performance.now()<ve.current});if(ge.current=n.following,n.scrollTop!==null&&(e.scrollTop=n.scrollTop),_e.current=e.scrollHeight,he(e=>e===n.following?e:n.following),Z8&&!n.following&&performance.now()>=ve.current){let t=Te.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}`)}}Te.current=je()??Te.current},[je,t]);(0,L.useLayoutEffect)(Pe),(0,L.useEffect)(()=>{let e=ye.current;if(!e)return;let t=new ResizeObserver(Pe);return t.observe(e),()=>t.disconnect()},[Pe]),(0,L.useEffect)(()=>{let e=t.current;if(!e)return;let n=()=>{Pe();let t=p8({armed:Se.current,scrollTop:e.scrollTop,readerMoved:be.current&&xe.current,hasEarlier:v,loading:b});Se.current=t.armed,t.shouldLoad&&ke()},r=()=>{xe.current=!0,ve.current=performance.now()+J8,requestAnimationFrame(n)},i=t=>{[`ArrowUp`,`PageUp`,`Home`,` `].includes(t.key)&&(e.scrollTop<=480&&(Se.current=!0),r())},a=t=>{t.deltaY<0&&e.scrollTop<=480&&(Se.current=!0),r()},o=()=>{e.scrollTop<=480&&(Se.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)}},[v,b,ke,Pe,t]);let Fe=pe.getVirtualItems(),Ie=pe.getTotalSize();return(0,R.jsxs)(`div`,{ref:ye,"data-virtualized-transcript":!0,"data-virtual-row-count":Fe.length,className:`relative w-full`,style:{height:Ie},children:[Fe.map(t=>{let n=fe[t.index];return n?(0,R.jsx)(`div`,{ref:pe.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`,style:{transform:`translateY(${t.start}px)`},children:n.kind===`head-anchor`?null:n.kind===`interactions`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P3,{thread:d,className:`px-6 pt-5`,autoFocusFirst:!0}),(0,R.jsx)(A0,{thread:d,questions:le.tail,inFlight:a,showSend:le.tailSend,className:`px-6 pt-5`})]}):n.kind===`questions`?(0,R.jsx)(A0,{thread:d,questions:n.questions,showSend:n.send,className:`px-6 pt-5`}):n.kind===`settled-questions`?(0,R.jsx)(D0,{questions:n.questions,className:`px-6 pt-5`}):n.kind===`transport-fallback`?m?(0,R.jsx)(`div`,{className:`px-6 pt-3`,children:(0,R.jsx)(Q8,{fallback:m,isFetching:h,onRefresh:g,onRetryLive:_})}):null:n.kind===`earlier-history`?(0,R.jsx)(`div`,{className:`flex min-h-10 items-center justify-center px-6 text-[11px] text-muted`,role:`status`,children:x?(0,R.jsxs)(`span`,{className:`flex flex-wrap items-center justify-center gap-2 text-center`,children:[(0,R.jsx)(`span`,{children:x}),(0,R.jsx)(`button`,{type:`button`,onClick:ke,className:`rounded-md border border-border px-2 py-1 text-fg/90 hover:bg-panel-2`,children:`Retry`})]}):b?(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(M_,{size:12,className:`animate-spin`}),` Loading earlier messages…`]}):(0,R.jsx)(`button`,{type:`button`,onClick:ke,className:`button-outline rounded-md px-2 py-1 outline-none hover:bg-panel-2 hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:`Load earlier messages`})}):n.kind===`message`?(0,R.jsxs)(`div`,{className:`relative flex flex-col px-6`,style:{paddingTop:n.timeBreak&&n.timeBreakAt?n.gap===0?0:22:n.gap},children:[n.timeBreak&&n.timeBreakAt?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(g5,{at:n.timeBreakAt,kind:n.timeBreak}),(0,R.jsx)(e1,{h:6})]}):null,(0,R.jsx)(H5,{m:n.message,answering:u?o(n.message):void 0,showSendButton:!0,paired:i[n.messageIndex],staleAwaiting:M>=0&&n.messageIndex<M,restingCardShown:n.messageIndex===j&&N,shadowedBy:de.get(n.messageIndex),placed:s.placed.get(n.messageIndex),settledPlaced:c.placed.get(n.messageIndex),thread:d})]}):n.kind===`runtime-status`?(0,R.jsxs)(`div`,{className:`px-6`,style:{paddingTop:ce},children:[(0,R.jsx)(t5,{state:ae,slug:e,retryText:ee>=0?r[ee]?.text:void 0,onTerminal:p,liveRuntimeStart:A,liveActivityLabel:k,liveToolRun:D}),d?.permPolicy?(0,R.jsx)(`div`,{className:oe?`mt-3`:``,children:(0,R.jsx)(q5,{policy:d.permPolicy,denies:d.permDenies})}):null]}):(0,R.jsx)(`div`,{className:`relative flex flex-col px-6`,style:{paddingTop:n.gap},children:(0,R.jsx)(H5,{m:n.message,paired:i[n.messageIndex]})})},n.key):null}),(0,R.jsx)(r5,{overlay:C,hidden:me,onJump:()=>pe.scrollToEnd({behavior:`smooth`})})]})}function r5({overlay:e,hidden:t,onJump:n}){return!e||t?null:(0,Tn.createPortal)((0,R.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-shadow-ink/30 hover:bg-panel-2`,children:[(0,R.jsx)(fee,{size:12}),`Jump to latest`]}),e)}function i5({slug:e,onStatusApplied:t,onClose:n,showReturnToQueue:r=!1}){let i=Cg(ME(),e),a=pt({mutationFn:()=>Y.markComplete({slug:e})}),o=lX(ct({queryKey:[`threadBody`,e],queryFn:()=>Y.threadBody({slug:e})}).data?.markdown??``).trim().length>0;if(!i)return null;let s=i.kind===`session`&&i.foreign!==!0;return(0,R.jsxs)(`header`,{"data-thread-header":!0,className:I2,children:[(0,R.jsxs)(`div`,{className:L2,children:[n&&(0,R.jsx)(pv,{onClose:n}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1 leading-tight`,children:[(0,R.jsx)(M4,{thread:i}),(0,R.jsx)(A4,{thread:i})]})]}),(0,R.jsx)(`div`,{className:R2,children:(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[s&&(0,R.jsx)(d8,{slug:e}),(0,R.jsx)(m4,{thread:i,collapse:r,expand:!!n,onDoc:o?()=>qh(`doc`,i.id):void 0,onDone:()=>a.mutate(void 0,{onSuccess:t}),doneBusy:a.isPending,onStatusApplied:t}),(0,R.jsx)(Aq,{thread:i,onArchived:t,onSnoozed:t})]})})]})}function a5(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||L4(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 o5(e){if(e.kind===`event`||e.kind===`reasoning`||e.role===`user`||L4(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 s5(e){return a5(e)!==null}function c5(e){return o5(e)!==null}function l5(e){return e.kind===`event`&&!e.boundary||e.kind===`reasoning`}function u5(e){return l5(e)||s5(e)}function d5(e){return l5(e)||c5(e)}function f5(e){if(l5(e))return!0;let t=a5(e);return t!==null&&!JG(t[t.length-1])}function p5(e){if(l5(e))return!0;let t=o5(e);return t!==null&&!JG(t[0])}function m5(e){let t=a5(e);return t!==null&&ZG(t[t.length-1])}function h5(e){let t=o5(e);return t!==null&&ZG(t[0])}function g5({at:e,kind:t}){let{day:n,time:r}=Z0(e,t);return(0,R.jsxs)(`time`,{dateTime:e,className:`block select-none text-center text-[11px] leading-4 [font-variant-numeric:tabular-nums] text-muted-45`,children:[n?(0,R.jsxs)(`span`,{className:`font-medium text-muted-60`,children:[n,` `]}):null,r]})}function _5(e,t){let n=m5(e)||h5(t),r=!n&&u5(e)&&d5(t)&&!(f5(e)&&p5(t));return(n?22:r?6:14)+(e.role===`user`&&t.role!==`user`?3:0)}function v5(e,t,n){return e.kind===`event`||e.kind===`reasoning`||e.role===`user`?!1:e.parts&&e.parts.length>0?e.parts.every(r=>r.kind===`tools`?r.tools.length===0:x5(e,r.text,t,n)):(e.tools?.length??0)===0&&x5(e,e.text,t,n)}function y5(e){for(let t=e.length-1;t>=0;t--)if(e[t].role===`assistant`&&e[t].kind!==`event`)return t;return-1}function b5(e,t,n=!1){let r=new WeakSet,i=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&&i.add(n.message);return e=>v5(e,r.has(e),i.has(e))}function x5(e,t,n,r){return!e.fenceRefused&&!n&&!r?t.includes("```awaiting")?UQ(t).every(e=>e.kind===`fence`&&e.fenceKind===`awaiting`&&jW(e.hints)&&!VW(e.body)):!t.trim():UQ(t).every(t=>t.kind===`fence`&&t.fenceKind===`awaiting`&&(e.fenceRefused||r||!S5(t.hints)))}function S5(e){return Gu(e).length>0}function C5(e,t,n){return e.kind===`event`||e.kind===`reasoning`||e.role===`user`?!1:e.parts&&e.parts.length>0?e.parts.some(r=>r.kind===`text`&&!x5(e,r.text,t,n)):typeof e.text==`string`&&!x5(e,e.text,t,n)}function w5(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(!(n.queued||v5(n)))return m5(n)?22:u5(n)&&!f5(n)?6:14+(n.role===`user`?3:0)}return 0}function T5(e,t,n){let r=[],i=null;return e.forEach((e,a)=>{n?.(e,a)||v5(e)||(i!==null&&r.push((0,R.jsx)(e1,{h:_5(i,e)},`s${a}`)),r.push(t(e,a)),i=e)}),r}function Rne(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 E5(e,t=14){let n=e.filter(e=>e!=null&&e!==!1),r=[];return n.forEach((e,n)=>{n>0&&r.push((0,R.jsx)(e1,{h:typeof t==`number`?t:t(n)},`vs${n}`)),r.push(e)}),r}var zne={head:!1,tail:!1};function D5(e,t){return n=>e[n-1]?.tail||e[n]?.head?22:t}function O5(e){return{head:ZG(e[0]),tail:ZG(e[e.length-1])}}function k5(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}):XG(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 A5(e){return e.split(`__`).pop()||e}function j5(e){let t=X.board?.projectDir;return t&&e.startsWith(t+`/`)?e.slice(t.length+1):e}function Bne({tools:e,at:t}){let[n,r]=(0,L.useState)(!1),i=(0,L.useId)(),a=e.reduce((e,t)=>e+t.count,0),o=wK(a,SK(e));return(0,R.jsxs)(`div`,{"data-tool-activity":!0,"data-tool-activity-state":`settled`,className:`flex min-w-0 flex-col`,children:[(0,R.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-focus-ink-60 ${q4}`,children:[(0,R.jsx)(`span`,{"data-tool-activity-label":!0,title:o,className:`min-w-0 truncate text-muted`,children:o}),(0,R.jsx)(r_,{"data-tool-activity-chevron":!0,"aria-hidden":`true`,size:13,className:Y4(n)})]}),n&&(0,R.jsx)(`div`,{id:i,className:`mt-1.5 flex flex-col`,children:E5(e.map((e,n)=>(0,R.jsx)(N5,{t:e,startedAt:t},n)),6)}),!n&&(0,R.jsx)(`div`,{id:i,hidden:!0})]})}function M5({tools:e,at:t}){let n=[];for(let t of e){let e=JG(t),r=n[n.length-1];r?.exceptional===e?r.tools.push(t):n.push({exceptional:e,tools:[t]})}return(0,R.jsx)(`div`,{className:`flex flex-col`,children:E5(n.map((e,n)=>e.exceptional?(0,R.jsx)(`div`,{className:`flex flex-col`,children:E5(e.tools.map((e,n)=>(0,R.jsx)(N5,{t:e,startedAt:t},n)),D5(e.tools.map(e=>O5([e])),6))},`exceptions-${n}`):(0,R.jsx)(Bne,{tools:e.tools,at:t},`activity-${n}`)),D5(n.map(e=>O5(e.tools)),6))})}function N5({t:e,startedAt:t}){let n=(0,L.useContext)(z8),r=ME(),i=xte(e,(n?Cg(r,n):void 0)?.bgShells??[]);return e.edits&&e.status!==`failed`&&e.status!==`cancelled`?(0,R.jsx)(eZ,{edits:e.edits,meta:(0,R.jsx)(I5,{status:e.status,backgroundState:e.backgroundState,liveBackgroundState:i,exitCode:e.exitCode,durationMs:e.durationMs})}):e.command?(0,R.jsx)(B5,{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,R.jsx)(Gne,{name:e.name,detail:e.detail,outputImage:e.outputImage,output:e.output,status:e.status,durationMs:e.durationMs}):e.read?(0,R.jsx)(Jne,{detail:e.detail,read:e.read,status:e.status,durationMs:e.durationMs}):e.prompt||e.agentId?(0,R.jsx)(Xne,{detail:e.detail,prompt:e.prompt,subagentType:e.subagentType,agentId:e.agentId,agentStatus:e.agentStatus,agentElapsedMs:e.agentElapsedMs,status:e.status,durationMs:e.durationMs}):e.sendTo!==void 0||e.sendBody!==void 0?(0,R.jsx)(Zne,{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,R.jsx)(Kne,{images:e.sentImages??[],files:e.sentFiles??[],caption:e.caption,status:e.status,durationMs:e.durationMs}):e.todos?(0,R.jsx)(_Q,{todos:e.todos,note:e.input,meta:(0,R.jsx)(I5,{status:e.status,durationMs:e.durationMs})}):XG(e)?(0,R.jsx)(Vne,{ask:e.ask??[],askAnswers:e.askAnswers}):e.input||e.output?(0,R.jsx)(B5,{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,R.jsx)(Wne,{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 Vne({ask:e,askAnswers:t}){return(0,R.jsx)(`div`,{"data-settled-ask":!0,className:`flex flex-col gap-1.5`,children:e.map((e,n)=>{let r=A3(e,t?.[n]);return(0,R.jsx)(B1,{question:r.question,settled:{chosenIdxs:r.chosenIdxs,text:r.text}},n)})})}function P5({tone:e,indicator:t,label:n,duration:r,title:i}){return(0,R.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,R.jsx)(`span`,{children:[n,r].filter(Boolean).join(` · `)})]})}function Hne(e,t,n){let[r,i]=(0,L.useState)(()=>Date.now()),a=VO(e,t),o=bte(e,t,n,r);return(0,L.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(BO-(Date.now()-e),0));return()=>clearTimeout(t)},[a,o,n]),o}function F5({status:e,backgroundState:t,liveBackgroundState:n,startedAt:r}){let i=Hne(e,t,r),a=n===`running`?(0,R.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--shell`,"data-running-indicator":`tool-disclosure`}):n===`stale`?(0,R.jsx)(`span`,{className:nk,title:ok}):yte(e,t)||i?(0,R.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--shell`,"data-running-indicator":`tool-disclosure`}):null;return a?(0,R.jsx)(`span`,{className:`frizz-tool-mark -mr-1 flex w-[9px] shrink-0 justify-center`,children:a}):null}function I5({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:UO(i),c=[o,s].filter(Boolean).join(` · `);return(0,R.jsx)(P5,{tone:e===`failed`?`frizz-tool-failed`:e===`cancelled`?`text-attention`:`text-muted-55`,title:c,label:a,duration:s})}function Une(e,t,n){let r=t?Date.parse(t):NaN,i=e===`pending`&&Number.isFinite(r),[a,o]=(0,L.useState)(()=>Date.now());return(0,L.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 L5(e,t,n){let r=t&&t!==X.board?.projectDir?`in ${j5(t)}`:void 0;return[e,t?r:n!==void 0&&!e?.includes(String(n))?`session ${n}`:void 0].filter(Boolean).join(` · `)||void 0}function R5(e){return e.startsWith(`/`)&&!e.includes(` `)&&!e.includes(`…`)}function Wne({name:e,detail:t,count:n,status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,cwd:s,sessionId:c,durationMs:l,startedAt:u}){let d=L5(t,s,c),f=d?j5(d):void 0,p=t&&R5(t)?t:void 0;return(0,R.jsx)(`div`,{className:`frizz-bash`,title:d,children:(0,R.jsxs)(`div`,{className:`frizz-bash-header`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(F5,{status:r,backgroundState:i,liveBackgroundState:a,startedAt:u}),(0,R.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:A5(e)}),f&&(p?(0,R.jsx)(`span`,{className:`min-w-0 truncate`,onClick:e=>e.stopPropagation(),children:(0,R.jsx)($X,{path:p,className:`text-[11.5px] text-muted`,children:f})}):(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:f}))]}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,R.jsx)(I5,{status:r,backgroundState:i,liveBackgroundState:a,exitCode:o,durationMs:l}),n>1&&(0,R.jsxs)(`span`,{className:`tabular-nums text-[11px] text-muted-45`,children:[`×`,n]})]})]})})}function Gne({name:e,detail:t,outputImage:n,output:r,status:i,durationMs:a}){let[o,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(!1),u=(0,L.useId)(),d=A5(e),f=t?j5(t):void 0;return(0,R.jsxs)(`div`,{"data-tool-image":!0,className:`frizz-bash`,children:[(0,R.jsxs)(QX,{className:`frizz-bash-header`,controls:u,expanded:o,label:`${o?`Collapse`:`Expand`} ${d}${t?`: ${t}`:``}`,onToggle:()=>s(e=>!e),meta:(0,R.jsx)(I5,{status:i,durationMs:a}),children:[(0,R.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:d}),f&&(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,title:t,children:f})]}),(0,R.jsx)(`div`,{id:u,hidden:!o,children:o&&(0,R.jsxs)(R.Fragment,{children:[c?(0,R.jsx)(`div`,{className:`frizz-bash-body break-all text-muted-70`,children:n}):(0,R.jsx)(`div`,{className:`flex justify-center bg-panel-2 p-1.5`,children:(0,R.jsx)(`img`,{src:BT(n),alt:f?`${d}: ${f}`:d,"data-local-path":n,"data-local-image":`true`,onError:()=>l(!0),className:`cursor-zoom-in block max-h-[420px] max-w-full w-auto rounded-md object-contain`})}),r&&(0,R.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body`,children:r})]})})]})}function Kne({images:e,files:t,caption:n,status:r,durationMs:i}){let[a,o]=(0,L.useState)(!0),s=(0,L.useId)(),c=(0,L.useMemo)(()=>e.map(e=>({target:e,title:n??`Delivered image`})),[e,n]),l=[e.length?`${e.length} image${e.length===1?``:`s`}`:``,t.length?`${t.length} file${t.length===1?``:`s`}`:``].filter(Boolean).join(` · `);return(0,R.jsxs)(`div`,{className:`frizz-bash`,children:[(0,R.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${l?`: ${l}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-60`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Sent to you`}),l&&(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:l})]}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,R.jsx)(I5,{status:r,durationMs:i}),(0,R.jsx)(r_,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${a?`rotate-90`:``}`})]})]}),(0,R.jsx)(`div`,{id:s,hidden:!a,children:a&&(0,R.jsxs)(R.Fragment,{children:[e.length>0&&(0,R.jsx)(PZ,{entries:c,framed:!1}),(t.length>0||n)&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5 px-2.5 pb-2.5 pt-1.5`,children:[t.length>0&&(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map((e,t)=>(0,R.jsx)(G5,{path:e},`f${t}`))}),n&&(0,R.jsx)(`div`,{className:`max-w-[65%] text-[12px] leading-snug text-muted`,children:n})]})]})})]})}var z5=16;function B5({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,L.useState)(!1),[m,h]=(0,L.useState)(!1),[g,_]=(0,L.useState)(!1),v=(0,L.useId)(),y=Une(i,d,l),b=(0,L.useMemo)(()=>e.split(`
|
|
329
329
|
`).length,[e]),x=b>z5,S=(0,L.useMemo)(()=>n?n.split(`
|
|
330
330
|
`).length:0,[n]),C=S>z5,w=L5(t,void 0,c),T=!!(e||n);return(0,R.jsxs)(`div`,{className:`frizz-bash`,children:[(0,R.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`} `:``}${A5(r)}${w?`: ${w}`:``}`,className:`frizz-bash-header w-full text-left outline-none focus-visible:ring-1 focus-visible:ring-inset focus-visible:ring-focus-ink-60`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(F5,{status:i,backgroundState:a,liveBackgroundState:o,startedAt:d}),(0,R.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:A5(r)}),(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,title:w,children:w??``})]}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,R.jsx)(I5,{status:i,backgroundState:a,liveBackgroundState:o,exitCode:s,durationMs:y}),T&&(0,R.jsx)(r_,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${f?`rotate-90`:``}`})]})]}),T&&(0,R.jsxs)(`div`,{id:v,hidden:!f,children:[f&&e&&(0,R.jsxs)(R.Fragment,{children:[u&&(0,R.jsx)(`div`,{className:`frizz-bash-output-label petite-caps`,children:u}),(0,R.jsx)(dQ,{text:e,language:u?`plaintext`:`bash`,className:`frizz-bash-body${u?` frizz-bash-output-body`:``}${x&&!m?` frizz-bash-clamp`:``}`}),x&&(0,R.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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`frizz-bash-output-label petite-caps`,children:`output`}),(0,R.jsx)(`pre`,{className:`frizz-bash-body frizz-bash-output-body${C&&!g?` frizz-bash-clamp`:``}`,children:n}),C&&(0,R.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 qne=16;function Jne({detail:e,read:t,status:n,durationMs:r}){let[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!1),c=(0,L.useId)(),l=(0,L.useMemo)(()=>t.split(`
|
|
331
331
|
`).length,[t]),u=l>qne,d=e?j5(e):void 0,f=e&&R5(e)?e:void 0;return(0,R.jsxs)(`div`,{className:`frizz-bash`,children:[(0,R.jsxs)(QX,{className:`frizz-bash-header`,controls:c,expanded:i,label:`${i?`Collapse`:`Expand`} Read${e?`: ${e}`:``}`,onToggle:()=>a(e=>!e),meta:(0,R.jsx)(I5,{status:n,durationMs:r}),children:[(0,R.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Read`}),d&&(f?(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:(0,R.jsx)($X,{path:f,className:`text-[11.5px] text-muted`,children:d})}):(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:d}))]}),(0,R.jsx)(`div`,{id:c,hidden:!i,children:i&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(dQ,{text:t,language:vT(e),className:`frizz-bash-body${u&&!o?` frizz-bash-clamp`:``}`}),u&&(0,R.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 Yne=16;function Xne({detail:e,prompt:t,subagentType:n,agentId:r,agentStatus:i,agentElapsedMs:a,status:o,durationMs:s}){let[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(!1),f=(0,L.useId)(),p=t||`Initial prompt unavailable.`,m=(0,L.useMemo)(()=>p?p.split(`
|
|
332
|
-
`).length:0,[p]),h=m>Yne,g=
|
|
333
|
-
`).length,[n]),p=f>Qne,m=!!n.trim(),h=V5(e,r);return(0,R.jsxs)(`div`,{className:`frizz-bash`,children:[(0,R.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-focus-ink-60`,disabled:!m,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:h}),t&&(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:t})]}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,R.jsx)(I5,{status:i,durationMs:a}),m&&(0,R.jsx)(r_,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${o?`rotate-90`:``}`})]})]}),m&&(0,R.jsx)(`div`,{id:u,hidden:!o,children:o&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`border-t border-border px-2.5 py-2${p&&!c?` frizz-bash-clamp`:``}`,children:(0,R.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:d})}),p&&(0,R.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 ere({body:e,items:t}){let[n,r]=(0,L.useState)(null),i=(0,L.useMemo)(()=>new Map(t.map(e=>[e.token,e])),[t]),a=n===null?void 0:i.get(n);return(0,R.jsxs)(R.Fragment,{children:[(0,L.useMemo)(()=>
|
|
334
|
-
`,1)[0]}`:``]}),i&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`button`,{type:`button`,className:l,disabled:c,title:`Send this message again`,onClick:()=>a({deliveryId:e,text:n}),children:`Retry`}),(0,R.jsx)(`button`,{type:`button`,className:l,disabled:c,title:`Put this message back in the prompt box`,onClick:n=>o({deliveryId:e,text:t,from:n.currentTarget}),children:`Edit`}),(0,R.jsx)(`button`,{type:`button`,className:l,disabled:c,title:`Discard this message`,onClick:()=>s({deliveryId:e}),children:`Dismiss`})]})]})}function nre({text:e,rawText:t,queued:n,deliveryUnconfirmed:r,deliveryFailed:i,deliveryError:a,deliveryId:o,sourceId:s}){let c=(0,L.useContext)(
|
|
335
|
-
`),i=r===void 0?b$(t):r;if(i&&e.deliveryState!==`failed`)return(0,R.jsx)(E1,{answers:i,queued:e.queued,sourceId:e.sourceId});let a=e.wake?od(t):void 0;return a?(0,R.jsx)(v1,{bump:a,sourceId:e.sourceId,at:e.at}):e.wake?(0,R.jsx)(o1,{steer:e.wakeSteer,text:t,sourceId:e.sourceId,at:e.at,wrap:n}):e.sessionPeer?(0,R.jsx)(u2,{peer:e.sessionPeer,text:t,queued:e.queued,sourceId:e.sourceId,at:e.at,wrap:n}):e.peerFrom?(0,R.jsx)(dre,{from:e.peerFrom,unnamed:e.peerUnnamed,dispatchId:e.peerDispatchId,sourceId:e.sourceId,at:e.at}):(0,R.jsx)(nre,{text:t,rawText:e.text,queued:e.queued,deliveryUnconfirmed:e.deliveryState===`unconfirmed`,deliveryFailed:e.deliveryState===`failed`,deliveryError:e.deliveryError,deliveryId:e.deliveryId,sourceId:e.sourceId})}let g=[],_=[],v=(e,t=zne)=>{g.push(e),_.push(t)},y={n:-1},b=[],x=new Set,S=(r,i)=>{for(let[a,u]of UQ(r).entries()){if(u.kind===`fence`){if(u.fenceKind===`awaiting`&&o&&!e.fenceRefused&&!d&&S5(u.hints)){v((0,R.jsx)(X6,{fence:{body:u.body,hints:u.hints}},`${i}-f${a}`));continue}if(u.fenceKind===`awaiting`&&(e.fenceRefused||o||d))continue;if(u.fenceKind===`awaiting`&&jW(u.hints)){let e=VW(u.body);e&&v((0,R.jsx)(U5,{md:e,wrap:n},`${i}-f${a}`));continue}v((0,R.jsx)(K5,{fenceKind:u.fenceKind,body:u.body,hints:u.hints,wrap:n},`${i}-f${a}`));continue}for(let[e,r]of xQ(u.text).entries()){if(r.kind===`prose`){for(let[t,o]of oz(r.text).entries()){let r=`${i}-${a}-p${e}-${t}`;v(o.kind===`image`?(0,R.jsx)(W5,{path:o.path},r):o.kind===`file`?(0,R.jsx)(G5,{path:o.path},r):o.kind===`visualization`?(0,R.jsx)(are,{file:o.file},r):o.kind===`directive`?(0,R.jsx)(A8,{directive:o.directive},r):o.kind===`mermaid`?(0,R.jsx)(I8,{source:o.source},r):o.kind===`lightbox`?(0,R.jsx)(PZ,{entries:o.entries},r):(0,R.jsx)(U5,{md:o.text,wrap:n},r))}continue}y.n+=1;let o=y.n,u=c&&r.registeredId?c.find(e=>e.id.toLowerCase()===r.registeredId):void 0;if(u&&!x.has(u.id)){x.add(u.id),v((0,R.jsx)(k0,{q:u},`${i}-${a}-q${e}`));continue}if(s&&G$(r,s)!==void 0)continue;let d=l&&r.registeredId?l.find(e=>e.id.toLowerCase()===r.registeredId):void 0;if(d&&!x.has(d.id)){x.add(d.id),v((0,R.jsx)(E0,{s:d,wrap:n},`${i}-${a}-q${e}`));continue}if(r.registeredId&&r.text.trim()===``)continue;t&&b.push({raw:r.text,kind:r.questionKind,danger:r.danger,bi:o});let p=t&&!f?{answer:t.answerFor(o),onChip:(e,n)=>t.onChip(o,e,n),onText:e=>t.onText(o,e),onSubmit:t.onSubmit}:void 0;v((0,R.jsx)(B1,{raw:r.text,questionKind:r.questionKind,danger:r.danger,interactive:p,wrap:n},`${i}-${a}-q${e}`))}}};if(e.parts&&e.parts.length>0)Rne(e.parts).forEach((t,r)=>{if(t.kind===`tools`){if(i)return;let a=k5(t.tools);a.length&&v((0,R.jsx)(M5,{tools:a,dense:n,at:e.at},`t${r}`),O5(a))}else S(t.text,`x${r}`)});else{if(!i){let t=k5(e.tools);t.length>0&&v((0,R.jsx)(M5,{tools:t,dense:n,at:e.at},`tools`),O5(t))}S(e.text,`leg`)}return g.length===0?null:(a&&t&&f&&b.length>0?v((0,R.jsx)(`div`,{className:`flex justify-start`,children:(0,R.jsx)(`button`,{type:`button`,"data-mobile-answer-open":!0,onClick:()=>m(!0),className:`button-outline flex h-[40px] items-center justify-center rounded-[12px] bg-accent-fill px-4 text-[15px] font-semibold text-on-accent active:brightness-90`,children:b.length>1?`Answer ${b.length} questions`:`Answer`})},`answer-open`)):a&&t&&b.length>0&&v((0,R.jsx)(`div`,{className:`flex justify-start`,children:(0,R.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:!t.anyAnswered||t.sending,onClick:t.onSubmit,onMouseDown:e=>e.preventDefault(),className:`button-outline 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,R.jsxs)(`div`,{"data-frizz-msg":e.sourceId,className:`flex flex-col text-[13px] min-w-0`,children:[E5(g,D5(_,14)),p&&t&&b.length>0?(0,R.jsx)(G1,{blocks:b,answering:t,onClose:()=>m(!1)}):null]}))});function U5({md:e,wrap:t}){let n=SX(e),r=rZ(n),i=(0,L.useRef)(null);return gZ(i,n),n?(0,R.jsx)(`div`,{ref:i,className:`md-body${t?` ${GQ}`:``}`,dangerouslySetInnerHTML:r}):null}function W5({path:e,hideCaption:t,altText:n}){let[r,i]=(0,L.useState)(!1);if(r)return(0,R.jsx)(`div`,{className:`font-mono-keep text-[12px] text-muted-70 break-all`,children:e});let a=xh(e);return(0,R.jsx)(VY,{caption:t?void 0:(0,R.jsx)(`figcaption`,{className:`bg-panel-2 px-2 pb-1.5 font-mono-keep text-[11px] text-muted-60 break-all`,children:a}),children:(0,R.jsx)(`img`,{src:BT(e),alt:n??a,"data-local-path":e,"data-local-image":`true`,onError:()=>i(!0),className:`cursor-zoom-in ${WY}`})})}function G5({path:e}){let t=xh(e);return(0,R.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,R.jsx)(v_,{size:14,strokeWidth:2,className:`shrink-0 text-muted`}),(0,R.jsx)(`span`,{className:`font-mono-keep truncate text-[12px] text-fg`,children:t})]})}var rre={"--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-control-strong`,"--ring":`--color-accent`,"--destructive":`--viz-destructive`,"--viz-series-1":`--viz-series-1`,"--viz-series-2":`--viz-series-2`,"--viz-series-3":`--viz-series-3`,"--viz-series-4":`--viz-series-4`,"--viz-series-5":`--viz-series-5`,"--viz-series-6":`--viz-series-6`};function ire(e){let t=getComputedStyle(document.documentElement),n=Object.fromEntries(Object.entries(rre).map(([e,n])=>[e,t.getPropertyValue(n).trim()]));return n[`--font-size-base`]=getComputedStyle(document.body).fontSize,M2(e,t.colorScheme===`light`?`light`:`dark`,n)}function are({file:e}){let t=(0,L.useContext)(L8),n=(0,L.useRef)(null),[r,i]=(0,L.useState)(360),[a,o]=(0,L.useState)(null),[s,c]=(0,L.useState)(null),l=(0,L.useRef)(void 0),u=(0,L.useRef)(0),d=(0,L.useRef)(null),{resolved:f}=(0,L.useSyncExternalStore)(A2,O2,O2),p=t?`${sm()}/local-visualization?slug=${encodeURIComponent(t)}&file=${encodeURIComponent(e)}`:null;(0,L.useEffect)(()=>{if(!p){o(!1);return}let e=new AbortController;return o(null),c(null),d.current=null,window.clearTimeout(l.current),fetch(p,{method:`HEAD`,signal:e.signal}).then(t=>{e.signal.aborted||o(t.ok)}).catch(()=>{e.signal.aborted||o(!1)}),()=>e.abort()},[p]);let m=(0,L.useCallback)(()=>{if(!p||d.current!==p)return;let e=++u.current;n.current?.contentWindow?.postMessage(ire(e),`*`)},[p]);return(0,L.useEffect)(()=>{let e=e=>{if(e.source!==n.current?.contentWindow)return;if(e.data?.type===`frizz-inline-vis-ready`){m();return}if(N2(e.data,u.current)&&p&&d.current===p){window.clearTimeout(l.current),c(p);return}if(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)},[m,p]),(0,L.useEffect)(()=>{m()},[f,m]),(0,L.useEffect)(()=>()=>window.clearTimeout(l.current),[]),a===!1||!p?(0,R.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,R.jsx)(`span`,{className:`font-mono-keep break-all`,children:e})]}):a===null?(0,R.jsx)(`div`,{role:`status`,className:`h-20 animate-pulse ${KQ} bg-panel-2`,"aria-label":`Loading ${e}`}):(0,R.jsx)(`iframe`,{ref:n,src:p,title:e.replace(/\.html$/,``).replaceAll(`-`,` `),sandbox:`allow-scripts`,onLoad:()=>{p&&(c(null),d.current=p,m(),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o(!1),5e3))},className:`block w-full border-0 bg-transparent`,style:{height:r,visibility:s===p?`visible`:`hidden`}})}function K5({fenceKind:e,body:t,hints:n,wrap:r}){let i=SX(t),a=(0,L.useContext)(L8),o=(0,L.useContext)(B8),s=ME(),c=a?Cg(s,a):void 0,l=c?zK(c):void 0,u=!!(c&&l?.archive),d=(0,L.useRef)(null);u&&c&&(d.current=c);let f=u&&c?c:d.current,p=Lg();return e===`done`?(0,R.jsxs)(r$,{icon:e_,label:`Done`,children:[i&&(0,R.jsx)(uQ,{className:`md-body${r?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:i}),f&&!p&&(0,R.jsx)(a$,{children:(0,R.jsx)(Mq,{thread:f,className:`rounded-md text-[11px] bg-fg px-2.5 py-1 text-bg hover:opacity-90`,iconClassName:`icon-label-nudge`,onArchived:o?.dismiss,onDismissCancel:o?.cancel})})]}):c&&q6(c)?null:(0,R.jsx)(X6,{thread:c,fence:{body:t,hints:n}})}function ore({slug:e,sessionId:t,fault:n,retryText:r}){let[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!1),c=qe(),l=rH[n.backend],u=t=>{s(!0),DW(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,R.jsxs)(r$,{"data-provider-fault":!0,tone:`danger`,icon:j_,label:`${l} sign-in required`,children:[(0,R.jsx)(`span`,{className:i$,children:`The provider rejected this session's credential. Sign in, then retry.`}),(0,R.jsxs)(a$,{children:[r?.trim()&&(0,R.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,R.jsx)(`button`,{onClick:()=>a(!0),onMouseDown:e=>e.preventDefault(),className:c$,children:`Sign in`})]}),i&&(0,R.jsx)(aH,{backend:n.backend,onClose:()=>a(!1),onAuthed:()=>a(!1)})]})}function sre({slug:e,sessionId:t,pause:n}){let r=n.backend===`acp`?`The agent`:rH[n.backend],i=n.window===`weekly`?`weekly limit`:n.window===`session`?`session limit`:`usage limit`,[a,o]=(0,L.useState)(!1),s=qe();return(0,R.jsxs)(r$,{"data-limit-pause":!0,tone:`caution`,icon:D_,label:`Paused by the ${r} ${i}`,children:[(0,R.jsx)(`span`,{className:i$,children:n.autoResume?n.resumesAt?`Continuing automatically at ${AO(n.resumesAt)}.`:`Continuing automatically once the window resets.`:`Continue it whenever you have capacity again.`}),(0,R.jsx)(a$,{children:(0,R.jsx)(`button`,{onClick:()=>{o(!0),DW(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 ${c$}`,children:`Continue now`})})]})}function cre({onTerminal:e}){return(0,R.jsxs)(r$,{tone:`attention`,icon:j_,label:`Permission approval`,children:[(0,R.jsx)(`span`,{className:i$,children:`The agent is waiting on your approval — respond in your external terminal.`}),(0,R.jsx)(a$,{children:(0,R.jsx)(`button`,{onClick:()=>e(),onMouseDown:e=>e.preventDefault(),className:c$,children:`Copy terminal command`})})]})}function q5({policy:e,denies:t}){let n=[e.tool,e.command].filter(Boolean).join(`: `);return(0,R.jsxs)(r$,{tone:`caution`,icon:ov,label:`Blocked by frizz's permission policy`,children:[n?(0,R.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,R.jsx)(`span`,{className:i$,children:e.reason}),(0,R.jsxs)(`span`,{className:`mt-1.5 block text-[11px] text-muted`,children:[`Rule `,(0,R.jsx)(`code`,{className:`rounded bg-panel px-1 py-0.5`,children:e.rule}),t&&t>1?` · ${t} denials this session`:``]})]})}function J5({slug:e,className:t=`px-4 pb-2 pt-1`,includeAgents:n=!0,transcriptShells:r=[],parentAgentId:i}){let a=Cg(ME(),e),o=a?.subAgents??[],s=n?i?gk(o,i):o:[],c=i?[...r]:bk(a?.bgShells??[],r),l=i?[]:(a?.watches??[]).filter(e=>e.kind===`github`),u=i?[]:a?.links??[],d=s.length+c.length+l.length,f=new Set((a?.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`).map(e=>e.target)),p=e=>f.has(e.taskId??``)||f.has(e.id??``)||f.has(e.label),[,m]=(0,L.useState)(0);(0,L.useEffect)(()=>{if(d===0)return;let e=setInterval(()=>m(e=>e+1),3e4);return()=>clearInterval(e)},[d]);let h=cte(e,c.flatMap(e=>e.id&&!e.outputUnavailable?[e.id]:[]));return d===0&&u.length===0?null:(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5 ${t}`,"data-background-ops":!0,children:[vk(s,`sheet`).map((t,n)=>(0,R.jsx)(xk,{kind:`AGENT`,label:t.label,state:t.state,density:`sheet`,depth:t.displayDepth??t.depth,startedAt:t.startedAt,onOpen:t.id?()=>Jh(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:zP(e,t)},`a${n}`)),vk(c,`sheet`).map((t,n)=>(0,R.jsx)(xk,{kind:`SHELL`,label:t.label,state:t.state,density:`sheet`,startedAt:t.startedAt,counter:t.id?lk(h.get(t.id)):void 0,counterTitle:`Lines of output so far — open the row to read them`,onOpen:t.id&&!t.outputUnavailable?()=>Yh(e,t.id,{label:t.label,startedAt:t.startedAt}):void 0,onDismiss:zP(e,t,`SHELL`),title:p(t)?`${t.label}\nWatched — this thread wakes when it finishes`:void 0},`s${n}`)),l.map(e=>(0,R.jsx)(xk,{kind:`GITHUB`,label:e.target,state:`running`,density:`sheet`,startedAt:e.createdAt,counter:e.subject===`issue`?dk(e.issue):uk(e.github),counterTone:e.github?.checks===`failing`?`danger`:void 0,counterTitle:e.subject===`issue`?e.issue?`${e.target} — ${j6(e.issue)}`:void 0:e.github?`${e.target} — ${y6(e.github)}`:void 0,onOpen:()=>window.open(AW(e.target,e.subject===`issue`?`issue`:`pull`)??`https://github.com/${e.target.replace(`#`,e.subject===`issue`?`/issues/`:`/pull/`)}`,`_blank`,`noreferrer,noopener`)},e.id)),(0,R.jsx)(K4,{links:u})]})}function lre({ask:e,onTerminal:t}){return(0,R.jsxs)(r$,{tone:`attention`,icon:u_,label:`Waiting on your answer — in your external terminal`,children:[(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.header&&(0,R.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-55`,children:e.header}),(0,R.jsx)(`div`,{className:`min-w-0 text-[12px] font-medium leading-5 text-fg`,children:e.question}),e.options.length>0&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.options.map((e,t)=>(0,R.jsxs)(`div`,{className:`rounded-md border border-border bg-elevated px-3 py-1.5 text-[12px] text-fg/80`,children:[(0,R.jsx)(`span`,{className:`font-medium text-fg/90`,children:e.label}),e.description&&(0,R.jsxs)(`span`,{className:`text-muted-70`,children:[` — `,e.description]})]},t)),e.multiSelect&&(0,R.jsx)(`div`,{className:`text-[10px] text-muted-50`,children:`select one or more`})]})]},t))}),(0,R.jsx)(a$,{children:(0,R.jsxs)(`button`,{onClick:()=>t(),onMouseDown:e=>e.preventDefault(),className:c$,children:[(0,R.jsx)(j_,{size:12,className:`shrink-0 ${m2}`}),`Copy terminal command`]})})]})}function ure({call:e,sourceId:t,at:n}){let r=z8(),i=e.detail??`sub-agent`,{tail:a}=z4(e),o=!!(r&&e.agentId);return(0,R.jsxs)(t1,{icon:Qg,sourceId:t,marker:`agent`,ariaLabel:o?void 0:`Sub-agent ${i} ${a}`,at:n,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:`Sub-agent`}),(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:`«`}),o?(0,R.jsx)(`button`,{type:`button`,"data-subagent-completion-open":!0,title:ck.AGENT,"aria-label":`${ck.AGENT}: ${i}`,onClick:()=>Jh(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-focus-ink-60`,children:i}):(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:i}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`»`})]}),(0,R.jsx)(`span`,{className:`shrink-0`,children:a})]})}function dre({from:e,unnamed:t,dispatchId:n,sourceId:r,at:i}){let a=z8(),o=!!(a&&n),s=t?void 0:e,c=t&&e?`${ck.AGENT} — ${e}`:ck.AGENT;return s===void 0?(0,R.jsx)(t1,{icon:Qg,sourceId:r,marker:`agent-report`,ariaLabel:o?void 0:`Sub-agent reported`,at:i,children:o?(0,R.jsx)(`button`,{type:`button`,"data-subagent-report-open":!0,title:c,"aria-label":`${ck.AGENT}${e?`: ${e}`:``}`,onClick:()=>Jh(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-focus-ink-60`,children:`Sub-agent reported`}):(0,R.jsx)(`span`,{className:`shrink-0`,title:e||void 0,children:`Sub-agent reported`})}):(0,R.jsxs)(t1,{icon:Qg,sourceId:r,marker:`agent-report`,ariaLabel:o?void 0:`Sub-agent ${s} reported`,at:i,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:`Sub-agent`}),(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:`«`}),o?(0,R.jsx)(`button`,{type:`button`,"data-subagent-report-open":!0,title:ck.AGENT,"aria-label":`${ck.AGENT}: ${s}`,onClick:()=>Jh(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-focus-ink-60`,children:s}):(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:s}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`»`})]}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`reported`})]})}function fre({to:e,type:t,dispatchId:n,targetLabel:r,sourceId:i,at:a}){let o=z8(),s=V5(e,t),c=e===`main`?void 0:r??e,l=!!(o&&n);return(0,R.jsxs)(t1,{icon:Qg,sourceId:i,marker:`agent-steer`,ariaLabel:l?void 0:`${s}${c?` ${c}`:``}`,at:a,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:s}),c&&(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:`«`}),l?(0,R.jsx)(`button`,{type:`button`,"data-subagent-steer-open":!0,title:ck.AGENT,"aria-label":`${ck.AGENT}: ${c}`,onClick:()=>Jh(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-focus-ink-60`,children:c}):(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:c}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`»`})]})]})}function pre({text:e,boundary:t,sourceId:n,at:r}){return t?(0,R.jsx)(t1,{icon:t===`wake`?rv:void 0,sourceId:n,marker:t===`rest`?`rest`:`event`,ariaLabel:e,at:r,children:(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:e})}):(0,R.jsx)(`div`,{"data-frizz-msg":n,className:q4,children:e})}function mre({text:e,sourceId:t}){let[n,r]=(0,L.useState)(!1),i=(0,L.useId)();return(0,R.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,R.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:`${q4} flex items-baseline gap-1.5 self-start rounded outline-none transition-colors hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:[(0,R.jsx)(`span`,{children:`Reasoning`}),(0,R.jsx)(r_,{"aria-hidden":`true`,size:13,className:Y4(n)})]}),n&&(0,R.jsx)(`div`,{id:i,className:`frizz-reasoning mt-1.5 ml-[5px] border-l border-border/70 pl-3`,children:(0,R.jsx)(U5,{md:e,wrap:!0})})]})}function Y5(){return(0,R.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-full border border-muted/70 border-t-transparent animate-spin`})}function X5({since:e,startedAt:t,activityLabel:n,run:r}){let[i]=(0,L.useState)(()=>Date.now()),a=(0,L.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,L.useState)(()=>Date.now()),[c,l]=(0,L.useState)(!1),u=(0,L.useId)();(0,L.useEffect)(()=>{let e=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(e)},[]);let d=qO(Math.max(0,o-a)),f=(0,L.useMemo)(()=>k5([...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-focus-ink-60 ${q4}`,g=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate shimmer-text`,children:n??TK(p)}),m&&(0,R.jsx)(r_,{"data-working-chevron":!0,"aria-hidden":`true`,size:13,className:Y4(c)})]}),(0,R.jsx)(`span`,{className:`shrink-0 whitespace-nowrap tabular-nums text-[12px] text-muted-60`,children:d})]});return(0,R.jsxs)(`div`,{"data-working-indicator":!0,"data-working-activity":n?`tool`:`generic`,className:`flex min-w-0 flex-col`,children:[m?(0,R.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,R.jsx)(`div`,{className:h,children:g}),m&&c&&(0,R.jsx)(`div`,{id:u,className:`mt-1.5 flex flex-col`,children:E5(f.map((e,t)=>(0,R.jsx)(N5,{t:e,startedAt:r?.at},t)),6)}),m&&!c&&(0,R.jsx)(`div`,{id:u,hidden:!0})]})}function hre({id:e,slug:t,depth:n,widthDepth:r,initiallyOpen:i}){let{shown:a,close:o,closingRef:s}=Vg(e,i===!0),[c,l]=(0,L.useState)(i===!0),u=(0,L.useRef)(null),d=(0,L.useRef)(null),f=gr(X),p=zg(e),m=Rg(e),h=Bg(),g=Lg(),_=(0,L.useRef)(typeof document<`u`&&document.activeElement instanceof HTMLElement?document.activeElement:null),v=(0,L.useCallback)(()=>{let e=_.current,t=document.activeElement;t&&t!==document.body||e?.isConnected&&e.focus({preventScroll:!0})},[]);(0,L.useEffect)(()=>()=>{window.setTimeout(v,0)},[v]);let y=ME(),b=Xp(y,t),x=b.kind===`found`?b.thread:void 0;y?.projectDir;let S=x?x.runtime===`turn-idle`||x.runtime===`exited`||x.runtime===`none`:!1;(0,L.useEffect)(()=>{!x||!S||Y.threadSeen({slug:t}).catch(()=>{})},[t,S,S?x?.lastActivityAt:void 0]);let C=(0,L.useRef)(null);return C.current===null&&x&&(C.current=g&&x.runtime!==`running`&&x.runtime!==`spawning`),(0,L.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 lJ({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||C.current===!0});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,L.useEffect)(()=>{d.current?.activationChanged()},[p]),(0,L.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,L.useEffect)(()=>(Ip(e,()=>u.current?.focus({preventScroll:!0})),()=>Ip(e,null)),[e]),(0,R.jsx)(gR,{modal:h,open:!0,onOpenChange:e=>{e||o()},children:(0,R.jsxs)(bR,{children:[h&&!m?(0,R.jsx)(`div`,{className:`${Dh} ${a?`opacity-100`:`opacity-0`}`,style:{zIndex:50+n*2,pointerEvents:`auto`}}):(0,R.jsx)(SR,{className:`${Dh} ${a?`opacity-100`:`opacity-0`}`,style:{zIndex:50+n*2}}),(0,R.jsxs)(ER,{ref:u,"aria-modal":h||void 0,"aria-describedby":void 0,tabIndex:-1,onEscapeKeyDown:t=>{if(t.target instanceof Element&&t.target.closest(`[data-claims-escape]`)){t.preventDefault();return}if(X.drawers.at(-1)?.id!==e){t.preventDefault();return}mB(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(),v()},onOpenAutoFocus:e=>{e.preventDefault(),u.current?.focus({preventScroll:!0})},"data-vt-chat":!0,className:`fixed right-0 top-0 overflow-hidden outline-none ${Oh} ${a?`translate-x-0`:`translate-x-full`}`,style:{zIndex:51+n*2,width:kh(r),viewTransitionName:f.vtReturnTarget===t?`thread-chat`:void 0},children:[(0,R.jsx)(jR,{className:`sr-only`,children:b.kind===`found`?`Thread: ${UD(b.thread)}`:`Thread: ${t}`}),c&&b.kind===`found`?(0,R.jsx)(W8,{slug:t,onStatusApplied:o,onClose:o,virtualized:!0}):c&&b.kind===`missing`?(0,R.jsx)(gre,{slug:t,onClose:o}):(0,R.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,R.jsx)(`span`,{className:`block h-5 w-5 rounded-full border-2 border-muted/50 border-t-transparent animate-spin`})})]})]})})}function gre({slug:e,onClose:t}){return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsx)(fv,{title:`Thread unavailable`,onClose:t}),(0,R.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 _re({id:e,slug:t,subId:n,label:r,subagentType:i,startedAt:a,depth:o,widthDepth:s}){let[c,l]=(0,L.useState)(!1),u=(0,L.useRef)(null),d=ote(t,n),f=NE(),p=(0,L.useMemo)(()=>d.data?.messages??[],[d.data]),m=d.data?.state,h=m===`running`,g=(0,L.useMemo)(()=>H8(p),[p]),_=(0,L.useMemo)(()=>U8(p),[p]),v=(0,L.useMemo)(()=>sK(_),[_]),y=h?uK(v):void 0,b=h?lK(v):void 0,x=b?yK(b,f):void 0,S=h?fK(v):void 0,C=(0,L.useMemo)(()=>h?mK(v):v,[v,h]),w=h,T=d.isError||m===`gone`||p.length===0&&(m===`done`||m===`stale`);return(0,L.useEffect)(()=>{let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>l(!0))});return()=>{cancelAnimationFrame(t),e&&cancelAnimationFrame(e)}},[]),(0,L.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,R.jsx)(Gg,{id:e,depth:o,widthDepth:s,children:e=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(fv,{title:r,onClose:e}),(0,R.jsx)(`div`,{ref:u,className:`flex-1 min-h-0 overflow-y-auto`,children:T?(0,R.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,R.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,R.jsx)(`span`,{className:`block h-5 w-5 rounded-full border-2 border-muted/50 border-t-transparent animate-spin`})}):(0,R.jsx)(R8.Provider,{value:t,children:(0,R.jsxs)(`div`,{"data-transcript-column":!0,className:`flex flex-col px-6 py-5`,children:[T5(C.map(e=>e.message),(e,t)=>(0,R.jsx)(H5,{m:e},t)),w&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(e1,{h:w5(C.map(e=>e.message))}),(0,R.jsx)(X5,{since:a,startedAt:S,activityLabel:x,run:y})]})]})})}),(0,R.jsx)(vre,{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,R.jsx)(J5,{slug:t,parentAgentId:n,transcriptShells:g,className:e})})]})})}function vre({slug:e,subId:t,subagentType:n,steerable:r,note:i,stoppable:a,stopNote:o,ops:s}){let[c,l]=(0,L.useState)(``),[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(!1),m=qe();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,R.jsxs)(`div`,{"data-subagent-steer-note":!0,className:`w-full shrink-0 border-t border-border bg-panel px-3 py-3`,children:[(0,R.jsx)(`div`,{className:`px-1 pb-2 text-[11.5px] text-muted-70`,children:e}),(0,R.jsx)(`div`,{className:`pl-1.5`,children:(0,R.jsx)(Z5,{subagentType:n})}),s?.(`px-1 pt-1.5 ops-column-optical-inset`)]}):(0,R.jsx)(R.Fragment,{children:s?.(`w-full shrink-0 border-t border-border bg-panel px-4 pb-2 pt-3`)})}return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{"data-subagent-steer":!0,className:`w-full shrink-0 border-t border-border bg-panel px-3 py-3`,children:[r?(0,R.jsx)(Uz,{value:c,onChange:l,onSubmit:h,surface:`subAgentComposer`,placeholder:`Steer this sub-agent…`,busy:u||f,footer:(0,R.jsx)(Z5,{subagentType:n})}):i?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`px-1 pb-2 text-[11.5px] text-muted-70`,children:i}),(0,R.jsx)(`div`,{className:`pl-1.5`,children:(0,R.jsx)(Z5,{subagentType:n})})]}):null,r&&!a&&o&&(0,R.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,R.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,R.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-danger/40 hover:bg-danger/10 hover:text-danger-soft disabled:opacity-50`,children:f?`Stopping…`:`Stop sub-agent`})})]})}function Z5({subagentType:e}){let t=F4(e);return(0,R.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 ${Jz}`,children:(0,R.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 truncate`,children:t})})}var Q5=`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 yre({id:e,slug:t,shellId:n,label:r,startedAt:i,depth:a,widthDepth:o}){let s=(0,L.useRef)(null),c=ste(t,n),l=c.data?.state,u=c.data?.command,d=c.data?.output??``,[f,p]=(0,L.useState)(!1),m=qe();(0,L.useEffect)(()=>{let e=s.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<160&&(e.scrollTop=e.scrollHeight)},[d]);let h=XO(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 eH(u),Z(`Command copied`)}catch{Z(`Could not copy command`)}}return(0,R.jsx)(Gg,{id:e,depth:a,widthDepth:o,children:e=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(fv,{title:r,icon:(0,R.jsx)(rv,{"aria-hidden":!0,size:14,className:`shrink-0 text-muted-60`}),meta:g?(0,R.jsx)(`span`,{className:`shrink-0 whitespace-nowrap text-[11.5px] text-muted-60`,children:g}):void 0,onClose:e}),(0,R.jsx)(`div`,{ref:s,className:`min-h-0 flex-1 overflow-y-auto px-5 py-5`,children:_?(0,R.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,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsxs)(`section`,{children:[(0,R.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,R.jsx)(`h2`,{className:`petite-caps text-[10px] text-muted-65`,children:`Command`}),u&&(0,R.jsxs)(`button`,{type:`button`,onClick:y,className:`button-outline 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-focus-ink-60`,children:[(0,R.jsx)(m_,{"aria-hidden":!0,size:11}),` Copy`]})]}),u?(0,R.jsx)(dQ,{"data-background-shell-command":!0,text:u,language:`bash`,className:Q5}):(0,R.jsx)(`pre`,{"data-background-shell-command":!0,className:Q5,children:c.isLoading?`Loading…`:`Command unavailable for this background operation.`})]}),(0,R.jsxs)(`section`,{children:[(0,R.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,R.jsx)(`h2`,{className:`petite-caps text-[10px] text-muted-65`,children:`Output`}),l===`running`&&(0,R.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--shell`,"data-running-indicator":`shell-drawer`}),c.data?.truncated&&(0,R.jsx)(`span`,{className:`text-[10.5px] text-muted-50`,children:`Showing latest 512 KB`})]}),d?(0,R.jsx)(`pre`,{"data-background-shell-output":!0,className:`font-mono-keep min-h-40 whitespace-pre-wrap break-words ${KQ} border border-border bg-inset px-4 py-3 text-[12px] leading-relaxed text-fg/85`,children:d}):(0,R.jsx)(`div`,{"data-background-shell-output":!0,className:`flex min-h-40 items-center justify-center ${KQ} border border-border bg-inset px-4 text-center text-[12px] text-muted-60`,children:l===`done`?`No output was captured.`:`No output yet.`})]})]})}),!_&&c.data?.stoppable&&(0,R.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,R.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-danger/40 hover:bg-danger/10 hover:text-danger-soft disabled:opacity-50`,children:f?`Stopping…`:`Stop shell`})}),!_&&!c.data?.stoppable&&l===`running`&&c.data?.stopNote&&(0,R.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 $5(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 e7={paddingBottom:`max(0.75rem, env(safe-area-inset-bottom))`};function t7({path:e}){return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{Y.openLocalFile({path:e}).then(async e=>{e.action===`copy`&&(await eH(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-focus-ink-60`,title:`Open ${e} outside Frizz`,"aria-label":`Open`,children:[(0,R.jsx)(g_,{size:12,"aria-hidden":`true`}),` Open`]})}function n7({source:e}){return(0,R.jsx)(dQ,{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 bre({id:e,path:t,title:n,depth:r,widthDepth:i}){let a=IE(t),o=ct({...XT(t),refetchInterval:a?!1:ZT}),s=o.data?.path??t,c=KT(t),{front:l,body:u}=$5(c?o.data?.markdown??``:``),d=JT(s),f=SX(u,{baseDir:d,asDocument:!0}),p=rZ(f),m=(0,L.useRef)(null);gZ(m,f);let h=BZ(m,f,d),g=Lg(),_=o.data?.markdown??``,v=rZ((0,L.useMemo)(()=>c?``:eE(s,_),[c,_,s]));return(0,R.jsx)(Gg,{id:e,depth:r,widthDepth:i,children:e=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(fv,{title:n,subtitle:s,onClose:e}),(0,R.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:[o.isLoading?(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):o.error?(0,R.jsxs)(`div`,{className:`text-[13px] text-danger-90`,children:[`Couldn’t read this file: `,o.error.message]}):c?f?(0,R.jsxs)(R.Fragment,{children:[l&&(0,R.jsx)(n7,{source:l}),(0,R.jsx)(`div`,{ref:m,className:`md-body`,dangerouslySetInnerHTML:p}),h,o.data?.truncated&&(0,R.jsxs)(`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.`,g?``:` Open it to read the rest.`]})]}):(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):_?(0,R.jsx)(`pre`,{"data-file-source":!0,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:v}):(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!c&&!o.isLoading&&!o.error&&o.data?.truncated&&(0,R.jsx)(`p`,{className:`mt-4 border-t border-border/60 pt-3 text-[12px] text-muted`,children:`This file is too long to show in full — everything above the cut is shown.`})]}),g?(0,R.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0`,style:{height:`env(safe-area-inset-bottom)`}}):(0,R.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:e7,children:(0,R.jsx)(t7,{path:s})})]})})}function xre({id:e,slug:t,title:n,depth:r,widthDepth:i}){let a=ct({queryKey:[`threadBody`,t],queryFn:()=>Y.threadBody({slug:t})}),o=gr(X);(0,L.useEffect)(()=>{a.refetch()},[o.board]);let s=F2(Cg(o.board,t)),c=wH(),l=CH.adopt(c,t),[u,d,f]=EH(l),p=pt({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)=>{bH.get(l)||d(t),Z(`Start failed: ${e.message.slice(0,80)}`)}}),m=SX(lX(a.data?.markdown??``)),h=rZ(m);return(0,R.jsx)(Gg,{id:e,depth:r,widthDepth:i,widthOffset:1,subagentParent:t,children:e=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(fv,{title:n,subtitle:`${t}.md`,onClose:e}),(0,R.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:a.isLoading?(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):m?(0,R.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:h}):(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`No thread file found.`})}),s&&(0,R.jsxs)(`div`,{className:`shrink-0 border-t border-border/60 px-5 pb-4 pt-3`,children:[(0,R.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,R.jsx)(Uz,{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 r7({onEscapeAtRest:e}={}){let t=gr(X),n=ME(),r=(0,L.useRef)(e);r.current=e,(0,L.useEffect)(()=>{function e(e){if(e.key===`Escape`){if(pB()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(X.showPalette)X.showPalette=!1;else if(X.showNewThread)X.showNewThread=!1;else if(X.showGithubPicker)Ih();else if(X.showSettings)jp()||(X.showSettings=!1);else if(X.drawers.length>0){let e=X.drawers[X.drawers.length-1];Fp(e.id)||X.drawers.pop()}else X.filePanels.length>0?lg():!e.defaultPrevented&&!e.isComposing&&r.current?.()}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let i=0;return(0,R.jsx)(R.Fragment,{children:t.drawers.map((e,t)=>{let r=i;e.closing||i++;let a=e.kind===`thread`?(0,R.jsx)(hre,{id:e.id,slug:e.slug,depth:t,widthDepth:r,initiallyOpen:e.routed},e.id):e.kind===`subagent`?(0,R.jsx)(_re,{id:e.id,slug:e.slug,subId:e.subId??``,label:e.label??e.slug,subagentType:e.subagentType,startedAt:e.startedAt,depth:t,widthDepth:r},e.id):e.kind===`shell`?(0,R.jsx)(yre,{id:e.id,slug:e.slug,shellId:e.subId??``,label:e.label??`Background shell`,startedAt:e.startedAt,depth:t,widthDepth:r},e.id):e.kind===`markdown`?(0,R.jsx)(bre,{id:e.id,path:e.path??e.slug,title:e.label??e.slug,depth:t,widthDepth:r},e.id):(0,R.jsx)(xre,{id:e.id,slug:e.slug,depth:t,widthDepth:r,title:(()=>{let t=Cg(n,e.slug);return t?UD(t):e.slug})()},e.id);return(0,R.jsx)(hv,{label:`this drawer`,resetKeys:[e.kind,e.slug,e.subId,e.path],fallback:(n,i)=>(0,R.jsx)(bv,{id:e.id,depth:t,widthDepth:r,error:n,onRetry:i}),children:a},e.id)})})}function i7(e){return(e.tools??[]).some(e=>e.name===`mcp__frizz__done`&&e.status===`completed`)}function Sre(e){let t=xQ(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 Cre(e){let t=new Map,n=[];for(let r=0;r<e.length;r++){let i=Sre(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 a7(e,t,n){return wQ(e.text)?!n.has(t):i7(e)||e.providerError?!0:e.wake===!0}function wre(e){return e.wake===!0}function Tre(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,hiddenBeforeOpen:!1};continue}let o=r===void 0;r||={start:n,end:n,open:-1,close:-1,steps:0,tools:0,resumed:i,waker:-1,hiddenBeforeOpen:!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++,n<t.open&&(t.hiddenBeforeOpen=!0))}return n}function Ere(e){return e.open<0||e.tools<1&&e.steps<1?!1:e.resumed||e.open!==e.close}function Dre(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)}}}var o7=new Map;function s7(){let e=o7.size===0?0:Math.max(...o7.values());e>0?document.documentElement.style.setProperty(`--queue-dock-inset`,`${e}px`):document.documentElement.style.removeProperty(`--queue-dock-inset`)}function Ore(e,t){let n=new ResizeObserver(()=>{o7.set(e,t.getBoundingClientRect().height),s7()});return n.observe(t),()=>{n.disconnect(),o7.delete(e),s7()}}var kre=320;function Are(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 jre(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 c7=0,l7=``;function u7(){c7++===0&&(l7=document.documentElement.style.overflowAnchor,document.documentElement.style.overflowAnchor=`none`)}function d7(){c7>0&&--c7===0&&(document.documentElement.style.overflowAnchor=l7)}function Mre(e){return{...e,tools:[],parts:e.parts?.filter(e=>e.kind!==`tools`)}}function Nre(){let e=ME(),t=nO(FE(e?.threads??[]).filter(rO),gr(zD).queueOrder),n=t.map(e=>e.id).join(`,`),[r,i]=(0,L.useState)(()=>new Set),a=(0,L.useRef)(t);a.current=t;let o=(0,L.useRef)(r);o.current=r;let s=new Set(t.map(e=>e.id)),c=(0,L.useRef)([]),l=(0,L.useRef)([]),u=(0,L.useRef)(new Map),d=(0,L.useRef)(new Set),f=(0,L.useRef)(new Set),p=(0,L.useRef)(new Map),m=(0,L.useRef)(new Map),h=(0,L.useRef)(null),[g,_]=(0,L.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=pW(),b=e=>v(e.id)||fW(e,y[e.id]),x=(0,L.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,L.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=jre(e);h.current=t?{kind:`top`,slug:t}:null}else{let t=Are(e);h.current=t?{kind:`hold`,...t}:null}f.current.add(e),d.current.delete(e),_(e=>e+1)},kre);p.current.set(e,t)}return()=>{n!==void 0&&cancelAnimationFrame(n)}},[n,r,g]),(0,L.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,L.useEffect)(()=>()=>{for(let e of p.current.values())clearTimeout(e);for(let e of m.current.values())clearTimeout(e)},[]),(0,L.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}u7();let n=()=>{let t=Nh(e.slug);t!==null&&Math.abs(Rp()-t)>.5&&window.scrollTo({top:t,left:0,behavior:`auto`})};n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n(),d7()})})},[g]);let S=(0,L.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,L.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,R.jsxs)(`div`,{className:`my-auto w-full min-w-0 flex flex-col py-8`,children:[(0,R.jsx)(Pre,{board:e}),x.length>0&&(0,R.jsx)(`div`,{className:`flex flex-col`,children:x.map((e,t)=>(0,R.jsxs)(L.Fragment,{children:[(0,R.jsx)(Ire,{slug:e.id,leaving:v(e.id),children:(0,R.jsx)(zre,{thread:e,leaving:v(e.id),frozen:b(e),onResolve:S,onUnresolve:C})}),t<x.length-1&&(0,R.jsx)(`hr`,{className:`my-10 border-0 border-t border-border/60`})]},e.id))}),w?(0,R.jsxs)(`div`,{className:`w-full flex flex-col gap-3`,children:[(0,R.jsx)(`h2`,{className:`text-[15px] font-medium text-center`,children:`What should the agent do?`}),(0,R.jsx)(oW,{}),(0,R.jsx)(kH,{autoFocus:!0})]}):x.length===0?(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2 pt-2`,children:[(0,R.jsx)(A_,{size:40,strokeWidth:1.25,className:`text-muted-30`}),(0,R.jsx)(`div`,{className:`text-[13px] text-muted-80`,children:`No threads awaiting human input`})]}):null]})}function Pre({board:e}){let t=e?.errorItems??[],n=e?.errors??[];return t.length===0&&n.length===0?null:(0,R.jsxs)(`div`,{className:`mb-6 ${KQ} border border-attention-fill/25 bg-attention-fill/[0.06] px-4 py-2.5 text-[12px] text-attention-detail-90`,children:[(0,R.jsx)(`div`,{className:`font-medium mb-0.5`,children:`Board errors`}),t.length>0?t.slice(0,6).map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5`,children:[(0,R.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,R.jsx)(Fre,{file:e.file})]},t)):n.slice(0,3).map((e,t)=>(0,R.jsx)(`div`,{className:`truncate`,title:e,children:e},t))]})}function Fre({file:e}){let t=pt({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,R.jsx)(`button`,{onClick:()=>t.mutate(),disabled:t.isPending,className:`shrink-0 rounded border border-attention/50 bg-attention-fill/10 px-2 py-0.5 text-[11px] font-medium text-attention-soft transition-colors hover:bg-attention-fill/25 disabled:opacity-50`,title:`Prepend minimal frontmatter (title + status: active) so this thread becomes visible again`,children:t.isPending?`Repairing…`:`Repair`})}function Ire({leaving:e,slug:t,children:n}){return(0,R.jsx)(`div`,{"data-queue-card":t,"data-queue-leaving":e,className:`frizz-card-slot min-w-0`,children:(0,R.jsx)(`div`,{className:`frizz-card-clip min-h-0 min-w-0`,children:(0,R.jsx)(`div`,{className:`frizz-card-body min-w-0`,children:n})})})}function Lre({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,R.jsxs)(t1,{icon:a_,marker:`middle-runs-summary`,onClick:n,ariaLabel:`Expand ${i}${r?` and ${r}`:``} of intermediate agent activity`,children:[(0,R.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:i}),r&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,R.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:r})]}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`Click to expand`})]})}function Rre({toolCount:e,onExpand:t}){let n=e>0?`${e} tool call${e===1?``:`s`}`:``;return(0,R.jsxs)(t1,{icon:a_,marker:`intermediate-summary`,onClick:t,ariaLabel:`Expand ${n?`${n} of `:``}intermediate agent activity`,children:[n&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:n}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`})]}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`Click to expand`})]})}var zre=(0,L.memo)(function({thread:e,leaving:t,frozen:n,onResolve:r,onUnresolve:i}){let a=C0(e),o=(0,L.useMemo)(()=>T0(e,a),[e,a]),s=gr(X),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(!1),[m,h]=(0,L.useState)(null),[g,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)(0),b=(0,L.useRef)(null),x=(0,L.useRef)(null),S=(0,L.useRef)(!1),C=(0,L.useRef)(!1),w=(0,L.useRef)(null),T=qe(),E=c8(e.id),D=RE(e.id,{poll:!1}),O=(0,L.useRef)(D.data);n||(O.current=D.data);let k=n?O.current:D.data,A=(0,L.useRef)(null),j=(0,L.useRef)(0),M=(0,L.useRef)(null);(0,L.useEffect)(()=>{let e=M.current,t=A.current;if(!e||!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>t.style.setProperty(`--queue-card-header-h`,`${e.getBoundingClientRect().height}px`));return n.observe(e),()=>n.disconnect()},[]),(0,L.useEffect)(()=>{let t=c?null:A.current?.querySelector(`:scope > [data-thread-composer-box]`);if(!(!t||typeof ResizeObserver>`u`))return Ore(e.id,t)},[c,e.id]),(0,L.useEffect)(()=>{let e=A.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(t=>{if(e.style.height)return;let n=t[0]?.borderBoxSize?.[0];n&&(j.current=n.blockSize)});return t.observe(e),()=>t.disconnect()},[]),(0,L.useLayoutEffect)(()=>{let e=A.current;if(e){if(!t){e.style.height=``,e.style.overflow=``;return}j.current>0&&(e.style.height=`${j.current}px`,e.style.overflow=`clip`)}});let N=(0,L.useMemo)(()=>k?.messages??[],[k]),P=(0,L.useMemo)(()=>H8(N),[N]),F=(0,L.useMemo)(()=>U8(N),[N]),I=e.runtime===`running`||e.runtime===`spawning`,ee=NE(),te=(0,L.useMemo)(()=>y5(F),[F]),ne=I?F.length:te,re=e=>ne>=0&&e<ne,ie=q6(e),ae=e=>[re(e),e===te&&ie],oe=(0,L.useMemo)(()=>j$(F),[F]),se=(0,L.useMemo)(()=>p2(F),[F]),ce=(0,L.useMemo)(()=>{for(let e=F.length-1;e>=0;e--)if(F[e].boundary===`rest`)for(let t=e+1;t<F.length;t++){let n=F[t];if(!(n.queued||n.boundary===`rest`||v5(n,...ae(t))))return e+1}return 0},[F]),le=(0,L.useMemo)(()=>{for(let e=F.length-1;e>=0;e--)if(F[e].role===`user`&&!F[e].queued)return e;return-1},[F]),ue=(0,L.useMemo)(()=>Cre(F),[F]),de=(0,L.useMemo)(()=>F.map((e,t)=>{if(!e||e.queued||v5(e,...ae(t))||e.pinnedFromSourceId)return{skip:!0};if(e.boundary===`rest`)return{skip:!0,closes:!0};let n=L4(e),r=n?0:e.tools.length;return{text:C5(e,...ae(t)),tools:r,countable:C5(e,...ae(t))||r>0||n!==void 0||e.kind!==void 0,survives:a7(e,t,ue),opens:wre(e),completion:e.boundary===`wake`||n!==void 0}}),[F,ue]),fe=(0,L.useMemo)(()=>Tre(de,se+1),[de,se]),{kept:pe,middle:me}=(0,L.useMemo)(()=>Dre(fe),[fe]),he=(0,L.useMemo)(()=>pe.filter(Ere),[pe]),ge=(0,L.useMemo)(()=>{let e=new Map;return he.forEach((t,n)=>{for(let r=t.start;r<=t.end;r++)e.set(r,n)}),e},[he]),_e=!u&&(le>=0||ce>0)&&(he.length>0||me!==void 0),ve=nw(F,m,se),ye=(0,L.useMemo)(()=>F.slice(ve),[F,ve]),be=(0,L.useMemo)(()=>sK(ye).map(e=>({...e,messageIndex:e.messageIndex+ve})),[ye,ve]),xe=(0,L.useMemo)(()=>I?mK(be):be,[be,I]),Se=I?uK(be):void 0,Ce=I?lK(be):void 0,we=Ce?yK(Ce,ee):void 0,Te=I?fK(be):void 0,Ee=(0,L.useMemo)(()=>Y$(q$(F,o),ve),[F,o,ve]),De=(0,L.useMemo)(()=>J$(F,o),[F,o]),Oe=(0,L.useMemo)(()=>{let e=[],t=new Map,n=F.length-1,r=o.filter(e=>!Ee.placedIds.has(e.id));for(let[i,a]of I$(F,r)){if(i>=n){e.push(...a);continue}let r=t.get(i);r?r.push(...a):t.set(i,[...a])}let i=!1,a=new Set;for(let e of X$(F,Ee)){if(e>=n){i=!0;continue}a.add(e),t.has(e)||t.set(e,[])}return{byAnchor:t,tail:e,tailSend:i,sendAnchors:a}},[F,o,Ee]),ke=(0,L.useMemo)(()=>$$(F,a),[F,a]),Ae=Vd(e.spawnedAt),je=(0,L.useMemo)(()=>z$(F,o),[F,o]),Me=(0,L.useMemo)(()=>E$(F,e.answersInFlight),[F,e.answersInFlight]),Ne=ve>0||k?.hasEarlier===!0;(0,L.useLayoutEffect)(()=>{let e=x.current,t=b.current;if(!e||!t||![...t.querySelectorAll(`[data-transcript-source-id]`)].some(t=>t.dataset.transcriptSourceId===e.targetStartId))return;let n=()=>{lw(t,e.anchor,e=>{e!==0&&window.scrollBy({top:e,left:0,behavior:`auto`})});let n=0;return lw(t,e.anchor,e=>{n=e}),n},r=n();if(uw({remaining:r,scrollY:window.scrollY,maxScrollY:Math.max(0,document.documentElement.scrollHeight-window.innerHeight),alreadyReserved:e.reserved===!0})===`reserve`){e.reserved=!0,y(e=>e+Math.ceil(r));return}C.current||(C.current=!0,requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n(),x.current=null,C.current=!1,S.current&&(S.current=!1,d7())})}))},[v,F,m]),(0,L.useEffect)(()=>{let e=k?.transcriptKey;if(!e)return;let t=w.current;w.current=e,!(!t||t===e)&&(h(null),y(0),d(!1),x.current=null,C.current=!1,S.current&&(S.current=!1,d7()))},[k?.transcriptKey]),(0,L.useEffect)(()=>()=>{S.current&&(S.current=!1,d7())},[]);let Pe=e=>{let t=sw(b.current);!e||!t||(S.current||(S.current=!0,u7()),x.current={anchor:t,targetStartId:e})},Fe=async()=>{if(g||!Ne)return;let t=tw(F,ve),n=t!==null&&F[t]?.role===`user`?t:null;if(n!==null){let e=F[n].sourceId;Pe(e),h(e??null);return}let r=k?.beforeCursor;if(!r){if(ve>0){let e=F[0]?.sourceId;Pe(e),h(e??null)}return}let i=k?.transcriptKey;if(i){_(!0);try{let t=await Y.threadTranscriptEarlier({slug:e.id,cursor:r}),n=T.getQueryData([`transcript`,e.id]);if(!n?.transcriptKey||n.transcriptKey!==i||t.transcriptKey!==i){await D.refetch(),h(null),Z(`Transcript changed while loading history; refreshed the current session`);return}let a=t.messages[0]?.sourceId??F[0]?.sourceId;Pe(a);let o=ow(n,t);T.setQueryData([`transcript`,e.id],o),h(a??null)}catch(e){await D.refetch(),h(null),Z(e instanceof Error?e.message:`Could not load earlier transcript history`)}finally{_(!1)}}},Ie=pt({mutationFn:()=>Y.markComplete({slug:e.id})}),{answeringForMessage:Le,answerable:Re,anyAnswered:ze,sendAnswers:Be,sendMessage:Ve}=I1(e.id,F,()=>{document.activeElement?.blur(),r(e.id)},{scrollToBottom:!1,onSendFailed:()=>i(e.id)}),He=(0,L.useMemo)(()=>{let e=P1(F);return e!==-1&&W$(F[e].text,je.get(e)??[])},[F,je]),Ue=Ae&&(Re&&!He||ze),We=(0,L.useCallback)(()=>r(e.id),[r,e.id]),Ge=(0,L.useCallback)(()=>i(e.id),[i,e.id]),Ke=te>=0?F[te]?.text:void 0,Je={thread:e,showWorking:I,registeredDone:WQ(e,Ke),restedCard:l$(e,Ke,De),errorVisible:d$(ye,e.providerError)},Ye=$8(Je),Xe=(0,L.useMemo)(()=>f2(F),[F]),Ze=(0,L.useMemo)(()=>({dismiss:We,cancel:Ge}),[We,Ge]);return(0,R.jsx)(L8.Provider,{value:e.id,children:(0,R.jsx)(B8.Provider,{value:Ze,children:(0,R.jsx)(O0,{thread:e,children:(0,R.jsxs)(`div`,{ref:A,"data-queue-card-root":e.id,"data-queue-leaving":t,style:{...v?{marginBottom:v}:null,...s.vtReturnTarget===e.id?{viewTransitionName:`thread-chat`}:null},onKeyDown:e=>{if(!ze)return;let t=e.target;t instanceof HTMLButtonElement||t instanceof HTMLAnchorElement||t instanceof HTMLTextAreaElement&&t.value.trim()||_z({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(),Be())},"data-vt-chat":!0,className:`flex flex-col min-w-0 max-w-full ${KQ} border border-border-strong bg-panel shadow-lg shadow-shadow-ink/25 transition-opacity ${f?`opacity-40`:``}`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col min-w-0 ${c?``:`mb-[calc(-1*var(--queue-card-header-h,0px))]`}`,children:[(0,R.jsxs)(`div`,{ref:M,className:`sticky top-0 z-10 flex items-center gap-2 bg-panel px-5 py-3.5 max-[800px]:top-10 ${c?KQ:`${qQ} border-b border-border/60`}`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(M4,{thread:e,className:`leading-snug`}),(0,R.jsx)(A4,{thread:e}),e.statusText&&e.status===`needs-human`&&(0,R.jsx)(`div`,{className:`text-[11px] text-muted-80 mt-0.5 truncate`,title:e.statusText,children:e.statusText})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[e.kind===`session`&&e.foreign!==!0&&(0,R.jsx)(l8,{slug:e.id}),(0,R.jsx)(m4,{thread:e,collapsed:c,onCollapse:()=>l(e=>!e),expand:!0,onDone:()=>Ie.mutate(void 0,{onSuccess:()=>r(e.id),onError:()=>p(!1)}),doneBusy:Ie.isPending,onStatusMutate:()=>p(!0),onStatusApplied:()=>r(e.id),onStatusFailed:()=>p(!1)}),(0,R.jsx)(Aq,{thread:e,onArchived:()=>r(e.id),onDismissCancel:()=>i(e.id),onSnoozed:()=>r(e.id)})]})]}),c?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`px-5 pt-5 ${Ue?`pb-2`:`pb-5`}`,children:[D.transportFallback&&(0,R.jsx)(X8,{fallback:D.transportFallback,isFetching:D.isFetching,onRefresh:()=>void D.refetch(),onRetryLive:D.retryLiveUpdates,className:`mb-3.5`}),F.length===0?(0,R.jsx)(`p`,{className:`text-[13px] text-muted`,children:D.isLoading?`Loading…`:e.statusText||`No message yet.`}):(0,R.jsxs)(`div`,{ref:b,className:`flex flex-col`,children:[Ne&&(0,R.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 Fe(),onMouseDown:e=>e.preventDefault(),disabled:g,children:g?`Loading earlier messages…`:k?.reachedTurnBoundary===!1?`Continue loading this turn`:`Load earlier messages`}),(()=>{let t=ve,n=[],r,i=e=>r?_5(r,e):h5(e)?22:14,a=[...Oe.byAnchor.entries()].sort((e,t)=>e[0]-t[0]),o=[...ke.anchored.entries()].filter(([e])=>e>=t).sort((e,t)=>e[0]-t[0]),s=e=>{for(;o.length>0&&o[0][0]<=e;){let[e,t]=o.shift();r!==void 0&&n.push((0,R.jsx)(e1,{h:14},`sq-space-${e}`)),n.push((0,R.jsx)(D0,{questions:t,wrap:!0},`sq-${e}`)),r=null}},c=t=>{for(s(t);a.length>0&&a[0][0]<=t;){let[t,i]=a.shift();r!==void 0&&n.push((0,R.jsx)(e1,{h:14},`qa-space-${t}`)),n.push((0,R.jsx)(A0,{thread:e,questions:i,showSend:Oe.sendAnchors.has(t)},`qa-${t}`)),r=null}};c(t-1);let l=new Set,u=!1;return xe.forEach(({message:t,messageIndex:a},o)=>{if(t.queued||v5(t,...ae(a))||t.boundary===`rest`)return;if(_e&&me&&a>=me.start&&a<=me.end){u||(u=!0,c(a-1),r!==void 0&&n.push((0,R.jsx)(e1,{h:14},`middle-runs-space`)),n.push((0,R.jsx)(Lre,{runs:me.runs,toolCount:me.tools,onExpand:()=>d(!0)},`middle-runs-summary`)),r=null);return}let s=_e?ge.get(a):void 0,f=s===void 0?void 0:he[s],p=f!==void 0,m=f!==void 0&&a===f.open,h=f!==void 0&&a===f.close,g=p&&!m&&!h&&!wQ(t.text)&&!i7(t)&&a7(t,a,ue);if(f!==void 0&&a===f.waker){c(a-1),r!==void 0&&n.push((0,R.jsx)(e1,{h:i(t)},`s${o}`));let e=t.sourceId??`legacy-${a}`;n.push((0,R.jsx)(`div`,{"data-transcript-source-id":e,className:`flex flex-col`,children:(0,R.jsx)(H5,{m:t,dense:!0})},e)),r=t;return}if(p&&!g){if(!m&&!h&&!a7(t,a,ue))return;let u=m&&h,p=()=>{s===void 0||l.has(s)||(r!==void 0&&n.push((0,R.jsx)(e1,{h:14},`im-space-${s}`)),n.push((0,R.jsx)(Rre,{toolCount:f.tools,onExpand:()=>d(!0)},`intermediate-summary-${s}`)),r=null,l.add(s))};if((!m||u&&f.hiddenBeforeOpen)&&p(),!C5(t,...ae(a)))return;c(a-1);let g=Mre(t);r!==void 0&&n.push((0,R.jsx)(e1,{h:i(g)},`s${o}`));let _=t.sourceId??`legacy-${a}`;n.push((0,R.jsx)(`div`,{"data-transcript-source-id":_,className:`flex flex-col`,children:(0,R.jsx)(H5,{m:t,dense:!0,textOnly:!0,answering:Ae?Le(t):void 0,paired:oe[a],staleAwaiting:re(a),restingCardShown:a===te&&ie,shadowedBy:je.get(a),placed:Ee.placed.get(a),settledPlaced:ke.placed.get(a),thread:e})},_)),r=g,u&&p(),c(a);return}c(a-1),r!==void 0&&n.push((0,R.jsx)(e1,{h:i(t)},`s${o}`));let _=t.sourceId??`legacy-${a}`;n.push((0,R.jsx)(`div`,{"data-transcript-source-id":_,className:`flex flex-col`,children:(0,R.jsx)(H5,{m:t,dense:!0,staleAwaiting:re(a),restingCardShown:a===te&&ie,answering:Ae?Le(t):void 0,paired:oe[a],shadowedBy:je.get(a),placed:Ee.placed.get(a),settledPlaced:ke.placed.get(a),thread:e})},_)),r=t,c(a)}),c(1/0),n})()]}),!D.isLoading&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P3,{thread:e,className:`mt-4`}),Ye!==null&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(e1,{h:e5(Je,xe.map(e=>e.message))}),(0,R.jsx)(t5,{state:Je,slug:e.id,retryText:Xe>=0?F[Xe]?.text:void 0,onTerminal:E,liveRuntimeStart:Te,liveActivityLabel:we,liveToolRun:Se,onRestingExit:We,onRestingExitFailed:Ge,wrap:!0})]}),e.permPolicy?(0,R.jsxs)(R.Fragment,{children:[Ye===null&&(0,R.jsx)(e1,{}),(0,R.jsx)(`div`,{className:Ye===null?``:`mt-3`,children:(0,R.jsx)(q5,{policy:e.permPolicy,denies:e.permDenies})})]}):null,ye.map((e,t)=>e.queued?(0,R.jsxs)(L.Fragment,{children:[(0,R.jsx)(e1,{}),(0,R.jsx)(H5,{m:e,dense:!0,paired:oe[ve+t]})]},`q${ve+t}`):null)]})]}),(0,R.jsx)(A0,{thread:e,questions:Oe.tail,inFlight:Me,showSend:Oe.tailSend,className:`shrink-0 px-5 pb-4 pt-0`}),Ue&&(0,R.jsx)(`div`,{className:`shrink-0 px-5 pt-0`,children:(0,R.jsx)(`div`,{className:`mb-4 flex items-center justify-start gap-2`,children:(0,R.jsx)(`button`,{disabled:!ze,onClick:()=>Be(),onMouseDown:e=>e.preventDefault(),className:`button-outline 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`})})})]})]}),c?null:(0,R.jsx)(e4,{slug:e.id,surface:`queueComposer`,className:`sticky bottom-0 z-10 mt-[var(--queue-card-header-h,0px)] shrink-0 ${JQ} border-t border-border/60 bg-panel px-5 pb-3 pt-3 shadow-[0_-12px_18px_-14px_var(--dock-shadow)]`,submitOverride:Ve,above:(0,R.jsx)(a4,{thread:e,transcriptShells:P})})]})})})})},Bre);function Bre(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))}var Vre=[{token:`repo`,gloss:`repository`},{token:`n`,gloss:`number`},{token:`title`,gloss:`title`},{token:`url`,gloss:`link`},{token:`labels`,gloss:`labels`},{token:`body`,gloss:`description`}];function Hre({draft:e,onChange:t,rows:n}){let r=ct({queryKey:[`githubPromptDefaults`],queryFn:()=>Y.githubPromptDefaults()});return r.data?(0,R.jsx)(Wre,{label:`Issue and PR triage prompt`,help:KB.githubPrompt,value:e.githubPrompt,fallback:r.data.prompt,rows:n,onChange:(n,r)=>t({...e,githubPrompt:n},r)}):(0,R.jsx)(`div`,{className:`text-[12px] text-muted`,children:`Loading defaults…`})}function Ure(){let[e,t]=(0,L.useState)(!1),n=(0,L.useRef)(void 0);function r(e){n.current?.(),n.current=void 0,e&&(n.current=fB(()=>r(!1))),t(e)}return(0,R.jsxs)(CV,{open:e,onOpenChange:r,children:[(0,R.jsx)(wV,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] transition-colors ${e?`text-accent`:`text-muted hover:text-accent`}`,children:`Tokens`})}),(0,R.jsxs)(EV,{side:`top`,align:`end`,className:`w-56 p-3`,children:[(0,R.jsx)(`div`,{className:`mb-2 text-[11px] font-medium text-fg`,children:`Substitution tokens`}),(0,R.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:Vre.map(({token:e,gloss:t})=>(0,R.jsxs)(`li`,{className:`flex items-center justify-between gap-3 text-[11px]`,children:[(0,R.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,R.jsx)(`span`,{className:`text-muted-80`,children:t})]},e))})]})]})}function Wre({label:e,help:t,value:n,fallback:r,rows:i=10,onChange:a}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(qB,{label:e,help:t}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[n!=null&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:`text-[11px] text-muted hover:text-accent transition-colors`,onClick:()=>a(void 0),children:`Reset to default`}),(0,R.jsx)(`span`,{"aria-hidden":!0,className:`text-[11px] text-muted-40`,children:`·`})]}),(0,R.jsx)(Ure,{})]})]}),(0,R.jsx)(`textarea`,{"data-1p-ignore":!0,value:n??r,onChange:e=>a(e.target.value===``?void 0:e.target.value,{debounce:!0}),rows:i,className:`input resize-none text-[12px] leading-relaxed font-mono-keep`,spellCheck:!1})]})}function Gre(){let[e,t]=(0,L.useState)(!1);return hB(e,()=>t(!1)),(0,R.jsxs)(CV,{modal:!0,open:e,onOpenChange:t,children:[(0,R.jsx)(wV,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Triage prompt settings`,title:`Edit the prompt every thread this picker starts will run`,onMouseDown:e=>e.preventDefault(),className:`github-prompt-trigger -ml-2 -mr-[5px] inline-flex size-6 shrink-0 self-baseline translate-y-[calc(7.5px_-_0.5cap)] items-center justify-center rounded-md text-muted-70 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:bg-panel-2 focus-visible:text-fg data-[state=open]:bg-panel-2 data-[state=open]:text-fg`,children:(0,R.jsx)(Q_,{"aria-hidden":`true`,size:15})})}),(0,R.jsx)(EV,{side:`bottom`,align:`end`,sideOffset:6,className:`w-[560px] max-w-[calc(100vw-1rem)] p-4`,"data-github-prompt-menu":``,children:(0,R.jsx)(Kre,{})})]})}function Kre(){let{draft:e,update:t,saveState:n}=SB();return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`span`,{className:`text-[12px] font-medium text-fg`,children:`Picker settings`}),(0,R.jsx)(CB,{state:n})]}),e?(0,R.jsx)(Hre,{draft:e,onChange:t,rows:14}):(0,R.jsx)(`div`,{className:`text-[12px] text-muted`,children:`Loading…`})]})}function qre(e,t,n=[]){if(e.backend===`acp`){let t=n.find(t=>t.id===wu(e.model));return t?t.available?void 0:`${t.label} is not installed on this machine`:`ACP agent ${e.model} is not in the catalogue`}if(!e.effort)return`Reasoning level is required for ${e.model}`;if(e.backend===`claude`)return FB.some(t=>t.value===e.model)?VB(e.model).includes(e.effort)?void 0:`Reasoning level ${e.effort} is not available for ${e.model}`:`Claude model ${e.model} is no longer available`;let r=t.find(t=>t.slug===e.model);if(!r)return`Codex model ${e.model} is no longer available`;if(!r.efforts.includes(e.effort))return`Reasoning level ${e.effort} is not available for ${e.model}`}function Jre(e,t){return{items:t.map(e=>({...e})),backend:e.backend,model:e.model,effort:e.effort}}function Yre({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 Xre=/^(?:#)?([0-9a-f]{6})$/i;function Zre(e){let t=Xre.exec(e.trim());return t?`#${t[1].toLowerCase()}`:void 0}function f7(e){let t=Zre(e)??`var(--color-muted)`;return{foreground:`color-mix(in srgb, var(--color-fg) var(--gh-label-fg-mix), ${t})`,background:`color-mix(in srgb, ${t} var(--gh-label-bg-mix), var(--gh-label-bg-base))`,border:`color-mix(in srgb, ${t} var(--gh-label-border-mix), var(--gh-label-border-base))`}}var Qre=30;function $re({onClose:e}){let t=Gz(),{resolved:n,codexList:r,claudeList:i,acpList:a,loadError:o,saveProfile:s}=uH(),c=ut({mutationKey:[...bB]})>0,[l,u]=(0,L.useState)(`issues`),[d,f]=(0,L.useState)(`recent`),[p,m]=(0,L.useState)(1),[h,g]=(0,L.useState)(()=>new Set),[_,v]=(0,L.useState)(null),y=ct({queryKey:[`githubList`,l,d,p],queryFn:()=>Y.githubList({kind:l,sort:d,page:p,perPage:Qre}),placeholderData:ae}),b=y.data?.items??[],x=y.data?.page??p,S=y.data?.pageCount??1,C=y.data?.total??0,w=(0,L.useRef)(null);(0,L.useEffect)(()=>{w.current&&(w.current.scrollTop=0)},[p,l,d]);let T=pt({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 E(e){e!==l&&(u(e),m(1),g(new Set),v(null))}function D(e){e!==d&&(f(e),m(1),g(new Set),v(null))}function O(e,t){let n=Yre({keys:b.map(e=>e.number),key:e,shiftKey:t,anchor:_,selected:h});g(n.selected),v(n.anchor)}function k(){g(new Set),v(null)}let A=h.size,j=(0,L.useMemo)(()=>cH(r,a,i),[r,a,i]),M=n?.acpAgentId?a.find(e=>e.id===n.acpAgentId):void 0,N=n?{backend:n.backend,model:n.model,effort:n.effort||void 0}:void 0,P=N?qre(N,r,a):o?`Could not load the model catalogue — reopen once it loads`:void 0,F=P??(c?`Saving settings…`:N?void 0:`Loading the model catalogue…`);function I(){if(!N||F){Z(F??`Choose a model and reasoning level`);return}T.mutate(Jre(N,[...h].map(e=>({kind:l===`issues`?`issue`:`pr`,number:e}))))}return(0,R.jsx)(NH,{onClose:e,children:(0,R.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-shadow-ink/50`,onKeyDownCapture:t=>{t.key===`Escape`&&(t.stopPropagation(),e())},children:[(0,R.jsxs)(`h2`,{className:`mb-4 flex items-baseline gap-2 text-[14px] font-medium`,children:[(0,R.jsx)(E_,{size:15,"aria-hidden":`true`,className:`shrink-0 self-baseline translate-y-[calc(7.5px_-_0.5cap)] text-muted`}),(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:`Investigate this issue and make recommendations`}),(0,R.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-baseline gap-2`,children:[t.data?.nameWithOwner&&(0,R.jsx)(eie,{nameWithOwner:t.data.nameWithOwner}),(0,R.jsx)(Gre,{})]})]}),(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,R.jsx)(m7,{value:l,onChange:e=>E(e),options:[{value:`issues`,label:`Issues`},{value:`prs`,label:`PRs`}]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`petite-caps text-[11px] text-muted-70`,children:`Sort`}),(0,R.jsx)(m7,{value:d,onChange:D,options:[{value:`recent`,label:`Recent`},{value:`reactions`,label:`Reactions`}]})]})]}),(0,R.jsx)(`div`,{ref:w,className:`min-h-[240px] flex-1 overflow-y-auto rounded-lg border border-border/70 bg-bg/40 transition-opacity ${y.isPlaceholderData?`opacity-40`:``}`,children:y.isLoading?(0,R.jsx)(sie,{}):y.isError?(0,R.jsxs)(_7,{children:[(0,R.jsxs)(`span`,{className:`text-[12.5px] text-muted-80`,children:[`Couldn't load `,l===`issues`?`issues`:`pull requests`,`.`]}),(0,R.jsx)(`span`,{className:`max-w-[80%] text-center text-[11px] text-muted-45`,children:y.error.message.slice(0,140)})]}):b.length===0?(0,R.jsxs)(_7,{children:[(0,R.jsx)(A_,{size:28,strokeWidth:1.25,className:`text-muted-30`}),(0,R.jsxs)(`span`,{className:`text-[12.5px] text-muted-60`,children:[`No open `,l===`issues`?`issues`:`pull requests`]})]}):b.map(e=>(0,R.jsx)(rie,{item:e,checked:h.has(e.number),onActivate:t=>O(e.number,t)},e.number))}),!y.isLoading&&!y.isError&&(0,R.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between gap-3 whitespace-nowrap text-[11.5px] text-muted-60`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.jsxs)(`span`,{className:`truncate tabular-nums`,children:[C,` open `,l===`issues`?C===1?`issue`:`issues`:C===1?`pull request`:`pull requests`]}),A>0&&(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`text-muted-30`,children:`·`}),(0,R.jsxs)(`span`,{className:`tabular-nums text-fg/70`,children:[A,` selected`]}),(0,R.jsx)(`button`,{onClick:k,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`})]})]}),S>1&&(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,R.jsx)(p7,{label:`Previous page`,disabled:x<=1,onClick:()=>m(Math.max(1,x-1)),children:(0,R.jsx)(n_,{size:14})}),(0,R.jsxs)(`span`,{className:`relative px-2 text-center tabular-nums`,children:[(0,R.jsxs)(`span`,{"aria-hidden":!0,className:`invisible`,children:[`Page `,S,` of `,S]}),(0,R.jsxs)(`span`,{className:`absolute inset-0`,children:[`Page `,x,` of `,S]})]}),(0,R.jsx)(p7,{label:`Next page`,disabled:x>=S,onClick:()=>m(Math.min(S,x+1)),children:(0,R.jsx)(r_,{size:14})})]})]}),(0,R.jsxs)(`div`,{className:`mt-4 flex items-end justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-0.5`,children:[(0,R.jsx)(YV,{groups:j,agentSettings:!0,value:n?{provider:n.backend,model:n.pickerModel,effort:n.effort}:void 0,onValueChange:e=>s({field:`profile`,backend:e.provider,model:e.model,effort:e.effort}),placeholder:o?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort`,title:F??`Model and reasoning effort for every thread this batch starts`,disabled:!n,side:`top`,menuZClass:MP,className:`max-w-[min(21rem,60vw)]`}),M&&(0,R.jsx)($V,{agentId:M.id,agentLabel:M.label,modelId:n?.acpModelId,onValueChange:e=>s({field:`model`,backend:`acp`,value:Su(M.id,e)}),side:`top`,menuZClass:`z-[250]`,className:`max-w-[min(14rem,30vw)] px-2 py-1`})]}),P&&(0,R.jsx)(`p`,{className:`mt-1 max-w-[430px] text-[10.5px] text-danger`,children:P})]}),(0,R.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,R.jsxs)(`button`,{disabled:A===0||T.isPending||!!F,onClick:I,onMouseDown:e=>e.preventDefault(),className:`button-outline 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:[T.isPending&&(0,R.jsx)(M_,{size:13,className:`animate-spin`}),A<=1?`Start investigation`:`Start ${A} investigations`]})})]})]})})}function eie({nameWithOwner:e}){return(0,R.jsxs)(`a`,{href:`https://github.com/${e}`,target:`_blank`,rel:`noreferrer noopener`,title:`Open ${e} on GitHub`,className:`github-repo-link inline-flex min-w-0 items-baseline gap-1 rounded-sm font-mono-keep text-[12.5px] font-normal text-muted outline-none transition-colors hover:text-fg focus-visible:text-fg`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e}),(0,R.jsx)(pee,{"aria-hidden":`true`,className:`-ml-[0.29em] size-[1em] shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`})]})}function p7({label:e,disabled:t,onClick:n,children:r}){return(0,R.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 m7({value:e,onChange:t,options:n}){return(0,R.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,R.jsx)(`button`,{onClick:()=>t(n.value),"aria-pressed":e===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-shadow-ink/20`:`text-muted hover:text-fg`}`,children:n.label},n.value))})}function tie({item:e}){let t=(e.state??`OPEN`).toUpperCase();return e.kind===`pr`?t===`MERGED`?(0,R.jsx)(S_,{size:15,className:`shrink-0`,style:{color:QO.fgDone}}):t===`CLOSED`?(0,R.jsx)(C_,{size:15,className:`shrink-0`,style:{color:QO.fgDanger}}):e.isDraft?(0,R.jsx)(w_,{size:15,className:`shrink-0`,style:{color:QO.fgNeutral}}):(0,R.jsx)(T_,{size:15,className:`shrink-0`,style:{color:QO.fgSuccess}}):t===`CLOSED`?(0,R.jsx)(s_,{size:15,className:`shrink-0`,style:{color:QO.fgDone}}):(0,R.jsx)(l_,{size:15,className:`shrink-0`,style:{color:QO.fgSuccess}})}function nie({name:e,color:t}){let n=f7(t);return(0,R.jsx)(`span`,{className:`max-w-[130px] shrink-0 truncate rounded-full border px-1.5 py-px text-[9.5px] leading-[13px]`,style:{borderColor:n.border,color:n.foreground,backgroundColor:n.background},title:e,children:e})}function rie({item:e,checked:t,onActivate:n}){let r=OO(e.createdAt)??``,i=[e.author,r?`opened ${r}`:``].filter(Boolean).join(` `);return(0,R.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-hover`,children:[(0,R.jsx)(`span`,{className:`mt-px shrink-0`,children:(0,R.jsx)(iie,{checked:t})}),(0,R.jsx)(`span`,{className:`mt-px`,children:(0,R.jsx)(tie,{item:e})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.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,R.jsx)(nie,{name:e.name,color:e.color},e.name))]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-muted-55`,children:[(0,R.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,R.jsxs)(`span`,{className:`truncate`,children:[`· `,i]}):null]})]}),(0,R.jsxs)(`span`,{className:`mt-px flex shrink-0 items-center gap-2.5 text-[11.5px] text-muted-70`,children:[e.linkedPrs?(0,R.jsx)(oie,{prs:e.linkedPrs}):null,e.comments?(0,R.jsx)(g7,{icon:F_,n:e.comments,label:`comments`}):null,e.reactions?(0,R.jsx)(g7,{emoji:`👍`,n:e.reactions,label:`reactions`}):null]})]})}function iie({checked:e}){return(0,R.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,R.jsx)(e_,{size:11,strokeWidth:3,className:`text-bg`})})}var h7={octicon:`-0.1em`,stroke:`-0.112em`};function aie({size:e=12,className:t}){return(0,R.jsx)(`svg`,{viewBox:`0 0 16 16`,width:e,height:e,fill:`currentColor`,"aria-hidden":!0,className:t,style:{transform:`translateY(${h7.octicon})`},children:(0,R.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 oie({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,R.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,R.jsx)(aie,{size:12}),e.count]})}function g7({icon:e,emoji:t,n,label:r}){return(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 tabular-nums`,title:`${n} ${r}`,children:[t?(0,R.jsx)(`span`,{"aria-hidden":!0,className:`text-[11px] leading-none`,children:t}):e?(0,R.jsx)(`span`,{className:`inline-flex`,style:{transform:`translateY(${h7.stroke})`},children:(0,R.jsx)(e,{size:12,strokeWidth:2})}):null,n]})}function sie(){return(0,R.jsx)(`div`,{className:`animate-pulse`,children:Array.from({length:6}).map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border/40 px-3 py-2.5 last:border-b-0`,children:[(0,R.jsx)(`span`,{className:`h-[15px] w-[15px] shrink-0 rounded-[4px] bg-muted/20`}),(0,R.jsx)(`span`,{className:`h-3 w-8 shrink-0 rounded bg-muted/20`}),(0,R.jsx)(`span`,{className:`h-3 flex-1 rounded bg-muted/15`,style:{maxWidth:`${55+t*7%35}%`}})]},t))})}function _7({children:e}){return(0,R.jsx)(`div`,{className:`flex h-full min-h-[240px] flex-col items-center justify-center gap-1.5`,children:e})}var cie=`/_frizz/control/sign-out`;function v7(e){return e?.remoteSession===!0}function lie(e,t){return t.result===`signed-out`||t.result===`cookie-cleared`?!0:e===401}async function uie(e=fetch){let t=await e(cie,{method:`POST`,headers:{"cache-control":`no-store`},credentials:`same-origin`}),n;try{n=await t.json()}catch{}if(!(n?.protocol===1&&(n.result===`signed-out`||n.result===`cookie-cleared`||n.result===`no-remote-session`))||!n)throw Error(`This Frizz cannot sign a device out from the browser`);return{signedOut:lie(t.status,n),result:n}}function die(e=window.location){e.replace(`/`)}function fie({className:e=``}){let t=RU(),[n,r]=(0,L.useState)(!1),i=pt({mutationFn:async()=>{let e=await uie();if(!e.signedOut)throw Error(`This browser has no remote session to sign out`);return e},onSuccess:()=>die()});if(!v7(t.data))return null;let a=i.error instanceof Error?i.error.message:i.error?String(i.error):null,o=i.isPending||i.isSuccess;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,"data-sign-out-this-device":!0,onClick:()=>r(!0),className:`flex min-h-[52px] w-full items-center border-y border-border px-[18px] text-left text-[15.5px] text-danger outline-none active:bg-danger-fill/10 ${e}`,children:`Sign out this device`}),(0,R.jsx)(Oq,{open:n,onOpenChange:e=>{o||r(e)},title:`Sign out this device?`,className:`w-[390px] max-w-[92vw]`,footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>r(!1),className:`button-outline 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,R.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>i.mutate(),className:`button-outline rounded-md bg-danger-button/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?`Signing out…`:`Sign out`})]}),children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 p-4 text-[12.5px] leading-relaxed text-muted`,children:[(0,R.jsx)(`p`,{children:`This browser will need a new access link to open Frizz again. Your other devices stay signed in.`}),a?(0,R.jsx)(`p`,{className:`text-[11.5px] text-danger`,children:a}):null]})})]})}function pie(){return typeof Notification>`u`?`unsupported`:Notification.permission}function y7({offerUpdate:e=!1}={}){let{draft:t,update:n,saveState:r,flush:i}=SB(),a=Lg(),[o,s]=(0,L.useState)(pie()),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(!1);(0,L.useEffect)(()=>{let e=requestAnimationFrame(()=>l(!0));return()=>cancelAnimationFrame(e)},[]),(0,L.useEffect)(()=>(Ap(f),()=>Ap(null)),[]);function f(){u||(i(),d(!0),l(!1),window.setTimeout(()=>X.showSettings=!1,Ah()?0:210))}async function p(e){if(t){if(e&&typeof Notification<`u`&&Notification.permission==="default"){let e=await Notification.requestPermission();s(e)}n({...t,notifications:e})}}return a?(0,R.jsx)(_ie,{shown:c,onClose:f,saveState:r,notifications:t?t.notifications:null,onNotifications:p,perm:o,offerUpdate:e}):(0,R.jsx)(`div`,{className:`${Dh} z-50 flex justify-end ${c?`opacity-100`:`opacity-0`}`,onMouseDown:e=>e.target===e.currentTarget&&f(),children:(0,R.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,className:`${Oh} w-[560px] max-w-[94vw] ${c?`translate-x-0`:`translate-x-full`}`,children:[(0,R.jsx)(fv,{title:`Settings`,actions:(0,R.jsx)(CB,{state:r}),onClose:f}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-5 flex flex-col gap-6`,children:[(0,R.jsx)(JB,{label:`Appearance`,help:KB.appearance,children:(0,R.jsx)(bie,{})}),t?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(JB,{label:`Project sidebar`,help:KB.projectRail,children:(0,R.jsx)(C7,{value:t.projectRail,onChange:e=>n({...t,projectRail:e})})}),(0,R.jsx)(JB,{label:`Density`,help:KB.density,children:(0,R.jsx)(Sie,{})}),(0,R.jsx)(JB,{label:`Queue order`,help:KB.queueOrder,children:(0,R.jsx)(Cie,{})}),(0,R.jsx)(JB,{label:`Dictation`,help:KB.dictation,children:(0,R.jsx)(xie,{})}),(0,R.jsxs)(JB,{label:`Desktop notifications`,help:KB.notifications,children:[(0,R.jsx)(C7,{value:t.notifications,onChange:p}),t.notifications&&(0,R.jsx)(w7,{perm:o})]}),(0,R.jsx)(JB,{label:`Local file links`,help:KB.localFileOpener,children:(0,R.jsx)(FV,{variant:`bordered`,value:t.localFileOpener??`system`,onValueChange:e=>n({...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,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading server settings…`})]})]})})}var mie={open:{dot:`bg-live`,word:`Connected`},connecting:{dot:`bg-muted`,word:`Connecting…`},closed:{dot:`bg-danger-fill`,word:`Disconnected`}},b7=`flex min-h-[52px] items-center gap-3 border-b border-border/70 px-[18px] text-[15.5px] text-fg`;function x7({label:e,children:t}){return(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h2`,{className:`m-0 px-[18px] pb-1.5 pt-[18px] text-[12.5px] font-semibold leading-[17px] text-muted`,children:e}),(0,R.jsx)(`div`,{className:`border-t border-border/70`,children:t})]})}function S7({label:e,value:t,options:n,onChange:r,data:i}){let a=n.find(e=>e.value===t)?.label??t;return(0,R.jsxs)(`label`,{"data-mobile-setting":i,className:`${b7} relative`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[14px] text-muted`,children:[a,(0,R.jsx)(r_,{size:15,"aria-hidden":!0,className:`-ml-[3px] -mr-[5px]`})]}),(0,R.jsx)(`select`,{"aria-label":e,value:t,onChange:e=>r(e.target.value),className:`absolute inset-0 cursor-pointer appearance-none opacity-0`,children:n.map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function hie(){let e=(0,L.useSyncExternalStore)(A2,O2,O2),t=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}];return(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Theme`,className:`flex shrink-0 rounded-[9px] border border-border-strong`,children:t.map((n,r)=>(0,R.jsx)(`button`,{role:`radio`,"aria-checked":e.preference===n.value,onClick:()=>k2(n.value),className:`relative h-[30px] px-[11px] text-[13px] after:absolute after:inset-x-0 after:-inset-y-[7px] after:content-[''] ${r>0?`border-l border-border-strong`:``} ${r===0?`rounded-l-[8px]`:``} ${r===t.length-1?`rounded-r-[8px]`:``} ${e.preference===n.value?`bg-fg text-bg`:`text-muted`}`,children:n.label},n.value))})}function gie({checked:e,disabled:t,label:n,onChange:r}){return(0,R.jsx)(`button`,{role:`switch`,"aria-checked":e,"aria-label":n,disabled:t,onClick:()=>r(!e),className:`relative h-6 w-10 shrink-0 rounded-full after:absolute after:-inset-x-2 after:-inset-y-[10px] after:content-[''] disabled:opacity-45 ${e?`bg-fg`:`bg-border-strong`}`,children:(0,R.jsx)(`span`,{className:`absolute top-[3px] size-[18px] rounded-full ${e?`right-[3px] bg-bg`:`left-[3px] bg-muted`}`})})}function _ie({shown:e,onClose:t,saveState:n,notifications:r,onNotifications:i,perm:a,offerUpdate:o}){let{connection:s}=gr(X),{queueOrder:c,snoozePreset:l}=gr(zD),u=mie[s],d=RU(),f=d.data?.version;return(0,R.jsxs)(`div`,{"data-mobile-settings-page":!0,role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,className:`fixed inset-0 z-50 flex flex-col bg-bg pt-[env(safe-area-inset-top)] transition-transform duration-200 ease-out motion-reduce:transition-none ${e?`translate-x-0`:`translate-x-full`}`,children:[(0,R.jsxs)(`header`,{className:`flex h-[56px] shrink-0 items-center gap-0.5 border-b border-border/70 pl-0.5 pr-[18px]`,children:[(0,R.jsx)(`button`,{"aria-label":`Back`,onClick:t,className:`flex size-[44px] shrink-0 items-center justify-center rounded-full text-fg/85 active:bg-hover-strong`,children:(0,R.jsx)(Yg,{size:21,strokeWidth:2.1})}),(0,R.jsx)(`h1`,{className:`m-0 min-w-0 flex-1 truncate pl-0.5 text-[16.5px] font-semibold tracking-[-0.01em] text-fg`,children:`Settings`}),(0,R.jsx)(CB,{state:n})]}),(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-[env(safe-area-inset-bottom)]`,children:[(0,R.jsxs)(`div`,{"data-mobile-connection":!0,className:`flex items-center gap-2 px-[18px] pb-1 pt-[14px] text-[14px] leading-[20px] text-fg`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`size-2 shrink-0 rounded-full ${u.dot}`}),(0,R.jsxs)(`span`,{className:`min-w-0 truncate`,children:[u.word,s===`open`?` · ${location.host}`:null]})]}),(0,R.jsx)(`div`,{className:`px-[18px] pb-1 pt-2.5`,children:(0,R.jsx)(aU,{})}),(0,R.jsx)(x7,{label:`Appearance`,children:(0,R.jsxs)(`div`,{className:b7,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Theme`}),(0,R.jsx)(hie,{})]})}),(0,R.jsxs)(x7,{label:`Queue`,children:[(0,R.jsx)(S7,{data:`queue-order`,label:`Order`,value:c,options:[{value:`fifo`,label:`Oldest first`},{value:`lifo`,label:`Newest first`}],onChange:e=>zD.queueOrder=e}),(0,R.jsx)(S7,{data:`snooze-length`,label:`Snooze length`,value:l,options:SD.map(e=>({value:e.value,label:e.kind===`calendar`?`Until ${e.label}, ${e.detail}`:e.label})),onChange:e=>{wD(e)&&(zD.snoozePreset=e)}}),(0,R.jsxs)(`div`,{className:b7,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Notifications`}),(0,R.jsx)(gie,{label:`Notifications`,checked:r===!0,disabled:r===null,onChange:i})]}),r?(0,R.jsx)(`div`,{className:`border-b border-border/70 px-[18px] py-2.5`,children:(0,R.jsx)(w7,{perm:a})}):null]}),v7(d.data)?(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h2`,{className:`m-0 px-[18px] pb-1.5 pt-[18px] text-[12.5px] font-semibold leading-[17px] text-muted`,children:`This device`}),(0,R.jsx)(fie,{})]}):null,o?(0,R.jsx)(vie,{}):null,f?(0,R.jsxs)(`div`,{"data-mobile-version":!0,className:`px-[18px] py-[14px] text-[12.5px] text-faint`,children:[`Frizz `,f]}):null]})]})}function vie(){let e=nW();if(!e.visible)return null;let t=e.busy?e.update?`Updating…`:`Restarting…`:e.current?`Frizz is up to date`:e.update?`Update Frizz`:`Restart Frizz`,n=e.update?e.updateVersion:void 0;return(0,R.jsxs)(`div`,{"data-mobile-update":!0,children:[(0,R.jsx)(x7,{label:`Version`,children:(0,R.jsxs)(`button`,{type:`button`,"data-mobile-update-row":!0,disabled:e.busy||e.current,"aria-busy":e.busy||void 0,onClick:()=>void e.run(),className:`${b7} w-full text-left active:bg-hover disabled:text-muted`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:t}),n&&!e.busy?(0,R.jsx)(`span`,{"data-mobile-update-row-notification":!0,"aria-hidden":!0,className:yie}):null]}),n&&e.version?(0,R.jsxs)(`span`,{"data-mobile-update-step":!0,className:`shrink-0 text-[14px] tabular-nums text-muted`,children:[e.version,` → `,n]}):null]})}),e.shownError?(0,R.jsx)(eW,{mobile:!0,update:e.update,message:e.shownError,outcome:e.outcome,onDismiss:e.dismiss}):null]})}var yie=`size-[5px] shrink-0 self-baseline translate-y-[calc(2.5px_-_0.5cap)] rounded-full bg-accent`;function bie(){return(0,R.jsx)(FV,{variant:`bordered`,value:(0,L.useSyncExternalStore)(A2,O2,O2).preference,onValueChange:e=>k2(e),options:[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}],indicatorPosition:`right`,ariaLabel:`Appearance`})}function C7({value:e,onChange:t}){return(0,R.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,R.jsx)(`button`,{onClick:()=>t(n.v),"aria-pressed":e===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 xie(){let{dictation:e}=gr(zD);return(0,R.jsx)(C7,{value:e,onChange:e=>zD.dictation=e})}function Sie(){let{compactDiffs:e}=gr(zD);return(0,R.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,R.jsx)(`button`,{onClick:()=>zD.compactDiffs=t.v,"aria-pressed":e===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 Cie(){let{queueOrder:e}=gr(zD);return(0,R.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,R.jsx)(`button`,{onClick:()=>zD.queueOrder=t.v,"aria-pressed":e===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 w7({perm:e}){return e===`denied`?(0,R.jsx)(Tie,{}):(0,R.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 wie(){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 Tie(){let e=(0,L.useMemo)(wie,[]),t=typeof location<`u`?location.origin:``,n=`${e===`edge`?`edge`:`chrome`}://settings/content/siteDetails?site=${encodeURIComponent(t)}`;return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 text-[11px] text-muted-70`,children:[(0,R.jsx)(`span`,{children:`Notifications are blocked for this site. Re-enable them in your browser, then reload.`}),e===`chrome`||e===`edge`?(0,R.jsx)(Die,{url:n,hint:`Paste this into a new tab, set Notifications → Allow:`}):e===`safari`?(0,R.jsxs)(`span`,{children:[`Safari → Settings → Websites → Notifications → allow `,Eie(t),`, then reload.`]}):e===`firefox`?(0,R.jsx)(`span`,{children:`Firefox → Settings → Privacy & Security → Permissions → Notifications → Settings → allow this site.`}):(0,R.jsx)(`span`,{children:`Open this site's notification permission in your browser's settings and set it to Allow.`})]})}function Eie(e){try{return new URL(e).host}catch{return e}}function Die({url:e,hint:t}){let[n,r]=(0,L.useState)(!1);async function i(){try{await eH(e),r(!0),window.setTimeout(()=>r(!1),1500)}catch{}}return(0,R.jsxs)(`span`,{className:`flex w-full flex-col gap-1`,children:[(0,R.jsx)(`span`,{children:t}),(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.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,R.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,R.jsx)(e_,{size:11,className:`text-live`}):(0,R.jsx)(m_,{size:11})})]})]})}var T7=1,Oie=.9,kie=.8,Aie=.17,E7=.1,D7=.999,jie=.9999,Mie=.99,Nie=/[\\\/_+.#"@\[\(\{&]/,Pie=/[\\\/_+.#"@\[\(\{&]/g,Fie=/[\s-]/,O7=/[\s-]/g;function k7(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?T7:Mie;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=k7(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=T7:Nie.test(e.charAt(l-1))?(d*=kie,p=e.slice(i,l-1).match(Pie),p&&i>0&&(d*=D7**+p.length)):Fie.test(e.charAt(l-1))?(d*=Oie,m=e.slice(i,l-1).match(O7),m&&i>0&&(d*=D7**+m.length)):(d*=Aie,i>0&&(d*=D7**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=jie)),(d<E7&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=k7(e,t,n,r,l+1,a+2,o),f*E7>d&&(d=f*E7)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function A7(e){return e.toLowerCase().replace(O7,` `)}function Iie(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,k7(e,t,A7(e),A7(t),0,0,{})}function j7(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function M7(...e){return t=>{let n=!1,r=e.map(e=>{let r=j7(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():j7(e[t],null)}}}}function Lie(...e){return L.useCallback(M7(...e),e)}function Rie(e){let t=L.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];N7(r)&&typeof P7==`function`&&(r=P7(r._payload)),L.Children.forEach(r,e=>{if(Uie(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;N7(n)&&typeof P7==`function`&&(n=P7(n._payload)),a=Bie(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=L.cloneElement(a,void 0,s):!o&&L.Children.count(r)===1&&L.isValidElement(r)&&(a=r);let c=a?Hie(a):void 0,l=Lie(n,c);if(!a){if(r||r===0)throw Error(o?qie(e):Kie(e));return r}let u=Vie(i,a.props??{});return a.type!==L.Fragment&&(u.ref=n?l:c),L.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}var zie=Symbol.for(`radix.slottable`),Bie=(e,t)=>{if(`child`in e.props){let t=e.props.child;return L.isValidElement(t)?L.cloneElement(t,void 0,e.props.children(t.props.children)):null}return L.isValidElement(t)?t:null};function Vie(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 Hie(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 Uie(e){return L.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===zie}var Wie=Symbol.for(`react.lazy`);function N7(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Wie&&`_payload`in e&&Gie(e._payload)}function Gie(e){return typeof e==`object`&&!!e&&`then`in e}var Kie=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,qie=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,P7=L.use,F7=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Rie(`Primitive.${t}`),r=L.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,R.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),Jie=globalThis?.document?L.useLayoutEffect:()=>{},Yie=L.useId||(()=>void 0),Xie=0;function I7(e){let[t,n]=L.useState(Yie());return Jie(()=>{e||n(e=>e??String(Xie++))},[e]),e||(t?`radix-${t}`:``)}var L7=`[cmdk-group=""]`,R7=`[cmdk-group-items=""]`,Zie=`[cmdk-group-heading=""]`,z7=`[cmdk-item=""]`,B7=`${z7}:not([aria-disabled="true"])`,V7=`cmdk-item-select`,H7=`data-value`,Qie=(e,t,n)=>Iie(e,t,n),U7=L.createContext(void 0),W7=()=>L.useContext(U7),G7=L.createContext(void 0),K7=()=>L.useContext(G7),q7=L.createContext(void 0),J7=L.forwardRef((e,t)=>{let n=Q7(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Q7(()=>new Set),i=Q7(()=>new Map),a=Q7(()=>new Map),o=Q7(()=>new Set),s=X7(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=I7(),y=I7(),b=I7(),x=L.useRef(null),S=lae();Z7(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Z7(()=>{S(6,k)},[]);let C=L.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=L.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??Qie;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(R7);t?t.appendChild(e.parentElement===t?e:e.closest(`${R7} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${R7} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${L7}[${H7}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(H7);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(L7)?.querySelector(Zie))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${z7}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(B7)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(H7))}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(H7))}function P(e){let t=A()?.closest(L7),n;for(;t&&!n;)t=e>0?sae(t,L7):cae(t,L7),n=t?.querySelector(B7);n?C.setState(`value`,n.getAttribute(H7)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},ee=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return L.createElement(F7.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&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&ee(e);break;case`ArrowUp`:ee(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(V7);t.dispatchEvent(e)}}}}},L.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:dae},c),t9(e,e=>L.createElement(G7.Provider,{value:C},L.createElement(U7.Provider,{value:w},e))))}),$ie=L.forwardRef((e,t)=>{let n=I7(),r=L.useRef(null),i=L.useContext(q7),a=W7(),o=X7(e),s=o.current?.forceMount??i?.forceMount;Z7(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=e9(n,r,[e.value,e.children,r],e.keywords),l=K7(),u=$7(e=>e.value&&e.value===c.current),d=$7(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);L.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(V7,f),()=>t.removeEventListener(V7,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 L.createElement(F7.div,{ref:M7(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)}),eae=L.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=I7(),s=L.useRef(null),c=L.useRef(null),l=I7(),u=W7(),d=$7(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);Z7(()=>u.group(o),[]),e9(o,s,[e.value,e.heading,c]);let f=L.useMemo(()=>({id:o,forceMount:i}),[i]);return L.createElement(F7.div,{ref:M7(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&L.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),t9(e,e=>L.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},L.createElement(q7.Provider,{value:f},e))))}),tae=L.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=L.useRef(null),a=$7(e=>!e.search);return!n&&!a?null:L.createElement(F7.div,{ref:M7(i,t),...r,"cmdk-separator":``,role:`separator`})}),nae=L.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=K7(),o=$7(e=>e.search),s=$7(e=>e.selectedItemId),c=W7();return L.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),L.createElement(F7.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)}})}),rae=L.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=L.useRef(null),o=L.useRef(null),s=$7(e=>e.selectedItemId),c=W7();return L.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)}}},[]),L.createElement(F7.div,{ref:M7(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},t9(e,e=>L.createElement(`div`,{ref:M7(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),iae=L.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return L.createElement(gR,{open:n,onOpenChange:r},L.createElement(bR,{container:o},L.createElement(SR,{"cmdk-overlay":``,className:i}),L.createElement(ER,{"aria-label":e.label,"cmdk-dialog":``,className:a},L.createElement(J7,{ref:t,...s}))))}),aae=L.forwardRef((e,t)=>$7(e=>e.filtered.count===0)?L.createElement(F7.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),oae=L.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return L.createElement(F7.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},t9(e,e=>L.createElement(`div`,{"aria-hidden":!0},e)))}),Y7=Object.assign(J7,{List:rae,Item:$ie,Input:nae,Group:eae,Separator:tae,Dialog:iae,Empty:aae,Loading:oae});function sae(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function cae(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function X7(e){let t=L.useRef(e);return Z7(()=>{t.current=e}),t}var Z7=typeof window>`u`?L.useEffect:L.useLayoutEffect;function Q7(e){let t=L.useRef();return t.current===void 0&&(t.current=e()),t}function $7(e){let t=K7(),n=()=>e(t.snapshot());return L.useSyncExternalStore(t.subscribe,n,n)}function e9(e,t,n,r=[]){let i=L.useRef(),a=W7();return Z7(()=>{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(H7,s),i.current=s}),i}var lae=()=>{let[e,t]=L.useState(),n=Q7(()=>new Map);return Z7(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function uae(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function t9({asChild:e,children:t},n){return e&&L.isValidElement(t)?L.cloneElement(uae(t),{ref:t.ref},n(t.props.children)):n(t)}var dae={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function fae(){let e=gr(X),t=ME(),[n,r]=(0,L.useState)(``);if((0,L.useEffect)(()=>{e.showPalette&&r(``)},[e.showPalette]),!e.showPalette)return null;let i=eO(FE(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){Xh(e)}return(0,R.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,className:`fixed inset-0 z-[60] flex items-start justify-center bg-scrim-50 pt-[12vh]`,onMouseDown:e=>e.target===e.currentTarget&&s(),children:(0,R.jsxs)(Y7,{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,R.jsx)(Y7.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,R.jsxs)(Y7.List,{className:`max-h-[52vh] overflow-y-auto py-1.5`,children:[(0,R.jsx)(Y7.Empty,{className:`px-4 py-6 text-center text-sm text-muted`,children:`No matches.`}),(0,R.jsxs)(Y7.Group,{heading:`Actions`,className:`cmdk-group`,children:[(0,R.jsx)(n9,{value:`new thread create home`,onSelect:()=>c(()=>Ph()),children:`New thread`}),(0,R.jsx)(n9,{value:`queue todos inbox pending`,onSelect:()=>c(()=>{_g(X.drawers.map(e=>e.id)),X.view=`todos`}),children:`Queue`}),(0,R.jsx)(n9,{value:`open settings preferences`,onSelect:()=>c(()=>X.showSettings=!0),children:`Open settings`}),o&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(n9,{value:`open details drawer doc ${UD(o)}`,onSelect:()=>c(()=>{let e=vg();e&&qh(`doc`,e)}),children:`Open thread details`}),(0,R.jsxs)(n9,{value:`mark complete done ${UD(o)}`,onSelect:()=>c(()=>Y.markComplete({slug:o.id}).catch(()=>{})),children:[`Mark “`,UD(o),`” complete`]}),(0,R.jsxs)(n9,{value:`mark read ${UD(o)}`,onSelect:()=>c(()=>Y.markRead({slug:o.id}).catch(()=>{})),children:[`Mark “`,UD(o),`” read`]})]})]}),i.length>0&&(0,R.jsx)(Y7.Group,{heading:`Threads`,className:`cmdk-group`,children:i.map(e=>(0,R.jsxs)(n9,{value:`${UD(e)} ${e.id}`,onSelect:()=>c(()=>l(e.id)),children:[(0,R.jsx)(`span`,{className:`truncate`,children:UD(e)}),(0,R.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted-70`,children:e.id})]},e.id))})]})]})})}function n9({value:e,onSelect:t,children:n}){return(0,R.jsx)(Y7.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 r9=`Updating and restarting Frizz`,pae=`This may take a moment while the new build is being prepared. All of your threads will continue running normally.`,mae=`Frizz did not come back`;function hae(e){return`${e?`Nothing has answered for ${e}.`:`Nothing is answering.`} Restart Frizz from the terminal with npx frizz (or frizz, if it is installed globally). This page reconnects on its own once the board is back.`}function gae(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 _ae({open:e,message:t,stalled:n=!1,silentFor:r}){let i=(0,L.useRef)(null),[a,o]=(0,L.useState)(!1),s=e&&!n;if((0,L.useEffect)(()=>{n||o(!1)},[n]),(0,L.useEffect)(()=>{if(!s)return;let e=document.activeElement;e instanceof HTMLElement&&e.blur(),i.current?.focus({preventScroll:!0});let t=e=>{gae(e)&&(e.preventDefault(),e.stopImmediatePropagation())};return window.addEventListener(`keydown`,t,{capture:!0}),()=>window.removeEventListener(`keydown`,t,{capture:!0})},[s]),!e)return null;if(n)return a?null:(0,R.jsx)(`div`,{className:`pointer-events-none fixed inset-x-0 top-6 z-[300] flex justify-center px-4`,children:(0,R.jsxs)(`div`,{role:`alert`,className:`pointer-events-auto w-[min(26rem,calc(100vw-2rem))] rounded-2xl border border-danger-fill/45 bg-elevated p-5 text-left shadow-2xl shadow-shadow-ink/60`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,R.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-danger-fill/15 text-danger-soft`,children:(0,R.jsx)(ov,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,R.jsx)(`h2`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:mae}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,onClick:()=>o(!0),className:`icon-hover-outline -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,R.jsx)(cv,{"aria-hidden":`true`,size:14,strokeWidth:2.25})})]}),(0,R.jsx)(`p`,{"aria-live":`polite`,className:`mt-2.5 text-[12px] leading-relaxed text-muted`,children:hae(r)})]})});let c=t?.trim()?t.trim():null;return(0,R.jsx)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":r9,className:`fixed inset-0 z-[300] flex items-center justify-center bg-scrim-55 px-4 backdrop-blur-md backdrop-saturate-150`,children:(0,R.jsxs)(`div`,{ref:i,tabIndex:-1,className:`w-[min(26rem,calc(100vw-2rem))] rounded-2xl border border-border-strong bg-elevated p-6 text-center shadow-2xl shadow-shadow-ink/60 outline-none`,children:[(0,R.jsx)(`span`,{className:`mx-auto flex h-11 w-11 items-center justify-center rounded-full bg-fg/10 text-fg`,children:(0,R.jsx)(J_,{size:20,strokeWidth:2.25,className:`animate-spin`,"aria-hidden":`true`})}),(0,R.jsx)(`h2`,{className:`mt-4 text-[15px] font-semibold tracking-[-0.01em] text-fg`,children:r9}),(0,R.jsx)(`p`,{className:`mt-2 text-[12.5px] leading-relaxed text-muted`,children:pae}),c&&(0,R.jsx)(`p`,{"aria-live":`polite`,className:`mt-2 text-[11.5px] leading-relaxed text-muted-80`,children:c})]})})}var i9=!1;function vae(){i9||(i9=!0,Z("Sign in to the GitHub CLI (`gh auth login`) to dispatch from issues/PRs.",{duration:6e3}))}function yae(){let e=gr(X),t=(0,L.useRef)({projectDir:null,hasBeenVisible:!1});(0,L.useEffect)(()=>{Y.board().then(xg).catch(()=>{})},[]);let n=Ax();(0,L.useEffect)(()=>YE((e,t)=>n(e,t)),[n]);let{data:r,dataUpdatedAt:i}=RU(),a=(0,L.useRef)(null),[o,s]=(0,L.useState)(bU),c=(0,L.useRef)(null),l=(0,L.useRef)(!1);(0,L.useEffect)(()=>{let e=r;if(e){let t=CU({state:X.controlPlaneState,message:X.controlPlaneMessage,attempt:X.controlPlaneRestartAttempt},e);X.controlPlaneState=t.state,X.controlPlaneMessage=t.message,X.controlPlaneRestartAttempt=t.attempt,c.current===null&&(c.current=_U(e))}if(s(t=>xU(t,{restarting:X.controlPlaneState===`restarting`,answered:e!=null,at:Date.now()})),!e||l.current)return;let t=sessionStorage.getItem(pU);if(TU({state:X.controlPlaneState,message:X.controlPlaneMessage,attempt:X.controlPlaneRestartAttempt},e)){if(t){sessionStorage.removeItem(pU),sessionStorage.removeItem(mU),l.current=!0,window.location.replace(t);return}if(vU(c.current,e)){l.current=!0,window.location.reload();return}}if(e.state===`failed`&&t){let t=sessionStorage.getItem(`frizz:update-restart-from-version`)??void 0;sessionStorage.removeItem(pU),sessionStorage.removeItem(mU),a.current!==e.message&&(a.current=e.message??`Update & Restart failed`,Z(`Update & Restart failed — ${gU(hU(t,e)).summary}`,{duration:7e3}))}},[r,i]);let u=e.drawers.length>0||e.showSettings||e.showNewThread||e.showGithubPicker||e.showPalette;(0,L.useEffect)(()=>{if(!u)return;let e=window.scrollY,t=document.body;return Hp(),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,Hp()??e)}},[u]);let d=ct({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()});(0,L.useEffect)(()=>{X.notificationsEnabled=d.data?.notifications??!1},[d.data?.notifications]);let f=Gz();(0,L.useEffect)(()=>{f.data?.inRepo&&!f.data.authed&&vae()},[f.data?.inRepo,f.data?.authed]),(0,L.useEffect)(()=>{function e(e){if(!(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=mg(),n=vg();t?.kind===`doc`?(e.preventDefault(),Fp(t.id)||X.drawers.pop()):n&&(e.preventDefault(),qh(`doc`,n))}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let p=ME(),m=Lg();(0,L.useEffect)(()=>{Zh()},[p,e.routeThreadSlug]),t.current=XE(t.current,p);let h=p!==null&&t.current.hasBeenVisible,g=p===null&&QE(tm()),_=t.current.hasBeenVisible;(0,L.useEffect)(()=>{p!==null&&ute(tm(),_)},[p,_]);let v=p?.projectLabel??p?.projectName;return(0,L.useEffect)(()=>{let e=window.matchMedia?.(`(display-mode: standalone)`).matches;document.title=e?v??`Frizz`:v?`${v} — Frizz`:`Frizz`},[v]),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(_ae,{open:e.controlPlaneState===`restarting`,message:e.controlPlaneMessage,stalled:o.stalled,silentFor:o.silentSince===null?void 0:KO(o.silentForMs)}),(0,R.jsxs)(`div`,{inert:e.controlPlaneState===`restarting`&&!o.stalled,className:`relative min-h-screen bg-bg text-fg text-sm`,children:[m?(0,R.jsx)(sJ,{}):(0,R.jsx)(R.Fragment,{children:(0,R.jsxs)(`div`,{className:`flex min-h-screen justify-center gap-[clamp(28px,3.4vw,52px)] px-5 max-[800px]:flex-col max-[800px]:justify-start max-[800px]:gap-0 max-[800px]:px-3`,children:[h&&(0,R.jsx)(hv,{label:`the sidebar`,children:(0,R.jsx)(aG,{})}),g&&(0,R.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,R.jsx)(`main`,{id:`workpane`,className:`w-[720px] max-w-[62vw] min-w-0 flex flex-col py-5 max-[800px]:w-full max-[800px]:max-w-none ${e.view===`todos`||!p?`min-h-screen`:``} ${e.view===`todos`?``:`rounded-lg border border-border bg-panel`}`,children:p?(0,R.jsxs)(hv,{label:`the queue`,resetKeys:[e.view],children:[e.view.startsWith(`status:`)&&(0,R.jsx)(RK,{status:e.view.slice(7)}),e.view===`todos`&&(0,R.jsx)(Nre,{})]}):(0,R.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,R.jsx)(`span`,{className:`block h-5 w-5 rounded-full border-2 border-muted/50 border-t-transparent animate-spin`})})})]})}),(0,R.jsx)(r7,{}),e.showSettings&&(0,R.jsx)(y7,{offerUpdate:!0}),e.showNewThread&&(0,R.jsx)(MH,{onClose:()=>{X.showNewThread=!1}}),e.showGithubPicker&&(0,R.jsx)($re,{onClose:Ih}),(0,R.jsx)(fae,{})]})]})}function a9(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 bae(e,t,n,r=48){let i=Math.round(t/r);return Math.max(0,Math.min(n-1,e+i))}function xae(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 o9(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 Sae=`w-[57px]`,Cae=`max-[800px]:pl-0 pl-[57px]`;function wae(e){let t=0;for(let n=0;n<e.length;n++)t=(t*31+e.charCodeAt(n))%360;return t}function Tae(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 Eae(e){let t=e.iconVersion?`&v=${encodeURIComponent(e.iconVersion)}`:``;return`/_frizz/project-icon?id=${encodeURIComponent(e.id)}${t}`}function s9({project:e,size:t}){let[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(!1),o=wae(e.id),s=e.iconStatus!==`none`,[c,l]=(0,L.useState)(!1),u=!s||c;return(0,R.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,R.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,R.jsx)(`span`,{style:{textBox:`trim-both cap alphabetic`},children:Tae(e.name)})}),s&&!c&&(0,R.jsx)(`img`,{src:Eae(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 Dae=40;function c9(e,t){let n=[];return t&&n.push(`${t} running`),e&&n.push(`${e} in the queue`),n.join(`, `)}var Oae=`shadow-[0_0_0_0.5px_var(--color-bg)]`;function kae(e){return e<10?`w-[16px]`:e<100?`w-[22px]`:`w-[28px]`}function Aae(){return(0,R.jsx)(`span`,{"aria-hidden":!0,className:`frizz-rail-badge-ring absolute -inset-[2px] scale-[0.975] rounded-full text-accent-fill`})}function jae({project:e,current:t,counts:n,index:r,drag:i,onPointerDown:a,onKeyDown:o}){let s=i?.fromIndex===r,c=n?.queued??0,l=n?.running??0,u=c+l,d=i?s?i.deltaY:xae(r,i.fromIndex,i.toIndex):0;return(0,R.jsx)(IP,{side:`right`,disabled:i!==null,label:e.stale?`${e.name} — directory is missing`:u?`${e.name} — ${c9(c,l)}`:e.name,children:(0,R.jsxs)(iC,{to:nm(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||Pae())&&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:d?`translateY(${d}px)`:void 0,transition:s?`none`:`transform 160ms ease`},children:[(0,R.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,R.jsx)(`span`,{className:`rounded-[30%] transition-[transform,opacity,box-shadow] duration-150 group-focus-visible:ring-1 group-focus-visible:ring-focus-ink-60 ${s?`scale-[1.12] opacity-100 shadow-lg shadow-shadow-ink/50`:`group-hover:scale-[1.06] ${t?``:`opacity-75 group-hover:opacity-100`}`} ${e.stale?`grayscale`:``}`,children:(0,R.jsx)(s9,{project:e,size:Dae})}),u?(0,R.jsxs)(`span`,{"aria-label":c9(c,l),"data-rail-count":u,"data-rail-running":l||void 0,className:`pointer-events-none absolute -bottom-[5px] right-[3px] flex`,children:[l?(0,R.jsx)(Aae,{}):null,(0,R.jsx)(`span`,{className:`relative flex h-[16px] ${kae(u)} items-center justify-center rounded-full border border-bg bg-accent-fill text-[10px] font-semibold leading-none proportional-nums text-on-accent ${l?Oae:``}`,children:(0,R.jsx)(`span`,{style:{textBox:`trim-both cap alphabetic`},children:u})})]}):null]})})}function Mae({project:e,children:t}){let n=(0,L.useRef)(null),r=qe(),i=()=>r.invalidateQueries({queryKey:[`projectsList`]}),a=e=>Z(e instanceof Error?e.message:String(e),{duration:7e3}),o=pt({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=pt({mutationFn:()=>Y.projectIconClear({id:e.id}),onSuccess:()=>void i(),onError:a}),c=pt({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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`input`,{ref:n,type:`file`,accept:Cp.map(e=>`.${e}`).join(`,`),className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&o.mutate(t)}}),(0,R.jsxs)(qL,{onOpenChange:t=>{t&&Y.projectIconPickWarm({id:e.id}).catch(()=>{})},children:[(0,R.jsx)(JL,{asChild:!0,children:t}),(0,R.jsx)(YL,{children:(0,R.jsxs)(XL,{align:`start`,sideOffset:6,className:`z-[220] min-w-[190px] rounded-lg border border-border bg-panel p-1 shadow-xl shadow-shadow-ink/40`,children:[(0,R.jsx)($L,{className:l,onSelect:()=>c.mutate(),children:o.isPending?`Uploading…`:`Choose an icon…`}),(0,R.jsx)($L,{className:l,onSelect:()=>s.mutate(),children:e.iconIsCustom?`Use the detected icon`:`Look for an icon again`})]})})]})]})}var Nae=4,l9=0;function Pae(){return Date.now()-l9<250}function Fae(e,t){let n=ct({queryKey:[`projectsRailCounts`],queryFn:()=>Y.projectsRailCounts(),refetchInterval:5e3}),r=gr(X).board,i=nG(hW(r?FE(r.threads):[])),a=e!==void 0&&r?i:void 0,o=a&&{queued:a.filter(rO).length,running:a.filter(xf).length,asks:a.filter(Cf).length},s=e===void 0?void 0:t.find(t=>t.slug===e)?.id;return e=>e.id===s&&o?o:n.data?.[e.id]}var u9=0;function d9(){let e=Date.now();e-u9<1e4||(u9=e,Y.projectPickWarm({}).catch(()=>{u9=0}))}function Iae(){let e=qe(),{data:t}=ct({queryKey:[`projectsList`],queryFn:()=>Y.projectsList()}),n=tm(),[r,i]=(0,L.useState)(!1),a=Ax(),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),u=(0,L.useRef)(null),d=pt({mutationFn:()=>Y.projectPick({}),onSuccess:t=>{t.kind===`picked`?(e.invalidateQueries({queryKey:[`projectsList`]}),a(nm(t.project.slug))):t.kind===`unavailable`&&a(`/`)},onSettled:()=>i(!1)}),f=pt({mutationFn:e=>Y.projectsReorder({ids:e}),onSuccess:async()=>{await e.invalidateQueries({queryKey:[`projectsList`]}),l(null)},onError:()=>l(null)}),p=c??t??[],m=Fae(n,p),[h,g]=(0,L.useState)(!1);(0,L.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,L.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=o9(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:bae(t,c,i.length),deltaY:c},s(o)},m=0,h=e=>{if(!a){if(Math.abs(e.clientY-r)<Nae)return;a=!0,n.setPointerCapture(e.pointerId)}e.preventDefault();let t=e.clientY;cancelAnimationFrame(c);let i=()=>{d(t),u.current&&o9(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;l9=Date.now();let e=a9(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,L.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=a9(p,t,n);l(r),f.mutate(r.map(e=>e.id)),requestAnimationFrame(()=>{u.current?.querySelectorAll(`a`)[n]?.focus()})},[p,f]);return(0,R.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 ${Sae}`,children:[(0,R.jsx)(IP,{side:`right`,label:`All projects`,children:(0,R.jsx)(iC,{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-focus-ink-60`,children:(0,R.jsx)(O_,{size:17})})}),(0,R.jsx)(`hr`,{className:`my-2.5 w-6 shrink-0 border-0 border-t border-border`}),(0,R.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-2`,children:p.map((e,t)=>(0,R.jsx)(jae,{project:e,index:t,current:e.slug===n,counts:m(e),drag:o,onPointerDown:_,onKeyDown:v},e.id))}),(0,R.jsx)(IP,{side:`right`,label:`Add a project`,children:(0,R.jsx)(`button`,{type:`button`,disabled:r,onPointerEnter:d9,onFocus:d9,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-focus-ink-60 disabled:opacity-50`,children:(0,R.jsx)(q_,{size:16})})})]})}var f9=76;function p9(e,t){return t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}var m9=`flex flex-col gap-1 rounded-lg border px-3 py-2.5 outline-none transition-colors focus-visible:ring-1 focus-visible:ring-focus-ink-60`,h9=34;function Lae({project:e,home:t}){let n=CO(e.lastOpenedAt),[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(!1);return(0,R.jsxs)(`div`,{className:`group/card relative`,children:[(0,R.jsxs)(iC,{to:nm(e.slug),className:`${m9} flex-row items-center gap-3 border-border bg-panel pr-9 group-hover/card:border-border-strong group-hover/card:bg-panel-2 ${e.stale?`opacity-60`:``}`,children:[(0,R.jsx)(`span`,{className:`shrink-0 ${e.stale?`grayscale`:``}`,children:(0,R.jsx)(s9,{project:e,size:h9})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium text-fg`,children:e.name}),e.slug===e.name?null:(0,R.jsxs)(`span`,{className:`max-w-[45%] shrink-0 truncate font-mono text-[11px] text-muted-70`,children:[`/`,e.slug]})]}),(0,R.jsx)(`span`,{className:`truncate text-[11px] text-muted`,title:e.path,children:p9(e.path,t)}),(0,R.jsx)(`span`,{className:`truncate text-[11px] text-muted-70`,children:e.stale?`Directory is missing`:n?`Opened ${n}`:`Never opened`})]})]}),(0,R.jsx)(Mae,{project:e,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Change the icon for ${e.name}`,style:{width:h9,height:h9},className:`icon-hover-outline absolute left-[13px] top-1/2 flex -translate-y-1/2 items-center justify-center rounded-[30%] bg-black/75 text-on-overlay opacity-0 outline-none transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-1 focus-visible:ring-focus-ink-60 data-[state=open]:opacity-100`,children:(0,R.jsx)(k_,{size:16,strokeWidth:1.75})})}),(0,R.jsx)(Rae,{onRename:()=>o(!0),onDelete:()=>i(!0),children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`More actions for ${e.name}`,className:`icon-hover-outline 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-focus-ink-60 group-hover/card:opacity-100 data-[state=open]:opacity-100`,children:(0,R.jsx)(h_,{size:15})})}),a?(0,R.jsx)(Bae,{project:e,home:t,onClose:()=>o(!1)}):null,r?(0,R.jsx)(Vae,{project:e,home:t,onClose:()=>i(!1)}):null]})}function Rae({onRename:e,onDelete:t,children:n}){return(0,R.jsxs)(qL,{children:[(0,R.jsx)(JL,{asChild:!0,children:n}),(0,R.jsx)(YL,{children:(0,R.jsxs)(XL,{align:`end`,sideOffset:6,className:`z-[220] min-w-[170px] rounded-lg border border-border bg-panel p-1 shadow-xl shadow-shadow-ink/40`,children:[(0,R.jsx)($L,{className:`cursor-default rounded px-2 py-1.5 text-[12.5px] text-fg outline-none data-[highlighted]:bg-panel-2`,onSelect:e,children:`Rename…`}),(0,R.jsx)($L,{className:`cursor-default rounded px-2 py-1.5 text-[12.5px] text-danger outline-none data-[highlighted]:bg-danger-fill/10 data-[highlighted]:text-danger-soft`,onSelect:t,children:`Delete project…`})]})})]})}function zae(e){return e.split(/[\\/]/u).filter(Boolean).pop()??e}function Bae({project:e,home:t,onClose:n}){let[r,i]=(0,L.useState)(e.name),[a,o]=(0,L.useState)(!1),s=(0,L.useRef)(null),c=qe(),l=pt({mutationFn:()=>Y.projectRename({id:e.id,name:r.trim(),renameDirectory:a}),onSuccess:t=>{c.invalidateQueries({queryKey:[`projectsList`]}),Z(`Renamed ${e.name} to ${t.name}`),n()}}),u=l.error instanceof Error?l.error.message:l.error?String(l.error):null,d=r.trim(),f=zae(e.path),p=e.path.slice(0,e.path.length-f.length),m=f===e.name&&d.length>0&&d!==f,h=Yc(d);return(0,R.jsx)(Oq,{open:!0,onOpenChange:e=>{!e&&!l.isPending&&n()},title:`Rename ${e.name}`,className:`w-[440px] max-w-[92vw]`,onOpenAutoFocus:e=>{e.preventDefault(),s.current?.focus(),s.current?.select()},footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,onClick:n,disabled:l.isPending,className:`button-outline 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,R.jsxs)(`button`,{type:`submit`,form:`rename-project`,disabled:l.isPending||d.length===0,className:`flex items-center gap-1.5 rounded-md border border-accent-fill bg-accent-fill px-3 py-1.5 text-[12.5px] font-medium text-on-accent outline-none hover:brightness-110 focus-visible:ring-1 focus-visible:ring-focus-accent-60 disabled:opacity-50`,children:[l.isPending&&(0,R.jsx)(M_,{size:12,className:`animate-spin`}),m&&a?`Rename project and folder`:`Rename project`]})]}),children:(0,R.jsxs)(`form`,{id:`rename-project`,onSubmit:e=>{e.preventDefault(),!l.isPending&&d.length>0&&l.mutate()},className:`flex flex-col gap-3 p-4 text-[12.5px] leading-relaxed text-muted`,children:[(0,R.jsx)(`input`,{ref:s,value:r,onChange:e=>i(e.target.value),spellCheck:!1,"aria-label":`Project name`,className:`w-full rounded-md border bg-bg px-2.5 py-2 text-[12.5px] text-fg outline-none placeholder:text-muted-50 focus-visible:ring-1 focus-visible:ring-focus-accent-60 ${u?`border-danger-fill/60`:`border-border-strong`}`}),(0,R.jsxs)(`p`,{children:[`Its address becomes`,` `,(0,R.jsxs)(`span`,{className:`font-mono text-[11.5px] text-fg/80`,children:[`/project/`,h]}),h===e.slug?`.`:(0,R.jsxs)(R.Fragment,{children:[` — links to `,(0,R.jsxs)(`span`,{className:`font-mono text-[11.5px]`,children:[`/project/`,e.slug]}),` stop working.`]})]}),m?(0,R.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,R.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`mt-[3px] accent-[var(--color-accent)]`}),(0,R.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{children:`Also rename the folder`}),(0,R.jsx)(`span`,{className:`text-[11.5px] text-muted-80`,children:a?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-mono text-[11px]`,children:p9(e.path,t)}),` becomes `,(0,R.jsx)(`span`,{className:`font-mono text-[11px]`,children:p9(p+d,t)}),`. Running workers keep going.`]}):`Left off, the folder keeps its name and only what Frizz calls it changes.`})]})]}):null,u?(0,R.jsx)(`p`,{className:`text-[11.5px] text-danger`,children:u}):null]})})}function Vae({project:e,home:t,onClose:n}){let[r,i]=(0,L.useState)(!1),a=qe(),o=pt({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,R.jsx)(Oq,{open:!0,onOpenChange:e=>{!e&&!o.isPending&&n()},title:`Delete ${e.name}?`,className:`w-[440px] max-w-[92vw]`,footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,onClick:n,disabled:o.isPending,className:`button-outline 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,R.jsxs)(`button`,{type:`button`,onClick:()=>o.mutate(),disabled:o.isPending,className:`button-outline flex items-center gap-1.5 rounded-md bg-danger-button/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,R.jsx)(M_,{size:12,className:`animate-spin`}),r?`Delete project and threads`:`Delete project`]})]}),children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 p-4 text-[12.5px] leading-relaxed text-muted`,children:[(0,R.jsxs)(`p`,{children:[`Frizz forgets this project. The folder itself is not touched — nothing inside`,` `,(0,R.jsx)(`span`,{className:`font-mono text-[11.5px] text-fg/80`,children:p9(e.path,t)}),` is changed or removed.`]}),(0,R.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,R.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked),className:`mt-[3px] accent-[var(--color-accent)]`}),(0,R.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{children:`Also delete its threads and history`}),(0,R.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,R.jsx)(`p`,{className:`text-[11.5px] text-danger`,children:s}):null]})})}function Hae({hero:e,pending:t,onClick:n}){return(0,R.jsxs)(`button`,{type:`button`,onPointerEnter:d9,onFocus:d9,onClick:n,disabled:t,className:`${m9} items-center justify-center gap-1.5 border-dashed border-border-strong bg-transparent text-muted hover:border-accent hover:text-fg ${e?`min-h-[118px]`:`min-h-[74px]`}`,children:[(0,R.jsx)(`span`,{className:`text-[17px] leading-none text-muted-70`,children:`+`}),(0,R.jsx)(`span`,{className:`text-[12.5px]`,children:t?`Choosing a folder…`:`Add a project`}),e?(0,R.jsx)(`span`,{className:`text-[11px] text-muted-70`,children:`Point Frizz at a folder on this machine`}):null]})}function g9({reason:e,proposed:t,onClose:n}){let[r,i]=(0,L.useState)(t??``),a=Ax(),o=qe(),s=pt({mutationFn:e=>Y.projectAdd({path:e}),onSuccess:e=>{o.invalidateQueries({queryKey:[`projectsList`]}),a(nm(e.slug))}}),c=s.error instanceof Error?s.error.message:s.error?String(s.error):null;return(0,R.jsx)(gR,{open:!0,onOpenChange:e=>{!e&&!s.isPending&&n()},children:(0,R.jsxs)(bR,{children:[(0,R.jsx)(SR,{className:`fixed inset-0 z-[210] bg-scrim-30 backdrop-blur-md backdrop-saturate-150`}),(0,R.jsxs)(ER,{"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-shadow-ink/50 outline-none`,children:[(0,R.jsx)(jR,{className:`mb-1 text-[14px] font-medium`,children:t?`Add this folder as a project?`:`Add a project`}),(0,R.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,R.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),s.isPending||s.mutate(r)},children:[(0,R.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-focus-ink-60 ${c?`border-danger-fill/60`:`border-border-strong`}`}),c?(0,R.jsx)(`p`,{className:`mt-1.5 text-[11.5px] text-danger`,children:c}):null,(0,R.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,R.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-focus-ink-60 disabled:opacity-50`,children:t?`Not now`:`Cancel`}),(0,R.jsx)(`button`,{type:`submit`,disabled:s.isPending||r.trim().length===0,className:`rounded-md border border-accent bg-accent-fill px-3 py-1.5 text-[12.5px] font-medium text-on-accent outline-none hover:brightness-110 focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:opacity-50`,children:s.isPending?`Adding…`:t?`Add it`:`Add project`})]})]})]})]})})}function Uae({projects:e,home:t}){let{showSettings:n}=gr(X),r=ct({queryKey:[`projectsRailCounts`],queryFn:()=>Y.projectsRailCounts(),refetchInterval:5e3});return(0,R.jsxs)(`div`,{"data-mobile-projects-page":!0,className:`min-h-dvh bg-bg`,children:[(0,R.jsx)(`header`,{className:`sticky top-0 z-10 border-b border-border/70 bg-bg pt-[env(safe-area-inset-top)]`,children:(0,R.jsxs)(`div`,{className:`flex h-[56px] items-center pl-[18px] pr-[5px]`,children:[(0,R.jsx)(`h1`,{className:`m-0 min-w-0 flex-1 truncate text-[16.5px] font-semibold tracking-[-0.01em] text-fg`,children:`Projects`}),(0,R.jsx)(`button`,{"aria-label":`Settings`,"data-mobile-settings":!0,onClick:()=>X.showSettings=!0,className:`flex size-[44px] shrink-0 items-center justify-center rounded-full text-fg/85 active:bg-hover-strong`,children:(0,R.jsx)(Q_,{size:21,strokeWidth:1.9})})]})}),e.length===0?(0,R.jsx)(`p`,{className:`m-0 px-10 pt-24 text-center text-[15px] text-muted`,children:`No projects yet. Add one from Frizz on a computer.`}):(0,R.jsx)(`ul`,{className:`m-0 list-none p-0 pb-[env(safe-area-inset-bottom)]`,children:e.map(e=>{let n=r.data?.[e.id];return(0,R.jsx)(`li`,{children:(0,R.jsxs)(iC,{to:nm(e.slug),"data-mobile-project-row":e.slug,className:`flex min-h-[62px] items-center gap-3 border-b border-border/70 px-[18px] py-2 active:bg-hover ${e.stale?`opacity-60`:``}`,children:[(0,R.jsx)(`span`,{className:`shrink-0 ${e.stale?`grayscale`:``}`,children:(0,R.jsx)(s9,{project:e,size:h9})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(`span`,{className:`truncate text-[15.5px] font-medium leading-[20px] text-fg`,children:e.name}),(0,R.jsx)(`span`,{className:`truncate font-mono-keep text-[12.5px] leading-[17px] text-muted`,title:e.path,children:e.stale?`Directory is missing`:p9(e.path,t)})]}),n&&(n.asks>0||n.running>0)?(0,R.jsxs)(`span`,{"data-mobile-project-counts":!0,className:`flex shrink-0 items-baseline gap-2.5 whitespace-nowrap text-[13px] text-muted`,children:[n.asks>0?(0,R.jsx)(`span`,{className:`font-bold tabular-nums text-accent`,children:n.asks}):null,n.running>0?(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[n.running,` working`]}):null]}):null]})},e.id)})}),n?(0,R.jsx)(y7,{}):null]})}function Wae(){let[e]=(0,L.useState)(()=>{let e=new URLSearchParams(location.search).get(`add`)??void 0;return e&&history.replaceState(null,``,location.pathname),e}),[t,n]=(0,L.useState)(e?{}:null);(0,L.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=Ax(),i=qe(),a=pt({mutationFn:()=>Y.projectPick({}),onSuccess:e=>{if(e.kind!==`cancelled`){if(e.kind===`unavailable`){n({reason:e.reason});return}i.invalidateQueries({queryKey:[`projectsList`]}),r(nm(e.project.slug))}},onError:e=>n({reason:e instanceof Error?e.message:String(e)})}),{data:o,isPending:s,error:c}=ct({queryKey:[`projectsList`],queryFn:()=>Y.projectsList()}),l=o?.[0]?.path.match(/^(\/(?:Users|home)\/[^/]+)\//u)?.[1],u=o!==void 0&&o.length===0;return Lg()&&o?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Uae,{projects:o,home:l}),t?(0,R.jsx)(g9,{reason:t.reason,proposed:e,onClose:()=>n(null)}):null]}):(0,R.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,R.jsxs)(`div`,{className:`m-auto flex w-full flex-col items-center`,children:[(0,R.jsxs)(`div`,{className:`mb-6 flex flex-col items-center gap-2.5 text-center`,children:[(0,R.jsx)(`img`,{src:`/favicon.svg`,width:f9,height:f9,alt:``,className:`rounded-[17px]`}),(0,R.jsx)(`h1`,{className:`text-[19px] font-semibold tracking-[-0.01em] text-fg`,children:u?`Welcome to Frizz`:`Select a project`}),u?(0,R.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,R.jsxs)(`p`,{className:`text-[13px] text-muted`,children:[`Could not read the project registry: `,String(c)]}):s?(0,R.jsx)(`p`,{className:`text-[13px] text-muted`,children:`Loading…`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid w-full gap-2 ${u?`max-w-[360px] grid-cols-1`:`max-w-[900px] grid-cols-[repeat(auto-fill,minmax(272px,1fr))]`}`,children:[o.map(e=>(0,R.jsx)(Lae,{project:e,home:l},e.id)),(0,R.jsx)(Hae,{hero:u,pending:a.isPending,onClick:()=>a.mutate()})]}),u?(0,R.jsxs)(`p`,{className:`mt-6 text-[11.5px] text-muted-70`,children:[`Or run`,` `,(0,R.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,R.jsx)(g9,{reason:t.reason,proposed:e,onClose:()=>n(null)}):null]})}var _9=64,v9=12,y9=_9-v9-4,b9=16,Gae=`#4a9eff`,x9,S9,C9=!1;function Kae(){return x9??=[...document.querySelectorAll(`link[rel~="icon"]`)].map(e=>({link:e,href:e.getAttribute(`href`)??``,type:e.getAttribute(`type`),sizes:e.getAttribute(`sizes`)})),x9}function qae(e){let t=document.createElement(`canvas`);t.width=t.height=_9;let n=t.getContext(`2d`);return n.drawImage(e,0,0,_9,_9),n.globalCompositeOperation=`destination-out`,n.beginPath(),n.arc(y9,b9,16,0,Math.PI*2),n.fill(),n.globalCompositeOperation=`source-over`,n.fillStyle=Gae,n.beginPath(),n.arc(y9,b9,v9,0,Math.PI*2),n.fill(),t.toDataURL(`image/png`)}function Jae(e){return S9??=new Promise((t,n)=>{let r=e.find(e=>e.type===`image/svg+xml`)??e[0];if(!r)return n(Error(`no favicon link`));let i=new Image;i.onload=()=>t(qae(i)),i.onerror=()=>n(Error(`favicon did not load`)),i.src=r.href}),S9}function w9(e){C9=e;let t=Kae();if(!e){for(let{link:e,href:n,type:r,sizes:i}of t)e.href=n,r===null?e.removeAttribute(`type`):e.type=r,i===null?e.removeAttribute(`sizes`):e.setAttribute(`sizes`,i);return}Jae(t).then(e=>{if(C9)for(let{link:n}of t)n.type=`image/png`,n.removeAttribute(`sizes`),n.href=e}).catch(()=>{S9=void 0})}function T9(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 E9(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 Yae({slug:e,path:t,active:n}){let r=KT(t),i=IE(t),a=ct({...XT(t),refetchInterval:i?!1:ZT}),o=a.data?.path??t,s=a.data?.markdown??``,{front:c,body:l}=$5(r?s:``),[u,d]=(0,L.useState)(r?`rendered`:`source`),f=JT(o),p=SX(l,{baseDir:f,asDocument:!0}),m=rZ(p),h=rZ((0,L.useMemo)(()=>u===`source`?eE(o,s):``,[s,o,u])),g=(0,L.useRef)(null),_=(0,L.useRef)(null),v=(0,L.useRef)(null);gZ(g,p);let y=BZ(g,p,f),b=xh(o),x=PE(),S=wH(),C=TH(e);return(0,L.useEffect)(()=>{if(!n)return;let t=()=>document.querySelector(`main[data-standalone-thread] textarea`);function r(e,t){return e?document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0?t.length:Math.min(e.selectionStart??t.length,t.length):t.length}function i(n){if(!(n.metaKey||n.ctrlKey)||n.altKey||n.shiftKey||n.key.toLowerCase()!==`i`)return;let i=v.current,a=window.getSelection(),c=a&&!a.isCollapsed&&a.rangeCount>0?a.getRangeAt(0):null,l=!!(i&&c&&i.contains(c.commonAncestorContainer)),u=l?a.toString():``;if(!l||!u.trim()){n.preventDefault(),n.stopPropagation();let e=t();if(!e)return;document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0&&e.setSelectionRange(e.value.length,e.value.length),e.focus();return}n.preventDefault(),n.stopPropagation();let d=null,f=_.current;if(f&&f.contains(c.commonAncestorContainer)){let e=T9(f,c.startContainer,c.startOffset),t=T9(f,c.endContainer,c.endOffset);e!==null&&t!==null&&(d={startLine:E9(s,Math.min(e,t)),endLine:E9(s,Math.max(0,Math.max(e,t)-1))})}else d=Rte(s,u);let p=t(),m=CH.followUp(S,e,C),{prose:h,attachments:g}=sz(bH.get(m)),y=Ite(lz({path:o,...d??{}}),X.composerContext[e]??[],h),b=Lte(h,r(p,h),y);bH.set(m,cz(b.prose,g.map(e=>e.path))),dg(e,{token:y,path:o,text:u,...d??{}}),a.removeAllRanges(),requestAnimationFrame(()=>{let e=t();e&&(e.setSelectionRange(b.caret,b.caret),e.focus())})}return window.addEventListener(`keydown`,i,!0),()=>window.removeEventListener(`keydown`,i,!0)},[n,e,o,s,S,C]),(0,R.jsxs)(`div`,{ref:v,"data-file-viewer-panel":!0,className:`flex h-full min-h-0 flex-col`,children:[(0,R.jsx)(fv,{title:b,subtitle:Eh(o,x),onClose:lg,actions:r?(0,R.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,R.jsx)(`button`,{type:`button`,onClick:()=>d(e),"aria-pressed":u===e,className:`rounded px-2 py-0.5 transition-colors ${u===e?`bg-panel-2 text-fg`:`text-muted hover:text-fg`}`,children:e===`rendered`?`Rendered`:`Source`},e))}):null}),(0,R.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:[a.isLoading?(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):a.error?(0,R.jsxs)(`div`,{className:`text-[13px] text-danger-90`,children:[`Couldn’t read this file: `,a.error.message]}):u===`source`?s?(0,R.jsx)(`pre`,{ref:_,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:h}):(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):p?(0,R.jsxs)(R.Fragment,{children:[c&&(0,R.jsx)(n7,{source:c}),(0,R.jsx)(`div`,{ref:g,className:`md-body`,dangerouslySetInnerHTML:m}),y]}):(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!a.isLoading&&!a.error&&a.data?.truncated&&(0,R.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,R.jsxs)(`div`,{className:`shrink-0 flex items-center justify-between gap-3 border-t border-border/60 bg-panel px-5 pt-3`,style:e7,children:[(0,R.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,R.jsx)(t7,{path:o})]})]})}function D9(){return{dirs:new Map,files:new Map}}function Xae(e,t,n){let r=e.replace(/[\\/]+$/,``);if(t){let e=Th(t,r);if(e!==null)return hh(e)}if(n){let e=Th(n,r);if(e!==null)return[`~`,...hh(e)]}let i=hh(r);return/^[\\/]/.test(r)?[`/`,...i]:i}var O9=(e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`,numeric:!0});function k9(e,t,n=``){let r=[];for(let i of[...e.dirs.keys()].sort(O9)){let a=e.dirs.get(i),o=i;for(;a.files.size===0&&a.dirs.size===1;){let[e,t]=[...a.dirs.entries()][0];o=o===`/`?`/${e}`:`${o}/${e}`,a=t}let s=n===``||n===`/`?`${n}${o}`:`${n}/${o}`;r.push({kind:`dir`,name:o,path:s,depth:t,children:k9(a,t+1,s)})}for(let n of[...e.files.keys()].sort(O9))r.push({kind:`file`,name:n,depth:t,file:e.files.get(n)});return r}function Zae(e,t,n){let r=D9();for(let i of e){let e=Xae(i.path,t,n);if(e.length===0)continue;let a=r;for(let t of e.slice(0,-1)){let e=a.dirs.get(t);e||(e=D9(),a.dirs.set(t,e)),a=e}a.files.set(e[e.length-1],i)}return k9(r,0)}function Qae(e){let t=[],n=e=>{for(let r of e)t.push(r),r.kind===`dir`&&n(r.children)};return n(e),t}var $ae=/(?:^|[\s;&|(])(?:rm|mv|unlink|git\s+(?:rm|mv|clean|checkout|restore|reset|stash|apply))\b/;function eoe(e){if(e.edit||e.edits?.length)return!0;let t=qG(e.name);return xK.has(t)?!0:t!==`bash`||!e.command?!1:$ae.test(e.command)||ru(e.command).length>0}function toe(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=n.tools??[];for(let e=r.length-1;e>=0;e--)if(eoe(r[e]))return`${n.sourceId??n.at??`#${t}`}:${e}:${r[e].status??``}`}}var A9=10;function noe({name:e,depth:t}){return(0,R.jsxs)(`div`,{"data-file-dir":e,className:`flex items-baseline pr-2 text-[12px] leading-5 text-muted-70`,style:{paddingLeft:8+t*A9},children:[(0,R.jsx)(`span`,{className:`flex shrink-0`,children:(0,R.jsx)(y_,{size:12,className:`${m6} text-muted-45`})}),(0,R.jsx)(`span`,{className:`ml-[5px] min-w-0 truncate`,title:e,children:e})]})}function roe({files:e}){let t=NE(),n=PE();return(0,R.jsx)(`div`,{"data-edited-file-tree":!0,className:`flex flex-col gap-y-px`,children:Qae(Zae(e,t,n)).map(e=>e.kind===`dir`?(0,R.jsx)(noe,{name:e.name,depth:e.depth},`d:${e.path}`):(0,R.jsx)(ioe,{file:e.file,name:e.name,depth:e.depth,homeDir:n},e.file.path))})}function ioe({file:e,name:t,depth:n,homeDir:r}){let i=qe();return(0,R.jsx)(k6,{testKind:`file`,testId:e.path,mark:(0,R.jsx)(__,{size:12,className:`${m6} -mr-[2px] text-muted-60`}),name:t,indent:n*A9,onOpen:()=>YK(e.path),onPrewarm:()=>nE(i,e.path),title:Eh(e.path,r),status:(0,R.jsxs)(R.Fragment,{children:[(e.added??0)>0&&(0,R.jsxs)(`span`,{style:{color:QO.fgSuccess},children:[`+`,e.added]}),(e.added??0)>0&&(e.removed??0)>0&&` `,(e.removed??0)>0&&(0,R.jsxs)(`span`,{style:{color:QO.fgDanger},children:[`−`,e.removed]})]})})}function aoe({link:e}){let t=qe(),n=PE();return e.kind===`link`?(0,R.jsx)(k6,{testKind:`link`,testId:e.id,mark:(0,R.jsx)(g_,{size:12,className:`${m6} text-muted-60`}),name:e.label,href:e.target,title:e.target,status:ooe(e.target)}):(0,R.jsx)(k6,{testKind:`link`,testId:e.id,mark:(0,R.jsx)(v_,{size:12,className:`${m6} text-muted-60`}),name:e.label,onOpen:()=>YK(e.target),onPrewarm:()=>nE(t,e.target),title:Eh(e.target,n),status:null})}function ooe(e){try{return new URL(e).host||e}catch{return e}}var soe=1500;function coe(e,t,n,r){let i=qe(),a=(0,L.useRef)({slug:e,loaded:t,changeKey:n,turnLive:r}),o=(0,L.useRef)(void 0);(0,L.useEffect)(()=>()=>clearTimeout(o.current),[e]),(0,L.useEffect)(()=>{let s=a.current;if(a.current={slug:e,loaded:t,changeKey:n,turnLive:r},s.slug!==e||!s.loaded)return;let c=n!==void 0&&n!==s.changeKey,l=s.turnLive&&!r;!c&&!l||(clearTimeout(o.current),o.current=setTimeout(()=>{i.refetchQueries({queryKey:[`transcript`,e],exact:!0,type:`active`})},soe))},[i,e,t,n,r])}function loe({thread:e}){let t=RO(),n=RE(e.id,{poll:!1}),r=n.data?.editedFiles??[],i=(0,L.useMemo)(()=>toe(n.data?.messages??[]),[n.data?.messages]);coe(e.id,n.data!==void 0,i,e.runtime===`running`||e.runtime===`spawning`);let a=(e.subAgents??[]).filter(Au),o=(0,L.useMemo)(()=>H8(n.data?.messages??[]),[n.data?.messages]),s=bk(e.bgShells??[],o),c=e.state!==`archived`,l=(e.watches??[]).filter(e=>c&&e.kind===`github`&&e.state===`armed`),u=l.filter(e=>e.subject!==`issue`),d=l.filter(e=>e.subject===`issue`),f=(e.watches??[]).filter(e=>c&&e.kind===`timer`&&e.state===`armed`),{railFilesCollapsed:p}=gr(zD),m=[{head:`Sub-agents`,rows:a.map(n=>(0,R.jsx)(V6,{agent:n,slug:e.id,now:t,onDismiss:zP(e.id,n)},n.id??n.label))},{head:`Background shells`,rows:s.map(n=>(0,R.jsx)(R6,{shell:n,slug:e.id,now:t,onDismiss:zP(e.id,n,`SHELL`)},n.id??n.label))},{head:`Pull requests`,rows:u.map(e=>(0,R.jsx)(M6,{watch:e},e.id))},{head:`Issues`,rows:d.map(e=>(0,R.jsx)(M6,{watch:e},e.id))},{head:`Timers`,rows:f.map(e=>(0,R.jsx)(z6,{watch:e,now:t},e.id))},{head:`Files and links`,rows:(e.links??[]).map(e=>(0,R.jsx)(aoe,{link:e},e.id))},{head:`Edited files`,rows:r.length>0?[(0,R.jsx)(roe,{files:r},`tree`)]:[],count:r.length,collapsed:p,onToggle:()=>zD.railFilesCollapsed=!zD.railFilesCollapsed}].filter(e=>e.rows.length>0);return(0,R.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,R.jsx)(`div`,{className:`my-auto py-6`,children:m.length===0?(0,R.jsx)(`div`,{className:`text-[11.5px] text-muted-50`,children:`Nothing running, watched or edited yet.`}):(0,R.jsx)(K6,{groups:m,divider:!1})})})}function j9(){let e=gr(X),t=e.toast,[n,r]=(0,L.useState)(!1),i=e.drawers.some(e=>!e.closing);return(0,L.useEffect)(()=>{if(!t||(r(!0),t.sticky))return;let e=setTimeout(()=>r(!1),t.duration??(t.link||t.action?5e3:1600));return()=>clearTimeout(e)},[t?.id]),t?(0,R.jsx)(`div`,{className:`pointer-events-none fixed right-4 z-[70] flex justify-end ${i?`bottom-20`:`bottom-[calc(var(--queue-dock-inset,0px)+1rem)]`}`,children:(0,R.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-shadow-ink/40 transition-all duration-200 ease-out ${n?`translate-y-0 opacity-100`:`translate-y-8 opacity-0`}`,children:[t.spinner&&(0,R.jsx)(M_,{size:13,className:`animate-spin text-muted`}),t.text,t.link&&(0,R.jsx)(`button`,{onClick:()=>{qh(`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}),t.action&&(0,R.jsx)(`button`,{"data-toast-action":!0,onClick:()=>{let e=t.action;X.toast=null,e.run()},className:`${n?`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.action.label})]})}):null}var M9=`max(50%, calc(100% - 720px))`,uoe={"--full-thread":`min(720px, ${M9})`,"--full-thread-narrow":`min(720px, 100%)`,"--full-pane":M9,"--full-gutter":`max(0px, calc((100% - min(720px, ${M9}) - 340px) / 2))`};function N9(e,t){return`${nm(e)}${cm(t,`/`)}`}function doe({slug:e}){let t=gr(X).filePanels.some(e=>!e.closing),n=ME(),r=Xp(n,e),i=r.kind===`found`?r.thread:void 0;n?.projectDir,(0,L.useEffect)(()=>{Y.board().then(xg).catch(()=>{})},[]),(0,L.useEffect)(()=>{let e=window.matchMedia?.(`(min-width: ${ree}px)`);if(!e)return;let t=()=>{X.splitFileViewer=e.matches};return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),X.splitFileViewer=!1,X.filePanels=[]}},[]);let a=i?.runtime===`turn-idle`||i?.runtime===`exited`||i?.runtime===`none`;(0,L.useEffect)(()=>{!i||!a||Y.threadSeen({slug:e}).catch(()=>{})},[a,e,i?.lastActivityAt]),(0,L.useEffect)(()=>{let t=n?.projectLabel??n?.projectName,r=i?UD(i):e;document.title=t?`${r} · ${t} — Frizz`:`${r} · Frizz`},[n?.projectLabel,n?.projectName,e,i]);let o=i!==void 0&&rO(i);return(0,L.useEffect)(()=>(w9(o),()=>w9(!1)),[o]),(0,R.jsx)(FP,{children:(0,R.jsxs)(`div`,{className:`h-dvh min-h-0 bg-bg text-sm text-fg`,children:[(0,R.jsx)(`div`,{className:`h-full w-full overflow-hidden`,children:(0,R.jsxs)(`div`,{className:`flex h-full w-full justify-center transition-transform duration-200 ease-out motion-reduce:transition-none split:justify-start`,style:{...uoe,transform:t?`translateX(calc(-1 * var(--full-gutter)))`:void 0},children:[(0,R.jsx)(`div`,{className:`hidden w-[var(--full-gutter)] shrink-0 split:block`,"aria-hidden":`true`}),(0,R.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,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,role:`status`,"aria-label":`Loading thread`,children:(0,R.jsx)(`span`,{className:`block h-5 w-5 animate-spin rounded-full border-2 border-muted/50 border-t-transparent`})}):r.kind===`missing`?(0,R.jsx)(moe,{slug:e}):(0,R.jsx)(W8,{slug:e,virtualized:!0,showReturnToQueue:!0})}),i?(0,R.jsx)(foe,{slug:e,thread:i}):(0,R.jsx)(`div`,{className:`hidden w-[var(--full-pane)] shrink-0 split:block`,"aria-hidden":`true`})]})}),(0,R.jsx)(r7,{onEscapeAtRest:()=>f4(e)}),(0,R.jsx)(j9,{})]})})}function foe({slug:e,thread:t}){let n=gr(X);return(0,R.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,R.jsx)(`div`,{inert:n.filePanels.length>0?!0:void 0,className:`h-full min-h-0`,children:(0,R.jsx)(loe,{thread:t})}),n.filePanels.map((t,r)=>(0,R.jsx)(poe,{slug:e,path:t.path,closing:!!t.closing,active:r===n.filePanels.length-1&&!t.closing&&n.splitFileViewer},t.id))]})}function poe({slug:e,path:t,closing:n,active:r}){let[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(null);return(0,L.useLayoutEffect)(()=>{o.current?.getBoundingClientRect();let e=()=>a(!0),t=requestAnimationFrame(e),n=window.setTimeout(e,120);return()=>{cancelAnimationFrame(t),window.clearTimeout(n)}},[]),(0,L.useEffect)(()=>{r&&o.current?.focus({preventScroll:!0})},[r]),(0,R.jsx)(`aside`,{ref:o,tabIndex:-1,"data-file-viewer-slot":!0,"aria-hidden":!r,inert:!r,className:`absolute inset-0 outline-none transition-[translate,opacity] duration-200 ease-out motion-reduce:transition-none ${i&&!n?`translate-x-0 opacity-100`:`translate-x-full opacity-0`}`,children:(0,R.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-panel`,children:(0,R.jsx)(Yae,{slug:e,path:t,active:r})})})}function moe({slug:e}){let{data:t,isPending:n}=ct({queryKey:[`threadLocate`,e],queryFn:()=>Y.threadLocate({slug:e})});return(0,L.useEffect)(()=>{t?.length===1&&location.replace(N9(t[0].projectSlug,e))},[t,e]),(0,R.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4 px-6 text-center`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h1`,{className:`font-medium text-fg`,children:`Thread unavailable`}),n?(0,R.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Looking for “`,e,`” in your other projects…`]}):t&&t.length>0?(0,R.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`“`,e,`” lives in `,t.length===1?`another project`:`these projects`,` — opening it there.`]}):(0,R.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Thread “`,e,`” was not found in any project on this machine.`]})]}),t&&t.length>1?(0,R.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:t.map(t=>(0,R.jsx)(`a`,{href:N9(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,R.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 hoe={OPEN_ISSUE:{bg:QO.bgSuccessEmphasis,icon:l_,label:`Open`},CLOSED_ISSUE:{bg:QO.bgDoneEmphasis,icon:s_,label:`Closed`},NOT_PLANNED:{bg:QO.bgNeutralEmphasis,icon:d_,label:`Closed as not planned`},OPEN_PR:{bg:QO.bgSuccessEmphasis,icon:T_,label:`Open`},DRAFT:{bg:QO.bgNeutralEmphasis,icon:w_,label:`Draft`},MERGED:{bg:QO.bgDoneEmphasis,icon:S_,label:`Merged`},CLOSED_PR:{bg:QO.bgDangerEmphasis,icon:C_,label:`Closed`}};function goe(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 P9(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 _oe(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 ${P9(e,t)}`:OO(e,t)??``:``}function voe(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 F9={add:QO.fgSuccess,del:QO.fgDanger},yoe={add:{backgroundColor:QO.bgSuccessEmphasis,borderColor:QO.bgSuccessEmphasis},del:{backgroundColor:QO.bgDangerEmphasis,borderColor:QO.bgDangerEmphasis},none:{backgroundColor:`color-mix(in srgb, var(--gh-bg-neutral-emphasis) 20%, transparent)`,borderColor:`var(--gh-neutral-border)`}};function I9({additions:e,deletions:t}){return(0,R.jsxs)(`div`,{className:`flex items-baseline gap-1.5 text-[12px] tabular-nums`,children:[(0,R.jsxs)(`span`,{"data-gh-add":!0,style:{color:F9.add},children:[`+`,e.toLocaleString()]}),(0,R.jsxs)(`span`,{"data-gh-del":!0,style:{color:F9.del},children:[`−`,t.toLocaleString()]}),(0,R.jsx)(`span`,{"data-gh-blocks":!0,className:`ml-0.5 inline-flex gap-[1px] self-baseline translate-y-[calc(4px_-_0.5cap)]`,children:voe(e,t).map((e,t)=>(0,R.jsx)(`span`,{className:`size-[8px] rounded-[2px] border`,style:yoe[e]},t))})]})}function boe({card:e}){let t=goe(e),n=t?hoe[t]:void 0;if(!n)return null;let r=n.icon;return(0,R.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-[color:var(--gh-on-emphasis)]`,style:{backgroundColor:n.bg},children:[(0,R.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,R.jsx)(`span`,{"data-gh-pill-label":!0,children:n.label})]})}function xoe({name:e,color:t}){let n=f7(t);return(0,R.jsx)(`span`,{className:`inline-flex items-center rounded-full border px-2 py-[1px] text-[11px] font-medium`,style:{color:n.foreground,backgroundColor:n.background,borderColor:n.border},children:e})}var Soe=/`([^`\n]+)`/g;function Coe(e,t){if(!t)return[e];let n=[],r=0;for(let t of e.matchAll(Soe))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 L9({text:e,code:t,className:n}){return(0,R.jsx)(`div`,{className:n,children:Coe(e,t).map((e,t)=>typeof e==`string`?e:(0,R.jsx)(`code`,{className:`rounded-[3px] bg-panel-2 px-[3px] py-[1px] font-mono-keep text-[0.92em]`,children:e.code},t))})}var woe=new Set([`avatars.githubusercontent.com`,`camo.githubusercontent.com`]);function Toe(e){if(e)try{let t=new URL(e);return t.protocol===`https:`&&woe.has(t.hostname)?e:void 0}catch{return}}function R9({card:e,nowMs:t}){let n=Toe(e.authorAvatar),r=e.authorLogin??e.authorName??`Someone`,i=e.kind===`commit`?`committed`:e.kind===`pr`?`opened this pull request`:`opened this issue`,a=_oe(e.at,t);return(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-2 text-[12px] text-muted`,children:[n?(0,R.jsx)(`img`,{"data-gh-avatar":!0,src:n,alt:``,className:`size-[18px] shrink-0 rounded-full`}):(0,R.jsx)(`span`,{"data-gh-avatar":!0,className:`size-[18px] shrink-0 rounded-full bg-border`}),(0,R.jsxs)(`span`,{"data-gh-byline-text":!0,className:`truncate`,children:[(0,R.jsx)(`span`,{className:`text-fg`,children:r}),` `,i,` `,a]})]})}var z9=`w-[360px] max-w-[min(360px,calc(100vw-24px))] leading-normal`;function Eoe({card:e,nowMs:t=Date.now()}){let n=e.additions!==void 0&&e.deletions!==void 0;if(e.kind===`commit`)return(0,R.jsxs)(`div`,{className:z9,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2 px-3 pt-3 pb-2.5`,children:[(0,R.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,R.jsx)(x_,{className:`size-[1em] text-muted`,"aria-hidden":!0})}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.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,R.jsx)(L9,{text:e.body,code:!1,className:`mt-1.5 line-clamp-6 text-[12px] text-muted`}):null,n?(0,R.jsx)(`div`,{className:`mt-2.5`,children:(0,R.jsx)(I9,{additions:e.additions,deletions:e.deletions})}):null]})]}),(0,R.jsx)(R9,{card:e,nowMs:t})]});let r=e.ref.slice(e.ref.indexOf(`#`));return(0,R.jsxs)(`div`,{className:z9,children:[(0,R.jsxs)(`div`,{className:`px-3 pt-3 pb-3`,children:[(0,R.jsxs)(`div`,{className:`text-[12px] text-muted`,children:[(0,R.jsx)(`span`,{className:`underline decoration-border underline-offset-2`,children:e.repo}),e.at?` on ${P9(e.at,t)}`:``]}),(0,R.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,R.jsx)(`span`,{className:`font-normal text-muted`,children:r})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,R.jsx)(boe,{card:e}),n?(0,R.jsx)(I9,{additions:e.additions,deletions:e.deletions}):null]})]}),e.body||e.labels.length>0?(0,R.jsxs)(`div`,{className:`border-t border-border px-3 py-2.5`,children:[e.body?(0,R.jsx)(L9,{text:e.body,code:!0,className:`line-clamp-2 text-[12px] text-muted`}):null,e.labels.length>0?(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 ${e.body?`mt-2`:``}`,children:e.labels.map(e=>(0,R.jsx)(xoe,{name:e.name,color:e.color},e.name))}):null]}):null,(0,R.jsx)(R9,{card:e,nowMs:t})]})}var Doe=250,Ooe=180;function koe(e){let t=e.getClientRects()[0]??e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}}function Aoe(){let[e,t]=(0,L.useState)(null),n=(0,L.useRef)(void 0),r=(0,L.useRef)(void 0),i=(0,L.useRef)(!1),a=(0,L.useCallback)(()=>{clearTimeout(n.current),clearTimeout(r.current),n.current=void 0,r.current=void 0},[]),o=(0,L.useCallback)(()=>{clearTimeout(r.current),r.current=setTimeout(()=>{i.current||t(null)},Ooe)},[]);return(0,L.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),eh([o]),n.current=setTimeout(()=>t({ref:o,rect:koe(a)}),Doe)))},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,L.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,L.useEffect)(()=>a,[a]),(0,R.jsxs)(CV,{open:e!==null,children:[(0,R.jsx)(TV,{asChild:!0,children:(0,R.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,R.jsx)(EV,{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,R.jsx)(joe,{refKey:e.ref})}):null]})}function joe({refKey:e}){let t=(0,L.useSyncExternalStore)(tee,()=>Xm(e),()=>Xm(e));return(0,L.useEffect)(()=>{Zm(Xm(e))&&ih(e)},[e]),t?.card?(0,R.jsx)(Eoe,{card:t.card}):(0,R.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 B9=`frizz-project-rail`;function Moe(){try{return localStorage.getItem(B9)===`shown`}catch{return!1}}function Noe(e){try{localStorage.setItem(B9,e?`shown`:`hidden`)}catch{}}function Poe(){Ox();let e=ct({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet(),placeholderData:ae}).data?.projectRail;return(0,L.useEffect)(()=>{e!==void 0&&Noe(e===!0)},[e]),e===void 0?Moe():e===!0}var V9=`/project/:slug`;function Foe(){W9();let e=Poe();return(0,R.jsxs)(FP,{children:[e?(0,R.jsx)(Iae,{}):null,(0,R.jsx)(`div`,{className:e?Cae:void 0,children:(0,R.jsx)(uS,{})}),(0,R.jsx)(j9,{}),(0,R.jsx)(VZ,{}),(0,R.jsx)(Aoe,{})]})}function H9(e){let t=dm(gr(X).board?.projectSlug),[n,r]=(0,L.useState)(null),i=(Pee(e)||n!==null&&n.slug===e)&&t;return(0,L.useLayoutEffect)(()=>{i||(bg(),Jee(),r({slug:e}))},[e,i]),i}function U9(){let{slug:e,thread:t}=Px(),n=H9(e);return Loe(),(0,L.useState)(()=>eg(t)),n?(0,R.jsx)(yae,{},e??`__launching__`):null}function Ioe(){return(0,R.jsx)(Wae,{})}function Loe(){let e=Ox();(0,L.useEffect)(()=>{UE(im(e.pathname))},[e.pathname])}function W9(){let e=Ax();(0,L.useEffect)(()=>(KE((t,n)=>e(t,n)),()=>KE(null)),[e])}function G9(){let{thread:e,slug:t}=Px();W9();let n=H9(t);return(0,L.useState)(()=>{X.drawers.length>0&&(X.drawers=[])}),$h(e),n?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(doe,{slug:e}),(0,R.jsx)(j9,{}),(0,R.jsx)(VZ,{})]}):null}var Roe=[{index:!0,element:(0,R.jsx)(U9,{})},{path:`thread/:thread`,element:(0,R.jsx)(U9,{})},{path:`status/:status`,element:(0,R.jsx)(U9,{})}],zoe=eC([{path:`/thread/:thread/full`,element:(0,R.jsx)(G9,{})},{path:`${V9}/thread/:thread/full`,element:(0,R.jsx)(G9,{})},{element:(0,R.jsx)(Foe,{}),children:[{path:`/`,element:(0,R.jsx)(Ioe,{})},{path:`/thread/:thread`,element:(0,R.jsx)(U9,{})},{path:`/status/:status`,element:(0,R.jsx)(U9,{})},{path:V9,children:Roe},{path:`*`,element:(0,R.jsx)(U9,{})}]}]),Boe=24,Voe=6,Hoe=700,K9=new Map,q9=null,J9=null;function Uoe(e){return!Array.isArray(e)||e.length!==2?null:e[0]===`transcript`&&typeof e[1]==`string`?e[1]:null}function Y9(e){return X.board?.threads.find(t=>t.id===e)?.lastActivityAt}function Woe(){let e=[...K9.entries()].filter(([,e])=>e.observers>0),t=new Set(e.slice(-24).map(([e])=>e));for(let[e,n]of K9){if(n.observers<=0){n.live&&(n.live=!1,OE(e)),K9.delete(e);continue}t.has(e)?!n.live&&!n.queued&&(n.queued=!0):(n.queued=!1,n.live&&(n.live=!1,OE(e)))}X9()}function X9(){J9||[...K9.values()].some(e=>e.queued)&&(J9=setTimeout(()=>{J9=null;let e=0,t=[...K9.values()].filter(e=>e.live).length;for(let[n,r]of K9){if(e>=Voe||t>=Boe)break;r.queued&&(r.queued=!1,!(r.observers<=0||r.live)&&(r.live=!0,t++,r.lastActivityAt=Y9(n),DE(n),e++))}X9()},Hoe))}function Goe(){if(q9)for(let[e,t]of K9){if(t.observers<=0)continue;let n=Y9(e);if(n===t.lastActivityAt)continue;t.lastActivityAt=n;let r=X.socketTranscriptFallbacks[e];t.live&&X.socketTranscripts&&!r||q9.refetchQueries({queryKey:[`transcript`,e],exact:!0,type:`active`})}}function Koe(e){q9||(q9=e,e.getQueryCache().subscribe(e=>{let t=Uoe(e.query.queryKey);if(!t||e.type!==`observerAdded`&&e.type!==`observerRemoved`)return;let n=e.query.getObserversCount(),r=K9.get(t);e.type===`observerAdded`?(K9.delete(t),K9.set(t,{observers:n,live:r?.live??!1,queued:r?.queued??!1,lastActivityAt:r?r.lastActivityAt:Y9(t)})):r&&(r.observers=n),Woe()}),pr(X,Goe))}function qoe(){document.documentElement.dataset.font=`sans`,document.body.style.fontFamily=`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;try{localStorage.removeItem(`frizz-font`)}catch{}}function Joe(){let e=e=>{if(e.button!==0||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`.${ST}`):null;t&&(e.preventDefault(),e.stopPropagation(),Xoe(t))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)}function Yoe(e){return e.closest(`.md-code`)?.querySelector(`pre code`)??null}async function Xoe(e){let t=Yoe(e);if(!t)return;let n=(t.textContent??``).replace(/\n$/,``);if(n){try{await eH(n)}catch(e){Z(`Could not copy code: ${e.message.slice(0,100)}`,{duration:7e3});return}Zoe(e)}}var Z9=new WeakMap;function Zoe(e){e.classList.add(CT),e.title=`Copied`;let t=Z9.get(e);t!==void 0&&window.clearTimeout(t),Z9.set(e,window.setTimeout(()=>{e.classList.remove(CT),e.title=wT,Z9.delete(e)},e8))}function Qoe(e){return/Macintosh/.test(e)&&/\bChrome\/15[56]\./.test(e)}function $oe(e){return t=>{if(t.defaultPrevented)return;let n=t.target?.tagName;if(n!==`TEXTAREA`&&n!==`INPUT`)return;let r=t.clipboardData;if(!r||r.types.includes(`Files`))return;let i=r.getData(`text/plain`).replace(/\r\n?/g,`
|
|
336
|
-
`);i&&e(i)&&t.preventDefault()}}function
|
|
332
|
+
`).length:0,[p]),h=m>Yne,g=V8(),_=ME(),v=g?Cg(_,g):void 0,y=!i&&r?(v?.subAgents??[]).find(e=>e.id===r):void 0,b=y?.state===`running`,x=!!(g&&r),S=e??`sub-agent`,C=I4(n),w=LO(),T=H4({agentStatus:i,agentElapsedMs:a,liveState:y?.state,liveElapsedMs:y?.startedAt?Math.max(w-Date.parse(y.startedAt),0):void 0,status:o,durationMs:s}),E=b?(0,R.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--agent`,"data-running-indicator":`subagent-disclosure`}):y?.state===`stale`?(0,R.jsx)(`span`,{className:nk,title:rk}):y?.state===`rested`?(0,R.jsx)(`span`,{className:ik,title:ak}):null;function D(){!g||!r||Jh(g,r,{label:S,subagentType:n,startedAt:y?.startedAt})}return(0,R.jsxs)(`div`,{className:`frizz-bash`,children:[(0,R.jsxs)(QX,{className:`frizz-bash-header`,controls:f,expanded:c,label:`${c?`Collapse`:`Expand`} Agent dispatch: ${S}`,onToggle:()=>l(e=>!e),meta:(C||T)&&(0,R.jsxs)(R.Fragment,{children:[C&&(0,R.jsx)(`span`,{"data-subagent-profile":!0,className:`petite-caps frizz-tool-header-caps shrink-0 whitespace-nowrap text-[11.5px] leading-none text-muted-55`,title:`Sub-agent profile: ${C}`,children:C}),C&&T&&(0,R.jsx)(`span`,{"aria-hidden":!0,className:`petite-caps frizz-tool-header-caps -mx-[2px] shrink-0 text-[11.5px] leading-none text-muted-55`,children:`·`}),T&&(0,R.jsx)(P5,{tone:T.tone===`failed`?`frizz-tool-failed`:`text-muted-55`,title:T.title,label:T.label,duration:T.duration})]}),children:[E&&(0,R.jsx)(`span`,{className:`frizz-tool-mark -mr-1 flex w-[9px] shrink-0 justify-center`,children:E}),(0,R.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:`Agent`}),x?(0,R.jsx)(`button`,{type:`button`,"aria-label":`Open sub-agent transcript: ${S}`,title:`Open sub-agent transcript`,onClick:D,className:`min-w-[4rem] flex-1 truncate text-left text-[11.5px] text-muted outline-none hover:underline hover:text-fg/80 focus-visible:underline focus-visible:text-fg/80`,children:S}):(0,R.jsx)(`span`,{className:`min-w-[4rem] flex-1 truncate text-[11.5px] text-muted`,title:S,children:S})]}),(0,R.jsx)(`div`,{id:f,hidden:!c,children:c&&(0,R.jsxs)(R.Fragment,{children:[p&&(0,R.jsx)(`pre`,{className:`frizz-bash-body${h&&!u?` frizz-bash-clamp`:``}`,children:p}),h&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>d(e=>!e),onMouseDown:e=>e.preventDefault(),className:`frizz-bash-expand petite-caps px-2.5 pb-1.5`,children:u?`Collapse`:`Show all ${m} lines`})]})})]})}function V5(e,t){return t===`shutdown_request`?`Shutdown`:t===`codex_followup`?`Followed up`:e===`main`?`Reported`:`Steered`}function Zne({to:e,summary:t,body:n,type:r,dispatchId:i,targetLabel:a,status:o,durationMs:s,at:c}){return(0,L.useContext)(z8)===null?(0,R.jsx)($ne,{to:e,summary:t,body:n,type:r,status:o,durationMs:s}):(0,R.jsx)(dre,{to:e,type:r,dispatchId:i,targetLabel:a,at:c})}var Qne=16;function $ne({to:e,summary:t,body:n,type:r,status:i,durationMs:a}){let[o,s]=(0,L.useState)(!t),[c,l]=(0,L.useState)(!1),u=(0,L.useId)(),d=rZ(SX(n)),f=(0,L.useMemo)(()=>n.split(`
|
|
333
|
+
`).length,[n]),p=f>Qne,m=!!n.trim(),h=V5(e,r);return(0,R.jsxs)(`div`,{className:`frizz-bash`,children:[(0,R.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-focus-ink-60`,disabled:!m,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`petite-caps frizz-bash-label shrink-0`,children:h}),t&&(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[11.5px] text-muted`,children:t})]}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,R.jsx)(I5,{status:i,durationMs:a}),m&&(0,R.jsx)(r_,{"aria-hidden":`true`,size:12,className:`shrink-0 text-muted transition-transform ${o?`rotate-90`:``}`})]})]}),m&&(0,R.jsx)(`div`,{id:u,hidden:!o,children:o&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`border-t border-border px-2.5 py-2${p&&!c?` frizz-bash-clamp`:``}`,children:(0,R.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:d})}),p&&(0,R.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 ere({body:e,items:t}){let[n,r]=(0,L.useState)(null),i=(0,L.useMemo)(()=>new Map(t.map(e=>[e.token,e])),[t]),a=n===null?void 0:i.get(n);return(0,R.jsxs)(R.Fragment,{children:[(0,L.useMemo)(()=>mz(e,[...i.keys()]),[e,i]).map((e,t)=>{let a=e.token?i.get(e.token):void 0;if(!a)return(0,R.jsx)(T1,{text:e.text},t);let o=n===a.token;return(0,R.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,R.jsx)(`span`,{className:`truncate`,children:lz(a.token)})},t)}),a&&(0,R.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,R.jsxs)(`span`,{className:`block truncate font-mono-keep text-[11px] text-user-bubble-fg/60`,children:[a.display,a.startLine===void 0?``:` · ${a.startLine===a.endLine?`line ${a.startLine}`:`lines ${a.startLine}-${a.endLine}`}`]}),(0,R.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-user-bubble-fg/80`,children:a.text})]})]})}function tre({deliveryId:e,text:t,rawText:n,error:r}){let i=(0,L.useContext)(z8),{retry:a,edit:o,dismiss:s,pending:c}=n2(i),l=`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-focus-ink-60 disabled:opacity-45 disabled:hover:bg-panel-2/60 disabled:hover:text-fg/80`;return(0,R.jsxs)(`div`,{"data-failed-send":e,className:`mt-1 flex flex-col items-end gap-1.5`,children:[(0,R.jsxs)(`div`,{role:`alert`,className:`text-left text-[12px] leading-snug text-danger-soft [overflow-wrap:anywhere]`,children:[`Not delivered`,r?` — ${r.split(`
|
|
334
|
+
`,1)[0]}`:``]}),i&&(0,R.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,R.jsx)(`button`,{type:`button`,className:l,disabled:c,title:`Send this message again`,onClick:()=>a({deliveryId:e,text:n}),children:`Retry`}),(0,R.jsx)(`button`,{type:`button`,className:l,disabled:c,title:`Put this message back in the prompt box`,onClick:n=>o({deliveryId:e,text:t,from:n.currentTarget}),children:`Edit`}),(0,R.jsx)(`button`,{type:`button`,className:l,disabled:c,title:`Discard this message`,onClick:()=>s({deliveryId:e}),children:`Dismiss`})]})]})}function nre({text:e,rawText:t,queued:n,deliveryUnconfirmed:r,deliveryFailed:i,deliveryError:a,deliveryId:o,sourceId:s}){let c=(0,L.useContext)(z8),l=Q0(c),{unqueue:u,pending:d}=Lne(c),f=!!(n&&o&&c&&l),p=s2(n?c:null),{deliverNow:m,pending:h}=c2(c),g=!!(n&&c&&p),{prose:_,attachments:v}=(0,L.useMemo)(()=>oz(e),[e]),y=(0,L.useMemo)(()=>Gte(_),[_]);return(0,R.jsxs)(`div`,{"data-frizz-msg":s,className:`self-end flex flex-col items-end gap-0.5 max-w-[85%]`,children:[_.trim()!==``&&(0,R.jsxs)(`div`,{className:`group relative`,children:[(0,R.jsx)(`div`,{...f?{role:`button`,tabIndex:0,"data-unqueue":o,"aria-label":`Unqueue this message and put it back in the prompt box`,title:d?`Taking it back…`:void 0,onClick:n=>u({deliveryId:o,text:e,rawText:t??e,from:n.currentTarget}),onKeyDown:n=>{n.key!==`Enter`&&n.key!==` `||(n.preventDefault(),u({deliveryId:o,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-user-bubble-fg ${n||i?`opacity-50`:``} ${f?`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`:``} ${d?`!opacity-30`:``}`,children:y?(0,R.jsx)(ere,{body:y.body,items:y.items}):(0,R.jsx)(T1,{text:_})}),g&&(0,R.jsx)(`button`,{type:`button`,onMouseDown:e=>e.preventDefault(),onClick:m,disabled:h,title:`Send now — interrupts what the worker is doing so it reads the queue immediately`,"aria-label":`Send now`,className:`icon-hover-outline 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:h?(0,R.jsx)(M_,{size:15,strokeWidth:2.2,className:`animate-spin`}):(0,R.jsx)(Xg,{size:15,strokeWidth:2.2})})]}),v.length>0&&(0,R.jsxs)(`div`,{className:`mt-1 flex flex-col items-end gap-1.5`,children:[v.filter(e=>e.kind===`image`).map((e,t)=>(0,R.jsx)(W5,{path:e.path,hideCaption:!0},`i${t}-${e.path}`)),v.some(e=>e.kind===`file`)&&(0,R.jsx)(`div`,{className:`flex flex-wrap justify-end gap-1.5`,children:v.filter(e=>e.kind===`file`).map((e,t)=>(0,R.jsx)(G5,{path:e.path},`f${t}-${e.path}`))})]}),r&&(0,R.jsx)(`div`,{className:`text-[11px] text-attention-80`,children:`Delivery unconfirmed — no receipt from the worker`}),i&&o&&(0,R.jsx)(tre,{deliveryId:o,text:e,rawText:t??e,error:a}),f&&d&&(0,R.jsx)(`div`,{"aria-hidden":!0,className:`h-0 overflow-visible text-[11px] text-muted`,children:`Taking it back…`})]})}var H5=(0,L.memo)(function({m:e,answering:t,dense:n,paired:r,textOnly:i,showSendButton:a,staleAwaiting:o,shadowedBy:s,placed:c,settledPlaced:l,thread:u,restingCardShown:d}){let f=Lg(),[p,m]=(0,L.useState)(!1);if(e.providerError)return(0,R.jsx)(f$,{error:e.providerError});if(e.kind===`event`)return(0,R.jsx)(fre,{text:e.text,boundary:e.boundary,sourceId:e.sourceId,at:e.at});if(e.kind===`reasoning`)return(0,R.jsx)(pre,{text:e.text,sourceId:e.sourceId});let h=L4(e);if(h)return(0,R.jsx)(lre,{call:h,sourceId:e.sourceId,at:e.at});if(e.role===`user`){let t=d2(e).replace(/\r\n?/g,`
|
|
335
|
+
`),i=r===void 0?b$(t):r;if(i&&e.deliveryState!==`failed`)return(0,R.jsx)(E1,{answers:i,queued:e.queued,sourceId:e.sourceId});let a=e.wake?od(t):void 0;return a?(0,R.jsx)(v1,{bump:a,sourceId:e.sourceId,at:e.at}):e.wake?(0,R.jsx)(o1,{steer:e.wakeSteer,text:t,sourceId:e.sourceId,at:e.at,wrap:n}):e.sessionPeer?(0,R.jsx)(u2,{peer:e.sessionPeer,text:t,queued:e.queued,sourceId:e.sourceId,at:e.at,wrap:n}):e.peerFrom?(0,R.jsx)(ure,{from:e.peerFrom,unnamed:e.peerUnnamed,dispatchId:e.peerDispatchId,sourceId:e.sourceId,at:e.at}):(0,R.jsx)(nre,{text:t,rawText:e.text,queued:e.queued,deliveryUnconfirmed:e.deliveryState===`unconfirmed`,deliveryFailed:e.deliveryState===`failed`,deliveryError:e.deliveryError,deliveryId:e.deliveryId,sourceId:e.sourceId})}let g=[],_=[],v=(e,t=zne)=>{g.push(e),_.push(t)},y={n:-1},b=[],x=new Set,S=(r,i)=>{for(let[a,u]of UQ(r).entries()){if(u.kind===`fence`){if(u.fenceKind===`awaiting`&&o&&!e.fenceRefused&&!d&&S5(u.hints)){v((0,R.jsx)(X6,{fence:{body:u.body,hints:u.hints}},`${i}-f${a}`));continue}if(u.fenceKind===`awaiting`&&(e.fenceRefused||o||d))continue;if(u.fenceKind===`awaiting`&&jW(u.hints)){let e=VW(u.body);e&&v((0,R.jsx)(U5,{md:e,wrap:n},`${i}-f${a}`));continue}v((0,R.jsx)(K5,{fenceKind:u.fenceKind,body:u.body,hints:u.hints,wrap:n},`${i}-f${a}`));continue}for(let[e,r]of xQ(u.text).entries()){if(r.kind===`prose`){for(let[t,o]of az(r.text).entries()){let r=`${i}-${a}-p${e}-${t}`;v(o.kind===`image`?(0,R.jsx)(W5,{path:o.path},r):o.kind===`file`?(0,R.jsx)(G5,{path:o.path},r):o.kind===`visualization`?(0,R.jsx)(are,{file:o.file},r):o.kind===`directive`?(0,R.jsx)(M8,{directive:o.directive},r):o.kind===`mermaid`?(0,R.jsx)(R8,{source:o.source},r):o.kind===`lightbox`?(0,R.jsx)(PZ,{entries:o.entries},r):(0,R.jsx)(U5,{md:o.text,wrap:n},r))}continue}y.n+=1;let o=y.n,u=c&&r.registeredId?c.find(e=>e.id.toLowerCase()===r.registeredId):void 0;if(u&&!x.has(u.id)){x.add(u.id),v((0,R.jsx)(k0,{q:u},`${i}-${a}-q${e}`));continue}if(s&&G$(r,s)!==void 0)continue;let d=l&&r.registeredId?l.find(e=>e.id.toLowerCase()===r.registeredId):void 0;if(d&&!x.has(d.id)){x.add(d.id),v((0,R.jsx)(E0,{s:d,wrap:n},`${i}-${a}-q${e}`));continue}if(r.registeredId&&r.text.trim()===``)continue;t&&b.push({raw:r.text,kind:r.questionKind,danger:r.danger,bi:o});let p=t&&!f?{answer:t.answerFor(o),onChip:(e,n)=>t.onChip(o,e,n),onText:e=>t.onText(o,e),onSubmit:t.onSubmit}:void 0;v((0,R.jsx)(B1,{raw:r.text,questionKind:r.questionKind,danger:r.danger,interactive:p,wrap:n},`${i}-${a}-q${e}`))}}};if(e.parts&&e.parts.length>0)Rne(e.parts).forEach((t,r)=>{if(t.kind===`tools`){if(i)return;let a=k5(t.tools);a.length&&v((0,R.jsx)(M5,{tools:a,dense:n,at:e.at},`t${r}`),O5(a))}else S(t.text,`x${r}`)});else{if(!i){let t=k5(e.tools);t.length>0&&v((0,R.jsx)(M5,{tools:t,dense:n,at:e.at},`tools`),O5(t))}S(e.text,`leg`)}return g.length===0?null:(a&&t&&f&&b.length>0?v((0,R.jsx)(`div`,{className:`flex justify-start`,children:(0,R.jsx)(`button`,{type:`button`,"data-mobile-answer-open":!0,onClick:()=>m(!0),className:`button-outline flex h-[40px] items-center justify-center rounded-[12px] bg-accent-fill px-4 text-[15px] font-semibold text-on-accent active:brightness-90`,children:b.length>1?`Answer ${b.length} questions`:`Answer`})},`answer-open`)):a&&t&&b.length>0&&v((0,R.jsx)(`div`,{className:`flex justify-start`,children:(0,R.jsx)(`button`,{type:`button`,"data-send-answers":!0,disabled:!t.anyAnswered||t.sending,onClick:t.onSubmit,onMouseDown:e=>e.preventDefault(),className:`button-outline 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,R.jsxs)(`div`,{"data-frizz-msg":e.sourceId,className:`flex flex-col text-[13px] min-w-0`,children:[E5(g,D5(_,14)),p&&t&&b.length>0?(0,R.jsx)(G1,{blocks:b,answering:t,onClose:()=>m(!1)}):null]}))});function U5({md:e,wrap:t}){let n=SX(e),r=rZ(n),i=(0,L.useRef)(null);return gZ(i,n),n?(0,R.jsx)(`div`,{ref:i,className:`md-body${t?` ${GQ}`:``}`,dangerouslySetInnerHTML:r}):null}function W5({path:e,hideCaption:t,altText:n}){let[r,i]=(0,L.useState)(!1);if(r)return(0,R.jsx)(`div`,{className:`font-mono-keep text-[12px] text-muted-70 break-all`,children:e});let a=xh(e);return(0,R.jsx)(VY,{caption:t?void 0:(0,R.jsx)(`figcaption`,{className:`bg-panel-2 px-2 pb-1.5 font-mono-keep text-[11px] text-muted-60 break-all`,children:a}),children:(0,R.jsx)(`img`,{src:BT(e),alt:n??a,"data-local-path":e,"data-local-image":`true`,onError:()=>i(!0),className:`cursor-zoom-in ${WY}`})})}function G5({path:e}){let t=xh(e);return(0,R.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,R.jsx)(v_,{size:14,strokeWidth:2,className:`shrink-0 text-muted`}),(0,R.jsx)(`span`,{className:`font-mono-keep truncate text-[12px] text-fg`,children:t})]})}var rre={"--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-control-strong`,"--ring":`--color-accent`,"--destructive":`--viz-destructive`,"--viz-series-1":`--viz-series-1`,"--viz-series-2":`--viz-series-2`,"--viz-series-3":`--viz-series-3`,"--viz-series-4":`--viz-series-4`,"--viz-series-5":`--viz-series-5`,"--viz-series-6":`--viz-series-6`};function ire(e){let t=getComputedStyle(document.documentElement),n=Object.fromEntries(Object.entries(rre).map(([e,n])=>[e,t.getPropertyValue(n).trim()]));return n[`--font-size-base`]=getComputedStyle(document.body).fontSize,M2(e,t.colorScheme===`light`?`light`:`dark`,n)}function are({file:e}){let t=(0,L.useContext)(z8),n=(0,L.useRef)(null),[r,i]=(0,L.useState)(360),[a,o]=(0,L.useState)(null),[s,c]=(0,L.useState)(null),l=(0,L.useRef)(void 0),u=(0,L.useRef)(0),d=(0,L.useRef)(null),{resolved:f}=(0,L.useSyncExternalStore)(A2,O2,O2),p=t?`${sm()}/local-visualization?slug=${encodeURIComponent(t)}&file=${encodeURIComponent(e)}`:null;(0,L.useEffect)(()=>{if(!p){o(!1);return}let e=new AbortController;return o(null),c(null),d.current=null,window.clearTimeout(l.current),fetch(p,{method:`HEAD`,signal:e.signal}).then(t=>{e.signal.aborted||o(t.ok)}).catch(()=>{e.signal.aborted||o(!1)}),()=>e.abort()},[p]);let m=(0,L.useCallback)(()=>{if(!p||d.current!==p)return;let e=++u.current;n.current?.contentWindow?.postMessage(ire(e),`*`)},[p]);return(0,L.useEffect)(()=>{let e=e=>{if(e.source!==n.current?.contentWindow)return;if(e.data?.type===`frizz-inline-vis-ready`){m();return}if(N2(e.data,u.current)&&p&&d.current===p){window.clearTimeout(l.current),c(p);return}if(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)},[m,p]),(0,L.useEffect)(()=>{m()},[f,m]),(0,L.useEffect)(()=>()=>window.clearTimeout(l.current),[]),a===!1||!p?(0,R.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,R.jsx)(`span`,{className:`font-mono-keep break-all`,children:e})]}):a===null?(0,R.jsx)(`div`,{role:`status`,className:`h-20 animate-pulse ${KQ} bg-panel-2`,"aria-label":`Loading ${e}`}):(0,R.jsx)(`iframe`,{ref:n,src:p,title:e.replace(/\.html$/,``).replaceAll(`-`,` `),sandbox:`allow-scripts`,onLoad:()=>{p&&(c(null),d.current=p,m(),window.clearTimeout(l.current),l.current=window.setTimeout(()=>o(!1),5e3))},className:`block w-full border-0 bg-transparent`,style:{height:r,visibility:s===p?`visible`:`hidden`}})}function K5({fenceKind:e,body:t,hints:n,wrap:r}){let i=SX(t),a=(0,L.useContext)(z8),o=(0,L.useContext)(H8),s=ME(),c=a?Cg(s,a):void 0,l=c?zK(c):void 0,u=!!(c&&l?.archive),d=(0,L.useRef)(null);u&&c&&(d.current=c);let f=u&&c?c:d.current,p=Lg();return e===`done`?(0,R.jsxs)(r$,{icon:e_,label:`Done`,children:[i&&(0,R.jsx)(uQ,{className:`md-body${r?` [overflow-wrap:anywhere] [&_pre]:whitespace-pre-wrap [&_pre]:break-all`:``}`,html:i}),f&&!p&&(0,R.jsx)(a$,{children:(0,R.jsx)(Mq,{thread:f,className:`rounded-md text-[11px] bg-fg px-2.5 py-1 text-bg hover:opacity-90`,iconClassName:`icon-label-nudge`,onArchived:o?.dismiss,onDismissCancel:o?.cancel})})]}):c&&q6(c)?null:(0,R.jsx)(X6,{thread:c,fence:{body:t,hints:n}})}function ore({slug:e,sessionId:t,fault:n,retryText:r}){let[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(!1),c=qe(),l=rH[n.backend],u=t=>{s(!0),DW(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,R.jsxs)(r$,{"data-provider-fault":!0,tone:`danger`,icon:j_,label:`${l} sign-in required`,children:[(0,R.jsx)(`span`,{className:i$,children:`The provider rejected this session's credential. Sign in, then retry.`}),(0,R.jsxs)(a$,{children:[r?.trim()&&(0,R.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,R.jsx)(`button`,{onClick:()=>a(!0),onMouseDown:e=>e.preventDefault(),className:c$,children:`Sign in`})]}),i&&(0,R.jsx)(aH,{backend:n.backend,onClose:()=>a(!1),onAuthed:()=>a(!1)})]})}function sre({slug:e,sessionId:t,pause:n}){let r=n.backend===`acp`?`The agent`:rH[n.backend],i=n.window===`weekly`?`weekly limit`:n.window===`session`?`session limit`:`usage limit`,[a,o]=(0,L.useState)(!1),s=qe();return(0,R.jsxs)(r$,{"data-limit-pause":!0,tone:`caution`,icon:D_,label:`Paused by the ${r} ${i}`,children:[(0,R.jsx)(`span`,{className:i$,children:n.autoResume?n.resumesAt?`Continuing automatically at ${kO(n.resumesAt)}.`:`Continuing automatically once the window resets.`:`Continue it whenever you have capacity again.`}),(0,R.jsx)(a$,{children:(0,R.jsx)(`button`,{onClick:()=>{o(!0),DW(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 ${c$}`,children:`Continue now`})})]})}function q5({policy:e,denies:t}){let n=[e.tool,e.command].filter(Boolean).join(`: `);return(0,R.jsxs)(r$,{tone:`caution`,icon:ov,label:`Blocked by frizz's permission policy`,children:[n?(0,R.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,R.jsx)(`span`,{className:i$,children:e.reason}),(0,R.jsxs)(`span`,{className:`mt-1.5 block text-[11px] text-muted`,children:[`Rule `,(0,R.jsx)(`code`,{className:`rounded bg-panel px-1 py-0.5`,children:e.rule}),t&&t>1?` · ${t} denials this session`:``]})]})}function J5({slug:e,className:t=`px-4 pb-2 pt-1`,includeAgents:n=!0,transcriptShells:r=[],parentAgentId:i}){let a=Cg(ME(),e),o=a?.subAgents??[],s=n?i?hk(o,i):o:[],c=i?[...r]:yk(a?.bgShells??[],r),l=i?[]:(a?.watches??[]).filter(e=>e.kind===`github`),u=i?[]:a?.links??[],d=s.length+c.length+l.length,f=new Set((a?.watches??[]).filter(e=>e.kind===`shell`&&e.state===`armed`).map(e=>e.target)),p=e=>f.has(e.taskId??``)||f.has(e.id??``)||f.has(e.label),[,m]=(0,L.useState)(0);(0,L.useEffect)(()=>{if(d===0)return;let e=setInterval(()=>m(e=>e+1),3e4);return()=>clearInterval(e)},[d]);let h=cte(e,c.flatMap(e=>e.id&&!e.outputUnavailable?[e.id]:[]));return d===0&&u.length===0?null:(0,R.jsxs)(`div`,{className:`flex flex-col gap-0.5 ${t}`,"data-background-ops":!0,children:[_k(s,`sheet`).map((t,n)=>(0,R.jsx)(bk,{kind:`AGENT`,label:t.label,state:t.state,density:`sheet`,depth:t.displayDepth??t.depth,startedAt:t.startedAt,onOpen:t.id?()=>Jh(e,t.id,{label:t.label,subagentType:t.subagentType,startedAt:t.startedAt}):void 0,onDismiss:RP(e,t)},`a${n}`)),_k(c,`sheet`).map((t,n)=>(0,R.jsx)(bk,{kind:`SHELL`,label:t.label,state:t.state,density:`sheet`,startedAt:t.startedAt,counter:t.id?ck(h.get(t.id)):void 0,counterTitle:`Lines of output so far — open the row to read them`,onOpen:t.id&&!t.outputUnavailable?()=>Yh(e,t.id,{label:t.label,startedAt:t.startedAt}):void 0,onDismiss:RP(e,t,`SHELL`),title:p(t)?`${t.label}\nWatched — this thread wakes when it finishes`:void 0},`s${n}`)),l.map(e=>(0,R.jsx)(bk,{kind:`GITHUB`,label:e.target,state:`running`,density:`sheet`,startedAt:e.createdAt,counter:e.subject===`issue`?uk(e.issue):lk(e.github),counterTone:e.github?.checks===`failing`?`danger`:void 0,counterTitle:e.subject===`issue`?e.issue?`${e.target} — ${j6(e.issue)}`:void 0:e.github?`${e.target} — ${y6(e.github)}`:void 0,onOpen:()=>window.open(AW(e.target,e.subject===`issue`?`issue`:`pull`)??`https://github.com/${e.target.replace(`#`,e.subject===`issue`?`/issues/`:`/pull/`)}`,`_blank`,`noreferrer,noopener`)},e.id)),(0,R.jsx)(K4,{links:u})]})}function cre({ask:e,onTerminal:t}){return(0,R.jsxs)(r$,{tone:`attention`,icon:u_,label:`Waiting on your answer — in your external terminal`,children:[(0,R.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,R.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[e.header&&(0,R.jsx)(`div`,{className:`text-[10px] uppercase tracking-wide text-muted-55`,children:e.header}),(0,R.jsx)(`div`,{className:`min-w-0 text-[12px] font-medium leading-5 text-fg`,children:e.question}),e.options.length>0&&(0,R.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[e.options.map((e,t)=>(0,R.jsxs)(`div`,{className:`rounded-md border border-border bg-elevated px-3 py-1.5 text-[12px] text-fg/80`,children:[(0,R.jsx)(`span`,{className:`font-medium text-fg/90`,children:e.label}),e.description&&(0,R.jsxs)(`span`,{className:`text-muted-70`,children:[` — `,e.description]})]},t)),e.multiSelect&&(0,R.jsx)(`div`,{className:`text-[10px] text-muted-50`,children:`select one or more`})]})]},t))}),(0,R.jsx)(a$,{children:(0,R.jsxs)(`button`,{onClick:()=>t(),onMouseDown:e=>e.preventDefault(),className:c$,children:[(0,R.jsx)(j_,{size:12,className:`shrink-0 ${m2}`}),`Copy terminal command`]})})]})}function lre({call:e,sourceId:t,at:n}){let r=V8(),i=e.detail??`sub-agent`,{tail:a}=z4(e),o=!!(r&&e.agentId);return(0,R.jsxs)(t1,{icon:Qg,sourceId:t,marker:`agent`,ariaLabel:o?void 0:`Sub-agent ${i} ${a}`,at:n,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:`Sub-agent`}),(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:`«`}),o?(0,R.jsx)(`button`,{type:`button`,"data-subagent-completion-open":!0,title:sk.AGENT,"aria-label":`${sk.AGENT}: ${i}`,onClick:()=>Jh(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-focus-ink-60`,children:i}):(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:i}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`»`})]}),(0,R.jsx)(`span`,{className:`shrink-0`,children:a})]})}function ure({from:e,unnamed:t,dispatchId:n,sourceId:r,at:i}){let a=V8(),o=!!(a&&n),s=t?void 0:e,c=t&&e?`${sk.AGENT} — ${e}`:sk.AGENT;return s===void 0?(0,R.jsx)(t1,{icon:Qg,sourceId:r,marker:`agent-report`,ariaLabel:o?void 0:`Sub-agent reported`,at:i,children:o?(0,R.jsx)(`button`,{type:`button`,"data-subagent-report-open":!0,title:c,"aria-label":`${sk.AGENT}${e?`: ${e}`:``}`,onClick:()=>Jh(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-focus-ink-60`,children:`Sub-agent reported`}):(0,R.jsx)(`span`,{className:`shrink-0`,title:e||void 0,children:`Sub-agent reported`})}):(0,R.jsxs)(t1,{icon:Qg,sourceId:r,marker:`agent-report`,ariaLabel:o?void 0:`Sub-agent ${s} reported`,at:i,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:`Sub-agent`}),(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:`«`}),o?(0,R.jsx)(`button`,{type:`button`,"data-subagent-report-open":!0,title:sk.AGENT,"aria-label":`${sk.AGENT}: ${s}`,onClick:()=>Jh(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-focus-ink-60`,children:s}):(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:s}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`»`})]}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`reported`})]})}function dre({to:e,type:t,dispatchId:n,targetLabel:r,sourceId:i,at:a}){let o=V8(),s=V5(e,t),c=e===`main`?void 0:r??e,l=!!(o&&n);return(0,R.jsxs)(t1,{icon:Qg,sourceId:i,marker:`agent-steer`,ariaLabel:l?void 0:`${s}${c?` ${c}`:``}`,at:a,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:s}),c&&(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center`,children:[(0,R.jsx)(`span`,{className:`shrink-0`,children:`«`}),l?(0,R.jsx)(`button`,{type:`button`,"data-subagent-steer-open":!0,title:sk.AGENT,"aria-label":`${sk.AGENT}: ${c}`,onClick:()=>Jh(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-focus-ink-60`,children:c}):(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:c}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`»`})]})]})}function fre({text:e,boundary:t,sourceId:n,at:r}){return t?(0,R.jsx)(t1,{icon:t===`wake`?rv:void 0,sourceId:n,marker:t===`rest`?`rest`:`event`,ariaLabel:e,at:r,children:(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:e})}):(0,R.jsx)(`div`,{"data-frizz-msg":n,className:q4,children:e})}function pre({text:e,sourceId:t}){let[n,r]=(0,L.useState)(!1),i=(0,L.useId)();return(0,R.jsxs)(`div`,{"data-frizz-msg":t,className:`flex flex-col`,children:[(0,R.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:`${q4} flex items-baseline gap-1.5 self-start rounded outline-none transition-colors hover:text-fg focus-visible:ring-1 focus-visible:ring-focus-ink-60`,children:[(0,R.jsx)(`span`,{children:`Reasoning`}),(0,R.jsx)(r_,{"aria-hidden":`true`,size:13,className:Y4(n)})]}),n&&(0,R.jsx)(`div`,{id:i,className:`frizz-reasoning mt-1.5 ml-[5px] border-l border-border/70 pl-3`,children:(0,R.jsx)(U5,{md:e,wrap:!0})})]})}function Y5(){return(0,R.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-full border border-muted/70 border-t-transparent animate-spin`})}function X5({since:e,startedAt:t,activityLabel:n,run:r}){let[i]=(0,L.useState)(()=>Date.now()),a=(0,L.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,L.useState)(()=>Date.now()),[c,l]=(0,L.useState)(!1),u=(0,L.useId)();(0,L.useEffect)(()=>{let e=setInterval(()=>s(Date.now()),1e3);return()=>clearInterval(e)},[]);let d=KO(Math.max(0,o-a)),f=(0,L.useMemo)(()=>k5([...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-focus-ink-60 ${q4}`,g=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-1.5`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate shimmer-text`,children:n??TK(p)}),m&&(0,R.jsx)(r_,{"data-working-chevron":!0,"aria-hidden":`true`,size:13,className:Y4(c)})]}),(0,R.jsx)(`span`,{className:`shrink-0 whitespace-nowrap tabular-nums text-[12px] text-muted-60`,children:d})]});return(0,R.jsxs)(`div`,{"data-working-indicator":!0,"data-working-activity":n?`tool`:`generic`,className:`flex min-w-0 flex-col`,children:[m?(0,R.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,R.jsx)(`div`,{className:h,children:g}),m&&c&&(0,R.jsx)(`div`,{id:u,className:`mt-1.5 flex flex-col`,children:E5(f.map((e,t)=>(0,R.jsx)(N5,{t:e,startedAt:r?.at},t)),6)}),m&&!c&&(0,R.jsx)(`div`,{id:u,hidden:!0})]})}function mre({id:e,slug:t,depth:n,widthDepth:r,initiallyOpen:i}){let{shown:a,close:o,closingRef:s}=Vg(e,i===!0),[c,l]=(0,L.useState)(i===!0),u=(0,L.useRef)(null),d=(0,L.useRef)(null),f=gr(X),p=zg(e),m=Rg(e),h=Bg(),g=Lg(),_=(0,L.useRef)(typeof document<`u`&&document.activeElement instanceof HTMLElement?document.activeElement:null),v=(0,L.useCallback)(()=>{let e=_.current,t=document.activeElement;t&&t!==document.body||e?.isConnected&&e.focus({preventScroll:!0})},[]);(0,L.useEffect)(()=>()=>{window.setTimeout(v,0)},[v]);let y=ME(),b=Xp(y,t),x=b.kind===`found`?b.thread:void 0;y?.projectDir;let S=x?x.runtime===`turn-idle`||x.runtime===`exited`||x.runtime===`none`:!1;(0,L.useEffect)(()=>{!x||!S||Y.threadSeen({slug:t}).catch(()=>{})},[t,S,S?x?.lastActivityAt:void 0]);let C=(0,L.useRef)(null);return C.current===null&&x&&(C.current=g&&x.runtime!==`running`&&x.runtime!==`spawning`),(0,L.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 lJ({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||C.current===!0});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,L.useEffect)(()=>{d.current?.activationChanged()},[p]),(0,L.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,L.useEffect)(()=>(Ip(e,()=>u.current?.focus({preventScroll:!0})),()=>Ip(e,null)),[e]),(0,R.jsx)(hR,{modal:h,open:!0,onOpenChange:e=>{e||o()},children:(0,R.jsxs)(yR,{children:[h&&!m?(0,R.jsx)(`div`,{className:`${Dh} ${a?`opacity-100`:`opacity-0`}`,style:{zIndex:50+n*2,pointerEvents:`auto`}}):(0,R.jsx)(xR,{className:`${Dh} ${a?`opacity-100`:`opacity-0`}`,style:{zIndex:50+n*2}}),(0,R.jsxs)(TR,{ref:u,"aria-modal":h||void 0,"aria-describedby":void 0,tabIndex:-1,onEscapeKeyDown:t=>{if(t.target instanceof Element&&t.target.closest(`[data-claims-escape]`)){t.preventDefault();return}if(X.drawers.at(-1)?.id!==e){t.preventDefault();return}mB(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(),v()},onOpenAutoFocus:e=>{e.preventDefault(),u.current?.focus({preventScroll:!0})},"data-vt-chat":!0,className:`fixed right-0 top-0 overflow-hidden outline-none ${Oh} ${a?`translate-x-0`:`translate-x-full`}`,style:{zIndex:51+n*2,width:kh(r),viewTransitionName:f.vtReturnTarget===t?`thread-chat`:void 0},children:[(0,R.jsx)(AR,{className:`sr-only`,children:b.kind===`found`?`Thread: ${HD(b.thread)}`:`Thread: ${t}`}),c&&b.kind===`found`?(0,R.jsx)(K8,{slug:t,onStatusApplied:o,onClose:o,virtualized:!0}):c&&b.kind===`missing`?(0,R.jsx)(hre,{slug:t,onClose:o}):(0,R.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,R.jsx)(`span`,{className:`block h-5 w-5 rounded-full border-2 border-muted/50 border-t-transparent animate-spin`})})]})]})})}function hre({slug:e,onClose:t}){return(0,R.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,R.jsx)(fv,{title:`Thread unavailable`,onClose:t}),(0,R.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 gre({id:e,slug:t,subId:n,label:r,subagentType:i,startedAt:a,depth:o,widthDepth:s}){let[c,l]=(0,L.useState)(!1),u=(0,L.useRef)(null),d=ote(t,n),f=NE(),p=(0,L.useMemo)(()=>d.data?.messages??[],[d.data]),m=d.data?.state,h=m===`running`,g=(0,L.useMemo)(()=>W8(p),[p]),_=(0,L.useMemo)(()=>G8(p),[p]),v=(0,L.useMemo)(()=>sK(_),[_]),y=h?uK(v):void 0,b=h?lK(v):void 0,x=b?yK(b,f):void 0,S=h?fK(v):void 0,C=(0,L.useMemo)(()=>h?mK(v):v,[v,h]),w=h,T=d.isError||m===`gone`||p.length===0&&(m===`done`||m===`stale`);return(0,L.useEffect)(()=>{let e=0,t=requestAnimationFrame(()=>{e=requestAnimationFrame(()=>l(!0))});return()=>{cancelAnimationFrame(t),e&&cancelAnimationFrame(e)}},[]),(0,L.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,R.jsx)(Gg,{id:e,depth:o,widthDepth:s,children:e=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(fv,{title:r,onClose:e}),(0,R.jsx)(`div`,{ref:u,className:`flex-1 min-h-0 overflow-y-auto`,children:T?(0,R.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,R.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,R.jsx)(`span`,{className:`block h-5 w-5 rounded-full border-2 border-muted/50 border-t-transparent animate-spin`})}):(0,R.jsx)(B8.Provider,{value:t,children:(0,R.jsxs)(`div`,{"data-transcript-column":!0,className:`flex flex-col px-6 py-5`,children:[T5(C.map(e=>e.message),(e,t)=>(0,R.jsx)(H5,{m:e},t)),w&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(e1,{h:w5(C.map(e=>e.message))}),(0,R.jsx)(X5,{since:a,startedAt:S,activityLabel:x,run:y})]})]})})}),(0,R.jsx)(_re,{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,R.jsx)(J5,{slug:t,parentAgentId:n,transcriptShells:g,className:e})})]})})}function _re({slug:e,subId:t,subagentType:n,steerable:r,note:i,stoppable:a,stopNote:o,ops:s}){let[c,l]=(0,L.useState)(``),[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(!1),m=qe();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,R.jsxs)(`div`,{"data-subagent-steer-note":!0,className:`w-full shrink-0 border-t border-border bg-panel px-3 py-3`,children:[(0,R.jsx)(`div`,{className:`px-1 pb-2 text-[11.5px] text-muted-70`,children:e}),(0,R.jsx)(`div`,{className:`pl-1.5`,children:(0,R.jsx)(Z5,{subagentType:n})}),s?.(`px-1 pt-1.5 ops-column-optical-inset`)]}):(0,R.jsx)(R.Fragment,{children:s?.(`w-full shrink-0 border-t border-border bg-panel px-4 pb-2 pt-3`)})}return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{"data-subagent-steer":!0,className:`w-full shrink-0 border-t border-border bg-panel px-3 py-3`,children:[r?(0,R.jsx)(Hz,{value:c,onChange:l,onSubmit:h,surface:`subAgentComposer`,placeholder:`Steer this sub-agent…`,busy:u||f,footer:(0,R.jsx)(Z5,{subagentType:n})}):i?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:`px-1 pb-2 text-[11.5px] text-muted-70`,children:i}),(0,R.jsx)(`div`,{className:`pl-1.5`,children:(0,R.jsx)(Z5,{subagentType:n})})]}):null,r&&!a&&o&&(0,R.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,R.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,R.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-danger/40 hover:bg-danger/10 hover:text-danger-soft disabled:opacity-50`,children:f?`Stopping…`:`Stop sub-agent`})})]})}function Z5({subagentType:e}){let t=F4(e);return(0,R.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 ${qz}`,children:(0,R.jsx)(`span`,{className:`profile-grid-value relative -top-px min-w-0 truncate`,children:t})})}var Q5=`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 vre({id:e,slug:t,shellId:n,label:r,startedAt:i,depth:a,widthDepth:o}){let s=(0,L.useRef)(null),c=ste(t,n),l=c.data?.state,u=c.data?.command,d=c.data?.output??``,[f,p]=(0,L.useState)(!1),m=qe();(0,L.useEffect)(()=>{let e=s.current;e&&e.scrollHeight-e.scrollTop-e.clientHeight<160&&(e.scrollTop=e.scrollHeight)},[d]);let h=YO(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 eH(u),Z(`Command copied`)}catch{Z(`Could not copy command`)}}return(0,R.jsx)(Gg,{id:e,depth:a,widthDepth:o,children:e=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(fv,{title:r,icon:(0,R.jsx)(rv,{"aria-hidden":!0,size:14,className:`shrink-0 text-muted-60`}),meta:g?(0,R.jsx)(`span`,{className:`shrink-0 whitespace-nowrap text-[11.5px] text-muted-60`,children:g}):void 0,onClose:e}),(0,R.jsx)(`div`,{ref:s,className:`min-h-0 flex-1 overflow-y-auto px-5 py-5`,children:_?(0,R.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,R.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,R.jsxs)(`section`,{children:[(0,R.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-3`,children:[(0,R.jsx)(`h2`,{className:`petite-caps text-[10px] text-muted-65`,children:`Command`}),u&&(0,R.jsxs)(`button`,{type:`button`,onClick:y,className:`button-outline 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-focus-ink-60`,children:[(0,R.jsx)(m_,{"aria-hidden":!0,size:11}),` Copy`]})]}),u?(0,R.jsx)(dQ,{"data-background-shell-command":!0,text:u,language:`bash`,className:Q5}):(0,R.jsx)(`pre`,{"data-background-shell-command":!0,className:Q5,children:c.isLoading?`Loading…`:`Command unavailable for this background operation.`})]}),(0,R.jsxs)(`section`,{children:[(0,R.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,R.jsx)(`h2`,{className:`petite-caps text-[10px] text-muted-65`,children:`Output`}),l===`running`&&(0,R.jsx)(`span`,{"aria-hidden":!0,className:`frizz-live-dot frizz-live-dot--shell`,"data-running-indicator":`shell-drawer`}),c.data?.truncated&&(0,R.jsx)(`span`,{className:`text-[10.5px] text-muted-50`,children:`Showing latest 512 KB`})]}),d?(0,R.jsx)(`pre`,{"data-background-shell-output":!0,className:`font-mono-keep min-h-40 whitespace-pre-wrap break-words ${KQ} border border-border bg-inset px-4 py-3 text-[12px] leading-relaxed text-fg/85`,children:d}):(0,R.jsx)(`div`,{"data-background-shell-output":!0,className:`flex min-h-40 items-center justify-center ${KQ} border border-border bg-inset px-4 text-center text-[12px] text-muted-60`,children:l===`done`?`No output was captured.`:`No output yet.`})]})]})}),!_&&c.data?.stoppable&&(0,R.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,R.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-danger/40 hover:bg-danger/10 hover:text-danger-soft disabled:opacity-50`,children:f?`Stopping…`:`Stop shell`})}),!_&&!c.data?.stoppable&&l===`running`&&c.data?.stopNote&&(0,R.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 $5(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 e7={paddingBottom:`max(0.75rem, env(safe-area-inset-bottom))`};function t7({path:e}){return(0,R.jsxs)(`button`,{type:`button`,onClick:()=>{Y.openLocalFile({path:e}).then(async e=>{e.action===`copy`&&(await eH(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-focus-ink-60`,title:`Open ${e} outside Frizz`,"aria-label":`Open`,children:[(0,R.jsx)(g_,{size:12,"aria-hidden":`true`}),` Open`]})}function n7({source:e}){return(0,R.jsx)(dQ,{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 yre({id:e,path:t,title:n,depth:r,widthDepth:i}){let a=IE(t),o=ct({...XT(t),refetchInterval:a?!1:ZT}),s=o.data?.path??t,c=KT(t),{front:l,body:u}=$5(c?o.data?.markdown??``:``),d=JT(s),f=SX(u,{baseDir:d,asDocument:!0}),p=rZ(f),m=(0,L.useRef)(null);gZ(m,f);let h=BZ(m,f,d),g=Lg(),_=o.data?.markdown??``,v=rZ((0,L.useMemo)(()=>c?``:eE(s,_),[c,_,s]));return(0,R.jsx)(Gg,{id:e,depth:r,widthDepth:i,children:e=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(fv,{title:n,subtitle:s,onClose:e}),(0,R.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:[o.isLoading?(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):o.error?(0,R.jsxs)(`div`,{className:`text-[13px] text-danger-90`,children:[`Couldn’t read this file: `,o.error.message]}):c?f?(0,R.jsxs)(R.Fragment,{children:[l&&(0,R.jsx)(n7,{source:l}),(0,R.jsx)(`div`,{ref:m,className:`md-body`,dangerouslySetInnerHTML:p}),h,o.data?.truncated&&(0,R.jsxs)(`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.`,g?``:` Open it to read the rest.`]})]}):(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):_?(0,R.jsx)(`pre`,{"data-file-source":!0,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:v}):(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!c&&!o.isLoading&&!o.error&&o.data?.truncated&&(0,R.jsx)(`p`,{className:`mt-4 border-t border-border/60 pt-3 text-[12px] text-muted`,children:`This file is too long to show in full — everything above the cut is shown.`})]}),g?(0,R.jsx)(`div`,{"aria-hidden":!0,className:`shrink-0`,style:{height:`env(safe-area-inset-bottom)`}}):(0,R.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:e7,children:(0,R.jsx)(t7,{path:s})})]})})}function bre({id:e,slug:t,title:n,depth:r,widthDepth:i}){let a=ct({queryKey:[`threadBody`,t],queryFn:()=>Y.threadBody({slug:t})}),o=gr(X);(0,L.useEffect)(()=>{a.refetch()},[o.board]);let s=F2(Cg(o.board,t)),c=wH(),l=CH.adopt(c,t),[u,d,f]=EH(l),p=pt({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)=>{bH.get(l)||d(t),Z(`Start failed: ${e.message.slice(0,80)}`)}}),m=SX(lX(a.data?.markdown??``)),h=rZ(m);return(0,R.jsx)(Gg,{id:e,depth:r,widthDepth:i,widthOffset:1,subagentParent:t,children:e=>(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(fv,{title:n,subtitle:`${t}.md`,onClose:e}),(0,R.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:a.isLoading?(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):m?(0,R.jsx)(`div`,{className:`md-body`,dangerouslySetInnerHTML:h}):(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`No thread file found.`})}),s&&(0,R.jsxs)(`div`,{className:`shrink-0 border-t border-border/60 px-5 pb-4 pt-3`,children:[(0,R.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,R.jsx)(Hz,{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 r7({onEscapeAtRest:e}={}){let t=gr(X),n=ME(),r=(0,L.useRef)(e);r.current=e,(0,L.useEffect)(()=>{function e(e){if(e.key===`Escape`){if(pB()){e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation();return}if(X.showPalette)X.showPalette=!1;else if(X.showNewThread)X.showNewThread=!1;else if(X.showGithubPicker)Ih();else if(X.showSettings)jp()||(X.showSettings=!1);else if(X.drawers.length>0){let e=X.drawers[X.drawers.length-1];Fp(e.id)||X.drawers.pop()}else X.filePanels.length>0?lg():!e.defaultPrevented&&!e.isComposing&&r.current?.()}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let i=0;return(0,R.jsx)(R.Fragment,{children:t.drawers.map((e,t)=>{let r=i;e.closing||i++;let a=e.kind===`thread`?(0,R.jsx)(mre,{id:e.id,slug:e.slug,depth:t,widthDepth:r,initiallyOpen:e.routed},e.id):e.kind===`subagent`?(0,R.jsx)(gre,{id:e.id,slug:e.slug,subId:e.subId??``,label:e.label??e.slug,subagentType:e.subagentType,startedAt:e.startedAt,depth:t,widthDepth:r},e.id):e.kind===`shell`?(0,R.jsx)(vre,{id:e.id,slug:e.slug,shellId:e.subId??``,label:e.label??`Background shell`,startedAt:e.startedAt,depth:t,widthDepth:r},e.id):e.kind===`markdown`?(0,R.jsx)(yre,{id:e.id,path:e.path??e.slug,title:e.label??e.slug,depth:t,widthDepth:r},e.id):(0,R.jsx)(bre,{id:e.id,slug:e.slug,depth:t,widthDepth:r,title:(()=>{let t=Cg(n,e.slug);return t?HD(t):e.slug})()},e.id);return(0,R.jsx)(hv,{label:`this drawer`,resetKeys:[e.kind,e.slug,e.subId,e.path],fallback:(n,i)=>(0,R.jsx)(bv,{id:e.id,depth:t,widthDepth:r,error:n,onRetry:i}),children:a},e.id)})})}function i7(e){return(e.tools??[]).some(e=>e.name===`mcp__frizz__done`&&e.status===`completed`)}function xre(e){let t=xQ(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 Sre(e){let t=new Map,n=[];for(let r=0;r<e.length;r++){let i=xre(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 a7(e,t,n){return wQ(e.text)?!n.has(t):i7(e)||e.providerError?!0:e.wake===!0}function Cre(e){return e.wake===!0}function wre(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,hiddenBeforeOpen:!1};continue}let o=r===void 0;r||={start:n,end:n,open:-1,close:-1,steps:0,tools:0,resumed:i,waker:-1,hiddenBeforeOpen:!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++,n<t.open&&(t.hiddenBeforeOpen=!0))}return n}function Tre(e){return e.open<0||e.tools<1&&e.steps<1?!1:e.resumed||e.open!==e.close}function Ere(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)}}}var o7=new Map;function s7(){let e=o7.size===0?0:Math.max(...o7.values());e>0?document.documentElement.style.setProperty(`--queue-dock-inset`,`${e}px`):document.documentElement.style.removeProperty(`--queue-dock-inset`)}function Dre(e,t){let n=new ResizeObserver(()=>{o7.set(e,t.getBoundingClientRect().height),s7()});return n.observe(t),()=>{n.disconnect(),o7.delete(e),s7()}}var Ore=320;function kre(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 Are(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 c7=0,l7=``;function u7(){c7++===0&&(l7=document.documentElement.style.overflowAnchor,document.documentElement.style.overflowAnchor=`none`)}function d7(){c7>0&&--c7===0&&(document.documentElement.style.overflowAnchor=l7)}function jre(e){return{...e,tools:[],parts:e.parts?.filter(e=>e.kind!==`tools`)}}function Mre(){let e=ME(),t=tO(FE(e?.threads??[]).filter(nO),gr(RD).queueOrder),n=t.map(e=>e.id).join(`,`),[r,i]=(0,L.useState)(()=>new Set),a=(0,L.useRef)(t);a.current=t;let o=(0,L.useRef)(r);o.current=r;let s=new Set(t.map(e=>e.id)),c=(0,L.useRef)([]),l=(0,L.useRef)([]),u=(0,L.useRef)(new Map),d=(0,L.useRef)(new Set),f=(0,L.useRef)(new Set),p=(0,L.useRef)(new Map),m=(0,L.useRef)(new Map),h=(0,L.useRef)(null),[g,_]=(0,L.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=pW(),b=e=>v(e.id)||fW(e,y[e.id]),x=(0,L.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,L.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=Are(e);h.current=t?{kind:`top`,slug:t}:null}else{let t=kre(e);h.current=t?{kind:`hold`,...t}:null}f.current.add(e),d.current.delete(e),_(e=>e+1)},Ore);p.current.set(e,t)}return()=>{n!==void 0&&cancelAnimationFrame(n)}},[n,r,g]),(0,L.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,L.useEffect)(()=>()=>{for(let e of p.current.values())clearTimeout(e);for(let e of m.current.values())clearTimeout(e)},[]),(0,L.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}u7();let n=()=>{let t=Nh(e.slug);t!==null&&Math.abs(Rp()-t)>.5&&window.scrollTo({top:t,left:0,behavior:`auto`})};n(),requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n(),d7()})})},[g]);let S=(0,L.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,L.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,R.jsxs)(`div`,{className:`my-auto w-full min-w-0 flex flex-col py-8`,children:[(0,R.jsx)(Nre,{board:e}),x.length>0&&(0,R.jsx)(`div`,{className:`flex flex-col`,children:x.map((e,t)=>(0,R.jsxs)(L.Fragment,{children:[(0,R.jsx)(Fre,{slug:e.id,leaving:v(e.id),children:(0,R.jsx)(Rre,{thread:e,leaving:v(e.id),frozen:b(e),onResolve:S,onUnresolve:C})}),t<x.length-1&&(0,R.jsx)(`hr`,{className:`my-10 border-0 border-t border-border/60`})]},e.id))}),w?(0,R.jsxs)(`div`,{className:`w-full flex flex-col gap-3`,children:[(0,R.jsx)(`h2`,{className:`text-[15px] font-medium text-center`,children:`What should the agent do?`}),(0,R.jsx)(oW,{}),(0,R.jsx)(kH,{autoFocus:!0})]}):x.length===0?(0,R.jsxs)(`div`,{className:`flex flex-col items-center gap-2 pt-2`,children:[(0,R.jsx)(A_,{size:40,strokeWidth:1.25,className:`text-muted-30`}),(0,R.jsx)(`div`,{className:`text-[13px] text-muted-80`,children:`No threads awaiting human input`})]}):null]})}function Nre({board:e}){let t=e?.errorItems??[],n=e?.errors??[];return t.length===0&&n.length===0?null:(0,R.jsxs)(`div`,{className:`mb-6 ${KQ} border border-attention-fill/25 bg-attention-fill/[0.06] px-4 py-2.5 text-[12px] text-attention-detail-90`,children:[(0,R.jsx)(`div`,{className:`font-medium mb-0.5`,children:`Board errors`}),t.length>0?t.slice(0,6).map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-2 py-0.5`,children:[(0,R.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,R.jsx)(Pre,{file:e.file})]},t)):n.slice(0,3).map((e,t)=>(0,R.jsx)(`div`,{className:`truncate`,title:e,children:e},t))]})}function Pre({file:e}){let t=pt({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,R.jsx)(`button`,{onClick:()=>t.mutate(),disabled:t.isPending,className:`shrink-0 rounded border border-attention/50 bg-attention-fill/10 px-2 py-0.5 text-[11px] font-medium text-attention-soft transition-colors hover:bg-attention-fill/25 disabled:opacity-50`,title:`Prepend minimal frontmatter (title + status: active) so this thread becomes visible again`,children:t.isPending?`Repairing…`:`Repair`})}function Fre({leaving:e,slug:t,children:n}){return(0,R.jsx)(`div`,{"data-queue-card":t,"data-queue-leaving":e,className:`frizz-card-slot min-w-0`,children:(0,R.jsx)(`div`,{className:`frizz-card-clip min-h-0 min-w-0`,children:(0,R.jsx)(`div`,{className:`frizz-card-body min-w-0`,children:n})})})}function Ire({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,R.jsxs)(t1,{icon:a_,marker:`middle-runs-summary`,onClick:n,ariaLabel:`Expand ${i}${r?` and ${r}`:``} of intermediate agent activity`,children:[(0,R.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:i}),r&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,R.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:r})]}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`Click to expand`})]})}function Lre({toolCount:e,onExpand:t}){let n=e>0?`${e} tool call${e===1?``:`s`}`:``;return(0,R.jsxs)(t1,{icon:a_,marker:`intermediate-summary`,onClick:t,ariaLabel:`Expand ${n?`${n} of `:``}intermediate agent activity`,children:[n&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`shrink-0 tabular-nums`,children:n}),(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 opacity-50`,children:`·`})]}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`Click to expand`})]})}var Rre=(0,L.memo)(function({thread:e,leaving:t,frozen:n,onResolve:r,onUnresolve:i}){let a=C0(e),o=(0,L.useMemo)(()=>T0(e,a),[e,a]),s=gr(X),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(!1),[f,p]=(0,L.useState)(!1),[m,h]=(0,L.useState)(null),[g,_]=(0,L.useState)(!1),[v,y]=(0,L.useState)(0),b=(0,L.useRef)(null),x=(0,L.useRef)(null),S=(0,L.useRef)(!1),C=(0,L.useRef)(!1),w=(0,L.useRef)(null),T=qe(),E=u8(e.id),D=RE(e.id,{poll:!1}),O=(0,L.useRef)(D.data);n||(O.current=D.data);let k=n?O.current:D.data,A=(0,L.useRef)(null),j=(0,L.useRef)(0),M=(0,L.useRef)(null);(0,L.useEffect)(()=>{let e=M.current,t=A.current;if(!e||!t||typeof ResizeObserver>`u`)return;let n=new ResizeObserver(()=>t.style.setProperty(`--queue-card-header-h`,`${e.getBoundingClientRect().height}px`));return n.observe(e),()=>n.disconnect()},[]),(0,L.useEffect)(()=>{let t=c?null:A.current?.querySelector(`:scope > [data-thread-composer-box]`);if(!(!t||typeof ResizeObserver>`u`))return Dre(e.id,t)},[c,e.id]),(0,L.useEffect)(()=>{let e=A.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(t=>{if(e.style.height)return;let n=t[0]?.borderBoxSize?.[0];n&&(j.current=n.blockSize)});return t.observe(e),()=>t.disconnect()},[]),(0,L.useLayoutEffect)(()=>{let e=A.current;if(e){if(!t){e.style.height=``,e.style.overflow=``;return}j.current>0&&(e.style.height=`${j.current}px`,e.style.overflow=`clip`)}});let N=(0,L.useMemo)(()=>k?.messages??[],[k]),P=(0,L.useMemo)(()=>W8(N),[N]),F=(0,L.useMemo)(()=>G8(N),[N]),I=e.runtime===`running`||e.runtime===`spawning`,ee=NE(),te=(0,L.useMemo)(()=>y5(F),[F]),ne=I?F.length:te,re=e=>ne>=0&&e<ne,ie=q6(e),ae=e=>[re(e),e===te&&ie],oe=(0,L.useMemo)(()=>j$(F),[F]),se=(0,L.useMemo)(()=>p2(F),[F]),ce=(0,L.useMemo)(()=>{for(let e=F.length-1;e>=0;e--)if(F[e].boundary===`rest`)for(let t=e+1;t<F.length;t++){let n=F[t];if(!(n.queued||n.boundary===`rest`||v5(n,...ae(t))))return e+1}return 0},[F]),le=(0,L.useMemo)(()=>{for(let e=F.length-1;e>=0;e--)if(F[e].role===`user`&&!F[e].queued)return e;return-1},[F]),ue=(0,L.useMemo)(()=>Sre(F),[F]),de=(0,L.useMemo)(()=>F.map((e,t)=>{if(!e||e.queued||v5(e,...ae(t))||e.pinnedFromSourceId)return{skip:!0};if(e.boundary===`rest`)return{skip:!0,closes:!0};let n=L4(e),r=n?0:e.tools.length;return{text:C5(e,...ae(t)),tools:r,countable:C5(e,...ae(t))||r>0||n!==void 0||e.kind!==void 0,survives:a7(e,t,ue),opens:Cre(e),completion:e.boundary===`wake`||n!==void 0}}),[F,ue]),fe=(0,L.useMemo)(()=>wre(de,se+1),[de,se]),{kept:pe,middle:me}=(0,L.useMemo)(()=>Ere(fe),[fe]),he=(0,L.useMemo)(()=>pe.filter(Tre),[pe]),ge=(0,L.useMemo)(()=>{let e=new Map;return he.forEach((t,n)=>{for(let r=t.start;r<=t.end;r++)e.set(r,n)}),e},[he]),_e=!u&&(le>=0||ce>0)&&(he.length>0||me!==void 0),ve=nw(F,m,se),ye=(0,L.useMemo)(()=>F.slice(ve),[F,ve]),be=(0,L.useMemo)(()=>sK(ye).map(e=>({...e,messageIndex:e.messageIndex+ve})),[ye,ve]),xe=(0,L.useMemo)(()=>I?mK(be):be,[be,I]),Se=I?uK(be):void 0,Ce=I?lK(be):void 0,we=Ce?yK(Ce,ee):void 0,Te=I?fK(be):void 0,Ee=(0,L.useMemo)(()=>Y$(q$(F,o),ve),[F,o,ve]),De=(0,L.useMemo)(()=>J$(F,o),[F,o]),Oe=(0,L.useMemo)(()=>{let e=[],t=new Map,n=F.length-1,r=o.filter(e=>!Ee.placedIds.has(e.id));for(let[i,a]of I$(F,r)){if(i>=n){e.push(...a);continue}let r=t.get(i);r?r.push(...a):t.set(i,[...a])}let i=!1,a=new Set;for(let e of X$(F,Ee)){if(e>=n){i=!0;continue}a.add(e),t.has(e)||t.set(e,[])}return{byAnchor:t,tail:e,tailSend:i,sendAnchors:a}},[F,o,Ee]),ke=(0,L.useMemo)(()=>$$(F,a),[F,a]),Ae=Vd(e.spawnedAt),je=(0,L.useMemo)(()=>z$(F,o),[F,o]),Me=(0,L.useMemo)(()=>E$(F,e.answersInFlight),[F,e.answersInFlight]),Ne=ve>0||k?.hasEarlier===!0;(0,L.useLayoutEffect)(()=>{let e=x.current,t=b.current;if(!e||!t||![...t.querySelectorAll(`[data-transcript-source-id]`)].some(t=>t.dataset.transcriptSourceId===e.targetStartId))return;let n=()=>{lw(t,e.anchor,e=>{e!==0&&window.scrollBy({top:e,left:0,behavior:`auto`})});let n=0;return lw(t,e.anchor,e=>{n=e}),n},r=n();if(uw({remaining:r,scrollY:window.scrollY,maxScrollY:Math.max(0,document.documentElement.scrollHeight-window.innerHeight),alreadyReserved:e.reserved===!0})===`reserve`){e.reserved=!0,y(e=>e+Math.ceil(r));return}C.current||(C.current=!0,requestAnimationFrame(()=>{n(),requestAnimationFrame(()=>{n(),x.current=null,C.current=!1,S.current&&(S.current=!1,d7())})}))},[v,F,m]),(0,L.useEffect)(()=>{let e=k?.transcriptKey;if(!e)return;let t=w.current;w.current=e,!(!t||t===e)&&(h(null),y(0),d(!1),x.current=null,C.current=!1,S.current&&(S.current=!1,d7()))},[k?.transcriptKey]),(0,L.useEffect)(()=>()=>{S.current&&(S.current=!1,d7())},[]);let Pe=e=>{let t=sw(b.current);!e||!t||(S.current||(S.current=!0,u7()),x.current={anchor:t,targetStartId:e})},Fe=async()=>{if(g||!Ne)return;let t=tw(F,ve),n=t!==null&&F[t]?.role===`user`?t:null;if(n!==null){let e=F[n].sourceId;Pe(e),h(e??null);return}let r=k?.beforeCursor;if(!r){if(ve>0){let e=F[0]?.sourceId;Pe(e),h(e??null)}return}let i=k?.transcriptKey;if(i){_(!0);try{let t=await Y.threadTranscriptEarlier({slug:e.id,cursor:r}),n=T.getQueryData([`transcript`,e.id]);if(!n?.transcriptKey||n.transcriptKey!==i||t.transcriptKey!==i){await D.refetch(),h(null),Z(`Transcript changed while loading history; refreshed the current session`);return}let a=t.messages[0]?.sourceId??F[0]?.sourceId;Pe(a);let o=ow(n,t);T.setQueryData([`transcript`,e.id],o),h(a??null)}catch(e){await D.refetch(),h(null),Z(e instanceof Error?e.message:`Could not load earlier transcript history`)}finally{_(!1)}}},Ie=pt({mutationFn:()=>Y.markComplete({slug:e.id})}),{answeringForMessage:Le,answerable:Re,anyAnswered:ze,sendAnswers:Be,sendMessage:Ve}=I1(e.id,F,()=>{document.activeElement?.blur(),r(e.id)},{scrollToBottom:!1,onSendFailed:()=>i(e.id)}),He=(0,L.useMemo)(()=>{let e=P1(F);return e!==-1&&W$(F[e].text,je.get(e)??[])},[F,je]),Ue=Ae&&(Re&&!He||ze),We=(0,L.useCallback)(()=>r(e.id),[r,e.id]),Ge=(0,L.useCallback)(()=>i(e.id),[i,e.id]),Ke=te>=0?F[te]?.text:void 0,Je={thread:e,showWorking:I,registeredDone:WQ(e,Ke),restedCard:l$(e,Ke,De),errorVisible:d$(ye,e.providerError)},Ye=$8(Je),Xe=(0,L.useMemo)(()=>f2(F),[F]),Ze=(0,L.useMemo)(()=>({dismiss:We,cancel:Ge}),[We,Ge]);return(0,R.jsx)(z8.Provider,{value:e.id,children:(0,R.jsx)(H8.Provider,{value:Ze,children:(0,R.jsx)(O0,{thread:e,children:(0,R.jsxs)(`div`,{ref:A,"data-queue-card-root":e.id,"data-queue-leaving":t,style:{...v?{marginBottom:v}:null,...s.vtReturnTarget===e.id?{viewTransitionName:`thread-chat`}:null},onKeyDown:e=>{if(!ze)return;let t=e.target;t instanceof HTMLButtonElement||t instanceof HTMLAnchorElement||t instanceof HTMLTextAreaElement&&t.value.trim()||gz({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(),Be())},"data-vt-chat":!0,className:`flex flex-col min-w-0 max-w-full ${KQ} border border-border-strong bg-panel shadow-lg shadow-shadow-ink/25 transition-opacity ${f?`opacity-40`:``}`,children:[(0,R.jsxs)(`div`,{className:`flex flex-col min-w-0 ${c?``:`mb-[calc(-1*var(--queue-card-header-h,0px))]`}`,children:[(0,R.jsxs)(`div`,{ref:M,className:`sticky top-0 z-10 flex items-center gap-2 bg-panel px-5 py-3.5 max-[800px]:top-10 ${c?KQ:`${qQ} border-b border-border/60`}`,children:[(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(M4,{thread:e,className:`leading-snug`}),(0,R.jsx)(A4,{thread:e}),e.statusText&&e.status===`needs-human`&&(0,R.jsx)(`div`,{className:`text-[11px] text-muted-80 mt-0.5 truncate`,title:e.statusText,children:e.statusText})]}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[e.kind===`session`&&e.foreign!==!0&&(0,R.jsx)(d8,{slug:e.id}),(0,R.jsx)(m4,{thread:e,collapsed:c,onCollapse:()=>l(e=>!e),expand:!0,onDone:()=>Ie.mutate(void 0,{onSuccess:()=>r(e.id),onError:()=>p(!1)}),doneBusy:Ie.isPending,onStatusMutate:()=>p(!0),onStatusApplied:()=>r(e.id),onStatusFailed:()=>p(!1)}),(0,R.jsx)(Aq,{thread:e,onArchived:()=>r(e.id),onDismissCancel:()=>i(e.id),onSnoozed:()=>r(e.id)})]})]}),c?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`px-5 pt-5 ${Ue?`pb-2`:`pb-5`}`,children:[D.transportFallback&&(0,R.jsx)(Q8,{fallback:D.transportFallback,isFetching:D.isFetching,onRefresh:()=>void D.refetch(),onRetryLive:D.retryLiveUpdates,className:`mb-3.5`}),F.length===0?(0,R.jsx)(`p`,{className:`text-[13px] text-muted`,children:D.isLoading?`Loading…`:e.statusText||`No message yet.`}):(0,R.jsxs)(`div`,{ref:b,className:`flex flex-col`,children:[Ne&&(0,R.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 Fe(),onMouseDown:e=>e.preventDefault(),disabled:g,children:g?`Loading earlier messages…`:k?.reachedTurnBoundary===!1?`Continue loading this turn`:`Load earlier messages`}),(()=>{let t=ve,n=[],r,i=e=>r?_5(r,e):h5(e)?22:14,a=[...Oe.byAnchor.entries()].sort((e,t)=>e[0]-t[0]),o=[...ke.anchored.entries()].filter(([e])=>e>=t).sort((e,t)=>e[0]-t[0]),s=e=>{for(;o.length>0&&o[0][0]<=e;){let[e,t]=o.shift();r!==void 0&&n.push((0,R.jsx)(e1,{h:14},`sq-space-${e}`)),n.push((0,R.jsx)(D0,{questions:t,wrap:!0},`sq-${e}`)),r=null}},c=t=>{for(s(t);a.length>0&&a[0][0]<=t;){let[t,i]=a.shift();r!==void 0&&n.push((0,R.jsx)(e1,{h:14},`qa-space-${t}`)),n.push((0,R.jsx)(A0,{thread:e,questions:i,showSend:Oe.sendAnchors.has(t)},`qa-${t}`)),r=null}};c(t-1);let l=new Set,u=!1;return xe.forEach(({message:t,messageIndex:a},o)=>{if(t.queued||v5(t,...ae(a))||t.boundary===`rest`)return;if(_e&&me&&a>=me.start&&a<=me.end){u||(u=!0,c(a-1),r!==void 0&&n.push((0,R.jsx)(e1,{h:14},`middle-runs-space`)),n.push((0,R.jsx)(Ire,{runs:me.runs,toolCount:me.tools,onExpand:()=>d(!0)},`middle-runs-summary`)),r=null);return}let s=_e?ge.get(a):void 0,f=s===void 0?void 0:he[s],p=f!==void 0,m=f!==void 0&&a===f.open,h=f!==void 0&&a===f.close,g=p&&!m&&!h&&!wQ(t.text)&&!i7(t)&&a7(t,a,ue);if(f!==void 0&&a===f.waker){c(a-1),r!==void 0&&n.push((0,R.jsx)(e1,{h:i(t)},`s${o}`));let e=t.sourceId??`legacy-${a}`;n.push((0,R.jsx)(`div`,{"data-transcript-source-id":e,className:`flex flex-col`,children:(0,R.jsx)(H5,{m:t,dense:!0})},e)),r=t;return}if(p&&!g){if(!m&&!h&&!a7(t,a,ue))return;let u=m&&h,p=()=>{s===void 0||l.has(s)||(r!==void 0&&n.push((0,R.jsx)(e1,{h:14},`im-space-${s}`)),n.push((0,R.jsx)(Lre,{toolCount:f.tools,onExpand:()=>d(!0)},`intermediate-summary-${s}`)),r=null,l.add(s))};if((!m||u&&f.hiddenBeforeOpen)&&p(),!C5(t,...ae(a)))return;c(a-1);let g=jre(t);r!==void 0&&n.push((0,R.jsx)(e1,{h:i(g)},`s${o}`));let _=t.sourceId??`legacy-${a}`;n.push((0,R.jsx)(`div`,{"data-transcript-source-id":_,className:`flex flex-col`,children:(0,R.jsx)(H5,{m:t,dense:!0,textOnly:!0,answering:Ae?Le(t):void 0,paired:oe[a],staleAwaiting:re(a),restingCardShown:a===te&&ie,shadowedBy:je.get(a),placed:Ee.placed.get(a),settledPlaced:ke.placed.get(a),thread:e})},_)),r=g,u&&p(),c(a);return}c(a-1),r!==void 0&&n.push((0,R.jsx)(e1,{h:i(t)},`s${o}`));let _=t.sourceId??`legacy-${a}`;n.push((0,R.jsx)(`div`,{"data-transcript-source-id":_,className:`flex flex-col`,children:(0,R.jsx)(H5,{m:t,dense:!0,staleAwaiting:re(a),restingCardShown:a===te&&ie,answering:Ae?Le(t):void 0,paired:oe[a],shadowedBy:je.get(a),placed:Ee.placed.get(a),settledPlaced:ke.placed.get(a),thread:e})},_)),r=t,c(a)}),c(1/0),n})()]}),!D.isLoading&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(P3,{thread:e,className:`mt-4`}),Ye!==null&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(e1,{h:e5(Je,xe.map(e=>e.message))}),(0,R.jsx)(t5,{state:Je,slug:e.id,retryText:Xe>=0?F[Xe]?.text:void 0,onTerminal:E,liveRuntimeStart:Te,liveActivityLabel:we,liveToolRun:Se,onRestingExit:We,onRestingExitFailed:Ge,wrap:!0})]}),e.permPolicy?(0,R.jsxs)(R.Fragment,{children:[Ye===null&&(0,R.jsx)(e1,{}),(0,R.jsx)(`div`,{className:Ye===null?``:`mt-3`,children:(0,R.jsx)(q5,{policy:e.permPolicy,denies:e.permDenies})})]}):null,ye.map((e,t)=>e.queued?(0,R.jsxs)(L.Fragment,{children:[(0,R.jsx)(e1,{}),(0,R.jsx)(H5,{m:e,dense:!0,paired:oe[ve+t]})]},`q${ve+t}`):null)]})]}),(0,R.jsx)(A0,{thread:e,questions:Oe.tail,inFlight:Me,showSend:Oe.tailSend,className:`shrink-0 px-5 pb-4 pt-0`}),Ue&&(0,R.jsx)(`div`,{className:`shrink-0 px-5 pt-0`,children:(0,R.jsx)(`div`,{className:`mb-4 flex items-center justify-start gap-2`,children:(0,R.jsx)(`button`,{disabled:!ze,onClick:()=>Be(),onMouseDown:e=>e.preventDefault(),className:`button-outline 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`})})})]})]}),c?null:(0,R.jsx)(e4,{slug:e.id,surface:`queueComposer`,className:`sticky bottom-0 z-10 mt-[var(--queue-card-header-h,0px)] shrink-0 ${JQ} border-t border-border/60 bg-panel px-5 pb-3 pt-3 shadow-[0_-12px_18px_-14px_var(--dock-shadow)]`,submitOverride:Ve,above:(0,R.jsx)(a4,{thread:e,transcriptShells:P})})]})})})})},zre);function zre(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))}var Bre=[{token:`repo`,gloss:`repository`},{token:`n`,gloss:`number`},{token:`title`,gloss:`title`},{token:`url`,gloss:`link`},{token:`labels`,gloss:`labels`},{token:`body`,gloss:`description`}];function Vre({draft:e,onChange:t,rows:n}){let r=ct({queryKey:[`githubPromptDefaults`],queryFn:()=>Y.githubPromptDefaults()});return r.data?(0,R.jsx)(Ure,{label:`Issue and PR triage prompt`,help:KB.githubPrompt,value:e.githubPrompt,fallback:r.data.prompt,rows:n,onChange:(n,r)=>t({...e,githubPrompt:n},r)}):(0,R.jsx)(`div`,{className:`text-[12px] text-muted`,children:`Loading defaults…`})}function Hre(){let[e,t]=(0,L.useState)(!1),n=(0,L.useRef)(void 0);function r(e){n.current?.(),n.current=void 0,e&&(n.current=fB(()=>r(!1))),t(e)}return(0,R.jsxs)(CV,{open:e,onOpenChange:r,children:[(0,R.jsx)(wV,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] transition-colors ${e?`text-accent`:`text-muted hover:text-accent`}`,children:`Tokens`})}),(0,R.jsxs)(EV,{side:`top`,align:`end`,className:`w-56 p-3`,children:[(0,R.jsx)(`div`,{className:`mb-2 text-[11px] font-medium text-fg`,children:`Substitution tokens`}),(0,R.jsx)(`ul`,{className:`flex flex-col gap-1.5`,children:Bre.map(({token:e,gloss:t})=>(0,R.jsxs)(`li`,{className:`flex items-center justify-between gap-3 text-[11px]`,children:[(0,R.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,R.jsx)(`span`,{className:`text-muted-80`,children:t})]},e))})]})]})}function Ure({label:e,help:t,value:n,fallback:r,rows:i=10,onChange:a}){return(0,R.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,R.jsx)(qB,{label:e,help:t}),(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[n!=null&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,className:`text-[11px] text-muted hover:text-accent transition-colors`,onClick:()=>a(void 0),children:`Reset to default`}),(0,R.jsx)(`span`,{"aria-hidden":!0,className:`text-[11px] text-muted-40`,children:`·`})]}),(0,R.jsx)(Hre,{})]})]}),(0,R.jsx)(`textarea`,{"data-1p-ignore":!0,value:n??r,onChange:e=>a(e.target.value===``?void 0:e.target.value,{debounce:!0}),rows:i,className:`input resize-none text-[12px] leading-relaxed font-mono-keep`,spellCheck:!1})]})}function Wre(){let[e,t]=(0,L.useState)(!1);return hB(e,()=>t(!1)),(0,R.jsxs)(CV,{modal:!0,open:e,onOpenChange:t,children:[(0,R.jsx)(wV,{asChild:!0,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Triage prompt settings`,title:`Edit the prompt every thread this picker starts will run`,onMouseDown:e=>e.preventDefault(),className:`github-prompt-trigger -ml-2 -mr-[5px] inline-flex size-6 shrink-0 self-baseline translate-y-[calc(7.5px_-_0.5cap)] items-center justify-center rounded-md text-muted-70 outline-none transition-colors hover:bg-panel-2 hover:text-fg focus-visible:bg-panel-2 focus-visible:text-fg data-[state=open]:bg-panel-2 data-[state=open]:text-fg`,children:(0,R.jsx)(Q_,{"aria-hidden":`true`,size:15})})}),(0,R.jsx)(EV,{side:`bottom`,align:`end`,sideOffset:6,className:`w-[560px] max-w-[calc(100vw-1rem)] p-4`,"data-github-prompt-menu":``,children:(0,R.jsx)(Gre,{})})]})}function Gre(){let{draft:e,update:t,saveState:n}=SB();return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,R.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,R.jsx)(`span`,{className:`text-[12px] font-medium text-fg`,children:`Picker settings`}),(0,R.jsx)(CB,{state:n})]}),e?(0,R.jsx)(Vre,{draft:e,onChange:t,rows:14}):(0,R.jsx)(`div`,{className:`text-[12px] text-muted`,children:`Loading…`})]})}function Kre(e,t,n=[]){if(e.backend===`acp`){let t=n.find(t=>t.id===wu(e.model));return t?t.available?void 0:`${t.label} is not installed on this machine`:`ACP agent ${e.model} is not in the catalogue`}if(!e.effort)return`Reasoning level is required for ${e.model}`;if(e.backend===`claude`)return FB.some(t=>t.value===e.model)?VB(e.model).includes(e.effort)?void 0:`Reasoning level ${e.effort} is not available for ${e.model}`:`Claude model ${e.model} is no longer available`;let r=t.find(t=>t.slug===e.model);if(!r)return`Codex model ${e.model} is no longer available`;if(!r.efforts.includes(e.effort))return`Reasoning level ${e.effort} is not available for ${e.model}`}function qre(e,t){return{items:t.map(e=>({...e})),backend:e.backend,model:e.model,effort:e.effort}}function Jre({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 Yre=/^(?:#)?([0-9a-f]{6})$/i;function Xre(e){let t=Yre.exec(e.trim());return t?`#${t[1].toLowerCase()}`:void 0}function f7(e){let t=Xre(e)??`var(--color-muted)`;return{foreground:`color-mix(in srgb, var(--color-fg) var(--gh-label-fg-mix), ${t})`,background:`color-mix(in srgb, ${t} var(--gh-label-bg-mix), var(--gh-label-bg-base))`,border:`color-mix(in srgb, ${t} var(--gh-label-border-mix), var(--gh-label-border-base))`}}var Zre=30;function Qre({onClose:e}){let t=Wz(),{resolved:n,codexList:r,claudeList:i,acpList:a,loadError:o,saveProfile:s}=uH(),c=ut({mutationKey:[...bB]})>0,[l,u]=(0,L.useState)(`issues`),[d,f]=(0,L.useState)(`recent`),[p,m]=(0,L.useState)(1),[h,g]=(0,L.useState)(()=>new Set),[_,v]=(0,L.useState)(null),y=ct({queryKey:[`githubList`,l,d,p],queryFn:()=>Y.githubList({kind:l,sort:d,page:p,perPage:Zre}),placeholderData:ae}),b=y.data?.items??[],x=y.data?.page??p,S=y.data?.pageCount??1,C=y.data?.total??0,w=(0,L.useRef)(null);(0,L.useEffect)(()=>{w.current&&(w.current.scrollTop=0)},[p,l,d]);let T=pt({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 E(e){e!==l&&(u(e),m(1),g(new Set),v(null))}function D(e){e!==d&&(f(e),m(1),g(new Set),v(null))}function O(e,t){let n=Jre({keys:b.map(e=>e.number),key:e,shiftKey:t,anchor:_,selected:h});g(n.selected),v(n.anchor)}function k(){g(new Set),v(null)}let A=h.size,j=(0,L.useMemo)(()=>cH(r,a,i),[r,a,i]),M=n?.acpAgentId?a.find(e=>e.id===n.acpAgentId):void 0,N=n?{backend:n.backend,model:n.model,effort:n.effort||void 0}:void 0,P=N?Kre(N,r,a):o?`Could not load the model catalogue — reopen once it loads`:void 0,F=P??(c?`Saving settings…`:N?void 0:`Loading the model catalogue…`);function I(){if(!N||F){Z(F??`Choose a model and reasoning level`);return}T.mutate(qre(N,[...h].map(e=>({kind:l===`issues`?`issue`:`pr`,number:e}))))}return(0,R.jsx)(NH,{onClose:e,children:(0,R.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-shadow-ink/50`,onKeyDownCapture:t=>{t.key===`Escape`&&(t.stopPropagation(),e())},children:[(0,R.jsxs)(`h2`,{className:`mb-4 flex items-baseline gap-2 text-[14px] font-medium`,children:[(0,R.jsx)(E_,{size:15,"aria-hidden":`true`,className:`shrink-0 self-baseline translate-y-[calc(7.5px_-_0.5cap)] text-muted`}),(0,R.jsx)(`span`,{className:`min-w-0 truncate`,children:`Investigate this issue and make recommendations`}),(0,R.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-baseline gap-2`,children:[t.data?.nameWithOwner&&(0,R.jsx)($re,{nameWithOwner:t.data.nameWithOwner}),(0,R.jsx)(Wre,{})]})]}),(0,R.jsxs)(`div`,{className:`mb-3 flex items-center justify-between gap-3`,children:[(0,R.jsx)(m7,{value:l,onChange:e=>E(e),options:[{value:`issues`,label:`Issues`},{value:`prs`,label:`PRs`}]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`petite-caps text-[11px] text-muted-70`,children:`Sort`}),(0,R.jsx)(m7,{value:d,onChange:D,options:[{value:`recent`,label:`Recent`},{value:`reactions`,label:`Reactions`}]})]})]}),(0,R.jsx)(`div`,{ref:w,className:`min-h-[240px] flex-1 overflow-y-auto rounded-lg border border-border/70 bg-bg/40 transition-opacity ${y.isPlaceholderData?`opacity-40`:``}`,children:y.isLoading?(0,R.jsx)(oie,{}):y.isError?(0,R.jsxs)(_7,{children:[(0,R.jsxs)(`span`,{className:`text-[12.5px] text-muted-80`,children:[`Couldn't load `,l===`issues`?`issues`:`pull requests`,`.`]}),(0,R.jsx)(`span`,{className:`max-w-[80%] text-center text-[11px] text-muted-45`,children:y.error.message.slice(0,140)})]}):b.length===0?(0,R.jsxs)(_7,{children:[(0,R.jsx)(A_,{size:28,strokeWidth:1.25,className:`text-muted-30`}),(0,R.jsxs)(`span`,{className:`text-[12.5px] text-muted-60`,children:[`No open `,l===`issues`?`issues`:`pull requests`]})]}):b.map(e=>(0,R.jsx)(nie,{item:e,checked:h.has(e.number),onActivate:t=>O(e.number,t)},e.number))}),!y.isLoading&&!y.isError&&(0,R.jsxs)(`div`,{className:`mt-2.5 flex items-center justify-between gap-3 whitespace-nowrap text-[11.5px] text-muted-60`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.jsxs)(`span`,{className:`truncate tabular-nums`,children:[C,` open `,l===`issues`?C===1?`issue`:`issues`:C===1?`pull request`:`pull requests`]}),A>0&&(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,R.jsx)(`span`,{className:`text-muted-30`,children:`·`}),(0,R.jsxs)(`span`,{className:`tabular-nums text-fg/70`,children:[A,` selected`]}),(0,R.jsx)(`button`,{onClick:k,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`})]})]}),S>1&&(0,R.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1`,children:[(0,R.jsx)(p7,{label:`Previous page`,disabled:x<=1,onClick:()=>m(Math.max(1,x-1)),children:(0,R.jsx)(n_,{size:14})}),(0,R.jsxs)(`span`,{className:`relative px-2 text-center tabular-nums`,children:[(0,R.jsxs)(`span`,{"aria-hidden":!0,className:`invisible`,children:[`Page `,S,` of `,S]}),(0,R.jsxs)(`span`,{className:`absolute inset-0`,children:[`Page `,x,` of `,S]})]}),(0,R.jsx)(p7,{label:`Next page`,disabled:x>=S,onClick:()=>m(Math.min(S,x+1)),children:(0,R.jsx)(r_,{size:14})})]})]}),(0,R.jsxs)(`div`,{className:`mt-4 flex items-end justify-between gap-3`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-0.5`,children:[(0,R.jsx)(YV,{groups:j,agentSettings:!0,value:n?{provider:n.backend,model:n.pickerModel,effort:n.effort}:void 0,onValueChange:e=>s({field:`profile`,backend:e.provider,model:e.model,effort:e.effort}),placeholder:o?`Profile unavailable`:`Profile loading…`,ariaLabel:`Model and effort`,title:F??`Model and reasoning effort for every thread this batch starts`,disabled:!n,side:`top`,menuZClass:jP,className:`max-w-[min(21rem,60vw)]`}),M&&(0,R.jsx)($V,{agentId:M.id,agentLabel:M.label,modelId:n?.acpModelId,onValueChange:e=>s({field:`model`,backend:`acp`,value:Su(M.id,e)}),side:`top`,menuZClass:`z-[250]`,className:`max-w-[min(14rem,30vw)] px-2 py-1`})]}),P&&(0,R.jsx)(`p`,{className:`mt-1 max-w-[430px] text-[10.5px] text-danger`,children:P})]}),(0,R.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,R.jsxs)(`button`,{disabled:A===0||T.isPending||!!F,onClick:I,onMouseDown:e=>e.preventDefault(),className:`button-outline 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:[T.isPending&&(0,R.jsx)(M_,{size:13,className:`animate-spin`}),A<=1?`Start investigation`:`Start ${A} investigations`]})})]})]})})}function $re({nameWithOwner:e}){return(0,R.jsxs)(`a`,{href:`https://github.com/${e}`,target:`_blank`,rel:`noreferrer noopener`,title:`Open ${e} on GitHub`,className:`github-repo-link inline-flex min-w-0 items-baseline gap-1 rounded-sm font-mono-keep text-[12.5px] font-normal text-muted outline-none transition-colors hover:text-fg focus-visible:text-fg`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:e}),(0,R.jsx)(pee,{"aria-hidden":`true`,className:`-ml-[0.29em] size-[1em] shrink-0 self-baseline translate-y-[calc(0.5em_-_0.5cap)]`})]})}function p7({label:e,disabled:t,onClick:n,children:r}){return(0,R.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 m7({value:e,onChange:t,options:n}){return(0,R.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,R.jsx)(`button`,{onClick:()=>t(n.value),"aria-pressed":e===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-shadow-ink/20`:`text-muted hover:text-fg`}`,children:n.label},n.value))})}function eie({item:e}){let t=(e.state??`OPEN`).toUpperCase();return e.kind===`pr`?t===`MERGED`?(0,R.jsx)(S_,{size:15,className:`shrink-0`,style:{color:ZO.fgDone}}):t===`CLOSED`?(0,R.jsx)(C_,{size:15,className:`shrink-0`,style:{color:ZO.fgDanger}}):e.isDraft?(0,R.jsx)(w_,{size:15,className:`shrink-0`,style:{color:ZO.fgNeutral}}):(0,R.jsx)(T_,{size:15,className:`shrink-0`,style:{color:ZO.fgSuccess}}):t===`CLOSED`?(0,R.jsx)(s_,{size:15,className:`shrink-0`,style:{color:ZO.fgDone}}):(0,R.jsx)(l_,{size:15,className:`shrink-0`,style:{color:ZO.fgSuccess}})}function tie({name:e,color:t}){let n=f7(t);return(0,R.jsx)(`span`,{className:`max-w-[130px] shrink-0 truncate rounded-full border px-1.5 py-px text-[9.5px] leading-[13px]`,style:{borderColor:n.border,color:n.foreground,backgroundColor:n.background},title:e,children:e})}function nie({item:e,checked:t,onActivate:n}){let r=DO(e.createdAt)??``,i=[e.author,r?`opened ${r}`:``].filter(Boolean).join(` `);return(0,R.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-hover`,children:[(0,R.jsx)(`span`,{className:`mt-px shrink-0`,children:(0,R.jsx)(rie,{checked:t})}),(0,R.jsx)(`span`,{className:`mt-px`,children:(0,R.jsx)(eie,{item:e})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.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,R.jsx)(tie,{name:e.name,color:e.color},e.name))]}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1 text-[11px] text-muted-55`,children:[(0,R.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,R.jsxs)(`span`,{className:`truncate`,children:[`· `,i]}):null]})]}),(0,R.jsxs)(`span`,{className:`mt-px flex shrink-0 items-center gap-2.5 text-[11.5px] text-muted-70`,children:[e.linkedPrs?(0,R.jsx)(aie,{prs:e.linkedPrs}):null,e.comments?(0,R.jsx)(g7,{icon:F_,n:e.comments,label:`comments`}):null,e.reactions?(0,R.jsx)(g7,{emoji:`👍`,n:e.reactions,label:`reactions`}):null]})]})}function rie({checked:e}){return(0,R.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,R.jsx)(e_,{size:11,strokeWidth:3,className:`text-bg`})})}var h7={octicon:`-0.1em`,stroke:`-0.112em`};function iie({size:e=12,className:t}){return(0,R.jsx)(`svg`,{viewBox:`0 0 16 16`,width:e,height:e,fill:`currentColor`,"aria-hidden":!0,className:t,style:{transform:`translateY(${h7.octicon})`},children:(0,R.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 aie({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,R.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,R.jsx)(iie,{size:12}),e.count]})}function g7({icon:e,emoji:t,n,label:r}){return(0,R.jsxs)(`span`,{className:`inline-flex items-center gap-1 tabular-nums`,title:`${n} ${r}`,children:[t?(0,R.jsx)(`span`,{"aria-hidden":!0,className:`text-[11px] leading-none`,children:t}):e?(0,R.jsx)(`span`,{className:`inline-flex`,style:{transform:`translateY(${h7.stroke})`},children:(0,R.jsx)(e,{size:12,strokeWidth:2})}):null,n]})}function oie(){return(0,R.jsx)(`div`,{className:`animate-pulse`,children:Array.from({length:6}).map((e,t)=>(0,R.jsxs)(`div`,{className:`flex items-center gap-3 border-b border-border/40 px-3 py-2.5 last:border-b-0`,children:[(0,R.jsx)(`span`,{className:`h-[15px] w-[15px] shrink-0 rounded-[4px] bg-muted/20`}),(0,R.jsx)(`span`,{className:`h-3 w-8 shrink-0 rounded bg-muted/20`}),(0,R.jsx)(`span`,{className:`h-3 flex-1 rounded bg-muted/15`,style:{maxWidth:`${55+t*7%35}%`}})]},t))})}function _7({children:e}){return(0,R.jsx)(`div`,{className:`flex h-full min-h-[240px] flex-col items-center justify-center gap-1.5`,children:e})}var sie=`/_frizz/control/sign-out`;function v7(e){return e?.remoteSession===!0}function cie(e,t){return t.result===`signed-out`||t.result===`cookie-cleared`?!0:e===401}async function lie(e=fetch){let t=await e(sie,{method:`POST`,headers:{"cache-control":`no-store`},credentials:`same-origin`}),n;try{n=await t.json()}catch{}if(!(n?.protocol===1&&(n.result===`signed-out`||n.result===`cookie-cleared`||n.result===`no-remote-session`))||!n)throw Error(`This Frizz cannot sign a device out from the browser`);return{signedOut:cie(t.status,n),result:n}}function uie(e=window.location){e.replace(`/`)}function die({className:e=``}){let t=RU(),[n,r]=(0,L.useState)(!1),i=pt({mutationFn:async()=>{let e=await lie();if(!e.signedOut)throw Error(`This browser has no remote session to sign out`);return e},onSuccess:()=>uie()});if(!v7(t.data))return null;let a=i.error instanceof Error?i.error.message:i.error?String(i.error):null,o=i.isPending||i.isSuccess;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,"data-sign-out-this-device":!0,onClick:()=>r(!0),className:`flex min-h-[52px] w-full items-center border-y border-border px-[18px] text-left text-[15.5px] text-danger outline-none active:bg-danger-fill/10 ${e}`,children:`Sign out this device`}),(0,R.jsx)(Oq,{open:n,onOpenChange:e=>{o||r(e)},title:`Sign out this device?`,className:`w-[390px] max-w-[92vw]`,footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>r(!1),className:`button-outline 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,R.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>i.mutate(),className:`button-outline rounded-md bg-danger-button/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?`Signing out…`:`Sign out`})]}),children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-2 p-4 text-[12.5px] leading-relaxed text-muted`,children:[(0,R.jsx)(`p`,{children:`This browser will need a new access link to open Frizz again. Your other devices stay signed in.`}),a?(0,R.jsx)(`p`,{className:`text-[11.5px] text-danger`,children:a}):null]})})]})}function fie(){return typeof Notification>`u`?`unsupported`:Notification.permission}function y7({offerUpdate:e=!1}={}){let{draft:t,update:n,saveState:r,flush:i}=SB(),a=Lg(),[o,s]=(0,L.useState)(fie()),[c,l]=(0,L.useState)(!1),[u,d]=(0,L.useState)(!1);(0,L.useEffect)(()=>{let e=requestAnimationFrame(()=>l(!0));return()=>cancelAnimationFrame(e)},[]),(0,L.useEffect)(()=>(Ap(f),()=>Ap(null)),[]);function f(){u||(i(),d(!0),l(!1),window.setTimeout(()=>X.showSettings=!1,Ah()?0:210))}async function p(e){if(t){if(e&&typeof Notification<`u`&&Notification.permission==="default"){let e=await Notification.requestPermission();s(e)}n({...t,notifications:e})}}return a?(0,R.jsx)(gie,{shown:c,onClose:f,saveState:r,notifications:t?t.notifications:null,onNotifications:p,perm:o,offerUpdate:e}):(0,R.jsx)(`div`,{className:`${Dh} z-50 flex justify-end ${c?`opacity-100`:`opacity-0`}`,onMouseDown:e=>e.target===e.currentTarget&&f(),children:(0,R.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,className:`${Oh} w-[560px] max-w-[94vw] ${c?`translate-x-0`:`translate-x-full`}`,children:[(0,R.jsx)(fv,{title:`Settings`,actions:(0,R.jsx)(CB,{state:r}),onClose:f}),(0,R.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-5 flex flex-col gap-6`,children:[(0,R.jsx)(JB,{label:`Appearance`,help:KB.appearance,children:(0,R.jsx)(yie,{})}),t?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(JB,{label:`Project sidebar`,help:KB.projectRail,children:(0,R.jsx)(C7,{value:t.projectRail,onChange:e=>n({...t,projectRail:e})})}),(0,R.jsx)(JB,{label:`Density`,help:KB.density,children:(0,R.jsx)(xie,{})}),(0,R.jsx)(JB,{label:`Queue order`,help:KB.queueOrder,children:(0,R.jsx)(Sie,{})}),(0,R.jsx)(JB,{label:`Dictation`,help:KB.dictation,children:(0,R.jsx)(bie,{})}),(0,R.jsxs)(JB,{label:`Desktop notifications`,help:KB.notifications,children:[(0,R.jsx)(C7,{value:t.notifications,onChange:p}),t.notifications&&(0,R.jsx)(w7,{perm:o})]}),(0,R.jsx)(JB,{label:`Local file links`,help:KB.localFileOpener,children:(0,R.jsx)(FV,{variant:`bordered`,value:t.localFileOpener??`system`,onValueChange:e=>n({...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,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading server settings…`})]})]})})}var pie={open:{dot:`bg-live`,word:`Connected`},connecting:{dot:`bg-muted`,word:`Connecting…`},closed:{dot:`bg-danger-fill`,word:`Disconnected`}},b7=`flex min-h-[52px] items-center gap-3 border-b border-border/70 px-[18px] text-[15.5px] text-fg`;function x7({label:e,children:t}){return(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h2`,{className:`m-0 px-[18px] pb-1.5 pt-[18px] text-[12.5px] font-semibold leading-[17px] text-muted`,children:e}),(0,R.jsx)(`div`,{className:`border-t border-border/70`,children:t})]})}function S7({label:e,value:t,options:n,onChange:r,data:i}){let a=n.find(e=>e.value===t)?.label??t;return(0,R.jsxs)(`label`,{"data-mobile-setting":i,className:`${b7} relative`,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e}),(0,R.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1 text-[14px] text-muted`,children:[a,(0,R.jsx)(r_,{size:15,"aria-hidden":!0,className:`-ml-[3px] -mr-[5px]`})]}),(0,R.jsx)(`select`,{"aria-label":e,value:t,onChange:e=>r(e.target.value),className:`absolute inset-0 cursor-pointer appearance-none opacity-0`,children:n.map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function mie(){let e=(0,L.useSyncExternalStore)(A2,O2,O2),t=[{value:`system`,label:`System`},{value:`dark`,label:`Dark`},{value:`light`,label:`Light`}];return(0,R.jsx)(`div`,{role:`radiogroup`,"aria-label":`Theme`,className:`flex shrink-0 rounded-[9px] border border-border-strong`,children:t.map((n,r)=>(0,R.jsx)(`button`,{role:`radio`,"aria-checked":e.preference===n.value,onClick:()=>k2(n.value),className:`relative h-[30px] px-[11px] text-[13px] after:absolute after:inset-x-0 after:-inset-y-[7px] after:content-[''] ${r>0?`border-l border-border-strong`:``} ${r===0?`rounded-l-[8px]`:``} ${r===t.length-1?`rounded-r-[8px]`:``} ${e.preference===n.value?`bg-fg text-bg`:`text-muted`}`,children:n.label},n.value))})}function hie({checked:e,disabled:t,label:n,onChange:r}){return(0,R.jsx)(`button`,{role:`switch`,"aria-checked":e,"aria-label":n,disabled:t,onClick:()=>r(!e),className:`relative h-6 w-10 shrink-0 rounded-full after:absolute after:-inset-x-2 after:-inset-y-[10px] after:content-[''] disabled:opacity-45 ${e?`bg-fg`:`bg-border-strong`}`,children:(0,R.jsx)(`span`,{className:`absolute top-[3px] size-[18px] rounded-full ${e?`right-[3px] bg-bg`:`left-[3px] bg-muted`}`})})}function gie({shown:e,onClose:t,saveState:n,notifications:r,onNotifications:i,perm:a,offerUpdate:o}){let{connection:s}=gr(X),{queueOrder:c,snoozePreset:l}=gr(RD),u=pie[s],d=RU(),f=d.data?.version;return(0,R.jsxs)(`div`,{"data-mobile-settings-page":!0,role:`dialog`,"aria-modal":`true`,"aria-label":`Settings`,className:`fixed inset-0 z-50 flex flex-col bg-bg pt-[env(safe-area-inset-top)] transition-transform duration-200 ease-out motion-reduce:transition-none ${e?`translate-x-0`:`translate-x-full`}`,children:[(0,R.jsxs)(`header`,{className:`flex h-[56px] shrink-0 items-center gap-0.5 border-b border-border/70 pl-0.5 pr-[18px]`,children:[(0,R.jsx)(`button`,{"aria-label":`Back`,onClick:t,className:`flex size-[44px] shrink-0 items-center justify-center rounded-full text-fg/85 active:bg-hover-strong`,children:(0,R.jsx)(Yg,{size:21,strokeWidth:2.1})}),(0,R.jsx)(`h1`,{className:`m-0 min-w-0 flex-1 truncate pl-0.5 text-[16.5px] font-semibold tracking-[-0.01em] text-fg`,children:`Settings`}),(0,R.jsx)(CB,{state:n})]}),(0,R.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto pb-[env(safe-area-inset-bottom)]`,children:[(0,R.jsxs)(`div`,{"data-mobile-connection":!0,className:`flex items-center gap-2 px-[18px] pb-1 pt-[14px] text-[14px] leading-[20px] text-fg`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`size-2 shrink-0 rounded-full ${u.dot}`}),(0,R.jsxs)(`span`,{className:`min-w-0 truncate`,children:[u.word,s===`open`?` · ${location.host}`:null]})]}),(0,R.jsx)(`div`,{className:`px-[18px] pb-1 pt-2.5`,children:(0,R.jsx)(aU,{})}),(0,R.jsx)(x7,{label:`Appearance`,children:(0,R.jsxs)(`div`,{className:b7,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Theme`}),(0,R.jsx)(mie,{})]})}),(0,R.jsxs)(x7,{label:`Queue`,children:[(0,R.jsx)(S7,{data:`queue-order`,label:`Order`,value:c,options:[{value:`fifo`,label:`Oldest first`},{value:`lifo`,label:`Newest first`}],onChange:e=>RD.queueOrder=e}),(0,R.jsx)(S7,{data:`snooze-length`,label:`Snooze length`,value:l,options:xD.map(e=>({value:e.value,label:e.kind===`calendar`?`Until ${e.label}, ${e.detail}`:e.label})),onChange:e=>{CD(e)&&(RD.snoozePreset=e)}}),(0,R.jsxs)(`div`,{className:b7,children:[(0,R.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:`Notifications`}),(0,R.jsx)(hie,{label:`Notifications`,checked:r===!0,disabled:r===null,onChange:i})]}),r?(0,R.jsx)(`div`,{className:`border-b border-border/70 px-[18px] py-2.5`,children:(0,R.jsx)(w7,{perm:a})}):null]}),v7(d.data)?(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h2`,{className:`m-0 px-[18px] pb-1.5 pt-[18px] text-[12.5px] font-semibold leading-[17px] text-muted`,children:`This device`}),(0,R.jsx)(die,{})]}):null,o?(0,R.jsx)(_ie,{}):null,f?(0,R.jsxs)(`div`,{"data-mobile-version":!0,className:`px-[18px] py-[14px] text-[12.5px] text-faint`,children:[`Frizz `,f]}):null]})]})}function _ie(){let e=nW();if(!e.visible)return null;let t=e.busy?e.update?`Updating…`:`Restarting…`:e.current?`Frizz is up to date`:e.update?`Update Frizz`:`Restart Frizz`,n=e.update?e.updateVersion:void 0;return(0,R.jsxs)(`div`,{"data-mobile-update":!0,children:[(0,R.jsx)(x7,{label:`Version`,children:(0,R.jsxs)(`button`,{type:`button`,"data-mobile-update-row":!0,disabled:e.busy||e.current,"aria-busy":e.busy||void 0,onClick:()=>void e.run(),className:`${b7} w-full text-left active:bg-hover disabled:text-muted`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-baseline gap-1.5`,children:[(0,R.jsx)(`span`,{className:`truncate`,children:t}),n&&!e.busy?(0,R.jsx)(`span`,{"data-mobile-update-row-notification":!0,"aria-hidden":!0,className:vie}):null]}),n&&e.version?(0,R.jsxs)(`span`,{"data-mobile-update-step":!0,className:`shrink-0 text-[14px] tabular-nums text-muted`,children:[e.version,` → `,n]}):null]})}),e.shownError?(0,R.jsx)(eW,{mobile:!0,update:e.update,message:e.shownError,outcome:e.outcome,onDismiss:e.dismiss}):null]})}var vie=`size-[5px] shrink-0 self-baseline translate-y-[calc(2.5px_-_0.5cap)] rounded-full bg-accent`;function yie(){return(0,R.jsx)(FV,{variant:`bordered`,value:(0,L.useSyncExternalStore)(A2,O2,O2).preference,onValueChange:e=>k2(e),options:[{value:`system`,label:`System`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`}],indicatorPosition:`right`,ariaLabel:`Appearance`})}function C7({value:e,onChange:t}){return(0,R.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,R.jsx)(`button`,{onClick:()=>t(n.v),"aria-pressed":e===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 bie(){let{dictation:e}=gr(RD);return(0,R.jsx)(C7,{value:e,onChange:e=>RD.dictation=e})}function xie(){let{compactDiffs:e}=gr(RD);return(0,R.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,R.jsx)(`button`,{onClick:()=>RD.compactDiffs=t.v,"aria-pressed":e===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 Sie(){let{queueOrder:e}=gr(RD);return(0,R.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,R.jsx)(`button`,{onClick:()=>RD.queueOrder=t.v,"aria-pressed":e===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 w7({perm:e}){return e===`denied`?(0,R.jsx)(wie,{}):(0,R.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 Cie(){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 wie(){let e=(0,L.useMemo)(Cie,[]),t=typeof location<`u`?location.origin:``,n=`${e===`edge`?`edge`:`chrome`}://settings/content/siteDetails?site=${encodeURIComponent(t)}`;return(0,R.jsxs)(`div`,{className:`flex flex-col gap-1 text-[11px] text-muted-70`,children:[(0,R.jsx)(`span`,{children:`Notifications are blocked for this site. Re-enable them in your browser, then reload.`}),e===`chrome`||e===`edge`?(0,R.jsx)(Eie,{url:n,hint:`Paste this into a new tab, set Notifications → Allow:`}):e===`safari`?(0,R.jsxs)(`span`,{children:[`Safari → Settings → Websites → Notifications → allow `,Tie(t),`, then reload.`]}):e===`firefox`?(0,R.jsx)(`span`,{children:`Firefox → Settings → Privacy & Security → Permissions → Notifications → Settings → allow this site.`}):(0,R.jsx)(`span`,{children:`Open this site's notification permission in your browser's settings and set it to Allow.`})]})}function Tie(e){try{return new URL(e).host}catch{return e}}function Eie({url:e,hint:t}){let[n,r]=(0,L.useState)(!1);async function i(){try{await eH(e),r(!0),window.setTimeout(()=>r(!1),1500)}catch{}}return(0,R.jsxs)(`span`,{className:`flex w-full flex-col gap-1`,children:[(0,R.jsx)(`span`,{children:t}),(0,R.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,R.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,R.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,R.jsx)(e_,{size:11,className:`text-live`}):(0,R.jsx)(m_,{size:11})})]})]})}var T7=1,Die=.9,Oie=.8,kie=.17,E7=.1,D7=.999,Aie=.9999,jie=.99,Mie=/[\\\/_+.#"@\[\(\{&]/,Nie=/[\\\/_+.#"@\[\(\{&]/g,Pie=/[\s-]/,O7=/[\s-]/g;function k7(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?T7:jie;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=k7(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=T7:Mie.test(e.charAt(l-1))?(d*=Oie,p=e.slice(i,l-1).match(Nie),p&&i>0&&(d*=D7**+p.length)):Pie.test(e.charAt(l-1))?(d*=Die,m=e.slice(i,l-1).match(O7),m&&i>0&&(d*=D7**+m.length)):(d*=kie,i>0&&(d*=D7**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=Aie)),(d<E7&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=k7(e,t,n,r,l+1,a+2,o),f*E7>d&&(d=f*E7)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function A7(e){return e.toLowerCase().replace(O7,` `)}function Fie(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,k7(e,t,A7(e),A7(t),0,0,{})}function j7(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function M7(...e){return t=>{let n=!1,r=e.map(e=>{let r=j7(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():j7(e[t],null)}}}}function Iie(...e){return L.useCallback(M7(...e),e)}function Lie(e){let t=L.forwardRef((t,n)=>{let{children:r,...i}=t,a=null,o=!1,s=[];N7(r)&&typeof P7==`function`&&(r=P7(r._payload)),L.Children.forEach(r,e=>{if(Hie(e)){o=!0;let t=e,n=`child`in t.props?t.props.child:t.props.children;N7(n)&&typeof P7==`function`&&(n=P7(n._payload)),a=zie(t,n),s.push(a?.props?.children)}else s.push(e)}),a?a=L.cloneElement(a,void 0,s):!o&&L.Children.count(r)===1&&L.isValidElement(r)&&(a=r);let c=a?Vie(a):void 0,l=Iie(n,c);if(!a){if(r||r===0)throw Error(o?Kie(e):Gie(e));return r}let u=Bie(i,a.props??{});return a.type!==L.Fragment&&(u.ref=n?l:c),L.cloneElement(a,u)});return t.displayName=`${e}.Slot`,t}var Rie=Symbol.for(`radix.slottable`),zie=(e,t)=>{if(`child`in e.props){let t=e.props.child;return L.isValidElement(t)?L.cloneElement(t,void 0,e.props.children(t.props.children)):null}return L.isValidElement(t)?t:null};function Bie(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 Vie(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 Hie(e){return L.isValidElement(e)&&typeof e.type==`function`&&`__radixId`in e.type&&e.type.__radixId===Rie}var Uie=Symbol.for(`react.lazy`);function N7(e){return typeof e==`object`&&!!e&&`$$typeof`in e&&e.$$typeof===Uie&&`_payload`in e&&Wie(e._payload)}function Wie(e){return typeof e==`object`&&!!e&&`then`in e}var Gie=e=>`${e} failed to slot onto its children. Expected a single React element child or \`Slottable\`.`,Kie=e=>`${e} failed to slot onto its \`Slottable\`. Expected \`Slottable\` to receive a single React element child.`,P7=L.use,F7=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=Lie(`Primitive.${t}`),r=L.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,R.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{}),qie=globalThis?.document?L.useLayoutEffect:()=>{},Jie=L.useId||(()=>void 0),Yie=0;function I7(e){let[t,n]=L.useState(Jie());return qie(()=>{e||n(e=>e??String(Yie++))},[e]),e||(t?`radix-${t}`:``)}var L7=`[cmdk-group=""]`,R7=`[cmdk-group-items=""]`,Xie=`[cmdk-group-heading=""]`,z7=`[cmdk-item=""]`,B7=`${z7}:not([aria-disabled="true"])`,V7=`cmdk-item-select`,H7=`data-value`,Zie=(e,t,n)=>Fie(e,t,n),U7=L.createContext(void 0),W7=()=>L.useContext(U7),G7=L.createContext(void 0),K7=()=>L.useContext(G7),q7=L.createContext(void 0),J7=L.forwardRef((e,t)=>{let n=Q7(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=Q7(()=>new Set),i=Q7(()=>new Map),a=Q7(()=>new Map),o=Q7(()=>new Set),s=X7(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=I7(),y=I7(),b=I7(),x=L.useRef(null),S=cae();Z7(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),Z7(()=>{S(6,k)},[]);let C=L.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=L.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??Zie;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(R7);t?t.appendChild(e.parentElement===t?e:e.closest(`${R7} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${R7} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${L7}[${H7}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(H7);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(L7)?.querySelector(Xie))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${z7}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(B7)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(H7))}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(H7))}function P(e){let t=A()?.closest(L7),n;for(;t&&!n;)t=e>0?oae(t,L7):sae(t,L7),n=t?.querySelector(B7);n?C.setState(`value`,n.getAttribute(H7)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},ee=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return L.createElement(F7.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&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&ee(e);break;case`ArrowUp`:ee(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(V7);t.dispatchEvent(e)}}}}},L.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:uae},c),t9(e,e=>L.createElement(G7.Provider,{value:C},L.createElement(U7.Provider,{value:w},e))))}),Qie=L.forwardRef((e,t)=>{let n=I7(),r=L.useRef(null),i=L.useContext(q7),a=W7(),o=X7(e),s=o.current?.forceMount??i?.forceMount;Z7(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=e9(n,r,[e.value,e.children,r],e.keywords),l=K7(),u=$7(e=>e.value&&e.value===c.current),d=$7(e=>s||a.filter()===!1?!0:e.search?e.filtered.items.get(n)>0:!0);L.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(V7,f),()=>t.removeEventListener(V7,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 L.createElement(F7.div,{ref:M7(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)}),$ie=L.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=I7(),s=L.useRef(null),c=L.useRef(null),l=I7(),u=W7(),d=$7(e=>i||u.filter()===!1?!0:e.search?e.filtered.groups.has(o):!0);Z7(()=>u.group(o),[]),e9(o,s,[e.value,e.heading,c]);let f=L.useMemo(()=>({id:o,forceMount:i}),[i]);return L.createElement(F7.div,{ref:M7(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:d?void 0:!0},n&&L.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),t9(e,e=>L.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},L.createElement(q7.Provider,{value:f},e))))}),eae=L.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=L.useRef(null),a=$7(e=>!e.search);return!n&&!a?null:L.createElement(F7.div,{ref:M7(i,t),...r,"cmdk-separator":``,role:`separator`})}),tae=L.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=K7(),o=$7(e=>e.search),s=$7(e=>e.selectedItemId),c=W7();return L.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),L.createElement(F7.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)}})}),nae=L.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=L.useRef(null),o=L.useRef(null),s=$7(e=>e.selectedItemId),c=W7();return L.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)}}},[]),L.createElement(F7.div,{ref:M7(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},t9(e,e=>L.createElement(`div`,{ref:M7(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),rae=L.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return L.createElement(hR,{open:n,onOpenChange:r},L.createElement(yR,{container:o},L.createElement(xR,{"cmdk-overlay":``,className:i}),L.createElement(TR,{"aria-label":e.label,"cmdk-dialog":``,className:a},L.createElement(J7,{ref:t,...s}))))}),iae=L.forwardRef((e,t)=>$7(e=>e.filtered.count===0)?L.createElement(F7.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),aae=L.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return L.createElement(F7.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},t9(e,e=>L.createElement(`div`,{"aria-hidden":!0},e)))}),Y7=Object.assign(J7,{List:nae,Item:Qie,Input:tae,Group:$ie,Separator:eae,Dialog:rae,Empty:iae,Loading:aae});function oae(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function sae(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function X7(e){let t=L.useRef(e);return Z7(()=>{t.current=e}),t}var Z7=typeof window>`u`?L.useEffect:L.useLayoutEffect;function Q7(e){let t=L.useRef();return t.current===void 0&&(t.current=e()),t}function $7(e){let t=K7(),n=()=>e(t.snapshot());return L.useSyncExternalStore(t.subscribe,n,n)}function e9(e,t,n,r=[]){let i=L.useRef(),a=W7();return Z7(()=>{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(H7,s),i.current=s}),i}var cae=()=>{let[e,t]=L.useState(),n=Q7(()=>new Map);return Z7(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function lae(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function t9({asChild:e,children:t},n){return e&&L.isValidElement(t)?L.cloneElement(lae(t),{ref:t.ref},n(t.props.children)):n(t)}var uae={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function dae(){let e=gr(X),t=ME(),[n,r]=(0,L.useState)(``);if((0,L.useEffect)(()=>{e.showPalette&&r(``)},[e.showPalette]),!e.showPalette)return null;let i=$D(FE(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){Xh(e)}return(0,R.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,className:`fixed inset-0 z-[60] flex items-start justify-center bg-scrim-50 pt-[12vh]`,onMouseDown:e=>e.target===e.currentTarget&&s(),children:(0,R.jsxs)(Y7,{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,R.jsx)(Y7.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,R.jsxs)(Y7.List,{className:`max-h-[52vh] overflow-y-auto py-1.5`,children:[(0,R.jsx)(Y7.Empty,{className:`px-4 py-6 text-center text-sm text-muted`,children:`No matches.`}),(0,R.jsxs)(Y7.Group,{heading:`Actions`,className:`cmdk-group`,children:[(0,R.jsx)(n9,{value:`new thread create home`,onSelect:()=>c(()=>Ph()),children:`New thread`}),(0,R.jsx)(n9,{value:`queue todos inbox pending`,onSelect:()=>c(()=>{_g(X.drawers.map(e=>e.id)),X.view=`todos`}),children:`Queue`}),(0,R.jsx)(n9,{value:`open settings preferences`,onSelect:()=>c(()=>X.showSettings=!0),children:`Open settings`}),o&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(n9,{value:`open details drawer doc ${HD(o)}`,onSelect:()=>c(()=>{let e=vg();e&&qh(`doc`,e)}),children:`Open thread details`}),(0,R.jsxs)(n9,{value:`mark complete done ${HD(o)}`,onSelect:()=>c(()=>Y.markComplete({slug:o.id}).catch(()=>{})),children:[`Mark “`,HD(o),`” complete`]}),(0,R.jsxs)(n9,{value:`mark read ${HD(o)}`,onSelect:()=>c(()=>Y.markRead({slug:o.id}).catch(()=>{})),children:[`Mark “`,HD(o),`” read`]})]})]}),i.length>0&&(0,R.jsx)(Y7.Group,{heading:`Threads`,className:`cmdk-group`,children:i.map(e=>(0,R.jsxs)(n9,{value:`${HD(e)} ${e.id}`,onSelect:()=>c(()=>l(e.id)),children:[(0,R.jsx)(`span`,{className:`truncate`,children:HD(e)}),(0,R.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] text-muted-70`,children:e.id})]},e.id))})]})]})})}function n9({value:e,onSelect:t,children:n}){return(0,R.jsx)(Y7.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 r9=`Updating and restarting Frizz`,fae=`This may take a moment while the new build is being prepared. All of your threads will continue running normally.`,pae=`Frizz did not come back`;function mae(e){return`${e?`Nothing has answered for ${e}.`:`Nothing is answering.`} Restart Frizz from the terminal with npx frizz (or frizz, if it is installed globally). This page reconnects on its own once the board is back.`}function hae(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 gae({open:e,message:t,stalled:n=!1,silentFor:r}){let i=(0,L.useRef)(null),[a,o]=(0,L.useState)(!1),s=e&&!n;if((0,L.useEffect)(()=>{n||o(!1)},[n]),(0,L.useEffect)(()=>{if(!s)return;let e=document.activeElement;e instanceof HTMLElement&&e.blur(),i.current?.focus({preventScroll:!0});let t=e=>{hae(e)&&(e.preventDefault(),e.stopImmediatePropagation())};return window.addEventListener(`keydown`,t,{capture:!0}),()=>window.removeEventListener(`keydown`,t,{capture:!0})},[s]),!e)return null;if(n)return a?null:(0,R.jsx)(`div`,{className:`pointer-events-none fixed inset-x-0 top-6 z-[300] flex justify-center px-4`,children:(0,R.jsxs)(`div`,{role:`alert`,className:`pointer-events-auto w-[min(26rem,calc(100vw-2rem))] rounded-2xl border border-danger-fill/45 bg-elevated p-5 text-left shadow-2xl shadow-shadow-ink/60`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,R.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-danger-fill/15 text-danger-soft`,children:(0,R.jsx)(ov,{"aria-hidden":`true`,size:14,strokeWidth:2.25})}),(0,R.jsx)(`h2`,{className:`text-[13px] font-semibold tracking-[-0.01em] text-fg`,children:pae}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Dismiss`,onClick:()=>o(!0),className:`icon-hover-outline -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,R.jsx)(cv,{"aria-hidden":`true`,size:14,strokeWidth:2.25})})]}),(0,R.jsx)(`p`,{"aria-live":`polite`,className:`mt-2.5 text-[12px] leading-relaxed text-muted`,children:mae(r)})]})});let c=t?.trim()?t.trim():null;return(0,R.jsx)(`div`,{role:`alertdialog`,"aria-modal":`true`,"aria-label":r9,className:`fixed inset-0 z-[300] flex items-center justify-center bg-scrim-55 px-4 backdrop-blur-md backdrop-saturate-150`,children:(0,R.jsxs)(`div`,{ref:i,tabIndex:-1,className:`w-[min(26rem,calc(100vw-2rem))] rounded-2xl border border-border-strong bg-elevated p-6 text-center shadow-2xl shadow-shadow-ink/60 outline-none`,children:[(0,R.jsx)(`span`,{className:`mx-auto flex h-11 w-11 items-center justify-center rounded-full bg-fg/10 text-fg`,children:(0,R.jsx)(J_,{size:20,strokeWidth:2.25,className:`animate-spin`,"aria-hidden":`true`})}),(0,R.jsx)(`h2`,{className:`mt-4 text-[15px] font-semibold tracking-[-0.01em] text-fg`,children:r9}),(0,R.jsx)(`p`,{className:`mt-2 text-[12.5px] leading-relaxed text-muted`,children:fae}),c&&(0,R.jsx)(`p`,{"aria-live":`polite`,className:`mt-2 text-[11.5px] leading-relaxed text-muted-80`,children:c})]})})}var i9=!1;function _ae(){i9||(i9=!0,Z("Sign in to the GitHub CLI (`gh auth login`) to dispatch from issues/PRs.",{duration:6e3}))}function vae(){let e=gr(X),t=(0,L.useRef)({projectDir:null,hasBeenVisible:!1});(0,L.useEffect)(()=>{Y.board().then(xg).catch(()=>{})},[]);let n=Ax();(0,L.useEffect)(()=>YE((e,t)=>n(e,t)),[n]);let{data:r,dataUpdatedAt:i}=RU(),a=(0,L.useRef)(null),[o,s]=(0,L.useState)(bU),c=(0,L.useRef)(null),l=(0,L.useRef)(!1);(0,L.useEffect)(()=>{let e=r;if(e){let t=CU({state:X.controlPlaneState,message:X.controlPlaneMessage,attempt:X.controlPlaneRestartAttempt},e);X.controlPlaneState=t.state,X.controlPlaneMessage=t.message,X.controlPlaneRestartAttempt=t.attempt,c.current===null&&(c.current=_U(e))}if(s(t=>xU(t,{restarting:X.controlPlaneState===`restarting`,answered:e!=null,at:Date.now()})),!e||l.current)return;let t=sessionStorage.getItem(pU);if(TU({state:X.controlPlaneState,message:X.controlPlaneMessage,attempt:X.controlPlaneRestartAttempt},e)){if(t){sessionStorage.removeItem(pU),sessionStorage.removeItem(mU),l.current=!0,window.location.replace(t);return}if(vU(c.current,e)){l.current=!0,window.location.reload();return}}if(e.state===`failed`&&t){let t=sessionStorage.getItem(`frizz:update-restart-from-version`)??void 0;sessionStorage.removeItem(pU),sessionStorage.removeItem(mU),a.current!==e.message&&(a.current=e.message??`Update & Restart failed`,Z(`Update & Restart failed — ${gU(hU(t,e)).summary}`,{duration:7e3}))}},[r,i]);let u=e.drawers.length>0||e.showSettings||e.showNewThread||e.showGithubPicker||e.showPalette;(0,L.useEffect)(()=>{if(!u)return;let e=window.scrollY,t=document.body;return Hp(),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,Hp()??e)}},[u]);let d=ct({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet()});(0,L.useEffect)(()=>{X.notificationsEnabled=d.data?.notifications??!1},[d.data?.notifications]);let f=Wz();(0,L.useEffect)(()=>{f.data?.inRepo&&!f.data.authed&&_ae()},[f.data?.inRepo,f.data?.authed]),(0,L.useEffect)(()=>{function e(e){if(!(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=mg(),n=vg();t?.kind===`doc`?(e.preventDefault(),Fp(t.id)||X.drawers.pop()):n&&(e.preventDefault(),qh(`doc`,n))}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let p=ME(),m=Lg();(0,L.useEffect)(()=>{Zh()},[p,e.routeThreadSlug]),t.current=XE(t.current,p);let h=p!==null&&t.current.hasBeenVisible,g=p===null&&QE(tm()),_=t.current.hasBeenVisible;(0,L.useEffect)(()=>{p!==null&&ute(tm(),_)},[p,_]);let v=p?.projectLabel??p?.projectName;return(0,L.useEffect)(()=>{let e=window.matchMedia?.(`(display-mode: standalone)`).matches;document.title=e?v??`Frizz`:v?`${v} — Frizz`:`Frizz`},[v]),(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(gae,{open:e.controlPlaneState===`restarting`,message:e.controlPlaneMessage,stalled:o.stalled,silentFor:o.silentSince===null?void 0:GO(o.silentForMs)}),(0,R.jsxs)(`div`,{inert:e.controlPlaneState===`restarting`&&!o.stalled,className:`relative min-h-screen bg-bg text-fg text-sm`,children:[m?(0,R.jsx)(sJ,{}):(0,R.jsx)(R.Fragment,{children:(0,R.jsxs)(`div`,{className:`flex min-h-screen justify-center gap-[clamp(28px,3.4vw,52px)] px-5 max-[800px]:flex-col max-[800px]:justify-start max-[800px]:gap-0 max-[800px]:px-3`,children:[h&&(0,R.jsx)(hv,{label:`the sidebar`,children:(0,R.jsx)(aG,{})}),g&&(0,R.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,R.jsx)(`main`,{id:`workpane`,className:`w-[720px] max-w-[62vw] min-w-0 flex flex-col py-5 max-[800px]:w-full max-[800px]:max-w-none ${e.view===`todos`||!p?`min-h-screen`:``} ${e.view===`todos`?``:`rounded-lg border border-border bg-panel`}`,children:p?(0,R.jsxs)(hv,{label:`the queue`,resetKeys:[e.view],children:[e.view.startsWith(`status:`)&&(0,R.jsx)(RK,{status:e.view.slice(7)}),e.view===`todos`&&(0,R.jsx)(Mre,{})]}):(0,R.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,R.jsx)(`span`,{className:`block h-5 w-5 rounded-full border-2 border-muted/50 border-t-transparent animate-spin`})})})]})}),(0,R.jsx)(r7,{}),e.showSettings&&(0,R.jsx)(y7,{offerUpdate:!0}),e.showNewThread&&(0,R.jsx)(MH,{onClose:()=>{X.showNewThread=!1}}),e.showGithubPicker&&(0,R.jsx)(Qre,{onClose:Ih}),(0,R.jsx)(dae,{})]})]})}function a9(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 yae(e,t,n,r=48){let i=Math.round(t/r);return Math.max(0,Math.min(n-1,e+i))}function bae(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 o9(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 xae=`w-[57px]`,Sae=`max-[800px]:pl-0 pl-[57px]`;function Cae(e){let t=0;for(let n=0;n<e.length;n++)t=(t*31+e.charCodeAt(n))%360;return t}function wae(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 Tae(e){let t=e.iconVersion?`&v=${encodeURIComponent(e.iconVersion)}`:``;return`/_frizz/project-icon?id=${encodeURIComponent(e.id)}${t}`}function s9({project:e,size:t}){let[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(!1),o=Cae(e.id),s=e.iconStatus!==`none`,[c,l]=(0,L.useState)(!1),u=!s||c;return(0,R.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,R.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,R.jsx)(`span`,{style:{textBox:`trim-both cap alphabetic`},children:wae(e.name)})}),s&&!c&&(0,R.jsx)(`img`,{src:Tae(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 Eae=40;function c9(e,t){let n=[];return t&&n.push(`${t} running`),e&&n.push(`${e} in the queue`),n.join(`, `)}var Dae=`shadow-[0_0_0_0.5px_var(--color-bg)]`;function Oae(e){return e<10?`w-[16px]`:e<100?`w-[22px]`:`w-[28px]`}function kae(){return(0,R.jsx)(`span`,{"aria-hidden":!0,className:`frizz-rail-badge-ring absolute -inset-[2px] scale-[0.975] rounded-full text-accent-fill`})}function Aae({project:e,current:t,counts:n,index:r,drag:i,onPointerDown:a,onKeyDown:o}){let s=i?.fromIndex===r,c=n?.queued??0,l=n?.running??0,u=c+l,d=i?s?i.deltaY:bae(r,i.fromIndex,i.toIndex):0;return(0,R.jsx)(FP,{side:`right`,disabled:i!==null,label:e.stale?`${e.name} — directory is missing`:u?`${e.name} — ${c9(c,l)}`:e.name,children:(0,R.jsxs)(iC,{to:nm(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||Nae())&&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:d?`translateY(${d}px)`:void 0,transition:s?`none`:`transform 160ms ease`},children:[(0,R.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,R.jsx)(`span`,{className:`rounded-[30%] transition-[transform,opacity,box-shadow] duration-150 group-focus-visible:ring-1 group-focus-visible:ring-focus-ink-60 ${s?`scale-[1.12] opacity-100 shadow-lg shadow-shadow-ink/50`:`group-hover:scale-[1.06] ${t?``:`opacity-75 group-hover:opacity-100`}`} ${e.stale?`grayscale`:``}`,children:(0,R.jsx)(s9,{project:e,size:Eae})}),u?(0,R.jsxs)(`span`,{"aria-label":c9(c,l),"data-rail-count":u,"data-rail-running":l||void 0,className:`pointer-events-none absolute -bottom-[5px] right-[3px] flex`,children:[l?(0,R.jsx)(kae,{}):null,(0,R.jsx)(`span`,{className:`relative flex h-[16px] ${Oae(u)} items-center justify-center rounded-full border border-bg bg-accent-fill text-[10px] font-semibold leading-none proportional-nums text-on-accent ${l?Dae:``}`,children:(0,R.jsx)(`span`,{style:{textBox:`trim-both cap alphabetic`},children:u})})]}):null]})})}function jae({project:e,children:t}){let n=(0,L.useRef)(null),r=qe(),i=()=>r.invalidateQueries({queryKey:[`projectsList`]}),a=e=>Z(e instanceof Error?e.message:String(e),{duration:7e3}),o=pt({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=pt({mutationFn:()=>Y.projectIconClear({id:e.id}),onSuccess:()=>void i(),onError:a}),c=pt({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,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`input`,{ref:n,type:`file`,accept:Cp.map(e=>`.${e}`).join(`,`),className:`hidden`,onChange:e=>{let t=e.target.files?.[0];e.target.value=``,t&&o.mutate(t)}}),(0,R.jsxs)(KL,{onOpenChange:t=>{t&&Y.projectIconPickWarm({id:e.id}).catch(()=>{})},children:[(0,R.jsx)(qL,{asChild:!0,children:t}),(0,R.jsx)(JL,{children:(0,R.jsxs)(YL,{align:`start`,sideOffset:6,className:`z-[220] min-w-[190px] rounded-lg border border-border bg-panel p-1 shadow-xl shadow-shadow-ink/40`,children:[(0,R.jsx)(QL,{className:l,onSelect:()=>c.mutate(),children:o.isPending?`Uploading…`:`Choose an icon…`}),(0,R.jsx)(QL,{className:l,onSelect:()=>s.mutate(),children:e.iconIsCustom?`Use the detected icon`:`Look for an icon again`})]})})]})]})}var Mae=4,l9=0;function Nae(){return Date.now()-l9<250}function Pae(e,t){let n=ct({queryKey:[`projectsRailCounts`],queryFn:()=>Y.projectsRailCounts(),refetchInterval:5e3}),r=gr(X).board,i=nG(hW(r?FE(r.threads):[])),a=e!==void 0&&r?i:void 0,o=a&&{queued:a.filter(nO).length,running:a.filter(xf).length,asks:a.filter(Cf).length},s=e===void 0?void 0:t.find(t=>t.slug===e)?.id;return e=>e.id===s&&o?o:n.data?.[e.id]}var u9=0;function d9(){let e=Date.now();e-u9<1e4||(u9=e,Y.projectPickWarm({}).catch(()=>{u9=0}))}function Fae(){let e=qe(),{data:t}=ct({queryKey:[`projectsList`],queryFn:()=>Y.projectsList()}),n=tm(),[r,i]=(0,L.useState)(!1),a=Ax(),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(null),u=(0,L.useRef)(null),d=pt({mutationFn:()=>Y.projectPick({}),onSuccess:t=>{t.kind===`picked`?(e.invalidateQueries({queryKey:[`projectsList`]}),a(nm(t.project.slug))):t.kind===`unavailable`&&a(`/`)},onSettled:()=>i(!1)}),f=pt({mutationFn:e=>Y.projectsReorder({ids:e}),onSuccess:async()=>{await e.invalidateQueries({queryKey:[`projectsList`]}),l(null)},onError:()=>l(null)}),p=c??t??[],m=Pae(n,p),[h,g]=(0,L.useState)(!1);(0,L.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,L.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=o9(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:yae(t,c,i.length),deltaY:c},s(o)},m=0,h=e=>{if(!a){if(Math.abs(e.clientY-r)<Mae)return;a=!0,n.setPointerCapture(e.pointerId)}e.preventDefault();let t=e.clientY;cancelAnimationFrame(c);let i=()=>{d(t),u.current&&o9(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;l9=Date.now();let e=a9(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,L.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=a9(p,t,n);l(r),f.mutate(r.map(e=>e.id)),requestAnimationFrame(()=>{u.current?.querySelectorAll(`a`)[n]?.focus()})},[p,f]);return(0,R.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 ${xae}`,children:[(0,R.jsx)(FP,{side:`right`,label:`All projects`,children:(0,R.jsx)(iC,{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-focus-ink-60`,children:(0,R.jsx)(O_,{size:17})})}),(0,R.jsx)(`hr`,{className:`my-2.5 w-6 shrink-0 border-0 border-t border-border`}),(0,R.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-2`,children:p.map((e,t)=>(0,R.jsx)(Aae,{project:e,index:t,current:e.slug===n,counts:m(e),drag:o,onPointerDown:_,onKeyDown:v},e.id))}),(0,R.jsx)(FP,{side:`right`,label:`Add a project`,children:(0,R.jsx)(`button`,{type:`button`,disabled:r,onPointerEnter:d9,onFocus:d9,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-focus-ink-60 disabled:opacity-50`,children:(0,R.jsx)(q_,{size:16})})})]})}var f9=76;function p9(e,t){return t&&e.startsWith(`${t}/`)?`~${e.slice(t.length)}`:e}var m9=`flex flex-col gap-1 rounded-lg border px-3 py-2.5 outline-none transition-colors focus-visible:ring-1 focus-visible:ring-focus-ink-60`,h9=34;function Iae({project:e,home:t}){let n=SO(e.lastOpenedAt),[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(!1);return(0,R.jsxs)(`div`,{className:`group/card relative`,children:[(0,R.jsxs)(iC,{to:nm(e.slug),className:`${m9} flex-row items-center gap-3 border-border bg-panel pr-9 group-hover/card:border-border-strong group-hover/card:bg-panel-2 ${e.stale?`opacity-60`:``}`,children:[(0,R.jsx)(`span`,{className:`shrink-0 ${e.stale?`grayscale`:``}`,children:(0,R.jsx)(s9,{project:e,size:h9})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium text-fg`,children:e.name}),e.slug===e.name?null:(0,R.jsxs)(`span`,{className:`max-w-[45%] shrink-0 truncate font-mono text-[11px] text-muted-70`,children:[`/`,e.slug]})]}),(0,R.jsx)(`span`,{className:`truncate text-[11px] text-muted`,title:e.path,children:p9(e.path,t)}),(0,R.jsx)(`span`,{className:`truncate text-[11px] text-muted-70`,children:e.stale?`Directory is missing`:n?`Opened ${n}`:`Never opened`})]})]}),(0,R.jsx)(jae,{project:e,children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`Change the icon for ${e.name}`,style:{width:h9,height:h9},className:`icon-hover-outline absolute left-[13px] top-1/2 flex -translate-y-1/2 items-center justify-center rounded-[30%] bg-black/75 text-on-overlay opacity-0 outline-none transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:ring-1 focus-visible:ring-focus-ink-60 data-[state=open]:opacity-100`,children:(0,R.jsx)(k_,{size:16,strokeWidth:1.75})})}),(0,R.jsx)(Lae,{onRename:()=>o(!0),onDelete:()=>i(!0),children:(0,R.jsx)(`button`,{type:`button`,"aria-label":`More actions for ${e.name}`,className:`icon-hover-outline 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-focus-ink-60 group-hover/card:opacity-100 data-[state=open]:opacity-100`,children:(0,R.jsx)(h_,{size:15})})}),a?(0,R.jsx)(zae,{project:e,home:t,onClose:()=>o(!1)}):null,r?(0,R.jsx)(Bae,{project:e,home:t,onClose:()=>i(!1)}):null]})}function Lae({onRename:e,onDelete:t,children:n}){return(0,R.jsxs)(KL,{children:[(0,R.jsx)(qL,{asChild:!0,children:n}),(0,R.jsx)(JL,{children:(0,R.jsxs)(YL,{align:`end`,sideOffset:6,className:`z-[220] min-w-[170px] rounded-lg border border-border bg-panel p-1 shadow-xl shadow-shadow-ink/40`,children:[(0,R.jsx)(QL,{className:`cursor-default rounded px-2 py-1.5 text-[12.5px] text-fg outline-none data-[highlighted]:bg-panel-2`,onSelect:e,children:`Rename…`}),(0,R.jsx)(QL,{className:`cursor-default rounded px-2 py-1.5 text-[12.5px] text-danger outline-none data-[highlighted]:bg-danger-fill/10 data-[highlighted]:text-danger-soft`,onSelect:t,children:`Delete project…`})]})})]})}function Rae(e){return e.split(/[\\/]/u).filter(Boolean).pop()??e}function zae({project:e,home:t,onClose:n}){let[r,i]=(0,L.useState)(e.name),[a,o]=(0,L.useState)(!1),s=(0,L.useRef)(null),c=qe(),l=pt({mutationFn:()=>Y.projectRename({id:e.id,name:r.trim(),renameDirectory:a}),onSuccess:t=>{c.invalidateQueries({queryKey:[`projectsList`]}),Z(`Renamed ${e.name} to ${t.name}`),n()}}),u=l.error instanceof Error?l.error.message:l.error?String(l.error):null,d=r.trim(),f=Rae(e.path),p=e.path.slice(0,e.path.length-f.length),m=f===e.name&&d.length>0&&d!==f,h=Yc(d);return(0,R.jsx)(Oq,{open:!0,onOpenChange:e=>{!e&&!l.isPending&&n()},title:`Rename ${e.name}`,className:`w-[440px] max-w-[92vw]`,onOpenAutoFocus:e=>{e.preventDefault(),s.current?.focus(),s.current?.select()},footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,onClick:n,disabled:l.isPending,className:`button-outline 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,R.jsxs)(`button`,{type:`submit`,form:`rename-project`,disabled:l.isPending||d.length===0,className:`flex items-center gap-1.5 rounded-md border border-accent-fill bg-accent-fill px-3 py-1.5 text-[12.5px] font-medium text-on-accent outline-none hover:brightness-110 focus-visible:ring-1 focus-visible:ring-focus-accent-60 disabled:opacity-50`,children:[l.isPending&&(0,R.jsx)(M_,{size:12,className:`animate-spin`}),m&&a?`Rename project and folder`:`Rename project`]})]}),children:(0,R.jsxs)(`form`,{id:`rename-project`,onSubmit:e=>{e.preventDefault(),!l.isPending&&d.length>0&&l.mutate()},className:`flex flex-col gap-3 p-4 text-[12.5px] leading-relaxed text-muted`,children:[(0,R.jsx)(`input`,{ref:s,value:r,onChange:e=>i(e.target.value),spellCheck:!1,"aria-label":`Project name`,className:`w-full rounded-md border bg-bg px-2.5 py-2 text-[12.5px] text-fg outline-none placeholder:text-muted-50 focus-visible:ring-1 focus-visible:ring-focus-accent-60 ${u?`border-danger-fill/60`:`border-border-strong`}`}),(0,R.jsxs)(`p`,{children:[`Its address becomes`,` `,(0,R.jsxs)(`span`,{className:`font-mono text-[11.5px] text-fg/80`,children:[`/project/`,h]}),h===e.slug?`.`:(0,R.jsxs)(R.Fragment,{children:[` — links to `,(0,R.jsxs)(`span`,{className:`font-mono text-[11.5px]`,children:[`/project/`,e.slug]}),` stop working.`]})]}),m?(0,R.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,R.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked),className:`mt-[3px] accent-[var(--color-accent)]`}),(0,R.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{children:`Also rename the folder`}),(0,R.jsx)(`span`,{className:`text-[11.5px] text-muted-80`,children:a?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:`font-mono text-[11px]`,children:p9(e.path,t)}),` becomes `,(0,R.jsx)(`span`,{className:`font-mono text-[11px]`,children:p9(p+d,t)}),`. Running workers keep going.`]}):`Left off, the folder keeps its name and only what Frizz calls it changes.`})]})]}):null,u?(0,R.jsx)(`p`,{className:`text-[11.5px] text-danger`,children:u}):null]})})}function Bae({project:e,home:t,onClose:n}){let[r,i]=(0,L.useState)(!1),a=qe(),o=pt({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,R.jsx)(Oq,{open:!0,onOpenChange:e=>{!e&&!o.isPending&&n()},title:`Delete ${e.name}?`,className:`w-[440px] max-w-[92vw]`,footer:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`button`,{type:`button`,onClick:n,disabled:o.isPending,className:`button-outline 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,R.jsxs)(`button`,{type:`button`,onClick:()=>o.mutate(),disabled:o.isPending,className:`button-outline flex items-center gap-1.5 rounded-md bg-danger-button/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,R.jsx)(M_,{size:12,className:`animate-spin`}),r?`Delete project and threads`:`Delete project`]})]}),children:(0,R.jsxs)(`div`,{className:`flex flex-col gap-3 p-4 text-[12.5px] leading-relaxed text-muted`,children:[(0,R.jsxs)(`p`,{children:[`Frizz forgets this project. The folder itself is not touched — nothing inside`,` `,(0,R.jsx)(`span`,{className:`font-mono text-[11.5px] text-fg/80`,children:p9(e.path,t)}),` is changed or removed.`]}),(0,R.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,R.jsx)(`input`,{type:`checkbox`,checked:r,onChange:e=>i(e.target.checked),className:`mt-[3px] accent-[var(--color-accent)]`}),(0,R.jsxs)(`span`,{className:`flex flex-col gap-0.5`,children:[(0,R.jsx)(`span`,{children:`Also delete its threads and history`}),(0,R.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,R.jsx)(`p`,{className:`text-[11.5px] text-danger`,children:s}):null]})})}function Vae({hero:e,pending:t,onClick:n}){return(0,R.jsxs)(`button`,{type:`button`,onPointerEnter:d9,onFocus:d9,onClick:n,disabled:t,className:`${m9} items-center justify-center gap-1.5 border-dashed border-border-strong bg-transparent text-muted hover:border-accent hover:text-fg ${e?`min-h-[118px]`:`min-h-[74px]`}`,children:[(0,R.jsx)(`span`,{className:`text-[17px] leading-none text-muted-70`,children:`+`}),(0,R.jsx)(`span`,{className:`text-[12.5px]`,children:t?`Choosing a folder…`:`Add a project`}),e?(0,R.jsx)(`span`,{className:`text-[11px] text-muted-70`,children:`Point Frizz at a folder on this machine`}):null]})}function g9({reason:e,proposed:t,onClose:n}){let[r,i]=(0,L.useState)(t??``),a=Ax(),o=qe(),s=pt({mutationFn:e=>Y.projectAdd({path:e}),onSuccess:e=>{o.invalidateQueries({queryKey:[`projectsList`]}),a(nm(e.slug))}}),c=s.error instanceof Error?s.error.message:s.error?String(s.error):null;return(0,R.jsx)(hR,{open:!0,onOpenChange:e=>{!e&&!s.isPending&&n()},children:(0,R.jsxs)(yR,{children:[(0,R.jsx)(xR,{className:`fixed inset-0 z-[210] bg-scrim-30 backdrop-blur-md backdrop-saturate-150`}),(0,R.jsxs)(TR,{"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-shadow-ink/50 outline-none`,children:[(0,R.jsx)(AR,{className:`mb-1 text-[14px] font-medium`,children:t?`Add this folder as a project?`:`Add a project`}),(0,R.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,R.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),s.isPending||s.mutate(r)},children:[(0,R.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-focus-ink-60 ${c?`border-danger-fill/60`:`border-border-strong`}`}),c?(0,R.jsx)(`p`,{className:`mt-1.5 text-[11.5px] text-danger`,children:c}):null,(0,R.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,R.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-focus-ink-60 disabled:opacity-50`,children:t?`Not now`:`Cancel`}),(0,R.jsx)(`button`,{type:`submit`,disabled:s.isPending||r.trim().length===0,className:`rounded-md border border-accent bg-accent-fill px-3 py-1.5 text-[12.5px] font-medium text-on-accent outline-none hover:brightness-110 focus-visible:ring-1 focus-visible:ring-focus-ink-60 disabled:opacity-50`,children:s.isPending?`Adding…`:t?`Add it`:`Add project`})]})]})]})]})})}function Hae({projects:e,home:t}){let{showSettings:n}=gr(X),r=ct({queryKey:[`projectsRailCounts`],queryFn:()=>Y.projectsRailCounts(),refetchInterval:5e3});return(0,R.jsxs)(`div`,{"data-mobile-projects-page":!0,className:`min-h-dvh bg-bg`,children:[(0,R.jsx)(`header`,{className:`sticky top-0 z-10 border-b border-border/70 bg-bg pt-[env(safe-area-inset-top)]`,children:(0,R.jsxs)(`div`,{className:`flex h-[56px] items-center pl-[18px] pr-[5px]`,children:[(0,R.jsx)(`h1`,{className:`m-0 min-w-0 flex-1 truncate text-[16.5px] font-semibold tracking-[-0.01em] text-fg`,children:`Projects`}),(0,R.jsx)(`button`,{"aria-label":`Settings`,"data-mobile-settings":!0,onClick:()=>X.showSettings=!0,className:`flex size-[44px] shrink-0 items-center justify-center rounded-full text-fg/85 active:bg-hover-strong`,children:(0,R.jsx)(Q_,{size:21,strokeWidth:1.9})})]})}),e.length===0?(0,R.jsx)(`p`,{className:`m-0 px-10 pt-24 text-center text-[15px] text-muted`,children:`No projects yet. Add one from Frizz on a computer.`}):(0,R.jsx)(`ul`,{className:`m-0 list-none p-0 pb-[env(safe-area-inset-bottom)]`,children:e.map(e=>{let n=r.data?.[e.id];return(0,R.jsx)(`li`,{children:(0,R.jsxs)(iC,{to:nm(e.slug),"data-mobile-project-row":e.slug,className:`flex min-h-[62px] items-center gap-3 border-b border-border/70 px-[18px] py-2 active:bg-hover ${e.stale?`opacity-60`:``}`,children:[(0,R.jsx)(`span`,{className:`shrink-0 ${e.stale?`grayscale`:``}`,children:(0,R.jsx)(s9,{project:e,size:h9})}),(0,R.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,R.jsx)(`span`,{className:`truncate text-[15.5px] font-medium leading-[20px] text-fg`,children:e.name}),(0,R.jsx)(`span`,{className:`truncate font-mono-keep text-[12.5px] leading-[17px] text-muted`,title:e.path,children:e.stale?`Directory is missing`:p9(e.path,t)})]}),n&&(n.asks>0||n.running>0)?(0,R.jsxs)(`span`,{"data-mobile-project-counts":!0,className:`flex shrink-0 items-baseline gap-2.5 whitespace-nowrap text-[13px] text-muted`,children:[n.asks>0?(0,R.jsx)(`span`,{className:`font-bold tabular-nums text-accent`,children:n.asks}):null,n.running>0?(0,R.jsxs)(`span`,{className:`tabular-nums`,children:[n.running,` working`]}):null]}):null]})},e.id)})}),n?(0,R.jsx)(y7,{}):null]})}function Uae(){let[e]=(0,L.useState)(()=>{let e=new URLSearchParams(location.search).get(`add`)??void 0;return e&&history.replaceState(null,``,location.pathname),e}),[t,n]=(0,L.useState)(e?{}:null);(0,L.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=Ax(),i=qe(),a=pt({mutationFn:()=>Y.projectPick({}),onSuccess:e=>{if(e.kind!==`cancelled`){if(e.kind===`unavailable`){n({reason:e.reason});return}i.invalidateQueries({queryKey:[`projectsList`]}),r(nm(e.project.slug))}},onError:e=>n({reason:e instanceof Error?e.message:String(e)})}),{data:o,isPending:s,error:c}=ct({queryKey:[`projectsList`],queryFn:()=>Y.projectsList()}),l=o?.[0]?.path.match(/^(\/(?:Users|home)\/[^/]+)\//u)?.[1],u=o!==void 0&&o.length===0;return Lg()&&o?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Hae,{projects:o,home:l}),t?(0,R.jsx)(g9,{reason:t.reason,proposed:e,onClose:()=>n(null)}):null]}):(0,R.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,R.jsxs)(`div`,{className:`m-auto flex w-full flex-col items-center`,children:[(0,R.jsxs)(`div`,{className:`mb-6 flex flex-col items-center gap-2.5 text-center`,children:[(0,R.jsx)(`img`,{src:`/favicon.svg`,width:f9,height:f9,alt:``,className:`rounded-[17px]`}),(0,R.jsx)(`h1`,{className:`text-[19px] font-semibold tracking-[-0.01em] text-fg`,children:u?`Welcome to Frizz`:`Select a project`}),u?(0,R.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,R.jsxs)(`p`,{className:`text-[13px] text-muted`,children:[`Could not read the project registry: `,String(c)]}):s?(0,R.jsx)(`p`,{className:`text-[13px] text-muted`,children:`Loading…`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`grid w-full gap-2 ${u?`max-w-[360px] grid-cols-1`:`max-w-[900px] grid-cols-[repeat(auto-fill,minmax(272px,1fr))]`}`,children:[(0,R.jsx)(Vae,{hero:u,pending:a.isPending,onClick:()=>a.mutate()}),o.map(e=>(0,R.jsx)(Iae,{project:e,home:l},e.id))]}),u?(0,R.jsxs)(`p`,{className:`mt-6 text-[11.5px] text-muted-70`,children:[`Or run`,` `,(0,R.jsx)(`code`,{className:`rounded border border-border bg-panel px-1.5 py-0.5 font-mono text-muted`,children:`frizz`}),` `,`inside a repository, and this page offers to add it.`]}):null]})]}),t?(0,R.jsx)(g9,{reason:t.reason,proposed:e,onClose:()=>n(null)}):null]})}var _9=64,v9=12,y9=_9-v9-4,b9=16,Wae=`#4a9eff`,x9,S9,C9=!1;function Gae(){return x9??=[...document.querySelectorAll(`link[rel~="icon"]`)].map(e=>({link:e,href:e.getAttribute(`href`)??``,type:e.getAttribute(`type`),sizes:e.getAttribute(`sizes`)})),x9}function Kae(e){let t=document.createElement(`canvas`);t.width=t.height=_9;let n=t.getContext(`2d`);return n.drawImage(e,0,0,_9,_9),n.globalCompositeOperation=`destination-out`,n.beginPath(),n.arc(y9,b9,16,0,Math.PI*2),n.fill(),n.globalCompositeOperation=`source-over`,n.fillStyle=Wae,n.beginPath(),n.arc(y9,b9,v9,0,Math.PI*2),n.fill(),t.toDataURL(`image/png`)}function qae(e){return S9??=new Promise((t,n)=>{let r=e.find(e=>e.type===`image/svg+xml`)??e[0];if(!r)return n(Error(`no favicon link`));let i=new Image;i.onload=()=>t(Kae(i)),i.onerror=()=>n(Error(`favicon did not load`)),i.src=r.href}),S9}function w9(e){C9=e;let t=Gae();if(!e){for(let{link:e,href:n,type:r,sizes:i}of t)e.href=n,r===null?e.removeAttribute(`type`):e.type=r,i===null?e.removeAttribute(`sizes`):e.setAttribute(`sizes`,i);return}qae(t).then(e=>{if(C9)for(let{link:n}of t)n.type=`image/png`,n.removeAttribute(`sizes`),n.href=e}).catch(()=>{S9=void 0})}function T9(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 E9(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 Jae({slug:e,path:t,active:n}){let r=KT(t),i=IE(t),a=ct({...XT(t),refetchInterval:i?!1:ZT}),o=a.data?.path??t,s=a.data?.markdown??``,{front:c,body:l}=$5(r?s:``),[u,d]=(0,L.useState)(r?`rendered`:`source`),f=JT(o),p=SX(l,{baseDir:f,asDocument:!0}),m=rZ(p),h=rZ((0,L.useMemo)(()=>u===`source`?eE(o,s):``,[s,o,u])),g=(0,L.useRef)(null),_=(0,L.useRef)(null),v=(0,L.useRef)(null);gZ(g,p);let y=BZ(g,p,f),b=xh(o),x=PE(),S=wH(),C=TH(e);return(0,L.useEffect)(()=>{if(!n)return;let t=()=>document.querySelector(`main[data-standalone-thread] textarea`);function r(e,t){return e?document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0?t.length:Math.min(e.selectionStart??t.length,t.length):t.length}function i(n){if(!(n.metaKey||n.ctrlKey)||n.altKey||n.shiftKey||n.key.toLowerCase()!==`i`)return;let i=v.current,a=window.getSelection(),c=a&&!a.isCollapsed&&a.rangeCount>0?a.getRangeAt(0):null,l=!!(i&&c&&i.contains(c.commonAncestorContainer)),u=l?a.toString():``;if(!l||!u.trim()){n.preventDefault(),n.stopPropagation();let e=t();if(!e)return;document.activeElement!==e&&e.selectionStart===0&&e.selectionEnd===0&&e.value.length>0&&e.setSelectionRange(e.value.length,e.value.length),e.focus();return}n.preventDefault(),n.stopPropagation();let d=null,f=_.current;if(f&&f.contains(c.commonAncestorContainer)){let e=T9(f,c.startContainer,c.startOffset),t=T9(f,c.endContainer,c.endOffset);e!==null&&t!==null&&(d={startLine:E9(s,Math.min(e,t)),endLine:E9(s,Math.max(0,Math.max(e,t)-1))})}else d=zte(s,u);let p=t(),m=CH.followUp(S,e,C),{prose:h,attachments:g}=oz(bH.get(m)),y=Lte(cz({path:o,...d??{}}),X.composerContext[e]??[],h),b=Rte(h,r(p,h),y);bH.set(m,sz(b.prose,g.map(e=>e.path))),dg(e,{token:y,path:o,text:u,...d??{}}),a.removeAllRanges(),requestAnimationFrame(()=>{let e=t();e&&(e.setSelectionRange(b.caret,b.caret),e.focus())})}return window.addEventListener(`keydown`,i,!0),()=>window.removeEventListener(`keydown`,i,!0)},[n,e,o,s,S,C]),(0,R.jsxs)(`div`,{ref:v,"data-file-viewer-panel":!0,className:`flex h-full min-h-0 flex-col`,children:[(0,R.jsx)(fv,{title:b,subtitle:Eh(o,x),onClose:lg,actions:r?(0,R.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,R.jsx)(`button`,{type:`button`,onClick:()=>d(e),"aria-pressed":u===e,className:`rounded px-2 py-0.5 transition-colors ${u===e?`bg-panel-2 text-fg`:`text-muted hover:text-fg`}`,children:e===`rendered`?`Rendered`:`Source`},e))}):null}),(0,R.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-y-auto px-5 py-4`,children:[a.isLoading?(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`Loading…`}):a.error?(0,R.jsxs)(`div`,{className:`text-[13px] text-danger-90`,children:[`Couldn’t read this file: `,a.error.message]}):u===`source`?s?(0,R.jsx)(`pre`,{ref:_,className:`hljs whitespace-pre-wrap break-words bg-transparent font-mono-keep text-[12px] leading-5 text-fg/90`,style:{tabSize:2},dangerouslySetInnerHTML:h}):(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}):p?(0,R.jsxs)(R.Fragment,{children:[c&&(0,R.jsx)(n7,{source:c}),(0,R.jsx)(`div`,{ref:g,className:`md-body`,dangerouslySetInnerHTML:m}),y]}):(0,R.jsx)(`div`,{className:`text-[13px] text-muted`,children:`This file is empty.`}),!a.isLoading&&!a.error&&a.data?.truncated&&(0,R.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,R.jsxs)(`div`,{className:`shrink-0 flex items-center justify-between gap-3 border-t border-border/60 bg-panel px-5 pt-3`,style:e7,children:[(0,R.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,R.jsx)(t7,{path:o})]})]})}function D9(){return{dirs:new Map,files:new Map}}function Yae(e,t,n){let r=e.replace(/[\\/]+$/,``);if(t){let e=Th(t,r);if(e!==null)return hh(e)}if(n){let e=Th(n,r);if(e!==null)return[`~`,...hh(e)]}let i=hh(r);return/^[\\/]/.test(r)?[`/`,...i]:i}var O9=(e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`,numeric:!0});function k9(e,t,n=``){let r=[];for(let i of[...e.dirs.keys()].sort(O9)){let a=e.dirs.get(i),o=i;for(;a.files.size===0&&a.dirs.size===1;){let[e,t]=[...a.dirs.entries()][0];o=o===`/`?`/${e}`:`${o}/${e}`,a=t}let s=n===``||n===`/`?`${n}${o}`:`${n}/${o}`;r.push({kind:`dir`,name:o,path:s,depth:t,children:k9(a,t+1,s)})}for(let n of[...e.files.keys()].sort(O9))r.push({kind:`file`,name:n,depth:t,file:e.files.get(n)});return r}function Xae(e,t,n){let r=D9();for(let i of e){let e=Yae(i.path,t,n);if(e.length===0)continue;let a=r;for(let t of e.slice(0,-1)){let e=a.dirs.get(t);e||(e=D9(),a.dirs.set(t,e)),a=e}a.files.set(e[e.length-1],i)}return k9(r,0)}function Zae(e){let t=[],n=e=>{for(let r of e)t.push(r),r.kind===`dir`&&n(r.children)};return n(e),t}var Qae=/(?:^|[\s;&|(])(?:rm|mv|unlink|git\s+(?:rm|mv|clean|checkout|restore|reset|stash|apply))\b/;function $ae(e){if(e.edit||e.edits?.length)return!0;let t=qG(e.name);return xK.has(t)?!0:t!==`bash`||!e.command?!1:Qae.test(e.command)||ru(e.command).length>0}function eoe(e){for(let t=e.length-1;t>=0;t--){let n=e[t],r=n.tools??[];for(let e=r.length-1;e>=0;e--)if($ae(r[e]))return`${n.sourceId??n.at??`#${t}`}:${e}:${r[e].status??``}`}}var A9=10;function toe({name:e,depth:t}){return(0,R.jsxs)(`div`,{"data-file-dir":e,className:`flex items-baseline pr-2 text-[12px] leading-5 text-muted-70`,style:{paddingLeft:8+t*A9},children:[(0,R.jsx)(`span`,{className:`flex shrink-0`,children:(0,R.jsx)(y_,{size:12,className:`${m6} text-muted-45`})}),(0,R.jsx)(`span`,{className:`ml-[5px] min-w-0 truncate`,title:e,children:e})]})}function noe({files:e}){let t=NE(),n=PE();return(0,R.jsx)(`div`,{"data-edited-file-tree":!0,className:`flex flex-col gap-y-px`,children:Zae(Xae(e,t,n)).map(e=>e.kind===`dir`?(0,R.jsx)(toe,{name:e.name,depth:e.depth},`d:${e.path}`):(0,R.jsx)(roe,{file:e.file,name:e.name,depth:e.depth,homeDir:n},e.file.path))})}function roe({file:e,name:t,depth:n,homeDir:r}){let i=qe();return(0,R.jsx)(k6,{testKind:`file`,testId:e.path,mark:(0,R.jsx)(__,{size:12,className:`${m6} -mr-[2px] text-muted-60`}),name:t,indent:n*A9,onOpen:()=>YK(e.path),onPrewarm:()=>nE(i,e.path),title:Eh(e.path,r),status:(0,R.jsxs)(R.Fragment,{children:[(e.added??0)>0&&(0,R.jsxs)(`span`,{style:{color:ZO.fgSuccess},children:[`+`,e.added]}),(e.added??0)>0&&(e.removed??0)>0&&` `,(e.removed??0)>0&&(0,R.jsxs)(`span`,{style:{color:ZO.fgDanger},children:[`−`,e.removed]})]})})}function ioe({link:e}){let t=qe(),n=PE();return e.kind===`link`?(0,R.jsx)(k6,{testKind:`link`,testId:e.id,mark:(0,R.jsx)(g_,{size:12,className:`${m6} text-muted-60`}),name:e.label,href:e.target,title:e.target,status:aoe(e.target)}):(0,R.jsx)(k6,{testKind:`link`,testId:e.id,mark:(0,R.jsx)(v_,{size:12,className:`${m6} text-muted-60`}),name:e.label,onOpen:()=>YK(e.target),onPrewarm:()=>nE(t,e.target),title:Eh(e.target,n),status:null})}function aoe(e){try{return new URL(e).host||e}catch{return e}}var ooe=1500;function soe(e,t,n,r){let i=qe(),a=(0,L.useRef)({slug:e,loaded:t,changeKey:n,turnLive:r}),o=(0,L.useRef)(void 0);(0,L.useEffect)(()=>()=>clearTimeout(o.current),[e]),(0,L.useEffect)(()=>{let s=a.current;if(a.current={slug:e,loaded:t,changeKey:n,turnLive:r},s.slug!==e||!s.loaded)return;let c=n!==void 0&&n!==s.changeKey,l=s.turnLive&&!r;!c&&!l||(clearTimeout(o.current),o.current=setTimeout(()=>{i.refetchQueries({queryKey:[`transcript`,e],exact:!0,type:`active`})},ooe))},[i,e,t,n,r])}function coe({thread:e}){let t=LO(),n=RE(e.id,{poll:!1}),r=n.data?.editedFiles??[],i=(0,L.useMemo)(()=>eoe(n.data?.messages??[]),[n.data?.messages]);soe(e.id,n.data!==void 0,i,e.runtime===`running`||e.runtime===`spawning`);let a=(e.subAgents??[]).filter(Au),o=(0,L.useMemo)(()=>W8(n.data?.messages??[]),[n.data?.messages]),s=yk(e.bgShells??[],o),c=e.state!==`archived`,l=(e.watches??[]).filter(e=>c&&e.kind===`github`&&e.state===`armed`),u=l.filter(e=>e.subject!==`issue`),d=l.filter(e=>e.subject===`issue`),f=(e.watches??[]).filter(e=>c&&e.kind===`timer`&&e.state===`armed`),{railFilesCollapsed:p}=gr(RD),m=[{head:`Sub-agents`,rows:a.map(n=>(0,R.jsx)(V6,{agent:n,slug:e.id,now:t,onDismiss:RP(e.id,n)},n.id??n.label))},{head:`Background shells`,rows:s.map(n=>(0,R.jsx)(R6,{shell:n,slug:e.id,now:t,onDismiss:RP(e.id,n,`SHELL`)},n.id??n.label))},{head:`Pull requests`,rows:u.map(e=>(0,R.jsx)(M6,{watch:e},e.id))},{head:`Issues`,rows:d.map(e=>(0,R.jsx)(M6,{watch:e},e.id))},{head:`Timers`,rows:f.map(e=>(0,R.jsx)(z6,{watch:e,now:t},e.id))},{head:`Files and links`,rows:(e.links??[]).map(e=>(0,R.jsx)(ioe,{link:e},e.id))},{head:`Edited files`,rows:r.length>0?[(0,R.jsx)(noe,{files:r},`tree`)]:[],count:r.length,collapsed:p,onToggle:()=>RD.railFilesCollapsed=!RD.railFilesCollapsed}].filter(e=>e.rows.length>0);return(0,R.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,R.jsx)(`div`,{className:`my-auto py-6`,children:m.length===0?(0,R.jsx)(`div`,{className:`text-[11.5px] text-muted-50`,children:`Nothing running, watched or edited yet.`}):(0,R.jsx)(K6,{groups:m,divider:!1})})})}function j9(){let e=gr(X),t=e.toast,[n,r]=(0,L.useState)(!1),i=e.drawers.some(e=>!e.closing);return(0,L.useEffect)(()=>{if(!t||(r(!0),t.sticky))return;let e=setTimeout(()=>r(!1),t.duration??(t.link||t.action?5e3:1600));return()=>clearTimeout(e)},[t?.id]),t?(0,R.jsx)(`div`,{className:`pointer-events-none fixed right-4 z-[70] flex justify-end ${i?`bottom-20`:`bottom-[calc(var(--queue-dock-inset,0px)+1rem)]`}`,children:(0,R.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-shadow-ink/40 transition-all duration-200 ease-out ${n?`translate-y-0 opacity-100`:`translate-y-8 opacity-0`}`,children:[t.spinner&&(0,R.jsx)(M_,{size:13,className:`animate-spin text-muted`}),t.text,t.link&&(0,R.jsx)(`button`,{onClick:()=>{qh(`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}),t.action&&(0,R.jsx)(`button`,{"data-toast-action":!0,onClick:()=>{let e=t.action;X.toast=null,e.run()},className:`${n?`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.action.label})]})}):null}var M9=`max(50%, calc(100% - 720px))`,loe={"--full-thread":`min(720px, ${M9})`,"--full-thread-narrow":`min(720px, 100%)`,"--full-pane":M9,"--full-gutter":`max(0px, calc((100% - min(720px, ${M9}) - 340px) / 2))`};function N9(e,t){return`${nm(e)}${cm(t,`/`)}`}function uoe({slug:e}){let t=gr(X).filePanels.some(e=>!e.closing),n=ME(),r=Xp(n,e),i=r.kind===`found`?r.thread:void 0;n?.projectDir,(0,L.useEffect)(()=>{Y.board().then(xg).catch(()=>{})},[]),(0,L.useEffect)(()=>{let e=window.matchMedia?.(`(min-width: ${ree}px)`);if(!e)return;let t=()=>{X.splitFileViewer=e.matches};return t(),e.addEventListener(`change`,t),()=>{e.removeEventListener(`change`,t),X.splitFileViewer=!1,X.filePanels=[]}},[]);let a=i?.runtime===`turn-idle`||i?.runtime===`exited`||i?.runtime===`none`;(0,L.useEffect)(()=>{!i||!a||Y.threadSeen({slug:e}).catch(()=>{})},[a,e,i?.lastActivityAt]),(0,L.useEffect)(()=>{let t=n?.projectLabel??n?.projectName,r=i?HD(i):e;document.title=t?`${r} · ${t} — Frizz`:`${r} · Frizz`},[n?.projectLabel,n?.projectName,e,i]);let o=i!==void 0&&nO(i);return(0,L.useEffect)(()=>(w9(o),()=>w9(!1)),[o]),(0,R.jsx)(PP,{children:(0,R.jsxs)(`div`,{className:`h-dvh min-h-0 bg-bg text-sm text-fg`,children:[(0,R.jsx)(`div`,{className:`h-full w-full overflow-hidden`,children:(0,R.jsxs)(`div`,{className:`flex h-full w-full justify-center transition-transform duration-200 ease-out motion-reduce:transition-none split:justify-start`,style:{...loe,transform:t?`translateX(calc(-1 * var(--full-gutter)))`:void 0},children:[(0,R.jsx)(`div`,{className:`hidden w-[var(--full-gutter)] shrink-0 split:block`,"aria-hidden":`true`}),(0,R.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,R.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,role:`status`,"aria-label":`Loading thread`,children:(0,R.jsx)(`span`,{className:`block h-5 w-5 animate-spin rounded-full border-2 border-muted/50 border-t-transparent`})}):r.kind===`missing`?(0,R.jsx)(poe,{slug:e}):(0,R.jsx)(K8,{slug:e,virtualized:!0,showReturnToQueue:!0})}),i?(0,R.jsx)(doe,{slug:e,thread:i}):(0,R.jsx)(`div`,{className:`hidden w-[var(--full-pane)] shrink-0 split:block`,"aria-hidden":`true`})]})}),(0,R.jsx)(r7,{onEscapeAtRest:()=>f4(e)}),(0,R.jsx)(j9,{})]})})}function doe({slug:e,thread:t}){let n=gr(X);return(0,R.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,R.jsx)(`div`,{inert:n.filePanels.length>0?!0:void 0,className:`h-full min-h-0`,children:(0,R.jsx)(coe,{thread:t})}),n.filePanels.map((t,r)=>(0,R.jsx)(foe,{slug:e,path:t.path,closing:!!t.closing,active:r===n.filePanels.length-1&&!t.closing&&n.splitFileViewer},t.id))]})}function foe({slug:e,path:t,closing:n,active:r}){let[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(null);return(0,L.useLayoutEffect)(()=>{o.current?.getBoundingClientRect();let e=()=>a(!0),t=requestAnimationFrame(e),n=window.setTimeout(e,120);return()=>{cancelAnimationFrame(t),window.clearTimeout(n)}},[]),(0,L.useEffect)(()=>{r&&o.current?.focus({preventScroll:!0})},[r]),(0,R.jsx)(`aside`,{ref:o,tabIndex:-1,"data-file-viewer-slot":!0,"aria-hidden":!r,inert:!r,className:`absolute inset-0 outline-none transition-[translate,opacity] duration-200 ease-out motion-reduce:transition-none ${i&&!n?`translate-x-0 opacity-100`:`translate-x-full opacity-0`}`,children:(0,R.jsx)(`div`,{className:`flex h-full min-h-0 flex-col overflow-hidden bg-panel`,children:(0,R.jsx)(Jae,{slug:e,path:t,active:r})})})}function poe({slug:e}){let{data:t,isPending:n}=ct({queryKey:[`threadLocate`,e],queryFn:()=>Y.threadLocate({slug:e})});return(0,L.useEffect)(()=>{t?.length===1&&location.replace(N9(t[0].projectSlug,e))},[t,e]),(0,R.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4 px-6 text-center`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h1`,{className:`font-medium text-fg`,children:`Thread unavailable`}),n?(0,R.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Looking for “`,e,`” in your other projects…`]}):t&&t.length>0?(0,R.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`“`,e,`” lives in `,t.length===1?`another project`:`these projects`,` — opening it there.`]}):(0,R.jsxs)(`p`,{className:`mt-1 text-muted`,children:[`Thread “`,e,`” was not found in any project on this machine.`]})]}),t&&t.length>1?(0,R.jsx)(`div`,{className:`flex flex-wrap justify-center gap-2`,children:t.map(t=>(0,R.jsx)(`a`,{href:N9(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,R.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 moe={OPEN_ISSUE:{bg:ZO.bgSuccessEmphasis,icon:l_,label:`Open`},CLOSED_ISSUE:{bg:ZO.bgDoneEmphasis,icon:s_,label:`Closed`},NOT_PLANNED:{bg:ZO.bgNeutralEmphasis,icon:d_,label:`Closed as not planned`},OPEN_PR:{bg:ZO.bgSuccessEmphasis,icon:T_,label:`Open`},DRAFT:{bg:ZO.bgNeutralEmphasis,icon:w_,label:`Draft`},MERGED:{bg:ZO.bgDoneEmphasis,icon:S_,label:`Merged`},CLOSED_PR:{bg:ZO.bgDangerEmphasis,icon:C_,label:`Closed`}};function hoe(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 P9(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 goe(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 ${P9(e,t)}`:DO(e,t)??``:``}function _oe(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 F9={add:ZO.fgSuccess,del:ZO.fgDanger},voe={add:{backgroundColor:ZO.bgSuccessEmphasis,borderColor:ZO.bgSuccessEmphasis},del:{backgroundColor:ZO.bgDangerEmphasis,borderColor:ZO.bgDangerEmphasis},none:{backgroundColor:`color-mix(in srgb, var(--gh-bg-neutral-emphasis) 20%, transparent)`,borderColor:`var(--gh-neutral-border)`}};function I9({additions:e,deletions:t}){return(0,R.jsxs)(`div`,{className:`flex items-baseline gap-1.5 text-[12px] tabular-nums`,children:[(0,R.jsxs)(`span`,{"data-gh-add":!0,style:{color:F9.add},children:[`+`,e.toLocaleString()]}),(0,R.jsxs)(`span`,{"data-gh-del":!0,style:{color:F9.del},children:[`−`,t.toLocaleString()]}),(0,R.jsx)(`span`,{"data-gh-blocks":!0,className:`ml-0.5 inline-flex gap-[1px] self-baseline translate-y-[calc(4px_-_0.5cap)]`,children:_oe(e,t).map((e,t)=>(0,R.jsx)(`span`,{className:`size-[8px] rounded-[2px] border`,style:voe[e]},t))})]})}function yoe({card:e}){let t=hoe(e),n=t?moe[t]:void 0;if(!n)return null;let r=n.icon;return(0,R.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-[color:var(--gh-on-emphasis)]`,style:{backgroundColor:n.bg},children:[(0,R.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,R.jsx)(`span`,{"data-gh-pill-label":!0,children:n.label})]})}function boe({name:e,color:t}){let n=f7(t);return(0,R.jsx)(`span`,{className:`inline-flex items-center rounded-full border px-2 py-[1px] text-[11px] font-medium`,style:{color:n.foreground,backgroundColor:n.background,borderColor:n.border},children:e})}var xoe=/`([^`\n]+)`/g;function Soe(e,t){if(!t)return[e];let n=[],r=0;for(let t of e.matchAll(xoe))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 L9({text:e,code:t,className:n}){return(0,R.jsx)(`div`,{className:n,children:Soe(e,t).map((e,t)=>typeof e==`string`?e:(0,R.jsx)(`code`,{className:`rounded-[3px] bg-panel-2 px-[3px] py-[1px] font-mono-keep text-[0.92em]`,children:e.code},t))})}var Coe=new Set([`avatars.githubusercontent.com`,`camo.githubusercontent.com`]);function woe(e){if(e)try{let t=new URL(e);return t.protocol===`https:`&&Coe.has(t.hostname)?e:void 0}catch{return}}function R9({card:e,nowMs:t}){let n=woe(e.authorAvatar),r=e.authorLogin??e.authorName??`Someone`,i=e.kind===`commit`?`committed`:e.kind===`pr`?`opened this pull request`:`opened this issue`,a=goe(e.at,t);return(0,R.jsxs)(`div`,{className:`flex items-center gap-2 border-t border-border px-3 py-2 text-[12px] text-muted`,children:[n?(0,R.jsx)(`img`,{"data-gh-avatar":!0,src:n,alt:``,className:`size-[18px] shrink-0 rounded-full`}):(0,R.jsx)(`span`,{"data-gh-avatar":!0,className:`size-[18px] shrink-0 rounded-full bg-border`}),(0,R.jsxs)(`span`,{"data-gh-byline-text":!0,className:`truncate`,children:[(0,R.jsx)(`span`,{className:`text-fg`,children:r}),` `,i,` `,a]})]})}var z9=`w-[360px] max-w-[min(360px,calc(100vw-24px))] leading-normal`;function Toe({card:e,nowMs:t=Date.now()}){let n=e.additions!==void 0&&e.deletions!==void 0;if(e.kind===`commit`)return(0,R.jsxs)(`div`,{className:z9,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline gap-2 px-3 pt-3 pb-2.5`,children:[(0,R.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,R.jsx)(x_,{className:`size-[1em] text-muted`,"aria-hidden":!0})}),(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.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,R.jsx)(L9,{text:e.body,code:!1,className:`mt-1.5 line-clamp-6 text-[12px] text-muted`}):null,n?(0,R.jsx)(`div`,{className:`mt-2.5`,children:(0,R.jsx)(I9,{additions:e.additions,deletions:e.deletions})}):null]})]}),(0,R.jsx)(R9,{card:e,nowMs:t})]});let r=e.ref.slice(e.ref.indexOf(`#`));return(0,R.jsxs)(`div`,{className:z9,children:[(0,R.jsxs)(`div`,{className:`px-3 pt-3 pb-3`,children:[(0,R.jsxs)(`div`,{className:`text-[12px] text-muted`,children:[(0,R.jsx)(`span`,{className:`underline decoration-border underline-offset-2`,children:e.repo}),e.at?` on ${P9(e.at,t)}`:``]}),(0,R.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,R.jsx)(`span`,{className:`font-normal text-muted`,children:r})]}),(0,R.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,R.jsx)(yoe,{card:e}),n?(0,R.jsx)(I9,{additions:e.additions,deletions:e.deletions}):null]})]}),e.body||e.labels.length>0?(0,R.jsxs)(`div`,{className:`border-t border-border px-3 py-2.5`,children:[e.body?(0,R.jsx)(L9,{text:e.body,code:!0,className:`line-clamp-2 text-[12px] text-muted`}):null,e.labels.length>0?(0,R.jsx)(`div`,{className:`flex flex-wrap gap-1 ${e.body?`mt-2`:``}`,children:e.labels.map(e=>(0,R.jsx)(boe,{name:e.name,color:e.color},e.name))}):null]}):null,(0,R.jsx)(R9,{card:e,nowMs:t})]})}var Eoe=250,Doe=180;function Ooe(e){let t=e.getClientRects()[0]??e.getBoundingClientRect();return{top:t.top,left:t.left,width:t.width,height:t.height}}function koe(){let[e,t]=(0,L.useState)(null),n=(0,L.useRef)(void 0),r=(0,L.useRef)(void 0),i=(0,L.useRef)(!1),a=(0,L.useCallback)(()=>{clearTimeout(n.current),clearTimeout(r.current),n.current=void 0,r.current=void 0},[]),o=(0,L.useCallback)(()=>{clearTimeout(r.current),r.current=setTimeout(()=>{i.current||t(null)},Doe)},[]);return(0,L.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),eh([o]),n.current=setTimeout(()=>t({ref:o,rect:Ooe(a)}),Eoe)))},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,L.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,L.useEffect)(()=>a,[a]),(0,R.jsxs)(CV,{open:e!==null,children:[(0,R.jsx)(TV,{asChild:!0,children:(0,R.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,R.jsx)(EV,{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,R.jsx)(Aoe,{refKey:e.ref})}):null]})}function Aoe({refKey:e}){let t=(0,L.useSyncExternalStore)(tee,()=>Xm(e),()=>Xm(e));return(0,L.useEffect)(()=>{Zm(Xm(e))&&ih(e)},[e]),t?.card?(0,R.jsx)(Toe,{card:t.card}):(0,R.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 B9=`frizz-project-rail`;function joe(){try{return localStorage.getItem(B9)===`shown`}catch{return!1}}function Moe(e){try{localStorage.setItem(B9,e?`shown`:`hidden`)}catch{}}function Noe(){Ox();let e=ct({queryKey:[`settingsGet`],queryFn:()=>Y.settingsGet(),placeholderData:ae}).data?.projectRail;return(0,L.useEffect)(()=>{e!==void 0&&Moe(e===!0)},[e]),e===void 0?joe():e===!0}var V9=`/project/:slug`;function Poe(){W9();let e=Noe();return(0,R.jsxs)(PP,{children:[e?(0,R.jsx)(Fae,{}):null,(0,R.jsx)(`div`,{className:e?Sae:void 0,children:(0,R.jsx)(uS,{})}),(0,R.jsx)(j9,{}),(0,R.jsx)(VZ,{}),(0,R.jsx)(koe,{})]})}function H9(e){let t=dm(gr(X).board?.projectSlug),[n,r]=(0,L.useState)(null),i=(Pee(e)||n!==null&&n.slug===e)&&t;return(0,L.useLayoutEffect)(()=>{i||(bg(),Jee(),r({slug:e}))},[e,i]),i}function U9(){let{slug:e,thread:t}=Px(),n=H9(e);return Ioe(),(0,L.useState)(()=>eg(t)),n?(0,R.jsx)(vae,{},e??`__launching__`):null}function Foe(){return(0,R.jsx)(Uae,{})}function Ioe(){let e=Ox();(0,L.useEffect)(()=>{UE(im(e.pathname))},[e.pathname])}function W9(){let e=Ax();(0,L.useEffect)(()=>(KE((t,n)=>e(t,n)),()=>KE(null)),[e])}function G9(){let{thread:e,slug:t}=Px();W9();let n=H9(t);return(0,L.useState)(()=>{X.drawers.length>0&&(X.drawers=[])}),$h(e),n?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(uoe,{slug:e}),(0,R.jsx)(j9,{}),(0,R.jsx)(VZ,{})]}):null}var Loe=[{index:!0,element:(0,R.jsx)(U9,{})},{path:`thread/:thread`,element:(0,R.jsx)(U9,{})},{path:`status/:status`,element:(0,R.jsx)(U9,{})}],Roe=eC([{path:`/thread/:thread/full`,element:(0,R.jsx)(G9,{})},{path:`${V9}/thread/:thread/full`,element:(0,R.jsx)(G9,{})},{element:(0,R.jsx)(Poe,{}),children:[{path:`/`,element:(0,R.jsx)(Foe,{})},{path:`/thread/:thread`,element:(0,R.jsx)(U9,{})},{path:`/status/:status`,element:(0,R.jsx)(U9,{})},{path:V9,children:Loe},{path:`*`,element:(0,R.jsx)(U9,{})}]}]),zoe=24,Boe=6,Voe=700,K9=new Map,q9=null,J9=null;function Hoe(e){return!Array.isArray(e)||e.length!==2?null:e[0]===`transcript`&&typeof e[1]==`string`?e[1]:null}function Y9(e){return X.board?.threads.find(t=>t.id===e)?.lastActivityAt}function Uoe(){let e=[...K9.entries()].filter(([,e])=>e.observers>0),t=new Set(e.slice(-24).map(([e])=>e));for(let[e,n]of K9){if(n.observers<=0){n.live&&(n.live=!1,OE(e)),K9.delete(e);continue}t.has(e)?!n.live&&!n.queued&&(n.queued=!0):(n.queued=!1,n.live&&(n.live=!1,OE(e)))}X9()}function X9(){J9||[...K9.values()].some(e=>e.queued)&&(J9=setTimeout(()=>{J9=null;let e=0,t=[...K9.values()].filter(e=>e.live).length;for(let[n,r]of K9){if(e>=Boe||t>=zoe)break;r.queued&&(r.queued=!1,!(r.observers<=0||r.live)&&(r.live=!0,t++,r.lastActivityAt=Y9(n),DE(n),e++))}X9()},Voe))}function Woe(){if(q9)for(let[e,t]of K9){if(t.observers<=0)continue;let n=Y9(e);if(n===t.lastActivityAt)continue;t.lastActivityAt=n;let r=X.socketTranscriptFallbacks[e];t.live&&X.socketTranscripts&&!r||q9.refetchQueries({queryKey:[`transcript`,e],exact:!0,type:`active`})}}function Goe(e){q9||(q9=e,e.getQueryCache().subscribe(e=>{let t=Hoe(e.query.queryKey);if(!t||e.type!==`observerAdded`&&e.type!==`observerRemoved`)return;let n=e.query.getObserversCount(),r=K9.get(t);e.type===`observerAdded`?(K9.delete(t),K9.set(t,{observers:n,live:r?.live??!1,queued:r?.queued??!1,lastActivityAt:r?r.lastActivityAt:Y9(t)})):r&&(r.observers=n),Uoe()}),pr(X,Woe))}function Koe(){document.documentElement.dataset.font=`sans`,document.body.style.fontFamily=`system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif`;try{localStorage.removeItem(`frizz-font`)}catch{}}function qoe(){let e=e=>{if(e.button!==0||e.defaultPrevented)return;let t=e.target instanceof Element?e.target.closest(`.${ST}`):null;t&&(e.preventDefault(),e.stopPropagation(),Yoe(t))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)}function Joe(e){return e.closest(`.md-code`)?.querySelector(`pre code`)??null}async function Yoe(e){let t=Joe(e);if(!t)return;let n=(t.textContent??``).replace(/\n$/,``);if(n){try{await eH(n)}catch(e){Z(`Could not copy code: ${e.message.slice(0,100)}`,{duration:7e3});return}Xoe(e)}}var Z9=new WeakMap;function Xoe(e){e.classList.add(CT),e.title=`Copied`;let t=Z9.get(e);t!==void 0&&window.clearTimeout(t),Z9.set(e,window.setTimeout(()=>{e.classList.remove(CT),e.title=wT,Z9.delete(e)},n8))}function Zoe(e){return/Macintosh/.test(e)&&/\bChrome\/15[56]\./.test(e)}function Qoe(e){return t=>{if(t.defaultPrevented)return;let n=t.target?.tagName;if(n!==`TEXTAREA`&&n!==`INPUT`)return;let r=t.clipboardData;if(!r||r.types.includes(`Files`))return;let i=r.getData(`text/plain`).replace(/\r\n?/g,`
|
|
336
|
+
`);i&&e(i)&&t.preventDefault()}}function $oe(){if(!Zoe(navigator.userAgent))return()=>{};let e=Qoe(e=>document.execCommand(`insertText`,!1,e));return document.addEventListener(`paste`,e),()=>document.removeEventListener(`paste`,e)}var ese=/^\/thread\/([a-z0-9][a-z0-9-]*)\/?$/;function tse(){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=tm(n);if(r&&r!==tm())return;let i=ese.exec(im(n));i&&(e.preventDefault(),e.stopPropagation(),Xh(i[1]))};return document.addEventListener(`click`,e),()=>document.removeEventListener(`click`,e)}var nse=new Set([`projectsList`,`projectsRailCounts`,`threadLocate`,`dispatchPreferencesGet`,`supervisorStatus`]);function rse(e){let t=e[0];return typeof t==`string`&&nse.has(t)?M(e):M([`project:${tm()??``}`,...e])}var Q9=typeof window<`u`&&window.location.pathname.endsWith(`/settings-formatting-fixture.html`),ise=typeof window<`u`?lm(im()):null;Q9||Dg(),!Q9&&!ise&&WE();var $9=new Ue({defaultOptions:{queries:{retry:!1,refetchOnWindowFocus:!1,queryKeyHashFn:rse}}});Q9||(j2(),Yee($9),Goe($9),BU($9),Koe(),T3(),KK(),qoe(),$oe(),tse()),Q9||(0,mt.createRoot)(document.getElementById(`root`)).render((0,R.jsx)(Je,{client:$9,children:(0,R.jsx)(yv,{children:(0,R.jsx)(oS,{router:Roe})})}));export{o as n,c as r,MS as t};
|